@imgly/pdf-importer 0.1.0-rc.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +23 -4
- package/dist/browser.d.cts +11054 -0
- package/dist/browser.d.ts +10780 -26
- package/dist/browser.js +12 -12
- package/dist/node.cjs +15 -0
- package/dist/node.d.cts +11054 -0
- package/dist/node.d.ts +10780 -26
- package/dist/node.js +11 -11
- package/package.json +30 -20
package/dist/browser.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var n0=Object.create;var Vi=Object.defineProperty;var s0=Object.getOwnPropertyDescriptor;var r0=Object.getOwnPropertyNames;var i0=Object.getPrototypeOf,o0=Object.prototype.hasOwnProperty;var a0=(o,t)=>()=>(o&&(t=o(o=0)),t);var l0=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),c0=(o,t)=>{for(var e in t)Vi(o,e,{get:t[e],enumerable:!0})},u0=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of r0(t))!o0.call(o,r)&&r!==e&&Vi(o,r,{get:()=>t[r],enumerable:!(s=s0(t,r))||s.enumerable});return o};var Pc=(o,t,e)=>(e=o!=null?n0(i0(o)):{},u0(t||!o||!o.__esModule?Vi(e,"default",{value:o,enumerable:!0}):e,o));var ru={};c0(ru,{AbortException:()=>py,AnnotationEditorLayer:()=>gy,AnnotationEditorParamsType:()=>my,AnnotationEditorType:()=>yy,AnnotationEditorUIManager:()=>by,AnnotationLayer:()=>vy,AnnotationMode:()=>Jr,ColorPicker:()=>xy,DOMSVGFactory:()=>Sy,DrawLayer:()=>Ay,FeatureTest:()=>Ty,GlobalWorkerOptions:()=>Cy,ImageKind:()=>Ey,InvalidPDFException:()=>wy,MissingPDFException:()=>ky,OPS:()=>Iy,OutputScale:()=>Ry,PDFDataRangeTransport:()=>Py,PDFDateString:()=>Oy,PDFWorker:()=>Ly,PasswordResponses:()=>My,PermissionFlag:()=>Dy,PixelsPerInch:()=>Fy,RenderingCancelledException:()=>_y,TextLayer:()=>Ny,TouchManager:()=>Uy,UnexpectedResponseException:()=>By,Util:()=>Gy,VerbosityLevel:()=>Hy,XfaLayer:()=>jy,build:()=>Vy,createValidAbsoluteUrl:()=>$y,fetchData:()=>zy,getDocument:()=>Wy,getFilenameFromUrl:()=>Xy,getPdfFilenameFromUrl:()=>Yy,getXfaPageViewport:()=>Ky,isDataScheme:()=>Zy,isPdfFile:()=>Qy,noContextMenu:()=>Jy,normalizeUnicode:()=>qy,setLayerDimensions:()=>tb,shadow:()=>eb,stopEvent:()=>nb,version:()=>sb});function Mt(o){var t=Dc[o];if(t!==void 0)return t.exports;var e=Dc[o]={exports:{}};return v0[o].call(e.exports,e,e.exports,Mt),e.exports}function E0(o){Number.isInteger(o)&&(zr=o)}function w0(){return zr}function Wr(o){zr>=$r.INFOS&&console.log(`Info: ${o}`)}function wt(o){zr>=$r.WARNINGS&&console.log(`Warning: ${o}`)}function Vt(o){throw new Error(o)}function te(o,t){o||Vt(t)}function k0(o){switch(o?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function I0(o,t=null,e=null){if(!o)return null;try{if(e&&typeof o=="string"&&(e.addDefaultProtocol&&o.startsWith("www.")&&o.match(/\./g)?.length>=2&&(o=`http://${o}`),e.tryConvertEncoding))try{o=L0(o)}catch{}let s=t?new URL(o,t):new URL(o);if(k0(s))return s}catch{}return null}function Pt(o,t,e,s=!1){return Object.defineProperty(o,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}function Zc(o){(typeof o!="object"||o?.length===void 0)&&Vt("Invalid argument for bytesToString");let t=o.length,e=8192;if(t<e)return String.fromCharCode.apply(null,o);let s=[];for(let r=0;r<t;r+=e){let a=Math.min(r+e,t),c=o.subarray(r,a);s.push(String.fromCharCode.apply(null,c))}return s.join("")}function Xr(o){typeof o!="string"&&Vt("Invalid argument for stringToBytes");let t=o.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=o.charCodeAt(s)&255;return e}function R0(o){return String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255)}function va(o){let t=Object.create(null);for(let[e,s]of o)t[e]=s;return t}function P0(){let o=new Uint8Array(4);return o[0]=1,new Uint32Array(o.buffer,0,1)[0]===1}function O0(){try{return new Function(""),!0}catch{return!1}}function L0(o){return decodeURIComponent(escape(o))}function M0(o){return Wi||(Wi=/([\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,Fc=new Map([["\uFB05","\u017Ft"]])),o.replaceAll(Wi,(t,e,s)=>e?e.normalize("NFKC"):Fc.get(s))}function D0(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let o=new Uint8Array(32);return crypto.getRandomValues(o),Zc(o)}function F0(o){return Uint8Array.prototype.toBase64?o.toBase64():btoa(Zc(o))}async function Yr(o,t="text"){if(fs(o,document.baseURI)){let e=await fetch(o);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{let r=new XMLHttpRequest;r.open("GET",o,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(r.status===200||r.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(r.response);return}e(r.responseText);return}s(new Error(r.statusText))}},r.send(null)})}function Kr(o){let t=o.length,e=0;for(;e<t&&o[e].trim()==="";)e++;return o.substring(e,e+5).toLowerCase()==="data:"}function Sa(o){return typeof o=="string"&&/\.pdf$/i.test(o)}function _0(o){return[o]=o.split(/[#?]/,1),o.substring(o.lastIndexOf("/")+1)}function N0(o,t="document.pdf"){if(typeof o!="string")return t;if(Kr(o))return wt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,r=e.exec(o),a=s.exec(r[1])||s.exec(r[2])||s.exec(r[3]);if(a&&(a=a[0],a.includes("%")))try{a=s.exec(decodeURIComponent(a))[0]}catch{}return a||t}function fs(o,t){try{let{protocol:e}=t?new URL(o,t):new URL(o);return e==="http:"||e==="https:"}catch{return!1}}function He(o){o.preventDefault()}function Ee(o){o.preventDefault(),o.stopPropagation()}function U0(o,{scale:t=1,rotation:e=0}){let{width:s,height:r}=o.attributes.style,a=[0,0,parseInt(s),parseInt(r)];return new ms({viewBox:a,userUnit:1,scale:t,rotation:e})}function Aa(o){if(o.startsWith("#")){let t=parseInt(o.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return o.startsWith("rgb(")?o.slice(4,-1).split(",").map(t=>parseInt(t)):o.startsWith("rgba(")?o.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(wt(`Not a valid color format: "${o}"`),[0,0,0])}function B0(o){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let e of o.keys()){t.style.color=e;let s=window.getComputedStyle(t).color;o.set(e,Aa(s))}t.remove()}function Wt(o){let{a:t,b:e,c:s,d:r,e:a,f:c}=o.getTransform();return[t,e,s,r,a,c]}function Xe(o){let{a:t,b:e,c:s,d:r,e:a,f:c}=o.getTransform().invertSelf();return[t,e,s,r,a,c]}function kn(o,t,e=!1,s=!0){if(t instanceof ms){let{pageWidth:r,pageHeight:a}=t.rawDims,{style:c}=o,u=ne.isCSSRoundSupported,f=`var(--scale-factor) * ${r}px`,g=`var(--scale-factor) * ${a}px`,m=u?`round(down, ${f}, var(--scale-round-x, 1px))`:`calc(${f})`,y=u?`round(down, ${g}, var(--scale-round-y, 1px))`:`calc(${g})`;!e||t.rotation%180===0?(c.width=m,c.height=y):(c.width=y,c.height=m)}s&&o.setAttribute("data-main-rotation",t.rotation)}function mr(o,t,e){for(let s of e)t.addEventListener(s,o[s].bind(o))}function Nc(){}function be(o){if(o instanceof Ke||o instanceof gs||o instanceof wn||o instanceof fr||o instanceof Kn||o instanceof ps)return o;switch(o instanceof Error||typeof o=="object"&&o!==null||Vt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),o.name){case"AbortException":return new Ke(o.message);case"InvalidPDFException":return new gs(o.message);case"MissingPDFException":return new wn(o.message);case"PasswordException":return new fr(o.message,o.code);case"UnexpectedResponseException":return new Kn(o.message,o.status);case"UnknownErrorException":return new ps(o.message,o.details)}return new ps(o.message,o.toString())}async function Qc(o){let e=await process.getBuiltinModule("fs").promises.readFile(o);return new Uint8Array(e)}function go(o,t){if(!t)return;let e=t[2]-t[0],s=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],e,s),o.clip(r)}function Xi(o,t,e,s,r,a,c,u){let f=t.coords,g=t.colors,m=o.data,y=o.width*4,v;f[e+1]>f[s+1]&&(v=e,e=s,s=v,v=a,a=c,c=v),f[s+1]>f[r+1]&&(v=s,s=r,r=v,v=c,c=u,u=v),f[e+1]>f[s+1]&&(v=e,e=s,s=v,v=a,a=c,c=v);let S=(f[e]+t.offsetX)*t.scaleX,T=(f[e+1]+t.offsetY)*t.scaleY,w=(f[s]+t.offsetX)*t.scaleX,I=(f[s+1]+t.offsetY)*t.scaleY,k=(f[r]+t.offsetX)*t.scaleX,L=(f[r+1]+t.offsetY)*t.scaleY;if(T>=L)return;let M=g[a],N=g[a+1],F=g[a+2],B=g[c],G=g[c+1],$=g[c+2],z=g[u],J=g[u+1],et=g[u+2],nt=Math.round(T),xt=Math.round(L),vt,St,W,K,pt,ft,X,gt;for(let Z=nt;Z<=xt;Z++){if(Z<I){let j=Z<T?0:(T-Z)/(T-I);vt=S-(S-w)*j,St=M-(M-B)*j,W=N-(N-G)*j,K=F-(F-$)*j}else{let j;Z>L?j=1:I===L?j=0:j=(I-Z)/(I-L),vt=w-(w-k)*j,St=B-(B-z)*j,W=G-(G-J)*j,K=$-($-et)*j}let tt;Z<T?tt=0:Z>L?tt=1:tt=(T-Z)/(T-L),pt=S-(S-k)*tt,ft=M-(M-z)*tt,X=N-(N-J)*tt,gt=F-(F-et)*tt;let ct=Math.round(Math.min(vt,pt)),st=Math.round(Math.max(vt,pt)),Y=y*Z+ct*4;for(let j=ct;j<=st;j++)tt=(vt-j)/(vt-pt),tt<0?tt=0:tt>1&&(tt=1),m[Y++]=St-(St-ft)*tt|0,m[Y++]=W-(W-X)*tt|0,m[Y++]=K-(K-gt)*tt|0,m[Y++]=255}}function G0(o,t,e){let s=t.coords,r=t.colors,a,c;switch(t.type){case"lattice":let u=t.verticesPerRow,f=Math.floor(s.length/u)-1,g=u-1;for(a=0;a<f;a++){let m=a*u;for(let y=0;y<g;y++,m++)Xi(o,e,s[m],s[m+1],s[m+u],r[m],r[m+1],r[m+u]),Xi(o,e,s[m+u+1],s[m+1],s[m+u],r[m+u+1],r[m+1],r[m+u])}break;case"triangles":for(a=0,c=s.length;a<c;a+=3)Xi(o,e,s[a],s[a+1],s[a+2],r[a],r[a+1],r[a+2]);break;default:throw new Error("illegal figure")}}function H0(o){switch(o[0]){case"RadialAxial":return new mo(o);case"Mesh":return new yo(o);case"Dummy":return new bo}throw new Error(`Unknown IR type: ${o[0]}`)}function j0({src:o,srcPos:t=0,dest:e,width:s,height:r,nonBlackColor:a=4294967295,inverseDecode:c=!1}){let u=ne.isLittleEndian?4278190080:255,[f,g]=c?[a,u]:[u,a],m=s>>3,y=s&7,v=o.length;e=new Uint32Array(e.buffer);let S=0;for(let T=0;T<r;T++){for(let I=t+m;t<I;t++){let k=t<v?o[t]:255;e[S++]=k&128?g:f,e[S++]=k&64?g:f,e[S++]=k&32?g:f,e[S++]=k&16?g:f,e[S++]=k&8?g:f,e[S++]=k&4?g:f,e[S++]=k&2?g:f,e[S++]=k&1?g:f}if(y===0)continue;let w=t<v?o[t++]:255;for(let I=0;I<y;I++)e[S++]=w&1<<7-I?g:f}return{srcPos:t,destPos:S}}function $0(o,t){if(o._removeMirroring)throw new Error("Context is already forwarding operations.");o.__originalSave=o.save,o.__originalRestore=o.restore,o.__originalRotate=o.rotate,o.__originalScale=o.scale,o.__originalTranslate=o.translate,o.__originalTransform=o.transform,o.__originalSetTransform=o.setTransform,o.__originalResetTransform=o.resetTransform,o.__originalClip=o.clip,o.__originalMoveTo=o.moveTo,o.__originalLineTo=o.lineTo,o.__originalBezierCurveTo=o.bezierCurveTo,o.__originalRect=o.rect,o.__originalClosePath=o.closePath,o.__originalBeginPath=o.beginPath,o._removeMirroring=()=>{o.save=o.__originalSave,o.restore=o.__originalRestore,o.rotate=o.__originalRotate,o.scale=o.__originalScale,o.translate=o.__originalTranslate,o.transform=o.__originalTransform,o.setTransform=o.__originalSetTransform,o.resetTransform=o.__originalResetTransform,o.clip=o.__originalClip,o.moveTo=o.__originalMoveTo,o.lineTo=o.__originalLineTo,o.bezierCurveTo=o.__originalBezierCurveTo,o.rect=o.__originalRect,o.closePath=o.__originalClosePath,o.beginPath=o.__originalBeginPath,delete o._removeMirroring},o.save=function(){t.save(),this.__originalSave()},o.restore=function(){t.restore(),this.__originalRestore()},o.translate=function(s,r){t.translate(s,r),this.__originalTranslate(s,r)},o.scale=function(s,r){t.scale(s,r),this.__originalScale(s,r)},o.transform=function(s,r,a,c,u,f){t.transform(s,r,a,c,u,f),this.__originalTransform(s,r,a,c,u,f)},o.setTransform=function(s,r,a,c,u,f){t.setTransform(s,r,a,c,u,f),this.__originalSetTransform(s,r,a,c,u,f)},o.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},o.rotate=function(s){t.rotate(s),this.__originalRotate(s)},o.clip=function(s){t.clip(s),this.__originalClip(s)},o.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},o.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},o.bezierCurveTo=function(e,s,r,a,c,u){t.bezierCurveTo(e,s,r,a,c,u),this.__originalBezierCurveTo(e,s,r,a,c,u)},o.rect=function(e,s,r,a){t.rect(e,s,r,a),this.__originalRect(e,s,r,a)},o.closePath=function(){t.closePath(),this.__originalClosePath()},o.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}function lr(o,t,e,s,r,a,c,u,f,g){let[m,y,v,S,T,w]=Wt(o);if(y===0&&v===0){let L=c*m+T,M=Math.round(L),N=u*S+w,F=Math.round(N),B=(c+f)*m+T,G=Math.abs(Math.round(B)-M)||1,$=(u+g)*S+w,z=Math.abs(Math.round($)-F)||1;return o.setTransform(Math.sign(m),0,0,Math.sign(S),M,F),o.drawImage(t,e,s,r,a,0,0,G,z),o.setTransform(m,y,v,S,T,w),[G,z]}if(m===0&&S===0){let L=u*v+T,M=Math.round(L),N=c*y+w,F=Math.round(N),B=(u+g)*v+T,G=Math.abs(Math.round(B)-M)||1,$=(c+f)*y+w,z=Math.abs(Math.round($)-F)||1;return o.setTransform(0,Math.sign(y),Math.sign(v),0,M,F),o.drawImage(t,e,s,r,a,0,0,z,G),o.setTransform(m,y,v,S,T,w),[z,G]}o.drawImage(t,e,s,r,a,c,u,f,g);let I=Math.hypot(m,y),k=Math.hypot(v,S);return[I*f,k*g]}function z0(o){let{width:t,height:e}=o;if(t>jc||e>jc)return null;let s=1e3,r=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1,c=new Uint8Array(a*(e+1)),u,f,g,m=t+7&-8,y=new Uint8Array(m*e),v=0;for(let k of o.data){let L=128;for(;L>0;)y[v++]=k&L?0:255,L>>=1}let S=0;for(v=0,y[v]!==0&&(c[0]=1,++S),f=1;f<t;f++)y[v]!==y[v+1]&&(c[f]=y[v]?2:1,++S),v++;for(y[v]!==0&&(c[f]=2,++S),u=1;u<e;u++){v=u*m,g=u*a,y[v-m]!==y[v]&&(c[g]=y[v]?1:8,++S);let k=(y[v]?4:0)+(y[v-m]?8:0);for(f=1;f<t;f++)k=(k>>2)+(y[v+1]?4:0)+(y[v-m+1]?8:0),r[k]&&(c[g+f]=r[k],++S),v++;if(y[v-m]!==y[v]&&(c[g+f]=y[v]?2:4,++S),S>s)return null}for(v=m*(e-1),g=u*a,y[v]!==0&&(c[g]=8,++S),f=1;f<t;f++)y[v]!==y[v+1]&&(c[g+f]=y[v]?4:8,++S),v++;if(y[v]!==0&&(c[g+f]=4,++S),S>s)return null;let T=new Int32Array([0,a,-1,0,-a,0,0,0,1]),w=new Path2D;for(u=0;S&&u<=e;u++){let k=u*a,L=k+t;for(;k<L&&!c[k];)k++;if(k===L)continue;w.moveTo(k%a,u);let M=k,N=c[k];do{let F=T[N];do k+=F;while(!c[k]);let B=c[k];B!==5&&B!==10?(N=B,c[k]=0):(N=B&51*N>>4,c[k]&=N>>2|N<<2),w.lineTo(k%a,k/a|0),c[k]||--S}while(M!==k);--u}return y=null,c=null,function(k){k.save(),k.scale(1/t,-1/e),k.translate(0,-e),k.fill(w),k.beginPath(),k.restore()}}function Vc(o,t){if(t instanceof ImageData){o.putImageData(t,0,0);return}let e=t.height,s=t.width,r=e%ve,a=(e-r)/ve,c=r===0?a:a+1,u=o.createImageData(s,ve),f=0,g,m=t.data,y=u.data,v,S,T,w;if(t.kind===dr.GRAYSCALE_1BPP){let I=m.byteLength,k=new Uint32Array(y.buffer,0,y.byteLength>>2),L=k.length,M=s+7>>3,N=4294967295,F=ne.isLittleEndian?4278190080:255;for(v=0;v<c;v++){for(T=v<a?ve:r,g=0,S=0;S<T;S++){let B=I-f,G=0,$=B>M?s:B*8-7,z=$&-8,J=0,et=0;for(;G<z;G+=8)et=m[f++],k[g++]=et&128?N:F,k[g++]=et&64?N:F,k[g++]=et&32?N:F,k[g++]=et&16?N:F,k[g++]=et&8?N:F,k[g++]=et&4?N:F,k[g++]=et&2?N:F,k[g++]=et&1?N:F;for(;G<$;G++)J===0&&(et=m[f++],J=128),k[g++]=et&J?N:F,J>>=1}for(;g<L;)k[g++]=0;o.putImageData(u,0,v*ve)}}else if(t.kind===dr.RGBA_32BPP){for(S=0,w=s*ve*4,v=0;v<a;v++)y.set(m.subarray(f,f+w)),f+=w,o.putImageData(u,0,S),S+=ve;v<c&&(w=s*r*4,y.set(m.subarray(f,f+w)),o.putImageData(u,0,S))}else if(t.kind===dr.RGB_24BPP)for(T=ve,w=s*T,v=0;v<c;v++){for(v>=a&&(T=r,w=s*T),g=0,S=w;S--;)y[g++]=m[f++],y[g++]=m[f++],y[g++]=m[f++],y[g++]=255;o.putImageData(u,0,v*ve)}else throw new Error(`bad image kind: ${t.kind}`)}function $c(o,t){if(t.bitmap){o.drawImage(t.bitmap,0,0);return}let e=t.height,s=t.width,r=e%ve,a=(e-r)/ve,c=r===0?a:a+1,u=o.createImageData(s,ve),f=0,g=t.data,m=u.data;for(let y=0;y<c;y++){let v=y<a?ve:r;({srcPos:f}=j0({src:g,srcPos:f,dest:m,width:s,height:v,nonBlackColor:0})),o.putImageData(u,0,y*ve)}}function us(o,t){let e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let s of e)o[s]!==void 0&&(t[s]=o[s]);o.setLineDash!==void 0&&(t.setLineDash(o.getLineDash()),t.lineDashOffset=o.lineDashOffset)}function cr(o){if(o.strokeStyle=o.fillStyle="#000000",o.fillRule="nonzero",o.globalAlpha=1,o.lineWidth=1,o.lineCap="butt",o.lineJoin="miter",o.miterLimit=10,o.globalCompositeOperation="source-over",o.font="10px sans-serif",o.setLineDash!==void 0&&(o.setLineDash([]),o.lineDashOffset=0),!ce){let{filter:t}=o;t!=="none"&&t!==""&&(o.filter="none")}}function zc(o,t){if(t)return!0;let e=bt.singularValueDecompose2dScale(o);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);let s=Math.fround((globalThis.devicePixelRatio||1)*pn.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}function K0(o){let t=!0,e=s("filename\\*","i").exec(o);if(e){e=e[1];let m=u(e);return m=unescape(m),m=f(m),m=g(m),a(m)}if(e=c(o),e){let m=g(e);return a(m)}if(e=s("filename","i").exec(o),e){e=e[1];let m=u(e);return m=g(m),a(m)}function s(m,y){return new RegExp("(?:^|;)\\s*"+m+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',y)}function r(m,y){if(m){if(!/^[\x00-\xFF]+$/.test(y))return y;try{let v=new TextDecoder(m,{fatal:!0}),S=Xr(y);y=v.decode(S),t=!1}catch{}}return y}function a(m){return t&&/[\x80-\xff]/.test(m)&&(m=r("utf-8",m),t&&(m=r("iso-8859-1",m))),m}function c(m){let y=[],v,S=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(v=S.exec(m))!==null;){let[,w,I,k]=v;if(w=parseInt(w,10),w in y){if(w===0)break;continue}y[w]=[I,k]}let T=[];for(let w=0;w<y.length&&w in y;++w){let[I,k]=y[w];k=u(k),I&&(k=unescape(k),w===0&&(k=f(k))),T.push(k)}return T.join("")}function u(m){if(m.startsWith('"')){let y=m.slice(1).split('\\"');for(let v=0;v<y.length;++v){let S=y[v].indexOf('"');S!==-1&&(y[v]=y[v].slice(0,S),y.length=v+1),y[v]=y[v].replaceAll(/\\(.)/g,"$1")}m=y.join('"')}return m}function f(m){let y=m.indexOf("'");if(y===-1)return m;let v=m.slice(0,y),T=m.slice(y+1).replace(/^[^']*'/,"");return r(v,T)}function g(m){return!m.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(m)?m:m.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(y,v,S,T){if(S==="q"||S==="Q")return T=T.replaceAll("_"," "),T=T.replaceAll(/=([0-9a-fA-F]{2})/g,function(w,I){return String.fromCharCode(parseInt(I,16))}),r(v,T);try{T=atob(T)}catch{}return r(v,T)})}return""}function Jc(o,t){let e=new Headers;if(!o||!t||typeof t!="object")return e;for(let s in t){let r=t[s];r!==void 0&&e.append(s,r)}return e}function Zr(o){try{return new URL(o).origin}catch{}return null}function qc({responseHeaders:o,isHttp:t,rangeChunkSize:e,disableRange:s}){let r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(o.get("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*e)||s||!t||o.get("Accept-Ranges")!=="bytes"||(o.get("Content-Encoding")||"identity")!=="identity"||(r.allowRangeRequests=!0),r}function tu(o){let t=o.get("Content-Disposition");if(t){let e=K0(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Sa(e))return e}return null}function Qr(o,t){return o===404||o===0&&t.startsWith("file:")?new wn('Missing PDF "'+t+'".'):new Kn(`Unexpected server response (${o}) while retrieving PDF "${t}".`,o)}function eu(o){return o===200||o===206}function nu(o,t,e){return{method:"GET",headers:o,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function su(o){return o instanceof Uint8Array?o.buffer:o instanceof ArrayBuffer?o:(wt(`getArrayBuffer - unexpected data format: ${o}`),new Uint8Array(o).buffer)}function Z0(o){let t=o.response;return typeof t!="string"?t:Xr(t).buffer}function J0(o){if(Q0.test(o))return new URL(o);let t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(o))}function ly(o={}){typeof o=="string"||o instanceof URL?o={url:o}:(o instanceof ArrayBuffer||ArrayBuffer.isView(o))&&(o={data:o});let t=new _o,{docId:e}=t,s=o.url?cy(o.url):null,r=o.data?uy(o.data):null,a=o.httpHeaders||null,c=o.withCredentials===!0,u=o.password??null,f=o.range instanceof Rr?o.range:null,g=Number.isInteger(o.rangeChunkSize)&&o.rangeChunkSize>0?o.rangeChunkSize:ey,m=o.worker instanceof Yn?o.worker:null,y=o.verbosity,v=typeof o.docBaseUrl=="string"&&!Kr(o.docBaseUrl)?o.docBaseUrl:null,S=typeof o.cMapUrl=="string"?o.cMapUrl:null,T=o.cMapPacked!==!1,w=o.CMapReaderFactory||iy,I=typeof o.standardFontDataUrl=="string"?o.standardFontDataUrl:null,k=o.StandardFontDataFactory||ay,L=o.stopAtErrors!==!0,M=Number.isInteger(o.maxImageSize)&&o.maxImageSize>-1?o.maxImageSize:-1,N=o.isEvalSupported!==!1,F=typeof o.isOffscreenCanvasSupported=="boolean"?o.isOffscreenCanvasSupported:!ce,B=typeof o.isImageDecoderSupported=="boolean"?o.isImageDecoderSupported:!ce&&(ne.platform.isFirefox||!globalThis.chrome),G=Number.isInteger(o.canvasMaxAreaInBytes)?o.canvasMaxAreaInBytes:-1,$=typeof o.disableFontFace=="boolean"?o.disableFontFace:ce,z=o.fontExtraProperties===!0,J=o.enableXfa===!0,et=o.ownerDocument||globalThis.document,nt=o.disableRange===!0,xt=o.disableStream===!0,vt=o.disableAutoFetch===!0,St=o.pdfBug===!0,W=o.CanvasFactory||ry,K=o.FilterFactory||oy,pt=o.enableHWA===!0,ft=f?f.length:o.length??NaN,X=typeof o.useSystemFonts=="boolean"?o.useSystemFonts:!ce&&!$,gt=typeof o.useWorkerFetch=="boolean"?o.useWorkerFetch:w===Tr&&k===wr&&S&&I&&fs(S,document.baseURI)&&fs(I,document.baseURI),Z=null;E0(y);let tt={canvasFactory:new W({ownerDocument:et,enableHWA:pt}),filterFactory:new K({docId:e,ownerDocument:et}),cMapReaderFactory:gt?null:new w({baseUrl:S,isCompressed:T}),standardFontDataFactory:gt?null:new k({baseUrl:I})};if(!m){let Y={verbosity:y,port:En.workerPort};m=Y.port?Yn.fromPort(Y):new Yn(Y),t._worker=m}let ct={docId:e,apiVersion:"4.10.45",data:r,password:u,disableAutoFetch:vt,rangeChunkSize:g,length:ft,docBaseUrl:v,enableXfa:J,evaluatorOptions:{maxImageSize:M,disableFontFace:$,ignoreErrors:L,isEvalSupported:N,isOffscreenCanvasSupported:F,isImageDecoderSupported:B,canvasMaxAreaInBytes:G,fontExtraProperties:z,useSystemFonts:X,cMapUrl:gt?S:null,standardFontDataUrl:gt?I:null}},st={disableFontFace:$,fontExtraProperties:z,ownerDocument:et,pdfBug:St,styleElement:Z,loadingParams:{disableAutoFetch:vt,enableXfa:J}};return m.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let Y=m.messageHandler.sendWithPromise("GetDocRequest",ct,r?[r.buffer]:null),j;if(f)j=new Co(f,{disableRange:nt,disableStream:xt});else if(!r){if(!s)throw new Error("getDocument - no `url` parameter provided.");let H;if(ce)if(fs(s)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");H=Ir}else H=Mo;else H=fs(s)?Ir:Po;j=new H({url:s,length:ft,httpHeaders:a,withCredentials:c,rangeChunkSize:g,disableRange:nt,disableStream:xt})}return Y.then(H=>{if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let Tt=new Cn(e,H,m.port),Ot=new Go(Tt,t,j,st,tt);t._transport=Ot,Tt.send("Ready",null)})}).catch(t._capability.reject),t}function cy(o){if(o instanceof URL)return o.href;try{return new URL(o,window.location).href}catch{if(ce&&typeof o=="string")return o}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function uy(o){if(ce&&typeof Buffer<"u"&&o instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength)return o;if(typeof o=="string")return Xr(o);if(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="object"&&!isNaN(o?.length))return new Uint8Array(o);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Xc(o){return typeof o=="object"&&Number.isInteger(o?.num)&&o.num>=0&&Number.isInteger(o?.gen)&&o.gen>=0}function Yc(o){return Math.floor(Math.max(0,Math.min(1,o))*255).toString(16).padStart(2,"0")}function ds(o){return Math.max(0,Math.min(255,255*o))}function fn(o){return{width:o[2]-o[0],height:o[3]-o[1]}}var v0,Dc,Et,xx,Sx,Ax,Tx,Cx,Ex,wx,kx,Ix,Rx,Px,Ox,ce,Kc,Zi,x0,hr,S0,Lx,Ce,dn,A0,Rt,Lt,T0,ae,dr,ee,cs,$r,Ge,C0,zr,gn,fr,ps,gs,wn,Kn,Qi,Ke,ne,zi,bt,Wi,Fc,xa,Mx,Dx,Fx,_x,Nx,Ux,Bx,Gx,Hx,jx,Vx,$x,zx,Wx,tn,pn,ms,ys,pr,gr,bs,Ji,qi,to,eo,no,In,so,Rn,yr,br,Xt,ro,_c,Pe,Ye,vr,io,vs,xr,oo,ao,ar,qt,Cn,Sr,lo,Ar,Tr,Xx,Cr,co,Er,wr,uo,ho,fo,po,le,xs,mo,yo,bo,Uc,vo,Bc,Gc,V0,Hc,jc,ve,xo,kr,W0,X0,Y0,Wc,Xn,En,So,Wn,Ao,To,Co,Eo,wo,Ir,ko,Io,Yi,Ki,Ro,Po,Oo,Lo,Q0,Mo,Do,Fo,q0,ye,ty,Ss,As,ey,ny,sy,ry,iy,oy,ay,_o,Rr,No,Uo,Bo,Yn,Go,hs,Pr,Ho,jo,hy,dy,Yx,Or,Vo,Ts,Lr,Is,fy,Pn,$o,Qt,Mr,zo,en,Wo,Xo,Yo,Dr,Ko,Zo,Cs,Qo,Fr,Jo,qo,ta,_r,ea,na,Es,Nr,sa,ra,ia,Ur,oa,aa,ur,la,lt,Br,Gr,ws,ca,ks,ua,Hr,jr,ha,da,fa,Vr,pa,ga,ma,ya,ba,py,gy,my,yy,by,vy,Jr,xy,Sy,Ay,Ty,Cy,Ey,wy,ky,Iy,Ry,Py,Oy,Ly,My,Dy,Fy,_y,Ny,Uy,By,Gy,Hy,jy,Vy,$y,zy,Wy,Xy,Yy,Ky,Zy,Qy,Jy,qy,tb,eb,nb,sb,Ta=a0(()=>{v0={9306:((o,t,e)=>{var s=e(4901),r=e(6823),a=TypeError;o.exports=function(c){if(s(c))return c;throw new a(r(c)+" is not a function")}}),3506:((o,t,e)=>{var s=e(3925),r=String,a=TypeError;o.exports=function(c){if(s(c))return c;throw new a("Can't set "+r(c)+" as a prototype")}}),7080:((o,t,e)=>{var s=e(4402).has;o.exports=function(r){return s(r),r}}),679:((o,t,e)=>{var s=e(1625),r=TypeError;o.exports=function(a,c){if(s(c,a))return a;throw new r("Incorrect invocation")}}),8551:((o,t,e)=>{var s=e(34),r=String,a=TypeError;o.exports=function(c){if(s(c))return c;throw new a(r(c)+" is not an object")}}),7811:(o=>{o.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),7394:((o,t,e)=>{var s=e(4576),r=e(6706),a=e(2195),c=s.ArrayBuffer,u=s.TypeError;o.exports=c&&r(c.prototype,"byteLength","get")||function(f){if(a(f)!=="ArrayBuffer")throw new u("ArrayBuffer expected");return f.byteLength}}),3238:((o,t,e)=>{var s=e(4576),r=e(7476),a=e(7394),c=s.ArrayBuffer,u=c&&c.prototype,f=u&&r(u.slice);o.exports=function(g){if(a(g)!==0||!f)return!1;try{return f(g,0,0),!1}catch{return!0}}}),5169:((o,t,e)=>{var s=e(3238),r=TypeError;o.exports=function(a){if(s(a))throw new r("ArrayBuffer is detached");return a}}),5636:((o,t,e)=>{var s=e(4576),r=e(9504),a=e(6706),c=e(7696),u=e(5169),f=e(7394),g=e(4483),m=e(1548),y=s.structuredClone,v=s.ArrayBuffer,S=s.DataView,T=Math.min,w=v.prototype,I=S.prototype,k=r(w.slice),L=a(w,"resizable","get"),M=a(w,"maxByteLength","get"),N=r(I.getInt8),F=r(I.setInt8);o.exports=(m||g)&&function(B,G,$){var z=f(B),J=G===void 0?z:c(G),et=!L||!L(B),nt;if(u(B),m&&(B=y(B,{transfer:[B]}),z===J&&($||et)))return B;if(z>=J&&(!$||et))nt=k(B,0,J);else{var xt=$&&!et&&M?{maxByteLength:M(B)}:void 0;nt=new v(J,xt);for(var vt=new S(B),St=new S(nt),W=T(J,z),K=0;K<W;K++)F(St,K,N(vt,K))}return m||g(B),nt}}),4644:((o,t,e)=>{var s=e(7811),r=e(3724),a=e(4576),c=e(4901),u=e(34),f=e(9297),g=e(6955),m=e(6823),y=e(6699),v=e(6840),S=e(2106),T=e(1625),w=e(2787),I=e(2967),k=e(8227),L=e(3392),M=e(1181),N=M.enforce,F=M.get,B=a.Int8Array,G=B&&B.prototype,$=a.Uint8ClampedArray,z=$&&$.prototype,J=B&&w(B),et=G&&w(G),nt=Object.prototype,xt=a.TypeError,vt=k("toStringTag"),St=L("TYPED_ARRAY_TAG"),W="TypedArrayConstructor",K=s&&!!I&&g(a.opera)!=="Opera",pt=!1,ft,X,gt,Z={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},tt={BigInt64Array:8,BigUint64Array:8},ct=function(zt){if(!u(zt))return!1;var Nt=g(zt);return Nt==="DataView"||f(Z,Nt)||f(tt,Nt)},st=function(Ct){var zt=w(Ct);if(u(zt)){var Nt=F(zt);return Nt&&f(Nt,W)?Nt[W]:st(zt)}},Y=function(Ct){if(!u(Ct))return!1;var zt=g(Ct);return f(Z,zt)||f(tt,zt)},j=function(Ct){if(Y(Ct))return Ct;throw new xt("Target is not a typed array")},H=function(Ct){if(c(Ct)&&(!I||T(J,Ct)))return Ct;throw new xt(m(Ct)+" is not a typed array constructor")},Tt=function(Ct,zt,Nt,q){if(r){if(Nt)for(var at in Z){var Ft=a[at];if(Ft&&f(Ft.prototype,Ct))try{delete Ft.prototype[Ct]}catch{try{Ft.prototype[Ct]=zt}catch{}}}(!et[Ct]||Nt)&&v(et,Ct,Nt?zt:K&&G[Ct]||zt,q)}},Ot=function(Ct,zt,Nt){var q,at;if(r){if(I){if(Nt){for(q in Z)if(at=a[q],at&&f(at,Ct))try{delete at[Ct]}catch{}}if(!J[Ct]||Nt)try{return v(J,Ct,Nt?zt:K&&J[Ct]||zt)}catch{}else return}for(q in Z)at=a[q],at&&(!at[Ct]||Nt)&&v(at,Ct,zt)}};for(ft in Z)X=a[ft],gt=X&&X.prototype,gt?N(gt)[W]=X:K=!1;for(ft in tt)X=a[ft],gt=X&&X.prototype,gt&&(N(gt)[W]=X);if((!K||!c(J)||J===Function.prototype)&&(J=function(){throw new xt("Incorrect invocation")},K))for(ft in Z)a[ft]&&I(a[ft],J);if((!K||!et||et===nt)&&(et=J.prototype,K))for(ft in Z)a[ft]&&I(a[ft].prototype,et);if(K&&w(z)!==et&&I(z,et),r&&!f(et,vt)){pt=!0,S(et,vt,{configurable:!0,get:function(){return u(this)?this[St]:void 0}});for(ft in Z)a[ft]&&y(a[ft],St,ft)}o.exports={NATIVE_ARRAY_BUFFER_VIEWS:K,TYPED_ARRAY_TAG:pt&&St,aTypedArray:j,aTypedArrayConstructor:H,exportTypedArrayMethod:Tt,exportTypedArrayStaticMethod:Ot,getTypedArrayConstructor:st,isView:ct,isTypedArray:Y,TypedArray:J,TypedArrayPrototype:et}}),5370:((o,t,e)=>{var s=e(6198);o.exports=function(r,a,c){for(var u=0,f=arguments.length>2?c:s(a),g=new r(f);f>u;)g[u]=a[u++];return g}}),9617:((o,t,e)=>{var s=e(5397),r=e(5610),a=e(6198),c=function(u){return function(f,g,m){var y=s(f),v=a(y);if(v===0)return!u&&-1;var S=r(m,v),T;if(u&&g!==g){for(;v>S;)if(T=y[S++],T!==T)return!0}else for(;v>S;S++)if((u||S in y)&&y[S]===g)return u||S||0;return!u&&-1}};o.exports={includes:c(!0),indexOf:c(!1)}}),4527:((o,t,e)=>{var s=e(3724),r=e(4376),a=TypeError,c=Object.getOwnPropertyDescriptor,u=s&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(f){return f instanceof TypeError}})();o.exports=u?function(f,g){if(r(f)&&!c(f,"length").writable)throw new a("Cannot set read only .length");return f.length=g}:function(f,g){return f.length=g}}),7680:((o,t,e)=>{var s=e(9504);o.exports=s([].slice)}),7628:((o,t,e)=>{var s=e(6198);o.exports=function(r,a){for(var c=s(r),u=new a(c),f=0;f<c;f++)u[f]=r[c-f-1];return u}}),9928:((o,t,e)=>{var s=e(6198),r=e(1291),a=RangeError;o.exports=function(c,u,f,g){var m=s(c),y=r(f),v=y<0?m+y:y;if(v>=m||v<0)throw new a("Incorrect index");for(var S=new u(m),T=0;T<m;T++)S[T]=T===v?g:c[T];return S}}),6319:((o,t,e)=>{var s=e(8551),r=e(9539);o.exports=function(a,c,u,f){try{return f?c(s(u)[0],u[1]):c(u)}catch(g){r(a,"throw",g)}}}),2195:((o,t,e)=>{var s=e(9504),r=s({}.toString),a=s("".slice);o.exports=function(c){return a(r(c),8,-1)}}),6955:((o,t,e)=>{var s=e(2140),r=e(4901),a=e(2195),c=e(8227),u=c("toStringTag"),f=Object,g=a((function(){return arguments})())==="Arguments",m=function(y,v){try{return y[v]}catch{}};o.exports=s?a:function(y){var v,S,T;return y===void 0?"Undefined":y===null?"Null":typeof(S=m(v=f(y),u))=="string"?S:g?a(v):(T=a(v))==="Object"&&r(v.callee)?"Arguments":T}}),7740:((o,t,e)=>{var s=e(9297),r=e(5031),a=e(7347),c=e(4913);o.exports=function(u,f,g){for(var m=r(f),y=c.f,v=a.f,S=0;S<m.length;S++){var T=m[S];!s(u,T)&&!(g&&s(g,T))&&y(u,T,v(f,T))}}}),2211:((o,t,e)=>{var s=e(9039);o.exports=!s(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})}),2529:(o=>{o.exports=function(t,e){return{value:t,done:e}}}),6699:((o,t,e)=>{var s=e(3724),r=e(4913),a=e(6980);o.exports=s?function(c,u,f){return r.f(c,u,a(1,f))}:function(c,u,f){return c[u]=f,c}}),6980:(o=>{o.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}}),4659:((o,t,e)=>{var s=e(3724),r=e(4913),a=e(6980);o.exports=function(c,u,f){s?r.f(c,u,a(0,f)):c[u]=f}}),2106:((o,t,e)=>{var s=e(283),r=e(4913);o.exports=function(a,c,u){return u.get&&s(u.get,c,{getter:!0}),u.set&&s(u.set,c,{setter:!0}),r.f(a,c,u)}}),6840:((o,t,e)=>{var s=e(4901),r=e(4913),a=e(283),c=e(9433);o.exports=function(u,f,g,m){m||(m={});var y=m.enumerable,v=m.name!==void 0?m.name:f;if(s(g)&&a(g,v,m),m.global)y?u[f]=g:c(f,g);else{try{m.unsafe?u[f]&&(y=!0):delete u[f]}catch{}y?u[f]=g:r.f(u,f,{value:g,enumerable:!1,configurable:!m.nonConfigurable,writable:!m.nonWritable})}return u}}),6279:((o,t,e)=>{var s=e(6840);o.exports=function(r,a,c){for(var u in a)s(r,u,a[u],c);return r}}),9433:((o,t,e)=>{var s=e(4576),r=Object.defineProperty;o.exports=function(a,c){try{r(s,a,{value:c,configurable:!0,writable:!0})}catch{s[a]=c}return c}}),3724:((o,t,e)=>{var s=e(9039);o.exports=!s(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),4483:((o,t,e)=>{var s=e(4576),r=e(9429),a=e(1548),c=s.structuredClone,u=s.ArrayBuffer,f=s.MessageChannel,g=!1,m,y,v,S;if(a)g=function(T){c(T,{transfer:[T]})};else if(u)try{f||(m=r("worker_threads"),m&&(f=m.MessageChannel)),f&&(y=new f,v=new u(2),S=function(T){y.port1.postMessage(null,[T])},v.byteLength===2&&(S(v),v.byteLength===0&&(g=S)))}catch{}o.exports=g}),4055:((o,t,e)=>{var s=e(4576),r=e(34),a=s.document,c=r(a)&&r(a.createElement);o.exports=function(u){return c?a.createElement(u):{}}}),6837:(o=>{var t=TypeError,e=9007199254740991;o.exports=function(s){if(s>e)throw t("Maximum allowed index exceeded");return s}}),5002:(o=>{o.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}}),8727:(o=>{o.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),6193:((o,t,e)=>{var s=e(4215);o.exports=s==="NODE"}),2839:((o,t,e)=>{var s=e(4576),r=s.navigator,a=r&&r.userAgent;o.exports=a?String(a):""}),9519:((o,t,e)=>{var s=e(4576),r=e(2839),a=s.process,c=s.Deno,u=a&&a.versions||c&&c.version,f=u&&u.v8,g,m;f&&(g=f.split("."),m=g[0]>0&&g[0]<4?1:+(g[0]+g[1])),!m&&r&&(g=r.match(/Edge\/(\d+)/),(!g||g[1]>=74)&&(g=r.match(/Chrome\/(\d+)/),g&&(m=+g[1]))),o.exports=m}),4215:((o,t,e)=>{var s=e(4576),r=e(2839),a=e(2195),c=function(u){return r.slice(0,u.length)===u};o.exports=(function(){return c("Bun/")?"BUN":c("Cloudflare-Workers")?"CLOUDFLARE":c("Deno/")?"DENO":c("Node.js/")?"NODE":s.Bun&&typeof Bun.version=="string"?"BUN":s.Deno&&typeof Deno.version=="object"?"DENO":a(s.process)==="process"?"NODE":s.window&&s.document?"BROWSER":"REST"})()}),8574:((o,t,e)=>{var s=e(9504),r=Error,a=s("".replace),c=(function(g){return String(new r(g).stack)})("zxcasd"),u=/\n\s*at [^:]*:[^\n]*/,f=u.test(c);o.exports=function(g,m){if(f&&typeof g=="string"&&!r.prepareStackTrace)for(;m--;)g=a(g,u,"");return g}}),6518:((o,t,e)=>{var s=e(4576),r=e(7347).f,a=e(6699),c=e(6840),u=e(9433),f=e(7740),g=e(2796);o.exports=function(m,y){var v=m.target,S=m.global,T=m.stat,w,I,k,L,M,N;if(S?I=s:T?I=s[v]||u(v,{}):I=s[v]&&s[v].prototype,I)for(k in y){if(M=y[k],m.dontCallGetSet?(N=r(I,k),L=N&&N.value):L=I[k],w=g(S?k:v+(T?".":"#")+k,m.forced),!w&&L!==void 0){if(typeof M==typeof L)continue;f(M,L)}(m.sham||L&&L.sham)&&a(M,"sham",!0),c(I,k,M,m)}}}),9039:(o=>{o.exports=function(t){try{return!!t()}catch{return!0}}}),8745:((o,t,e)=>{var s=e(616),r=Function.prototype,a=r.apply,c=r.call;o.exports=typeof Reflect=="object"&&Reflect.apply||(s?c.bind(a):function(){return c.apply(a,arguments)})}),6080:((o,t,e)=>{var s=e(7476),r=e(9306),a=e(616),c=s(s.bind);o.exports=function(u,f){return r(u),f===void 0?u:a?c(u,f):function(){return u.apply(f,arguments)}}}),616:((o,t,e)=>{var s=e(9039);o.exports=!s(function(){var r=(function(){}).bind();return typeof r!="function"||r.hasOwnProperty("prototype")})}),9565:((o,t,e)=>{var s=e(616),r=Function.prototype.call;o.exports=s?r.bind(r):function(){return r.apply(r,arguments)}}),350:((o,t,e)=>{var s=e(3724),r=e(9297),a=Function.prototype,c=s&&Object.getOwnPropertyDescriptor,u=r(a,"name"),f=u&&(function(){}).name==="something",g=u&&(!s||s&&c(a,"name").configurable);o.exports={EXISTS:u,PROPER:f,CONFIGURABLE:g}}),6706:((o,t,e)=>{var s=e(9504),r=e(9306);o.exports=function(a,c,u){try{return s(r(Object.getOwnPropertyDescriptor(a,c)[u]))}catch{}}}),7476:((o,t,e)=>{var s=e(2195),r=e(9504);o.exports=function(a){if(s(a)==="Function")return r(a)}}),9504:((o,t,e)=>{var s=e(616),r=Function.prototype,a=r.call,c=s&&r.bind.bind(a,a);o.exports=s?c:function(u){return function(){return a.apply(u,arguments)}}}),9429:((o,t,e)=>{var s=e(4576),r=e(6193);o.exports=function(a){if(r){try{return s.process.getBuiltinModule(a)}catch{}try{return Function('return require("'+a+'")')()}catch{}}}}),7751:((o,t,e)=>{var s=e(4576),r=e(4901),a=function(c){return r(c)?c:void 0};o.exports=function(c,u){return arguments.length<2?a(s[c]):s[c]&&s[c][u]}}),1767:(o=>{o.exports=function(t){return{iterator:t,next:t.next,done:!1}}}),8646:((o,t,e)=>{var s=e(9565),r=e(8551),a=e(1767),c=e(851);o.exports=function(u,f){(!f||typeof u!="string")&&r(u);var g=c(u);return a(r(g!==void 0?s(g,u):u))}}),851:((o,t,e)=>{var s=e(6955),r=e(5966),a=e(4117),c=e(6269),u=e(8227),f=u("iterator");o.exports=function(g){if(!a(g))return r(g,f)||r(g,"@@iterator")||c[s(g)]}}),81:((o,t,e)=>{var s=e(9565),r=e(9306),a=e(8551),c=e(6823),u=e(851),f=TypeError;o.exports=function(g,m){var y=arguments.length<2?u(g):m;if(r(y))return a(s(y,g));throw new f(c(g)+" is not iterable")}}),5966:((o,t,e)=>{var s=e(9306),r=e(4117);o.exports=function(a,c){var u=a[c];return r(u)?void 0:s(u)}}),3789:((o,t,e)=>{var s=e(9306),r=e(8551),a=e(9565),c=e(1291),u=e(1767),f="Invalid size",g=RangeError,m=TypeError,y=Math.max,v=function(S,T){this.set=S,this.size=y(T,0),this.has=s(S.has),this.keys=s(S.keys)};v.prototype={getIterator:function(){return u(r(a(this.keys,this.set)))},includes:function(S){return a(this.has,this.set,S)}},o.exports=function(S){r(S);var T=+S.size;if(T!==T)throw new m(f);var w=c(T);if(w<0)throw new g(f);return new v(S,w)}}),4576:(function(o){var t=function(e){return e&&e.Math===Math&&e};o.exports=t(typeof globalThis=="object"&&globalThis)||t(typeof window=="object"&&window)||t(typeof self=="object"&&self)||t(typeof global=="object"&&global)||t(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()}),9297:((o,t,e)=>{var s=e(9504),r=e(8981),a=s({}.hasOwnProperty);o.exports=Object.hasOwn||function(u,f){return a(r(u),f)}}),421:(o=>{o.exports={}}),397:((o,t,e)=>{var s=e(7751);o.exports=s("document","documentElement")}),5917:((o,t,e)=>{var s=e(3724),r=e(9039),a=e(4055);o.exports=!s&&!r(function(){return Object.defineProperty(a("div"),"a",{get:function(){return 7}}).a!==7})}),7055:((o,t,e)=>{var s=e(9504),r=e(9039),a=e(2195),c=Object,u=s("".split);o.exports=r(function(){return!c("z").propertyIsEnumerable(0)})?function(f){return a(f)==="String"?u(f,""):c(f)}:c}),3167:((o,t,e)=>{var s=e(4901),r=e(34),a=e(2967);o.exports=function(c,u,f){var g,m;return a&&s(g=u.constructor)&&g!==f&&r(m=g.prototype)&&m!==f.prototype&&a(c,m),c}}),3706:((o,t,e)=>{var s=e(9504),r=e(4901),a=e(7629),c=s(Function.toString);r(a.inspectSource)||(a.inspectSource=function(u){return c(u)}),o.exports=a.inspectSource}),1181:((o,t,e)=>{var s=e(8622),r=e(4576),a=e(34),c=e(6699),u=e(9297),f=e(7629),g=e(6119),m=e(421),y="Object already initialized",v=r.TypeError,S=r.WeakMap,T,w,I,k=function(F){return I(F)?w(F):T(F,{})},L=function(F){return function(B){var G;if(!a(B)||(G=w(B)).type!==F)throw new v("Incompatible receiver, "+F+" required");return G}};if(s||f.state){var M=f.state||(f.state=new S);M.get=M.get,M.has=M.has,M.set=M.set,T=function(F,B){if(M.has(F))throw new v(y);return B.facade=F,M.set(F,B),B},w=function(F){return M.get(F)||{}},I=function(F){return M.has(F)}}else{var N=g("state");m[N]=!0,T=function(F,B){if(u(F,N))throw new v(y);return B.facade=F,c(F,N,B),B},w=function(F){return u(F,N)?F[N]:{}},I=function(F){return u(F,N)}}o.exports={set:T,get:w,has:I,enforce:k,getterFor:L}}),4209:((o,t,e)=>{var s=e(8227),r=e(6269),a=s("iterator"),c=Array.prototype;o.exports=function(u){return u!==void 0&&(r.Array===u||c[a]===u)}}),4376:((o,t,e)=>{var s=e(2195);o.exports=Array.isArray||function(a){return s(a)==="Array"}}),1108:((o,t,e)=>{var s=e(6955);o.exports=function(r){var a=s(r);return a==="BigInt64Array"||a==="BigUint64Array"}}),4901:(o=>{var t=typeof document=="object"&&document.all;o.exports=typeof t>"u"&&t!==void 0?function(e){return typeof e=="function"||e===t}:function(e){return typeof e=="function"}}),2796:((o,t,e)=>{var s=e(9039),r=e(4901),a=/#|\.prototype\./,c=function(y,v){var S=f[u(y)];return S===m?!0:S===g?!1:r(v)?s(v):!!v},u=c.normalize=function(y){return String(y).replace(a,".").toLowerCase()},f=c.data={},g=c.NATIVE="N",m=c.POLYFILL="P";o.exports=c}),4117:(o=>{o.exports=function(t){return t==null}}),34:((o,t,e)=>{var s=e(4901);o.exports=function(r){return typeof r=="object"?r!==null:s(r)}}),3925:((o,t,e)=>{var s=e(34);o.exports=function(r){return s(r)||r===null}}),6395:(o=>{o.exports=!1}),757:((o,t,e)=>{var s=e(7751),r=e(4901),a=e(1625),c=e(7040),u=Object;o.exports=c?function(f){return typeof f=="symbol"}:function(f){var g=s("Symbol");return r(g)&&a(g.prototype,u(f))}}),507:((o,t,e)=>{var s=e(9565);o.exports=function(r,a,c){for(var u=c?r:r.iterator,f=r.next,g,m;!(g=s(f,u)).done;)if(m=a(g.value),m!==void 0)return m}}),2652:((o,t,e)=>{var s=e(6080),r=e(9565),a=e(8551),c=e(6823),u=e(4209),f=e(6198),g=e(1625),m=e(81),y=e(851),v=e(9539),S=TypeError,T=function(I,k){this.stopped=I,this.result=k},w=T.prototype;o.exports=function(I,k,L){var M=L&&L.that,N=!!(L&&L.AS_ENTRIES),F=!!(L&&L.IS_RECORD),B=!!(L&&L.IS_ITERATOR),G=!!(L&&L.INTERRUPTED),$=s(k,M),z,J,et,nt,xt,vt,St,W=function(pt){return z&&v(z,"normal",pt),new T(!0,pt)},K=function(pt){return N?(a(pt),G?$(pt[0],pt[1],W):$(pt[0],pt[1])):G?$(pt,W):$(pt)};if(F)z=I.iterator;else if(B)z=I;else{if(J=y(I),!J)throw new S(c(I)+" is not iterable");if(u(J)){for(et=0,nt=f(I);nt>et;et++)if(xt=K(I[et]),xt&&g(w,xt))return xt;return new T(!1)}z=m(I,J)}for(vt=F?I.next:z.next;!(St=r(vt,z)).done;){try{xt=K(St.value)}catch(pt){v(z,"throw",pt)}if(typeof xt=="object"&&xt&&g(w,xt))return xt}return new T(!1)}}),9539:((o,t,e)=>{var s=e(9565),r=e(8551),a=e(5966);o.exports=function(c,u,f){var g,m;r(c);try{if(g=a(c,"return"),!g){if(u==="throw")throw f;return f}g=s(g,c)}catch(y){m=!0,g=y}if(u==="throw")throw f;if(m)throw g;return r(g),f}}),9462:((o,t,e)=>{var s=e(9565),r=e(2360),a=e(6699),c=e(6279),u=e(8227),f=e(1181),g=e(5966),m=e(7657).IteratorPrototype,y=e(2529),v=e(9539),S=u("toStringTag"),T="IteratorHelper",w="WrapForValidIterator",I=f.set,k=function(N){var F=f.getterFor(N?w:T);return c(r(m),{next:function(){var G=F(this);if(N)return G.nextHandler();try{var $=G.done?void 0:G.nextHandler();return y($,G.done)}catch(z){throw G.done=!0,z}},return:function(){var B=F(this),G=B.iterator;if(B.done=!0,N){var $=g(G,"return");return $?s($,G):y(void 0,!0)}if(B.inner)try{v(B.inner.iterator,"normal")}catch(z){return v(G,"throw",z)}return G&&v(G,"normal"),y(void 0,!0)}})},L=k(!0),M=k(!1);a(M,S,"Iterator Helper"),o.exports=function(N,F){var B=function($,z){z?(z.iterator=$.iterator,z.next=$.next):z=$,z.type=F?w:T,z.nextHandler=N,z.counter=0,z.done=!1,I(this,z)};return B.prototype=F?L:M,B}}),713:((o,t,e)=>{var s=e(9565),r=e(9306),a=e(8551),c=e(1767),u=e(9462),f=e(6319),g=u(function(){var m=this.iterator,y=a(s(this.next,m)),v=this.done=!!y.done;if(!v)return f(m,this.mapper,[y.value,this.counter++],!0)});o.exports=function(y){return a(this),r(y),new g(c(this),{mapper:y})}}),7657:((o,t,e)=>{var s=e(9039),r=e(4901),a=e(34),c=e(2360),u=e(2787),f=e(6840),g=e(8227),m=e(6395),y=g("iterator"),v=!1,S,T,w;[].keys&&(w=[].keys(),"next"in w?(T=u(u(w)),T!==Object.prototype&&(S=T)):v=!0);var I=!a(S)||s(function(){var k={};return S[y].call(k)!==k});I?S={}:m&&(S=c(S)),r(S[y])||f(S,y,function(){return this}),o.exports={IteratorPrototype:S,BUGGY_SAFARI_ITERATORS:v}}),6269:(o=>{o.exports={}}),6198:((o,t,e)=>{var s=e(8014);o.exports=function(r){return s(r.length)}}),283:((o,t,e)=>{var s=e(9504),r=e(9039),a=e(4901),c=e(9297),u=e(3724),f=e(350).CONFIGURABLE,g=e(3706),m=e(1181),y=m.enforce,v=m.get,S=String,T=Object.defineProperty,w=s("".slice),I=s("".replace),k=s([].join),L=u&&!r(function(){return T(function(){},"length",{value:8}).length!==8}),M=String(String).split("String"),N=o.exports=function(F,B,G){w(S(B),0,7)==="Symbol("&&(B="["+I(S(B),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),G&&G.getter&&(B="get "+B),G&&G.setter&&(B="set "+B),(!c(F,"name")||f&&F.name!==B)&&(u?T(F,"name",{value:B,configurable:!0}):F.name=B),L&&G&&c(G,"arity")&&F.length!==G.arity&&T(F,"length",{value:G.arity});try{G&&c(G,"constructor")&&G.constructor?u&&T(F,"prototype",{writable:!1}):F.prototype&&(F.prototype=void 0)}catch{}var $=y(F);return c($,"source")||($.source=k(M,typeof B=="string"?B:"")),F};Function.prototype.toString=N(function(){return a(this)&&v(this).source||g(this)},"toString")}),741:(o=>{var t=Math.ceil,e=Math.floor;o.exports=Math.trunc||function(r){var a=+r;return(a>0?e:t)(a)}}),6043:((o,t,e)=>{var s=e(9306),r=TypeError,a=function(c){var u,f;this.promise=new c(function(g,m){if(u!==void 0||f!==void 0)throw new r("Bad Promise constructor");u=g,f=m}),this.resolve=s(u),this.reject=s(f)};o.exports.f=function(c){return new a(c)}}),2603:((o,t,e)=>{var s=e(655);o.exports=function(r,a){return r===void 0?arguments.length<2?"":a:s(r)}}),4149:(o=>{var t=RangeError;o.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}}),2360:((o,t,e)=>{var s=e(8551),r=e(6801),a=e(8727),c=e(421),u=e(397),f=e(4055),g=e(6119),m=">",y="<",v="prototype",S="script",T=g("IE_PROTO"),w=function(){},I=function(F){return y+S+m+F+y+"/"+S+m},k=function(F){F.write(I("")),F.close();var B=F.parentWindow.Object;return F=null,B},L=function(){var F=f("iframe"),B="java"+S+":",G;return F.style.display="none",u.appendChild(F),F.src=String(B),G=F.contentWindow.document,G.open(),G.write(I("document.F=Object")),G.close(),G.F},M,N=function(){try{M=new ActiveXObject("htmlfile")}catch{}N=typeof document<"u"?document.domain&&M?k(M):L():k(M);for(var F=a.length;F--;)delete N[v][a[F]];return N()};c[T]=!0,o.exports=Object.create||function(B,G){var $;return B!==null?(w[v]=s(B),$=new w,w[v]=null,$[T]=B):$=N(),G===void 0?$:r.f($,G)}}),6801:((o,t,e)=>{var s=e(3724),r=e(8686),a=e(4913),c=e(8551),u=e(5397),f=e(1072);t.f=s&&!r?Object.defineProperties:function(m,y){c(m);for(var v=u(y),S=f(y),T=S.length,w=0,I;T>w;)a.f(m,I=S[w++],v[I]);return m}}),4913:((o,t,e)=>{var s=e(3724),r=e(5917),a=e(8686),c=e(8551),u=e(6969),f=TypeError,g=Object.defineProperty,m=Object.getOwnPropertyDescriptor,y="enumerable",v="configurable",S="writable";t.f=s?a?function(w,I,k){if(c(w),I=u(I),c(k),typeof w=="function"&&I==="prototype"&&"value"in k&&S in k&&!k[S]){var L=m(w,I);L&&L[S]&&(w[I]=k.value,k={configurable:v in k?k[v]:L[v],enumerable:y in k?k[y]:L[y],writable:!1})}return g(w,I,k)}:g:function(w,I,k){if(c(w),I=u(I),c(k),r)try{return g(w,I,k)}catch{}if("get"in k||"set"in k)throw new f("Accessors not supported");return"value"in k&&(w[I]=k.value),w}}),7347:((o,t,e)=>{var s=e(3724),r=e(9565),a=e(8773),c=e(6980),u=e(5397),f=e(6969),g=e(9297),m=e(5917),y=Object.getOwnPropertyDescriptor;t.f=s?y:function(S,T){if(S=u(S),T=f(T),m)try{return y(S,T)}catch{}if(g(S,T))return c(!r(a.f,S,T),S[T])}}),8480:((o,t,e)=>{var s=e(1828),r=e(8727),a=r.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(u){return s(u,a)}}),3717:((o,t)=>{t.f=Object.getOwnPropertySymbols}),2787:((o,t,e)=>{var s=e(9297),r=e(4901),a=e(8981),c=e(6119),u=e(2211),f=c("IE_PROTO"),g=Object,m=g.prototype;o.exports=u?g.getPrototypeOf:function(y){var v=a(y);if(s(v,f))return v[f];var S=v.constructor;return r(S)&&v instanceof S?S.prototype:v instanceof g?m:null}}),1625:((o,t,e)=>{var s=e(9504);o.exports=s({}.isPrototypeOf)}),1828:((o,t,e)=>{var s=e(9504),r=e(9297),a=e(5397),c=e(9617).indexOf,u=e(421),f=s([].push);o.exports=function(g,m){var y=a(g),v=0,S=[],T;for(T in y)!r(u,T)&&r(y,T)&&f(S,T);for(;m.length>v;)r(y,T=m[v++])&&(~c(S,T)||f(S,T));return S}}),1072:((o,t,e)=>{var s=e(1828),r=e(8727);o.exports=Object.keys||function(c){return s(c,r)}}),8773:((o,t)=>{var e={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,r=s&&!e.call({1:2},1);t.f=r?function(c){var u=s(this,c);return!!u&&u.enumerable}:e}),2967:((o,t,e)=>{var s=e(6706),r=e(34),a=e(7750),c=e(3506);o.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var u=!1,f={},g;try{g=s(Object.prototype,"__proto__","set"),g(f,[]),u=f instanceof Array}catch{}return function(y,v){return a(y),c(v),r(y)&&(u?g(y,v):y.__proto__=v),y}})():void 0)}),4270:((o,t,e)=>{var s=e(9565),r=e(4901),a=e(34),c=TypeError;o.exports=function(u,f){var g,m;if(f==="string"&&r(g=u.toString)&&!a(m=s(g,u))||r(g=u.valueOf)&&!a(m=s(g,u))||f!=="string"&&r(g=u.toString)&&!a(m=s(g,u)))return m;throw new c("Can't convert object to primitive value")}}),5031:((o,t,e)=>{var s=e(7751),r=e(9504),a=e(8480),c=e(3717),u=e(8551),f=r([].concat);o.exports=s("Reflect","ownKeys")||function(m){var y=a.f(u(m)),v=c.f;return v?f(y,v(m)):y}}),8235:((o,t,e)=>{var s=e(9504),r=e(9297),a=SyntaxError,c=parseInt,u=String.fromCharCode,f=s("".charAt),g=s("".slice),m=s(/./.exec),y={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
|
|
2
|
-
`,"\\r":"\r","\\t":" "},v=/^[\da-f]{4}$/i,S=/^[\u0000-\u001F]$/;o.exports=function(T,w){for(var I=!0,k="";w<T.length;){var L=f(T,w);if(L==="\\"){var M=g(T,w,w+2);if(r(y,M))k+=y[M],w+=2;else if(M==="\\u"){w+=2;var N=g(T,w,w+4);if(!m(v,N))throw new a("Bad Unicode escape at: "+w);k+=u(c(N,16)),w+=4}else throw new a('Unknown escape sequence: "'+M+'"')}else if(L==='"'){I=!1,w++;break}else{if(m(S,L))throw new a("Bad control character in string literal at: "+w);k+=L,w++}}if(I)throw new a("Unterminated string at: "+w);return{value:k,end:w}}}),1103:(o=>{o.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}}),7750:((o,t,e)=>{var s=e(4117),r=TypeError;o.exports=function(a){if(s(a))throw new r("Can't call method on "+a);return a}}),9286:((o,t,e)=>{var s=e(4402),r=e(8469),a=s.Set,c=s.add;o.exports=function(u){var f=new a;return r(u,function(g){c(f,g)}),f}}),3440:((o,t,e)=>{var s=e(7080),r=e(4402),a=e(9286),c=e(5170),u=e(3789),f=e(8469),g=e(507),m=r.has,y=r.remove;o.exports=function(S){var T=s(this),w=u(S),I=a(T);return c(T)<=w.size?f(T,function(k){w.includes(k)&&y(I,k)}):g(w.getIterator(),function(k){m(T,k)&&y(I,k)}),I}}),4402:((o,t,e)=>{var s=e(9504),r=Set.prototype;o.exports={Set,add:s(r.add),has:s(r.has),remove:s(r.delete),proto:r}}),8750:((o,t,e)=>{var s=e(7080),r=e(4402),a=e(5170),c=e(3789),u=e(8469),f=e(507),g=r.Set,m=r.add,y=r.has;o.exports=function(S){var T=s(this),w=c(S),I=new g;return a(T)>w.size?f(w.getIterator(),function(k){y(T,k)&&m(I,k)}):u(T,function(k){w.includes(k)&&m(I,k)}),I}}),4449:((o,t,e)=>{var s=e(7080),r=e(4402).has,a=e(5170),c=e(3789),u=e(8469),f=e(507),g=e(9539);o.exports=function(y){var v=s(this),S=c(y);if(a(v)<=S.size)return u(v,function(w){if(S.includes(w))return!1},!0)!==!1;var T=S.getIterator();return f(T,function(w){if(r(v,w))return g(T,"normal",!1)})!==!1}}),3838:((o,t,e)=>{var s=e(7080),r=e(5170),a=e(8469),c=e(3789);o.exports=function(f){var g=s(this),m=c(f);return r(g)>m.size?!1:a(g,function(y){if(!m.includes(y))return!1},!0)!==!1}}),8527:((o,t,e)=>{var s=e(7080),r=e(4402).has,a=e(5170),c=e(3789),u=e(507),f=e(9539);o.exports=function(m){var y=s(this),v=c(m);if(a(y)<v.size)return!1;var S=v.getIterator();return u(S,function(T){if(!r(y,T))return f(S,"normal",!1)})!==!1}}),8469:((o,t,e)=>{var s=e(9504),r=e(507),a=e(4402),c=a.Set,u=a.proto,f=s(u.forEach),g=s(u.keys),m=g(new c).next;o.exports=function(y,v,S){return S?r({iterator:g(y),next:m},v):f(y,v)}}),4916:((o,t,e)=>{var s=e(7751),r=function(a){return{size:a,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}};o.exports=function(a){var c=s("Set");try{new c()[a](r(0));try{return new c()[a](r(-1)),!1}catch{return!0}}catch{return!1}}}),5170:((o,t,e)=>{var s=e(6706),r=e(4402);o.exports=s(r.proto,"size","get")||function(a){return a.size}}),3650:((o,t,e)=>{var s=e(7080),r=e(4402),a=e(9286),c=e(3789),u=e(507),f=r.add,g=r.has,m=r.remove;o.exports=function(v){var S=s(this),T=c(v).getIterator(),w=a(S);return u(T,function(I){g(S,I)?m(w,I):f(w,I)}),w}}),4204:((o,t,e)=>{var s=e(7080),r=e(4402).add,a=e(9286),c=e(3789),u=e(507);o.exports=function(g){var m=s(this),y=c(g).getIterator(),v=a(m);return u(y,function(S){r(v,S)}),v}}),6119:((o,t,e)=>{var s=e(5745),r=e(3392),a=s("keys");o.exports=function(c){return a[c]||(a[c]=r(c))}}),7629:((o,t,e)=>{var s=e(6395),r=e(4576),a=e(9433),c="__core-js_shared__",u=o.exports=r[c]||a(c,{});(u.versions||(u.versions=[])).push({version:"3.39.0",mode:s?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),5745:((o,t,e)=>{var s=e(7629);o.exports=function(r,a){return s[r]||(s[r]=a||{})}}),1548:((o,t,e)=>{var s=e(4576),r=e(9039),a=e(9519),c=e(4215),u=s.structuredClone;o.exports=!!u&&!r(function(){if(c==="DENO"&&a>92||c==="NODE"&&a>94||c==="BROWSER"&&a>97)return!1;var f=new ArrayBuffer(8),g=u(f,{transfer:[f]});return f.byteLength!==0||g.byteLength!==8})}),4495:((o,t,e)=>{var s=e(9519),r=e(9039),a=e(4576),c=a.String;o.exports=!!Object.getOwnPropertySymbols&&!r(function(){var u=Symbol("symbol detection");return!c(u)||!(Object(u)instanceof Symbol)||!Symbol.sham&&s&&s<41})}),5610:((o,t,e)=>{var s=e(1291),r=Math.max,a=Math.min;o.exports=function(c,u){var f=s(c);return f<0?r(f+u,0):a(f,u)}}),5854:((o,t,e)=>{var s=e(2777),r=TypeError;o.exports=function(a){var c=s(a,"number");if(typeof c=="number")throw new r("Can't convert number to bigint");return BigInt(c)}}),7696:((o,t,e)=>{var s=e(1291),r=e(8014),a=RangeError;o.exports=function(c){if(c===void 0)return 0;var u=s(c),f=r(u);if(u!==f)throw new a("Wrong length or index");return f}}),5397:((o,t,e)=>{var s=e(7055),r=e(7750);o.exports=function(a){return s(r(a))}}),1291:((o,t,e)=>{var s=e(741);o.exports=function(r){var a=+r;return a!==a||a===0?0:s(a)}}),8014:((o,t,e)=>{var s=e(1291),r=Math.min;o.exports=function(a){var c=s(a);return c>0?r(c,9007199254740991):0}}),8981:((o,t,e)=>{var s=e(7750),r=Object;o.exports=function(a){return r(s(a))}}),9590:((o,t,e)=>{var s=e(1291),r=RangeError;o.exports=function(a){var c=s(a);if(c<0)throw new r("The argument can't be less than 0");return c}}),2777:((o,t,e)=>{var s=e(9565),r=e(34),a=e(757),c=e(5966),u=e(4270),f=e(8227),g=TypeError,m=f("toPrimitive");o.exports=function(y,v){if(!r(y)||a(y))return y;var S=c(y,m),T;if(S){if(v===void 0&&(v="default"),T=s(S,y,v),!r(T)||a(T))return T;throw new g("Can't convert object to primitive value")}return v===void 0&&(v="number"),u(y,v)}}),6969:((o,t,e)=>{var s=e(2777),r=e(757);o.exports=function(a){var c=s(a,"string");return r(c)?c:c+""}}),2140:((o,t,e)=>{var s=e(8227),r=s("toStringTag"),a={};a[r]="z",o.exports=String(a)==="[object z]"}),655:((o,t,e)=>{var s=e(6955),r=String;o.exports=function(a){if(s(a)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return r(a)}}),6823:(o=>{var t=String;o.exports=function(e){try{return t(e)}catch{return"Object"}}}),3392:((o,t,e)=>{var s=e(9504),r=0,a=Math.random(),c=s(1 .toString);o.exports=function(u){return"Symbol("+(u===void 0?"":u)+")_"+c(++r+a,36)}}),7040:((o,t,e)=>{var s=e(4495);o.exports=s&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),8686:((o,t,e)=>{var s=e(3724),r=e(9039);o.exports=s&&r(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),2812:(o=>{var t=TypeError;o.exports=function(e,s){if(e<s)throw new t("Not enough arguments");return e}}),8622:((o,t,e)=>{var s=e(4576),r=e(4901),a=s.WeakMap;o.exports=r(a)&&/native code/.test(String(a))}),8227:((o,t,e)=>{var s=e(4576),r=e(5745),a=e(9297),c=e(3392),u=e(4495),f=e(7040),g=s.Symbol,m=r("wks"),y=f?g.for||g:g&&g.withoutSetter||c;o.exports=function(v){return a(m,v)||(m[v]=u&&a(g,v)?g[v]:y("Symbol."+v)),m[v]}}),6573:((o,t,e)=>{var s=e(3724),r=e(2106),a=e(3238),c=ArrayBuffer.prototype;s&&!("detached"in c)&&r(c,"detached",{configurable:!0,get:function(){return a(this)}})}),7936:((o,t,e)=>{var s=e(6518),r=e(5636);r&&s({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return r(this,arguments.length?arguments[0]:void 0,!1)}})}),8100:((o,t,e)=>{var s=e(6518),r=e(5636);r&&s({target:"ArrayBuffer",proto:!0},{transfer:function(){return r(this,arguments.length?arguments[0]:void 0,!0)}})}),4114:((o,t,e)=>{var s=e(6518),r=e(8981),a=e(6198),c=e(4527),u=e(6837),f=e(9039),g=f(function(){return[].push.call({length:4294967296},1)!==4294967297}),m=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(v){return v instanceof TypeError}},y=g||!m();s({target:"Array",proto:!0,arity:1,forced:y},{push:function(S){var T=r(this),w=a(T),I=arguments.length;u(w+I);for(var k=0;k<I;k++)T[w]=arguments[k],w++;return c(T,w),w}})}),8111:((o,t,e)=>{var s=e(6518),r=e(4576),a=e(679),c=e(8551),u=e(4901),f=e(2787),g=e(2106),m=e(4659),y=e(9039),v=e(9297),S=e(8227),T=e(7657).IteratorPrototype,w=e(3724),I=e(6395),k="constructor",L="Iterator",M=S("toStringTag"),N=TypeError,F=r[L],B=I||!u(F)||F.prototype!==T||!y(function(){F({})}),G=function(){if(a(this,T),f(this)===T)throw new N("Abstract class Iterator not directly constructable")},$=function(z,J){w?g(T,z,{configurable:!0,get:function(){return J},set:function(et){if(c(this),this===T)throw new N("You can't redefine this property");v(this,z)?this[z]=et:m(this,z,et)}}):T[z]=J};v(T,M)||$(M,L),(B||!v(T,k)||T[k]===Object)&&$(k,G),G.prototype=T,s({global:!0,constructor:!0,forced:B},{Iterator:G})}),9314:((o,t,e)=>{var s=e(6518),r=e(9565),a=e(8551),c=e(1767),u=e(4149),f=e(9590),g=e(9462),m=e(6395),y=g(function(){for(var v=this.iterator,S=this.next,T,w;this.remaining;)if(this.remaining--,T=a(r(S,v)),w=this.done=!!T.done,w)return;if(T=a(r(S,v)),w=this.done=!!T.done,!w)return T.value});s({target:"Iterator",proto:!0,real:!0,forced:m},{drop:function(S){a(this);var T=f(u(+S));return new y(c(this),{remaining:T})}})}),1148:((o,t,e)=>{var s=e(6518),r=e(2652),a=e(9306),c=e(8551),u=e(1767);s({target:"Iterator",proto:!0,real:!0},{every:function(g){c(this),a(g);var m=u(this),y=0;return!r(m,function(v,S){if(!g(v,y++))return S()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),2489:((o,t,e)=>{var s=e(6518),r=e(9565),a=e(9306),c=e(8551),u=e(1767),f=e(9462),g=e(6319),m=e(6395),y=f(function(){for(var v=this.iterator,S=this.predicate,T=this.next,w,I,k;;){if(w=c(r(T,v)),I=this.done=!!w.done,I)return;if(k=w.value,g(v,S,[k,this.counter++],!0))return k}});s({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(S){return c(this),a(S),new y(u(this),{predicate:S})}})}),531:((o,t,e)=>{var s=e(6518),r=e(9565),a=e(9306),c=e(8551),u=e(1767),f=e(8646),g=e(9462),m=e(9539),y=e(6395),v=g(function(){for(var S=this.iterator,T=this.mapper,w,I;;){if(I=this.inner)try{if(w=c(r(I.next,I.iterator)),!w.done)return w.value;this.inner=null}catch(k){m(S,"throw",k)}if(w=c(r(this.next,S)),this.done=!!w.done)return;try{this.inner=f(T(w.value,this.counter++),!1)}catch(k){m(S,"throw",k)}}});s({target:"Iterator",proto:!0,real:!0,forced:y},{flatMap:function(T){return c(this),a(T),new v(u(this),{mapper:T,inner:null})}})}),1701:((o,t,e)=>{var s=e(6518),r=e(713),a=e(6395);s({target:"Iterator",proto:!0,real:!0,forced:a},{map:r})}),3579:((o,t,e)=>{var s=e(6518),r=e(2652),a=e(9306),c=e(8551),u=e(1767);s({target:"Iterator",proto:!0,real:!0},{some:function(g){c(this),a(g);var m=u(this),y=0;return r(m,function(v,S){if(g(v,y++))return S()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),1689:((o,t,e)=>{var s=e(6518),r=e(4576),a=e(8745),c=e(7680),u=e(6043),f=e(9306),g=e(1103),m=r.Promise,y=!1,v=!m||!m.try||g(function(){m.try(function(S){y=S===8},8)}).error||!y;s({target:"Promise",stat:!0,forced:v},{try:function(S){var T=arguments.length>1?c(arguments,1):[],w=u.f(this),I=g(function(){return a(f(S),void 0,T)});return(I.error?w.reject:w.resolve)(I.value),w.promise}})}),4628:((o,t,e)=>{var s=e(6518),r=e(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var c=r.f(this);return{promise:c.promise,resolve:c.resolve,reject:c.reject}}})}),7642:((o,t,e)=>{var s=e(6518),r=e(3440),a=e(4916);s({target:"Set",proto:!0,real:!0,forced:!a("difference")},{difference:r})}),8004:((o,t,e)=>{var s=e(6518),r=e(9039),a=e(8750),c=e(4916),u=!c("intersection")||r(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});s({target:"Set",proto:!0,real:!0,forced:u},{intersection:a})}),3853:((o,t,e)=>{var s=e(6518),r=e(4449),a=e(4916);s({target:"Set",proto:!0,real:!0,forced:!a("isDisjointFrom")},{isDisjointFrom:r})}),5876:((o,t,e)=>{var s=e(6518),r=e(3838),a=e(4916);s({target:"Set",proto:!0,real:!0,forced:!a("isSubsetOf")},{isSubsetOf:r})}),2475:((o,t,e)=>{var s=e(6518),r=e(8527),a=e(4916);s({target:"Set",proto:!0,real:!0,forced:!a("isSupersetOf")},{isSupersetOf:r})}),5024:((o,t,e)=>{var s=e(6518),r=e(3650),a=e(4916);s({target:"Set",proto:!0,real:!0,forced:!a("symmetricDifference")},{symmetricDifference:r})}),1698:((o,t,e)=>{var s=e(6518),r=e(4204),a=e(4916);s({target:"Set",proto:!0,real:!0,forced:!a("union")},{union:r})}),7467:((o,t,e)=>{var s=e(7628),r=e(4644),a=r.aTypedArray,c=r.exportTypedArrayMethod,u=r.getTypedArrayConstructor;c("toReversed",function(){return s(a(this),u(this))})}),4732:((o,t,e)=>{var s=e(4644),r=e(9504),a=e(9306),c=e(5370),u=s.aTypedArray,f=s.getTypedArrayConstructor,g=s.exportTypedArrayMethod,m=r(s.TypedArrayPrototype.sort);g("toSorted",function(v){v!==void 0&&a(v);var S=u(this),T=c(f(S),S);return m(T,v)})}),9577:((o,t,e)=>{var s=e(9928),r=e(4644),a=e(1108),c=e(1291),u=e(5854),f=r.aTypedArray,g=r.getTypedArrayConstructor,m=r.exportTypedArrayMethod,y=!!(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(v){return v===8}})();m("with",function(v,S){var T=f(this),w=c(v),I=a(T)?u(S):+S;return s(T,g(T),w,I)},!y)}),8992:((o,t,e)=>{e(8111)}),4743:((o,t,e)=>{e(9314)}),3215:((o,t,e)=>{e(1148)}),4520:((o,t,e)=>{e(2489)}),670:((o,t,e)=>{e(531)}),1454:((o,t,e)=>{e(1701)}),7550:((o,t,e)=>{e(3579)}),8335:((o,t,e)=>{var s=e(6518),r=e(3724),a=e(4576),c=e(7751),u=e(9504),f=e(9565),g=e(4901),m=e(34),y=e(4376),v=e(9297),S=e(655),T=e(6198),w=e(4659),I=e(9039),k=e(8235),L=e(4495),M=a.JSON,N=a.Number,F=a.SyntaxError,B=M&&M.parse,G=c("Object","keys"),$=Object.getOwnPropertyDescriptor,z=u("".charAt),J=u("".slice),et=u(/./.exec),nt=u([].push),xt=/^\d$/,vt=/^[1-9]$/,St=/^[\d-]$/,W=/^[\t\n\r ]$/,K=0,pt=1,ft=function(Y,j){Y=S(Y);var H=new tt(Y,0,""),Tt=H.parse(),Ot=Tt.value,Ct=H.skip(W,Tt.end);if(Ct<Y.length)throw new F('Unexpected extra character: "'+z(Y,Ct)+'" after the parsed data at: '+Ct);return g(j)?X({"":Ot},"",j,Tt):Ot},X=function(Y,j,H,Tt){var Ot=Y[j],Ct=Tt&&Ot===Tt.value,zt=Ct&&typeof Tt.source=="string"?{source:Tt.source}:{},Nt,q,at,Ft,Me;if(m(Ot)){var nn=y(Ot),Ze=Ct?Tt.nodes:nn?[]:{};if(nn)for(Nt=Ze.length,at=T(Ot),Ft=0;Ft<at;Ft++)gt(Ot,Ft,X(Ot,""+Ft,H,Ft<Nt?Ze[Ft]:void 0));else for(q=G(Ot),at=T(q),Ft=0;Ft<at;Ft++)Me=q[Ft],gt(Ot,Me,X(Ot,Me,H,v(Ze,Me)?Ze[Me]:void 0))}return f(H,Y,j,Ot,zt)},gt=function(Y,j,H){if(r){var Tt=$(Y,j);if(Tt&&!Tt.configurable)return}H===void 0?delete Y[j]:w(Y,j,H)},Z=function(Y,j,H,Tt){this.value=Y,this.end=j,this.source=H,this.nodes=Tt},tt=function(Y,j){this.source=Y,this.index=j};tt.prototype={fork:function(Y){return new tt(this.source,Y)},parse:function(){var Y=this.source,j=this.skip(W,this.index),H=this.fork(j),Tt=z(Y,j);if(et(St,Tt))return H.number();switch(Tt){case"{":return H.object();case"[":return H.array();case'"':return H.string();case"t":return H.keyword(!0);case"f":return H.keyword(!1);case"n":return H.keyword(null)}throw new F('Unexpected character: "'+Tt+'" at: '+j)},node:function(Y,j,H,Tt,Ot){return new Z(j,Tt,Y?null:J(this.source,H,Tt),Ot)},object:function(){for(var Y=this.source,j=this.index+1,H=!1,Tt={},Ot={};j<Y.length;){if(j=this.until(['"',"}"],j),z(Y,j)==="}"&&!H){j++;break}var Ct=this.fork(j).string(),zt=Ct.value;j=Ct.end,j=this.until([":"],j)+1,j=this.skip(W,j),Ct=this.fork(j).parse(),w(Ot,zt,Ct),w(Tt,zt,Ct.value),j=this.until([",","}"],Ct.end);var Nt=z(Y,j);if(Nt===",")H=!0,j++;else if(Nt==="}"){j++;break}}return this.node(pt,Tt,this.index,j,Ot)},array:function(){for(var Y=this.source,j=this.index+1,H=!1,Tt=[],Ot=[];j<Y.length;){if(j=this.skip(W,j),z(Y,j)==="]"&&!H){j++;break}var Ct=this.fork(j).parse();if(nt(Ot,Ct),nt(Tt,Ct.value),j=this.until([",","]"],Ct.end),z(Y,j)===",")H=!0,j++;else if(z(Y,j)==="]"){j++;break}}return this.node(pt,Tt,this.index,j,Ot)},string:function(){var Y=this.index,j=k(this.source,this.index+1);return this.node(K,j.value,Y,j.end)},number:function(){var Y=this.source,j=this.index,H=j;if(z(Y,H)==="-"&&H++,z(Y,H)==="0")H++;else if(et(vt,z(Y,H)))H=this.skip(xt,H+1);else throw new F("Failed to parse number at: "+H);if(z(Y,H)==="."&&(H=this.skip(xt,H+1)),z(Y,H)==="e"||z(Y,H)==="E"){H++,(z(Y,H)==="+"||z(Y,H)==="-")&&H++;var Tt=H;if(H=this.skip(xt,H),Tt===H)throw new F("Failed to parse number's exponent value at: "+H)}return this.node(K,N(J(Y,j,H)),j,H)},keyword:function(Y){var j=""+Y,H=this.index,Tt=H+j.length;if(J(this.source,H,Tt)!==j)throw new F("Failed to parse value at: "+H);return this.node(K,Y,H,Tt)},skip:function(Y,j){for(var H=this.source;j<H.length&&et(Y,z(H,j));j++);return j},until:function(Y,j){j=this.skip(W,j);for(var H=z(this.source,j),Tt=0;Tt<Y.length;Tt++)if(Y[Tt]===H)return j;throw new F('Unexpected character: "'+H+'" at: '+j)}};var ct=I(function(){var Y="9007199254740993",j;return B(Y,function(H,Tt,Ot){j=Ot.source}),j!==Y}),st=L&&!I(function(){return 1/B("-0 ")!==-1/0});s({target:"JSON",stat:!0,forced:ct},{parse:function(j,H){return st&&!g(H)?B(j):ft(j,H)}})}),5247:((o,t,e)=>{e(1689)}),4979:((o,t,e)=>{var s=e(6518),r=e(4576),a=e(7751),c=e(6980),u=e(4913).f,f=e(9297),g=e(679),m=e(3167),y=e(2603),v=e(5002),S=e(8574),T=e(3724),w=e(6395),I="DOMException",k=a("Error"),L=a(I),M=function(){g(this,N);var W=arguments.length,K=y(W<1?void 0:arguments[0]),pt=y(W<2?void 0:arguments[1],"Error"),ft=new L(K,pt),X=new k(K);return X.name=I,u(ft,"stack",c(1,S(X.stack,1))),m(ft,this,M),ft},N=M.prototype=L.prototype,F="stack"in new k(I),B="stack"in new L(1,2),G=L&&T&&Object.getOwnPropertyDescriptor(r,I),$=!!G&&!(G.writable&&G.configurable),z=F&&!$&&!B;s({global:!0,constructor:!0,forced:w||z},{DOMException:z?M:L});var J=a(I),et=J.prototype;if(et.constructor!==J){w||u(et,"constructor",c(1,J));for(var nt in v)if(f(v,nt)){var xt=v[nt],vt=xt.s;f(J,vt)||u(J,vt,c(6,xt.c))}}}),4603:((o,t,e)=>{var s=e(6840),r=e(9504),a=e(655),c=e(2812),u=URLSearchParams,f=u.prototype,g=r(f.append),m=r(f.delete),y=r(f.forEach),v=r([].push),S=new u("a=1&a=2&b=3");S.delete("a",1),S.delete("b",void 0),S+""!="a=2"&&s(f,"delete",function(T){var w=arguments.length,I=w<2?void 0:arguments[1];if(w&&I===void 0)return m(this,T);var k=[];y(this,function(z,J){v(k,{key:J,value:z})}),c(w,1);for(var L=a(T),M=a(I),N=0,F=0,B=!1,G=k.length,$;N<G;)$=k[N++],B||$.key===L?(B=!0,m(this,$.key)):F++;for(;F<G;)$=k[F++],$.key===L&&$.value===M||g(this,$.key,$.value)},{enumerable:!0,unsafe:!0})}),7566:((o,t,e)=>{var s=e(6840),r=e(9504),a=e(655),c=e(2812),u=URLSearchParams,f=u.prototype,g=r(f.getAll),m=r(f.has),y=new u("a=1");(y.has("a",2)||!y.has("a",void 0))&&s(f,"has",function(S){var T=arguments.length,w=T<2?void 0:arguments[1];if(T&&w===void 0)return m(this,S);var I=g(this,S);c(T,1);for(var k=a(w),L=0;L<I.length;)if(I[L++]===k)return!0;return!1},{enumerable:!0,unsafe:!0})}),8721:((o,t,e)=>{var s=e(3724),r=e(9504),a=e(2106),c=URLSearchParams.prototype,u=r(c.forEach);s&&!("size"in c)&&a(c,"size",{get:function(){var g=0;return u(this,function(){g++}),g},configurable:!0,enumerable:!0})})},Dc={};Mt.d=(o,t)=>{for(var e in t)Mt.o(t,e)&&!Mt.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:t[e]})};Mt.o=(o,t)=>Object.prototype.hasOwnProperty.call(o,t);Et=globalThis.pdfjsLib={};Mt.d(Et,{AbortException:()=>Ke,AnnotationEditorLayer:()=>ya,AnnotationEditorParamsType:()=>Lt,AnnotationEditorType:()=>Rt,AnnotationEditorUIManager:()=>Rn,AnnotationLayer:()=>aa,AnnotationMode:()=>dn,ColorPicker:()=>Hr,DOMSVGFactory:()=>Ts,DrawLayer:()=>ba,FeatureTest:()=>ne,GlobalWorkerOptions:()=>En,ImageKind:()=>dr,InvalidPDFException:()=>gs,MissingPDFException:()=>wn,OPS:()=>Ge,OutputScale:()=>bs,PDFDataRangeTransport:()=>Rr,PDFDateString:()=>gr,PDFWorker:()=>Yn,PasswordResponses:()=>C0,PermissionFlag:()=>T0,PixelsPerInch:()=>pn,RenderingCancelledException:()=>ys,TextLayer:()=>Ss,TouchManager:()=>br,UnexpectedResponseException:()=>Kn,Util:()=>bt,VerbosityLevel:()=>$r,XfaLayer:()=>Lr,build:()=>dy,createValidAbsoluteUrl:()=>I0,fetchData:()=>Yr,getDocument:()=>ly,getFilenameFromUrl:()=>_0,getPdfFilenameFromUrl:()=>N0,getXfaPageViewport:()=>U0,isDataScheme:()=>Kr,isPdfFile:()=>Sa,noContextMenu:()=>He,normalizeUnicode:()=>M0,setLayerDimensions:()=>kn,shadow:()=>Pt,stopEvent:()=>Ee,version:()=>hy});xx=Mt(4114),Sx=Mt(6573),Ax=Mt(8100),Tx=Mt(7936),Cx=Mt(7467),Ex=Mt(4732),wx=Mt(9577),kx=Mt(5247),Ix=Mt(4979),Rx=Mt(4603),Px=Mt(7566),Ox=Mt(8721),ce=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Kc=[1,0,0,1,0,0],Zi=[.001,0,0,.001,0,0],x0=1e7,hr=1.35,S0=.35,Lx=S0/hr,Ce={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},dn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},A0="pdfjs_internal_editor_",Rt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Lt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},T0={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ae={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},dr={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ee={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},cs={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},$r={ERRORS:0,WARNINGS:1,INFOS:5},Ge={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},C0={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},zr=$r.WARNINGS;gn=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})(),fr=class extends gn{constructor(t,e){super(t,"PasswordException"),this.code=e}},ps=class extends gn{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},gs=class extends gn{constructor(t){super(t,"InvalidPDFException")}},wn=class extends gn{constructor(t){super(t,"MissingPDFException")}},Kn=class extends gn{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},Qi=class extends gn{constructor(t){super(t,"FormatError")}},Ke=class extends gn{constructor(t){super(t,"AbortException")}};ne=class{static get isLittleEndian(){return Pt(this,"isLittleEndian",P0())}static get isEvalSupported(){return Pt(this,"isEvalSupported",O0())}static get isOffscreenCanvasSupported(){return Pt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Pt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?Pt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):Pt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Pt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},zi=Array.from(Array(256).keys(),o=>o.toString(16).padStart(2,"0")),bt=class{static makeHexColor(t,e,s){return`#${zi[t]}${zi[e]}${zi[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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){let s=t[0]*e[0]+t[1]*e[2]+e[4],r=t[0]*e[1]+t[1]*e[3]+e[5];return[s,r]}static applyInverseTransform(t,e){let s=e[0]*e[3]-e[1]*e[2],r=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,a=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[r,a]}static getAxialAlignedBoundingBox(t,e){let s=this.applyTransform(t,e),r=this.applyTransform(t.slice(2,4),e),a=this.applyTransform([t[0],t[3]],e),c=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],r[0],a[0],c[0]),Math.min(s[1],r[1],a[1],c[1]),Math.max(s[0],r[0],a[0],c[0]),Math.max(s[1],r[1],a[1],c[1])]}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){let e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],r=t[0]*e[1]+t[1]*e[3],a=t[2]*e[0]+t[3]*e[2],c=t[2]*e[1]+t[3]*e[3],u=(s+c)/2,f=Math.sqrt((s+c)**2-4*(s*c-a*r))/2,g=u+f||1,m=u-f||1;return[Math.sqrt(g),Math.sqrt(m)]}static normalizeRect(t){let 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){let s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),r=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>r)return null;let a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),c=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>c?null:[s,a,r,c]}static#t(t,e,s,r,a,c,u,f,g,m){if(g<=0||g>=1)return;let y=1-g,v=g*g,S=v*g,T=y*(y*(y*t+3*g*e)+3*v*s)+S*r,w=y*(y*(y*a+3*g*c)+3*v*u)+S*f;m[0]=Math.min(m[0],T),m[1]=Math.min(m[1],w),m[2]=Math.max(m[2],T),m[3]=Math.max(m[3],w)}static#e(t,e,s,r,a,c,u,f,g,m,y,v){if(Math.abs(g)<1e-12){Math.abs(m)>=1e-12&&this.#t(t,e,s,r,a,c,u,f,-y/m,v);return}let S=m**2-4*y*g;if(S<0)return;let T=Math.sqrt(S),w=2*g;this.#t(t,e,s,r,a,c,u,f,(-m+T)/w,v),this.#t(t,e,s,r,a,c,u,f,(-m-T)/w,v)}static bezierBoundingBox(t,e,s,r,a,c,u,f,g){return g?(g[0]=Math.min(g[0],t,u),g[1]=Math.min(g[1],e,f),g[2]=Math.max(g[2],t,u),g[3]=Math.max(g[3],e,f)):g=[Math.min(t,u),Math.min(e,f),Math.max(t,u),Math.max(e,f)],this.#e(t,s,a,u,e,r,c,f,3*(-t+3*(s-a)+u),6*(t-2*s+a),3*(s-t),g),this.#e(t,s,a,u,e,r,c,f,3*(-e+3*(r-c)+f),6*(e-2*r+c),3*(r-e),g),g}};Wi=null,Fc=null;xa="pdfjs_internal_id_";Mx=Mt(4628),Dx=Mt(7642),Fx=Mt(8004),_x=Mt(3853),Nx=Mt(5876),Ux=Mt(2475),Bx=Mt(5024),Gx=Mt(1698),Hx=Mt(1454),jx=Mt(8992),Vx=Mt(4743),$x=Mt(3215),zx=Mt(7550),Wx=Mt(8335),tn="http://www.w3.org/2000/svg",pn=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};ms=class o{constructor({viewBox:t,userUnit:e,scale:s,rotation:r,offsetX:a=0,offsetY:c=0,dontFlip:u=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=r,this.offsetX=a,this.offsetY=c,s*=e;let f=(t[2]+t[0])/2,g=(t[3]+t[1])/2,m,y,v,S;switch(r%=360,r<0&&(r+=360),r){case 180:m=-1,y=0,v=0,S=1;break;case 90:m=0,y=1,v=1,S=0;break;case 270:m=0,y=-1,v=-1,S=0;break;case 0:m=1,y=0,v=0,S=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}u&&(v=-v,S=-S);let T,w,I,k;m===0?(T=Math.abs(g-t[1])*s+a,w=Math.abs(f-t[0])*s+c,I=(t[3]-t[1])*s,k=(t[2]-t[0])*s):(T=Math.abs(f-t[0])*s+a,w=Math.abs(g-t[1])*s+c,I=(t[2]-t[0])*s,k=(t[3]-t[1])*s),this.transform=[m*s,y*s,v*s,S*s,T-m*s*f-v*s*g,w-y*s*f-S*s*g],this.width=I,this.height=k}get rawDims(){let{userUnit:t,viewBox:e}=this,s=e.map(r=>r*t);return Pt(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:r=this.offsetY,dontFlip:a=!1}={}){return new o({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:r,dontFlip:a})}convertToViewportPoint(t,e){return bt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=bt.applyTransform([t[0],t[1]],this.transform),s=bt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return bt.applyInverseTransform([t,e],this.transform)}},ys=class extends gn{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};pr=class{started=Object.create(null);times=[];time(t){t in this.started&&wt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||wt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:s}of this.times)e=Math.max(s.length,e);for(let{name:s,start:r,end:a}of this.times)t.push(`${s.padEnd(e)} ${a-r}ms
|
|
3
|
-
`);return t.join("")}};gr=class{static#t;static toDateObject(t){if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let s=parseInt(e[1],10),r=parseInt(e[2],10);r=r>=1&&r<=12?r-1:0;let a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let c=parseInt(e[4],10);c=c>=0&&c<=23?c:0;let u=parseInt(e[5],10);u=u>=0&&u<=59?u:0;let f=parseInt(e[6],10);f=f>=0&&f<=59?f:0;let g=e[7]||"Z",m=parseInt(e[8],10);m=m>=0&&m<=23?m:0;let y=parseInt(e[9],10)||0;return y=y>=0&&y<=59?y:0,g==="-"?(c+=m,u+=y):g==="+"&&(c-=m,u-=y),new Date(Date.UTC(s,r,a,c,u,f))}};bs=class{constructor(){let t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},Ji=class o{#t=null;#e=null;#n;#s=null;#i=null;static#r=null;constructor(t){this.#n=t,o.#r||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;t.addEventListener("contextmenu",He,{signal:e}),t.addEventListener("pointerdown",o.#l,{signal:e});let s=this.#s=document.createElement("div");s.className="buttons",t.append(s);let r=this.#n.toolbarPosition;if(r){let{style:a}=t,c=this.#n._uiManager.direction==="ltr"?1-r[0]:r[0];a.insetInlineEnd=`${100*c}%`,a.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#t}static#l(t){t.stopPropagation()}#a(t){this.#n._focusEventsAllowed=!1,Ee(t)}#u(t){this.#n._focusEventsAllowed=!0,Ee(t)}#c(t){let e=this.#n._uiManager._signal;t.addEventListener("focusin",this.#a.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",He,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#i?.shown()}#d(){let{editorType:t,_uiManager:e}=this.#n,s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",o.#r[t]),this.#c(s),s.addEventListener("click",r=>{e.delete()},{signal:e._signal}),this.#s.append(s)}get#h(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#c(e),this.#s.prepend(e,this.#h),this.#i=t}addColorPicker(t){this.#e=t;let e=t.renderButton();this.#c(e),this.#s.prepend(e,this.#h)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},qi=class{#t=null;#e=null;#n;constructor(t){this.#n=t}#s(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",He,{signal:this.#n._signal});let e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#r(),t}#i(t,e){let s=0,r=0;for(let a of t){let c=a.y+a.height;if(c<s)continue;let u=a.x+(e?a.width:0);if(c>s){r=u,s=c;continue}e?u>r&&(r=u):u<r&&(r=u)}return[e?1-r:r,s]}show(t,e,s){let[r,a]=this.#i(e,s),{style:c}=this.#e||=this.#s();t.append(this.#e),c.insetInlineEnd=`${100*r}%`,c.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#r(){let t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let s=this.#n._signal;t.addEventListener("contextmenu",He,{signal:s}),t.addEventListener("click",()=>{this.#n.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}};to=class{#t=0;get id(){return`${A0}${this.#t++}`}},eo=class o{#t=D0();#e=0;#n=null;static get _isSVGFittingCanvas(){let t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),r=new Image;r.src=t;let a=r.decode().then(()=>(s.drawImage(r,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return Pt(this,"_isSVGFittingCanvas",a)}async#s(t,e){this.#n||=new Map;let s=this.#n.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let r;if(typeof e=="string"?(s.url=e,r=await Yr(e,"blob")):e instanceof File?r=s.file=e:e instanceof Blob&&(r=e),r.type==="image/svg+xml"){let a=o._isSVGFittingCanvas,c=new FileReader,u=new Image,f=new Promise((g,m)=>{u.onload=()=>{s.bitmap=u,s.isSvg=!0,g()},c.onload=async()=>{let y=s.svgUrl=c.result;u.src=await a?`${y}#svgView(preserveAspectRatio(none))`:y},u.onerror=c.onerror=m});c.readAsDataURL(r),await f}else s.bitmap=await createImageBitmap(r);s.refCounter=1}catch(r){wt(r),s=null}return this.#n.set(t,s),s&&this.#n.set(s.id,s),s}async getFromFile(t){let{lastModified:e,name:s,size:r,type:a}=t;return this.#s(`${e}_${s}_${r}_${a}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){let s=await e;return this.#s(t,s)}async getFromId(t){this.#n||=new Map;let e=this.#n.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#n||=new Map;let s=this.#n.get(t);if(s?.bitmap)return s.refCounter+=1,s;let r=new OffscreenCanvas(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),s={bitmap:r.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#n.set(t,s),this.#n.set(s.id,s),s}getSvgUrl(t){let e=this.#n.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#n||=new Map;let e=this.#n.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;let{bitmap:s}=e;if(!e.url&&!e.file){let r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}},no=class{#t=[];#e=!1;#n;#s=-1;constructor(t=128){this.#n=t}add({cmd:t,undo:e,post:s,mustExec:r,type:a=NaN,overwriteIfSameType:c=!1,keepUndo:u=!1}){if(r&&t(),this.#e)return;let f={cmd:t,undo:e,post:s,type:a};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(f);return}if(c&&this.#t[this.#s].type===a){u&&(f.undo=this.#t[this.#s].undo),this.#t[this.#s]=f;return}let g=this.#s+1;g===this.#n?this.#t.splice(0,1):(this.#s=g,g<this.#t.length&&this.#t.splice(g)),this.#t.push(f)}undo(){if(this.#s===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(this.#s!==-1){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#s-e),this.#s=e;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}},In=class{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=ne.platform;for(let[s,r,a={}]of t)for(let c of s){let u=c.startsWith("mac+");e&&u?(this.callbacks.set(c.slice(4),{callback:r,options:a}),this.allKeys.add(c.split("+").at(-1))):!e&&!u&&(this.callbacks.set(c,{callback:r,options:a}),this.allKeys.add(c.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let s=this.callbacks.get(this.#t(e));if(!s)return;let{callback:r,options:{bubbles:a=!1,args:c=[],checker:u=null}}=s;u&&!u(t,e)||(r.bind(t,...c,e)(),a||Ee(e))}},so=class o{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return B0(t),Pt(this,"_colors",t)}convert(t){let e=Aa(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[s,r]of this._colors)if(r.every((a,c)=>a===e[c]))return o._colorsMapping.get(s);return e}getHexCode(t){let e=this._colors.get(t);return e?bt.makeHexColor(...e):t}},Rn=class o{#t=new AbortController;#e=null;#n=new Map;#s=new Map;#i=null;#r=null;#l=null;#a=new no;#u=null;#c=null;#d=0;#h=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#y=!1;#x=null;#b=null;#S=null;#T=null;#E=!1;#k=null;#R=new to;#A=!1;#I=!1;#w=null;#O=null;#D=null;#_=null;#C=Rt.NONE;#v=new Set;#M=null;#H=null;#j=null;#V={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#F=null;#U=null;#$=null;#L=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=o.prototype,e=c=>c.#U.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&c.hasSomethingToControl(),s=(c,{target:u})=>{if(u instanceof HTMLInputElement){let{type:f}=u;return f!=="text"&&f!=="number"}return!0},r=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return Pt(this,"_keyboardManager",new In([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(c,{target:u})=>!(u instanceof HTMLButtonElement)&&c.#U.contains(u)&&!c.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(c,{target:u})=>!(u instanceof HTMLButtonElement)&&c.#U.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}constructor(t,e,s,r,a,c,u,f,g,m,y,v,S){let T=this._signal=this.#t.signal;this.#U=t,this.#$=e,this.#i=s,this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:T}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:T}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:T}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:T}),r._on("setpreference",this.onSetPreference.bind(this),{signal:T}),r._on("switchannotationeditorparams",w=>this.updateParams(w.type,w.value),{signal:T}),this.#et(),this.#it(),this.#Y(),this.#r=a.annotationStorage,this.#x=a.filterFactory,this.#H=c,this.#T=u||null,this.#m=f,this.#g=g,this.#y=m,this.#_=y||null,this.viewParameters={realScale:pn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=v||null,this._supportsPinchToZoom=S!==!1}destroy(){this.#L?.resolve(),this.#L=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#s.values())t.destroy();this.#s.clear(),this.#n.clear(),this.#p.clear(),this.#e=null,this.#v.clear(),this.#a.destroy(),this.#i?.destroy(),this.#k?.hide(),this.#k=null,this.#b&&(clearTimeout(this.#b),this.#b=null),this.#F&&(clearTimeout(this.#F),this.#F=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#_}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#y}get hcmFilter(){return Pt(this,"hcmFilter",this.#H?this.#x.addHCMFilter(this.#H.foreground,this.#H.background):"none")}get direction(){return Pt(this,"direction",getComputedStyle(this.#U).direction)}get highlightColors(){return Pt(this,"highlightColors",this.#T?new Map(this.#T.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return Pt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#c=t}setMainHighlightColorPicker(t){this.#D=t}editAltText(t,e=!1){this.#i?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#y=e;break}}onPageChanging({pageNumber:t}){this.#d=t-1}focusMainContainer(){this.#U.focus()}findParent(t,e){for(let s of this.#s.values()){let{x:r,y:a,width:c,height:u}=s.div.getBoundingClientRect();if(t>=r&&t<=r+c&&e>=a&&e<=a+u)return s}return null}disableUserSelect(t=!1){this.#$.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*pn.PDF_TO_CSS_UNITS;for(let e of this.#p)e.onScaleChanging();this.#c?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#B({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let s of this.#s.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:s,anchorOffset:r,focusNode:a,focusOffset:c}=e,u=e.toString(),g=this.#B(e).closest(".textLayer"),m=this.getSelectionBoxes(g);if(!m)return;e.empty();let y=this.#X(g),v=this.#C===Rt.NONE,S=()=>{y?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:m,anchorNode:s,anchorOffset:r,focusNode:a,focusOffset:c,text:u}),v&&this.showAllEditors("highlight",!0,!0)};if(v){this.switchToMode(Rt.HIGHLIGHT,S);return}S()}#q(){let t=document.getSelection();if(!t||t.isCollapsed)return;let s=this.#B(t).closest(".textLayer"),r=this.getSelectionBoxes(s);r&&(this.#k||=new qi(this),this.#k.show(s,r,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#r&&!this.#r.has(t.id)&&this.#r.setValue(t.id,t)}#tt(){let t=document.getSelection();if(!t||t.isCollapsed){this.#M&&(this.#k?.hide(),this.#M=null,this.#P({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#M)return;let r=this.#B(t).closest(".textLayer");if(!r){this.#M&&(this.#k?.hide(),this.#M=null,this.#P({hasSelectedText:!1}));return}if(this.#k?.hide(),this.#M=e,this.#P({hasSelectedText:!0}),!(this.#C!==Rt.HIGHLIGHT&&this.#C!==Rt.NONE)&&(this.#C===Rt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#E=this.isShiftKeyDown,!this.isShiftKeyDown)){let a=this.#C===Rt.HIGHLIGHT?this.#X(r):null;a?.toggleDrawing();let c=new AbortController,u=this.combinedSignal(c),f=g=>{g.type==="pointerup"&&g.button!==0||(c.abort(),a?.toggleDrawing(!0),g.type==="pointerup"&&this.#W("main_toolbar"))};window.addEventListener("pointerup",f,{signal:u}),window.addEventListener("blur",f,{signal:u})}}#W(t=""){this.#C===Rt.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#q()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#nt(){if(this.#S)return;this.#S=new AbortController;let t=this.combinedSignal(this.#S);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#st(){this.#S?.abort(),this.#S=null}blur(){if(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#W("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#v)if(e.div.contains(t)){this.#O=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#O)return;let[t,e]=this.#O;this.#O=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Y(){if(this.#w)return;this.#w=new AbortController;let t=this.combinedSignal(this.#w);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#rt(){this.#w?.abort(),this.#w=null}#K(){if(this.#u)return;this.#u=new AbortController;let t=this.combinedSignal(this.#u);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Z(){this.#u?.abort(),this.#u=null}#it(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Y(),this.#K()}removeEditListeners(){this.#rt(),this.#Z()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let s of this.#o)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let s of this.#o)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let s of this.#v){let r=s.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let a of e.items)for(let c of this.#o)if(c.isHandlingMimeForPasting(a.type)){c.paste(a,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(a){wt(`paste: "${a.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();let r=this.currentLayer;try{let a=[];for(let f of s){let g=await r.deserialize(f);if(!g)return;a.push(g)}let c=()=>{for(let f of a)this.#Q(f);this.#J(a)},u=()=>{for(let f of a)f.remove()};this.addCommands({cmd:c,undo:u,mustExec:!0})}catch(a){wt(`paste: "${a.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==Rt.NONE&&!this.isEditorHandlingKeyboard&&o._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#W("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#P(t){Object.entries(t).some(([s,r])=>this.#V[s]!==r)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#V,t)}),this.#C===Rt.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#G([[Lt.HIGHLIGHT_FREE,!0]]))}#G(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#nt(),this.#K(),this.#P({isEditing:this.#C!==Rt.NONE,isEmpty:this.#z(),hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:this.#a.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#st(),this.#Z(),this.#P({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#o){this.#o=t;for(let e of this.#o)this.#G(e.defaultPropertiesToUpdate)}}getId(){return this.#R.id}get currentLayer(){return this.#s.get(this.#d)}getLayer(t){return this.#s.get(t)}get currentPageIndex(){return this.#d}addLayer(t){this.#s.set(t.pageIndex,t),this.#A?t.enable():t.disable()}removeLayer(t){this.#s.delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(this.#C!==t&&!(this.#L&&(await this.#L.promise,!this.#L))){if(this.#L=Promise.withResolvers(),this.#C=t,t===Rt.NONE){this.setEditingState(!1),this.#at(),this._editorUndoBar?.hide(),this.#L.resolve();return}this.setEditingState(!0),await this.#ot(),this.unselectAll();for(let r of this.#s.values())r.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),this.#L.resolve();return}for(let r of this.#n.values())r.annotationElementId===e?(this.setSelected(r),r.enterInEditMode()):r.unselect();this.#L.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#o){switch(t){case Lt.CREATE:this.currentLayer.addNewEditor();return;case Lt.HIGHLIGHT_DEFAULT_COLOR:this.#D?.updateColor(e);break;case Lt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#j||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(let s of this.#v)s.updateParams(t,e);for(let s of this.#o)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(let a of this.#n.values())a.editorType===t&&a.show(e);(this.#j?.get(Lt.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#G([[Lt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#I!==t){this.#I=t;for(let e of this.#s.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#ot(){if(!this.#A){this.#A=!0;let t=[];for(let e of this.#s.values())t.push(e.enable());await Promise.all(t);for(let e of this.#n.values())e.enable()}}#at(){if(this.unselectAll(),this.#A){this.#A=!1;for(let t of this.#s.values())t.disable();for(let t of this.#n.values())t.disable()}}getEditors(t){let e=[];for(let s of this.#n.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.focusMainContainer(),this.#b=null},0)),this.#n.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#h.has(t.annotationElementId))&&this.#r?.remove(t.id)}addDeletedAnnotationElement(t){this.#h.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#h.has(t)}removeDeletedAnnotationElement(t){this.#h.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){let e=this.#s.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#G(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#lt===t&&this.#G(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#G(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#v.has(t)){this.#v.delete(t),t.unselect(),this.#P({hasSelectedEditor:this.hasSelection});return}this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}setSelected(t){this.#c?.commitOrRemove();for(let e of this.#v)e!==t&&e.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#P({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#a.undo(),this.#P({hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#z()}),this._editorUndoBar?.hide()}redo(){this.#a.redo(),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:this.#a.hasSomethingToRedo(),isEmpty:this.#z()})}addCommands(t){this.#a.add(t),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#z()})}cleanUndoStack(t){this.#a.cleanType(t)}#z(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let t of this.#n.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#v],s=()=>{this._editorUndoBar?.show(r,e.length===1?e[0].editorType:e.length);for(let a of e)a.remove()},r=()=>{for(let a of e)this.#Q(a)};this.addCommands({cmd:s,undo:r,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#J(t){for(let e of this.#v)e.unselect();this.#v.clear();for(let e of t)e.isEmpty()||(this.#v.add(e),e.select());this.#P({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#v)t.commit();this.#J(this.#n.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==Rt.NONE))&&!this.#c?.commitOrRemove()&&this.hasSelection){for(let t of this.#v)t.unselect();this.#v.clear(),this.#P({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=e;let[r,a]=this.#N,c=[...this.#v],u=1e3;this.#F&&clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#F=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(let f of c)this.#n.has(f.id)&&f.translateInPage(r,a)},undo:()=>{for(let f of c)this.#n.has(f.id)&&f.translateInPage(-r,-a)},mustExec:!1})},u);for(let f of c)f.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let t of this.#v)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let t=this.#f;this.#f=null;let e=!1;for(let[{x:r,y:a,pageIndex:c},u]of t)u.newX=r,u.newY=a,u.newPageIndex=c,e||=r!==u.savedX||a!==u.savedY||c!==u.savedPageIndex;if(!e)return!1;let s=(r,a,c,u)=>{if(this.#n.has(r.id)){let f=this.#s.get(u);f?r._setParentAndPosition(f,a,c):(r.pageIndex=u,r.x=a,r.y=c)}};return this.addCommands({cmd:()=>{for(let[r,{newX:a,newY:c,newPageIndex:u}]of t)s(r,a,c,u)},undo:()=>{for(let[r,{savedX:a,savedY:c,savedPageIndex:u}]of t)s(r,a,c,u)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(let s of this.#f.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){let 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()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}get imageManager(){return Pt(this,"imageManager",new eo)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let g=0,m=e.rangeCount;g<m;g++)if(!t.contains(e.getRangeAt(g).commonAncestorContainer))return null;let{x:s,y:r,width:a,height:c}=t.getBoundingClientRect(),u;switch(t.getAttribute("data-main-rotation")){case"90":u=(g,m,y,v)=>({x:(m-r)/c,y:1-(g+y-s)/a,width:v/c,height:y/a});break;case"180":u=(g,m,y,v)=>({x:1-(g+y-s)/a,y:1-(m+v-r)/c,width:y/a,height:v/c});break;case"270":u=(g,m,y,v)=>({x:1-(m+v-r)/c,y:(g-s)/a,width:v/c,height:y/a});break;default:u=(g,m,y,v)=>({x:(g-s)/a,y:(m-r)/c,width:y/a,height:v/c});break}let f=[];for(let g=0,m=e.rangeCount;g<m;g++){let y=e.getRangeAt(g);if(!y.collapsed)for(let{x:v,y:S,width:T,height:w}of y.getClientRects())T===0||w===0||f.push(u(v,S,T,w))}return f.length===0?null:f}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#l||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#l?.delete(t)}renderAnnotationElement(t){let e=this.#l?.get(t.data.id);if(!e)return;let s=this.#r.getRawValue(e);s&&(this.#C===Rt.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}},yr=class o{#t=null;#e=!1;#n=null;#s=null;#i=null;#r=null;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=!1;static#f=null;static _l10n=null;constructor(t){this.#u=t,this.#h=t._uiManager.useNewAltTextFlow,o.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){o._l10n??=t}async render(){let t=this.#n=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#s=document.createElement("span");t.append(e),this.#h?(t.classList.add("new"),t.setAttribute("data-l10n-id",o.#f.missing),e.setAttribute("data-l10n-id",o.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let s=this.#u._uiManager._signal;t.addEventListener("contextmenu",He,{signal:s}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});let r=a=>{a.preventDefault(),this.#u._uiManager.editAltText(this.#u),this.#h&&this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#o}})};return t.addEventListener("click",r,{capture:!0,signal:s}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(this.#l=!0,r(a))},{signal:s}),await this.#p(),t}get#o(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#l}),this.#l=!1)}isEmpty(){return this.#h?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#h?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){this.#t===null&&(this.#c=t,this.#d=await o._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())}toggleAltTextBadge(t=!1){if(!this.#h||this.#t){this.#a?.remove(),this.#a=null;return}if(!this.#a){let e=this.#a=document.createElement("div");e.className="noAltTextBadge",this.#u.div.append(e)}this.#a.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#c===e&&(e=this.#d),{altText:e,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#d}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:r,cancel:a=!1}){s&&(this.#c=s,this.#d=r),!(this.#t===t&&this.#e===e)&&(a||(this.#t=t,this.#e=e),this.#p())}toggle(t=!1){this.#n&&(!t&&this.#r&&(clearTimeout(this.#r),this.#r=null),this.#n.disabled=!t)}shown(){this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#n?.remove(),this.#n=null,this.#s=null,this.#i=null,this.#a?.remove(),this.#a=null}async#p(){let t=this.#n;if(!t)return;if(this.#h){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",o.#f[this.#o]),this.#s?.setAttribute("data-l10n-id",o.#f[`${this.#o}-label`]),!this.#t){this.#i?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#i?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#i;if(!e){this.#i=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#u.id}`;let r=100,a=this.#u._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(this.#r),this.#r=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#r=setTimeout(()=>{this.#r=null,this.#i.classList.add("show"),this.#u._reportTelemetry({action:"alt_text_tooltip"})},r)},{signal:a}),t.addEventListener("mouseleave",()=>{this.#r&&(clearTimeout(this.#r),this.#r=null),this.#i?.classList.remove("show")},{signal:a})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#u.getImageForAltText()?.setAttribute("aria-describedby",e.id)}},br=class o{#t;#e=!1;#n=null;#s;#i;#r;#l;#a;#u=null;#c;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:r=null,onPinching:a=null,onPinchEnd:c=null,signal:u}){this.#t=t,this.#n=s,this.#s=e,this.#i=r,this.#r=a,this.#l=c,this.#c=new AbortController,this.#a=AbortSignal.any([u,this.#c.signal]),t.addEventListener("touchstart",this.#h.bind(this),{passive:!1,signal:this.#a})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Pt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#h(t){if(this.#s?.()||t.touches.length<2)return;if(!this.#d){this.#d=new AbortController;let r=AbortSignal.any([this.#a,this.#d.signal]),a=this.#t,c={signal:r,passive:!1};a.addEventListener("touchmove",this.#f.bind(this),c),a.addEventListener("touchend",this.#o.bind(this),c),a.addEventListener("touchcancel",this.#o.bind(this),c),this.#i?.()}if(Ee(t),t.touches.length!==2||this.#n?.()){this.#u=null;return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),this.#u={touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#f(t){if(!this.#u||t.touches.length!==2)return;let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);let{screenX:r,screenY:a}=e,{screenX:c,screenY:u}=s,f=this.#u,{touch0X:g,touch0Y:m,touch1X:y,touch1Y:v}=f,S=y-g,T=v-m,w=c-r,I=u-a,k=Math.hypot(w,I)||1,L=Math.hypot(S,T)||1;if(!this.#e&&Math.abs(L-k)<=o.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(f.touch0X=r,f.touch0Y=a,f.touch1X=c,f.touch1Y=u,t.preventDefault(),!this.#e){this.#e=!0;return}let M=[(r+c)/2,(a+u)/2];this.#r?.(M,L,k)}#o(t){this.#d.abort(),this.#d=null,this.#l?.(),this.#u&&(t.preventDefault(),this.#u=null,this.#e=!1)}destroy(){this.#c?.abort(),this.#c=null}},Xt=class o{#t=null;#e=null;#n=null;#s=!1;#i=null;#r="";#l=!1;#a=null;#u=null;#c=null;#d=null;#h="";#f=!1;#o=null;#p=!1;#m=!1;#g=!1;#y=null;#x=0;#b=0;#S=null;#T=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#E=!1;#k=o._zIndex++;static _borderLineWidth=-1;static _colorManager=new so;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=o.prototype._resizeWithKeyboard,e=Rn.TRANSLATE_SMALL,s=Rn.TRANSLATE_BIG;return Pt(this,"_resizerKeyboardManager",new In([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],o.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;let{rotation:e,rawDims:{pageWidth:s,pageHeight:r,pageX:a,pageY:c}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,r],this.pageTranslation=[a,c];let[u,f]=this.parentDimensions;this.x=t.x/u,this.y=t.y/f,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Pt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new ro({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(o._l10n??=t,o._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),o._borderLineWidth!==-1)return;let s=getComputedStyle(document.documentElement);o._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Vt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#k}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#B(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,r){let[a,c]=this.parentDimensions;[s,r]=this.screenToPageTranslation(s,r),this.x=(t+s)/a,this.y=(e+r)/c,this.fixAndSetPosition()}#R([t,e],s,r){[s,r]=this.screenToPageTranslation(s,r),this.x+=s/t,this.y+=r/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#R(this.parentDimensions,t,e)}translateInPage(t,e){this.#o||=[this.x,this.y,this.width,this.height],this.#R(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#o||=[this.x,this.y,this.width,this.height];let{div:s,parentDimensions:[r,a]}=this;if(this.x+=t/r,this.y+=e/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:y,y:v}=this.div.getBoundingClientRect();this.parent.findNewParent(this,y,v)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:c,y:u}=this,[f,g]=this.getBaseTranslation();c+=f,u+=g;let{style:m}=s;m.left=`${(100*c).toFixed(2)}%`,m.top=`${(100*u).toFixed(2)}%`,this._onTranslating(c,u),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:s}=o,r=s/t,a=s/e;switch(this.rotation){case 90:return[-r,a];case 180:return[r,a];case 270:return[r,-a];default:return[-r,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[s,r]}=this,{x:a,y:c,width:u,height:f}=this;if(u*=s,f*=r,a*=s,c*=r,this._mustFixPosition)switch(t){case 0:a=Math.max(0,Math.min(s-u,a)),c=Math.max(0,Math.min(r-f,c));break;case 90:a=Math.max(0,Math.min(s-f,a)),c=Math.min(r,Math.max(u,c));break;case 180:a=Math.min(s,Math.max(u,a)),c=Math.min(r,Math.max(f,c));break;case 270:a=Math.min(s,Math.max(f,a)),c=Math.max(0,Math.min(r-u,c));break}this.x=a/=s,this.y=c/=r;let[g,m]=this.getBaseTranslation();a+=g,c+=m,e.left=`${(100*a).toFixed(2)}%`,e.top=`${(100*c).toFixed(2)}%`,this.moveInDOM()}static#A(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return o.#A(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return o.#A(t,e,360-this.parentRotation)}#I(t){switch(t){case 90:{let[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){let[s,r]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*t/s).toFixed(2)}%`,this.#l||(a.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:s}=t,r=s.endsWith("%"),a=!this.#l&&e.endsWith("%");if(r&&a)return;let[c,u]=this.parentDimensions;r||(t.width=`${(100*parseFloat(s)/c).toFixed(2)}%`),!this.#l&&!a&&(t.height=`${(100*parseFloat(e)/u).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#w(){if(this.#a)return;this.#a=document.createElement("div"),this.#a.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let s of t){let r=document.createElement("div");this.#a.append(r),r.classList.add("resizer",s),r.setAttribute("data-resizer-name",s),r.addEventListener("pointerdown",this.#O.bind(this,s),{signal:e}),r.addEventListener("contextmenu",He,{signal:e}),r.tabIndex=-1}this.div.prepend(this.#a)}#O(t,e){e.preventDefault();let{isMac:s}=ne.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#u=[e.screenX,e.screenY];let a=new AbortController,c=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#C.bind(this,t),{passive:!0,capture:!0,signal:c}),window.addEventListener("touchmove",Ee,{passive:!1,signal:c}),window.addEventListener("contextmenu",He,{signal:c}),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let u=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let g=()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=u,this.div.style.cursor=f,this.#_()};window.addEventListener("pointerup",g,{signal:c}),window.addEventListener("blur",g,{signal:c})}#D(t,e,s,r){this.width=s,this.height=r,this.x=t,this.y=e;let[a,c]=this.parentDimensions;this.setDims(a*s,c*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#_(){if(!this.#c)return;let{savedX:t,savedY:e,savedWidth:s,savedHeight:r}=this.#c;this.#c=null;let a=this.x,c=this.y,u=this.width,f=this.height;a===t&&c===e&&u===s&&f===r||this.addCommands({cmd:this.#D.bind(this,a,c,u,f),undo:this.#D.bind(this,t,e,s,r),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#C(t,e){let[s,r]=this.parentDimensions,a=this.x,c=this.y,u=this.width,f=this.height,g=o.MIN_SIZE/s,m=o.MIN_SIZE/r,y=this.#I(this.rotation),v=(W,K)=>[y[0]*W+y[2]*K,y[1]*W+y[3]*K],S=this.#I(360-this.rotation),T=(W,K)=>[S[0]*W+S[2]*K,S[1]*W+S[3]*K],w,I,k=!1,L=!1;switch(t){case"topLeft":k=!0,w=(W,K)=>[0,0],I=(W,K)=>[W,K];break;case"topMiddle":w=(W,K)=>[W/2,0],I=(W,K)=>[W/2,K];break;case"topRight":k=!0,w=(W,K)=>[W,0],I=(W,K)=>[0,K];break;case"middleRight":L=!0,w=(W,K)=>[W,K/2],I=(W,K)=>[0,K/2];break;case"bottomRight":k=!0,w=(W,K)=>[W,K],I=(W,K)=>[0,0];break;case"bottomMiddle":w=(W,K)=>[W/2,K],I=(W,K)=>[W/2,0];break;case"bottomLeft":k=!0,w=(W,K)=>[0,K],I=(W,K)=>[W,0];break;case"middleLeft":L=!0,w=(W,K)=>[0,K/2],I=(W,K)=>[W,K/2];break}let M=w(u,f),N=I(u,f),F=v(...N),B=o._round(a+F[0]),G=o._round(c+F[1]),$=1,z=1,J,et;if(e.fromKeyboard)({deltaX:J,deltaY:et}=e);else{let{screenX:W,screenY:K}=e,[pt,ft]=this.#u;[J,et]=this.screenToPageTranslation(W-pt,K-ft),this.#u[0]=W,this.#u[1]=K}if([J,et]=T(J/s,et/r),k){let W=Math.hypot(u,f);$=z=Math.max(Math.min(Math.hypot(N[0]-M[0]-J,N[1]-M[1]-et)/W,1/u,1/f),g/u,m/f)}else L?$=Math.max(g,Math.min(1,Math.abs(N[0]-M[0]-J)))/u:z=Math.max(m,Math.min(1,Math.abs(N[1]-M[1]-et)))/f;let nt=o._round(u*$),xt=o._round(f*z);F=v(...I(nt,xt));let vt=B-F[0],St=G-F[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=nt,this.height=xt,this.x=vt,this.y=St,this.setDims(s*nt,r*xt),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new Ji(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(yr.initialize(o._l10n),this.#n=new yr(this),this.#t&&(this.#n.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(t){this.#n&&(this.#n.data=t)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(t){await this.#n?.setGuessedText(t)}serializeAltText(t){return this.#n?.serialize(t)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}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.#s?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#N();let[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);let[s,r]=this.getInitialTranslation();return this.translate(s,r),mr(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#T||=new br({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#v.bind(this),onPinching:this.#M.bind(this),onPinchEnd:this.#H.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#v(){this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#M(t,e,s){let a=.7*(s/e)+1-.7;if(a===1)return;let c=this.#I(this.rotation),u=(B,G)=>[c[0]*B+c[2]*G,c[1]*B+c[3]*G],[f,g]=this.parentDimensions,m=this.x,y=this.y,v=this.width,S=this.height,T=o.MIN_SIZE/f,w=o.MIN_SIZE/g;a=Math.max(Math.min(a,1/v,1/S),T/v,w/S);let I=o._round(v*a),k=o._round(S*a);if(I===v&&k===S)return;this.#o||=[m,y,v,S];let L=u(v/2,S/2),M=o._round(m+L[0]),N=o._round(y+L[1]),F=u(I/2,k/2);this.x=M-F[0],this.y=N-F[1],this.width=I,this.height=k,this.setDims(f*I,g*k),this.fixAndSetPosition(),this._onResizing()}#H(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#_()}pointerdown(t){let{isMac:e}=ne.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#V(t);return}this.#j(t)}get isSelected(){return this._uiManager.isSelected(this)}#j(t){let{isMac:e}=ne.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#V(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1,r=new AbortController,a=this._uiManager.combinedSignal(r),c={capture:!0,passive:!1,signal:a},u=g=>{r.abort(),this.#i=null,this.#f=!1,this._uiManager.endDragSession()||this.#j(g),s&&this._onStopDragging()};e&&(this.#x=t.clientX,this.#b=t.clientY,this.#i=t.pointerId,this.#r=t.pointerType,window.addEventListener("pointermove",g=>{s||(s=!0,this._onStartDragging());let{clientX:m,clientY:y,pointerId:v}=g;if(v!==this.#i){Ee(g);return}let[S,T]=this.screenToPageTranslation(m-this.#x,y-this.#b);this.#x=m,this.#b=y,this._uiManager.dragSelectedEditors(S,T)},c),window.addEventListener("touchmove",Ee,c),window.addEventListener("pointerdown",g=>{g.pointerType===this.#r&&(this.#T||g.isPrimary)&&u(g),Ee(g)},c));let f=g=>{if(!this.#i||this.#i===g.pointerId){u(g);return}Ee(g)};window.addEventListener("pointerup",f,{signal:a}),window.addEventListener("blur",f,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){let r=this.parentScale,[a,c]=this.pageDimensions,[u,f]=this.pageTranslation,g=t/r,m=e/r,y=this.x*a,v=this.y*c,S=this.width*a,T=this.height*c;switch(s){case 0:return[y+g+u,c-v-m-T+f,y+g+S+u,c-v-m+f];case 90:return[y+m+u,c-v+g+f,y+m+T+u,c-v+g+S+f];case 180:return[y-g-S+u,c-v+m+f,y-g+u,c-v+m+T+f];case 270:return[y-m-T+u,c-v-g-S+f,y-m+u,c-v-g+f];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[s,r,a,c]=t,u=a-s,f=c-r;switch(this.rotation){case 0:return[s,e-c,u,f];case 90:return[s,e-r,f,u];case 180:return[a,e-r,u,f];case 270:return[a,e-c,f,u];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:s,right:r}=this.getClientDimensions(),{innerHeight:a,innerWidth:c}=window;return e<c&&r>0&&t<a&&s>0}#N(){if(this.#d||!this.div)return;this.#d=new AbortController;let t=this._uiManager.combinedSignal(this.#d);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#N()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){Vt("An editor must be serializable")}static async deserialize(t,e,s){let r=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});r.rotation=t.rotation,r.#t=t.accessibilityData;let[a,c]=r.pageDimensions,[u,f,g,m]=r.getRectInCurrentCoords(t.rect,c);return r.x=u/a,r.y=f/c,r.width=g/a,r.height=m/c,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#d?.abort(),this.#d=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#y&&(clearTimeout(this.#y),this.#y=null),this.#B(),this.removeEditToolbar(),this.#S){for(let t of this.#S.values())clearTimeout(t);this.#S=null}this.parent=null,this.#T?.destroy(),this.#T=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#w(),this.#a.classList.remove("hidden"),mr(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#a.children;if(!this.#e){this.#e=Array.from(e);let c=this.#F.bind(this),u=this.#U.bind(this),f=this._uiManager._signal;for(let g of this.#e){let m=g.getAttribute("data-resizer-name");g.setAttribute("role","spinbutton"),g.addEventListener("keydown",c,{signal:f}),g.addEventListener("blur",u,{signal:f}),g.addEventListener("focus",this.#$.bind(this,m),{signal:f}),g.setAttribute("data-l10n-id",o._l10nResizer[m])}}let s=this.#e[0],r=0;for(let c of e){if(c===s)break;r++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(a!==r){if(a<r)for(let u=0;u<r-a;u++)this.#a.append(this.#a.firstChild);else if(a>r)for(let u=0;u<a-r;u++)this.#a.firstChild.before(this.#a.lastChild);let c=0;for(let u of e){let g=this.#e[c++].getAttribute("data-resizer-name");u.setAttribute("data-l10n-id",o._l10nResizer[g])}}this.#L(0),this.#g=!0,this.#a.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#F(t){o._resizerKeyboardManager.exec(this,t)}#U(t){this.#g&&t.relatedTarget?.parentNode!==this.#a&&this.#B()}#$(t){this.#h=this.#g?t:""}#L(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#C(this.#h,{deltaX:t,deltaY:e,fromKeyboard:!0})}#B(){this.#g=!1,this.#L(-1),this.#_()}_stopResizingWithKeyboard(){this.#B(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#a?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#l=!0;let s=t/e,{style:r}=this.div;r.aspectRatio=s,r.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.#S||=new Map;let{action:s}=t,r=this.#S.get(s);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(s),this.#S.size===0&&(this.#S=null)},o._telemetryTimeout),this.#S.set(s,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#s=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#s=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}},ro=class extends Xt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},_c=3285377520,Pe=4294901760,Ye=65535,vr=class{constructor(t){this.h1=t?t&4294967295:_c,this.h2=t?t&4294967295:_c}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let w=0,I=t.length;w<I;w++){let k=t.charCodeAt(w);k<=255?e[s++]=k:(e[s++]=k>>>8,e[s++]=k&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let r=s>>2,a=s-r*4,c=new Uint32Array(e.buffer,0,r),u=0,f=0,g=this.h1,m=this.h2,y=3432918353,v=461845907,S=y&Ye,T=v&Ye;for(let w=0;w<r;w++)w&1?(u=c[w],u=u*y&Pe|u*S&Ye,u=u<<15|u>>>17,u=u*v&Pe|u*T&Ye,g^=u,g=g<<13|g>>>19,g=g*5+3864292196):(f=c[w],f=f*y&Pe|f*S&Ye,f=f<<15|f>>>17,f=f*v&Pe|f*T&Ye,m^=f,m=m<<13|m>>>19,m=m*5+3864292196);switch(u=0,a){case 3:u^=e[r*4+2]<<16;case 2:u^=e[r*4+1]<<8;case 1:u^=e[r*4],u=u*y&Pe|u*S&Ye,u=u<<15|u>>>17,u=u*v&Pe|u*T&Ye,r&1?g^=u:m^=u}this.h1=g,this.h2=m}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Pe|t*36045&Ye,e=e*4283543511&Pe|((e<<16|t>>>16)*2950163797&Pe)>>>16,t^=e>>>1,t=t*444984403&Pe|t*60499&Ye,e=e*3301882366&Pe|((e<<16|t>>>16)*3120437893&Pe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}},io=Object.freeze({map:null,hash:"",transfer:void 0}),vs=class{#t=!1;#e=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let s=this.#n.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#n.get(t)}remove(t){if(this.#n.delete(t),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let e of this.#n.values())if(e instanceof Xt)return;this.onAnnotationEditor(null)}}setValue(t,e){let s=this.#n.get(t),r=!1;if(s!==void 0)for(let[a,c]of Object.entries(e))s[a]!==c&&(r=!0,s[a]=c);else r=!0,this.#n.set(t,e);r&&this.#s(),e instanceof Xt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#n.has(t)}getAll(){return this.#n.size>0?va(this.#n):null}setAll(t){for(let[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#n.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new xr(this)}get serializable(){if(this.#n.size===0)return io;let t=new Map,e=new vr,s=[],r=Object.create(null),a=!1;for(let[c,u]of this.#n){let f=u instanceof Xt?u.serialize(!1,r):u;f&&(t.set(c,f),e.update(`${c}:${JSON.stringify(f)}`),a||=!!f.bitmap)}if(a)for(let c of t.values())c.bitmap&&s.push(c.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:io}get editorStats(){let t=null,e=new Map;for(let s of this.#n.values()){if(!(s instanceof Xt))continue;let r=s.telemetryFinalData;if(!r)continue;let{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(s).constructor),t||=Object.create(null);let c=t[a]||=new Map;for(let[u,f]of Object.entries(r)){if(u==="type")continue;let g=c.get(u);g||(g=new Map,c.set(u,g));let m=g.get(f)??0;g.set(f,m+1)}}for(let[s,r]of e)t[s]=r.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;let t=[];for(let e of this.#n.values())!(e instanceof Xt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}},xr=class extends vs{#t;constructor(t){super();let{map:e,hash:s,transfer:r}=t.serializable,a=structuredClone(e,r?{transfer:r}:null);this.#t={map:a,hash:s,transfer:r}}get print(){Vt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return Pt(this,"modifiedIds",{ids:new Set,hash:""})}},oo=class{#t=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));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(te(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:s,src:r,style:a}=t,c=new FontFace(s,r,a);this.addNativeFontFace(c);try{await c.load(),this.#t.add(s),e?.(t)}catch{wt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(c)}return}Vt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(r){throw wt(`Failed to load font '${s.family}': '${r}'.`),t.disableFontFace=!0,r}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{let r=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,r)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return Pt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ce||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Pt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(te(!r.done,"completeRequest() cannot be called twice."),r.done=!0;s.length>0&&s[0].done;){let a=s.shift();setTimeout(a.callback,0)}}let{loadingRequests:s}=this,r={done:!1,complete:e,callback:t};return s.push(r),r}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Pt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(N,F){return N.charCodeAt(F)<<24|N.charCodeAt(F+1)<<16|N.charCodeAt(F+2)<<8|N.charCodeAt(F+3)&255}function r(N,F,B,G){let $=N.substring(0,F),z=N.substring(F+B);return $+G+z}let a,c,u=this._document.createElement("canvas");u.width=1,u.height=1;let f=u.getContext("2d"),g=0;function m(N,F){if(++g>30){wt("Load test font never loaded."),F();return}if(f.font="30px "+N,f.fillText(".",0,20),f.getImageData(0,0,1,1).data[3]>0){F();return}setTimeout(m.bind(null,N,F))}let y=`lt${Date.now()}${this.loadTestFontId++}`,v=this._loadTestFont;v=r(v,976,y.length,y);let T=16,w=1482184792,I=s(v,T);for(a=0,c=y.length-3;a<c;a+=4)I=I-w+s(y,a)|0;a<y.length&&(I=I-w+s(y+"XXX",a)|0),v=r(v,T,4,R0(I));let k=`url(data:font/opentype;base64,${btoa(v)});`,L=`@font-face {font-family:"${y}";src:${k}}`;this.insertRule(L);let M=this._document.createElement("div");M.style.visibility="hidden",M.style.width=M.style.height="10px",M.style.position="absolute",M.style.top=M.style.left="0px";for(let N of[t.loadedName,y]){let F=this._document.createElement("span");F.textContent="Hi",F.style.fontFamily=N,M.append(F)}this._document.body.append(M),m(y,()=>{M.remove(),e.complete()})}},ao=class{constructor(t,{disableFontFace:e=!1,fontExtraProperties:s=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let a in t)this[a]=t[a];this.disableFontFace=e===!0,this.fontExtraProperties=s===!0,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${F0(this.data)});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e,r;try{r=t.get(s)}catch(c){wt(`getPathGenerator - ignoring character: "${c}".`)}let a=new Path2D(r||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=a}},ar={DATA:1,ERROR:2},qt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};Cn=class{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#s(t);return}if(t.callback){let s=t.callbackId,r=this.callbackCapabilities[s];if(!r)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===ar.DATA)r.resolve(t.data);else if(t.callback===ar.ERROR)r.reject(be(t.reason));else throw new Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let s=this.sourceName,r=t.sourceName,a=this.comObj;Promise.try(e,t.data).then(function(c){a.postMessage({sourceName:s,targetName:r,callback:ar.DATA,callbackId:t.callbackId,data:c})},function(c){a.postMessage({sourceName:s,targetName:r,callback:ar.ERROR,callbackId:t.callbackId,reason:be(c)})});return}if(t.streamId){this.#n(t);return}e(t.data)}on(t,e){let s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){let r=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[r]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},s)}catch(c){a.reject(c)}return a.promise}sendWithStream(t,e,s,r){let a=this.streamId++,c=this.sourceName,u=this.targetName,f=this.comObj;return new ReadableStream({start:g=>{let m=Promise.withResolvers();return this.streamControllers[a]={controller:g,startCall:m,pullCall:null,cancelCall:null,isClosed:!1},f.postMessage({sourceName:c,targetName:u,action:t,streamId:a,data:e,desiredSize:g.desiredSize},r),m.promise},pull:g=>{let m=Promise.withResolvers();return this.streamControllers[a].pullCall=m,f.postMessage({sourceName:c,targetName:u,stream:qt.PULL,streamId:a,desiredSize:g.desiredSize}),m.promise},cancel:g=>{te(g instanceof Error,"cancel must have a valid reason");let m=Promise.withResolvers();return this.streamControllers[a].cancelCall=m,this.streamControllers[a].isClosed=!0,f.postMessage({sourceName:c,targetName:u,stream:qt.CANCEL,streamId:a,reason:be(g)}),m.promise}},s)}#n(t){let e=t.streamId,s=this.sourceName,r=t.sourceName,a=this.comObj,c=this,u=this.actionHandler[t.action],f={enqueue(g,m=1,y){if(this.isCancelled)return;let v=this.desiredSize;this.desiredSize-=m,v>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:s,targetName:r,stream:qt.ENQUEUE,streamId:e,chunk:g},y)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:r,stream:qt.CLOSE,streamId:e}),delete c.streamSinks[e])},error(g){te(g instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:r,stream:qt.ERROR,streamId:e,reason:be(g)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};f.sinkCapability.resolve(),f.ready=f.sinkCapability.promise,this.streamSinks[e]=f,Promise.try(u,t.data,f).then(function(){a.postMessage({sourceName:s,targetName:r,stream:qt.START_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:s,targetName:r,stream:qt.START_COMPLETE,streamId:e,reason:be(g)})})}#s(t){let e=t.streamId,s=this.sourceName,r=t.sourceName,a=this.comObj,c=this.streamControllers[e],u=this.streamSinks[e];switch(t.stream){case qt.START_COMPLETE:t.success?c.startCall.resolve():c.startCall.reject(be(t.reason));break;case qt.PULL_COMPLETE:t.success?c.pullCall.resolve():c.pullCall.reject(be(t.reason));break;case qt.PULL:if(!u){a.postMessage({sourceName:s,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,success:!0});break}u.desiredSize<=0&&t.desiredSize>0&&u.sinkCapability.resolve(),u.desiredSize=t.desiredSize,Promise.try(u.onPull||Nc).then(function(){a.postMessage({sourceName:s,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:s,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,reason:be(g)})});break;case qt.ENQUEUE:if(te(c,"enqueue should have stream controller"),c.isClosed)break;c.controller.enqueue(t.chunk);break;case qt.CLOSE:if(te(c,"close should have stream controller"),c.isClosed)break;c.isClosed=!0,c.controller.close(),this.#i(c,e);break;case qt.ERROR:te(c,"error should have stream controller"),c.controller.error(be(t.reason)),this.#i(c,e);break;case qt.CANCEL_COMPLETE:t.success?c.cancelCall.resolve():c.cancelCall.reject(be(t.reason)),this.#i(c,e);break;case qt.CANCEL:if(!u)break;let f=be(t.reason);Promise.try(u.onCancel||Nc,f).then(function(){a.postMessage({sourceName:s,targetName:r,stream:qt.CANCEL_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:s,targetName:r,stream:qt.CANCEL_COMPLETE,streamId:e,reason:be(g)})}),u.sinkCapability.reject(f),u.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#i(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}},Sr=class{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");let s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}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){Vt("Abstract method `_createCanvas` called.")}},lo=class extends Sr{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},Ar=class{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){Vt("Abstract method `_fetch` called.")}},Tr=class extends Ar{async _fetch(t){let e=await Yr(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Xr(e)}},Xx=Mt(4520),Cr=class{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,r,a){return"none"}destroy(t=!1){}},co=class extends Cr{#t;#e;#n;#s;#i;#r;#l=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#i=e}get#a(){return this.#e||=new Map}get#u(){return this.#r||=new Map}get#c(){if(!this.#n){let t=this.#i.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;let s=this.#i.createElementNS(tn,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#n=this.#i.createElementNS(tn,"defs"),t.append(s),s.append(this.#n),this.#i.body.append(t)}return this.#n}#d(t){if(t.length===1){let f=t[0],g=new Array(256);for(let y=0;y<256;y++)g[y]=f[y]/255;let m=g.join(",");return[m,m,m]}let[e,s,r]=t,a=new Array(256),c=new Array(256),u=new Array(256);for(let f=0;f<256;f++)a[f]=e[f]/255,c[f]=s[f]/255,u[f]=r[f]/255;return[a.join(","),c.join(","),u.join(",")]}#h(t){if(this.#t===void 0){this.#t="";let e=this.#i.URL;e!==this.#i.baseURI&&(Kr(e)?wt('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#a.get(t);if(e)return e;let[s,r,a]=this.#d(t),c=t.length===1?s:`${s}${r}${a}`;if(e=this.#a.get(c),e)return this.#a.set(t,e),e;let u=`g_${this.#s}_transfer_map_${this.#l++}`,f=this.#h(u);this.#a.set(t,f),this.#a.set(c,f);let g=this.#p(u);return this.#g(s,r,a,g),f}addHCMFilter(t,e){let s=`${t}-${e}`,r="base",a=this.#u.get(r);if(a?.key===s||(a?(a.filter?.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},this.#u.set(r,a)),!t||!e))return a.url;let c=this.#x(t);t=bt.makeHexColor(...c);let u=this.#x(e);if(e=bt.makeHexColor(...u),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return a.url;let f=new Array(256);for(let S=0;S<=255;S++){let T=S/255;f[S]=T<=.03928?T/12.92:((T+.055)/1.055)**2.4}let g=f.join(","),m=`g_${this.#s}_hcm_filter`,y=a.filter=this.#p(m);this.#g(g,g,g,y),this.#o(y);let v=(S,T)=>{let w=c[S]/255,I=u[S]/255,k=new Array(T+1);for(let L=0;L<=T;L++)k[L]=w+L/T*(I-w);return k.join(",")};return this.#g(v(0,5),v(1,5),v(2,5),y),a.url=this.#h(m),a.url}addAlphaFilter(t){let e=this.#a.get(t);if(e)return e;let[s]=this.#d([t]),r=`alpha_${s}`;if(e=this.#a.get(r),e)return this.#a.set(t,e),e;let a=`g_${this.#s}_alpha_map_${this.#l++}`,c=this.#h(a);this.#a.set(t,c),this.#a.set(r,c);let u=this.#p(a);return this.#y(s,u),c}addLuminosityFilter(t){let e=this.#a.get(t||"luminosity");if(e)return e;let s,r;if(t?([s]=this.#d([t]),r=`luminosity_${s}`):r="luminosity",e=this.#a.get(r),e)return this.#a.set(t,e),e;let a=`g_${this.#s}_luminosity_map_${this.#l++}`,c=this.#h(a);this.#a.set(t,c),this.#a.set(r,c);let u=this.#p(a);return this.#f(u),t&&this.#y(s,u),c}addHighlightHCMFilter(t,e,s,r,a){let c=`${e}-${s}-${r}-${a}`,u=this.#u.get(t);if(u?.key===c||(u?(u.filter?.remove(),u.key=c,u.url="none",u.filter=null):(u={key:c,url:"none",filter:null},this.#u.set(t,u)),!e||!s))return u.url;let[f,g]=[e,s].map(this.#x.bind(this)),m=Math.round(.2126*f[0]+.7152*f[1]+.0722*f[2]),y=Math.round(.2126*g[0]+.7152*g[1]+.0722*g[2]),[v,S]=[r,a].map(this.#x.bind(this));y<m&&([m,y,v,S]=[y,m,S,v]),this.#c.style.color="";let T=(k,L,M)=>{let N=new Array(256),F=(y-m)/M,B=k/255,G=(L-k)/(255*M),$=0;for(let z=0;z<=M;z++){let J=Math.round(m+z*F),et=B+z*G;for(let nt=$;nt<=J;nt++)N[nt]=et;$=J+1}for(let z=$;z<256;z++)N[z]=N[$-1];return N.join(",")},w=`g_${this.#s}_hcm_${t}_filter`,I=u.filter=this.#p(w);return this.#o(I),this.#g(T(v[0],S[0],5),T(v[1],S[1],5),T(v[2],S[2],5),I),u.url=this.#h(w),u.url}destroy(t=!1){t&&this.#r?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#e?.clear(),this.#e=null,this.#r?.clear(),this.#r=null,this.#l=0)}#f(t){let e=this.#i.createElementNS(tn,"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)}#o(t){let e=this.#i.createElementNS(tn,"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)}#p(t){let e=this.#i.createElementNS(tn,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#m(t,e,s){let r=this.#i.createElementNS(tn,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",s),t.append(r)}#g(t,e,s,r){let a=this.#i.createElementNS(tn,"feComponentTransfer");r.append(a),this.#m(a,"feFuncR",t),this.#m(a,"feFuncG",e),this.#m(a,"feFuncB",s)}#y(t,e){let s=this.#i.createElementNS(tn,"feComponentTransfer");e.append(s),this.#m(s,"feFuncA",t)}#x(t){return this.#c.style.color=t,Aa(getComputedStyle(this.#c).getPropertyValue("color"))}},Er=class{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){Vt("Abstract method `_fetch` called.")}},wr=class extends Er{async _fetch(t){let e=await Yr(t,"arraybuffer");return new Uint8Array(e)}};if(ce){let o;try{let t=process.getBuiltinModule("module").createRequire(import.meta.url);try{o=t("@napi-rs/canvas")}catch(e){wt(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){wt(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(o?.DOMMatrix?globalThis.DOMMatrix=o.DOMMatrix:wt("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(o?.ImageData?globalThis.ImageData=o.ImageData:wt("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(o?.Path2D?globalThis.Path2D=o.Path2D:wt("Cannot polyfill `Path2D`, rendering may be broken."))}uo=class extends Cr{},ho=class extends Sr{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}},fo=class extends Ar{async _fetch(t){return Qc(t)}},po=class extends Er{async _fetch(t){return Qc(t)}},le={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};xs=class{getPattern(){Vt("Abstract method `getPattern` called.")}},mo=class extends xs{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,r){let a;if(r===le.STROKE||r===le.FILL){let c=e.current.getClippedPathBoundingBox(r,Wt(t))||[0,0,0,0],u=Math.ceil(c[2]-c[0])||1,f=Math.ceil(c[3]-c[1])||1,g=e.cachedCanvases.getCanvas("pattern",u,f),m=g.context;m.clearRect(0,0,m.canvas.width,m.canvas.height),m.beginPath(),m.rect(0,0,m.canvas.width,m.canvas.height),m.translate(-c[0],-c[1]),s=bt.transform(s,[1,0,0,1,c[0],c[1]]),m.transform(...e.baseTransform),this.matrix&&m.transform(...this.matrix),go(m,this._bbox),m.fillStyle=this._createGradient(m),m.fill(),a=t.createPattern(g.canvas,"no-repeat");let y=new DOMMatrix(s);a.setTransform(y)}else go(t,this._bbox),a=this._createGradient(t);return a}};yo=class extends xs{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){let u=Math.floor(this._bounds[0]),f=Math.floor(this._bounds[1]),g=Math.ceil(this._bounds[2])-u,m=Math.ceil(this._bounds[3])-f,y=Math.min(Math.ceil(Math.abs(g*t[0]*1.1)),3e3),v=Math.min(Math.ceil(Math.abs(m*t[1]*1.1)),3e3),S=g/y,T=m/v,w={coords:this._coords,colors:this._colors,offsetX:-u,offsetY:-f,scaleX:1/S,scaleY:1/T},I=y+4,k=v+4,L=s.getCanvas("mesh",I,k),M=L.context,N=M.createImageData(y,v);if(e){let B=N.data;for(let G=0,$=B.length;G<$;G+=4)B[G]=e[0],B[G+1]=e[1],B[G+2]=e[2],B[G+3]=255}for(let B of this._figures)G0(N,B,w);return M.putImageData(N,2,2),{canvas:L.canvas,offsetX:u-2*S,offsetY:f-2*T,scaleX:S,scaleY:T}}getPattern(t,e,s,r){go(t,this._bbox);let a;if(r===le.SHADING)a=bt.singularValueDecompose2dScale(Wt(t));else if(a=bt.singularValueDecompose2dScale(e.baseTransform),this.matrix){let u=bt.singularValueDecompose2dScale(this.matrix);a=[a[0]*u[0],a[1]*u[1]]}let c=this._createMeshCanvas(a,r===le.SHADING?null:this._background,e.cachedCanvases);return r!==le.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(c.offsetX,c.offsetY),t.scale(c.scaleX,c.scaleY),t.createPattern(c.canvas,"no-repeat")}},bo=class extends xs{getPattern(){return"hotpink"}};Uc={COLORED:1,UNCOLORED:2},vo=class o{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,r,a){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(t){let{bbox:e,operatorList:s,paintType:r,tilingType:a,color:c,canvasGraphicsFactory:u}=this,{xstep:f,ystep:g}=this;f=Math.abs(f),g=Math.abs(g),Wr("TilingType: "+a);let m=e[0],y=e[1],v=e[2],S=e[3],T=v-m,w=S-y,I=bt.singularValueDecompose2dScale(this.matrix),k=bt.singularValueDecompose2dScale(this.baseTransform),L=I[0]*k[0],M=I[1]*k[1],N=T,F=w,B=!1,G=!1,$=Math.ceil(f*L),z=Math.ceil(g*M),J=Math.ceil(T*L),et=Math.ceil(w*M);$>=J?N=f:B=!0,z>=et?F=g:G=!0;let nt=this.getSizeAndScale(N,this.ctx.canvas.width,L),xt=this.getSizeAndScale(F,this.ctx.canvas.height,M),vt=t.cachedCanvases.getCanvas("pattern",nt.size,xt.size),St=vt.context,W=u.createCanvasGraphics(St);if(W.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(W,r,c),St.translate(-nt.scale*m,-xt.scale*y),W.transform(nt.scale,0,0,xt.scale,0,0),St.save(),this.clipBbox(W,m,y,v,S),W.baseTransform=Wt(W.ctx),W.executeOperatorList(s),W.endDrawing(),St.restore(),B||G){let K=vt.canvas;B&&(N=f),G&&(F=g);let pt=this.getSizeAndScale(N,this.ctx.canvas.width,L),ft=this.getSizeAndScale(F,this.ctx.canvas.height,M),X=pt.size,gt=ft.size,Z=t.cachedCanvases.getCanvas("pattern-workaround",X,gt),tt=Z.context,ct=B?Math.floor(T/f):0,st=G?Math.floor(w/g):0;for(let Y=0;Y<=ct;Y++)for(let j=0;j<=st;j++)tt.drawImage(K,X*Y,gt*j,X,gt,0,0,X,gt);return{canvas:Z.canvas,scaleX:pt.scale,scaleY:ft.scale,offsetX:m,offsetY:y}}return{canvas:vt.canvas,scaleX:nt.scale,scaleY:xt.scale,offsetX:m,offsetY:y}}getSizeAndScale(t,e,s){let r=Math.max(o.MAX_PATTERN_SIZE,e),a=Math.ceil(t*s);return a>=r?a=r:s=a/t,{scale:s,size:a}}clipBbox(t,e,s,r,a){let c=r-e,u=a-s;t.ctx.rect(e,s,c,u),t.current.updateRectMinMax(Wt(t.ctx),[e,s,r,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){let r=t.ctx,a=t.current;switch(e){case Uc.COLORED:let c=this.ctx;r.fillStyle=c.fillStyle,r.strokeStyle=c.strokeStyle,a.fillColor=c.fillStyle,a.strokeColor=c.strokeStyle;break;case Uc.UNCOLORED:let u=bt.makeHexColor(s[0],s[1],s[2]);r.fillStyle=u,r.strokeStyle=u,a.fillColor=u,a.strokeColor=u;break;default:throw new Qi(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,r){let a=s;r!==le.SHADING&&(a=bt.transform(a,e.baseTransform),this.matrix&&(a=bt.transform(a,this.matrix)));let c=this.createPatternCanvas(e),u=new DOMMatrix(a);u=u.translate(c.offsetX,c.offsetY),u=u.scale(1/c.scaleX,1/c.scaleY);let f=t.createPattern(c.canvas,"repeat");return f.setTransform(u),f}};Bc=16,Gc=100,V0=15,Hc=10,jc=1e3,ve=16;xo=class{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let r;return this.cache[t]!==void 0?(r=this.cache[t],this.canvasFactory.reset(r,e,s)):(r=this.canvasFactory.create(e,s),this.cache[t]=r),r}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}};kr=class{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Kc,this.textMatrixScale=1,this.fontMatrix=Zi,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=ae.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=bt.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){let s=bt.applyTransform(e,t),r=bt.applyTransform(e.slice(2),t),a=bt.applyTransform([e[0],e[3]],t),c=bt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],r[0],a[0],c[0]),this.minY=Math.min(this.minY,s[1],r[1],a[1],c[1]),this.maxX=Math.max(this.maxX,s[0],r[0],a[0],c[0]),this.maxY=Math.max(this.maxY,s[1],r[1],a[1],c[1])}updateScalingPathMinMax(t,e){bt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,r,a,c,u,f,g,m){let y=bt.bezierBoundingBox(e,s,r,a,c,u,f,g,m);m||this.updateRectMinMax(t,y)}getPathBoundingBox(t=le.FILL,e=null){let s=[this.minX,this.minY,this.maxX,this.maxY];if(t===le.STROKE){e||Vt("Stroke bounding box must include transform.");let r=bt.singularValueDecompose2dScale(e),a=r[0]*this.lineWidth/2,c=r[1]*this.lineWidth/2;s[0]-=a,s[1]-=c,s[2]+=a,s[3]+=c}return s}updateClipFromPath(){let t=bt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=le.FILL,e=null){return bt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}};W0=["butt","round","square"],X0=["miter","round","bevel"],Y0={},Wc={},Xn=class o{constructor(t,e,s,r,a,{optionalContentConfig:c,markedContentStack:u=null},f,g){this.ctx=t,this.current=new kr(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=r,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=u||[],this.optionalContentConfig=c,this.cachedCanvases=new xo(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=f,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=g,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:r=null}){let a=this.ctx.canvas.width,c=this.ctx.canvas.height,u=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,a,c),this.ctx.fillStyle=u,s){let f=this.cachedCanvases.getCanvas("transparent",a,c);this.compositeCtx=this.ctx,this.transparentCanvas=f.canvas,this.ctx=f.context,this.ctx.save(),this.ctx.transform(...Wt(this.compositeCtx))}this.ctx.save(),cr(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Wt(this.ctx)}executeOperatorList(t,e,s,r){let a=t.argsArray,c=t.fnArray,u=e||0,f=a.length;if(f===u)return u;let g=f-u>Hc&&typeof s=="function",m=g?Date.now()+V0:0,y=0,v=this.commonObjs,S=this.objs,T;for(;;){if(r!==void 0&&u===r.nextBreakPoint)return r.breakIt(u,s),u;if(T=c[u],T!==Ge.dependency)this[T].apply(this,a[u]);else for(let w of a[u]){let I=w.startsWith("g_")?v:S;if(!I.has(w))return I.get(w,s),u}if(u++,u===f)return u;if(g&&++y>Hc){if(Date.now()>m)return s(),u;y=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let s=t.width??t.displayWidth,r=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),c=Math.max(Math.hypot(e[2],e[3]),1),u=s,f=r,g="prescale1",m,y;for(;a>2&&u>1||c>2&&f>1;){let v=u,S=f;a>2&&u>1&&(v=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u/2),a/=u/v),c>2&&f>1&&(S=f>=16384?Math.floor(f/2)-1||1:Math.ceil(f)/2,c/=f/S),m=this.cachedCanvases.getCanvas(g,v,S),y=m.context,y.clearRect(0,0,v,S),y.drawImage(t,0,0,u,f,0,0,v,S),t=m.canvas,u=v,f=S,g=g==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:u,paintHeight:f}}_createMaskCanvas(t){let e=this.ctx,{width:s,height:r}=t,a=this.current.fillColor,c=this.current.patternFill,u=Wt(e),f,g,m,y;if((t.bitmap||t.data)&&t.count>1){let $=t.bitmap||t.data.buffer;g=JSON.stringify(c?u:[u.slice(0,4),a]),f=this._cachedBitmapsMap.get($),f||(f=new Map,this._cachedBitmapsMap.set($,f));let z=f.get(g);if(z&&!c){let J=Math.round(Math.min(u[0],u[2])+u[4]),et=Math.round(Math.min(u[1],u[3])+u[5]);return{canvas:z,offsetX:J,offsetY:et}}m=z}m||(y=this.cachedCanvases.getCanvas("maskCanvas",s,r),$c(y.context,t));let v=bt.transform(u,[1/s,0,0,-1/r,0,0]);v=bt.transform(v,[1,0,0,1,0,-r]);let[S,T,w,I]=bt.getAxialAlignedBoundingBox([0,0,s,r],v),k=Math.round(w-S)||1,L=Math.round(I-T)||1,M=this.cachedCanvases.getCanvas("fillCanvas",k,L),N=M.context,F=S,B=T;N.translate(-F,-B),N.transform(...v),m||(m=this._scaleImage(y.canvas,Xe(N)),m=m.img,f&&c&&f.set(g,m)),N.imageSmoothingEnabled=zc(Wt(N),t.interpolate),lr(N,m,0,0,m.width,m.height,0,0,s,r),N.globalCompositeOperation="source-in";let G=bt.transform(Xe(N),[1,0,0,1,-F,-B]);return N.fillStyle=c?a.getPattern(e,this,G,le.FILL):a,N.fillRect(0,0,s,r),f&&!c&&(this.cachedCanvases.delete("fillCanvas"),f.set(g,M.canvas)),{canvas:M.canvas,offsetX:Math.round(F),offsetY:Math.round(B)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=W0[t]}setLineJoin(t){this.ctx.lineJoin=X0[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let 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");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=r.context;let a=this.ctx;a.setTransform(...Wt(this.suspendedCtx)),us(this.suspendedCtx,a),$0(a,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(),us(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];let e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,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,s,r){let a=r[0],c=r[1],u=r[2]-a,f=r[3]-c;u===0||f===0||(this.genericComposeSMask(e.context,s,u,f,e.subtype,e.backdrop,e.transferMap,a,c,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,r,a,c,u,f,g,m,y){let v=t.canvas,S=f-m,T=g-y;if(c){let I=bt.makeHexColor(...c);if(S<0||T<0||S+s>v.width||T+r>v.height){let k=this.cachedCanvases.getCanvas("maskExtension",s,r),L=k.context;L.drawImage(v,-S,-T),L.globalCompositeOperation="destination-atop",L.fillStyle=I,L.fillRect(0,0,s,r),L.globalCompositeOperation="source-over",v=k.canvas,S=T=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let k=new Path2D;k.rect(S,T,s,r),t.clip(k),t.globalCompositeOperation="destination-atop",t.fillStyle=I,t.fillRect(S,T,s,r),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),a==="Alpha"&&u?e.filter=this.filterFactory.addAlphaFilter(u):a==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(u));let w=new Path2D;w.rect(f,g,s,r),e.clip(w),e.globalCompositeOperation="destination-in",e.drawImage(v,S,T,s,r,f,g,s,r),e.restore()}save(){this.inSMaskMode?(us(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),us(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,r,a,c){this.ctx.transform(t,e,s,r,a,c),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){let r=this.ctx,a=this.current,c=a.x,u=a.y,f,g,m=Wt(r),y=m[0]===0&&m[3]===0||m[1]===0&&m[2]===0,v=y?s.slice(0):null;for(let S=0,T=0,w=t.length;S<w;S++)switch(t[S]|0){case Ge.rectangle:c=e[T++],u=e[T++];let I=e[T++],k=e[T++],L=c+I,M=u+k;r.moveTo(c,u),I===0||k===0?r.lineTo(L,M):(r.lineTo(L,u),r.lineTo(L,M),r.lineTo(c,M)),y||a.updateRectMinMax(m,[c,u,L,M]),r.closePath();break;case Ge.moveTo:c=e[T++],u=e[T++],r.moveTo(c,u),y||a.updatePathMinMax(m,c,u);break;case Ge.lineTo:c=e[T++],u=e[T++],r.lineTo(c,u),y||a.updatePathMinMax(m,c,u);break;case Ge.curveTo:f=c,g=u,c=e[T+4],u=e[T+5],r.bezierCurveTo(e[T],e[T+1],e[T+2],e[T+3],c,u),a.updateCurvePathMinMax(m,f,g,e[T],e[T+1],e[T+2],e[T+3],c,u,v),T+=6;break;case Ge.curveTo2:f=c,g=u,r.bezierCurveTo(c,u,e[T],e[T+1],e[T+2],e[T+3]),a.updateCurvePathMinMax(m,f,g,c,u,e[T],e[T+1],e[T+2],e[T+3],v),c=e[T+2],u=e[T+3],T+=4;break;case Ge.curveTo3:f=c,g=u,c=e[T+2],u=e[T+3],r.bezierCurveTo(e[T],e[T+1],c,u,c,u),a.updateCurvePathMinMax(m,f,g,e[T],e[T+1],c,u,c,u,v),T+=4;break;case Ge.closePath:r.closePath();break}y&&a.updateScalingPathMinMax(m,v),a.setCurrentPoint(c,u)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,Xe(e),le.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){let e=this.ctx,s=this.current.fillColor,r=this.current.patternFill,a=!1;r&&(e.save(),e.fillStyle=s.getPattern(e,this,Xe(e),le.FILL),a=!0);let c=this.current.getClippedPathBoundingBox();this.contentVisible&&c!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),a&&e.restore(),t&&this.consumePath(c)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Y0}eoClip(){this.pendingClip=Wc}beginText(){this.current.textMatrix=Kc,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}let s=new Path2D,r=e.getTransform().invertSelf();for(let{transform:a,x:c,y:u,fontSize:f,path:g}of t)s.addPath(g,new DOMMatrix(a).preMultiplySelf(r).translate(c,u).scale(f,-f));e.clip(s),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){let s=this.commonObjs.get(t),r=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(r.fontMatrix=s.fontMatrix||Zi,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&wt("Invalid font matrix for font "+t),e<0?(e=-e,r.fontDirection=-1):r.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;let a=s.loadedName||"sans-serif",c=s.systemFontInfo?.css||`"${a}", ${s.fallbackName}`,u="normal";s.black?u="900":s.bold&&(u="bold");let f=s.italic?"italic":"normal",g=e;e<Bc?g=Bc:e>Gc&&(g=Gc),this.current.fontSizeScale=e/g,this.ctx.font=`${f} ${u} ${g}px ${c}`}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,s,r,a,c){this.current.textMatrix=[t,e,s,r,a,c],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)}#n(t,e,s){let r=new Path2D;return r.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),r}paintChar(t,e,s,r,a){let c=this.ctx,u=this.current,f=u.font,g=u.textRenderingMode,m=u.fontSize/u.fontSizeScale,y=g&ae.FILL_STROKE_MASK,v=!!(g&ae.ADD_TO_PATH_FLAG),S=u.patternFill&&!f.missingFile,T=u.patternStroke&&!f.missingFile,w;if((f.disableFontFace||v||S||T)&&(w=f.getPathGenerator(this.commonObjs,t)),f.disableFontFace||S||T){if(c.save(),c.translate(e,s),c.scale(m,-m),y===ae.FILL||y===ae.FILL_STROKE)if(r){let I=c.getTransform();c.setTransform(...r),c.fill(this.#n(w,I,r))}else c.fill(w);if(y===ae.STROKE||y===ae.FILL_STROKE)if(a){let I=c.getTransform();c.setTransform(...a),c.stroke(this.#n(w,I,a))}else c.lineWidth/=m,c.stroke(w);c.restore()}else(y===ae.FILL||y===ae.FILL_STROKE)&&c.fillText(t,e,s),(y===ae.STROKE||y===ae.FILL_STROKE)&&c.strokeText(t,e,s);v&&(this.pendingTextPaths||=[]).push({transform:Wt(c),x:e,y:s,fontSize:m,path:w})}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,s=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){s=!0;break}return Pt(this,"isFontSubpixelAAEnabled",s)}showText(t){let e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);let r=e.fontSize;if(r===0)return;let a=this.ctx,c=e.fontSizeScale,u=e.charSpacing,f=e.wordSpacing,g=e.fontDirection,m=e.textHScale*g,y=t.length,v=s.vertical,S=v?1:-1,T=s.defaultVMetrics,w=r*e.fontMatrix[0],I=e.textRenderingMode===ae.FILL&&!s.disableFontFace&&!e.patternFill;a.save(),a.transform(...e.textMatrix),a.translate(e.x,e.y+e.textRise),g>0?a.scale(m,-1):a.scale(m,1);let k,L;if(e.patternFill){a.save();let G=e.fillColor.getPattern(a,this,Xe(a),le.FILL);k=Wt(a),a.restore(),a.fillStyle=G}if(e.patternStroke){a.save();let G=e.strokeColor.getPattern(a,this,Xe(a),le.STROKE);L=Wt(a),a.restore(),a.strokeStyle=G}let M=e.lineWidth,N=e.textMatrixScale;if(N===0||M===0){let G=e.textRenderingMode&ae.FILL_STROKE_MASK;(G===ae.STROKE||G===ae.FILL_STROKE)&&(M=this.getSinglePixelWidth())}else M/=N;if(c!==1&&(a.scale(c,c),M/=c),a.lineWidth=M,s.isInvalidPDFjsFont){let G=[],$=0;for(let z of t)G.push(z.unicode),$+=z.width;a.fillText(G.join(""),0,0),e.x+=$*w*m,a.restore(),this.compose();return}let F=0,B;for(B=0;B<y;++B){let G=t[B];if(typeof G=="number"){F+=S*G*r/1e3;continue}let $=!1,z=(G.isSpace?f:0)+u,J=G.fontChar,et=G.accent,nt,xt,vt=G.width;if(v){let W=G.vmetric||T,K=-(G.vmetric?W[1]:vt*.5)*w,pt=W[2]*w;vt=W?-W[0]:vt,nt=K/c,xt=(F+pt)/c}else nt=F/c,xt=0;if(s.remeasure&&vt>0){let W=a.measureText(J).width*1e3/r*c;if(vt<W&&this.isFontSubpixelAAEnabled){let K=vt/W;$=!0,a.save(),a.scale(K,1),nt/=K}else vt!==W&&(nt+=(vt-W)/2e3*r/c)}if(this.contentVisible&&(G.isInFont||s.missingFile)){if(I&&!et)a.fillText(J,nt,xt);else if(this.paintChar(J,nt,xt,k,L),et){let W=nt+r*et.offset.x/c,K=xt-r*et.offset.y/c;this.paintChar(et.fontChar,W,K,k,L)}}let St=v?vt*w-z*g:vt*w+z*g;F+=St,$&&a.restore()}v?e.y-=F:e.x+=F*m,a.restore(),this.compose()}showType3Text(t){let e=this.ctx,s=this.current,r=s.font,a=s.fontSize,c=s.fontDirection,u=r.vertical?1:-1,f=s.charSpacing,g=s.wordSpacing,m=s.textHScale*c,y=s.fontMatrix||Zi,v=t.length,S=s.textRenderingMode===ae.INVISIBLE,T,w,I,k;if(!(S||a===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(m,c),T=0;T<v;++T){if(w=t[T],typeof w=="number"){k=u*w*a/1e3,this.ctx.translate(k,0),s.x+=k*m;continue}let L=(w.isSpace?g:0)+f,M=r.charProcOperatorList[w.operatorListId];if(!M){wt(`Type3 character "${w.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=w,this.save(),e.scale(a,a),e.transform(...y),this.executeOperatorList(M),this.restore()),I=bt.applyTransform([w.width,0],y)[0]*a+L,e.translate(I,0),s.x+=I*m}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,r,a,c){this.ctx.rect(s,r,a-s,c-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){let s=t[1],r=this.baseTransform||Wt(this.ctx),a={createCanvasGraphics:c=>new o(c,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new vo(t,s,this.ctx,a,r)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=bt.makeHexColor(t,e,s),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=bt.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=H0(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save();let s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Xe(e),le.SHADING);let r=Xe(e);if(r){let{width:a,height:c}=e.canvas,[u,f,g,m]=bt.getAxialAlignedBoundingBox([0,0,a,c],r);this.ctx.fillRect(u,f,g-u,m-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Vt("Should not call beginInlineImage")}beginImageData(){Vt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Wt(this.ctx),e)){let s=e[2]-e[0],r=e[3]-e[1];this.ctx.rect(e[0],e[1],s,r),this.current.updateRectMinMax(Wt(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);let e=this.ctx;t.isolated||Wr("TODO: Support non-isolated groups."),t.knockout&&wt("Knockout groups not supported.");let s=Wt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=bt.getAxialAlignedBoundingBox(t.bbox,Wt(e)),a=[0,0,e.canvas.width,e.canvas.height];r=bt.intersect(r,a)||[0,0,0,0];let c=Math.floor(r[0]),u=Math.floor(r[1]),f=Math.max(Math.ceil(r[2])-c,1),g=Math.max(Math.ceil(r[3])-u,1);this.current.startNewPathAndClipBox([0,0,f,g]);let m="groupAt"+this.groupLevel;t.smask&&(m+="_smask_"+this.smaskCounter++%2);let y=this.cachedCanvases.getCanvas(m,f,g),v=y.context;v.translate(-c,-u),v.transform(...s),t.smask?this.smaskStack.push({canvas:y.canvas,context:v,offsetX:c,offsetY:u,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(c,u),e.save()),us(e,v),this.ctx=v,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;let e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let r=Wt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);let a=bt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],r);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,e,s,r,a){if(this.#t(),cr(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let c=e[2]-e[0],u=e[3]-e[1];if(a&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=c,e[3]=u;let[f,g]=bt.singularValueDecompose2dScale(Wt(this.ctx)),{viewportScale:m}=this,y=Math.ceil(c*this.outputScaleX*m),v=Math.ceil(u*this.outputScaleY*m);this.annotationCanvas=this.canvasFactory.create(y,v);let{canvas:S,context:T}=this.annotationCanvas;this.annotationCanvasMap.set(t,S),this.annotationCanvas.savedCtx=this.ctx,this.ctx=T,this.ctx.save(),this.ctx.setTransform(f,0,0,-g,0,u*g),cr(this.ctx)}else cr(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],c,u),this.ctx.clip(),this.ctx.beginPath()}this.current=new kr(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;let e=t.count;t=this.getObject(t.data,t),t.count=e;let s=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=z0(t)),r.compiled)){r.compiled(s);return}let a=this._createMaskCanvas(t),c=a.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(c,a.offsetX,a.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,r=0,a,c){if(!this.contentVisible)return;t=this.getObject(t.data,t);let u=this.ctx;u.save();let f=Wt(u);u.transform(e,s,r,a,0,0);let g=this._createMaskCanvas(t);u.setTransform(1,0,0,1,g.offsetX-f[4],g.offsetY-f[5]);for(let m=0,y=c.length;m<y;m+=2){let v=bt.transform(f,[e,s,r,a,c[m],c[m+1]]),[S,T]=bt.applyTransform([0,0],v);u.drawImage(g.canvas,S,T)}u.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,s=this.current.fillColor,r=this.current.patternFill;for(let a of t){let{data:c,width:u,height:f,transform:g}=a,m=this.cachedCanvases.getCanvas("maskCanvas",u,f),y=m.context;y.save();let v=this.getObject(c,a);$c(y,v),y.globalCompositeOperation="source-in",y.fillStyle=r?s.getPattern(y,this,Xe(e),le.FILL):s,y.fillRect(0,0,u,f),y.restore(),e.save(),e.transform(...g),e.scale(1,-1),lr(e,m.canvas,0,0,u,f,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);if(!e){wt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,r){if(!this.contentVisible)return;let a=this.getObject(t);if(!a){wt("Dependent image isn't ready yet");return}let c=a.width,u=a.height,f=[];for(let g=0,m=r.length;g<m;g+=2)f.push({transform:[e,0,0,s,r[g],r[g+1]],x:0,y:0,w:c,h:u});this.paintInlineImageXObjectGroup(a,f)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;let{bitmap:e,width:s,height:r}=t,a=this.cachedCanvases.getCanvas("inlineImage",s,r),c=a.context;return c.filter=this.current.transferMaps,c.drawImage(e,0,0),c.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;let e=t.width,s=t.height,r=this.ctx;if(this.save(),!ce){let{filter:u}=r;u!=="none"&&u!==""&&(r.filter="none")}r.scale(1/e,-1/s);let a;if(t.bitmap)a=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)a=t;else{let f=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Vc(f,t),a=this.applyTransferMapsToCanvas(f)}let c=this._scaleImage(a,Xe(r));r.imageSmoothingEnabled=zc(Wt(r),t.interpolate),lr(r,c.img,0,0,c.paintWidth,c.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;let s=this.ctx,r;if(t.bitmap)r=t.bitmap;else{let a=t.width,c=t.height,f=this.cachedCanvases.getCanvas("inlineImage",a,c).context;Vc(f,t),r=this.applyTransferMapsToCanvas(f)}for(let a of e)s.save(),s.transform(...a.transform),s.scale(1,-1),lr(s,r,a.x,a.y,a.w,a.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){let e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);let s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Wc?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=Wt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),r=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,r)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:s,c:r,d:a}=this.ctx.getTransform(),c,u;if(s===0&&r===0){let f=Math.abs(e),g=Math.abs(a);if(f===g)if(t===0)c=u=1/f;else{let m=f*t;c=u=m<1?1/m:1}else if(t===0)c=1/f,u=1/g;else{let m=f*t,y=g*t;c=m<1?1/m:1,u=y<1?1/y:1}}else{let f=Math.abs(e*a-s*r),g=Math.hypot(e,s),m=Math.hypot(r,a);if(t===0)c=m/f,u=g/f;else{let y=t*f;c=m>y?m/y:1,u=g>y?g/y:1}}this._cachedScaleForStroking[0]=c,this._cachedScaleForStroking[1]=u}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:s}=this.current,[r,a]=this.getScaleForStroking();if(e.lineWidth=s||1,r===1&&a===1){e.stroke();return}let c=e.getLineDash();if(t&&e.save(),e.scale(r,a),c.length>0){let u=Math.max(r,a);e.setLineDash(c.map(f=>f/u)),e.lineDashOffset/=u}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(let o in Ge)Xn.prototype[o]!==void 0&&(Xn.prototype[Ge[o]]=Xn.prototype[o]);En=class{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}},So=class{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return va(this.#t)}has(t){return this.#t.has(t)}},Wn=Symbol("INTERNAL"),Ao=class{#t=!1;#e=!1;#n=!1;#s=!0;constructor(t,{name:e,intent:s,usage:r,rbGroups:a}){this.#t=!!(t&Ce.DISPLAY),this.#e=!!(t&Ce.PRINT),this.name=e,this.intent=s,this.usage=r,this.rbGroups=a}get visible(){if(this.#n)return this.#s;if(!this.#s)return!1;let{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Wn&&Vt("Internal method `_setVisible` called."),this.#n=s,this.#s=e}},To=class{#t=null;#e=new Map;#n=null;#s=null;constructor(t,e=Ce.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#s=t.order;for(let s of t.groups)this.#e.set(s.id,new Ao(e,s));if(t.baseState==="OFF")for(let s of this.#e.values())s._setVisible(Wn,!1);for(let s of t.on)this.#e.get(s)._setVisible(Wn,!0);for(let s of t.off)this.#e.get(s)._setVisible(Wn,!1);this.#n=this.getHash()}}#i(t){let e=t.length;if(e<2)return!0;let s=t[0];for(let r=1;r<e;r++){let a=t[r],c;if(Array.isArray(a))c=this.#i(a);else if(this.#e.has(a))c=this.#e.get(a).visible;else return wt(`Optional content group not found: ${a}`),!0;switch(s){case"And":if(!c)return!1;break;case"Or":if(c)return!0;break;case"Not":return!c;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Wr("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(wt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#i(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return wt(`Unknown optional content policy ${t.policy}.`),!0}return wt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){let r=this.#e.get(t);if(!r){wt(`Optional content group not found: ${t}`);return}if(s&&e&&r.rbGroups.length)for(let a of r.rbGroups)for(let c of a)c!==t&&this.#e.get(c)?._setVisible(Wn,!1,!0);r._setVisible(Wn,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(let r of t){switch(r){case"ON":case"OFF":case"Toggle":s=r;continue}let a=this.#e.get(r);if(a)switch(s){case"ON":this.setVisibility(r,!0,e);break;case"OFF":this.setVisibility(r,!1,e);break;case"Toggle":this.setVisibility(r,!a.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?va(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new vr;for(let[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}},Co=class{constructor(t,{disableRange:e=!1,disableStream:s=!1}){te(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:r,initialData:a,progressiveDone:c,contentDispositionFilename:u}=t;if(this._queuedChunks=[],this._progressiveDone=c,this._contentDispositionFilename=u,a?.length>0){let f=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(f)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((f,g)=>{this._onReceiveData({begin:f,chunk:g})}),t.addProgressListener((f,g)=>{this._onProgress({loaded:f,total:g})}),t.addProgressiveReadListener(f=>{this._onReceiveData({chunk:f})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{let r=this._rangeReaders.some(function(a){return a._begin!==t?!1:(a._enqueue(s),!0)});te(r,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){te(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new Eo(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new wo(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}},Eo=class{constructor(t,e,s=!1,r=null){this._stream=t,this._done=s||!1,this._filename=Sa(r)?r:null,this._queuedChunks=e||[],this._loaded=0;for(let a of this._queuedChunks)this._loaded+=a.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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}},wo=class{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(let s of this._requests)s.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){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};Ir=class{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Jc(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return te(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ko(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new Io(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},ko=class{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;let e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;let s=new Headers(t.headers),r=e.url;fetch(r,nu(s,this._withCredentials,this._abortController)).then(a=>{if(t._responseOrigin=Zr(a.url),!eu(a.status))throw Qr(a.status,r);this._reader=a.body.getReader(),this._headersCapability.resolve();let c=a.headers,{allowRangeRequests:u,suggestedLength:f}=qc({responseHeaders:c,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=u,this._contentLength=f||this._contentLength,this._filename=tu(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ke("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;let{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:su(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},Io=class{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;let r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;let a=new Headers(t.headers);a.append("Range",`bytes=${e}-${s-1}`);let c=r.url;fetch(c,nu(a,this._withCredentials,this._abortController)).then(u=>{let f=Zr(u.url);if(f!==t._responseOrigin)throw new Error(`Expected range response-origin "${f}" to match "${t._responseOrigin}".`);if(!eu(u.status))throw Qr(u.status,c);this._readCapability.resolve(),this._reader=u.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:su(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},Yi=200,Ki=206;Ro=class{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Jc(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,s=this.currXhrId++,r=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(let[a,c]of this.headers)e.setRequestHeader(a,c);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=Ki):r.expectedStatus=Yi,e.responseType="arraybuffer",te(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),r.onHeadersReceived=t.onHeadersReceived,r.onDone=t.onDone,r.onError=t.onError,r.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){let s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){let s=this.pendingRequests[t];if(!s)return;let r=s.xhr;if(r.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),r.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],r.status===0&&this.isHttp){s.onError(r.status);return}let a=r.status||Yi;if(!(a===Yi&&s.expectedStatus===Ki)&&a!==s.expectedStatus){s.onError(r.status);return}let u=Z0(r);if(a===Ki){let f=r.getResponseHeader("Content-Range"),g=/bytes (\d+)-(\d+)\/(\d+)/.exec(f);g?s.onDone({begin:parseInt(g[1],10),chunk:u}):(wt('Missing or invalid "Content-Range" header.'),s.onError(0))}else u?s.onDone({begin:0,chunk:u}):s.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}},Po=class{constructor(t){this._source=t,this._manager=new Ro(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return te(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Oo(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let s=new Lo(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Oo=class{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Zr(e.responseURL);let s=e.getAllResponseHeaders(),r=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(u=>{let[f,...g]=u.split(": ");return[f,g.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:c}=qc({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=c||this._contentLength,this._filename=tu(r),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Qr(t,this._url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}},Lo=class{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=Zr(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(let s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=Qr(t,this._url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},Q0=/^[a-z][a-z0-9\-+.]+:/i;Mo=class{constructor(t){this.source=t,this.url=J0(t.url),te(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return te(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Do(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new Fo(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Do=class{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;let 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();let s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(r=>{this._contentLength=r.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},r=>{r.code==="ENOENT"&&(r=new wn(`Missing PDF "${this._url}".`)),this._storedError=r,this._headersCapability.reject(r)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Ke("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}},Fo=class{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let r=t.source;this._isStreamingSupported=!r.disableStream;let a=process.getBuiltinModule("fs");this._setReadableStream(a.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},q0=1e5,ye=30,ty=.8,Ss=class o{#t=Promise.withResolvers();#e=null;#n=!1;#s=!!globalThis.FontInspector?.enabled;#i=null;#r=null;#l=0;#a=0;#u=null;#c=null;#d=0;#h=0;#f=Object.create(null);#o=[];#p=null;#m=[];#g=new WeakMap;#y=null;static#x=new Map;static#b=new Map;static#S=new WeakMap;static#T=null;static#E=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#p=t;else if(typeof t=="object")this.#p=new ReadableStream({start(f){f.enqueue(t),f.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#c=e,this.#h=s.scale*(globalThis.devicePixelRatio||1),this.#d=s.rotation,this.#r={div:null,properties:null,ctx:null};let{pageWidth:r,pageHeight:a,pageX:c,pageY:u}=s.rawDims;this.#y=[1,0,0,-1,-c,u+a],this.#a=r,this.#l=a,o.#O(),kn(e,s),this.#t.promise.finally(()=>{o.#E.delete(this),this.#r=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=ne.platform;return Pt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#u.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#i??=e.lang,Object.assign(this.#f,e.styles),this.#k(e.items),t()},this.#t.reject)};return this.#u=this.#p.getReader(),o.#E.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let s=t.scale*(globalThis.devicePixelRatio||1),r=t.rotation;if(r!==this.#d&&(e?.(),this.#d=r,kn(this.#c,{rotation:r})),s!==this.#h){e?.(),this.#h=s;let a={div:null,properties:null,ctx:o.#I(this.#i)};for(let c of this.#m)a.properties=this.#g.get(c),a.div=c,this.#A(a)}}cancel(){let t=new Ke("TextLayer task cancelled.");this.#u?.cancel(t).catch(()=>{}),this.#u=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#o}#k(t){if(this.#n)return;this.#r.ctx??=o.#I(this.#i);let e=this.#m,s=this.#o;for(let r of t){if(e.length>q0){wt("Ignoring additional textDivs for performance reasons."),this.#n=!0;return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){let a=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),r.id!==null&&this.#e.setAttribute("id",`${r.id}`),a.append(this.#e)}else r.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(r.str),this.#R(r)}}#R(t){let e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);let r=bt.transform(this.#y,t.transform),a=Math.atan2(r[1],r[0]),c=this.#f[t.fontName];c.vertical&&(a+=Math.PI/2);let u=this.#s&&c.fontSubstitution||c.fontFamily;u=o.fontFamilyMap.get(u)||u;let f=Math.hypot(r[2],r[3]),g=f*o.#D(u,this.#i),m,y;a===0?(m=r[4],y=r[5]-g):(m=r[4]+g*Math.sin(a),y=r[5]-g*Math.cos(a));let v="calc(var(--scale-factor)*",S=e.style;this.#e===this.#c?(S.left=`${(100*m/this.#a).toFixed(2)}%`,S.top=`${(100*y/this.#l).toFixed(2)}%`):(S.left=`${v}${m.toFixed(2)}px)`,S.top=`${v}${y.toFixed(2)}px)`),S.fontSize=`${v}${(o.#T*f).toFixed(2)}px)`,S.fontFamily=u,s.fontSize=f,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(e.dataset.fontName=c.fontSubstitutionLoadedName||t.fontName),a!==0&&(s.angle=a*(180/Math.PI));let T=!1;if(t.str.length>1)T=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let w=Math.abs(t.transform[0]),I=Math.abs(t.transform[3]);w!==I&&Math.max(w,I)/Math.min(w,I)>1.5&&(T=!0)}if(T&&(s.canvasWidth=c.vertical?t.height:t.width),this.#g.set(e,s),this.#r.div=e,this.#r.properties=s,this.#A(this.#r),s.hasText&&this.#e.append(e),s.hasEOL){let w=document.createElement("br");w.setAttribute("role","presentation"),this.#e.append(w)}}#A(t){let{div:e,properties:s,ctx:r}=t,{style:a}=e,c="";if(o.#T>1&&(c=`scale(${1/o.#T})`),s.canvasWidth!==0&&s.hasText){let{fontFamily:u}=a,{canvasWidth:f,fontSize:g}=s;o.#w(r,g*this.#h,u);let{width:m}=r.measureText(e.textContent);m>0&&(c=`scaleX(${f*this.#h/m}) ${c}`)}s.angle!==0&&(c=`rotate(${s.angle}deg) ${c}`),c.length>0&&(a.transform=c)}static cleanup(){if(!(this.#E.size>0)){this.#x.clear();for(let{canvas:t}of this.#b.values())t.remove();this.#b.clear()}}static#I(t=null){let e=this.#b.get(t||="");if(!e){let s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#b.set(t,e),this.#S.set(e,{size:0,family:""})}return e}static#w(t,e,s){let r=this.#S.get(t);e===r.size&&s===r.family||(t.font=`${e}px ${s}`,r.size=e,r.family=s)}static#O(){if(this.#T!==null)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#T=t.getBoundingClientRect().height,t.remove()}static#D(t,e){let s=this.#x.get(t);if(s)return s;let r=this.#I(e);r.canvas.width=r.canvas.height=ye,this.#w(r,ye,t);let a=r.measureText(""),c=a.fontBoundingBoxAscent,u=Math.abs(a.fontBoundingBoxDescent);if(c){let m=c/(c+u);return this.#x.set(t,m),r.canvas.width=r.canvas.height=0,m}r.strokeStyle="red",r.clearRect(0,0,ye,ye),r.strokeText("g",0,0);let f=r.getImageData(0,0,ye,ye).data;u=0;for(let m=f.length-1-3;m>=0;m-=4)if(f[m]>0){u=Math.ceil(m/4/ye);break}r.clearRect(0,0,ye,ye),r.strokeText("A",0,ye),f=r.getImageData(0,0,ye,ye).data,c=0;for(let m=0,y=f.length;m<y;m+=4)if(f[m]>0){c=ye-Math.floor(m/4/ye);break}r.canvas.width=r.canvas.height=0;let g=c?c/(c+u):ty;return this.#x.set(t,g),g}},As=class o{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function r(a){if(!a)return;let c=null,u=a.name;if(u==="#text")c=a.value;else if(o.shouldBuildText(u))a?.attributes?.textContent?c=a.attributes.textContent:a.value&&(c=a.value);else return;if(c!==null&&e.push({str:c}),!!a.children)for(let f of a.children)r(f)}return r(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},ey=65536,ny=100,sy=5e3,ry=ce?ho:lo,iy=ce?fo:Tr,oy=ce?uo:co,ay=ce?po:wr;_o=class o{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${o.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}},Rr=class{constructor(t,e,s=!1,r=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=r,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(let s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(let e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Vt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},No=class{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Pt(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"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}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()}},Uo=class{#t=null;#e=!1;constructor(t,e,s,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new pr:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new Pr,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}get trimBox(){return this._pageInfo.trimBox??null}get bleedBox(){return this._pageInfo.bleedBox??null}get colorSpaceResources(){return this._pageInfo.colorSpaceResources??{}}get imglyPatchVersion(){return this._pageInfo.imglyPatchVersion??null}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:r=0,dontFlip:a=!1}={}){return new ms({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:r,dontFlip:a})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Pt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:r=dn.ENABLE,transform:a=null,background:c=null,optionalContentConfigPromise:u=null,annotationCanvasMap:f=null,pageColors:g=null,printAnnotationStorage:m=null,isEditing:y=!1}){this._stats?.time("Overall");let v=this._transport.getRenderingIntent(s,r,m,y),{renderingIntent:S,cacheKey:T}=v;this.#e=!1,this.#s(),u||=this._transport.getOptionalContentConfig(S);let w=this._intentStates.get(T);w||(w=Object.create(null),this._intentStates.set(T,w)),w.streamReaderCancelTimeout&&(clearTimeout(w.streamReaderCancelTimeout),w.streamReaderCancelTimeout=null);let I=!!(S&Ce.PRINT);w.displayReadyCapability||(w.displayReadyCapability=Promise.withResolvers(),w.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(v));let k=N=>{w.renderTasks.delete(L),(this._maybeCleanupAfterRender||I)&&(this.#e=!0),this.#n(!I),N?(L.capability.reject(N),this._abortOperatorList({intentState:w,reason:N instanceof Error?N:new Error(N)})):L.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},L=new jo({callback:k,params:{canvasContext:t,viewport:e,transform:a,background:c},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:f,operatorList:w.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!I,pdfBug:this._pdfBug,pageColors:g});(w.renderTasks||=new Set).add(L);let M=L.task;return Promise.all([w.displayReadyCapability.promise,u]).then(([N,F])=>{if(this.destroyed){k();return}if(this._stats?.time("Rendering"),!(F.renderingIntent&S))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");L.initializeGraphics({transparency:N,optionalContentConfig:F}),L.operatorListChanged()}).catch(k),M}getOperatorList({intent:t="display",annotationMode:e=dn.ENABLE,printAnnotationStorage:s=null,isEditing:r=!1}={}){function a(){u.operatorList.lastChunk&&(u.opListReadCapability.resolve(u.operatorList),u.renderTasks.delete(f))}let c=this._transport.getRenderingIntent(t,e,s,r,!0),u=this._intentStates.get(c.cacheKey);u||(u=Object.create(null),this._intentStates.set(c.cacheKey,u));let f;return u.opListReadCapability||(f=Object.create(null),f.operatorListChanged=a,u.opListReadCapability=Promise.withResolvers(),(u.renderTasks||=new Set).add(f),u.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c)),u.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(r){return r.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>As.textContent(s));let e=this.streamTextContent(t);return new Promise(function(s,r){function a(){c.read().then(function({value:f,done:g}){if(g){s(u);return}u.lang??=f.lang,Object.assign(u.styles,f.styles),u.items.push(...f.items),a()},r)}let c=e.getReader(),u={items:[],styles:Object.create(null),lang:null};a()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#s(),Promise.all(t)}cleanup(t=!1){this.#e=!0;let e=this.#n(!1);return t&&e&&(this._stats&&=new pr),e}#n(t=!1){if(this.#s(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#n(!1)},sy),!1;for(let{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#s(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){let s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,r=t.length;s<r;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:r}){let{map:a,transfer:c}=s,f=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:a,modifiedIds:r},c).getReader(),g=this._intentStates.get(e);g.streamReader=f;let m=()=>{f.read().then(({value:y,done:v})=>{if(v){g.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(y,g),m())},y=>{if(g.streamReader=null,!this._transport.destroyed){if(g.operatorList){g.operatorList.lastChunk=!0;for(let v of g.renderTasks)v.operatorListChanged();this.#n(!0)}if(g.displayReadyCapability)g.displayReadyCapability.reject(y);else if(g.opListReadCapability)g.opListReadCapability.reject(y);else throw y}})};m()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof ys){let r=ny;e.extraDelay>0&&e.extraDelay<1e3&&(r+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},r);return}}if(t.streamReader.cancel(new Ke(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[r,a]of this._intentStates)if(a===t){this._intentStates.delete(r);break}this.cleanup()}}}get stats(){return this._stats}},Bo=class{#t=new Map;#e=Promise.resolve();postMessage(t,e){let s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[r]of this.#t)r.call(this,s)})}addEventListener(t,e,s=null){let r=null;if(s?.signal instanceof AbortSignal){let{signal:a}=s;if(a.aborted){wt("LoopbackPort - cannot use an `aborted` signal.");return}let c=()=>this.removeEventListener(t,e);r=()=>a.removeEventListener("abort",c),a.addEventListener("abort",c)}this.#t.set(e,r)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}},Yn=class o{static#t=0;static#e=!1;static#n;static{ce&&(this.#e=!0,En.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}let r=new URL(e,s);return s.origin===r.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:s=w0()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(o.#n?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(o.#n||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#s(){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 Cn("main","worker",t),this._messageHandler.on("ready",function(){}),this.#s()}_initialize(){if(o.#e||o.#i){this._setupFakeWorker();return}let{workerSrc:t}=o;try{o._isSameOrigin(window.location.href,t)||(t=o._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),s=new Cn("main","worker",e),r=()=>{a.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;e.addEventListener("error",()=>{this._webWorker||r()},{signal:a.signal}),s.on("test",u=>{if(a.abort(),this.destroyed||!u){r();return}this._messageHandler=s,this._port=e,this._webWorker=e,this.#s()}),s.on("ready",u=>{if(a.abort(),this.destroyed){r();return}try{c()}catch{this._setupFakeWorker()}});let c=()=>{let u=new Uint8Array;s.send("test",u,[u.buffer])};c();return}catch{Wr("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){o.#e||(wt("Setting up fake worker."),o.#e=!0),o._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let e=new Bo;this._port=e;let s=`fake${o.#t++}`,r=new Cn(s+"_worker",s,e);t.setup(r,e),this._messageHandler=new Cn(s,s+"_worker",e),this.#s()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,o.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let e=this.#n?.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 o(t)}static get workerSrc(){if(En.workerSrc)return En.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#i(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Pt(this,"_setupFakeWorkerGlobal",(async()=>this.#i?this.#i:(await import(this.workerSrc)).WorkerMessageHandler)())}},Go=class{#t=new Map;#e=new Map;#n=new Map;#s=new Map;#i=null;constructor(t,e,s,r,a){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Pr,this.fontLoader=new oo({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#r(t,e=null){let s=this.#t.get(t);if(s)return s;let r=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,r),r}get annotationStorage(){return Pt(this,"annotationStorage",new vs)}getRenderingIntent(t,e=dn.ENABLE,s=null,r=!1,a=!1){let c=Ce.DISPLAY,u=io;switch(t){case"any":c=Ce.ANY;break;case"display":break;case"print":c=Ce.PRINT;break;default:wt(`getRenderingIntent - invalid intent: ${t}`)}let f=c&Ce.PRINT&&s instanceof xr?s:this.annotationStorage;switch(e){case dn.DISABLE:c+=Ce.ANNOTATIONS_DISABLE;break;case dn.ENABLE:break;case dn.ENABLE_FORMS:c+=Ce.ANNOTATIONS_FORMS;break;case dn.ENABLE_STORAGE:c+=Ce.ANNOTATIONS_STORAGE,u=f.serializable;break;default:wt(`getRenderingIntent - invalid annotationMode: ${e}`)}r&&(c+=Ce.IS_EDITING),a&&(c+=Ce.OPLIST);let{ids:g,hash:m}=f.modifiedIds,y=[c,u.hash,m];return{renderingIntent:c,cacheKey:y.join("_"),annotationStorageSerializable:u,modifiedIds:g}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(new Error("Worker was destroyed during onPassword callback"));let t=[];for(let s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#n.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),Ss.cleanup(),this._networkStream?.cancelAllRequests(new Ke("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,r)=>{te(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},r.onPull=()=>{this._fullReader.read().then(function({value:a,done:c}){if(c){r.close();return}te(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{r.error(a)})},r.onCancel=a=>{this._fullReader.cancel(a),r.ready.catch(c=>{if(!this.destroyed)throw c})}}),t.on("ReaderHeadersReady",async s=>{await this._fullReader.headersReady;let{isStreamingSupported:r,isRangeSupported:a,contentLength:c}=this._fullReader;return(!r||!a)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=u=>{e.onProgress?.({loaded:u.loaded,total:u.total})}),{isStreamingSupported:r,isRangeSupported:a,contentLength:c}}),t.on("GetRangeReader",(s,r)=>{te(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let a=this._networkStream.getRangeReader(s.begin,s.end);if(!a){r.close();return}r.onPull=()=>{a.read().then(function({value:c,done:u}){if(u){r.close();return}te(c instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(c),1,[c])}).catch(c=>{r.error(c)})},r.onCancel=c=>{a.cancel(c),r.ready.catch(u=>{if(!this.destroyed)throw u})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new No(s,this))}),t.on("DocException",s=>{e._capability.reject(be(s))}),t.on("PasswordRequest",s=>{this.#i=Promise.withResolvers();try{if(!e.onPassword)throw be(s);let r=a=>{a instanceof Error?this.#i.reject(a):this.#i.resolve({password:a})};e.onPassword(r,s.code)}catch(r){this.#i.reject(r)}return this.#i.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,r,a])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(r){case"Font":let{disableFontFace:c,fontExtraProperties:u,pdfBug:f}=this._params;if("error"in a){let v=a.error;wt(`Error during font loading: ${v}`),this.commonObjs.resolve(s,v);break}let g=f&&globalThis.FontInspector?.enabled?(v,S)=>globalThis.FontInspector.fontAdded(v,S):null,m=new ao(a,{disableFontFace:c,fontExtraProperties:u,inspectFont:g});this.fontLoader.bind(m).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!u&&m.data&&(m.data=null),this.commonObjs.resolve(s,m)});break;case"CopyLocalImage":let{imageRef:y}=a;te(y,"The imageRef must be defined.");for(let v of this.#e.values())for(let[,S]of v.objs)if(S?.ref===y)return S.dataLen?(this.commonObjs.resolve(s,structuredClone(S)),S.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,a);break;default:throw new Error(`Got unknown common object type ${r}`)}return null}),t.on("obj",([s,r,a,c])=>{if(this.destroyed)return;let u=this.#e.get(r);if(!u.objs.has(s)){if(u._intentStates.size===0){c?.bitmap?.close();return}switch(a){case"Image":u.objs.resolve(s,c),c?.dataLen>x0&&(u._maybeCleanupAfterRender=!0);break;case"Pattern":u.objs.resolve(s,c);break;default:throw new Error(`Got unknown object type ${a}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),t.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&wt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._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."));let e=t-1,s=this.#n.get(e);if(s)return s;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&this.#s.set(a.refStr,t);let c=new Uo(e,a,this,this._params.pdfBug);return this.#e.set(e,c),c});return this.#n.set(e,r),r}getPageIndex(t){return Xc(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.#r("GetFieldObjects")}hasJSActions(){return this.#r("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#r("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.#r("GetOptionalContentConfig").then(e=>new To(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#t.get(t);if(e)return e;let s=this.messageHandler.sendWithPromise(t,null).then(r=>({info:r[0],metadata:r[1]?new So(r[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Ss.cleanup()}}cachedPageNumber(t){if(!Xc(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#s.get(e)??null}},hs=Symbol("INITIAL_DATA"),Pr=class{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:hs}}get(t,e=null){if(e){let r=this.#e(t);return r.promise.then(()=>e(r.data)),null}let s=this.#t[t];if(!s||s.data===hs)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){let e=this.#t[t];return!!e&&e.data!==hs}delete(t){let e=this.#t[t];return!e||e.data===hs?!1:(delete this.#t[t],!0)}resolve(t,e=null){let s=this.#e(t);s.data=e,s.resolve()}clear(){for(let t in this.#t){let{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let t in this.#t){let{data:e}=this.#t[t];e!==hs&&(yield[t,e])}}},Ho=class{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}},jo=class o{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:r,annotationCanvasMap:a,operatorList:c,pageIndex:u,canvasFactory:f,filterFactory:g,useRequestAnimationFrame:m=!1,pdfBug:y=!1,pageColors:v=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=r,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=c,this._pageIndex=u,this.canvasFactory=f,this.filterFactory=g,this._pdfBug=y,this.pageColors=v,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=m===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Ho(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(o.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");o.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:s,viewport:r,transform:a,background:c}=this.params;this.gfx=new Xn(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:r,transparency:t,background:c}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),o.#e.delete(this._canvas),this.callback(t||new ys(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),o.#e.delete(this._canvas),this.callback())))}},hy="4.10.45",dy="18f8e0416",Yx=Mt(670);Or=class{static CMYK_G([t,e,s,r]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+r)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=ds(t),[t,t,t]}static G_HTML([t]){let e=Yc(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(ds)}static RGB_HTML(t){return`#${t.map(Yc).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,r]){return["RGB",1-Math.min(1,t+r),1-Math.min(1,s+r),1-Math.min(1,e+r)]}static CMYK_rgb([t,e,s,r]){return[ds(1-Math.min(1,t+r)),ds(1-Math.min(1,s+r)),ds(1-Math.min(1,e+r))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){let r=1-t,a=1-e,c=1-s,u=Math.min(r,a,c);return["CMYK",r,a,c,u]}},Vo=class{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");let r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),s||(r.setAttribute("width",`${t}px`),r.setAttribute("height",`${e}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${t} ${e}`),r}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Vt("Abstract method `_createSVG` called.")}},Ts=class extends Vo{_createSVG(t){return document.createElementNS(tn,t)}},Lr=class{static setupStorage(t,e,s,r,a){let c=r.getValue(e,{value:null});switch(s.name){case"textarea":if(c.value!==null&&(t.textContent=c.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(c.value===s.attributes.xfaOn?t.setAttribute("checked",!0):c.value===s.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",u=>{r.setValue(e,{value:u.target.checked?u.target.getAttribute("xfaOn"):u.target.getAttribute("xfaOff")})})}else{if(c.value!==null&&t.setAttribute("value",c.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})})}break;case"select":if(c.value!==null){t.setAttribute("value",c.value);for(let u of s.children)u.attributes.value===c.value?u.attributes.selected=!0:u.attributes.hasOwnProperty("selected")&&delete u.attributes.selected}t.addEventListener("input",u=>{let f=u.target.options,g=f.selectedIndex===-1?"":f[f.selectedIndex].value;r.setValue(e,{value:g})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:r,linkService:a}){let{attributes:c}=e,u=t instanceof HTMLAnchorElement;c.type==="radio"&&(c.name=`${c.name}-${r}`);for(let[f,g]of Object.entries(c))if(g!=null)switch(f){case"class":g.length&&t.setAttribute(f,g.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",g);break;case"style":Object.assign(t.style,g);break;case"textContent":t.textContent=g;break;default:(!u||f!=="href"&&f!=="newWindow")&&t.setAttribute(f,g)}u&&a.addLinkAttributes(t,c.href,c.newWindow),s&&c.dataId&&this.setupStorage(t,c.dataId,e,s)}static render(t){let e=t.annotationStorage,s=t.linkService,r=t.xfaHtml,a=t.intent||"display",c=document.createElement(r.name);r.attributes&&this.setAttributes({html:c,element:r,intent:a,linkService:s});let u=a!=="richText",f=t.div;if(f.append(c),t.viewport){let y=`matrix(${t.viewport.transform.join(",")})`;f.style.transform=y}u&&f.setAttribute("class","xfaLayer xfaFont");let g=[];if(r.children.length===0){if(r.value){let y=document.createTextNode(r.value);c.append(y),u&&As.shouldBuildText(r.name)&&g.push(y)}return{textDivs:g}}let m=[[r,-1,c]];for(;m.length>0;){let[y,v,S]=m.at(-1);if(v+1===y.children.length){m.pop();continue}let T=y.children[++m.at(-1)[1]];if(T===null)continue;let{name:w}=T;if(w==="#text"){let k=document.createTextNode(T.value);g.push(k),S.append(k);continue}let I=T?.attributes?.xmlns?document.createElementNS(T.attributes.xmlns,w):document.createElement(w);if(S.append(I),T.attributes&&this.setAttributes({html:I,element:T,storage:e,intent:a,linkService:s}),T.children?.length>0)m.push([T,-1,I]);else if(T.value){let k=document.createTextNode(T.value);u&&As.shouldBuildText(w)&&g.push(k),I.append(k)}}for(let y of f.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.setAttribute("readOnly",!0);return{textDivs:g}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}},Is=1e3,fy=9,Pn=new WeakSet;$o=class{static create(t){switch(t.data.annotationType){case ee.LINK:return new Mr(t);case ee.TEXT:return new zo(t);case ee.WIDGET:switch(t.data.fieldType){case"Tx":return new Wo(t);case"Btn":return t.data.radioButton?new Dr(t):t.data.checkBox?new Yo(t):new Ko(t);case"Ch":return new Zo(t);case"Sig":return new Xo(t)}return new en(t);case ee.POPUP:return new Cs(t);case ee.FREETEXT:return new Fr(t);case ee.LINE:return new Jo(t);case ee.SQUARE:return new qo(t);case ee.CIRCLE:return new ta(t);case ee.POLYLINE:return new _r(t);case ee.CARET:return new na(t);case ee.INK:return new Es(t);case ee.POLYGON:return new ea(t);case ee.HIGHLIGHT:return new Nr(t);case ee.UNDERLINE:return new sa(t);case ee.SQUIGGLY:return new ra(t);case ee.STRIKEOUT:return new ia(t);case ee.STAMP:return new Ur(t);case ee.FILEATTACHMENT:return new oa(t);default:return new Qt(t)}}},Qt=class o{#t=null;#e=!1;#n=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:r=!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(s)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return o._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#s(e),this.#n?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#n?.popup.resetEdited(),this.#t=null)}#s(t){let{container:{style:e},data:{rect:s,rotation:r},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:c,pageX:u,pageY:f}}}}=this;s?.splice(0,4,...t);let{width:g,height:m}=fn(t);e.left=`${100*(t[0]-u)/a}%`,e.top=`${100*(c-t[3]+f)/c}%`,r===0?(e.width=`${100*g/a}%`,e.height=`${100*m/c}%`):this.setRotation(r)}_createContainer(t){let{data:e,parent:{page:s,viewport:r}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof en||(a.tabIndex=Is);let{style:c}=a;if(c.zIndex=this.parent.zIndex++,e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof Cs){let{rotation:w}=e;return!e.hasOwnCanvas&&w!==0&&this.setRotation(w,a),a}let{width:u,height:f}=fn(e.rect);if(!t&&e.borderStyle.width>0){c.borderWidth=`${e.borderStyle.width}px`;let w=e.borderStyle.horizontalCornerRadius,I=e.borderStyle.verticalCornerRadius;if(w>0||I>0){let L=`calc(${w}px * var(--scale-factor)) / calc(${I}px * var(--scale-factor))`;c.borderRadius=L}else if(this instanceof Dr){let L=`calc(${u}px * var(--scale-factor)) / calc(${f}px * var(--scale-factor))`;c.borderRadius=L}switch(e.borderStyle.style){case cs.SOLID:c.borderStyle="solid";break;case cs.DASHED:c.borderStyle="dashed";break;case cs.BEVELED:wt("Unimplemented border style: beveled");break;case cs.INSET:wt("Unimplemented border style: inset");break;case cs.UNDERLINE:c.borderBottomStyle="solid";break;default:break}let k=e.borderColor||null;k?(this.#e=!0,c.borderColor=bt.makeHexColor(k[0]|0,k[1]|0,k[2]|0)):c.borderWidth=0}let g=bt.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:m,pageHeight:y,pageX:v,pageY:S}=r.rawDims;c.left=`${100*(g[0]-v)/m}%`,c.top=`${100*(g[1]-S)/y}%`;let{rotation:T}=e;return e.hasOwnCanvas||T===0?(c.width=`${100*u/m}%`,c.height=`${100*f/y}%`):this.setRotation(T,a),a}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:s,pageHeight:r}=this.parent.viewport.rawDims,{width:a,height:c}=fn(this.data.rect),u,f;t%180===0?(u=100*a/s,f=100*c/r):(u=100*c/s,f=100*a/r),e.style.width=`${u}%`,e.style.height=`${f}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,s,r)=>{let a=r.detail[e],c=a[0],u=a.slice(1);r.target.style[s]=Or[`${c}_HTML`](u),this.annotationStorage.setValue(this.data.id,{[s]:Or[`${c}_rgb`](u)})};return Pt(this,"_commonActions",{display:e=>{let{display:s}=e.detail,r=s%2===1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{let s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){let s=this._commonActions;for(let r of Object.keys(e.detail))(t[r]||s[r])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let s=this._commonActions;for(let[r,a]of Object.entries(e)){let c=s[r];if(c){let u={detail:{[r]:a},target:t};c(u),delete e[r]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,s,r,a]=this.data.rect.map(w=>Math.fround(w));if(t.length===8){let[w,I,k,L]=t.subarray(2,6);if(r===w&&a===I&&e===k&&s===L)return}let{style:c}=this.container,u;if(this.#e){let{borderColor:w,borderWidth:I}=c;c.borderWidth=0,u=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${w}" stroke-width="${I}">`],this.container.classList.add("hasBorder")}let f=r-e,g=a-s,{svgFactory:m}=this,y=m.createElement("svg");y.classList.add("quadrilateralsContainer"),y.setAttribute("width",0),y.setAttribute("height",0);let v=m.createElement("defs");y.append(v);let S=m.createElement("clipPath"),T=`clippath_${this.data.id}`;S.setAttribute("id",T),S.setAttribute("clipPathUnits","objectBoundingBox"),v.append(S);for(let w=2,I=t.length;w<I;w+=8){let k=t[w],L=t[w+1],M=t[w+2],N=t[w+3],F=m.createElement("rect"),B=(M-e)/f,G=(a-L)/g,$=(k-M)/f,z=(L-N)/g;F.setAttribute("x",B),F.setAttribute("y",G),F.setAttribute("width",$),F.setAttribute("height",z),S.append(F),u?.push(`<rect vector-effect="non-scaling-stroke" x="${B}" y="${G}" width="${$}" height="${z}"/>`)}this.#e&&(u.push("</g></svg>')"),c.backgroundImage=u.join("")),this.container.append(y),this.container.style.clipPath=`url(#${T})`}_createPopup(){let{data:t}=this,e=this.#n=new Cs({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){Vt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let s=[];if(this._fieldObjects){let r=this._fieldObjects[t];if(r)for(let{page:a,id:c,exportValues:u}of r){if(a===-1||c===e)continue;let f=typeof u=="string"?u:null,g=document.querySelector(`[data-element-id="${c}"]`);if(g&&!Pn.has(g)){wt(`_getElementsByName - element not allowed: ${c}`);continue}s.push({id:c,exportValue:f,domElement:g})}return s}for(let r of document.getElementsByName(t)){let{exportValue:a}=r,c=r.getAttribute("data-element-id");c!==e&&Pn.has(r)&&s.push({id:c,exportValue:a,domElement:r})}return s}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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}},Mr=class extends Qt{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let r=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(s,t.action),r=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),r=!0):t.setOCGState?(this.#n(s,t.setOCGState),r=!0):t.dest?(this._bindLink(s,t.dest),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),r=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(s,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(s),this.container}#t(){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.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#n(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let r of Object.keys(e.actions)){let a=s.get(r);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:r}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){let s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){wt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();let{fields:r,refs:a,include:c}=e,u=[];if(r.length!==0||a.length!==0){let m=new Set(a);for(let y of r){let v=this._fieldObjects[y]||[];for(let{id:S}of v)m.add(S)}for(let y of Object.values(this._fieldObjects))for(let v of y)m.has(v.id)===c&&u.push(v)}else for(let m of Object.values(this._fieldObjects))u.push(...m);let f=this.annotationStorage,g=[];for(let m of u){let{id:y}=m;switch(g.push(y),m.type){case"text":{let S=m.defaultValue||"";f.setValue(y,{value:S});break}case"checkbox":case"radiobutton":{let S=m.defaultValue===m.exportValues;f.setValue(y,{value:S});break}case"combobox":case"listbox":{let S=m.defaultValue||"";f.setValue(y,{value:S});break}default:continue}let v=document.querySelector(`[data-element-id="${y}"]`);if(v){if(!Pn.has(v)){wt(`_bindResetFormAction - element not allowed: ${y}`);continue}}else continue;v.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}}),!1}}},zo=class extends Qt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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}},en=class extends Qt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ne.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,r,a){s.includes("mouse")?t.addEventListener(s,c=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(c),shift:c.shiftKey,modifier:this._getKeyModifier(c)}})}):t.addEventListener(s,c=>{if(s==="blur"){if(!e.focused||!c.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(c)}})})}_setEventListeners(t,e,s,r){for(let[a,c]of s)(c==="Action"||this.data.actions?.[c])&&((c==="Focus"||c==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,a,c,r),c==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":bt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||fy,a=t.style,c,u=2,f=g=>Math.round(10*g)/10;if(this.data.multiLine){let g=Math.abs(this.data.rect[3]-this.data.rect[1]-u),m=Math.round(g/(hr*r))||1,y=g/m;c=Math.min(r,f(y/hr))}else{let g=Math.abs(this.data.rect[3]-this.data.rect[1]-u);c=Math.min(r,f(g/hr))}a.fontSize=`calc(${c}px * var(--scale-factor))`,a.color=bt.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(a.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}},Wo=class extends en{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,r){let a=this.annotationStorage;for(let c of this._getElementsByName(t.name,t.id))c.domElement&&(c.domElement[e]=s),a.setValue(c.id,{[r]:s})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){let r=t.getValue(e,{value:this.data.fieldValue}),a=r.value||"",c=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;c&&a.length>c&&(a=a.slice(0,c));let u=r.formattedValue||this.data.textContent?.join(`
|
|
4
|
-
`)||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));let f={userValue:a,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=u??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",u??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Pn.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=Is,this._setRequired(s,this.data.required),c&&(s.maxLength=c),s.addEventListener("input",m=>{t.setValue(e,{value:m.target.value}),this.setPropertyOnSiblings(s,"value",m.target.value,"value"),f.formattedValue=null}),s.addEventListener("resetform",m=>{let y=this.data.defaultFieldValue??"";s.value=f.userValue=y,f.formattedValue=null});let g=m=>{let{formattedValue:y}=f;y!=null&&(m.target.value=y),m.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",y=>{if(f.focused)return;let{target:v}=y;f.userValue&&(v.value=f.userValue),f.lastCommittedValue=v.value,f.commitKey=1,this.data.actions?.Focus||(f.focused=!0)}),s.addEventListener("updatefromsandbox",y=>{this.showElementAndHideCanvas(y.target);let v={value(S){f.userValue=S.detail.value??"",t.setValue(e,{value:f.userValue.toString()}),S.target.value=f.userValue},formattedValue(S){let{formattedValue:T}=S.detail;f.formattedValue=T,T!=null&&S.target!==document.activeElement&&(S.target.value=T),t.setValue(e,{formattedValue:T})},selRange(S){S.target.setSelectionRange(...S.detail.selRange)},charLimit:S=>{let{charLimit:T}=S.detail,{target:w}=S;if(T===0){w.removeAttribute("maxLength");return}w.setAttribute("maxLength",T);let I=f.userValue;!I||I.length<=T||(I=I.slice(0,T),w.value=f.userValue=I,t.setValue(e,{value:I}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:I,willCommit:!0,commitKey:1,selStart:w.selectionStart,selEnd:w.selectionEnd}}))}};this._dispatchEventFromSandbox(v,y)}),s.addEventListener("keydown",y=>{f.commitKey=1;let v=-1;if(y.key==="Escape"?v=0:y.key==="Enter"&&!this.data.multiLine?v=2:y.key==="Tab"&&(f.commitKey=3),v===-1)return;let{value:S}=y.target;f.lastCommittedValue!==S&&(f.lastCommittedValue=S,f.userValue=S,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:S,willCommit:!0,commitKey:v,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}))});let m=g;g=null,s.addEventListener("blur",y=>{if(!f.focused||!y.relatedTarget)return;this.data.actions?.Blur||(f.focused=!1);let{value:v}=y.target;f.userValue=v,f.lastCommittedValue!==v&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:f.commitKey,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}),m(y)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",y=>{f.lastCommittedValue=null;let{data:v,target:S}=y,{value:T,selectionStart:w,selectionEnd:I}=S,k=w,L=I;switch(y.inputType){case"deleteWordBackward":{let M=T.substring(0,w).match(/\w*[^\w]*$/);M&&(k-=M[0].length);break}case"deleteWordForward":{let M=T.substring(w).match(/^[^\w]*\w*/);M&&(L+=M[0].length);break}case"deleteContentBackward":w===I&&(k-=1);break;case"deleteContentForward":w===I&&(L+=1);break}y.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,change:v||"",willCommit:!1,selStart:k,selEnd:L}})}),this._setEventListeners(s,f,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],y=>y.target.value)}if(g&&s.addEventListener("blur",g),this.data.comb){let y=(this.data.rect[2]-this.data.rect[0])/c;s.classList.add("comb"),s.style.letterSpacing=`calc(${y}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}},Xo=class extends en{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}},Yo=class extends en{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,s=e.id,r=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof r=="string"&&(r=r!=="Off",t.setValue(s,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let a=document.createElement("input");return Pn.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=Is,a.addEventListener("change",c=>{let{name:u,checked:f}=c.target;for(let g of this._getElementsByName(u,s)){let m=f&&g.exportValue===e.exportValue;g.domElement&&(g.domElement.checked=m),t.setValue(g.id,{value:m})}t.setValue(s,{value:f})}),a.addEventListener("resetform",c=>{let u=e.defaultFieldValue||"Off";c.target.checked=u===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",c=>{let u={value(f){f.target.checked=f.detail.value!=="Off",t.setValue(s,{value:f.target.checked})}};this._dispatchEventFromSandbox(u,c)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],c=>c.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}},Dr=class extends en{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,s=e.id,r=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof r=="string"&&(r=r!==e.buttonValue,t.setValue(s,{value:r})),r)for(let c of this._getElementsByName(e.fieldName,s))t.setValue(c.id,{value:!1});let a=document.createElement("input");if(Pn.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.tabIndex=Is,a.addEventListener("change",c=>{let{name:u,checked:f}=c.target;for(let g of this._getElementsByName(u,s))t.setValue(g.id,{value:!1});t.setValue(s,{value:f})}),a.addEventListener("resetform",c=>{let u=e.defaultFieldValue;c.target.checked=u!=null&&u===e.buttonValue}),this.enableScripting&&this.hasJSActions){let c=e.buttonValue;a.addEventListener("updatefromsandbox",u=>{let f={value:g=>{let m=c===g.detail.value;for(let y of this._getElementsByName(g.target.name)){let v=m&&y.id===s;y.domElement&&(y.domElement.checked=v),t.setValue(y.id,{value:v})}}};this._dispatchEventFromSandbox(f,u)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],u=>u.target.checked)}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}},Ko=class extends Mr{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}},Zo=class extends en{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),r=document.createElement("select");Pn.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=Is;let a=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",m=>{let y=this.data.defaultFieldValue;for(let v of r.options)v.selected=v.value===y});for(let m of this.data.options){let y=document.createElement("option");y.textContent=m.displayValue,y.value=m.exportValue,s.value.includes(m.exportValue)&&(y.setAttribute("selected",!0),a=!1),r.append(y)}let c=null;if(a){let m=document.createElement("option");m.value=" ",m.setAttribute("hidden",!0),m.setAttribute("selected",!0),r.prepend(m),c=()=>{m.remove(),r.removeEventListener("input",c),c=null},r.addEventListener("input",c)}let u=m=>{let y=m?"value":"textContent",{options:v,multiple:S}=r;return S?Array.prototype.filter.call(v,T=>T.selected).map(T=>T[y]):v.selectedIndex===-1?null:v[v.selectedIndex][y]},f=u(!1),g=m=>{let y=m.target.options;return Array.prototype.map.call(y,v=>({displayValue:v.textContent,exportValue:v.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",m=>{let y={value(v){c?.();let S=v.detail.value,T=new Set(Array.isArray(S)?S:[S]);for(let w of r.options)w.selected=T.has(w.value);t.setValue(e,{value:u(!0)}),f=u(!1)},multipleSelection(v){r.multiple=!0},remove(v){let S=r.options,T=v.detail.remove;S[T].selected=!1,r.remove(T),S.length>0&&Array.prototype.findIndex.call(S,I=>I.selected)===-1&&(S[0].selected=!0),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},clear(v){for(;r.length!==0;)r.remove(0);t.setValue(e,{value:null,items:[]}),f=u(!1)},insert(v){let{index:S,displayValue:T,exportValue:w}=v.detail.insert,I=r.children[S],k=document.createElement("option");k.textContent=T,k.value=w,I?I.before(k):r.append(k),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},items(v){let{items:S}=v.detail;for(;r.length!==0;)r.remove(0);for(let T of S){let{displayValue:w,exportValue:I}=T,k=document.createElement("option");k.textContent=w,k.value=I,r.append(k)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},indices(v){let S=new Set(v.detail.indices);for(let T of v.target.options)T.selected=S.has(T.index);t.setValue(e,{value:u(!0)}),f=u(!1)},editable(v){v.target.disabled=!v.detail.editable}};this._dispatchEventFromSandbox(y,m)}),r.addEventListener("input",m=>{let y=u(!0),v=u(!1);t.setValue(e,{value:y}),m.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,change:v,changeEx:y,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],m=>m.target.value)):r.addEventListener("input",function(m){t.setValue(e,{value:u(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},Cs=class extends Qt{constructor(t){let{data:e,elements:s}=t;super(t,{isRenderable:Qt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new Qo({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(let s of this.elements)s.popup=t,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${xa}${s}`).join(",")),this.container}},Qo=class{#t=this.#k.bind(this);#e=this.#w.bind(this);#n=this.#I.bind(this);#s=this.#A.bind(this);#i=null;#r=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=!1;#f=null;#o=null;#p=null;#m=null;#g=null;#y=null;#x=!1;constructor({container:t,color:e,elements:s,titleObj:r,modificationDate:a,contentsObj:c,richText:u,parent:f,rect:g,parentRect:m,open:y}){this.#r=t,this.#g=r,this.#l=c,this.#m=u,this.#c=f,this.#i=e,this.#p=g,this.#d=m,this.#u=s,this.#a=gr.toDateObject(a),this.trigger=s.flatMap(v=>v.getElementsToTriggerPopup());for(let v of this.trigger)v.addEventListener("click",this.#s),v.addEventListener("mouseenter",this.#n),v.addEventListener("mouseleave",this.#e),v.classList.add("popupTriggerArea");for(let v of s)v.container?.addEventListener("keydown",this.#t);this.#r.hidden=!0,y&&this.#A()}render(){if(this.#f)return;let t=this.#f=document.createElement("div");if(t.className="popup",this.#i){let a=t.style.outlineColor=bt.makeHexColor(...this.#i);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`:t.style.backgroundColor=bt.makeHexColor(...this.#i.map(u=>Math.floor(.7*(255-u)+u)))}let e=document.createElement("span");e.className="header";let s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=this.#g,t.append(e),this.#a){let a=document.createElement("span");a.classList.add("popupDate"),a.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),a.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#a.valueOf()})),e.append(a)}let r=this.#b;if(r)Lr.render({xfaHtml:r,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let a=this._formatContents(this.#l);t.append(a)}this.#r.append(t)}get#b(){let t=this.#m,e=this.#l;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#S(){return this.#b?.attributes?.style?.fontSize||0}get#T(){return this.#b?.attributes?.style?.color||null}#E(t){let e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},r={style:{color:this.#T,fontSize:this.#S?`calc(${this.#S}px * var(--scale-factor))`:""}};for(let a of t.split(`
|
|
5
|
-
`))e.push({name:"span",value:a,attributes:r});return s}_formatContents({str:t,dir:e}){let s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;let r=t.split(/(?:\r\n?|\n)/);for(let a=0,c=r.length;a<c;++a){let u=r[a];s.append(document.createTextNode(u)),a<c-1&&s.append(document.createElement("br"))}return s}#k(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#h)&&this.#A()}updateEdited({rect:t,popupContent:e}){this.#y||={contentsObj:this.#l,richText:this.#m},t&&(this.#o=null),e&&(this.#m=this.#E(e),this.#l=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#y&&({contentsObj:this.#l,richText:this.#m}=this.#y,this.#y=null,this.#f?.remove(),this.#f=null,this.#o=null)}#R(){if(this.#o!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:r,pageY:a}}}=this.#c,c=!!this.#d,u=c?this.#d:this.#p;for(let T of this.#u)if(!u||bt.intersect(T.data.rect,u)!==null){u=T.data.rect,c=!0;break}let f=bt.normalizeRect([u[0],t[3]-u[1]+t[1],u[2],t[3]-u[3]+t[1]]),m=c?u[2]-u[0]+5:0,y=f[0]+m,v=f[1];this.#o=[100*(y-r)/e,100*(v-a)/s];let{style:S}=this.#r;S.left=`${this.#o[0]}%`,S.top=`${this.#o[1]}%`}#A(){this.#h=!this.#h,this.#h?(this.#I(),this.#r.addEventListener("click",this.#s),this.#r.addEventListener("keydown",this.#t)):(this.#w(),this.#r.removeEventListener("click",this.#s),this.#r.removeEventListener("keydown",this.#t))}#I(){this.#f||this.render(),this.isVisible?this.#h&&this.#r.classList.add("focused"):(this.#R(),this.#r.hidden=!1,this.#r.style.zIndex=parseInt(this.#r.style.zIndex)+1e3)}#w(){this.#r.classList.remove("focused"),!(this.#h||!this.isVisible)&&(this.#r.hidden=!0,this.#r.style.zIndex=parseInt(this.#r.style.zIndex)-1e3)}forceHide(){this.#x=this.isVisible,this.#x&&(this.#r.hidden=!0)}maybeShow(){this.#x&&(this.#f||this.#I(),this.#x=!1,this.#r.hidden=!1)}get isVisible(){return this.#r.hidden===!1}},Fr=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Rt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},Jo=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:s}=fn(t.rect),r=this.svgFactory.create(e,s,!0),a=this.#t=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},qo=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:s}=fn(t.rect),r=this.svgFactory.create(e,s,!0),a=t.borderStyle.width,c=this.#t=this.svgFactory.createElement("svg:rect");return c.setAttribute("x",a/2),c.setAttribute("y",a/2),c.setAttribute("width",e-a),c.setAttribute("height",s-a),c.setAttribute("stroke-width",a||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),r.append(c),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ta=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:s}=fn(t.rect),r=this.svgFactory.create(e,s,!0),a=t.borderStyle.width,c=this.#t=this.svgFactory.createElement("svg:ellipse");return c.setAttribute("cx",e/2),c.setAttribute("cy",s/2),c.setAttribute("rx",e/2-a/2),c.setAttribute("ry",s/2-a/2),c.setAttribute("stroke-width",a||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),r.append(c),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},_r=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:s,popupRef:r}}=this;if(!e)return this.container;let{width:a,height:c}=fn(t),u=this.svgFactory.create(a,c,!0),f=[];for(let m=0,y=e.length;m<y;m+=2){let v=e[m]-t[0],S=t[3]-e[m+1];f.push(`${v},${S}`)}f=f.join(" ");let g=this.#t=this.svgFactory.createElement(this.svgElementName);return g.setAttribute("points",f),g.setAttribute("stroke-width",s.width||1),g.setAttribute("stroke","transparent"),g.setAttribute("fill","transparent"),u.append(g),this.container.append(u),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ea=class extends _r{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},na=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},Es=class extends Qt{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Rt.HIGHLIGHT:Rt.INK}#n(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:s,borderStyle:r,popupRef:a}}=this,{transform:c,width:u,height:f}=this.#n(e,t),g=this.svgFactory.create(u,f,!0),m=this.#t=this.svgFactory.createElement("svg:g");g.append(m),m.setAttribute("stroke-width",r.width||1),m.setAttribute("stroke-linecap","round"),m.setAttribute("stroke-linejoin","round"),m.setAttribute("stroke-miterlimit",10),m.setAttribute("stroke","transparent"),m.setAttribute("fill","transparent"),m.setAttribute("transform",c);for(let y=0,v=s.length;y<v;y++){let S=this.svgFactory.createElement(this.svgElementName);this.#e.push(S),S.setAttribute("points",s[y].join(",")),m.append(S)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(g),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:s,rect:r}=t,a=this.#t;if(e>=0&&a.setAttribute("stroke-width",e||1),s)for(let c=0,u=this.#e.length;c<u;c++)this.#e[c].setAttribute("points",s[c].join(","));if(r){let{transform:c,width:u,height:f}=this.#n(this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${u} ${f}`),a.setAttribute("transform",c)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},Nr=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Rt.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}},sa=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}},ra=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}},ia=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}},Ur=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Rt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},oa=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0});let{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;let{isMac:r}=ne.platform;return t.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},aa=class{#t=null;#e=null;#n=new Map;#s=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:r,page:a,viewport:c,structTreeLayer:u}){this.div=t,this.#t=e,this.#e=s,this.#s=u||null,this.page=a,this.viewport=c,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#n.size>0}async#i(t,e){let s=t.firstChild||t,r=s.id=`${xa}${e}`,a=await this.#s?.getAriaAttributes(r);if(a)for(let[c,u]of a)s.setAttribute(c,u);this.div.append(t),this.#t?.moveElementInDOM(this.div,t,s,!1)}async render(t){let{annotations:e}=t,s=this.div;kn(s,this.viewport);let r=new Map,a={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ts,annotationStorage:t.annotationStorage||new vs,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let c of e){if(c.noHTML)continue;let u=c.annotationType===ee.POPUP;if(u){let m=r.get(c.id);if(!m)continue;a.elements=m}else{let{width:m,height:y}=fn(c.rect);if(m<=0||y<=0)continue}a.data=c;let f=$o.create(a);if(!f.isRenderable)continue;if(!u&&c.popupRef){let m=r.get(c.popupRef);m?m.push(f):r.set(c.popupRef,[f])}let g=f.render();c.hidden&&(g.style.visibility="hidden"),await this.#i(g,c.id),f._isEditable&&(this.#n.set(f.data.id,f),this._annotationEditorUIManager?.renderAnnotationElement(f))}this.#r()}update({viewport:t}){let e=this.div;this.viewport=t,kn(e,{rotation:t.rotation}),this.#r(),e.hidden=!1}#r(){if(!this.#e)return;let t=this.div;for(let[e,s]of this.#e){let r=t.querySelector(`[data-annotation-id="${e}"]`);if(!r)continue;s.className="annotationContent";let{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(s):a.classList.contains("annotationContent")?a.after(s):a.before(s):r.append(s)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(t){return this.#n.get(t)}},ur=/\r\n?|\n/g,la=class o extends Xt{#t;#e="";#n=`${this.id}-editor`;#s=null;#i;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=o.prototype,e=a=>a.isEmpty(),s=Rn.TRANSLATE_SMALL,r=Rn.TRANSLATE_BIG;return Pt(this,"_keyboardManager",new In([[["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:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}]]))}static _type="freetext";static _editorType=Rt.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||o._defaultColor||Xt._defaultLineColor,this.#i=t.fontSize||o._defaultFontSize}static initialize(t,e){Xt.initialize(t,e);let s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Lt.FREETEXT_SIZE:o._defaultFontSize=e;break;case Lt.FREETEXT_COLOR:o._defaultColor=e;break}}updateParams(t,e){switch(t){case Lt.FREETEXT_SIZE:this.#r(e);break;case Lt.FREETEXT_COLOR:this.#l(e);break}}static get defaultPropertiesToUpdate(){return[[Lt.FREETEXT_SIZE,o._defaultFontSize],[Lt.FREETEXT_COLOR,o._defaultColor||Xt._defaultLineColor]]}get propertiesToUpdate(){return[[Lt.FREETEXT_SIZE,this.#i],[Lt.FREETEXT_COLOR,this.#t]]}#r(t){let e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-this.#i)*this.parentScale),this.#i=r,this.#u()},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Lt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){let e=r=>{this.#t=this.editorDiv.style.color=r},s=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Lt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-o._internalPadding*t,-(o._internalPadding+this.#i)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Rt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;let t=this._uiManager.combinedSignal(this.#s);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#n),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#a(){let t=[];this.editorDiv.normalize();let e=null;for(let s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(o.#c(s)),e=s);return t.join(`
|
|
6
|
-
`)}#u(){let[t,e]=this.parentDimensions,
|
|
1
|
+
var Mb=Object.create;var so=Object.defineProperty;var Lb=Object.getOwnPropertyDescriptor;var Fb=Object.getOwnPropertyNames;var Db=Object.getPrototypeOf,_b=Object.prototype.hasOwnProperty;var Nb=(o,t)=>()=>(o&&(t=o(o=0)),t);var Ub=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),Bb=(o,t)=>{for(var e in t)so(o,e,{get:t[e],enumerable:!0})},Gb=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fb(t))!_b.call(o,r)&&r!==e&&so(o,r,{get:()=>t[r],enumerable:!(n=Lb(t,r))||n.enumerable});return o};var Kc=(o,t,e)=>(e=o!=null?Mb(Db(o)):{},Gb(t||!o||!o.__esModule?so(e,"default",{value:o,enumerable:!0}):e,o));var Cu={};Bb(Cu,{AbortException:()=>$y,AnnotationEditorLayer:()=>zy,AnnotationEditorParamsType:()=>Wy,AnnotationEditorType:()=>Xy,AnnotationEditorUIManager:()=>Yy,AnnotationLayer:()=>Ky,AnnotationMode:()=>Ba,ColorPicker:()=>Zy,DOMSVGFactory:()=>Qy,DrawLayer:()=>Jy,FeatureTest:()=>qy,GlobalWorkerOptions:()=>t0,ImageKind:()=>e0,InvalidPDFException:()=>n0,MissingPDFException:()=>s0,OPS:()=>r0,OutputScale:()=>i0,PDFDataRangeTransport:()=>o0,PDFDateString:()=>a0,PDFWorker:()=>l0,PasswordResponses:()=>c0,PermissionFlag:()=>u0,PixelsPerInch:()=>h0,RenderingCancelledException:()=>d0,TextLayer:()=>f0,TouchManager:()=>p0,UnexpectedResponseException:()=>g0,Util:()=>m0,VerbosityLevel:()=>b0,XfaLayer:()=>y0,build:()=>v0,createValidAbsoluteUrl:()=>x0,fetchData:()=>S0,getDocument:()=>A0,getFilenameFromUrl:()=>T0,getPdfFilenameFromUrl:()=>C0,getXfaPageViewport:()=>w0,isDataScheme:()=>E0,isPdfFile:()=>k0,noContextMenu:()=>I0,normalizeUnicode:()=>P0,setLayerDimensions:()=>R0,shadow:()=>O0,stopEvent:()=>M0,version:()=>L0});function Lt(o){var t=tu[o];if(t!==void 0)return t.exports;var e=tu[o]={exports:{}};return Kb[o].call(e.exports,e,e.exports,Lt),e.exports}function ey(o){Number.isInteger(o)&&(Qr=o)}function ny(){return Qr}function Jr(o){Qr>=Zr.INFOS&&console.log(`Info: ${o}`)}function Et(o){Qr>=Zr.WARNINGS&&console.log(`Warning: ${o}`)}function $t(o){throw new Error(o)}function te(o,t){o||$t(t)}function sy(o){switch(o?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function ry(o,t=null,e=null){if(!o)return null;try{if(e&&typeof o=="string"&&(e.addDefaultProtocol&&o.startsWith("www.")&&o.match(/\./g)?.length>=2&&(o=`http://${o}`),e.tryConvertEncoding))try{o=ly(o)}catch{}let n=t?new URL(o,t):new URL(o);if(sy(n))return n}catch{}return null}function Ot(o,t,e,n=!1){return Object.defineProperty(o,t,{value:e,enumerable:!n,configurable:!0,writable:!1}),e}function mu(o){(typeof o!="object"||o?.length===void 0)&&$t("Invalid argument for bytesToString");let t=o.length,e=8192;if(t<e)return String.fromCharCode.apply(null,o);let n=[];for(let r=0;r<t;r+=e){let a=Math.min(r+e,t),c=o.subarray(r,a);n.push(String.fromCharCode.apply(null,c))}return n.join("")}function qr(o){typeof o!="string"&&$t("Invalid argument for stringToBytes");let t=o.length,e=new Uint8Array(t);for(let n=0;n<t;++n)e[n]=o.charCodeAt(n)&255;return e}function iy(o){return String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255)}function Da(o){let t=Object.create(null);for(let[e,n]of o)t[e]=n;return t}function oy(){let o=new Uint8Array(4);return o[0]=1,new Uint32Array(o.buffer,0,1)[0]===1}function ay(){try{return new Function(""),!0}catch{return!1}}function ly(o){return decodeURIComponent(escape(o))}function cy(o){return lo||(lo=/([\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,eu=new Map([["\uFB05","\u017Ft"]])),o.replaceAll(lo,(t,e,n)=>e?e.normalize("NFKC"):eu.get(n))}function uy(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let o=new Uint8Array(32);return crypto.getRandomValues(o),mu(o)}function hy(o){return Uint8Array.prototype.toBase64?o.toBase64():btoa(mu(o))}async function ti(o,t="text"){if(ys(o,document.baseURI)){let e=await fetch(o);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,n)=>{let r=new XMLHttpRequest;r.open("GET",o,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(r.status===200||r.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(r.response);return}e(r.responseText);return}n(new Error(r.statusText))}},r.send(null)})}function ei(o){let t=o.length,e=0;for(;e<t&&o[e].trim()==="";)e++;return o.substring(e,e+5).toLowerCase()==="data:"}function Na(o){return typeof o=="string"&&/\.pdf$/i.test(o)}function dy(o){return[o]=o.split(/[#?]/,1),o.substring(o.lastIndexOf("/")+1)}function fy(o,t="document.pdf"){if(typeof o!="string")return t;if(ei(o))return Et('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,r=e.exec(o),a=n.exec(r[1])||n.exec(r[2])||n.exec(r[3]);if(a&&(a=a[0],a.includes("%")))try{a=n.exec(decodeURIComponent(a))[0]}catch{}return a||t}function ys(o,t){try{let{protocol:e}=t?new URL(o,t):new URL(o);return e==="http:"||e==="https:"}catch{return!1}}function He(o){o.preventDefault()}function Ee(o){o.preventDefault(),o.stopPropagation()}function py(o,{scale:t=1,rotation:e=0}){let{width:n,height:r}=o.attributes.style,a=[0,0,parseInt(n),parseInt(r)];return new Ss({viewBox:a,userUnit:1,scale:t,rotation:e})}function Ua(o){if(o.startsWith("#")){let t=parseInt(o.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return o.startsWith("rgb(")?o.slice(4,-1).split(",").map(t=>parseInt(t)):o.startsWith("rgba(")?o.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Et(`Not a valid color format: "${o}"`),[0,0,0])}function gy(o){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let e of o.keys()){t.style.color=e;let n=window.getComputedStyle(t).color;o.set(e,Ua(n))}t.remove()}function Wt(o){let{a:t,b:e,c:n,d:r,e:a,f:c}=o.getTransform();return[t,e,n,r,a,c]}function Ye(o){let{a:t,b:e,c:n,d:r,e:a,f:c}=o.getTransform().invertSelf();return[t,e,n,r,a,c]}function Mn(o,t,e=!1,n=!0){if(t instanceof Ss){let{pageWidth:r,pageHeight:a}=t.rawDims,{style:c}=o,u=ne.isCSSRoundSupported,f=`var(--scale-factor) * ${r}px`,g=`var(--scale-factor) * ${a}px`,m=u?`round(down, ${f}, var(--scale-round-x, 1px))`:`calc(${f})`,b=u?`round(down, ${g}, var(--scale-round-y, 1px))`:`calc(${g})`;!e||t.rotation%180===0?(c.width=m,c.height=b):(c.width=b,c.height=m)}n&&o.setAttribute("data-main-rotation",t.rotation)}function Ar(o,t,e){for(let n of e)t.addEventListener(n,o[n].bind(o))}function su(){}function ve(o){if(o instanceof Ze||o instanceof xs||o instanceof On||o instanceof vr||o instanceof qn||o instanceof vs)return o;switch(o instanceof Error||typeof o=="object"&&o!==null||$t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),o.name){case"AbortException":return new Ze(o.message);case"InvalidPDFException":return new xs(o.message);case"MissingPDFException":return new On(o.message);case"PasswordException":return new vr(o.message,o.code);case"UnexpectedResponseException":return new qn(o.message,o.status);case"UnknownErrorException":return new vs(o.message,o.details)}return new vs(o.message,o.toString())}async function bu(o){let e=await process.getBuiltinModule("fs").promises.readFile(o);return new Uint8Array(e)}function Oo(o,t){if(!t)return;let e=t[2]-t[0],n=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],e,n),o.clip(r)}function co(o,t,e,n,r,a,c,u){let f=t.coords,g=t.colors,m=o.data,b=o.width*4,v;f[e+1]>f[n+1]&&(v=e,e=n,n=v,v=a,a=c,c=v),f[n+1]>f[r+1]&&(v=n,n=r,r=v,v=c,c=u,u=v),f[e+1]>f[n+1]&&(v=e,e=n,n=v,v=a,a=c,c=v);let S=(f[e]+t.offsetX)*t.scaleX,T=(f[e+1]+t.offsetY)*t.scaleY,w=(f[n]+t.offsetX)*t.scaleX,I=(f[n+1]+t.offsetY)*t.scaleY,k=(f[r]+t.offsetX)*t.scaleX,O=(f[r+1]+t.offsetY)*t.scaleY;if(T>=O)return;let F=g[a],_=g[a+1],D=g[a+2],G=g[c],j=g[c+1],W=g[c+2],$=g[u],Z=g[u+1],q=g[u+2],yt=Math.round(T),et=Math.round(O),Tt,dt,Y,K,bt,lt,kt,X;for(let ot=yt;ot<=et;ot++){if(ot<I){let H=ot<T?0:(T-ot)/(T-I);Tt=S-(S-w)*H,dt=F-(F-G)*H,Y=_-(_-j)*H,K=D-(D-W)*H}else{let H;ot>O?H=1:I===O?H=0:H=(I-ot)/(I-O),Tt=w-(w-k)*H,dt=G-(G-$)*H,Y=j-(j-Z)*H,K=W-(W-q)*H}let Q;ot<T?Q=0:ot>O?Q=1:Q=(T-ot)/(T-O),bt=S-(S-k)*Q,lt=F-(F-$)*Q,kt=_-(_-Z)*Q,X=D-(D-q)*Q;let nt=Math.round(Math.min(Tt,bt)),it=Math.round(Math.max(Tt,bt)),V=b*ot+nt*4;for(let H=nt;H<=it;H++)Q=(Tt-H)/(Tt-bt),Q<0?Q=0:Q>1&&(Q=1),m[V++]=dt-(dt-lt)*Q|0,m[V++]=Y-(Y-kt)*Q|0,m[V++]=K-(K-X)*Q|0,m[V++]=255}}function my(o,t,e){let n=t.coords,r=t.colors,a,c;switch(t.type){case"lattice":let u=t.verticesPerRow,f=Math.floor(n.length/u)-1,g=u-1;for(a=0;a<f;a++){let m=a*u;for(let b=0;b<g;b++,m++)co(o,e,n[m],n[m+1],n[m+u],r[m],r[m+1],r[m+u]),co(o,e,n[m+u+1],n[m+1],n[m+u],r[m+u+1],r[m+1],r[m+u])}break;case"triangles":for(a=0,c=n.length;a<c;a+=3)co(o,e,n[a],n[a+1],n[a+2],r[a],r[a+1],r[a+2]);break;default:throw new Error("illegal figure")}}function by(o){switch(o[0]){case"RadialAxial":return new Mo(o);case"Mesh":return new Lo(o);case"Dummy":return new Fo}throw new Error(`Unknown IR type: ${o[0]}`)}function yy({src:o,srcPos:t=0,dest:e,width:n,height:r,nonBlackColor:a=4294967295,inverseDecode:c=!1}){let u=ne.isLittleEndian?4278190080:255,[f,g]=c?[a,u]:[u,a],m=n>>3,b=n&7,v=o.length;e=new Uint32Array(e.buffer);let S=0;for(let T=0;T<r;T++){for(let I=t+m;t<I;t++){let k=t<v?o[t]:255;e[S++]=k&128?g:f,e[S++]=k&64?g:f,e[S++]=k&32?g:f,e[S++]=k&16?g:f,e[S++]=k&8?g:f,e[S++]=k&4?g:f,e[S++]=k&2?g:f,e[S++]=k&1?g:f}if(b===0)continue;let w=t<v?o[t++]:255;for(let I=0;I<b;I++)e[S++]=w&1<<7-I?g:f}return{srcPos:t,destPos:S}}function xy(o,t){if(o._removeMirroring)throw new Error("Context is already forwarding operations.");o.__originalSave=o.save,o.__originalRestore=o.restore,o.__originalRotate=o.rotate,o.__originalScale=o.scale,o.__originalTranslate=o.translate,o.__originalTransform=o.transform,o.__originalSetTransform=o.setTransform,o.__originalResetTransform=o.resetTransform,o.__originalClip=o.clip,o.__originalMoveTo=o.moveTo,o.__originalLineTo=o.lineTo,o.__originalBezierCurveTo=o.bezierCurveTo,o.__originalRect=o.rect,o.__originalClosePath=o.closePath,o.__originalBeginPath=o.beginPath,o._removeMirroring=()=>{o.save=o.__originalSave,o.restore=o.__originalRestore,o.rotate=o.__originalRotate,o.scale=o.__originalScale,o.translate=o.__originalTranslate,o.transform=o.__originalTransform,o.setTransform=o.__originalSetTransform,o.resetTransform=o.__originalResetTransform,o.clip=o.__originalClip,o.moveTo=o.__originalMoveTo,o.lineTo=o.__originalLineTo,o.bezierCurveTo=o.__originalBezierCurveTo,o.rect=o.__originalRect,o.closePath=o.__originalClosePath,o.beginPath=o.__originalBeginPath,delete o._removeMirroring},o.save=function(){t.save(),this.__originalSave()},o.restore=function(){t.restore(),this.__originalRestore()},o.translate=function(n,r){t.translate(n,r),this.__originalTranslate(n,r)},o.scale=function(n,r){t.scale(n,r),this.__originalScale(n,r)},o.transform=function(n,r,a,c,u,f){t.transform(n,r,a,c,u,f),this.__originalTransform(n,r,a,c,u,f)},o.setTransform=function(n,r,a,c,u,f){t.setTransform(n,r,a,c,u,f),this.__originalSetTransform(n,r,a,c,u,f)},o.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},o.rotate=function(n){t.rotate(n),this.__originalRotate(n)},o.clip=function(n){t.clip(n),this.__originalClip(n)},o.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},o.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},o.bezierCurveTo=function(e,n,r,a,c,u){t.bezierCurveTo(e,n,r,a,c,u),this.__originalBezierCurveTo(e,n,r,a,c,u)},o.rect=function(e,n,r,a){t.rect(e,n,r,a),this.__originalRect(e,n,r,a)},o.closePath=function(){t.closePath(),this.__originalClosePath()},o.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}function pr(o,t,e,n,r,a,c,u,f,g){let[m,b,v,S,T,w]=Wt(o);if(b===0&&v===0){let O=c*m+T,F=Math.round(O),_=u*S+w,D=Math.round(_),G=(c+f)*m+T,j=Math.abs(Math.round(G)-F)||1,W=(u+g)*S+w,$=Math.abs(Math.round(W)-D)||1;return o.setTransform(Math.sign(m),0,0,Math.sign(S),F,D),o.drawImage(t,e,n,r,a,0,0,j,$),o.setTransform(m,b,v,S,T,w),[j,$]}if(m===0&&S===0){let O=u*v+T,F=Math.round(O),_=c*b+w,D=Math.round(_),G=(u+g)*v+T,j=Math.abs(Math.round(G)-F)||1,W=(c+f)*b+w,$=Math.abs(Math.round(W)-D)||1;return o.setTransform(0,Math.sign(b),Math.sign(v),0,F,D),o.drawImage(t,e,n,r,a,0,0,$,j),o.setTransform(m,b,v,S,T,w),[$,j]}o.drawImage(t,e,n,r,a,c,u,f,g);let I=Math.hypot(m,b),k=Math.hypot(v,S);return[I*f,k*g]}function Sy(o){let{width:t,height:e}=o;if(t>lu||e>lu)return null;let n=1e3,r=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1,c=new Uint8Array(a*(e+1)),u,f,g,m=t+7&-8,b=new Uint8Array(m*e),v=0;for(let k of o.data){let O=128;for(;O>0;)b[v++]=k&O?0:255,O>>=1}let S=0;for(v=0,b[v]!==0&&(c[0]=1,++S),f=1;f<t;f++)b[v]!==b[v+1]&&(c[f]=b[v]?2:1,++S),v++;for(b[v]!==0&&(c[f]=2,++S),u=1;u<e;u++){v=u*m,g=u*a,b[v-m]!==b[v]&&(c[g]=b[v]?1:8,++S);let k=(b[v]?4:0)+(b[v-m]?8:0);for(f=1;f<t;f++)k=(k>>2)+(b[v+1]?4:0)+(b[v-m+1]?8:0),r[k]&&(c[g+f]=r[k],++S),v++;if(b[v-m]!==b[v]&&(c[g+f]=b[v]?2:4,++S),S>n)return null}for(v=m*(e-1),g=u*a,b[v]!==0&&(c[g]=8,++S),f=1;f<t;f++)b[v]!==b[v+1]&&(c[g+f]=b[v]?4:8,++S),v++;if(b[v]!==0&&(c[g+f]=4,++S),S>n)return null;let T=new Int32Array([0,a,-1,0,-a,0,0,0,1]),w=new Path2D;for(u=0;S&&u<=e;u++){let k=u*a,O=k+t;for(;k<O&&!c[k];)k++;if(k===O)continue;w.moveTo(k%a,u);let F=k,_=c[k];do{let D=T[_];do k+=D;while(!c[k]);let G=c[k];G!==5&&G!==10?(_=G,c[k]=0):(_=G&51*_>>4,c[k]&=_>>2|_<<2),w.lineTo(k%a,k/a|0),c[k]||--S}while(F!==k);--u}return b=null,c=null,function(k){k.save(),k.scale(1/t,-1/e),k.translate(0,-e),k.fill(w),k.beginPath(),k.restore()}}function cu(o,t){if(t instanceof ImageData){o.putImageData(t,0,0);return}let e=t.height,n=t.width,r=e%xe,a=(e-r)/xe,c=r===0?a:a+1,u=o.createImageData(n,xe),f=0,g,m=t.data,b=u.data,v,S,T,w;if(t.kind===yr.GRAYSCALE_1BPP){let I=m.byteLength,k=new Uint32Array(b.buffer,0,b.byteLength>>2),O=k.length,F=n+7>>3,_=4294967295,D=ne.isLittleEndian?4278190080:255;for(v=0;v<c;v++){for(T=v<a?xe:r,g=0,S=0;S<T;S++){let G=I-f,j=0,W=G>F?n:G*8-7,$=W&-8,Z=0,q=0;for(;j<$;j+=8)q=m[f++],k[g++]=q&128?_:D,k[g++]=q&64?_:D,k[g++]=q&32?_:D,k[g++]=q&16?_:D,k[g++]=q&8?_:D,k[g++]=q&4?_:D,k[g++]=q&2?_:D,k[g++]=q&1?_:D;for(;j<W;j++)Z===0&&(q=m[f++],Z=128),k[g++]=q&Z?_:D,Z>>=1}for(;g<O;)k[g++]=0;o.putImageData(u,0,v*xe)}}else if(t.kind===yr.RGBA_32BPP){for(S=0,w=n*xe*4,v=0;v<a;v++)b.set(m.subarray(f,f+w)),f+=w,o.putImageData(u,0,S),S+=xe;v<c&&(w=n*r*4,b.set(m.subarray(f,f+w)),o.putImageData(u,0,S))}else if(t.kind===yr.RGB_24BPP)for(T=xe,w=n*T,v=0;v<c;v++){for(v>=a&&(T=r,w=n*T),g=0,S=w;S--;)b[g++]=m[f++],b[g++]=m[f++],b[g++]=m[f++],b[g++]=255;o.putImageData(u,0,v*xe)}else throw new Error(`bad image kind: ${t.kind}`)}function uu(o,t){if(t.bitmap){o.drawImage(t.bitmap,0,0);return}let e=t.height,n=t.width,r=e%xe,a=(e-r)/xe,c=r===0?a:a+1,u=o.createImageData(n,xe),f=0,g=t.data,m=u.data;for(let b=0;b<c;b++){let v=b<a?xe:r;({srcPos:f}=yy({src:g,srcPos:f,dest:m,width:n,height:v,nonBlackColor:0})),o.putImageData(u,0,b*xe)}}function gs(o,t){let e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let n of e)o[n]!==void 0&&(t[n]=o[n]);o.setLineDash!==void 0&&(t.setLineDash(o.getLineDash()),t.lineDashOffset=o.lineDashOffset)}function gr(o){if(o.strokeStyle=o.fillStyle="#000000",o.fillRule="nonzero",o.globalAlpha=1,o.lineWidth=1,o.lineCap="butt",o.lineJoin="miter",o.miterLimit=10,o.globalCompositeOperation="source-over",o.font="10px sans-serif",o.setLineDash!==void 0&&(o.setLineDash([]),o.lineDashOffset=0),!ue){let{filter:t}=o;t!=="none"&&t!==""&&(o.filter="none")}}function hu(o,t){if(t)return!0;let e=St.singularValueDecompose2dScale(o);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);let n=Math.fround((globalThis.devicePixelRatio||1)*bn.PDF_TO_CSS_UNITS);return e[0]<=n&&e[1]<=n}function wy(o){let t=!0,e=n("filename\\*","i").exec(o);if(e){e=e[1];let m=u(e);return m=unescape(m),m=f(m),m=g(m),a(m)}if(e=c(o),e){let m=g(e);return a(m)}if(e=n("filename","i").exec(o),e){e=e[1];let m=u(e);return m=g(m),a(m)}function n(m,b){return new RegExp("(?:^|;)\\s*"+m+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',b)}function r(m,b){if(m){if(!/^[\x00-\xFF]+$/.test(b))return b;try{let v=new TextDecoder(m,{fatal:!0}),S=qr(b);b=v.decode(S),t=!1}catch{}}return b}function a(m){return t&&/[\x80-\xff]/.test(m)&&(m=r("utf-8",m),t&&(m=r("iso-8859-1",m))),m}function c(m){let b=[],v,S=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(v=S.exec(m))!==null;){let[,w,I,k]=v;if(w=parseInt(w,10),w in b){if(w===0)break;continue}b[w]=[I,k]}let T=[];for(let w=0;w<b.length&&w in b;++w){let[I,k]=b[w];k=u(k),I&&(k=unescape(k),w===0&&(k=f(k))),T.push(k)}return T.join("")}function u(m){if(m.startsWith('"')){let b=m.slice(1).split('\\"');for(let v=0;v<b.length;++v){let S=b[v].indexOf('"');S!==-1&&(b[v]=b[v].slice(0,S),b.length=v+1),b[v]=b[v].replaceAll(/\\(.)/g,"$1")}m=b.join('"')}return m}function f(m){let b=m.indexOf("'");if(b===-1)return m;let v=m.slice(0,b),T=m.slice(b+1).replace(/^[^']*'/,"");return r(v,T)}function g(m){return!m.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(m)?m:m.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(b,v,S,T){if(S==="q"||S==="Q")return T=T.replaceAll("_"," "),T=T.replaceAll(/=([0-9a-fA-F]{2})/g,function(w,I){return String.fromCharCode(parseInt(I,16))}),r(v,T);try{T=atob(T)}catch{}return r(v,T)})}return""}function yu(o,t){let e=new Headers;if(!o||!t||typeof t!="object")return e;for(let n in t){let r=t[n];r!==void 0&&e.append(n,r)}return e}function ni(o){try{return new URL(o).origin}catch{}return null}function vu({responseHeaders:o,isHttp:t,rangeChunkSize:e,disableRange:n}){let r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(o.get("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*e)||n||!t||o.get("Accept-Ranges")!=="bytes"||(o.get("Content-Encoding")||"identity")!=="identity"||(r.allowRangeRequests=!0),r}function xu(o){let t=o.get("Content-Disposition");if(t){let e=wy(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Na(e))return e}return null}function si(o,t){return o===404||o===0&&t.startsWith("file:")?new On('Missing PDF "'+t+'".'):new qn(`Unexpected server response (${o}) while retrieving PDF "${t}".`,o)}function Su(o){return o===200||o===206}function Au(o,t,e){return{method:"GET",headers:o,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Tu(o){return o instanceof Uint8Array?o.buffer:o instanceof ArrayBuffer?o:(Et(`getArrayBuffer - unexpected data format: ${o}`),new Uint8Array(o).buffer)}function Ey(o){let t=o.response;return typeof t!="string"?t:qr(t).buffer}function Iy(o){if(ky.test(o))return new URL(o);let t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(o))}function Uy(o={}){typeof o=="string"||o instanceof URL?o={url:o}:(o instanceof ArrayBuffer||ArrayBuffer.isView(o))&&(o={data:o});let t=new Jo,{docId:e}=t,n=o.url?By(o.url):null,r=o.data?Gy(o.data):null,a=o.httpHeaders||null,c=o.withCredentials===!0,u=o.password??null,f=o.range instanceof Dr?o.range:null,g=Number.isInteger(o.rangeChunkSize)&&o.rangeChunkSize>0?o.rangeChunkSize:Oy,m=o.worker instanceof Jn?o.worker:null,b=o.verbosity,v=typeof o.docBaseUrl=="string"&&!ei(o.docBaseUrl)?o.docBaseUrl:null,S=typeof o.cMapUrl=="string"?o.cMapUrl:null,T=o.cMapPacked!==!1,w=o.CMapReaderFactory||Dy,I=typeof o.standardFontDataUrl=="string"?o.standardFontDataUrl:null,k=o.StandardFontDataFactory||Ny,O=o.stopAtErrors!==!0,F=Number.isInteger(o.maxImageSize)&&o.maxImageSize>-1?o.maxImageSize:-1,_=o.isEvalSupported!==!1,D=typeof o.isOffscreenCanvasSupported=="boolean"?o.isOffscreenCanvasSupported:!ue,G=typeof o.isImageDecoderSupported=="boolean"?o.isImageDecoderSupported:!ue&&(ne.platform.isFirefox||!globalThis.chrome),j=Number.isInteger(o.canvasMaxAreaInBytes)?o.canvasMaxAreaInBytes:-1,W=typeof o.disableFontFace=="boolean"?o.disableFontFace:ue,$=o.fontExtraProperties===!0,Z=o.enableXfa===!0,q=o.ownerDocument||globalThis.document,yt=o.disableRange===!0,et=o.disableStream===!0,Tt=o.disableAutoFetch===!0,dt=o.pdfBug===!0,Y=o.CanvasFactory||Fy,K=o.FilterFactory||_y,bt=o.enableHWA===!0,lt=f?f.length:o.length??NaN,kt=typeof o.useSystemFonts=="boolean"?o.useSystemFonts:!ue&&!W,X=typeof o.useWorkerFetch=="boolean"?o.useWorkerFetch:w===Pr&&k===Mr&&S&&I&&ys(S,document.baseURI)&&ys(I,document.baseURI),ot=null;ey(b);let Q={canvasFactory:new Y({ownerDocument:q,enableHWA:bt}),filterFactory:new K({docId:e,ownerDocument:q}),cMapReaderFactory:X?null:new w({baseUrl:S,isCompressed:T}),standardFontDataFactory:X?null:new k({baseUrl:I})};if(!m){let V={verbosity:b,port:Rn.workerPort};m=V.port?Jn.fromPort(V):new Jn(V),t._worker=m}let nt={docId:e,apiVersion:"4.10.45",data:r,password:u,disableAutoFetch:Tt,rangeChunkSize:g,length:lt,docBaseUrl:v,enableXfa:Z,evaluatorOptions:{maxImageSize:F,disableFontFace:W,ignoreErrors:O,isEvalSupported:_,isOffscreenCanvasSupported:D,isImageDecoderSupported:G,canvasMaxAreaInBytes:j,fontExtraProperties:$,useSystemFonts:kt,cMapUrl:X?S:null,standardFontDataUrl:X?I:null}},it={disableFontFace:W,fontExtraProperties:$,ownerDocument:q,pdfBug:dt,styleElement:ot,loadingParams:{disableAutoFetch:Tt,enableXfa:Z}};return m.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let V=m.messageHandler.sendWithPromise("GetDocRequest",nt,r?[r.buffer]:null),H;if(f)H=new Go(f,{disableRange:yt,disableStream:et});else if(!r){if(!n)throw new Error("getDocument - no `url` parameter provided.");let U;if(ue)if(ys(n)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");U=Fr}else U=Ko;else U=ys(n)?Fr:Wo;H=new U({url:n,length:lt,httpHeaders:a,withCredentials:c,rangeChunkSize:g,disableRange:yt,disableStream:et})}return V.then(U=>{if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let at=new Pn(e,U,m.port),Ct=new na(at,t,H,it,Q);t._transport=Ct,at.send("Ready",null)})}).catch(t._capability.reject),t}function By(o){if(o instanceof URL)return o.href;try{return new URL(o,window.location).href}catch{if(ue&&typeof o=="string")return o}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Gy(o){if(ue&&typeof Buffer<"u"&&o instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength)return o;if(typeof o=="string")return qr(o);if(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="object"&&!isNaN(o?.length))return new Uint8Array(o);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function fu(o){return typeof o=="object"&&Number.isInteger(o?.num)&&o.num>=0&&Number.isInteger(o?.gen)&&o.gen>=0}function pu(o){return Math.floor(Math.max(0,Math.min(1,o))*255).toString(16).padStart(2,"0")}function bs(o){return Math.max(0,Math.min(255,255*o))}function mn(o){return{width:o[2]-o[0],height:o[3]-o[1]}}var Kb,tu,wt,k1,I1,P1,R1,O1,M1,L1,F1,D1,_1,N1,U1,ue,gu,fo,Zb,br,Qb,B1,we,gn,Jb,Rt,Mt,qb,le,yr,ee,ps,Zr,Ge,ty,Qr,yn,vr,vs,xs,On,qn,po,Ze,ne,ao,St,lo,eu,_a,G1,H1,j1,V1,$1,z1,W1,X1,Y1,K1,Z1,Q1,J1,q1,nn,bn,Ss,As,xr,Sr,Ts,go,mo,bo,yo,vo,Ln,xo,Fn,Tr,Cr,Xt,So,nu,Oe,Ke,wr,Ao,Cs,Er,To,Co,fr,qt,Pn,kr,wo,Ir,Pr,tS,Rr,Eo,Or,Mr,ko,Io,Po,Ro,ce,ws,Mo,Lo,Fo,ru,Do,iu,ou,vy,au,lu,xe,_o,Lr,Ay,Ty,Cy,du,Qn,Rn,No,Zn,Uo,Bo,Go,Ho,jo,Fr,Vo,$o,uo,ho,zo,Wo,Xo,Yo,ky,Ko,Zo,Qo,Py,ye,Ry,Es,ks,Oy,My,Ly,Fy,Dy,_y,Ny,Jo,Dr,qo,ta,ea,Jn,na,ms,_r,sa,ra,Hy,jy,eS,Nr,ia,Is,Ur,Ls,Vy,Dn,oa,Qt,Br,aa,sn,la,ca,ua,Gr,ha,da,Ps,fa,Hr,pa,ga,ma,jr,ba,ya,Rs,Vr,va,xa,Sa,$r,Aa,Ta,mr,Ca,ht,zr,Wr,Os,wa,Ms,Ea,Xr,Yr,ka,Ia,Pa,Kr,Ra,Oa,Ma,La,Fa,$y,zy,Wy,Xy,Yy,Ky,Ba,Zy,Qy,Jy,qy,t0,e0,n0,s0,r0,i0,o0,a0,l0,c0,u0,h0,d0,f0,p0,g0,m0,b0,y0,v0,x0,S0,A0,T0,C0,w0,E0,k0,I0,P0,R0,O0,M0,L0,Ga=Nb(()=>{Kb={9306:((o,t,e)=>{var n=e(4901),r=e(6823),a=TypeError;o.exports=function(c){if(n(c))return c;throw new a(r(c)+" is not a function")}}),3506:((o,t,e)=>{var n=e(3925),r=String,a=TypeError;o.exports=function(c){if(n(c))return c;throw new a("Can't set "+r(c)+" as a prototype")}}),7080:((o,t,e)=>{var n=e(4402).has;o.exports=function(r){return n(r),r}}),679:((o,t,e)=>{var n=e(1625),r=TypeError;o.exports=function(a,c){if(n(c,a))return a;throw new r("Incorrect invocation")}}),8551:((o,t,e)=>{var n=e(34),r=String,a=TypeError;o.exports=function(c){if(n(c))return c;throw new a(r(c)+" is not an object")}}),7811:(o=>{o.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),7394:((o,t,e)=>{var n=e(4576),r=e(6706),a=e(2195),c=n.ArrayBuffer,u=n.TypeError;o.exports=c&&r(c.prototype,"byteLength","get")||function(f){if(a(f)!=="ArrayBuffer")throw new u("ArrayBuffer expected");return f.byteLength}}),3238:((o,t,e)=>{var n=e(4576),r=e(7476),a=e(7394),c=n.ArrayBuffer,u=c&&c.prototype,f=u&&r(u.slice);o.exports=function(g){if(a(g)!==0||!f)return!1;try{return f(g,0,0),!1}catch{return!0}}}),5169:((o,t,e)=>{var n=e(3238),r=TypeError;o.exports=function(a){if(n(a))throw new r("ArrayBuffer is detached");return a}}),5636:((o,t,e)=>{var n=e(4576),r=e(9504),a=e(6706),c=e(7696),u=e(5169),f=e(7394),g=e(4483),m=e(1548),b=n.structuredClone,v=n.ArrayBuffer,S=n.DataView,T=Math.min,w=v.prototype,I=S.prototype,k=r(w.slice),O=a(w,"resizable","get"),F=a(w,"maxByteLength","get"),_=r(I.getInt8),D=r(I.setInt8);o.exports=(m||g)&&function(G,j,W){var $=f(G),Z=j===void 0?$:c(j),q=!O||!O(G),yt;if(u(G),m&&(G=b(G,{transfer:[G]}),$===Z&&(W||q)))return G;if($>=Z&&(!W||q))yt=k(G,0,Z);else{var et=W&&!q&&F?{maxByteLength:F(G)}:void 0;yt=new v(Z,et);for(var Tt=new S(G),dt=new S(yt),Y=T(Z,$),K=0;K<Y;K++)D(dt,K,_(Tt,K))}return m||g(G),yt}}),4644:((o,t,e)=>{var n=e(7811),r=e(3724),a=e(4576),c=e(4901),u=e(34),f=e(9297),g=e(6955),m=e(6823),b=e(6699),v=e(6840),S=e(2106),T=e(1625),w=e(2787),I=e(2967),k=e(8227),O=e(3392),F=e(1181),_=F.enforce,D=F.get,G=a.Int8Array,j=G&&G.prototype,W=a.Uint8ClampedArray,$=W&&W.prototype,Z=G&&w(G),q=j&&w(j),yt=Object.prototype,et=a.TypeError,Tt=k("toStringTag"),dt=O("TYPED_ARRAY_TAG"),Y="TypedArrayConstructor",K=n&&!!I&&g(a.opera)!=="Opera",bt=!1,lt,kt,X,ot={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Q={BigInt64Array:8,BigUint64Array:8},nt=function(jt){if(!u(jt))return!1;var Ft=g(jt);return Ft==="DataView"||f(ot,Ft)||f(Q,Ft)},it=function(gt){var jt=w(gt);if(u(jt)){var Ft=D(jt);return Ft&&f(Ft,Y)?Ft[Y]:it(jt)}},V=function(gt){if(!u(gt))return!1;var jt=g(gt);return f(ot,jt)||f(Q,jt)},H=function(gt){if(V(gt))return gt;throw new et("Target is not a typed array")},U=function(gt){if(c(gt)&&(!I||T(Z,gt)))return gt;throw new et(m(gt)+" is not a typed array constructor")},at=function(gt,jt,Ft,tt){if(r){if(Ft)for(var ut in ot){var _t=a[ut];if(_t&&f(_t.prototype,gt))try{delete _t.prototype[gt]}catch{try{_t.prototype[gt]=jt}catch{}}}(!q[gt]||Ft)&&v(q,gt,Ft?jt:K&&j[gt]||jt,tt)}},Ct=function(gt,jt,Ft){var tt,ut;if(r){if(I){if(Ft){for(tt in ot)if(ut=a[tt],ut&&f(ut,gt))try{delete ut[gt]}catch{}}if(!Z[gt]||Ft)try{return v(Z,gt,Ft?jt:K&&Z[gt]||jt)}catch{}else return}for(tt in ot)ut=a[tt],ut&&(!ut[gt]||Ft)&&v(ut,gt,jt)}};for(lt in ot)kt=a[lt],X=kt&&kt.prototype,X?_(X)[Y]=kt:K=!1;for(lt in Q)kt=a[lt],X=kt&&kt.prototype,X&&(_(X)[Y]=kt);if((!K||!c(Z)||Z===Function.prototype)&&(Z=function(){throw new et("Incorrect invocation")},K))for(lt in ot)a[lt]&&I(a[lt],Z);if((!K||!q||q===yt)&&(q=Z.prototype,K))for(lt in ot)a[lt]&&I(a[lt].prototype,q);if(K&&w($)!==q&&I($,q),r&&!f(q,Tt)){bt=!0,S(q,Tt,{configurable:!0,get:function(){return u(this)?this[dt]:void 0}});for(lt in ot)a[lt]&&b(a[lt],dt,lt)}o.exports={NATIVE_ARRAY_BUFFER_VIEWS:K,TYPED_ARRAY_TAG:bt&&dt,aTypedArray:H,aTypedArrayConstructor:U,exportTypedArrayMethod:at,exportTypedArrayStaticMethod:Ct,getTypedArrayConstructor:it,isView:nt,isTypedArray:V,TypedArray:Z,TypedArrayPrototype:q}}),5370:((o,t,e)=>{var n=e(6198);o.exports=function(r,a,c){for(var u=0,f=arguments.length>2?c:n(a),g=new r(f);f>u;)g[u]=a[u++];return g}}),9617:((o,t,e)=>{var n=e(5397),r=e(5610),a=e(6198),c=function(u){return function(f,g,m){var b=n(f),v=a(b);if(v===0)return!u&&-1;var S=r(m,v),T;if(u&&g!==g){for(;v>S;)if(T=b[S++],T!==T)return!0}else for(;v>S;S++)if((u||S in b)&&b[S]===g)return u||S||0;return!u&&-1}};o.exports={includes:c(!0),indexOf:c(!1)}}),4527:((o,t,e)=>{var n=e(3724),r=e(4376),a=TypeError,c=Object.getOwnPropertyDescriptor,u=n&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(f){return f instanceof TypeError}})();o.exports=u?function(f,g){if(r(f)&&!c(f,"length").writable)throw new a("Cannot set read only .length");return f.length=g}:function(f,g){return f.length=g}}),7680:((o,t,e)=>{var n=e(9504);o.exports=n([].slice)}),7628:((o,t,e)=>{var n=e(6198);o.exports=function(r,a){for(var c=n(r),u=new a(c),f=0;f<c;f++)u[f]=r[c-f-1];return u}}),9928:((o,t,e)=>{var n=e(6198),r=e(1291),a=RangeError;o.exports=function(c,u,f,g){var m=n(c),b=r(f),v=b<0?m+b:b;if(v>=m||v<0)throw new a("Incorrect index");for(var S=new u(m),T=0;T<m;T++)S[T]=T===v?g:c[T];return S}}),6319:((o,t,e)=>{var n=e(8551),r=e(9539);o.exports=function(a,c,u,f){try{return f?c(n(u)[0],u[1]):c(u)}catch(g){r(a,"throw",g)}}}),2195:((o,t,e)=>{var n=e(9504),r=n({}.toString),a=n("".slice);o.exports=function(c){return a(r(c),8,-1)}}),6955:((o,t,e)=>{var n=e(2140),r=e(4901),a=e(2195),c=e(8227),u=c("toStringTag"),f=Object,g=a((function(){return arguments})())==="Arguments",m=function(b,v){try{return b[v]}catch{}};o.exports=n?a:function(b){var v,S,T;return b===void 0?"Undefined":b===null?"Null":typeof(S=m(v=f(b),u))=="string"?S:g?a(v):(T=a(v))==="Object"&&r(v.callee)?"Arguments":T}}),7740:((o,t,e)=>{var n=e(9297),r=e(5031),a=e(7347),c=e(4913);o.exports=function(u,f,g){for(var m=r(f),b=c.f,v=a.f,S=0;S<m.length;S++){var T=m[S];!n(u,T)&&!(g&&n(g,T))&&b(u,T,v(f,T))}}}),2211:((o,t,e)=>{var n=e(9039);o.exports=!n(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})}),2529:(o=>{o.exports=function(t,e){return{value:t,done:e}}}),6699:((o,t,e)=>{var n=e(3724),r=e(4913),a=e(6980);o.exports=n?function(c,u,f){return r.f(c,u,a(1,f))}:function(c,u,f){return c[u]=f,c}}),6980:(o=>{o.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}}),4659:((o,t,e)=>{var n=e(3724),r=e(4913),a=e(6980);o.exports=function(c,u,f){n?r.f(c,u,a(0,f)):c[u]=f}}),2106:((o,t,e)=>{var n=e(283),r=e(4913);o.exports=function(a,c,u){return u.get&&n(u.get,c,{getter:!0}),u.set&&n(u.set,c,{setter:!0}),r.f(a,c,u)}}),6840:((o,t,e)=>{var n=e(4901),r=e(4913),a=e(283),c=e(9433);o.exports=function(u,f,g,m){m||(m={});var b=m.enumerable,v=m.name!==void 0?m.name:f;if(n(g)&&a(g,v,m),m.global)b?u[f]=g:c(f,g);else{try{m.unsafe?u[f]&&(b=!0):delete u[f]}catch{}b?u[f]=g:r.f(u,f,{value:g,enumerable:!1,configurable:!m.nonConfigurable,writable:!m.nonWritable})}return u}}),6279:((o,t,e)=>{var n=e(6840);o.exports=function(r,a,c){for(var u in a)n(r,u,a[u],c);return r}}),9433:((o,t,e)=>{var n=e(4576),r=Object.defineProperty;o.exports=function(a,c){try{r(n,a,{value:c,configurable:!0,writable:!0})}catch{n[a]=c}return c}}),3724:((o,t,e)=>{var n=e(9039);o.exports=!n(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),4483:((o,t,e)=>{var n=e(4576),r=e(9429),a=e(1548),c=n.structuredClone,u=n.ArrayBuffer,f=n.MessageChannel,g=!1,m,b,v,S;if(a)g=function(T){c(T,{transfer:[T]})};else if(u)try{f||(m=r("worker_threads"),m&&(f=m.MessageChannel)),f&&(b=new f,v=new u(2),S=function(T){b.port1.postMessage(null,[T])},v.byteLength===2&&(S(v),v.byteLength===0&&(g=S)))}catch{}o.exports=g}),4055:((o,t,e)=>{var n=e(4576),r=e(34),a=n.document,c=r(a)&&r(a.createElement);o.exports=function(u){return c?a.createElement(u):{}}}),6837:(o=>{var t=TypeError,e=9007199254740991;o.exports=function(n){if(n>e)throw t("Maximum allowed index exceeded");return n}}),5002:(o=>{o.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}}),8727:(o=>{o.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),6193:((o,t,e)=>{var n=e(4215);o.exports=n==="NODE"}),2839:((o,t,e)=>{var n=e(4576),r=n.navigator,a=r&&r.userAgent;o.exports=a?String(a):""}),9519:((o,t,e)=>{var n=e(4576),r=e(2839),a=n.process,c=n.Deno,u=a&&a.versions||c&&c.version,f=u&&u.v8,g,m;f&&(g=f.split("."),m=g[0]>0&&g[0]<4?1:+(g[0]+g[1])),!m&&r&&(g=r.match(/Edge\/(\d+)/),(!g||g[1]>=74)&&(g=r.match(/Chrome\/(\d+)/),g&&(m=+g[1]))),o.exports=m}),4215:((o,t,e)=>{var n=e(4576),r=e(2839),a=e(2195),c=function(u){return r.slice(0,u.length)===u};o.exports=(function(){return c("Bun/")?"BUN":c("Cloudflare-Workers")?"CLOUDFLARE":c("Deno/")?"DENO":c("Node.js/")?"NODE":n.Bun&&typeof Bun.version=="string"?"BUN":n.Deno&&typeof Deno.version=="object"?"DENO":a(n.process)==="process"?"NODE":n.window&&n.document?"BROWSER":"REST"})()}),8574:((o,t,e)=>{var n=e(9504),r=Error,a=n("".replace),c=(function(g){return String(new r(g).stack)})("zxcasd"),u=/\n\s*at [^:]*:[^\n]*/,f=u.test(c);o.exports=function(g,m){if(f&&typeof g=="string"&&!r.prepareStackTrace)for(;m--;)g=a(g,u,"");return g}}),6518:((o,t,e)=>{var n=e(4576),r=e(7347).f,a=e(6699),c=e(6840),u=e(9433),f=e(7740),g=e(2796);o.exports=function(m,b){var v=m.target,S=m.global,T=m.stat,w,I,k,O,F,_;if(S?I=n:T?I=n[v]||u(v,{}):I=n[v]&&n[v].prototype,I)for(k in b){if(F=b[k],m.dontCallGetSet?(_=r(I,k),O=_&&_.value):O=I[k],w=g(S?k:v+(T?".":"#")+k,m.forced),!w&&O!==void 0){if(typeof F==typeof O)continue;f(F,O)}(m.sham||O&&O.sham)&&a(F,"sham",!0),c(I,k,F,m)}}}),9039:(o=>{o.exports=function(t){try{return!!t()}catch{return!0}}}),8745:((o,t,e)=>{var n=e(616),r=Function.prototype,a=r.apply,c=r.call;o.exports=typeof Reflect=="object"&&Reflect.apply||(n?c.bind(a):function(){return c.apply(a,arguments)})}),6080:((o,t,e)=>{var n=e(7476),r=e(9306),a=e(616),c=n(n.bind);o.exports=function(u,f){return r(u),f===void 0?u:a?c(u,f):function(){return u.apply(f,arguments)}}}),616:((o,t,e)=>{var n=e(9039);o.exports=!n(function(){var r=(function(){}).bind();return typeof r!="function"||r.hasOwnProperty("prototype")})}),9565:((o,t,e)=>{var n=e(616),r=Function.prototype.call;o.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),350:((o,t,e)=>{var n=e(3724),r=e(9297),a=Function.prototype,c=n&&Object.getOwnPropertyDescriptor,u=r(a,"name"),f=u&&(function(){}).name==="something",g=u&&(!n||n&&c(a,"name").configurable);o.exports={EXISTS:u,PROPER:f,CONFIGURABLE:g}}),6706:((o,t,e)=>{var n=e(9504),r=e(9306);o.exports=function(a,c,u){try{return n(r(Object.getOwnPropertyDescriptor(a,c)[u]))}catch{}}}),7476:((o,t,e)=>{var n=e(2195),r=e(9504);o.exports=function(a){if(n(a)==="Function")return r(a)}}),9504:((o,t,e)=>{var n=e(616),r=Function.prototype,a=r.call,c=n&&r.bind.bind(a,a);o.exports=n?c:function(u){return function(){return a.apply(u,arguments)}}}),9429:((o,t,e)=>{var n=e(4576),r=e(6193);o.exports=function(a){if(r){try{return n.process.getBuiltinModule(a)}catch{}try{return Function('return require("'+a+'")')()}catch{}}}}),7751:((o,t,e)=>{var n=e(4576),r=e(4901),a=function(c){return r(c)?c:void 0};o.exports=function(c,u){return arguments.length<2?a(n[c]):n[c]&&n[c][u]}}),1767:(o=>{o.exports=function(t){return{iterator:t,next:t.next,done:!1}}}),8646:((o,t,e)=>{var n=e(9565),r=e(8551),a=e(1767),c=e(851);o.exports=function(u,f){(!f||typeof u!="string")&&r(u);var g=c(u);return a(r(g!==void 0?n(g,u):u))}}),851:((o,t,e)=>{var n=e(6955),r=e(5966),a=e(4117),c=e(6269),u=e(8227),f=u("iterator");o.exports=function(g){if(!a(g))return r(g,f)||r(g,"@@iterator")||c[n(g)]}}),81:((o,t,e)=>{var n=e(9565),r=e(9306),a=e(8551),c=e(6823),u=e(851),f=TypeError;o.exports=function(g,m){var b=arguments.length<2?u(g):m;if(r(b))return a(n(b,g));throw new f(c(g)+" is not iterable")}}),5966:((o,t,e)=>{var n=e(9306),r=e(4117);o.exports=function(a,c){var u=a[c];return r(u)?void 0:n(u)}}),3789:((o,t,e)=>{var n=e(9306),r=e(8551),a=e(9565),c=e(1291),u=e(1767),f="Invalid size",g=RangeError,m=TypeError,b=Math.max,v=function(S,T){this.set=S,this.size=b(T,0),this.has=n(S.has),this.keys=n(S.keys)};v.prototype={getIterator:function(){return u(r(a(this.keys,this.set)))},includes:function(S){return a(this.has,this.set,S)}},o.exports=function(S){r(S);var T=+S.size;if(T!==T)throw new m(f);var w=c(T);if(w<0)throw new g(f);return new v(S,w)}}),4576:(function(o){var t=function(e){return e&&e.Math===Math&&e};o.exports=t(typeof globalThis=="object"&&globalThis)||t(typeof window=="object"&&window)||t(typeof self=="object"&&self)||t(typeof global=="object"&&global)||t(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()}),9297:((o,t,e)=>{var n=e(9504),r=e(8981),a=n({}.hasOwnProperty);o.exports=Object.hasOwn||function(u,f){return a(r(u),f)}}),421:(o=>{o.exports={}}),397:((o,t,e)=>{var n=e(7751);o.exports=n("document","documentElement")}),5917:((o,t,e)=>{var n=e(3724),r=e(9039),a=e(4055);o.exports=!n&&!r(function(){return Object.defineProperty(a("div"),"a",{get:function(){return 7}}).a!==7})}),7055:((o,t,e)=>{var n=e(9504),r=e(9039),a=e(2195),c=Object,u=n("".split);o.exports=r(function(){return!c("z").propertyIsEnumerable(0)})?function(f){return a(f)==="String"?u(f,""):c(f)}:c}),3167:((o,t,e)=>{var n=e(4901),r=e(34),a=e(2967);o.exports=function(c,u,f){var g,m;return a&&n(g=u.constructor)&&g!==f&&r(m=g.prototype)&&m!==f.prototype&&a(c,m),c}}),3706:((o,t,e)=>{var n=e(9504),r=e(4901),a=e(7629),c=n(Function.toString);r(a.inspectSource)||(a.inspectSource=function(u){return c(u)}),o.exports=a.inspectSource}),1181:((o,t,e)=>{var n=e(8622),r=e(4576),a=e(34),c=e(6699),u=e(9297),f=e(7629),g=e(6119),m=e(421),b="Object already initialized",v=r.TypeError,S=r.WeakMap,T,w,I,k=function(D){return I(D)?w(D):T(D,{})},O=function(D){return function(G){var j;if(!a(G)||(j=w(G)).type!==D)throw new v("Incompatible receiver, "+D+" required");return j}};if(n||f.state){var F=f.state||(f.state=new S);F.get=F.get,F.has=F.has,F.set=F.set,T=function(D,G){if(F.has(D))throw new v(b);return G.facade=D,F.set(D,G),G},w=function(D){return F.get(D)||{}},I=function(D){return F.has(D)}}else{var _=g("state");m[_]=!0,T=function(D,G){if(u(D,_))throw new v(b);return G.facade=D,c(D,_,G),G},w=function(D){return u(D,_)?D[_]:{}},I=function(D){return u(D,_)}}o.exports={set:T,get:w,has:I,enforce:k,getterFor:O}}),4209:((o,t,e)=>{var n=e(8227),r=e(6269),a=n("iterator"),c=Array.prototype;o.exports=function(u){return u!==void 0&&(r.Array===u||c[a]===u)}}),4376:((o,t,e)=>{var n=e(2195);o.exports=Array.isArray||function(a){return n(a)==="Array"}}),1108:((o,t,e)=>{var n=e(6955);o.exports=function(r){var a=n(r);return a==="BigInt64Array"||a==="BigUint64Array"}}),4901:(o=>{var t=typeof document=="object"&&document.all;o.exports=typeof t>"u"&&t!==void 0?function(e){return typeof e=="function"||e===t}:function(e){return typeof e=="function"}}),2796:((o,t,e)=>{var n=e(9039),r=e(4901),a=/#|\.prototype\./,c=function(b,v){var S=f[u(b)];return S===m?!0:S===g?!1:r(v)?n(v):!!v},u=c.normalize=function(b){return String(b).replace(a,".").toLowerCase()},f=c.data={},g=c.NATIVE="N",m=c.POLYFILL="P";o.exports=c}),4117:(o=>{o.exports=function(t){return t==null}}),34:((o,t,e)=>{var n=e(4901);o.exports=function(r){return typeof r=="object"?r!==null:n(r)}}),3925:((o,t,e)=>{var n=e(34);o.exports=function(r){return n(r)||r===null}}),6395:(o=>{o.exports=!1}),757:((o,t,e)=>{var n=e(7751),r=e(4901),a=e(1625),c=e(7040),u=Object;o.exports=c?function(f){return typeof f=="symbol"}:function(f){var g=n("Symbol");return r(g)&&a(g.prototype,u(f))}}),507:((o,t,e)=>{var n=e(9565);o.exports=function(r,a,c){for(var u=c?r:r.iterator,f=r.next,g,m;!(g=n(f,u)).done;)if(m=a(g.value),m!==void 0)return m}}),2652:((o,t,e)=>{var n=e(6080),r=e(9565),a=e(8551),c=e(6823),u=e(4209),f=e(6198),g=e(1625),m=e(81),b=e(851),v=e(9539),S=TypeError,T=function(I,k){this.stopped=I,this.result=k},w=T.prototype;o.exports=function(I,k,O){var F=O&&O.that,_=!!(O&&O.AS_ENTRIES),D=!!(O&&O.IS_RECORD),G=!!(O&&O.IS_ITERATOR),j=!!(O&&O.INTERRUPTED),W=n(k,F),$,Z,q,yt,et,Tt,dt,Y=function(bt){return $&&v($,"normal",bt),new T(!0,bt)},K=function(bt){return _?(a(bt),j?W(bt[0],bt[1],Y):W(bt[0],bt[1])):j?W(bt,Y):W(bt)};if(D)$=I.iterator;else if(G)$=I;else{if(Z=b(I),!Z)throw new S(c(I)+" is not iterable");if(u(Z)){for(q=0,yt=f(I);yt>q;q++)if(et=K(I[q]),et&&g(w,et))return et;return new T(!1)}$=m(I,Z)}for(Tt=D?I.next:$.next;!(dt=r(Tt,$)).done;){try{et=K(dt.value)}catch(bt){v($,"throw",bt)}if(typeof et=="object"&&et&&g(w,et))return et}return new T(!1)}}),9539:((o,t,e)=>{var n=e(9565),r=e(8551),a=e(5966);o.exports=function(c,u,f){var g,m;r(c);try{if(g=a(c,"return"),!g){if(u==="throw")throw f;return f}g=n(g,c)}catch(b){m=!0,g=b}if(u==="throw")throw f;if(m)throw g;return r(g),f}}),9462:((o,t,e)=>{var n=e(9565),r=e(2360),a=e(6699),c=e(6279),u=e(8227),f=e(1181),g=e(5966),m=e(7657).IteratorPrototype,b=e(2529),v=e(9539),S=u("toStringTag"),T="IteratorHelper",w="WrapForValidIterator",I=f.set,k=function(_){var D=f.getterFor(_?w:T);return c(r(m),{next:function(){var j=D(this);if(_)return j.nextHandler();try{var W=j.done?void 0:j.nextHandler();return b(W,j.done)}catch($){throw j.done=!0,$}},return:function(){var G=D(this),j=G.iterator;if(G.done=!0,_){var W=g(j,"return");return W?n(W,j):b(void 0,!0)}if(G.inner)try{v(G.inner.iterator,"normal")}catch($){return v(j,"throw",$)}return j&&v(j,"normal"),b(void 0,!0)}})},O=k(!0),F=k(!1);a(F,S,"Iterator Helper"),o.exports=function(_,D){var G=function(W,$){$?($.iterator=W.iterator,$.next=W.next):$=W,$.type=D?w:T,$.nextHandler=_,$.counter=0,$.done=!1,I(this,$)};return G.prototype=D?O:F,G}}),713:((o,t,e)=>{var n=e(9565),r=e(9306),a=e(8551),c=e(1767),u=e(9462),f=e(6319),g=u(function(){var m=this.iterator,b=a(n(this.next,m)),v=this.done=!!b.done;if(!v)return f(m,this.mapper,[b.value,this.counter++],!0)});o.exports=function(b){return a(this),r(b),new g(c(this),{mapper:b})}}),7657:((o,t,e)=>{var n=e(9039),r=e(4901),a=e(34),c=e(2360),u=e(2787),f=e(6840),g=e(8227),m=e(6395),b=g("iterator"),v=!1,S,T,w;[].keys&&(w=[].keys(),"next"in w?(T=u(u(w)),T!==Object.prototype&&(S=T)):v=!0);var I=!a(S)||n(function(){var k={};return S[b].call(k)!==k});I?S={}:m&&(S=c(S)),r(S[b])||f(S,b,function(){return this}),o.exports={IteratorPrototype:S,BUGGY_SAFARI_ITERATORS:v}}),6269:(o=>{o.exports={}}),6198:((o,t,e)=>{var n=e(8014);o.exports=function(r){return n(r.length)}}),283:((o,t,e)=>{var n=e(9504),r=e(9039),a=e(4901),c=e(9297),u=e(3724),f=e(350).CONFIGURABLE,g=e(3706),m=e(1181),b=m.enforce,v=m.get,S=String,T=Object.defineProperty,w=n("".slice),I=n("".replace),k=n([].join),O=u&&!r(function(){return T(function(){},"length",{value:8}).length!==8}),F=String(String).split("String"),_=o.exports=function(D,G,j){w(S(G),0,7)==="Symbol("&&(G="["+I(S(G),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),j&&j.getter&&(G="get "+G),j&&j.setter&&(G="set "+G),(!c(D,"name")||f&&D.name!==G)&&(u?T(D,"name",{value:G,configurable:!0}):D.name=G),O&&j&&c(j,"arity")&&D.length!==j.arity&&T(D,"length",{value:j.arity});try{j&&c(j,"constructor")&&j.constructor?u&&T(D,"prototype",{writable:!1}):D.prototype&&(D.prototype=void 0)}catch{}var W=b(D);return c(W,"source")||(W.source=k(F,typeof G=="string"?G:"")),D};Function.prototype.toString=_(function(){return a(this)&&v(this).source||g(this)},"toString")}),741:(o=>{var t=Math.ceil,e=Math.floor;o.exports=Math.trunc||function(r){var a=+r;return(a>0?e:t)(a)}}),6043:((o,t,e)=>{var n=e(9306),r=TypeError,a=function(c){var u,f;this.promise=new c(function(g,m){if(u!==void 0||f!==void 0)throw new r("Bad Promise constructor");u=g,f=m}),this.resolve=n(u),this.reject=n(f)};o.exports.f=function(c){return new a(c)}}),2603:((o,t,e)=>{var n=e(655);o.exports=function(r,a){return r===void 0?arguments.length<2?"":a:n(r)}}),4149:(o=>{var t=RangeError;o.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}}),2360:((o,t,e)=>{var n=e(8551),r=e(6801),a=e(8727),c=e(421),u=e(397),f=e(4055),g=e(6119),m=">",b="<",v="prototype",S="script",T=g("IE_PROTO"),w=function(){},I=function(D){return b+S+m+D+b+"/"+S+m},k=function(D){D.write(I("")),D.close();var G=D.parentWindow.Object;return D=null,G},O=function(){var D=f("iframe"),G="java"+S+":",j;return D.style.display="none",u.appendChild(D),D.src=String(G),j=D.contentWindow.document,j.open(),j.write(I("document.F=Object")),j.close(),j.F},F,_=function(){try{F=new ActiveXObject("htmlfile")}catch{}_=typeof document<"u"?document.domain&&F?k(F):O():k(F);for(var D=a.length;D--;)delete _[v][a[D]];return _()};c[T]=!0,o.exports=Object.create||function(G,j){var W;return G!==null?(w[v]=n(G),W=new w,w[v]=null,W[T]=G):W=_(),j===void 0?W:r.f(W,j)}}),6801:((o,t,e)=>{var n=e(3724),r=e(8686),a=e(4913),c=e(8551),u=e(5397),f=e(1072);t.f=n&&!r?Object.defineProperties:function(m,b){c(m);for(var v=u(b),S=f(b),T=S.length,w=0,I;T>w;)a.f(m,I=S[w++],v[I]);return m}}),4913:((o,t,e)=>{var n=e(3724),r=e(5917),a=e(8686),c=e(8551),u=e(6969),f=TypeError,g=Object.defineProperty,m=Object.getOwnPropertyDescriptor,b="enumerable",v="configurable",S="writable";t.f=n?a?function(w,I,k){if(c(w),I=u(I),c(k),typeof w=="function"&&I==="prototype"&&"value"in k&&S in k&&!k[S]){var O=m(w,I);O&&O[S]&&(w[I]=k.value,k={configurable:v in k?k[v]:O[v],enumerable:b in k?k[b]:O[b],writable:!1})}return g(w,I,k)}:g:function(w,I,k){if(c(w),I=u(I),c(k),r)try{return g(w,I,k)}catch{}if("get"in k||"set"in k)throw new f("Accessors not supported");return"value"in k&&(w[I]=k.value),w}}),7347:((o,t,e)=>{var n=e(3724),r=e(9565),a=e(8773),c=e(6980),u=e(5397),f=e(6969),g=e(9297),m=e(5917),b=Object.getOwnPropertyDescriptor;t.f=n?b:function(S,T){if(S=u(S),T=f(T),m)try{return b(S,T)}catch{}if(g(S,T))return c(!r(a.f,S,T),S[T])}}),8480:((o,t,e)=>{var n=e(1828),r=e(8727),a=r.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(u){return n(u,a)}}),3717:((o,t)=>{t.f=Object.getOwnPropertySymbols}),2787:((o,t,e)=>{var n=e(9297),r=e(4901),a=e(8981),c=e(6119),u=e(2211),f=c("IE_PROTO"),g=Object,m=g.prototype;o.exports=u?g.getPrototypeOf:function(b){var v=a(b);if(n(v,f))return v[f];var S=v.constructor;return r(S)&&v instanceof S?S.prototype:v instanceof g?m:null}}),1625:((o,t,e)=>{var n=e(9504);o.exports=n({}.isPrototypeOf)}),1828:((o,t,e)=>{var n=e(9504),r=e(9297),a=e(5397),c=e(9617).indexOf,u=e(421),f=n([].push);o.exports=function(g,m){var b=a(g),v=0,S=[],T;for(T in b)!r(u,T)&&r(b,T)&&f(S,T);for(;m.length>v;)r(b,T=m[v++])&&(~c(S,T)||f(S,T));return S}}),1072:((o,t,e)=>{var n=e(1828),r=e(8727);o.exports=Object.keys||function(c){return n(c,r)}}),8773:((o,t)=>{var e={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,r=n&&!e.call({1:2},1);t.f=r?function(c){var u=n(this,c);return!!u&&u.enumerable}:e}),2967:((o,t,e)=>{var n=e(6706),r=e(34),a=e(7750),c=e(3506);o.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var u=!1,f={},g;try{g=n(Object.prototype,"__proto__","set"),g(f,[]),u=f instanceof Array}catch{}return function(b,v){return a(b),c(v),r(b)&&(u?g(b,v):b.__proto__=v),b}})():void 0)}),4270:((o,t,e)=>{var n=e(9565),r=e(4901),a=e(34),c=TypeError;o.exports=function(u,f){var g,m;if(f==="string"&&r(g=u.toString)&&!a(m=n(g,u))||r(g=u.valueOf)&&!a(m=n(g,u))||f!=="string"&&r(g=u.toString)&&!a(m=n(g,u)))return m;throw new c("Can't convert object to primitive value")}}),5031:((o,t,e)=>{var n=e(7751),r=e(9504),a=e(8480),c=e(3717),u=e(8551),f=r([].concat);o.exports=n("Reflect","ownKeys")||function(m){var b=a.f(u(m)),v=c.f;return v?f(b,v(m)):b}}),8235:((o,t,e)=>{var n=e(9504),r=e(9297),a=SyntaxError,c=parseInt,u=String.fromCharCode,f=n("".charAt),g=n("".slice),m=n(/./.exec),b={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
|
|
2
|
+
`,"\\r":"\r","\\t":" "},v=/^[\da-f]{4}$/i,S=/^[\u0000-\u001F]$/;o.exports=function(T,w){for(var I=!0,k="";w<T.length;){var O=f(T,w);if(O==="\\"){var F=g(T,w,w+2);if(r(b,F))k+=b[F],w+=2;else if(F==="\\u"){w+=2;var _=g(T,w,w+4);if(!m(v,_))throw new a("Bad Unicode escape at: "+w);k+=u(c(_,16)),w+=4}else throw new a('Unknown escape sequence: "'+F+'"')}else if(O==='"'){I=!1,w++;break}else{if(m(S,O))throw new a("Bad control character in string literal at: "+w);k+=O,w++}}if(I)throw new a("Unterminated string at: "+w);return{value:k,end:w}}}),1103:(o=>{o.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}}),7750:((o,t,e)=>{var n=e(4117),r=TypeError;o.exports=function(a){if(n(a))throw new r("Can't call method on "+a);return a}}),9286:((o,t,e)=>{var n=e(4402),r=e(8469),a=n.Set,c=n.add;o.exports=function(u){var f=new a;return r(u,function(g){c(f,g)}),f}}),3440:((o,t,e)=>{var n=e(7080),r=e(4402),a=e(9286),c=e(5170),u=e(3789),f=e(8469),g=e(507),m=r.has,b=r.remove;o.exports=function(S){var T=n(this),w=u(S),I=a(T);return c(T)<=w.size?f(T,function(k){w.includes(k)&&b(I,k)}):g(w.getIterator(),function(k){m(T,k)&&b(I,k)}),I}}),4402:((o,t,e)=>{var n=e(9504),r=Set.prototype;o.exports={Set,add:n(r.add),has:n(r.has),remove:n(r.delete),proto:r}}),8750:((o,t,e)=>{var n=e(7080),r=e(4402),a=e(5170),c=e(3789),u=e(8469),f=e(507),g=r.Set,m=r.add,b=r.has;o.exports=function(S){var T=n(this),w=c(S),I=new g;return a(T)>w.size?f(w.getIterator(),function(k){b(T,k)&&m(I,k)}):u(T,function(k){w.includes(k)&&m(I,k)}),I}}),4449:((o,t,e)=>{var n=e(7080),r=e(4402).has,a=e(5170),c=e(3789),u=e(8469),f=e(507),g=e(9539);o.exports=function(b){var v=n(this),S=c(b);if(a(v)<=S.size)return u(v,function(w){if(S.includes(w))return!1},!0)!==!1;var T=S.getIterator();return f(T,function(w){if(r(v,w))return g(T,"normal",!1)})!==!1}}),3838:((o,t,e)=>{var n=e(7080),r=e(5170),a=e(8469),c=e(3789);o.exports=function(f){var g=n(this),m=c(f);return r(g)>m.size?!1:a(g,function(b){if(!m.includes(b))return!1},!0)!==!1}}),8527:((o,t,e)=>{var n=e(7080),r=e(4402).has,a=e(5170),c=e(3789),u=e(507),f=e(9539);o.exports=function(m){var b=n(this),v=c(m);if(a(b)<v.size)return!1;var S=v.getIterator();return u(S,function(T){if(!r(b,T))return f(S,"normal",!1)})!==!1}}),8469:((o,t,e)=>{var n=e(9504),r=e(507),a=e(4402),c=a.Set,u=a.proto,f=n(u.forEach),g=n(u.keys),m=g(new c).next;o.exports=function(b,v,S){return S?r({iterator:g(b),next:m},v):f(b,v)}}),4916:((o,t,e)=>{var n=e(7751),r=function(a){return{size:a,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}};o.exports=function(a){var c=n("Set");try{new c()[a](r(0));try{return new c()[a](r(-1)),!1}catch{return!0}}catch{return!1}}}),5170:((o,t,e)=>{var n=e(6706),r=e(4402);o.exports=n(r.proto,"size","get")||function(a){return a.size}}),3650:((o,t,e)=>{var n=e(7080),r=e(4402),a=e(9286),c=e(3789),u=e(507),f=r.add,g=r.has,m=r.remove;o.exports=function(v){var S=n(this),T=c(v).getIterator(),w=a(S);return u(T,function(I){g(S,I)?m(w,I):f(w,I)}),w}}),4204:((o,t,e)=>{var n=e(7080),r=e(4402).add,a=e(9286),c=e(3789),u=e(507);o.exports=function(g){var m=n(this),b=c(g).getIterator(),v=a(m);return u(b,function(S){r(v,S)}),v}}),6119:((o,t,e)=>{var n=e(5745),r=e(3392),a=n("keys");o.exports=function(c){return a[c]||(a[c]=r(c))}}),7629:((o,t,e)=>{var n=e(6395),r=e(4576),a=e(9433),c="__core-js_shared__",u=o.exports=r[c]||a(c,{});(u.versions||(u.versions=[])).push({version:"3.39.0",mode:n?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),5745:((o,t,e)=>{var n=e(7629);o.exports=function(r,a){return n[r]||(n[r]=a||{})}}),1548:((o,t,e)=>{var n=e(4576),r=e(9039),a=e(9519),c=e(4215),u=n.structuredClone;o.exports=!!u&&!r(function(){if(c==="DENO"&&a>92||c==="NODE"&&a>94||c==="BROWSER"&&a>97)return!1;var f=new ArrayBuffer(8),g=u(f,{transfer:[f]});return f.byteLength!==0||g.byteLength!==8})}),4495:((o,t,e)=>{var n=e(9519),r=e(9039),a=e(4576),c=a.String;o.exports=!!Object.getOwnPropertySymbols&&!r(function(){var u=Symbol("symbol detection");return!c(u)||!(Object(u)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),5610:((o,t,e)=>{var n=e(1291),r=Math.max,a=Math.min;o.exports=function(c,u){var f=n(c);return f<0?r(f+u,0):a(f,u)}}),5854:((o,t,e)=>{var n=e(2777),r=TypeError;o.exports=function(a){var c=n(a,"number");if(typeof c=="number")throw new r("Can't convert number to bigint");return BigInt(c)}}),7696:((o,t,e)=>{var n=e(1291),r=e(8014),a=RangeError;o.exports=function(c){if(c===void 0)return 0;var u=n(c),f=r(u);if(u!==f)throw new a("Wrong length or index");return f}}),5397:((o,t,e)=>{var n=e(7055),r=e(7750);o.exports=function(a){return n(r(a))}}),1291:((o,t,e)=>{var n=e(741);o.exports=function(r){var a=+r;return a!==a||a===0?0:n(a)}}),8014:((o,t,e)=>{var n=e(1291),r=Math.min;o.exports=function(a){var c=n(a);return c>0?r(c,9007199254740991):0}}),8981:((o,t,e)=>{var n=e(7750),r=Object;o.exports=function(a){return r(n(a))}}),9590:((o,t,e)=>{var n=e(1291),r=RangeError;o.exports=function(a){var c=n(a);if(c<0)throw new r("The argument can't be less than 0");return c}}),2777:((o,t,e)=>{var n=e(9565),r=e(34),a=e(757),c=e(5966),u=e(4270),f=e(8227),g=TypeError,m=f("toPrimitive");o.exports=function(b,v){if(!r(b)||a(b))return b;var S=c(b,m),T;if(S){if(v===void 0&&(v="default"),T=n(S,b,v),!r(T)||a(T))return T;throw new g("Can't convert object to primitive value")}return v===void 0&&(v="number"),u(b,v)}}),6969:((o,t,e)=>{var n=e(2777),r=e(757);o.exports=function(a){var c=n(a,"string");return r(c)?c:c+""}}),2140:((o,t,e)=>{var n=e(8227),r=n("toStringTag"),a={};a[r]="z",o.exports=String(a)==="[object z]"}),655:((o,t,e)=>{var n=e(6955),r=String;o.exports=function(a){if(n(a)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return r(a)}}),6823:(o=>{var t=String;o.exports=function(e){try{return t(e)}catch{return"Object"}}}),3392:((o,t,e)=>{var n=e(9504),r=0,a=Math.random(),c=n(1 .toString);o.exports=function(u){return"Symbol("+(u===void 0?"":u)+")_"+c(++r+a,36)}}),7040:((o,t,e)=>{var n=e(4495);o.exports=n&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),8686:((o,t,e)=>{var n=e(3724),r=e(9039);o.exports=n&&r(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),2812:(o=>{var t=TypeError;o.exports=function(e,n){if(e<n)throw new t("Not enough arguments");return e}}),8622:((o,t,e)=>{var n=e(4576),r=e(4901),a=n.WeakMap;o.exports=r(a)&&/native code/.test(String(a))}),8227:((o,t,e)=>{var n=e(4576),r=e(5745),a=e(9297),c=e(3392),u=e(4495),f=e(7040),g=n.Symbol,m=r("wks"),b=f?g.for||g:g&&g.withoutSetter||c;o.exports=function(v){return a(m,v)||(m[v]=u&&a(g,v)?g[v]:b("Symbol."+v)),m[v]}}),6573:((o,t,e)=>{var n=e(3724),r=e(2106),a=e(3238),c=ArrayBuffer.prototype;n&&!("detached"in c)&&r(c,"detached",{configurable:!0,get:function(){return a(this)}})}),7936:((o,t,e)=>{var n=e(6518),r=e(5636);r&&n({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return r(this,arguments.length?arguments[0]:void 0,!1)}})}),8100:((o,t,e)=>{var n=e(6518),r=e(5636);r&&n({target:"ArrayBuffer",proto:!0},{transfer:function(){return r(this,arguments.length?arguments[0]:void 0,!0)}})}),4114:((o,t,e)=>{var n=e(6518),r=e(8981),a=e(6198),c=e(4527),u=e(6837),f=e(9039),g=f(function(){return[].push.call({length:4294967296},1)!==4294967297}),m=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(v){return v instanceof TypeError}},b=g||!m();n({target:"Array",proto:!0,arity:1,forced:b},{push:function(S){var T=r(this),w=a(T),I=arguments.length;u(w+I);for(var k=0;k<I;k++)T[w]=arguments[k],w++;return c(T,w),w}})}),8111:((o,t,e)=>{var n=e(6518),r=e(4576),a=e(679),c=e(8551),u=e(4901),f=e(2787),g=e(2106),m=e(4659),b=e(9039),v=e(9297),S=e(8227),T=e(7657).IteratorPrototype,w=e(3724),I=e(6395),k="constructor",O="Iterator",F=S("toStringTag"),_=TypeError,D=r[O],G=I||!u(D)||D.prototype!==T||!b(function(){D({})}),j=function(){if(a(this,T),f(this)===T)throw new _("Abstract class Iterator not directly constructable")},W=function($,Z){w?g(T,$,{configurable:!0,get:function(){return Z},set:function(q){if(c(this),this===T)throw new _("You can't redefine this property");v(this,$)?this[$]=q:m(this,$,q)}}):T[$]=Z};v(T,F)||W(F,O),(G||!v(T,k)||T[k]===Object)&&W(k,j),j.prototype=T,n({global:!0,constructor:!0,forced:G},{Iterator:j})}),9314:((o,t,e)=>{var n=e(6518),r=e(9565),a=e(8551),c=e(1767),u=e(4149),f=e(9590),g=e(9462),m=e(6395),b=g(function(){for(var v=this.iterator,S=this.next,T,w;this.remaining;)if(this.remaining--,T=a(r(S,v)),w=this.done=!!T.done,w)return;if(T=a(r(S,v)),w=this.done=!!T.done,!w)return T.value});n({target:"Iterator",proto:!0,real:!0,forced:m},{drop:function(S){a(this);var T=f(u(+S));return new b(c(this),{remaining:T})}})}),1148:((o,t,e)=>{var n=e(6518),r=e(2652),a=e(9306),c=e(8551),u=e(1767);n({target:"Iterator",proto:!0,real:!0},{every:function(g){c(this),a(g);var m=u(this),b=0;return!r(m,function(v,S){if(!g(v,b++))return S()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),2489:((o,t,e)=>{var n=e(6518),r=e(9565),a=e(9306),c=e(8551),u=e(1767),f=e(9462),g=e(6319),m=e(6395),b=f(function(){for(var v=this.iterator,S=this.predicate,T=this.next,w,I,k;;){if(w=c(r(T,v)),I=this.done=!!w.done,I)return;if(k=w.value,g(v,S,[k,this.counter++],!0))return k}});n({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(S){return c(this),a(S),new b(u(this),{predicate:S})}})}),531:((o,t,e)=>{var n=e(6518),r=e(9565),a=e(9306),c=e(8551),u=e(1767),f=e(8646),g=e(9462),m=e(9539),b=e(6395),v=g(function(){for(var S=this.iterator,T=this.mapper,w,I;;){if(I=this.inner)try{if(w=c(r(I.next,I.iterator)),!w.done)return w.value;this.inner=null}catch(k){m(S,"throw",k)}if(w=c(r(this.next,S)),this.done=!!w.done)return;try{this.inner=f(T(w.value,this.counter++),!1)}catch(k){m(S,"throw",k)}}});n({target:"Iterator",proto:!0,real:!0,forced:b},{flatMap:function(T){return c(this),a(T),new v(u(this),{mapper:T,inner:null})}})}),1701:((o,t,e)=>{var n=e(6518),r=e(713),a=e(6395);n({target:"Iterator",proto:!0,real:!0,forced:a},{map:r})}),3579:((o,t,e)=>{var n=e(6518),r=e(2652),a=e(9306),c=e(8551),u=e(1767);n({target:"Iterator",proto:!0,real:!0},{some:function(g){c(this),a(g);var m=u(this),b=0;return r(m,function(v,S){if(g(v,b++))return S()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),1689:((o,t,e)=>{var n=e(6518),r=e(4576),a=e(8745),c=e(7680),u=e(6043),f=e(9306),g=e(1103),m=r.Promise,b=!1,v=!m||!m.try||g(function(){m.try(function(S){b=S===8},8)}).error||!b;n({target:"Promise",stat:!0,forced:v},{try:function(S){var T=arguments.length>1?c(arguments,1):[],w=u.f(this),I=g(function(){return a(f(S),void 0,T)});return(I.error?w.reject:w.resolve)(I.value),w.promise}})}),4628:((o,t,e)=>{var n=e(6518),r=e(6043);n({target:"Promise",stat:!0},{withResolvers:function(){var c=r.f(this);return{promise:c.promise,resolve:c.resolve,reject:c.reject}}})}),7642:((o,t,e)=>{var n=e(6518),r=e(3440),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("difference")},{difference:r})}),8004:((o,t,e)=>{var n=e(6518),r=e(9039),a=e(8750),c=e(4916),u=!c("intersection")||r(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});n({target:"Set",proto:!0,real:!0,forced:u},{intersection:a})}),3853:((o,t,e)=>{var n=e(6518),r=e(4449),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("isDisjointFrom")},{isDisjointFrom:r})}),5876:((o,t,e)=>{var n=e(6518),r=e(3838),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("isSubsetOf")},{isSubsetOf:r})}),2475:((o,t,e)=>{var n=e(6518),r=e(8527),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("isSupersetOf")},{isSupersetOf:r})}),5024:((o,t,e)=>{var n=e(6518),r=e(3650),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("symmetricDifference")},{symmetricDifference:r})}),1698:((o,t,e)=>{var n=e(6518),r=e(4204),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("union")},{union:r})}),7467:((o,t,e)=>{var n=e(7628),r=e(4644),a=r.aTypedArray,c=r.exportTypedArrayMethod,u=r.getTypedArrayConstructor;c("toReversed",function(){return n(a(this),u(this))})}),4732:((o,t,e)=>{var n=e(4644),r=e(9504),a=e(9306),c=e(5370),u=n.aTypedArray,f=n.getTypedArrayConstructor,g=n.exportTypedArrayMethod,m=r(n.TypedArrayPrototype.sort);g("toSorted",function(v){v!==void 0&&a(v);var S=u(this),T=c(f(S),S);return m(T,v)})}),9577:((o,t,e)=>{var n=e(9928),r=e(4644),a=e(1108),c=e(1291),u=e(5854),f=r.aTypedArray,g=r.getTypedArrayConstructor,m=r.exportTypedArrayMethod,b=!!(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(v){return v===8}})();m("with",function(v,S){var T=f(this),w=c(v),I=a(T)?u(S):+S;return n(T,g(T),w,I)},!b)}),8992:((o,t,e)=>{e(8111)}),4743:((o,t,e)=>{e(9314)}),3215:((o,t,e)=>{e(1148)}),4520:((o,t,e)=>{e(2489)}),670:((o,t,e)=>{e(531)}),1454:((o,t,e)=>{e(1701)}),7550:((o,t,e)=>{e(3579)}),8335:((o,t,e)=>{var n=e(6518),r=e(3724),a=e(4576),c=e(7751),u=e(9504),f=e(9565),g=e(4901),m=e(34),b=e(4376),v=e(9297),S=e(655),T=e(6198),w=e(4659),I=e(9039),k=e(8235),O=e(4495),F=a.JSON,_=a.Number,D=a.SyntaxError,G=F&&F.parse,j=c("Object","keys"),W=Object.getOwnPropertyDescriptor,$=u("".charAt),Z=u("".slice),q=u(/./.exec),yt=u([].push),et=/^\d$/,Tt=/^[1-9]$/,dt=/^[\d-]$/,Y=/^[\t\n\r ]$/,K=0,bt=1,lt=function(V,H){V=S(V);var U=new Q(V,0,""),at=U.parse(),Ct=at.value,gt=U.skip(Y,at.end);if(gt<V.length)throw new D('Unexpected extra character: "'+$(V,gt)+'" after the parsed data at: '+gt);return g(H)?kt({"":Ct},"",H,at):Ct},kt=function(V,H,U,at){var Ct=V[H],gt=at&&Ct===at.value,jt=gt&&typeof at.source=="string"?{source:at.source}:{},Ft,tt,ut,_t,Le;if(m(Ct)){var rn=b(Ct),Je=gt?at.nodes:rn?[]:{};if(rn)for(Ft=Je.length,ut=T(Ct),_t=0;_t<ut;_t++)X(Ct,_t,kt(Ct,""+_t,U,_t<Ft?Je[_t]:void 0));else for(tt=j(Ct),ut=T(tt),_t=0;_t<ut;_t++)Le=tt[_t],X(Ct,Le,kt(Ct,Le,U,v(Je,Le)?Je[Le]:void 0))}return f(U,V,H,Ct,jt)},X=function(V,H,U){if(r){var at=W(V,H);if(at&&!at.configurable)return}U===void 0?delete V[H]:w(V,H,U)},ot=function(V,H,U,at){this.value=V,this.end=H,this.source=U,this.nodes=at},Q=function(V,H){this.source=V,this.index=H};Q.prototype={fork:function(V){return new Q(this.source,V)},parse:function(){var V=this.source,H=this.skip(Y,this.index),U=this.fork(H),at=$(V,H);if(q(dt,at))return U.number();switch(at){case"{":return U.object();case"[":return U.array();case'"':return U.string();case"t":return U.keyword(!0);case"f":return U.keyword(!1);case"n":return U.keyword(null)}throw new D('Unexpected character: "'+at+'" at: '+H)},node:function(V,H,U,at,Ct){return new ot(H,at,V?null:Z(this.source,U,at),Ct)},object:function(){for(var V=this.source,H=this.index+1,U=!1,at={},Ct={};H<V.length;){if(H=this.until(['"',"}"],H),$(V,H)==="}"&&!U){H++;break}var gt=this.fork(H).string(),jt=gt.value;H=gt.end,H=this.until([":"],H)+1,H=this.skip(Y,H),gt=this.fork(H).parse(),w(Ct,jt,gt),w(at,jt,gt.value),H=this.until([",","}"],gt.end);var Ft=$(V,H);if(Ft===",")U=!0,H++;else if(Ft==="}"){H++;break}}return this.node(bt,at,this.index,H,Ct)},array:function(){for(var V=this.source,H=this.index+1,U=!1,at=[],Ct=[];H<V.length;){if(H=this.skip(Y,H),$(V,H)==="]"&&!U){H++;break}var gt=this.fork(H).parse();if(yt(Ct,gt),yt(at,gt.value),H=this.until([",","]"],gt.end),$(V,H)===",")U=!0,H++;else if($(V,H)==="]"){H++;break}}return this.node(bt,at,this.index,H,Ct)},string:function(){var V=this.index,H=k(this.source,this.index+1);return this.node(K,H.value,V,H.end)},number:function(){var V=this.source,H=this.index,U=H;if($(V,U)==="-"&&U++,$(V,U)==="0")U++;else if(q(Tt,$(V,U)))U=this.skip(et,U+1);else throw new D("Failed to parse number at: "+U);if($(V,U)==="."&&(U=this.skip(et,U+1)),$(V,U)==="e"||$(V,U)==="E"){U++,($(V,U)==="+"||$(V,U)==="-")&&U++;var at=U;if(U=this.skip(et,U),at===U)throw new D("Failed to parse number's exponent value at: "+U)}return this.node(K,_(Z(V,H,U)),H,U)},keyword:function(V){var H=""+V,U=this.index,at=U+H.length;if(Z(this.source,U,at)!==H)throw new D("Failed to parse value at: "+U);return this.node(K,V,U,at)},skip:function(V,H){for(var U=this.source;H<U.length&&q(V,$(U,H));H++);return H},until:function(V,H){H=this.skip(Y,H);for(var U=$(this.source,H),at=0;at<V.length;at++)if(V[at]===U)return H;throw new D('Unexpected character: "'+U+'" at: '+H)}};var nt=I(function(){var V="9007199254740993",H;return G(V,function(U,at,Ct){H=Ct.source}),H!==V}),it=O&&!I(function(){return 1/G("-0 ")!==-1/0});n({target:"JSON",stat:!0,forced:nt},{parse:function(H,U){return it&&!g(U)?G(H):lt(H,U)}})}),5247:((o,t,e)=>{e(1689)}),4979:((o,t,e)=>{var n=e(6518),r=e(4576),a=e(7751),c=e(6980),u=e(4913).f,f=e(9297),g=e(679),m=e(3167),b=e(2603),v=e(5002),S=e(8574),T=e(3724),w=e(6395),I="DOMException",k=a("Error"),O=a(I),F=function(){g(this,_);var Y=arguments.length,K=b(Y<1?void 0:arguments[0]),bt=b(Y<2?void 0:arguments[1],"Error"),lt=new O(K,bt),kt=new k(K);return kt.name=I,u(lt,"stack",c(1,S(kt.stack,1))),m(lt,this,F),lt},_=F.prototype=O.prototype,D="stack"in new k(I),G="stack"in new O(1,2),j=O&&T&&Object.getOwnPropertyDescriptor(r,I),W=!!j&&!(j.writable&&j.configurable),$=D&&!W&&!G;n({global:!0,constructor:!0,forced:w||$},{DOMException:$?F:O});var Z=a(I),q=Z.prototype;if(q.constructor!==Z){w||u(q,"constructor",c(1,Z));for(var yt in v)if(f(v,yt)){var et=v[yt],Tt=et.s;f(Z,Tt)||u(Z,Tt,c(6,et.c))}}}),4603:((o,t,e)=>{var n=e(6840),r=e(9504),a=e(655),c=e(2812),u=URLSearchParams,f=u.prototype,g=r(f.append),m=r(f.delete),b=r(f.forEach),v=r([].push),S=new u("a=1&a=2&b=3");S.delete("a",1),S.delete("b",void 0),S+""!="a=2"&&n(f,"delete",function(T){var w=arguments.length,I=w<2?void 0:arguments[1];if(w&&I===void 0)return m(this,T);var k=[];b(this,function($,Z){v(k,{key:Z,value:$})}),c(w,1);for(var O=a(T),F=a(I),_=0,D=0,G=!1,j=k.length,W;_<j;)W=k[_++],G||W.key===O?(G=!0,m(this,W.key)):D++;for(;D<j;)W=k[D++],W.key===O&&W.value===F||g(this,W.key,W.value)},{enumerable:!0,unsafe:!0})}),7566:((o,t,e)=>{var n=e(6840),r=e(9504),a=e(655),c=e(2812),u=URLSearchParams,f=u.prototype,g=r(f.getAll),m=r(f.has),b=new u("a=1");(b.has("a",2)||!b.has("a",void 0))&&n(f,"has",function(S){var T=arguments.length,w=T<2?void 0:arguments[1];if(T&&w===void 0)return m(this,S);var I=g(this,S);c(T,1);for(var k=a(w),O=0;O<I.length;)if(I[O++]===k)return!0;return!1},{enumerable:!0,unsafe:!0})}),8721:((o,t,e)=>{var n=e(3724),r=e(9504),a=e(2106),c=URLSearchParams.prototype,u=r(c.forEach);n&&!("size"in c)&&a(c,"size",{get:function(){var g=0;return u(this,function(){g++}),g},configurable:!0,enumerable:!0})})},tu={};Lt.d=(o,t)=>{for(var e in t)Lt.o(t,e)&&!Lt.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:t[e]})};Lt.o=(o,t)=>Object.prototype.hasOwnProperty.call(o,t);wt=globalThis.pdfjsLib={};Lt.d(wt,{AbortException:()=>Ze,AnnotationEditorLayer:()=>La,AnnotationEditorParamsType:()=>Mt,AnnotationEditorType:()=>Rt,AnnotationEditorUIManager:()=>Fn,AnnotationLayer:()=>Ta,AnnotationMode:()=>gn,ColorPicker:()=>Xr,DOMSVGFactory:()=>Is,DrawLayer:()=>Fa,FeatureTest:()=>ne,GlobalWorkerOptions:()=>Rn,ImageKind:()=>yr,InvalidPDFException:()=>xs,MissingPDFException:()=>On,OPS:()=>Ge,OutputScale:()=>Ts,PDFDataRangeTransport:()=>Dr,PDFDateString:()=>Sr,PDFWorker:()=>Jn,PasswordResponses:()=>ty,PermissionFlag:()=>qb,PixelsPerInch:()=>bn,RenderingCancelledException:()=>As,TextLayer:()=>Es,TouchManager:()=>Cr,UnexpectedResponseException:()=>qn,Util:()=>St,VerbosityLevel:()=>Zr,XfaLayer:()=>Ur,build:()=>jy,createValidAbsoluteUrl:()=>ry,fetchData:()=>ti,getDocument:()=>Uy,getFilenameFromUrl:()=>dy,getPdfFilenameFromUrl:()=>fy,getXfaPageViewport:()=>py,isDataScheme:()=>ei,isPdfFile:()=>Na,noContextMenu:()=>He,normalizeUnicode:()=>cy,setLayerDimensions:()=>Mn,shadow:()=>Ot,stopEvent:()=>Ee,version:()=>Hy});k1=Lt(4114),I1=Lt(6573),P1=Lt(8100),R1=Lt(7936),O1=Lt(7467),M1=Lt(4732),L1=Lt(9577),F1=Lt(5247),D1=Lt(4979),_1=Lt(4603),N1=Lt(7566),U1=Lt(8721),ue=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),gu=[1,0,0,1,0,0],fo=[.001,0,0,.001,0,0],Zb=1e7,br=1.35,Qb=.35,B1=Qb/br,we={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},gn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Jb="pdfjs_internal_editor_",Rt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Mt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},qb={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},le={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},yr={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ee={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},ps={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Zr={ERRORS:0,WARNINGS:1,INFOS:5},Ge={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},ty={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Qr=Zr.WARNINGS;yn=(function(){function t(e,n){this.message=e,this.name=n}return t.prototype=new Error,t.constructor=t,t})(),vr=class extends yn{constructor(t,e){super(t,"PasswordException"),this.code=e}},vs=class extends yn{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},xs=class extends yn{constructor(t){super(t,"InvalidPDFException")}},On=class extends yn{constructor(t){super(t,"MissingPDFException")}},qn=class extends yn{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},po=class extends yn{constructor(t){super(t,"FormatError")}},Ze=class extends yn{constructor(t){super(t,"AbortException")}};ne=class{static get isLittleEndian(){return Ot(this,"isLittleEndian",oy())}static get isEvalSupported(){return Ot(this,"isEvalSupported",ay())}static get isOffscreenCanvasSupported(){return Ot(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Ot(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?Ot(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):Ot(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Ot(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},ao=Array.from(Array(256).keys(),o=>o.toString(16).padStart(2,"0")),St=class{static makeHexColor(t,e,n){return`#${ao[t]}${ao[e]}${ao[n]}`}static scaleMinMax(t,e){let n;t[0]?(t[0]<0&&(n=e[0],e[0]=e[2],e[2]=n),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[3],e[3]*=t[3]):(n=e[0],e[0]=e[1],e[1]=n,n=e[2],e[2]=e[3],e[3]=n,t[1]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(n=e[0],e[0]=e[2],e[2]=n),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){let n=t[0]*e[0]+t[1]*e[2]+e[4],r=t[0]*e[1]+t[1]*e[3]+e[5];return[n,r]}static applyInverseTransform(t,e){let n=e[0]*e[3]-e[1]*e[2],r=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/n,a=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/n;return[r,a]}static getAxialAlignedBoundingBox(t,e){let n=this.applyTransform(t,e),r=this.applyTransform(t.slice(2,4),e),a=this.applyTransform([t[0],t[3]],e),c=this.applyTransform([t[2],t[1]],e);return[Math.min(n[0],r[0],a[0],c[0]),Math.min(n[1],r[1],a[1],c[1]),Math.max(n[0],r[0],a[0],c[0]),Math.max(n[1],r[1],a[1],c[1])]}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){let e=[t[0],t[2],t[1],t[3]],n=t[0]*e[0]+t[1]*e[2],r=t[0]*e[1]+t[1]*e[3],a=t[2]*e[0]+t[3]*e[2],c=t[2]*e[1]+t[3]*e[3],u=(n+c)/2,f=Math.sqrt((n+c)**2-4*(n*c-a*r))/2,g=u+f||1,m=u-f||1;return[Math.sqrt(g),Math.sqrt(m)]}static normalizeRect(t){let 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){let n=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),r=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(n>r)return null;let a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),c=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>c?null:[n,a,r,c]}static#t(t,e,n,r,a,c,u,f,g,m){if(g<=0||g>=1)return;let b=1-g,v=g*g,S=v*g,T=b*(b*(b*t+3*g*e)+3*v*n)+S*r,w=b*(b*(b*a+3*g*c)+3*v*u)+S*f;m[0]=Math.min(m[0],T),m[1]=Math.min(m[1],w),m[2]=Math.max(m[2],T),m[3]=Math.max(m[3],w)}static#e(t,e,n,r,a,c,u,f,g,m,b,v){if(Math.abs(g)<1e-12){Math.abs(m)>=1e-12&&this.#t(t,e,n,r,a,c,u,f,-b/m,v);return}let S=m**2-4*b*g;if(S<0)return;let T=Math.sqrt(S),w=2*g;this.#t(t,e,n,r,a,c,u,f,(-m+T)/w,v),this.#t(t,e,n,r,a,c,u,f,(-m-T)/w,v)}static bezierBoundingBox(t,e,n,r,a,c,u,f,g){return g?(g[0]=Math.min(g[0],t,u),g[1]=Math.min(g[1],e,f),g[2]=Math.max(g[2],t,u),g[3]=Math.max(g[3],e,f)):g=[Math.min(t,u),Math.min(e,f),Math.max(t,u),Math.max(e,f)],this.#e(t,n,a,u,e,r,c,f,3*(-t+3*(n-a)+u),6*(t-2*n+a),3*(n-t),g),this.#e(t,n,a,u,e,r,c,f,3*(-e+3*(r-c)+f),6*(e-2*r+c),3*(r-e),g),g}};lo=null,eu=null;_a="pdfjs_internal_id_";G1=Lt(4628),H1=Lt(7642),j1=Lt(8004),V1=Lt(3853),$1=Lt(5876),z1=Lt(2475),W1=Lt(5024),X1=Lt(1698),Y1=Lt(1454),K1=Lt(8992),Z1=Lt(4743),Q1=Lt(3215),J1=Lt(7550),q1=Lt(8335),nn="http://www.w3.org/2000/svg",bn=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};Ss=class o{constructor({viewBox:t,userUnit:e,scale:n,rotation:r,offsetX:a=0,offsetY:c=0,dontFlip:u=!1}){this.viewBox=t,this.userUnit=e,this.scale=n,this.rotation=r,this.offsetX=a,this.offsetY=c,n*=e;let f=(t[2]+t[0])/2,g=(t[3]+t[1])/2,m,b,v,S;switch(r%=360,r<0&&(r+=360),r){case 180:m=-1,b=0,v=0,S=1;break;case 90:m=0,b=1,v=1,S=0;break;case 270:m=0,b=-1,v=-1,S=0;break;case 0:m=1,b=0,v=0,S=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}u&&(v=-v,S=-S);let T,w,I,k;m===0?(T=Math.abs(g-t[1])*n+a,w=Math.abs(f-t[0])*n+c,I=(t[3]-t[1])*n,k=(t[2]-t[0])*n):(T=Math.abs(f-t[0])*n+a,w=Math.abs(g-t[1])*n+c,I=(t[2]-t[0])*n,k=(t[3]-t[1])*n),this.transform=[m*n,b*n,v*n,S*n,T-m*n*f-v*n*g,w-b*n*f-S*n*g],this.width=I,this.height=k}get rawDims(){let{userUnit:t,viewBox:e}=this,n=e.map(r=>r*t);return Ot(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:n=this.offsetX,offsetY:r=this.offsetY,dontFlip:a=!1}={}){return new o({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:a})}convertToViewportPoint(t,e){return St.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=St.applyTransform([t[0],t[1]],this.transform),n=St.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],n[0],n[1]]}convertToPdfPoint(t,e){return St.applyInverseTransform([t,e],this.transform)}},As=class extends yn{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};xr=class{started=Object.create(null);times=[];time(t){t in this.started&&Et(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Et(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:n}of this.times)e=Math.max(n.length,e);for(let{name:n,start:r,end:a}of this.times)t.push(`${n.padEnd(e)} ${a-r}ms
|
|
3
|
+
`);return t.join("")}};Sr=class{static#t;static toDateObject(t){if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let n=parseInt(e[1],10),r=parseInt(e[2],10);r=r>=1&&r<=12?r-1:0;let a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let c=parseInt(e[4],10);c=c>=0&&c<=23?c:0;let u=parseInt(e[5],10);u=u>=0&&u<=59?u:0;let f=parseInt(e[6],10);f=f>=0&&f<=59?f:0;let g=e[7]||"Z",m=parseInt(e[8],10);m=m>=0&&m<=23?m:0;let b=parseInt(e[9],10)||0;return b=b>=0&&b<=59?b:0,g==="-"?(c+=m,u+=b):g==="+"&&(c-=m,u-=b),new Date(Date.UTC(n,r,a,c,u,f))}};Ts=class{constructor(){let t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},go=class o{#t=null;#e=null;#n;#s=null;#i=null;static#r=null;constructor(t){this.#n=t,o.#r||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;t.addEventListener("contextmenu",He,{signal:e}),t.addEventListener("pointerdown",o.#l,{signal:e});let n=this.#s=document.createElement("div");n.className="buttons",t.append(n);let r=this.#n.toolbarPosition;if(r){let{style:a}=t,c=this.#n._uiManager.direction==="ltr"?1-r[0]:r[0];a.insetInlineEnd=`${100*c}%`,a.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#t}static#l(t){t.stopPropagation()}#a(t){this.#n._focusEventsAllowed=!1,Ee(t)}#u(t){this.#n._focusEventsAllowed=!0,Ee(t)}#c(t){let e=this.#n._uiManager._signal;t.addEventListener("focusin",this.#a.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",He,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#i?.shown()}#d(){let{editorType:t,_uiManager:e}=this.#n,n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",o.#r[t]),this.#c(n),n.addEventListener("click",r=>{e.delete()},{signal:e._signal}),this.#s.append(n)}get#h(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#c(e),this.#s.prepend(e,this.#h),this.#i=t}addColorPicker(t){this.#e=t;let e=t.renderButton();this.#c(e),this.#s.prepend(e,this.#h)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},mo=class{#t=null;#e=null;#n;constructor(t){this.#n=t}#s(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",He,{signal:this.#n._signal});let e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#r(),t}#i(t,e){let n=0,r=0;for(let a of t){let c=a.y+a.height;if(c<n)continue;let u=a.x+(e?a.width:0);if(c>n){r=u,n=c;continue}e?u>r&&(r=u):u<r&&(r=u)}return[e?1-r:r,n]}show(t,e,n){let[r,a]=this.#i(e,n),{style:c}=this.#e||=this.#s();t.append(this.#e),c.insetInlineEnd=`${100*r}%`,c.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#r(){let t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let n=this.#n._signal;t.addEventListener("contextmenu",He,{signal:n}),t.addEventListener("click",()=>{this.#n.highlightSelection("floating_button")},{signal:n}),this.#t.append(t)}};bo=class{#t=0;get id(){return`${Jb}${this.#t++}`}},yo=class o{#t=uy();#e=0;#n=null;static get _isSVGFittingCanvas(){let t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',n=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),r=new Image;r.src=t;let a=r.decode().then(()=>(n.drawImage(r,0,0,1,1,0,0,1,3),new Uint32Array(n.getImageData(0,0,1,1).data.buffer)[0]===0));return Ot(this,"_isSVGFittingCanvas",a)}async#s(t,e){this.#n||=new Map;let n=this.#n.get(t);if(n===null)return null;if(n?.bitmap)return n.refCounter+=1,n;try{n||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let r;if(typeof e=="string"?(n.url=e,r=await ti(e,"blob")):e instanceof File?r=n.file=e:e instanceof Blob&&(r=e),r.type==="image/svg+xml"){let a=o._isSVGFittingCanvas,c=new FileReader,u=new Image,f=new Promise((g,m)=>{u.onload=()=>{n.bitmap=u,n.isSvg=!0,g()},c.onload=async()=>{let b=n.svgUrl=c.result;u.src=await a?`${b}#svgView(preserveAspectRatio(none))`:b},u.onerror=c.onerror=m});c.readAsDataURL(r),await f}else n.bitmap=await createImageBitmap(r);n.refCounter=1}catch(r){Et(r),n=null}return this.#n.set(t,n),n&&this.#n.set(n.id,n),n}async getFromFile(t){let{lastModified:e,name:n,size:r,type:a}=t;return this.#s(`${e}_${n}_${r}_${a}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){let n=await e;return this.#s(t,n)}async getFromId(t){this.#n||=new Map;let e=this.#n.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:n}=e;return delete e.blobPromise,this.getFromBlob(e.id,n)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#n||=new Map;let n=this.#n.get(t);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#n.set(t,n),this.#n.set(n.id,n),n}getSvgUrl(t){let e=this.#n.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#n||=new Map;let e=this.#n.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;let{bitmap:n}=e;if(!e.url&&!e.file){let r=new OffscreenCanvas(n.width,n.height);r.getContext("bitmaprenderer").transferFromImageBitmap(n),e.blobPromise=r.convertToBlob()}n.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}},vo=class{#t=[];#e=!1;#n;#s=-1;constructor(t=128){this.#n=t}add({cmd:t,undo:e,post:n,mustExec:r,type:a=NaN,overwriteIfSameType:c=!1,keepUndo:u=!1}){if(r&&t(),this.#e)return;let f={cmd:t,undo:e,post:n,type:a};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(f);return}if(c&&this.#t[this.#s].type===a){u&&(f.undo=this.#t[this.#s].undo),this.#t[this.#s]=f;return}let g=this.#s+1;g===this.#n?this.#t.splice(0,1):(this.#s=g,g<this.#t.length&&this.#t.splice(g)),this.#t.push(f)}undo(){if(this.#s===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(this.#s!==-1){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#s-e),this.#s=e;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}},Ln=class{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=ne.platform;for(let[n,r,a={}]of t)for(let c of n){let u=c.startsWith("mac+");e&&u?(this.callbacks.set(c.slice(4),{callback:r,options:a}),this.allKeys.add(c.split("+").at(-1))):!e&&!u&&(this.callbacks.set(c,{callback:r,options:a}),this.allKeys.add(c.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let n=this.callbacks.get(this.#t(e));if(!n)return;let{callback:r,options:{bubbles:a=!1,args:c=[],checker:u=null}}=n;u&&!u(t,e)||(r.bind(t,...c,e)(),a||Ee(e))}},xo=class o{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return gy(t),Ot(this,"_colors",t)}convert(t){let e=Ua(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[n,r]of this._colors)if(r.every((a,c)=>a===e[c]))return o._colorsMapping.get(n);return e}getHexCode(t){let e=this._colors.get(t);return e?St.makeHexColor(...e):t}},Fn=class o{#t=new AbortController;#e=null;#n=new Map;#s=new Map;#i=null;#r=null;#l=null;#a=new vo;#u=null;#c=null;#d=0;#h=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#b=!1;#x=null;#y=null;#S=null;#T=null;#w=!1;#k=null;#P=new bo;#A=!1;#I=!1;#E=null;#O=null;#F=null;#_=null;#C=Rt.NONE;#v=new Set;#L=null;#H=null;#j=null;#V={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#D=null;#U=null;#$=null;#M=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=o.prototype,e=c=>c.#U.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&c.hasSomethingToControl(),n=(c,{target:u})=>{if(u instanceof HTMLInputElement){let{type:f}=u;return f!=="text"&&f!=="number"}return!0},r=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return Ot(this,"_keyboardManager",new Ln([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],t.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:n}],[["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:n}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(c,{target:u})=>!(u instanceof HTMLButtonElement)&&c.#U.contains(u)&&!c.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(c,{target:u})=>!(u instanceof HTMLButtonElement)&&c.#U.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}constructor(t,e,n,r,a,c,u,f,g,m,b,v,S){let T=this._signal=this.#t.signal;this.#U=t,this.#$=e,this.#i=n,this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:T}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:T}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:T}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:T}),r._on("setpreference",this.onSetPreference.bind(this),{signal:T}),r._on("switchannotationeditorparams",w=>this.updateParams(w.type,w.value),{signal:T}),this.#et(),this.#it(),this.#Y(),this.#r=a.annotationStorage,this.#x=a.filterFactory,this.#H=c,this.#T=u||null,this.#m=f,this.#g=g,this.#b=m,this.#_=b||null,this.viewParameters={realScale:bn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=v||null,this._supportsPinchToZoom=S!==!1}destroy(){this.#M?.resolve(),this.#M=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#s.values())t.destroy();this.#s.clear(),this.#n.clear(),this.#p.clear(),this.#e=null,this.#v.clear(),this.#a.destroy(),this.#i?.destroy(),this.#k?.hide(),this.#k=null,this.#y&&(clearTimeout(this.#y),this.#y=null),this.#D&&(clearTimeout(this.#D),this.#D=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#_}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return Ot(this,"hcmFilter",this.#H?this.#x.addHCMFilter(this.#H.foreground,this.#H.background):"none")}get direction(){return Ot(this,"direction",getComputedStyle(this.#U).direction)}get highlightColors(){return Ot(this,"highlightColors",this.#T?new Map(this.#T.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return Ot(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#c=t}setMainHighlightColorPicker(t){this.#F=t}editAltText(t,e=!1){this.#i?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#b=e;break}}onPageChanging({pageNumber:t}){this.#d=t-1}focusMainContainer(){this.#U.focus()}findParent(t,e){for(let n of this.#s.values()){let{x:r,y:a,width:c,height:u}=n.div.getBoundingClientRect();if(t>=r&&t<=r+c&&e>=a&&e<=a+u)return n}return null}disableUserSelect(t=!1){this.#$.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*bn.PDF_TO_CSS_UNITS;for(let e of this.#p)e.onScaleChanging();this.#c?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#B({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let n of this.#s.values())if(n.hasTextLayer(t))return n;return null}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:c}=e,u=e.toString(),g=this.#B(e).closest(".textLayer"),m=this.getSelectionBoxes(g);if(!m)return;e.empty();let b=this.#X(g),v=this.#C===Rt.NONE,S=()=>{b?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:m,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:c,text:u}),v&&this.showAllEditors("highlight",!0,!0)};if(v){this.switchToMode(Rt.HIGHLIGHT,S);return}S()}#q(){let t=document.getSelection();if(!t||t.isCollapsed)return;let n=this.#B(t).closest(".textLayer"),r=this.getSelectionBoxes(n);r&&(this.#k||=new mo(this),this.#k.show(n,r,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#r&&!this.#r.has(t.id)&&this.#r.setValue(t.id,t)}#tt(){let t=document.getSelection();if(!t||t.isCollapsed){this.#L&&(this.#k?.hide(),this.#L=null,this.#R({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#L)return;let r=this.#B(t).closest(".textLayer");if(!r){this.#L&&(this.#k?.hide(),this.#L=null,this.#R({hasSelectedText:!1}));return}if(this.#k?.hide(),this.#L=e,this.#R({hasSelectedText:!0}),!(this.#C!==Rt.HIGHLIGHT&&this.#C!==Rt.NONE)&&(this.#C===Rt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#w=this.isShiftKeyDown,!this.isShiftKeyDown)){let a=this.#C===Rt.HIGHLIGHT?this.#X(r):null;a?.toggleDrawing();let c=new AbortController,u=this.combinedSignal(c),f=g=>{g.type==="pointerup"&&g.button!==0||(c.abort(),a?.toggleDrawing(!0),g.type==="pointerup"&&this.#W("main_toolbar"))};window.addEventListener("pointerup",f,{signal:u}),window.addEventListener("blur",f,{signal:u})}}#W(t=""){this.#C===Rt.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#q()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#nt(){if(this.#S)return;this.#S=new AbortController;let t=this.combinedSignal(this.#S);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#st(){this.#S?.abort(),this.#S=null}blur(){if(this.isShiftKeyDown=!1,this.#w&&(this.#w=!1,this.#W("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#v)if(e.div.contains(t)){this.#O=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#O)return;let[t,e]=this.#O;this.#O=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Y(){if(this.#E)return;this.#E=new AbortController;let t=this.combinedSignal(this.#E);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#rt(){this.#E?.abort(),this.#E=null}#K(){if(this.#u)return;this.#u=new AbortController;let t=this.combinedSignal(this.#u);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Z(){this.#u?.abort(),this.#u=null}#it(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Y(),this.#K()}removeEditListeners(){this.#rt(),this.#Z()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let n of this.#o)if(n.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let n of this.#o)if(n.isHandlingMimeForPasting(e.type)){n.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let n of this.#v){let r=n.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let a of e.items)for(let c of this.#o)if(c.isHandlingMimeForPasting(a.type)){c.paste(a,this.currentLayer);return}let n=e.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(a){Et(`paste: "${a.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let a=[];for(let f of n){let g=await r.deserialize(f);if(!g)return;a.push(g)}let c=()=>{for(let f of a)this.#Q(f);this.#J(a)},u=()=>{for(let f of a)f.remove()};this.addCommands({cmd:c,undo:u,mustExec:!0})}catch(a){Et(`paste: "${a.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==Rt.NONE&&!this.isEditorHandlingKeyboard&&o._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#w&&(this.#w=!1,this.#W("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([n,r])=>this.#V[n]!==r)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#V,t)}),this.#C===Rt.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#G([[Mt.HIGHLIGHT_FREE,!0]]))}#G(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#nt(),this.#K(),this.#R({isEditing:this.#C!==Rt.NONE,isEmpty:this.#z(),hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:this.#a.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#st(),this.#Z(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#o){this.#o=t;for(let e of this.#o)this.#G(e.defaultPropertiesToUpdate)}}getId(){return this.#P.id}get currentLayer(){return this.#s.get(this.#d)}getLayer(t){return this.#s.get(t)}get currentPageIndex(){return this.#d}addLayer(t){this.#s.set(t.pageIndex,t),this.#A?t.enable():t.disable()}removeLayer(t){this.#s.delete(t.pageIndex)}async updateMode(t,e=null,n=!1){if(this.#C!==t&&!(this.#M&&(await this.#M.promise,!this.#M))){if(this.#M=Promise.withResolvers(),this.#C=t,t===Rt.NONE){this.setEditingState(!1),this.#at(),this._editorUndoBar?.hide(),this.#M.resolve();return}this.setEditingState(!0),await this.#ot(),this.unselectAll();for(let r of this.#s.values())r.updateMode(t);if(!e){n&&this.addNewEditorFromKeyboard(),this.#M.resolve();return}for(let r of this.#n.values())r.annotationElementId===e?(this.setSelected(r),r.enterInEditMode()):r.unselect();this.#M.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#o){switch(t){case Mt.CREATE:this.currentLayer.addNewEditor();return;case Mt.HIGHLIGHT_DEFAULT_COLOR:this.#F?.updateColor(e);break;case Mt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#j||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(let n of this.#v)n.updateParams(t,e);for(let n of this.#o)n.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){for(let a of this.#n.values())a.editorType===t&&a.show(e);(this.#j?.get(Mt.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#G([[Mt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#I!==t){this.#I=t;for(let e of this.#s.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#ot(){if(!this.#A){this.#A=!0;let t=[];for(let e of this.#s.values())t.push(e.enable());await Promise.all(t);for(let e of this.#n.values())e.enable()}}#at(){if(this.unselectAll(),this.#A){this.#A=!1;for(let t of this.#s.values())t.disable();for(let t of this.#n.values())t.disable()}}getEditors(t){let e=[];for(let n of this.#n.values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.focusMainContainer(),this.#y=null},0)),this.#n.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#h.has(t.annotationElementId))&&this.#r?.remove(t.id)}addDeletedAnnotationElement(t){this.#h.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#h.has(t)}removeDeletedAnnotationElement(t){this.#h.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){let e=this.#s.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#G(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#lt===t&&this.#G(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#G(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#v.has(t)){this.#v.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){this.#c?.commitOrRemove();for(let e of this.#v)e!==t&&e.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#a.undo(),this.#R({hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#z()}),this._editorUndoBar?.hide()}redo(){this.#a.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#a.hasSomethingToRedo(),isEmpty:this.#z()})}addCommands(t){this.#a.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#z()})}cleanUndoStack(t){this.#a.cleanType(t)}#z(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let t of this.#n.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#v],n=()=>{this._editorUndoBar?.show(r,e.length===1?e[0].editorType:e.length);for(let a of e)a.remove()},r=()=>{for(let a of e)this.#Q(a)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#J(t){for(let e of this.#v)e.unselect();this.#v.clear();for(let e of t)e.isEmpty()||(this.#v.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#v)t.commit();this.#J(this.#n.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==Rt.NONE))&&!this.#c?.commitOrRemove()&&this.hasSelection){for(let t of this.#v)t.unselect();this.#v.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=e;let[r,a]=this.#N,c=[...this.#v],u=1e3;this.#D&&clearTimeout(this.#D),this.#D=setTimeout(()=>{this.#D=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(let f of c)this.#n.has(f.id)&&f.translateInPage(r,a)},undo:()=>{for(let f of c)this.#n.has(f.id)&&f.translateInPage(-r,-a)},mustExec:!1})},u);for(let f of c)f.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let t of this.#v)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let t=this.#f;this.#f=null;let e=!1;for(let[{x:r,y:a,pageIndex:c},u]of t)u.newX=r,u.newY=a,u.newPageIndex=c,e||=r!==u.savedX||a!==u.savedY||c!==u.savedPageIndex;if(!e)return!1;let n=(r,a,c,u)=>{if(this.#n.has(r.id)){let f=this.#s.get(u);f?r._setParentAndPosition(f,a,c):(r.pageIndex=u,r.x=a,r.y=c)}};return this.addCommands({cmd:()=>{for(let[r,{newX:a,newY:c,newPageIndex:u}]of t)n(r,a,c,u)},undo:()=>{for(let[r,{savedX:a,savedY:c,savedPageIndex:u}]of t)n(r,a,c,u)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(let n of this.#f.keys())n.drag(t,e)}rebuild(t){if(t.parent===null){let 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()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}get imageManager(){return Ot(this,"imageManager",new yo)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let g=0,m=e.rangeCount;g<m;g++)if(!t.contains(e.getRangeAt(g).commonAncestorContainer))return null;let{x:n,y:r,width:a,height:c}=t.getBoundingClientRect(),u;switch(t.getAttribute("data-main-rotation")){case"90":u=(g,m,b,v)=>({x:(m-r)/c,y:1-(g+b-n)/a,width:v/c,height:b/a});break;case"180":u=(g,m,b,v)=>({x:1-(g+b-n)/a,y:1-(m+v-r)/c,width:b/a,height:v/c});break;case"270":u=(g,m,b,v)=>({x:1-(m+v-r)/c,y:(g-n)/a,width:v/c,height:b/a});break;default:u=(g,m,b,v)=>({x:(g-n)/a,y:(m-r)/c,width:b/a,height:v/c});break}let f=[];for(let g=0,m=e.rangeCount;g<m;g++){let b=e.getRangeAt(g);if(!b.collapsed)for(let{x:v,y:S,width:T,height:w}of b.getClientRects())T===0||w===0||f.push(u(v,S,T,w))}return f.length===0?null:f}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#l||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#l?.delete(t)}renderAnnotationElement(t){let e=this.#l?.get(t.data.id);if(!e)return;let n=this.#r.getRawValue(e);n&&(this.#C===Rt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(t))}},Tr=class o{#t=null;#e=!1;#n=null;#s=null;#i=null;#r=null;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=!1;static#f=null;static _l10n=null;constructor(t){this.#u=t,this.#h=t._uiManager.useNewAltTextFlow,o.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){o._l10n??=t}async render(){let t=this.#n=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#s=document.createElement("span");t.append(e),this.#h?(t.classList.add("new"),t.setAttribute("data-l10n-id",o.#f.missing),e.setAttribute("data-l10n-id",o.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let n=this.#u._uiManager._signal;t.addEventListener("contextmenu",He,{signal:n}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:n});let r=a=>{a.preventDefault(),this.#u._uiManager.editAltText(this.#u),this.#h&&this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#o}})};return t.addEventListener("click",r,{capture:!0,signal:n}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(this.#l=!0,r(a))},{signal:n}),await this.#p(),t}get#o(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#l}),this.#l=!1)}isEmpty(){return this.#h?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#h?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){this.#t===null&&(this.#c=t,this.#d=await o._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())}toggleAltTextBadge(t=!1){if(!this.#h||this.#t){this.#a?.remove(),this.#a=null;return}if(!this.#a){let e=this.#a=document.createElement("div");e.className="noAltTextBadge",this.#u.div.append(e)}this.#a.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#c===e&&(e=this.#d),{altText:e,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#d}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:r,cancel:a=!1}){n&&(this.#c=n,this.#d=r),!(this.#t===t&&this.#e===e)&&(a||(this.#t=t,this.#e=e),this.#p())}toggle(t=!1){this.#n&&(!t&&this.#r&&(clearTimeout(this.#r),this.#r=null),this.#n.disabled=!t)}shown(){this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#n?.remove(),this.#n=null,this.#s=null,this.#i=null,this.#a?.remove(),this.#a=null}async#p(){let t=this.#n;if(!t)return;if(this.#h){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",o.#f[this.#o]),this.#s?.setAttribute("data-l10n-id",o.#f[`${this.#o}-label`]),!this.#t){this.#i?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#i?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#i;if(!e){this.#i=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#u.id}`;let r=100,a=this.#u._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(this.#r),this.#r=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#r=setTimeout(()=>{this.#r=null,this.#i.classList.add("show"),this.#u._reportTelemetry({action:"alt_text_tooltip"})},r)},{signal:a}),t.addEventListener("mouseleave",()=>{this.#r&&(clearTimeout(this.#r),this.#r=null),this.#i?.classList.remove("show")},{signal:a})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#u.getImageForAltText()?.setAttribute("aria-describedby",e.id)}},Cr=class o{#t;#e=!1;#n=null;#s;#i;#r;#l;#a;#u=null;#c;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:a=null,onPinchEnd:c=null,signal:u}){this.#t=t,this.#n=n,this.#s=e,this.#i=r,this.#r=a,this.#l=c,this.#c=new AbortController,this.#a=AbortSignal.any([u,this.#c.signal]),t.addEventListener("touchstart",this.#h.bind(this),{passive:!1,signal:this.#a})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Ot(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#h(t){if(this.#s?.()||t.touches.length<2)return;if(!this.#d){this.#d=new AbortController;let r=AbortSignal.any([this.#a,this.#d.signal]),a=this.#t,c={signal:r,passive:!1};a.addEventListener("touchmove",this.#f.bind(this),c),a.addEventListener("touchend",this.#o.bind(this),c),a.addEventListener("touchcancel",this.#o.bind(this),c),this.#i?.()}if(Ee(t),t.touches.length!==2||this.#n?.()){this.#u=null;return}let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]),this.#u={touch0X:e.screenX,touch0Y:e.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#f(t){if(!this.#u||t.touches.length!==2)return;let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]);let{screenX:r,screenY:a}=e,{screenX:c,screenY:u}=n,f=this.#u,{touch0X:g,touch0Y:m,touch1X:b,touch1Y:v}=f,S=b-g,T=v-m,w=c-r,I=u-a,k=Math.hypot(w,I)||1,O=Math.hypot(S,T)||1;if(!this.#e&&Math.abs(O-k)<=o.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(f.touch0X=r,f.touch0Y=a,f.touch1X=c,f.touch1Y=u,t.preventDefault(),!this.#e){this.#e=!0;return}let F=[(r+c)/2,(a+u)/2];this.#r?.(F,O,k)}#o(t){this.#d.abort(),this.#d=null,this.#l?.(),this.#u&&(t.preventDefault(),this.#u=null,this.#e=!1)}destroy(){this.#c?.abort(),this.#c=null}},Xt=class o{#t=null;#e=null;#n=null;#s=!1;#i=null;#r="";#l=!1;#a=null;#u=null;#c=null;#d=null;#h="";#f=!1;#o=null;#p=!1;#m=!1;#g=!1;#b=null;#x=0;#y=0;#S=null;#T=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#w=!1;#k=o._zIndex++;static _borderLineWidth=-1;static _colorManager=new xo;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=o.prototype._resizeWithKeyboard,e=Fn.TRANSLATE_SMALL,n=Fn.TRANSLATE_BIG;return Ot(this,"_resizerKeyboardManager",new Ln([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,n]}],[["Escape","mac+Escape"],o.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;let{rotation:e,rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:c}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[a,c];let[u,f]=this.parentDimensions;this.x=t.x/u,this.y=t.y/f,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Ot(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new So({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(o._l10n??=t,o._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),o._borderLineWidth!==-1)return;let n=getComputedStyle(document.documentElement);o._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){$t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#w}set _isDraggable(t){this.#w=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#k}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#B(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,n,r){let[a,c]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(t+n)/a,this.y=(e+r)/c,this.fixAndSetPosition()}#P([t,e],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/t,this.y+=r/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#P(this.parentDimensions,t,e)}translateInPage(t,e){this.#o||=[this.x,this.y,this.width,this.height],this.#P(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#o||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,a]}=this;if(this.x+=t/r,this.y+=e/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:b,y:v}=this.div.getBoundingClientRect();this.parent.findNewParent(this,b,v)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:c,y:u}=this,[f,g]=this.getBaseTranslation();c+=f,u+=g;let{style:m}=n;m.left=`${(100*c).toFixed(2)}%`,m.top=`${(100*u).toFixed(2)}%`,this._onTranslating(c,u),n.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:n}=o,r=n/t,a=n/e;switch(this.rotation){case 90:return[-r,a];case 180:return[r,a];case 270:return[r,-a];default:return[-r,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[n,r]}=this,{x:a,y:c,width:u,height:f}=this;if(u*=n,f*=r,a*=n,c*=r,this._mustFixPosition)switch(t){case 0:a=Math.max(0,Math.min(n-u,a)),c=Math.max(0,Math.min(r-f,c));break;case 90:a=Math.max(0,Math.min(n-f,a)),c=Math.min(r,Math.max(u,c));break;case 180:a=Math.min(n,Math.max(u,a)),c=Math.min(r,Math.max(f,c));break;case 270:a=Math.min(n,Math.max(f,a)),c=Math.max(0,Math.min(r-u,c));break}this.x=a/=n,this.y=c/=r;let[g,m]=this.getBaseTranslation();a+=g,c+=m,e.left=`${(100*a).toFixed(2)}%`,e.top=`${(100*c).toFixed(2)}%`,this.moveInDOM()}static#A(t,e,n){switch(n){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return o.#A(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return o.#A(t,e,360-this.parentRotation)}#I(t){switch(t){case 90:{let[e,n]=this.pageDimensions;return[0,-e/n,n/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,n]=this.pageDimensions;return[0,e/n,-n/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,n]}=this;return[e*t,n*t]}setDims(t,e){let[n,r]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*t/n).toFixed(2)}%`,this.#l||(a.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:n}=t,r=n.endsWith("%"),a=!this.#l&&e.endsWith("%");if(r&&a)return;let[c,u]=this.parentDimensions;r||(t.width=`${(100*parseFloat(n)/c).toFixed(2)}%`),!this.#l&&!a&&(t.height=`${(100*parseFloat(e)/u).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#E(){if(this.#a)return;this.#a=document.createElement("div"),this.#a.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let n of t){let r=document.createElement("div");this.#a.append(r),r.classList.add("resizer",n),r.setAttribute("data-resizer-name",n),r.addEventListener("pointerdown",this.#O.bind(this,n),{signal:e}),r.addEventListener("contextmenu",He,{signal:e}),r.tabIndex=-1}this.div.prepend(this.#a)}#O(t,e){e.preventDefault();let{isMac:n}=ne.platform;if(e.button!==0||e.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#u=[e.screenX,e.screenY];let a=new AbortController,c=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#C.bind(this,t),{passive:!0,capture:!0,signal:c}),window.addEventListener("touchmove",Ee,{passive:!1,signal:c}),window.addEventListener("contextmenu",He,{signal:c}),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let u=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let g=()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=u,this.div.style.cursor=f,this.#_()};window.addEventListener("pointerup",g,{signal:c}),window.addEventListener("blur",g,{signal:c})}#F(t,e,n,r){this.width=n,this.height=r,this.x=t,this.y=e;let[a,c]=this.parentDimensions;this.setDims(a*n,c*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#_(){if(!this.#c)return;let{savedX:t,savedY:e,savedWidth:n,savedHeight:r}=this.#c;this.#c=null;let a=this.x,c=this.y,u=this.width,f=this.height;a===t&&c===e&&u===n&&f===r||this.addCommands({cmd:this.#F.bind(this,a,c,u,f),undo:this.#F.bind(this,t,e,n,r),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#C(t,e){let[n,r]=this.parentDimensions,a=this.x,c=this.y,u=this.width,f=this.height,g=o.MIN_SIZE/n,m=o.MIN_SIZE/r,b=this.#I(this.rotation),v=(Y,K)=>[b[0]*Y+b[2]*K,b[1]*Y+b[3]*K],S=this.#I(360-this.rotation),T=(Y,K)=>[S[0]*Y+S[2]*K,S[1]*Y+S[3]*K],w,I,k=!1,O=!1;switch(t){case"topLeft":k=!0,w=(Y,K)=>[0,0],I=(Y,K)=>[Y,K];break;case"topMiddle":w=(Y,K)=>[Y/2,0],I=(Y,K)=>[Y/2,K];break;case"topRight":k=!0,w=(Y,K)=>[Y,0],I=(Y,K)=>[0,K];break;case"middleRight":O=!0,w=(Y,K)=>[Y,K/2],I=(Y,K)=>[0,K/2];break;case"bottomRight":k=!0,w=(Y,K)=>[Y,K],I=(Y,K)=>[0,0];break;case"bottomMiddle":w=(Y,K)=>[Y/2,K],I=(Y,K)=>[Y/2,0];break;case"bottomLeft":k=!0,w=(Y,K)=>[0,K],I=(Y,K)=>[Y,0];break;case"middleLeft":O=!0,w=(Y,K)=>[0,K/2],I=(Y,K)=>[Y,K/2];break}let F=w(u,f),_=I(u,f),D=v(..._),G=o._round(a+D[0]),j=o._round(c+D[1]),W=1,$=1,Z,q;if(e.fromKeyboard)({deltaX:Z,deltaY:q}=e);else{let{screenX:Y,screenY:K}=e,[bt,lt]=this.#u;[Z,q]=this.screenToPageTranslation(Y-bt,K-lt),this.#u[0]=Y,this.#u[1]=K}if([Z,q]=T(Z/n,q/r),k){let Y=Math.hypot(u,f);W=$=Math.max(Math.min(Math.hypot(_[0]-F[0]-Z,_[1]-F[1]-q)/Y,1/u,1/f),g/u,m/f)}else O?W=Math.max(g,Math.min(1,Math.abs(_[0]-F[0]-Z)))/u:$=Math.max(m,Math.min(1,Math.abs(_[1]-F[1]-q)))/f;let yt=o._round(u*W),et=o._round(f*$);D=v(...I(yt,et));let Tt=G-D[0],dt=j-D[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=yt,this.height=et,this.x=Tt,this.y=dt,this.setDims(n*yt,r*et),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new go(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(Tr.initialize(o._l10n),this.#n=new Tr(this),this.#t&&(this.#n.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(t){this.#n&&(this.#n.data=t)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(t){await this.#n?.setGuessedText(t)}serializeAltText(t){return this.#n?.serialize(t)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}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.#s?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#N();let[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);let[n,r]=this.getInitialTranslation();return this.translate(n,r),Ar(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#T||=new Cr({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#v.bind(this),onPinching:this.#L.bind(this),onPinchEnd:this.#H.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#v(){this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#L(t,e,n){let a=.7*(n/e)+1-.7;if(a===1)return;let c=this.#I(this.rotation),u=(G,j)=>[c[0]*G+c[2]*j,c[1]*G+c[3]*j],[f,g]=this.parentDimensions,m=this.x,b=this.y,v=this.width,S=this.height,T=o.MIN_SIZE/f,w=o.MIN_SIZE/g;a=Math.max(Math.min(a,1/v,1/S),T/v,w/S);let I=o._round(v*a),k=o._round(S*a);if(I===v&&k===S)return;this.#o||=[m,b,v,S];let O=u(v/2,S/2),F=o._round(m+O[0]),_=o._round(b+O[1]),D=u(I/2,k/2);this.x=F-D[0],this.y=_-D[1],this.width=I,this.height=k,this.setDims(f*I,g*k),this.fixAndSetPosition(),this._onResizing()}#H(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#_()}pointerdown(t){let{isMac:e}=ne.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#V(t);return}this.#j(t)}get isSelected(){return this._uiManager.isSelected(this)}#j(t){let{isMac:e}=ne.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#V(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,a=this._uiManager.combinedSignal(r),c={capture:!0,passive:!1,signal:a},u=g=>{r.abort(),this.#i=null,this.#f=!1,this._uiManager.endDragSession()||this.#j(g),n&&this._onStopDragging()};e&&(this.#x=t.clientX,this.#y=t.clientY,this.#i=t.pointerId,this.#r=t.pointerType,window.addEventListener("pointermove",g=>{n||(n=!0,this._onStartDragging());let{clientX:m,clientY:b,pointerId:v}=g;if(v!==this.#i){Ee(g);return}let[S,T]=this.screenToPageTranslation(m-this.#x,b-this.#y);this.#x=m,this.#y=b,this._uiManager.dragSelectedEditors(S,T)},c),window.addEventListener("touchmove",Ee,c),window.addEventListener("pointerdown",g=>{g.pointerType===this.#r&&(this.#T||g.isPrimary)&&u(g),Ee(g)},c));let f=g=>{if(!this.#i||this.#i===g.pointerId){u(g);return}Ee(g)};window.addEventListener("pointerup",f,{signal:a}),window.addEventListener("blur",f,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,n){t.changeParent(this),this.x=e,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,n=this.rotation){let r=this.parentScale,[a,c]=this.pageDimensions,[u,f]=this.pageTranslation,g=t/r,m=e/r,b=this.x*a,v=this.y*c,S=this.width*a,T=this.height*c;switch(n){case 0:return[b+g+u,c-v-m-T+f,b+g+S+u,c-v-m+f];case 90:return[b+m+u,c-v+g+f,b+m+T+u,c-v+g+S+f];case 180:return[b-g-S+u,c-v+m+f,b-g+u,c-v+m+T+f];case 270:return[b-m-T+u,c-v-g-S+f,b-m+u,c-v-g+f];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[n,r,a,c]=t,u=a-n,f=c-r;switch(this.rotation){case 0:return[n,e-c,u,f];case 90:return[n,e-r,f,u];case 180:return[a,e-r,u,f];case 270:return[a,e-c,f,u];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:a,innerWidth:c}=window;return e<c&&r>0&&t<a&&n>0}#N(){if(this.#d||!this.div)return;this.#d=new AbortController;let t=this._uiManager.combinedSignal(this.#d);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#N()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){$t("An editor must be serializable")}static async deserialize(t,e,n){let r=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:n});r.rotation=t.rotation,r.#t=t.accessibilityData;let[a,c]=r.pageDimensions,[u,f,g,m]=r.getRectInCurrentCoords(t.rect,c);return r.x=u/a,r.y=f/c,r.width=g/a,r.height=m/c,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#d?.abort(),this.#d=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#B(),this.removeEditToolbar(),this.#S){for(let t of this.#S.values())clearTimeout(t);this.#S=null}this.parent=null,this.#T?.destroy(),this.#T=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#E(),this.#a.classList.remove("hidden"),Ar(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#a.children;if(!this.#e){this.#e=Array.from(e);let c=this.#D.bind(this),u=this.#U.bind(this),f=this._uiManager._signal;for(let g of this.#e){let m=g.getAttribute("data-resizer-name");g.setAttribute("role","spinbutton"),g.addEventListener("keydown",c,{signal:f}),g.addEventListener("blur",u,{signal:f}),g.addEventListener("focus",this.#$.bind(this,m),{signal:f}),g.setAttribute("data-l10n-id",o._l10nResizer[m])}}let n=this.#e[0],r=0;for(let c of e){if(c===n)break;r++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(a!==r){if(a<r)for(let u=0;u<r-a;u++)this.#a.append(this.#a.firstChild);else if(a>r)for(let u=0;u<a-r;u++)this.#a.firstChild.before(this.#a.lastChild);let c=0;for(let u of e){let g=this.#e[c++].getAttribute("data-resizer-name");u.setAttribute("data-l10n-id",o._l10nResizer[g])}}this.#M(0),this.#g=!0,this.#a.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#D(t){o._resizerKeyboardManager.exec(this,t)}#U(t){this.#g&&t.relatedTarget?.parentNode!==this.#a&&this.#B()}#$(t){this.#h=this.#g?t:""}#M(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#C(this.#h,{deltaX:t,deltaY:e,fromKeyboard:!0})}#B(){this.#g=!1,this.#M(-1),this.#_()}_stopResizingWithKeyboard(){this.#B(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#a?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#l=!0;let n=t/e,{style:r}=this.div;r.aspectRatio=n,r.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.#S||=new Map;let{action:n}=t,r=this.#S.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(n),this.#S.size===0&&(this.#S=null)},o._telemetryTimeout),this.#S.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#s=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#s=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let n=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),n.before(e)}return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}},So=class extends Xt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},nu=3285377520,Oe=4294901760,Ke=65535,wr=class{constructor(t){this.h1=t?t&4294967295:nu,this.h2=t?t&4294967295:nu}update(t){let e,n;if(typeof t=="string"){e=new Uint8Array(t.length*2),n=0;for(let w=0,I=t.length;w<I;w++){let k=t.charCodeAt(w);k<=255?e[n++]=k:(e[n++]=k>>>8,e[n++]=k&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),n=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let r=n>>2,a=n-r*4,c=new Uint32Array(e.buffer,0,r),u=0,f=0,g=this.h1,m=this.h2,b=3432918353,v=461845907,S=b&Ke,T=v&Ke;for(let w=0;w<r;w++)w&1?(u=c[w],u=u*b&Oe|u*S&Ke,u=u<<15|u>>>17,u=u*v&Oe|u*T&Ke,g^=u,g=g<<13|g>>>19,g=g*5+3864292196):(f=c[w],f=f*b&Oe|f*S&Ke,f=f<<15|f>>>17,f=f*v&Oe|f*T&Ke,m^=f,m=m<<13|m>>>19,m=m*5+3864292196);switch(u=0,a){case 3:u^=e[r*4+2]<<16;case 2:u^=e[r*4+1]<<8;case 1:u^=e[r*4],u=u*b&Oe|u*S&Ke,u=u<<15|u>>>17,u=u*v&Oe|u*T&Ke,r&1?g^=u:m^=u}this.h1=g,this.h2=m}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Oe|t*36045&Ke,e=e*4283543511&Oe|((e<<16|t>>>16)*2950163797&Oe)>>>16,t^=e>>>1,t=t*444984403&Oe|t*60499&Ke,e=e*3301882366&Oe|((e<<16|t>>>16)*3120437893&Oe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}},Ao=Object.freeze({map:null,hash:"",transfer:void 0}),Cs=class{#t=!1;#e=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let n=this.#n.get(t);return n===void 0?e:Object.assign(e,n)}getRawValue(t){return this.#n.get(t)}remove(t){if(this.#n.delete(t),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let e of this.#n.values())if(e instanceof Xt)return;this.onAnnotationEditor(null)}}setValue(t,e){let n=this.#n.get(t),r=!1;if(n!==void 0)for(let[a,c]of Object.entries(e))n[a]!==c&&(r=!0,n[a]=c);else r=!0,this.#n.set(t,e);r&&this.#s(),e instanceof Xt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#n.has(t)}getAll(){return this.#n.size>0?Da(this.#n):null}setAll(t){for(let[e,n]of Object.entries(t))this.setValue(e,n)}get size(){return this.#n.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Er(this)}get serializable(){if(this.#n.size===0)return Ao;let t=new Map,e=new wr,n=[],r=Object.create(null),a=!1;for(let[c,u]of this.#n){let f=u instanceof Xt?u.serialize(!1,r):u;f&&(t.set(c,f),e.update(`${c}:${JSON.stringify(f)}`),a||=!!f.bitmap)}if(a)for(let c of t.values())c.bitmap&&n.push(c.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:n}:Ao}get editorStats(){let t=null,e=new Map;for(let n of this.#n.values()){if(!(n instanceof Xt))continue;let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(n).constructor),t||=Object.create(null);let c=t[a]||=new Map;for(let[u,f]of Object.entries(r)){if(u==="type")continue;let g=c.get(u);g||(g=new Map,c.set(u,g));let m=g.get(f)??0;g.set(f,m+1)}}for(let[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;let t=[];for(let e of this.#n.values())!(e instanceof Xt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}},Er=class extends Cs{#t;constructor(t){super();let{map:e,hash:n,transfer:r}=t.serializable,a=structuredClone(e,r?{transfer:r}:null);this.#t={map:a,hash:n,transfer:r}}get print(){$t("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return Ot(this,"modifiedIds",{ids:new Set,hash:""})}},To=class{#t=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));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(te(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:r,style:a}=t,c=new FontFace(n,r,a);this.addNativeFontFace(c);try{await c.load(),this.#t.add(n),e?.(t)}catch{Et(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(c)}return}$t("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let n=t.createNativeFontFace();if(n){this.addNativeFontFace(n);try{await n.loaded}catch(r){throw Et(`Failed to load font '${n.family}': '${r}'.`),t.disableFontFace=!0,r}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(n=>{let r=this._queueLoadingCallback(n);this._prepareFontLoadEvent(t,r)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return Ot(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ue||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Ot(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(te(!r.done,"completeRequest() cannot be called twice."),r.done=!0;n.length>0&&n[0].done;){let a=n.shift();setTimeout(a.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:e,callback:t};return n.push(r),r}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Ot(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function n(_,D){return _.charCodeAt(D)<<24|_.charCodeAt(D+1)<<16|_.charCodeAt(D+2)<<8|_.charCodeAt(D+3)&255}function r(_,D,G,j){let W=_.substring(0,D),$=_.substring(D+G);return W+j+$}let a,c,u=this._document.createElement("canvas");u.width=1,u.height=1;let f=u.getContext("2d"),g=0;function m(_,D){if(++g>30){Et("Load test font never loaded."),D();return}if(f.font="30px "+_,f.fillText(".",0,20),f.getImageData(0,0,1,1).data[3]>0){D();return}setTimeout(m.bind(null,_,D))}let b=`lt${Date.now()}${this.loadTestFontId++}`,v=this._loadTestFont;v=r(v,976,b.length,b);let T=16,w=1482184792,I=n(v,T);for(a=0,c=b.length-3;a<c;a+=4)I=I-w+n(b,a)|0;a<b.length&&(I=I-w+n(b+"XXX",a)|0),v=r(v,T,4,iy(I));let k=`url(data:font/opentype;base64,${btoa(v)});`,O=`@font-face {font-family:"${b}";src:${k}}`;this.insertRule(O);let F=this._document.createElement("div");F.style.visibility="hidden",F.style.width=F.style.height="10px",F.style.position="absolute",F.style.top=F.style.left="0px";for(let _ of[t.loadedName,b]){let D=this._document.createElement("span");D.textContent="Hi",D.style.fontFamily=_,F.append(D)}this._document.body.append(F),m(b,()=>{F.remove(),e.complete()})}},Co=class{constructor(t,{disableFontFace:e=!1,fontExtraProperties:n=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let a in t)this[a]=t[a];this.disableFontFace=e===!0,this.fontExtraProperties=n===!0,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${hy(this.data)});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let n=this.loadedName+"_path_"+e,r;try{r=t.get(n)}catch(c){Et(`getPathGenerator - ignoring character: "${c}".`)}let a=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=a}},fr={DATA:1,ERROR:2},qt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};Pn=class{#t=new AbortController;constructor(t,e,n){this.sourceName=t,this.targetName=e,this.comObj=n,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),n.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#s(t);return}if(t.callback){let n=t.callbackId,r=this.callbackCapabilities[n];if(!r)throw new Error(`Cannot resolve callback ${n}`);if(delete this.callbackCapabilities[n],t.callback===fr.DATA)r.resolve(t.data);else if(t.callback===fr.ERROR)r.reject(ve(t.reason));else throw new Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let n=this.sourceName,r=t.sourceName,a=this.comObj;Promise.try(e,t.data).then(function(c){a.postMessage({sourceName:n,targetName:r,callback:fr.DATA,callbackId:t.callbackId,data:c})},function(c){a.postMessage({sourceName:n,targetName:r,callback:fr.ERROR,callbackId:t.callbackId,reason:ve(c)})});return}if(t.streamId){this.#n(t);return}e(t.data)}on(t,e){let n=this.actionHandler;if(n[t])throw new Error(`There is already an actionName called "${t}"`);n[t]=e}send(t,e,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},n)}sendWithPromise(t,e,n){let r=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[r]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},n)}catch(c){a.reject(c)}return a.promise}sendWithStream(t,e,n,r){let a=this.streamId++,c=this.sourceName,u=this.targetName,f=this.comObj;return new ReadableStream({start:g=>{let m=Promise.withResolvers();return this.streamControllers[a]={controller:g,startCall:m,pullCall:null,cancelCall:null,isClosed:!1},f.postMessage({sourceName:c,targetName:u,action:t,streamId:a,data:e,desiredSize:g.desiredSize},r),m.promise},pull:g=>{let m=Promise.withResolvers();return this.streamControllers[a].pullCall=m,f.postMessage({sourceName:c,targetName:u,stream:qt.PULL,streamId:a,desiredSize:g.desiredSize}),m.promise},cancel:g=>{te(g instanceof Error,"cancel must have a valid reason");let m=Promise.withResolvers();return this.streamControllers[a].cancelCall=m,this.streamControllers[a].isClosed=!0,f.postMessage({sourceName:c,targetName:u,stream:qt.CANCEL,streamId:a,reason:ve(g)}),m.promise}},n)}#n(t){let e=t.streamId,n=this.sourceName,r=t.sourceName,a=this.comObj,c=this,u=this.actionHandler[t.action],f={enqueue(g,m=1,b){if(this.isCancelled)return;let v=this.desiredSize;this.desiredSize-=m,v>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:n,targetName:r,stream:qt.ENQUEUE,streamId:e,chunk:g},b)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:qt.CLOSE,streamId:e}),delete c.streamSinks[e])},error(g){te(g instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:qt.ERROR,streamId:e,reason:ve(g)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};f.sinkCapability.resolve(),f.ready=f.sinkCapability.promise,this.streamSinks[e]=f,Promise.try(u,t.data,f).then(function(){a.postMessage({sourceName:n,targetName:r,stream:qt.START_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:n,targetName:r,stream:qt.START_COMPLETE,streamId:e,reason:ve(g)})})}#s(t){let e=t.streamId,n=this.sourceName,r=t.sourceName,a=this.comObj,c=this.streamControllers[e],u=this.streamSinks[e];switch(t.stream){case qt.START_COMPLETE:t.success?c.startCall.resolve():c.startCall.reject(ve(t.reason));break;case qt.PULL_COMPLETE:t.success?c.pullCall.resolve():c.pullCall.reject(ve(t.reason));break;case qt.PULL:if(!u){a.postMessage({sourceName:n,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,success:!0});break}u.desiredSize<=0&&t.desiredSize>0&&u.sinkCapability.resolve(),u.desiredSize=t.desiredSize,Promise.try(u.onPull||su).then(function(){a.postMessage({sourceName:n,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:n,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,reason:ve(g)})});break;case qt.ENQUEUE:if(te(c,"enqueue should have stream controller"),c.isClosed)break;c.controller.enqueue(t.chunk);break;case qt.CLOSE:if(te(c,"close should have stream controller"),c.isClosed)break;c.isClosed=!0,c.controller.close(),this.#i(c,e);break;case qt.ERROR:te(c,"error should have stream controller"),c.controller.error(ve(t.reason)),this.#i(c,e);break;case qt.CANCEL_COMPLETE:t.success?c.cancelCall.resolve():c.cancelCall.reject(ve(t.reason)),this.#i(c,e);break;case qt.CANCEL:if(!u)break;let f=ve(t.reason);Promise.try(u.onCancel||su,f).then(function(){a.postMessage({sourceName:n,targetName:r,stream:qt.CANCEL_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:n,targetName:r,stream:qt.CANCEL_COMPLETE,streamId:e,reason:ve(g)})}),u.sinkCapability.reject(f),u.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#i(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}},kr=class{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");let n=this._createCanvas(t,e);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,n){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||n<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=n}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){$t("Abstract method `_createCanvas` called.")}},wo=class extends kr{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let n=this._document.createElement("canvas");return n.width=t,n.height=e,n}},Ir=class{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(n=>({cMapData:n,isCompressed:this.isCompressed})).catch(n=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){$t("Abstract method `_fetch` called.")}},Pr=class extends Ir{async _fetch(t){let e=await ti(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):qr(e)}},tS=Lt(4520),Rr=class{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,n,r,a){return"none"}destroy(t=!1){}},Eo=class extends Rr{#t;#e;#n;#s;#i;#r;#l=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#i=e}get#a(){return this.#e||=new Map}get#u(){return this.#r||=new Map}get#c(){if(!this.#n){let t=this.#i.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;let n=this.#i.createElementNS(nn,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#n=this.#i.createElementNS(nn,"defs"),t.append(n),n.append(this.#n),this.#i.body.append(t)}return this.#n}#d(t){if(t.length===1){let f=t[0],g=new Array(256);for(let b=0;b<256;b++)g[b]=f[b]/255;let m=g.join(",");return[m,m,m]}let[e,n,r]=t,a=new Array(256),c=new Array(256),u=new Array(256);for(let f=0;f<256;f++)a[f]=e[f]/255,c[f]=n[f]/255,u[f]=r[f]/255;return[a.join(","),c.join(","),u.join(",")]}#h(t){if(this.#t===void 0){this.#t="";let e=this.#i.URL;e!==this.#i.baseURI&&(ei(e)?Et('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#a.get(t);if(e)return e;let[n,r,a]=this.#d(t),c=t.length===1?n:`${n}${r}${a}`;if(e=this.#a.get(c),e)return this.#a.set(t,e),e;let u=`g_${this.#s}_transfer_map_${this.#l++}`,f=this.#h(u);this.#a.set(t,f),this.#a.set(c,f);let g=this.#p(u);return this.#g(n,r,a,g),f}addHCMFilter(t,e){let n=`${t}-${e}`,r="base",a=this.#u.get(r);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#u.set(r,a)),!t||!e))return a.url;let c=this.#x(t);t=St.makeHexColor(...c);let u=this.#x(e);if(e=St.makeHexColor(...u),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return a.url;let f=new Array(256);for(let S=0;S<=255;S++){let T=S/255;f[S]=T<=.03928?T/12.92:((T+.055)/1.055)**2.4}let g=f.join(","),m=`g_${this.#s}_hcm_filter`,b=a.filter=this.#p(m);this.#g(g,g,g,b),this.#o(b);let v=(S,T)=>{let w=c[S]/255,I=u[S]/255,k=new Array(T+1);for(let O=0;O<=T;O++)k[O]=w+O/T*(I-w);return k.join(",")};return this.#g(v(0,5),v(1,5),v(2,5),b),a.url=this.#h(m),a.url}addAlphaFilter(t){let e=this.#a.get(t);if(e)return e;let[n]=this.#d([t]),r=`alpha_${n}`;if(e=this.#a.get(r),e)return this.#a.set(t,e),e;let a=`g_${this.#s}_alpha_map_${this.#l++}`,c=this.#h(a);this.#a.set(t,c),this.#a.set(r,c);let u=this.#p(a);return this.#b(n,u),c}addLuminosityFilter(t){let e=this.#a.get(t||"luminosity");if(e)return e;let n,r;if(t?([n]=this.#d([t]),r=`luminosity_${n}`):r="luminosity",e=this.#a.get(r),e)return this.#a.set(t,e),e;let a=`g_${this.#s}_luminosity_map_${this.#l++}`,c=this.#h(a);this.#a.set(t,c),this.#a.set(r,c);let u=this.#p(a);return this.#f(u),t&&this.#b(n,u),c}addHighlightHCMFilter(t,e,n,r,a){let c=`${e}-${n}-${r}-${a}`,u=this.#u.get(t);if(u?.key===c||(u?(u.filter?.remove(),u.key=c,u.url="none",u.filter=null):(u={key:c,url:"none",filter:null},this.#u.set(t,u)),!e||!n))return u.url;let[f,g]=[e,n].map(this.#x.bind(this)),m=Math.round(.2126*f[0]+.7152*f[1]+.0722*f[2]),b=Math.round(.2126*g[0]+.7152*g[1]+.0722*g[2]),[v,S]=[r,a].map(this.#x.bind(this));b<m&&([m,b,v,S]=[b,m,S,v]),this.#c.style.color="";let T=(k,O,F)=>{let _=new Array(256),D=(b-m)/F,G=k/255,j=(O-k)/(255*F),W=0;for(let $=0;$<=F;$++){let Z=Math.round(m+$*D),q=G+$*j;for(let yt=W;yt<=Z;yt++)_[yt]=q;W=Z+1}for(let $=W;$<256;$++)_[$]=_[W-1];return _.join(",")},w=`g_${this.#s}_hcm_${t}_filter`,I=u.filter=this.#p(w);return this.#o(I),this.#g(T(v[0],S[0],5),T(v[1],S[1],5),T(v[2],S[2],5),I),u.url=this.#h(w),u.url}destroy(t=!1){t&&this.#r?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#e?.clear(),this.#e=null,this.#r?.clear(),this.#r=null,this.#l=0)}#f(t){let e=this.#i.createElementNS(nn,"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)}#o(t){let e=this.#i.createElementNS(nn,"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)}#p(t){let e=this.#i.createElementNS(nn,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#m(t,e,n){let r=this.#i.createElementNS(nn,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),t.append(r)}#g(t,e,n,r){let a=this.#i.createElementNS(nn,"feComponentTransfer");r.append(a),this.#m(a,"feFuncR",t),this.#m(a,"feFuncG",e),this.#m(a,"feFuncB",n)}#b(t,e){let n=this.#i.createElementNS(nn,"feComponentTransfer");e.append(n),this.#m(n,"feFuncA",t)}#x(t){return this.#c.style.color=t,Ua(getComputedStyle(this.#c).getPropertyValue("color"))}},Or=class{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(n=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){$t("Abstract method `_fetch` called.")}},Mr=class extends Or{async _fetch(t){let e=await ti(t,"arraybuffer");return new Uint8Array(e)}};if(ue){let o;try{let t=process.getBuiltinModule("module").createRequire(import.meta.url);try{o=t("@napi-rs/canvas")}catch(e){Et(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){Et(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(o?.DOMMatrix?globalThis.DOMMatrix=o.DOMMatrix:Et("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(o?.ImageData?globalThis.ImageData=o.ImageData:Et("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(o?.Path2D?globalThis.Path2D=o.Path2D:Et("Cannot polyfill `Path2D`, rendering may be broken."))}ko=class extends Rr{},Io=class extends kr{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}},Po=class extends Ir{async _fetch(t){return bu(t)}},Ro=class extends Or{async _fetch(t){return bu(t)}},ce={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};ws=class{getPattern(){$t("Abstract method `getPattern` called.")}},Mo=class extends ws{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let n of this._colorStops)e.addColorStop(n[0],n[1]);return e}getPattern(t,e,n,r){let a;if(r===ce.STROKE||r===ce.FILL){let c=e.current.getClippedPathBoundingBox(r,Wt(t))||[0,0,0,0],u=Math.ceil(c[2]-c[0])||1,f=Math.ceil(c[3]-c[1])||1,g=e.cachedCanvases.getCanvas("pattern",u,f),m=g.context;m.clearRect(0,0,m.canvas.width,m.canvas.height),m.beginPath(),m.rect(0,0,m.canvas.width,m.canvas.height),m.translate(-c[0],-c[1]),n=St.transform(n,[1,0,0,1,c[0],c[1]]),m.transform(...e.baseTransform),this.matrix&&m.transform(...this.matrix),Oo(m,this._bbox),m.fillStyle=this._createGradient(m),m.fill(),a=t.createPattern(g.canvas,"no-repeat");let b=new DOMMatrix(n);a.setTransform(b)}else Oo(t,this._bbox),a=this._createGradient(t);return a}};Lo=class extends ws{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,n){let u=Math.floor(this._bounds[0]),f=Math.floor(this._bounds[1]),g=Math.ceil(this._bounds[2])-u,m=Math.ceil(this._bounds[3])-f,b=Math.min(Math.ceil(Math.abs(g*t[0]*1.1)),3e3),v=Math.min(Math.ceil(Math.abs(m*t[1]*1.1)),3e3),S=g/b,T=m/v,w={coords:this._coords,colors:this._colors,offsetX:-u,offsetY:-f,scaleX:1/S,scaleY:1/T},I=b+4,k=v+4,O=n.getCanvas("mesh",I,k),F=O.context,_=F.createImageData(b,v);if(e){let G=_.data;for(let j=0,W=G.length;j<W;j+=4)G[j]=e[0],G[j+1]=e[1],G[j+2]=e[2],G[j+3]=255}for(let G of this._figures)my(_,G,w);return F.putImageData(_,2,2),{canvas:O.canvas,offsetX:u-2*S,offsetY:f-2*T,scaleX:S,scaleY:T}}getPattern(t,e,n,r){Oo(t,this._bbox);let a;if(r===ce.SHADING)a=St.singularValueDecompose2dScale(Wt(t));else if(a=St.singularValueDecompose2dScale(e.baseTransform),this.matrix){let u=St.singularValueDecompose2dScale(this.matrix);a=[a[0]*u[0],a[1]*u[1]]}let c=this._createMeshCanvas(a,r===ce.SHADING?null:this._background,e.cachedCanvases);return r!==ce.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(c.offsetX,c.offsetY),t.scale(c.scaleX,c.scaleY),t.createPattern(c.canvas,"no-repeat")}},Fo=class extends ws{getPattern(){return"hotpink"}};ru={COLORED:1,UNCOLORED:2},Do=class o{static MAX_PATTERN_SIZE=3e3;constructor(t,e,n,r,a){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(t){let{bbox:e,operatorList:n,paintType:r,tilingType:a,color:c,canvasGraphicsFactory:u}=this,{xstep:f,ystep:g}=this;f=Math.abs(f),g=Math.abs(g),Jr("TilingType: "+a);let m=e[0],b=e[1],v=e[2],S=e[3],T=v-m,w=S-b,I=St.singularValueDecompose2dScale(this.matrix),k=St.singularValueDecompose2dScale(this.baseTransform),O=I[0]*k[0],F=I[1]*k[1],_=T,D=w,G=!1,j=!1,W=Math.ceil(f*O),$=Math.ceil(g*F),Z=Math.ceil(T*O),q=Math.ceil(w*F);W>=Z?_=f:G=!0,$>=q?D=g:j=!0;let yt=this.getSizeAndScale(_,this.ctx.canvas.width,O),et=this.getSizeAndScale(D,this.ctx.canvas.height,F),Tt=t.cachedCanvases.getCanvas("pattern",yt.size,et.size),dt=Tt.context,Y=u.createCanvasGraphics(dt);if(Y.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(Y,r,c),dt.translate(-yt.scale*m,-et.scale*b),Y.transform(yt.scale,0,0,et.scale,0,0),dt.save(),this.clipBbox(Y,m,b,v,S),Y.baseTransform=Wt(Y.ctx),Y.executeOperatorList(n),Y.endDrawing(),dt.restore(),G||j){let K=Tt.canvas;G&&(_=f),j&&(D=g);let bt=this.getSizeAndScale(_,this.ctx.canvas.width,O),lt=this.getSizeAndScale(D,this.ctx.canvas.height,F),kt=bt.size,X=lt.size,ot=t.cachedCanvases.getCanvas("pattern-workaround",kt,X),Q=ot.context,nt=G?Math.floor(T/f):0,it=j?Math.floor(w/g):0;for(let V=0;V<=nt;V++)for(let H=0;H<=it;H++)Q.drawImage(K,kt*V,X*H,kt,X,0,0,kt,X);return{canvas:ot.canvas,scaleX:bt.scale,scaleY:lt.scale,offsetX:m,offsetY:b}}return{canvas:Tt.canvas,scaleX:yt.scale,scaleY:et.scale,offsetX:m,offsetY:b}}getSizeAndScale(t,e,n){let r=Math.max(o.MAX_PATTERN_SIZE,e),a=Math.ceil(t*n);return a>=r?a=r:n=a/t,{scale:n,size:a}}clipBbox(t,e,n,r,a){let c=r-e,u=a-n;t.ctx.rect(e,n,c,u),t.current.updateRectMinMax(Wt(t.ctx),[e,n,r,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,n){let r=t.ctx,a=t.current;switch(e){case ru.COLORED:let c=this.ctx;r.fillStyle=c.fillStyle,r.strokeStyle=c.strokeStyle,a.fillColor=c.fillStyle,a.strokeColor=c.strokeStyle;break;case ru.UNCOLORED:let u=St.makeHexColor(n[0],n[1],n[2]);r.fillStyle=u,r.strokeStyle=u,a.fillColor=u,a.strokeColor=u;break;default:throw new po(`Unsupported paint type: ${e}`)}}getPattern(t,e,n,r){let a=n;r!==ce.SHADING&&(a=St.transform(a,e.baseTransform),this.matrix&&(a=St.transform(a,this.matrix)));let c=this.createPatternCanvas(e),u=new DOMMatrix(a);u=u.translate(c.offsetX,c.offsetY),u=u.scale(1/c.scaleX,1/c.scaleY);let f=t.createPattern(c.canvas,"repeat");return f.setTransform(u),f}};iu=16,ou=100,vy=15,au=10,lu=1e3,xe=16;_o=class{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,n){let r;return this.cache[t]!==void 0?(r=this.cache[t],this.canvasFactory.reset(r,e,n)):(r=this.canvasFactory.create(e,n),this.cache[t]=r),r}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}};Lr=class{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=gu,this.textMatrixScale=1,this.fontMatrix=fo,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=le.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,n){[e,n]=St.applyTransform([e,n],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(t,e){let n=St.applyTransform(e,t),r=St.applyTransform(e.slice(2),t),a=St.applyTransform([e[0],e[3]],t),c=St.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,n[0],r[0],a[0],c[0]),this.minY=Math.min(this.minY,n[1],r[1],a[1],c[1]),this.maxX=Math.max(this.maxX,n[0],r[0],a[0],c[0]),this.maxY=Math.max(this.maxY,n[1],r[1],a[1],c[1])}updateScalingPathMinMax(t,e){St.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,n,r,a,c,u,f,g,m){let b=St.bezierBoundingBox(e,n,r,a,c,u,f,g,m);m||this.updateRectMinMax(t,b)}getPathBoundingBox(t=ce.FILL,e=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(t===ce.STROKE){e||$t("Stroke bounding box must include transform.");let r=St.singularValueDecompose2dScale(e),a=r[0]*this.lineWidth/2,c=r[1]*this.lineWidth/2;n[0]-=a,n[1]-=c,n[2]+=a,n[3]+=c}return n}updateClipFromPath(){let t=St.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=ce.FILL,e=null){return St.intersect(this.clipBox,this.getPathBoundingBox(t,e))}};Ay=["butt","round","square"],Ty=["miter","round","bevel"],Cy={},du={},Qn=class o{constructor(t,e,n,r,a,{optionalContentConfig:c,markedContentStack:u=null},f,g){this.ctx=t,this.current=new Lr(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=n,this.canvasFactory=r,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=u||[],this.optionalContentConfig=c,this.cachedCanvases=new _o(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=f,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=g,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:n=!1,background:r=null}){let a=this.ctx.canvas.width,c=this.ctx.canvas.height,u=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,a,c),this.ctx.fillStyle=u,n){let f=this.cachedCanvases.getCanvas("transparent",a,c);this.compositeCtx=this.ctx,this.transparentCanvas=f.canvas,this.ctx=f.context,this.ctx.save(),this.ctx.transform(...Wt(this.compositeCtx))}this.ctx.save(),gr(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Wt(this.ctx)}executeOperatorList(t,e,n,r){let a=t.argsArray,c=t.fnArray,u=e||0,f=a.length;if(f===u)return u;let g=f-u>au&&typeof n=="function",m=g?Date.now()+vy:0,b=0,v=this.commonObjs,S=this.objs,T;for(;;){if(r!==void 0&&u===r.nextBreakPoint)return r.breakIt(u,n),u;if(T=c[u],T!==Ge.dependency)this[T].apply(this,a[u]);else for(let w of a[u]){let I=w.startsWith("g_")?v:S;if(!I.has(w))return I.get(w,n),u}if(u++,u===f)return u;if(g&&++b>au){if(Date.now()>m)return n(),u;b=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let n=t.width??t.displayWidth,r=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),c=Math.max(Math.hypot(e[2],e[3]),1),u=n,f=r,g="prescale1",m,b;for(;a>2&&u>1||c>2&&f>1;){let v=u,S=f;a>2&&u>1&&(v=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u/2),a/=u/v),c>2&&f>1&&(S=f>=16384?Math.floor(f/2)-1||1:Math.ceil(f)/2,c/=f/S),m=this.cachedCanvases.getCanvas(g,v,S),b=m.context,b.clearRect(0,0,v,S),b.drawImage(t,0,0,u,f,0,0,v,S),t=m.canvas,u=v,f=S,g=g==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:u,paintHeight:f}}_createMaskCanvas(t){let e=this.ctx,{width:n,height:r}=t,a=this.current.fillColor,c=this.current.patternFill,u=Wt(e),f,g,m,b;if((t.bitmap||t.data)&&t.count>1){let W=t.bitmap||t.data.buffer;g=JSON.stringify(c?u:[u.slice(0,4),a]),f=this._cachedBitmapsMap.get(W),f||(f=new Map,this._cachedBitmapsMap.set(W,f));let $=f.get(g);if($&&!c){let Z=Math.round(Math.min(u[0],u[2])+u[4]),q=Math.round(Math.min(u[1],u[3])+u[5]);return{canvas:$,offsetX:Z,offsetY:q}}m=$}m||(b=this.cachedCanvases.getCanvas("maskCanvas",n,r),uu(b.context,t));let v=St.transform(u,[1/n,0,0,-1/r,0,0]);v=St.transform(v,[1,0,0,1,0,-r]);let[S,T,w,I]=St.getAxialAlignedBoundingBox([0,0,n,r],v),k=Math.round(w-S)||1,O=Math.round(I-T)||1,F=this.cachedCanvases.getCanvas("fillCanvas",k,O),_=F.context,D=S,G=T;_.translate(-D,-G),_.transform(...v),m||(m=this._scaleImage(b.canvas,Ye(_)),m=m.img,f&&c&&f.set(g,m)),_.imageSmoothingEnabled=hu(Wt(_),t.interpolate),pr(_,m,0,0,m.width,m.height,0,0,n,r),_.globalCompositeOperation="source-in";let j=St.transform(Ye(_),[1,0,0,1,-D,-G]);return _.fillStyle=c?a.getPattern(e,this,j,ce.FILL):a,_.fillRect(0,0,n,r),f&&!c&&(this.cachedCanvases.delete("fillCanvas"),f.set(g,F.canvas)),{canvas:F.canvas,offsetX:Math.round(D),offsetY:Math.round(G)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ay[t]}setLineJoin(t){this.ctx.lineJoin=Ty[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(t),n.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,n]of t)switch(e){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let 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");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,t,e);this.suspendedCtx=this.ctx,this.ctx=r.context;let a=this.ctx;a.setTransform(...Wt(this.suspendedCtx)),gs(this.suspendedCtx,a),xy(a,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(),gs(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];let e=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,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,n,r){let a=r[0],c=r[1],u=r[2]-a,f=r[3]-c;u===0||f===0||(this.genericComposeSMask(e.context,n,u,f,e.subtype,e.backdrop,e.transferMap,a,c,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(n.canvas,0,0),t.restore())}genericComposeSMask(t,e,n,r,a,c,u,f,g,m,b){let v=t.canvas,S=f-m,T=g-b;if(c){let I=St.makeHexColor(...c);if(S<0||T<0||S+n>v.width||T+r>v.height){let k=this.cachedCanvases.getCanvas("maskExtension",n,r),O=k.context;O.drawImage(v,-S,-T),O.globalCompositeOperation="destination-atop",O.fillStyle=I,O.fillRect(0,0,n,r),O.globalCompositeOperation="source-over",v=k.canvas,S=T=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let k=new Path2D;k.rect(S,T,n,r),t.clip(k),t.globalCompositeOperation="destination-atop",t.fillStyle=I,t.fillRect(S,T,n,r),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),a==="Alpha"&&u?e.filter=this.filterFactory.addAlphaFilter(u):a==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(u));let w=new Path2D;w.rect(f,g,n,r),e.clip(w),e.globalCompositeOperation="destination-in",e.drawImage(v,S,T,n,r,f,g,n,r),e.restore()}save(){this.inSMaskMode?(gs(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),gs(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,n,r,a,c){this.ctx.transform(t,e,n,r,a,c),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,n){let r=this.ctx,a=this.current,c=a.x,u=a.y,f,g,m=Wt(r),b=m[0]===0&&m[3]===0||m[1]===0&&m[2]===0,v=b?n.slice(0):null;for(let S=0,T=0,w=t.length;S<w;S++)switch(t[S]|0){case Ge.rectangle:c=e[T++],u=e[T++];let I=e[T++],k=e[T++],O=c+I,F=u+k;r.moveTo(c,u),I===0||k===0?r.lineTo(O,F):(r.lineTo(O,u),r.lineTo(O,F),r.lineTo(c,F)),b||a.updateRectMinMax(m,[c,u,O,F]),r.closePath();break;case Ge.moveTo:c=e[T++],u=e[T++],r.moveTo(c,u),b||a.updatePathMinMax(m,c,u);break;case Ge.lineTo:c=e[T++],u=e[T++],r.lineTo(c,u),b||a.updatePathMinMax(m,c,u);break;case Ge.curveTo:f=c,g=u,c=e[T+4],u=e[T+5],r.bezierCurveTo(e[T],e[T+1],e[T+2],e[T+3],c,u),a.updateCurvePathMinMax(m,f,g,e[T],e[T+1],e[T+2],e[T+3],c,u,v),T+=6;break;case Ge.curveTo2:f=c,g=u,r.bezierCurveTo(c,u,e[T],e[T+1],e[T+2],e[T+3]),a.updateCurvePathMinMax(m,f,g,c,u,e[T],e[T+1],e[T+2],e[T+3],v),c=e[T+2],u=e[T+3],T+=4;break;case Ge.curveTo3:f=c,g=u,c=e[T+2],u=e[T+3],r.bezierCurveTo(e[T],e[T+1],c,u,c,u),a.updateCurvePathMinMax(m,f,g,e[T],e[T+1],c,u,c,u,v),T+=4;break;case Ge.closePath:r.closePath();break}b&&a.updateScalingPathMinMax(m,v),a.setCurrentPoint(c,u)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,n=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n=="object"&&n?.getPattern?(e.save(),e.strokeStyle=n.getPattern(e,this,Ye(e),ce.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){let e=this.ctx,n=this.current.fillColor,r=this.current.patternFill,a=!1;r&&(e.save(),e.fillStyle=n.getPattern(e,this,Ye(e),ce.FILL),a=!0);let c=this.current.getClippedPathBoundingBox();this.contentVisible&&c!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),a&&e.restore(),t&&this.consumePath(c)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Cy}eoClip(){this.pendingClip=du}beginText(){this.current.textMatrix=gu,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}let n=new Path2D,r=e.getTransform().invertSelf();for(let{transform:a,x:c,y:u,fontSize:f,path:g}of t)n.addPath(g,new DOMMatrix(a).preMultiplySelf(r).translate(c,u).scale(f,-f));e.clip(n),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){let n=this.commonObjs.get(t),r=this.current;if(!n)throw new Error(`Can't find font for ${t}`);if(r.fontMatrix=n.fontMatrix||fo,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&Et("Invalid font matrix for font "+t),e<0?(e=-e,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=e,n.isType3Font)return;let a=n.loadedName||"sans-serif",c=n.systemFontInfo?.css||`"${a}", ${n.fallbackName}`,u="normal";n.black?u="900":n.bold&&(u="bold");let f=n.italic?"italic":"normal",g=e;e<iu?g=iu:e>ou&&(g=ou),this.current.fontSizeScale=e/g,this.ctx.font=`${f} ${u} ${g}px ${c}`}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,n,r,a,c){this.current.textMatrix=[t,e,n,r,a,c],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)}#n(t,e,n){let r=new Path2D;return r.addPath(t,new DOMMatrix(n).invertSelf().multiplySelf(e)),r}paintChar(t,e,n,r,a){let c=this.ctx,u=this.current,f=u.font,g=u.textRenderingMode,m=u.fontSize/u.fontSizeScale,b=g&le.FILL_STROKE_MASK,v=!!(g&le.ADD_TO_PATH_FLAG),S=u.patternFill&&!f.missingFile,T=u.patternStroke&&!f.missingFile,w;if((f.disableFontFace||v||S||T)&&(w=f.getPathGenerator(this.commonObjs,t)),f.disableFontFace||S||T){if(c.save(),c.translate(e,n),c.scale(m,-m),b===le.FILL||b===le.FILL_STROKE)if(r){let I=c.getTransform();c.setTransform(...r),c.fill(this.#n(w,I,r))}else c.fill(w);if(b===le.STROKE||b===le.FILL_STROKE)if(a){let I=c.getTransform();c.setTransform(...a),c.stroke(this.#n(w,I,a))}else c.lineWidth/=m,c.stroke(w);c.restore()}else(b===le.FILL||b===le.FILL_STROKE)&&c.fillText(t,e,n),(b===le.STROKE||b===le.FILL_STROKE)&&c.strokeText(t,e,n);v&&(this.pendingTextPaths||=[]).push({transform:Wt(c),x:e,y:n,fontSize:m,path:w})}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,n=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){n=!0;break}return Ot(this,"isFontSubpixelAAEnabled",n)}showText(t){let e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);let r=e.fontSize;if(r===0)return;let a=this.ctx,c=e.fontSizeScale,u=e.charSpacing,f=e.wordSpacing,g=e.fontDirection,m=e.textHScale*g,b=t.length,v=n.vertical,S=v?1:-1,T=n.defaultVMetrics,w=r*e.fontMatrix[0],I=e.textRenderingMode===le.FILL&&!n.disableFontFace&&!e.patternFill;a.save(),a.transform(...e.textMatrix),a.translate(e.x,e.y+e.textRise),g>0?a.scale(m,-1):a.scale(m,1);let k,O;if(e.patternFill){a.save();let j=e.fillColor.getPattern(a,this,Ye(a),ce.FILL);k=Wt(a),a.restore(),a.fillStyle=j}if(e.patternStroke){a.save();let j=e.strokeColor.getPattern(a,this,Ye(a),ce.STROKE);O=Wt(a),a.restore(),a.strokeStyle=j}let F=e.lineWidth,_=e.textMatrixScale;if(_===0||F===0){let j=e.textRenderingMode&le.FILL_STROKE_MASK;(j===le.STROKE||j===le.FILL_STROKE)&&(F=this.getSinglePixelWidth())}else F/=_;if(c!==1&&(a.scale(c,c),F/=c),a.lineWidth=F,n.isInvalidPDFjsFont){let j=[],W=0;for(let $ of t)j.push($.unicode),W+=$.width;a.fillText(j.join(""),0,0),e.x+=W*w*m,a.restore(),this.compose();return}let D=0,G;for(G=0;G<b;++G){let j=t[G];if(typeof j=="number"){D+=S*j*r/1e3;continue}let W=!1,$=(j.isSpace?f:0)+u,Z=j.fontChar,q=j.accent,yt,et,Tt=j.width;if(v){let Y=j.vmetric||T,K=-(j.vmetric?Y[1]:Tt*.5)*w,bt=Y[2]*w;Tt=Y?-Y[0]:Tt,yt=K/c,et=(D+bt)/c}else yt=D/c,et=0;if(n.remeasure&&Tt>0){let Y=a.measureText(Z).width*1e3/r*c;if(Tt<Y&&this.isFontSubpixelAAEnabled){let K=Tt/Y;W=!0,a.save(),a.scale(K,1),yt/=K}else Tt!==Y&&(yt+=(Tt-Y)/2e3*r/c)}if(this.contentVisible&&(j.isInFont||n.missingFile)){if(I&&!q)a.fillText(Z,yt,et);else if(this.paintChar(Z,yt,et,k,O),q){let Y=yt+r*q.offset.x/c,K=et-r*q.offset.y/c;this.paintChar(q.fontChar,Y,K,k,O)}}let dt=v?Tt*w-$*g:Tt*w+$*g;D+=dt,W&&a.restore()}v?e.y-=D:e.x+=D*m,a.restore(),this.compose()}showType3Text(t){let e=this.ctx,n=this.current,r=n.font,a=n.fontSize,c=n.fontDirection,u=r.vertical?1:-1,f=n.charSpacing,g=n.wordSpacing,m=n.textHScale*c,b=n.fontMatrix||fo,v=t.length,S=n.textRenderingMode===le.INVISIBLE,T,w,I,k;if(!(S||a===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...n.textMatrix),e.translate(n.x,n.y),e.scale(m,c),T=0;T<v;++T){if(w=t[T],typeof w=="number"){k=u*w*a/1e3,this.ctx.translate(k,0),n.x+=k*m;continue}let O=(w.isSpace?g:0)+f,F=r.charProcOperatorList[w.operatorListId];if(!F){Et(`Type3 character "${w.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=w,this.save(),e.scale(a,a),e.transform(...b),this.executeOperatorList(F),this.restore()),I=St.applyTransform([w.width,0],b)[0]*a+O,e.translate(I,0),n.x+=I*m}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,n,r,a,c){this.ctx.rect(n,r,a-n,c-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){let n=t[1],r=this.baseTransform||Wt(this.ctx),a={createCanvasGraphics:c=>new o(c,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Do(t,n,this.ctx,a,r)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,n){this.ctx.strokeStyle=this.current.strokeColor=St.makeHexColor(t,e,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,n){this.ctx.fillStyle=this.current.fillColor=St.makeHexColor(t,e,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let n;return this.cachedPatterns.has(t)?n=this.cachedPatterns.get(t):(n=by(this.getObject(t)),this.cachedPatterns.set(t,n)),e&&(n.matrix=e),n}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save();let n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,Ye(e),ce.SHADING);let r=Ye(e);if(r){let{width:a,height:c}=e.canvas,[u,f,g,m]=St.getAxialAlignedBoundingBox([0,0,a,c],r);this.ctx.fillRect(u,f,g-u,m-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){$t("Should not call beginInlineImage")}beginImageData(){$t("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Wt(this.ctx),e)){let n=e[2]-e[0],r=e[3]-e[1];this.ctx.rect(e[0],e[1],n,r),this.current.updateRectMinMax(Wt(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);let e=this.ctx;t.isolated||Jr("TODO: Support non-isolated groups."),t.knockout&&Et("Knockout groups not supported.");let n=Wt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=St.getAxialAlignedBoundingBox(t.bbox,Wt(e)),a=[0,0,e.canvas.width,e.canvas.height];r=St.intersect(r,a)||[0,0,0,0];let c=Math.floor(r[0]),u=Math.floor(r[1]),f=Math.max(Math.ceil(r[2])-c,1),g=Math.max(Math.ceil(r[3])-u,1);this.current.startNewPathAndClipBox([0,0,f,g]);let m="groupAt"+this.groupLevel;t.smask&&(m+="_smask_"+this.smaskCounter++%2);let b=this.cachedCanvases.getCanvas(m,f,g),v=b.context;v.translate(-c,-u),v.transform(...n),t.smask?this.smaskStack.push({canvas:b.canvas,context:v,offsetX:c,offsetY:u,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(c,u),e.save()),gs(e,v),this.ctx=v,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;let e=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let r=Wt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);let a=St.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],r);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,e,n,r,a){if(this.#t(),gr(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let c=e[2]-e[0],u=e[3]-e[1];if(a&&this.annotationCanvasMap){n=n.slice(),n[4]-=e[0],n[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=c,e[3]=u;let[f,g]=St.singularValueDecompose2dScale(Wt(this.ctx)),{viewportScale:m}=this,b=Math.ceil(c*this.outputScaleX*m),v=Math.ceil(u*this.outputScaleY*m);this.annotationCanvas=this.canvasFactory.create(b,v);let{canvas:S,context:T}=this.annotationCanvas;this.annotationCanvasMap.set(t,S),this.annotationCanvas.savedCtx=this.ctx,this.ctx=T,this.ctx.save(),this.ctx.setTransform(f,0,0,-g,0,u*g),gr(this.ctx)}else gr(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],c,u),this.ctx.clip(),this.ctx.beginPath()}this.current=new Lr(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;let e=t.count;t=this.getObject(t.data,t),t.count=e;let n=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=Sy(t)),r.compiled)){r.compiled(n);return}let a=this._createMaskCanvas(t),c=a.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(c,a.offsetX,a.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,n=0,r=0,a,c){if(!this.contentVisible)return;t=this.getObject(t.data,t);let u=this.ctx;u.save();let f=Wt(u);u.transform(e,n,r,a,0,0);let g=this._createMaskCanvas(t);u.setTransform(1,0,0,1,g.offsetX-f[4],g.offsetY-f[5]);for(let m=0,b=c.length;m<b;m+=2){let v=St.transform(f,[e,n,r,a,c[m],c[m+1]]),[S,T]=St.applyTransform([0,0],v);u.drawImage(g.canvas,S,T)}u.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(let a of t){let{data:c,width:u,height:f,transform:g}=a,m=this.cachedCanvases.getCanvas("maskCanvas",u,f),b=m.context;b.save();let v=this.getObject(c,a);uu(b,v),b.globalCompositeOperation="source-in",b.fillStyle=r?n.getPattern(b,this,Ye(e),ce.FILL):n,b.fillRect(0,0,u,f),b.restore(),e.save(),e.transform(...g),e.scale(1,-1),pr(e,m.canvas,0,0,u,f,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);if(!e){Et("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,n,r){if(!this.contentVisible)return;let a=this.getObject(t);if(!a){Et("Dependent image isn't ready yet");return}let c=a.width,u=a.height,f=[];for(let g=0,m=r.length;g<m;g+=2)f.push({transform:[e,0,0,n,r[g],r[g+1]],x:0,y:0,w:c,h:u});this.paintInlineImageXObjectGroup(a,f)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;let{bitmap:e,width:n,height:r}=t,a=this.cachedCanvases.getCanvas("inlineImage",n,r),c=a.context;return c.filter=this.current.transferMaps,c.drawImage(e,0,0),c.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;let e=t.width,n=t.height,r=this.ctx;if(this.save(),!ue){let{filter:u}=r;u!=="none"&&u!==""&&(r.filter="none")}r.scale(1/e,-1/n);let a;if(t.bitmap)a=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)a=t;else{let f=this.cachedCanvases.getCanvas("inlineImage",e,n).context;cu(f,t),a=this.applyTransferMapsToCanvas(f)}let c=this._scaleImage(a,Ye(r));r.imageSmoothingEnabled=hu(Wt(r),t.interpolate),pr(r,c.img,0,0,c.paintWidth,c.paintHeight,0,-n,e,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;let n=this.ctx,r;if(t.bitmap)r=t.bitmap;else{let a=t.width,c=t.height,f=this.cachedCanvases.getCanvas("inlineImage",a,c).context;cu(f,t),r=this.applyTransferMapsToCanvas(f)}for(let a of e)n.save(),n.transform(...a.transform),n.scale(1,-1),pr(n,r,a.x,a.y,a.w,a.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){let e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);let n=this.ctx;this.pendingClip&&(e||(this.pendingClip===du?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=Wt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),n=Math.hypot(t[0],t[2]),r=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:n,c:r,d:a}=this.ctx.getTransform(),c,u;if(n===0&&r===0){let f=Math.abs(e),g=Math.abs(a);if(f===g)if(t===0)c=u=1/f;else{let m=f*t;c=u=m<1?1/m:1}else if(t===0)c=1/f,u=1/g;else{let m=f*t,b=g*t;c=m<1?1/m:1,u=b<1?1/b:1}}else{let f=Math.abs(e*a-n*r),g=Math.hypot(e,n),m=Math.hypot(r,a);if(t===0)c=m/f,u=g/f;else{let b=t*f;c=m>b?m/b:1,u=g>b?g/b:1}}this._cachedScaleForStroking[0]=c,this._cachedScaleForStroking[1]=u}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:n}=this.current,[r,a]=this.getScaleForStroking();if(e.lineWidth=n||1,r===1&&a===1){e.stroke();return}let c=e.getLineDash();if(t&&e.save(),e.scale(r,a),c.length>0){let u=Math.max(r,a);e.setLineDash(c.map(f=>f/u)),e.lineDashOffset/=u}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(let o in Ge)Qn.prototype[o]!==void 0&&(Qn.prototype[Ge[o]]=Qn.prototype[o]);Rn=class{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}},No=class{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return Da(this.#t)}has(t){return this.#t.has(t)}},Zn=Symbol("INTERNAL"),Uo=class{#t=!1;#e=!1;#n=!1;#s=!0;constructor(t,{name:e,intent:n,usage:r,rbGroups:a}){this.#t=!!(t&we.DISPLAY),this.#e=!!(t&we.PRINT),this.name=e,this.intent=n,this.usage=r,this.rbGroups=a}get visible(){if(this.#n)return this.#s;if(!this.#s)return!1;let{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,n=!1){t!==Zn&&$t("Internal method `_setVisible` called."),this.#n=n,this.#s=e}},Bo=class{#t=null;#e=new Map;#n=null;#s=null;constructor(t,e=we.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#s=t.order;for(let n of t.groups)this.#e.set(n.id,new Uo(e,n));if(t.baseState==="OFF")for(let n of this.#e.values())n._setVisible(Zn,!1);for(let n of t.on)this.#e.get(n)._setVisible(Zn,!0);for(let n of t.off)this.#e.get(n)._setVisible(Zn,!1);this.#n=this.getHash()}}#i(t){let e=t.length;if(e<2)return!0;let n=t[0];for(let r=1;r<e;r++){let a=t[r],c;if(Array.isArray(a))c=this.#i(a);else if(this.#e.has(a))c=this.#e.get(a).visible;else return Et(`Optional content group not found: ${a}`),!0;switch(n){case"And":if(!c)return!1;break;case"Or":if(c)return!0;break;case"Not":return!c;default:return!0}}return n==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Jr("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(Et(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#i(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return Et(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return Et(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return Et(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return Et(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return Et(`Unknown optional content policy ${t.policy}.`),!0}return Et(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,n=!0){let r=this.#e.get(t);if(!r){Et(`Optional content group not found: ${t}`);return}if(n&&e&&r.rbGroups.length)for(let a of r.rbGroups)for(let c of a)c!==t&&this.#e.get(c)?._setVisible(Zn,!1,!0);r._setVisible(Zn,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let n;for(let r of t){switch(r){case"ON":case"OFF":case"Toggle":n=r;continue}let a=this.#e.get(r);if(a)switch(n){case"ON":this.setVisibility(r,!0,e);break;case"OFF":this.setVisibility(r,!1,e);break;case"Toggle":this.setVisibility(r,!a.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Da(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new wr;for(let[e,n]of this.#e)t.update(`${e}:${n.visible}`);return this.#t=t.hexdigest()}},Go=class{constructor(t,{disableRange:e=!1,disableStream:n=!1}){te(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:r,initialData:a,progressiveDone:c,contentDispositionFilename:u}=t;if(this._queuedChunks=[],this._progressiveDone=c,this._contentDispositionFilename=u,a?.length>0){let f=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(f)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!e,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((f,g)=>{this._onReceiveData({begin:f,chunk:g})}),t.addProgressListener((f,g)=>{this._onProgress({loaded:f,total:g})}),t.addProgressiveReadListener(f=>{this._onReceiveData({chunk:f})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let n=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{let r=this._rangeReaders.some(function(a){return a._begin!==t?!1:(a._enqueue(n),!0)});te(r,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){te(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new Ho(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new jo(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}},Ho=class{constructor(t,e,n=!1,r=null){this._stream=t,this._done=n||!1,this._filename=Na(r)?r:null,this._queuedChunks=e||[],this._loaded=0;for(let a of this._queuedChunks)this._loaded+=a.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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}},jo=class{constructor(t,e,n){this._stream=t,this._begin=e,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(let n of this._requests)n.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){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};Fr=class{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=yu(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return te(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Vo(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new $o(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Vo=class{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;let e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;let n=new Headers(t.headers),r=e.url;fetch(r,Au(n,this._withCredentials,this._abortController)).then(a=>{if(t._responseOrigin=ni(a.url),!Su(a.status))throw si(a.status,r);this._reader=a.body.getReader(),this._headersCapability.resolve();let c=a.headers,{allowRangeRequests:u,suggestedLength:f}=vu({responseHeaders:c,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=u,this._contentLength=f||this._contentLength,this._filename=xu(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ze("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;let{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:Tu(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},$o=class{constructor(t,e,n){this._stream=t,this._reader=null,this._loaded=0;let r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;let a=new Headers(t.headers);a.append("Range",`bytes=${e}-${n-1}`);let c=r.url;fetch(c,Au(a,this._withCredentials,this._abortController)).then(u=>{let f=ni(u.url);if(f!==t._responseOrigin)throw new Error(`Expected range response-origin "${f}" to match "${t._responseOrigin}".`);if(!Su(u.status))throw si(u.status,c);this._readCapability.resolve(),this._reader=u.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Tu(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},uo=200,ho=206;zo=class{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:n}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=yu(this.isHttp,e),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(let[a,c]of this.headers)e.setRequestHeader(a,c);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=ho):r.expectedStatus=uo,e.responseType="arraybuffer",te(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,n),e.onprogress=this.onProgress.bind(this,n),r.onHeadersReceived=t.onHeadersReceived,r.onDone=t.onDone,r.onError=t.onError,r.onProgress=t.onProgress,e.send(null),n}onProgress(t,e){let n=this.pendingRequests[t];n&&n.onProgress?.(e)}onStateChange(t,e){let n=this.pendingRequests[t];if(!n)return;let r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),r.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],r.status===0&&this.isHttp){n.onError(r.status);return}let a=r.status||uo;if(!(a===uo&&n.expectedStatus===ho)&&a!==n.expectedStatus){n.onError(r.status);return}let u=Ey(r);if(a===ho){let f=r.getResponseHeader("Content-Range"),g=/bytes (\d+)-(\d+)\/(\d+)/.exec(f);g?n.onDone({begin:parseInt(g[1],10),chunk:u}):(Et('Missing or invalid "Content-Range" header.'),n.onError(0))}else u?n.onDone({begin:0,chunk:u}):n.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}},Wo=class{constructor(t){this._source=t,this._manager=new zo(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return te(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Xo(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let n=new Yo(this._manager,t,e);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Xo=class{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=ni(e.responseURL);let n=e.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(u=>{let[f,...g]=u.split(": ");return[f,g.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:c}=vu({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=c||this._contentLength,this._filename=xu(r),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=si(t,this._url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}},Yo=class{constructor(t,e,n){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=ni(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(let n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=si(t,this._url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},ky=/^[a-z][a-z0-9\-+.]+:/i;Ko=class{constructor(t){this.source=t,this.url=Iy(t.url),te(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return te(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Zo(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new Qo(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Zo=class{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;let 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();let n=process.getBuiltinModule("fs");n.promises.lstat(this._url).then(r=>{this._contentLength=r.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},r=>{r.code==="ENOENT"&&(r=new On(`Missing PDF "${this._url}".`)),this._storedError=r,this._headersCapability.reject(r)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Ze("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}},Qo=class{constructor(t,e,n){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let r=t.source;this._isStreamingSupported=!r.disableStream;let a=process.getBuiltinModule("fs");this._setReadableStream(a.createReadStream(this._url,{start:e,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},Py=1e5,ye=30,Ry=.8,Es=class o{#t=Promise.withResolvers();#e=null;#n=!1;#s=!!globalThis.FontInspector?.enabled;#i=null;#r=null;#l=0;#a=0;#u=null;#c=null;#d=0;#h=0;#f=Object.create(null);#o=[];#p=null;#m=[];#g=new WeakMap;#b=null;static#x=new Map;static#y=new Map;static#S=new WeakMap;static#T=null;static#w=new Set;constructor({textContentSource:t,container:e,viewport:n}){if(t instanceof ReadableStream)this.#p=t;else if(typeof t=="object")this.#p=new ReadableStream({start(f){f.enqueue(t),f.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#c=e,this.#h=n.scale*(globalThis.devicePixelRatio||1),this.#d=n.rotation,this.#r={div:null,properties:null,ctx:null};let{pageWidth:r,pageHeight:a,pageX:c,pageY:u}=n.rawDims;this.#b=[1,0,0,-1,-c,u+a],this.#a=r,this.#l=a,o.#O(),Mn(e,n),this.#t.promise.finally(()=>{o.#w.delete(this),this.#r=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=ne.platform;return Ot(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#u.read().then(({value:e,done:n})=>{if(n){this.#t.resolve();return}this.#i??=e.lang,Object.assign(this.#f,e.styles),this.#k(e.items),t()},this.#t.reject)};return this.#u=this.#p.getReader(),o.#w.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let n=t.scale*(globalThis.devicePixelRatio||1),r=t.rotation;if(r!==this.#d&&(e?.(),this.#d=r,Mn(this.#c,{rotation:r})),n!==this.#h){e?.(),this.#h=n;let a={div:null,properties:null,ctx:o.#I(this.#i)};for(let c of this.#m)a.properties=this.#g.get(c),a.div=c,this.#A(a)}}cancel(){let t=new Ze("TextLayer task cancelled.");this.#u?.cancel(t).catch(()=>{}),this.#u=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#o}#k(t){if(this.#n)return;this.#r.ctx??=o.#I(this.#i);let e=this.#m,n=this.#o;for(let r of t){if(e.length>Py){Et("Ignoring additional textDivs for performance reasons."),this.#n=!0;return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){let a=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),r.id!==null&&this.#e.setAttribute("id",`${r.id}`),a.append(this.#e)}else r.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}n.push(r.str),this.#P(r)}}#P(t){let e=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);let r=St.transform(this.#b,t.transform),a=Math.atan2(r[1],r[0]),c=this.#f[t.fontName];c.vertical&&(a+=Math.PI/2);let u=this.#s&&c.fontSubstitution||c.fontFamily;u=o.fontFamilyMap.get(u)||u;let f=Math.hypot(r[2],r[3]),g=f*o.#F(u,this.#i),m,b;a===0?(m=r[4],b=r[5]-g):(m=r[4]+g*Math.sin(a),b=r[5]-g*Math.cos(a));let v="calc(var(--scale-factor)*",S=e.style;this.#e===this.#c?(S.left=`${(100*m/this.#a).toFixed(2)}%`,S.top=`${(100*b/this.#l).toFixed(2)}%`):(S.left=`${v}${m.toFixed(2)}px)`,S.top=`${v}${b.toFixed(2)}px)`),S.fontSize=`${v}${(o.#T*f).toFixed(2)}px)`,S.fontFamily=u,n.fontSize=f,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(e.dataset.fontName=c.fontSubstitutionLoadedName||t.fontName),a!==0&&(n.angle=a*(180/Math.PI));let T=!1;if(t.str.length>1)T=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let w=Math.abs(t.transform[0]),I=Math.abs(t.transform[3]);w!==I&&Math.max(w,I)/Math.min(w,I)>1.5&&(T=!0)}if(T&&(n.canvasWidth=c.vertical?t.height:t.width),this.#g.set(e,n),this.#r.div=e,this.#r.properties=n,this.#A(this.#r),n.hasText&&this.#e.append(e),n.hasEOL){let w=document.createElement("br");w.setAttribute("role","presentation"),this.#e.append(w)}}#A(t){let{div:e,properties:n,ctx:r}=t,{style:a}=e,c="";if(o.#T>1&&(c=`scale(${1/o.#T})`),n.canvasWidth!==0&&n.hasText){let{fontFamily:u}=a,{canvasWidth:f,fontSize:g}=n;o.#E(r,g*this.#h,u);let{width:m}=r.measureText(e.textContent);m>0&&(c=`scaleX(${f*this.#h/m}) ${c}`)}n.angle!==0&&(c=`rotate(${n.angle}deg) ${c}`),c.length>0&&(a.transform=c)}static cleanup(){if(!(this.#w.size>0)){this.#x.clear();for(let{canvas:t}of this.#y.values())t.remove();this.#y.clear()}}static#I(t=null){let e=this.#y.get(t||="");if(!e){let n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),e=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#y.set(t,e),this.#S.set(e,{size:0,family:""})}return e}static#E(t,e,n){let r=this.#S.get(t);e===r.size&&n===r.family||(t.font=`${e}px ${n}`,r.size=e,r.family=n)}static#O(){if(this.#T!==null)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#T=t.getBoundingClientRect().height,t.remove()}static#F(t,e){let n=this.#x.get(t);if(n)return n;let r=this.#I(e);r.canvas.width=r.canvas.height=ye,this.#E(r,ye,t);let a=r.measureText(""),c=a.fontBoundingBoxAscent,u=Math.abs(a.fontBoundingBoxDescent);if(c){let m=c/(c+u);return this.#x.set(t,m),r.canvas.width=r.canvas.height=0,m}r.strokeStyle="red",r.clearRect(0,0,ye,ye),r.strokeText("g",0,0);let f=r.getImageData(0,0,ye,ye).data;u=0;for(let m=f.length-1-3;m>=0;m-=4)if(f[m]>0){u=Math.ceil(m/4/ye);break}r.clearRect(0,0,ye,ye),r.strokeText("A",0,ye),f=r.getImageData(0,0,ye,ye).data,c=0;for(let m=0,b=f.length;m<b;m+=4)if(f[m]>0){c=ye-Math.floor(m/4/ye);break}r.canvas.width=r.canvas.height=0;let g=c?c/(c+u):Ry;return this.#x.set(t,g),g}},ks=class o{static textContent(t){let e=[],n={items:e,styles:Object.create(null)};function r(a){if(!a)return;let c=null,u=a.name;if(u==="#text")c=a.value;else if(o.shouldBuildText(u))a?.attributes?.textContent?c=a.attributes.textContent:a.value&&(c=a.value);else return;if(c!==null&&e.push({str:c}),!!a.children)for(let f of a.children)r(f)}return r(t),n}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},Oy=65536,My=100,Ly=5e3,Fy=ue?Io:wo,Dy=ue?Po:Pr,_y=ue?ko:Eo,Ny=ue?Ro:Mr;Jo=class o{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${o.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}},Dr=class{constructor(t,e,n=!1,r=null){this.length=t,this.initialData=e,this.progressiveDone=n,this.contentDispositionFilename=r,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(let n of this._rangeListeners)n(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(let e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){$t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},qo=class{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ot(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"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}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()}},ta=class{#t=null;#e=!1;constructor(t,e,n,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=r?new xr:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new _r,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}get trimBox(){return this._pageInfo.trimBox??null}get bleedBox(){return this._pageInfo.bleedBox??null}get colorSpaceResources(){return this._pageInfo.colorSpaceResources??{}}get imglyPatchVersion(){return this._pageInfo.imglyPatchVersion??null}getViewport({scale:t,rotation:e=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}={}){return new Ss({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:a})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ot(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:n="display",annotationMode:r=gn.ENABLE,transform:a=null,background:c=null,optionalContentConfigPromise:u=null,annotationCanvasMap:f=null,pageColors:g=null,printAnnotationStorage:m=null,isEditing:b=!1}){this._stats?.time("Overall");let v=this._transport.getRenderingIntent(n,r,m,b),{renderingIntent:S,cacheKey:T}=v;this.#e=!1,this.#s(),u||=this._transport.getOptionalContentConfig(S);let w=this._intentStates.get(T);w||(w=Object.create(null),this._intentStates.set(T,w)),w.streamReaderCancelTimeout&&(clearTimeout(w.streamReaderCancelTimeout),w.streamReaderCancelTimeout=null);let I=!!(S&we.PRINT);w.displayReadyCapability||(w.displayReadyCapability=Promise.withResolvers(),w.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(v));let k=_=>{w.renderTasks.delete(O),(this._maybeCleanupAfterRender||I)&&(this.#e=!0),this.#n(!I),_?(O.capability.reject(_),this._abortOperatorList({intentState:w,reason:_ instanceof Error?_:new Error(_)})):O.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},O=new ra({callback:k,params:{canvasContext:t,viewport:e,transform:a,background:c},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:f,operatorList:w.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!I,pdfBug:this._pdfBug,pageColors:g});(w.renderTasks||=new Set).add(O);let F=O.task;return Promise.all([w.displayReadyCapability.promise,u]).then(([_,D])=>{if(this.destroyed){k();return}if(this._stats?.time("Rendering"),!(D.renderingIntent&S))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");O.initializeGraphics({transparency:_,optionalContentConfig:D}),O.operatorListChanged()}).catch(k),F}getOperatorList({intent:t="display",annotationMode:e=gn.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function a(){u.operatorList.lastChunk&&(u.opListReadCapability.resolve(u.operatorList),u.renderTasks.delete(f))}let c=this._transport.getRenderingIntent(t,e,n,r,!0),u=this._intentStates.get(c.cacheKey);u||(u=Object.create(null),this._intentStates.set(c.cacheKey,u));let f;return u.opListReadCapability||(f=Object.create(null),f.operatorListChanged=a,u.opListReadCapability=Promise.withResolvers(),(u.renderTasks||=new Set).add(f),u.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c)),u.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(r){return r.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>ks.textContent(n));let e=this.streamTextContent(t);return new Promise(function(n,r){function a(){c.read().then(function({value:f,done:g}){if(g){n(u);return}u.lang??=f.lang,Object.assign(u.styles,f.styles),u.items.push(...f.items),a()},r)}let c=e.getReader(),u={items:[],styles:Object.create(null),lang:null};a()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let n of e.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),this.#e=!1,this.#s(),Promise.all(t)}cleanup(t=!1){this.#e=!0;let e=this.#n(!1);return t&&e&&(this._stats&&=new xr),e}#n(t=!1){if(this.#s(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#n(!1)},Ly),!1;for(let{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#s(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){let n=this._intentStates.get(e);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let n=0,r=t.length;n<r;n++)e.operatorList.fnArray.push(t.fnArray[n]),e.operatorList.argsArray.push(t.argsArray[n]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let n of e.renderTasks)n.operatorListChanged();t.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:n,modifiedIds:r}){let{map:a,transfer:c}=n,f=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:a,modifiedIds:r},c).getReader(),g=this._intentStates.get(e);g.streamReader=f;let m=()=>{f.read().then(({value:b,done:v})=>{if(v){g.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(b,g),m())},b=>{if(g.streamReader=null,!this._transport.destroyed){if(g.operatorList){g.operatorList.lastChunk=!0;for(let v of g.renderTasks)v.operatorListChanged();this.#n(!0)}if(g.displayReadyCapability)g.displayReadyCapability.reject(b);else if(g.opListReadCapability)g.opListReadCapability.reject(b);else throw b}})};m()}_abortOperatorList({intentState:t,reason:e,force:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(e instanceof As){let r=My;e.extraDelay>0&&e.extraDelay<1e3&&(r+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},r);return}}if(t.streamReader.cancel(new Ze(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[r,a]of this._intentStates)if(a===t){this._intentStates.delete(r);break}this.cleanup()}}}get stats(){return this._stats}},ea=class{#t=new Map;#e=Promise.resolve();postMessage(t,e){let n={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[r]of this.#t)r.call(this,n)})}addEventListener(t,e,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:a}=n;if(a.aborted){Et("LoopbackPort - cannot use an `aborted` signal.");return}let c=()=>this.removeEventListener(t,e);r=()=>a.removeEventListener("abort",c),a.addEventListener("abort",c)}this.#t.set(e,r)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}},Jn=class o{static#t=0;static#e=!1;static#n;static{ue&&(this.#e=!0,Rn.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let n;try{if(n=new URL(t),!n.origin||n.origin==="null")return!1}catch{return!1}let r=new URL(e,n);return n.origin===r.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:n=ny()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(o.#n?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(o.#n||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#s(){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 Pn("main","worker",t),this._messageHandler.on("ready",function(){}),this.#s()}_initialize(){if(o.#e||o.#i){this._setupFakeWorker();return}let{workerSrc:t}=o;try{o._isSameOrigin(window.location.href,t)||(t=o._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),n=new Pn("main","worker",e),r=()=>{a.abort(),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;e.addEventListener("error",()=>{this._webWorker||r()},{signal:a.signal}),n.on("test",u=>{if(a.abort(),this.destroyed||!u){r();return}this._messageHandler=n,this._port=e,this._webWorker=e,this.#s()}),n.on("ready",u=>{if(a.abort(),this.destroyed){r();return}try{c()}catch{this._setupFakeWorker()}});let c=()=>{let u=new Uint8Array;n.send("test",u,[u.buffer])};c();return}catch{Jr("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){o.#e||(Et("Setting up fake worker."),o.#e=!0),o._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let e=new ea;this._port=e;let n=`fake${o.#t++}`,r=new Pn(n+"_worker",n,e);t.setup(r,e),this._messageHandler=new Pn(n,n+"_worker",e),this.#s()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,o.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let e=this.#n?.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 o(t)}static get workerSrc(){if(Rn.workerSrc)return Rn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#i(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Ot(this,"_setupFakeWorkerGlobal",(async()=>this.#i?this.#i:(await import(this.workerSrc)).WorkerMessageHandler)())}},na=class{#t=new Map;#e=new Map;#n=new Map;#s=new Map;#i=null;constructor(t,e,n,r,a){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new _r,this.fontLoader=new To({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#r(t,e=null){let n=this.#t.get(t);if(n)return n;let r=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,r),r}get annotationStorage(){return Ot(this,"annotationStorage",new Cs)}getRenderingIntent(t,e=gn.ENABLE,n=null,r=!1,a=!1){let c=we.DISPLAY,u=Ao;switch(t){case"any":c=we.ANY;break;case"display":break;case"print":c=we.PRINT;break;default:Et(`getRenderingIntent - invalid intent: ${t}`)}let f=c&we.PRINT&&n instanceof Er?n:this.annotationStorage;switch(e){case gn.DISABLE:c+=we.ANNOTATIONS_DISABLE;break;case gn.ENABLE:break;case gn.ENABLE_FORMS:c+=we.ANNOTATIONS_FORMS;break;case gn.ENABLE_STORAGE:c+=we.ANNOTATIONS_STORAGE,u=f.serializable;break;default:Et(`getRenderingIntent - invalid annotationMode: ${e}`)}r&&(c+=we.IS_EDITING),a&&(c+=we.OPLIST);let{ids:g,hash:m}=f.modifiedIds,b=[c,u.hash,m];return{renderingIntent:c,cacheKey:b.join("_"),annotationStorageSerializable:u,modifiedIds:g}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(new Error("Worker was destroyed during onPassword callback"));let t=[];for(let n of this.#e.values())t.push(n._destroy());this.#e.clear(),this.#n.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),Es.cleanup(),this._networkStream?.cancelAllRequests(new Ze("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(n,r)=>{te(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},r.onPull=()=>{this._fullReader.read().then(function({value:a,done:c}){if(c){r.close();return}te(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{r.error(a)})},r.onCancel=a=>{this._fullReader.cancel(a),r.ready.catch(c=>{if(!this.destroyed)throw c})}}),t.on("ReaderHeadersReady",async n=>{await this._fullReader.headersReady;let{isStreamingSupported:r,isRangeSupported:a,contentLength:c}=this._fullReader;return(!r||!a)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=u=>{e.onProgress?.({loaded:u.loaded,total:u.total})}),{isStreamingSupported:r,isRangeSupported:a,contentLength:c}}),t.on("GetRangeReader",(n,r)=>{te(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let a=this._networkStream.getRangeReader(n.begin,n.end);if(!a){r.close();return}r.onPull=()=>{a.read().then(function({value:c,done:u}){if(u){r.close();return}te(c instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(c),1,[c])}).catch(c=>{r.error(c)})},r.onCancel=c=>{a.cancel(c),r.ready.catch(u=>{if(!this.destroyed)throw u})}}),t.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,e._capability.resolve(new qo(n,this))}),t.on("DocException",n=>{e._capability.reject(ve(n))}),t.on("PasswordRequest",n=>{this.#i=Promise.withResolvers();try{if(!e.onPassword)throw ve(n);let r=a=>{a instanceof Error?this.#i.reject(a):this.#i.resolve({password:a})};e.onPassword(r,n.code)}catch(r){this.#i.reject(r)}return this.#i.promise}),t.on("DataLoaded",n=>{e.onProgress?.({loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),t.on("StartRenderPage",n=>{if(this.destroyed)return;this.#e.get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),t.on("commonobj",([n,r,a])=>{if(this.destroyed||this.commonObjs.has(n))return null;switch(r){case"Font":let{disableFontFace:c,fontExtraProperties:u,pdfBug:f}=this._params;if("error"in a){let v=a.error;Et(`Error during font loading: ${v}`),this.commonObjs.resolve(n,v);break}let g=f&&globalThis.FontInspector?.enabled?(v,S)=>globalThis.FontInspector.fontAdded(v,S):null,m=new Co(a,{disableFontFace:c,fontExtraProperties:u,inspectFont:g});this.fontLoader.bind(m).catch(()=>t.sendWithPromise("FontFallback",{id:n})).finally(()=>{!u&&m.data&&(m.data=null),this.commonObjs.resolve(n,m)});break;case"CopyLocalImage":let{imageRef:b}=a;te(b,"The imageRef must be defined.");for(let v of this.#e.values())for(let[,S]of v.objs)if(S?.ref===b)return S.dataLen?(this.commonObjs.resolve(n,structuredClone(S)),S.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error(`Got unknown common object type ${r}`)}return null}),t.on("obj",([n,r,a,c])=>{if(this.destroyed)return;let u=this.#e.get(r);if(!u.objs.has(n)){if(u._intentStates.size===0){c?.bitmap?.close();return}switch(a){case"Image":u.objs.resolve(n,c),c?.dataLen>Zb&&(u._maybeCleanupAfterRender=!0);break;case"Pattern":u.objs.resolve(n,c);break;default:throw new Error(`Got unknown object type ${a}`)}}}),t.on("DocProgress",n=>{this.destroyed||e.onProgress?.({loaded:n.loaded,total:n.total})}),t.on("FetchBuiltInCMap",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(n)}),t.on("FetchStandardFontData",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(n)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Et("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._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."));let e=t-1,n=this.#n.get(e);if(n)return n;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&this.#s.set(a.refStr,t);let c=new ta(e,a,this,this._params.pdfBug);return this.#e.set(e,c),c});return this.#n.set(e,r),r}getPageIndex(t){return fu(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.#r("GetFieldObjects")}hasJSActions(){return this.#r("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#r("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.#r("GetOptionalContentConfig").then(e=>new Bo(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#t.get(t);if(e)return e;let n=this.messageHandler.sendWithPromise(t,null).then(r=>({info:r[0],metadata:r[1]?new No(r[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Es.cleanup()}}cachedPageNumber(t){if(!fu(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#s.get(e)??null}},ms=Symbol("INITIAL_DATA"),_r=class{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:ms}}get(t,e=null){if(e){let r=this.#e(t);return r.promise.then(()=>e(r.data)),null}let n=this.#t[t];if(!n||n.data===ms)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){let e=this.#t[t];return!!e&&e.data!==ms}delete(t){let e=this.#t[t];return!e||e.data===ms?!1:(delete this.#t[t],!0)}resolve(t,e=null){let n=this.#e(t);n.data=e,n.resolve()}clear(){for(let t in this.#t){let{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let t in this.#t){let{data:e}=this.#t[t];e!==ms&&(yield[t,e])}}},sa=class{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}},ra=class o{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:n,commonObjs:r,annotationCanvasMap:a,operatorList:c,pageIndex:u,canvasFactory:f,filterFactory:g,useRequestAnimationFrame:m=!1,pdfBug:b=!1,pageColors:v=null}){this.callback=t,this.params=e,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=c,this._pageIndex=u,this.canvasFactory=f,this.filterFactory=g,this._pdfBug=b,this.pageColors=v,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=m===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new sa(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(o.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");o.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:n,viewport:r,transform:a,background:c}=this.params;this.gfx=new Qn(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:r,transparency:t,background:c}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),o.#e.delete(this._canvas),this.callback(t||new As(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),o.#e.delete(this._canvas),this.callback())))}},Hy="4.10.45",jy="18f8e0416",eS=Lt(670);Nr=class{static CMYK_G([t,e,n,r]){return["G",1-Math.min(1,.3*t+.59*n+.11*e+r)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=bs(t),[t,t,t]}static G_HTML([t]){let e=pu(t);return`#${e}${e}${e}`}static RGB_G([t,e,n]){return["G",.3*t+.59*e+.11*n]}static RGB_rgb(t){return t.map(bs)}static RGB_HTML(t){return`#${t.map(pu).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,n,r]){return["RGB",1-Math.min(1,t+r),1-Math.min(1,n+r),1-Math.min(1,e+r)]}static CMYK_rgb([t,e,n,r]){return[bs(1-Math.min(1,t+r)),bs(1-Math.min(1,n+r)),bs(1-Math.min(1,e+r))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,n]){let r=1-t,a=1-e,c=1-n,u=Math.min(r,a,c);return["CMYK",r,a,c,u]}},ia=class{create(t,e,n=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");let r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),n||(r.setAttribute("width",`${t}px`),r.setAttribute("height",`${e}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${t} ${e}`),r}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){$t("Abstract method `_createSVG` called.")}},Is=class extends ia{_createSVG(t){return document.createElementNS(nn,t)}},Ur=class{static setupStorage(t,e,n,r,a){let c=r.getValue(e,{value:null});switch(n.name){case"textarea":if(c.value!==null&&(t.textContent=c.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})});break;case"input":if(n.attributes.type==="radio"||n.attributes.type==="checkbox"){if(c.value===n.attributes.xfaOn?t.setAttribute("checked",!0):c.value===n.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",u=>{r.setValue(e,{value:u.target.checked?u.target.getAttribute("xfaOn"):u.target.getAttribute("xfaOff")})})}else{if(c.value!==null&&t.setAttribute("value",c.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})})}break;case"select":if(c.value!==null){t.setAttribute("value",c.value);for(let u of n.children)u.attributes.value===c.value?u.attributes.selected=!0:u.attributes.hasOwnProperty("selected")&&delete u.attributes.selected}t.addEventListener("input",u=>{let f=u.target.options,g=f.selectedIndex===-1?"":f[f.selectedIndex].value;r.setValue(e,{value:g})});break}}static setAttributes({html:t,element:e,storage:n=null,intent:r,linkService:a}){let{attributes:c}=e,u=t instanceof HTMLAnchorElement;c.type==="radio"&&(c.name=`${c.name}-${r}`);for(let[f,g]of Object.entries(c))if(g!=null)switch(f){case"class":g.length&&t.setAttribute(f,g.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",g);break;case"style":Object.assign(t.style,g);break;case"textContent":t.textContent=g;break;default:(!u||f!=="href"&&f!=="newWindow")&&t.setAttribute(f,g)}u&&a.addLinkAttributes(t,c.href,c.newWindow),n&&c.dataId&&this.setupStorage(t,c.dataId,e,n)}static render(t){let e=t.annotationStorage,n=t.linkService,r=t.xfaHtml,a=t.intent||"display",c=document.createElement(r.name);r.attributes&&this.setAttributes({html:c,element:r,intent:a,linkService:n});let u=a!=="richText",f=t.div;if(f.append(c),t.viewport){let b=`matrix(${t.viewport.transform.join(",")})`;f.style.transform=b}u&&f.setAttribute("class","xfaLayer xfaFont");let g=[];if(r.children.length===0){if(r.value){let b=document.createTextNode(r.value);c.append(b),u&&ks.shouldBuildText(r.name)&&g.push(b)}return{textDivs:g}}let m=[[r,-1,c]];for(;m.length>0;){let[b,v,S]=m.at(-1);if(v+1===b.children.length){m.pop();continue}let T=b.children[++m.at(-1)[1]];if(T===null)continue;let{name:w}=T;if(w==="#text"){let k=document.createTextNode(T.value);g.push(k),S.append(k);continue}let I=T?.attributes?.xmlns?document.createElementNS(T.attributes.xmlns,w):document.createElement(w);if(S.append(I),T.attributes&&this.setAttributes({html:I,element:T,storage:e,intent:a,linkService:n}),T.children?.length>0)m.push([T,-1,I]);else if(T.value){let k=document.createTextNode(T.value);u&&ks.shouldBuildText(w)&&g.push(k),I.append(k)}}for(let b of f.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))b.setAttribute("readOnly",!0);return{textDivs:g}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}},Ls=1e3,Vy=9,Dn=new WeakSet;oa=class{static create(t){switch(t.data.annotationType){case ee.LINK:return new Br(t);case ee.TEXT:return new aa(t);case ee.WIDGET:switch(t.data.fieldType){case"Tx":return new la(t);case"Btn":return t.data.radioButton?new Gr(t):t.data.checkBox?new ua(t):new ha(t);case"Ch":return new da(t);case"Sig":return new ca(t)}return new sn(t);case ee.POPUP:return new Ps(t);case ee.FREETEXT:return new Hr(t);case ee.LINE:return new pa(t);case ee.SQUARE:return new ga(t);case ee.CIRCLE:return new ma(t);case ee.POLYLINE:return new jr(t);case ee.CARET:return new ya(t);case ee.INK:return new Rs(t);case ee.POLYGON:return new ba(t);case ee.HIGHLIGHT:return new Vr(t);case ee.UNDERLINE:return new va(t);case ee.SQUIGGLY:return new xa(t);case ee.STRIKEOUT:return new Sa(t);case ee.STAMP:return new $r(t);case ee.FILEATTACHMENT:return new Aa(t);default:return new Qt(t)}}},Qt=class o{#t=null;#e=!1;#n=null;constructor(t,{isRenderable:e=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!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(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:n}){return!!(t?.str||e?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return o._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#s(e),this.#n?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#n?.popup.resetEdited(),this.#t=null)}#s(t){let{container:{style:e},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:c,pageX:u,pageY:f}}}}=this;n?.splice(0,4,...t);let{width:g,height:m}=mn(t);e.left=`${100*(t[0]-u)/a}%`,e.top=`${100*(c-t[3]+f)/c}%`,r===0?(e.width=`${100*g/a}%`,e.height=`${100*m/c}%`):this.setRotation(r)}_createContainer(t){let{data:e,parent:{page:n,viewport:r}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof sn||(a.tabIndex=Ls);let{style:c}=a;if(c.zIndex=this.parent.zIndex++,e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof Ps){let{rotation:w}=e;return!e.hasOwnCanvas&&w!==0&&this.setRotation(w,a),a}let{width:u,height:f}=mn(e.rect);if(!t&&e.borderStyle.width>0){c.borderWidth=`${e.borderStyle.width}px`;let w=e.borderStyle.horizontalCornerRadius,I=e.borderStyle.verticalCornerRadius;if(w>0||I>0){let O=`calc(${w}px * var(--scale-factor)) / calc(${I}px * var(--scale-factor))`;c.borderRadius=O}else if(this instanceof Gr){let O=`calc(${u}px * var(--scale-factor)) / calc(${f}px * var(--scale-factor))`;c.borderRadius=O}switch(e.borderStyle.style){case ps.SOLID:c.borderStyle="solid";break;case ps.DASHED:c.borderStyle="dashed";break;case ps.BEVELED:Et("Unimplemented border style: beveled");break;case ps.INSET:Et("Unimplemented border style: inset");break;case ps.UNDERLINE:c.borderBottomStyle="solid";break;default:break}let k=e.borderColor||null;k?(this.#e=!0,c.borderColor=St.makeHexColor(k[0]|0,k[1]|0,k[2]|0)):c.borderWidth=0}let g=St.normalizeRect([e.rect[0],n.view[3]-e.rect[1]+n.view[1],e.rect[2],n.view[3]-e.rect[3]+n.view[1]]),{pageWidth:m,pageHeight:b,pageX:v,pageY:S}=r.rawDims;c.left=`${100*(g[0]-v)/m}%`,c.top=`${100*(g[1]-S)/b}%`;let{rotation:T}=e;return e.hasOwnCanvas||T===0?(c.width=`${100*u/m}%`,c.height=`${100*f/b}%`):this.setRotation(T,a),a}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:a,height:c}=mn(this.data.rect),u,f;t%180===0?(u=100*a/n,f=100*c/r):(u=100*c/n,f=100*a/r),e.style.width=`${u}%`,e.style.height=`${f}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,n,r)=>{let a=r.detail[e],c=a[0],u=a.slice(1);r.target.style[n]=Nr[`${c}_HTML`](u),this.annotationStorage.setValue(this.data.id,{[n]:Nr[`${c}_rgb`](u)})};return Ot(this,"_commonActions",{display:e=>{let{display:n}=e.detail,r=n%2===1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:n===1||n===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:n}=e.detail;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:n,noView:n})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{let n=e.detail.rotation;this.setRotation(n),this.annotationStorage.setValue(this.data.id,{rotation:n})}})}_dispatchEventFromSandbox(t,e){let n=this._commonActions;for(let r of Object.keys(e.detail))(t[r]||n[r])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let n=this._commonActions;for(let[r,a]of Object.entries(e)){let c=n[r];if(c){let u={detail:{[r]:a},target:t};c(u),delete e[r]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,n,r,a]=this.data.rect.map(w=>Math.fround(w));if(t.length===8){let[w,I,k,O]=t.subarray(2,6);if(r===w&&a===I&&e===k&&n===O)return}let{style:c}=this.container,u;if(this.#e){let{borderColor:w,borderWidth:I}=c;c.borderWidth=0,u=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${w}" stroke-width="${I}">`],this.container.classList.add("hasBorder")}let f=r-e,g=a-n,{svgFactory:m}=this,b=m.createElement("svg");b.classList.add("quadrilateralsContainer"),b.setAttribute("width",0),b.setAttribute("height",0);let v=m.createElement("defs");b.append(v);let S=m.createElement("clipPath"),T=`clippath_${this.data.id}`;S.setAttribute("id",T),S.setAttribute("clipPathUnits","objectBoundingBox"),v.append(S);for(let w=2,I=t.length;w<I;w+=8){let k=t[w],O=t[w+1],F=t[w+2],_=t[w+3],D=m.createElement("rect"),G=(F-e)/f,j=(a-O)/g,W=(k-F)/f,$=(O-_)/g;D.setAttribute("x",G),D.setAttribute("y",j),D.setAttribute("width",W),D.setAttribute("height",$),S.append(D),u?.push(`<rect vector-effect="non-scaling-stroke" x="${G}" y="${j}" width="${W}" height="${$}"/>`)}this.#e&&(u.push("</g></svg>')"),c.backgroundImage=u.join("")),this.container.append(b),this.container.style.clipPath=`url(#${T})`}_createPopup(){let{data:t}=this,e=this.#n=new Ps({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){$t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[t];if(r)for(let{page:a,id:c,exportValues:u}of r){if(a===-1||c===e)continue;let f=typeof u=="string"?u:null,g=document.querySelector(`[data-element-id="${c}"]`);if(g&&!Dn.has(g)){Et(`_getElementsByName - element not allowed: ${c}`);continue}n.push({id:c,exportValue:f,domElement:g})}return n}for(let r of document.getElementsByName(t)){let{exportValue:a}=r,c=r.getAttribute("data-element-id");c!==e&&Dn.has(r)&&n.push({id:c,exportValue:a,domElement:r})}return n}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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}},Br=class extends Qt{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,n=document.createElement("a");n.setAttribute("data-element-id",t.id);let r=!1;return t.url?(e.addLinkAttributes(n,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(n,t.action),r=!0):t.attachment?(this.#e(n,t.attachment,t.attachmentDest),r=!0):t.setOCGState?(this.#n(n,t.setOCGState),r=!0):t.dest?(this._bindLink(n,t.dest),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,t),r=!0),t.resetForm?(this._bindResetFormAction(n,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(n),this.container}#t(){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.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,n=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,n),!1),this.#t()}#n(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let r of Object.keys(e.actions)){let a=n.get(r);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:r}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){let n=t.onclick;if(n||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){Et('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(t.onclick=()=>!1);return}t.onclick=()=>{n?.();let{fields:r,refs:a,include:c}=e,u=[];if(r.length!==0||a.length!==0){let m=new Set(a);for(let b of r){let v=this._fieldObjects[b]||[];for(let{id:S}of v)m.add(S)}for(let b of Object.values(this._fieldObjects))for(let v of b)m.has(v.id)===c&&u.push(v)}else for(let m of Object.values(this._fieldObjects))u.push(...m);let f=this.annotationStorage,g=[];for(let m of u){let{id:b}=m;switch(g.push(b),m.type){case"text":{let S=m.defaultValue||"";f.setValue(b,{value:S});break}case"checkbox":case"radiobutton":{let S=m.defaultValue===m.exportValues;f.setValue(b,{value:S});break}case"combobox":case"listbox":{let S=m.defaultValue||"";f.setValue(b,{value:S});break}default:continue}let v=document.querySelector(`[data-element-id="${b}"]`);if(v){if(!Dn.has(v)){Et(`_bindResetFormAction - element not allowed: ${b}`);continue}}else continue;v.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}}),!1}}},aa=class extends Qt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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}},sn=class extends Qt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ne.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,n,r,a){n.includes("mouse")?t.addEventListener(n,c=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(c),shift:c.shiftKey,modifier:this._getKeyModifier(c)}})}):t.addEventListener(n,c=>{if(n==="blur"){if(!e.focused||!c.relatedTarget)return;e.focused=!1}else if(n==="focus"){if(e.focused)return;e.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(c)}})})}_setEventListeners(t,e,n,r){for(let[a,c]of n)(c==="Action"||this.data.actions?.[c])&&((c==="Focus"||c==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,a,c,r),c==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":St.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||Vy,a=t.style,c,u=2,f=g=>Math.round(10*g)/10;if(this.data.multiLine){let g=Math.abs(this.data.rect[3]-this.data.rect[1]-u),m=Math.round(g/(br*r))||1,b=g/m;c=Math.min(r,f(b/br))}else{let g=Math.abs(this.data.rect[3]-this.data.rect[1]-u);c=Math.min(r,f(g/br))}a.fontSize=`calc(${c}px * var(--scale-factor))`,a.color=St.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(a.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}},la=class extends sn{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,n,r){let a=this.annotationStorage;for(let c of this._getElementsByName(t.name,t.id))c.domElement&&(c.domElement[e]=n),a.setValue(c.id,{[r]:n})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){let r=t.getValue(e,{value:this.data.fieldValue}),a=r.value||"",c=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;c&&a.length>c&&(a=a.slice(0,c));let u=r.formattedValue||this.data.textContent?.join(`
|
|
4
|
+
`)||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));let f={userValue:a,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=u??a,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",u??a),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),Dn.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=Ls,this._setRequired(n,this.data.required),c&&(n.maxLength=c),n.addEventListener("input",m=>{t.setValue(e,{value:m.target.value}),this.setPropertyOnSiblings(n,"value",m.target.value,"value"),f.formattedValue=null}),n.addEventListener("resetform",m=>{let b=this.data.defaultFieldValue??"";n.value=f.userValue=b,f.formattedValue=null});let g=m=>{let{formattedValue:b}=f;b!=null&&(m.target.value=b),m.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",b=>{if(f.focused)return;let{target:v}=b;f.userValue&&(v.value=f.userValue),f.lastCommittedValue=v.value,f.commitKey=1,this.data.actions?.Focus||(f.focused=!0)}),n.addEventListener("updatefromsandbox",b=>{this.showElementAndHideCanvas(b.target);let v={value(S){f.userValue=S.detail.value??"",t.setValue(e,{value:f.userValue.toString()}),S.target.value=f.userValue},formattedValue(S){let{formattedValue:T}=S.detail;f.formattedValue=T,T!=null&&S.target!==document.activeElement&&(S.target.value=T),t.setValue(e,{formattedValue:T})},selRange(S){S.target.setSelectionRange(...S.detail.selRange)},charLimit:S=>{let{charLimit:T}=S.detail,{target:w}=S;if(T===0){w.removeAttribute("maxLength");return}w.setAttribute("maxLength",T);let I=f.userValue;!I||I.length<=T||(I=I.slice(0,T),w.value=f.userValue=I,t.setValue(e,{value:I}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:I,willCommit:!0,commitKey:1,selStart:w.selectionStart,selEnd:w.selectionEnd}}))}};this._dispatchEventFromSandbox(v,b)}),n.addEventListener("keydown",b=>{f.commitKey=1;let v=-1;if(b.key==="Escape"?v=0:b.key==="Enter"&&!this.data.multiLine?v=2:b.key==="Tab"&&(f.commitKey=3),v===-1)return;let{value:S}=b.target;f.lastCommittedValue!==S&&(f.lastCommittedValue=S,f.userValue=S,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:S,willCommit:!0,commitKey:v,selStart:b.target.selectionStart,selEnd:b.target.selectionEnd}}))});let m=g;g=null,n.addEventListener("blur",b=>{if(!f.focused||!b.relatedTarget)return;this.data.actions?.Blur||(f.focused=!1);let{value:v}=b.target;f.userValue=v,f.lastCommittedValue!==v&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:f.commitKey,selStart:b.target.selectionStart,selEnd:b.target.selectionEnd}}),m(b)}),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",b=>{f.lastCommittedValue=null;let{data:v,target:S}=b,{value:T,selectionStart:w,selectionEnd:I}=S,k=w,O=I;switch(b.inputType){case"deleteWordBackward":{let F=T.substring(0,w).match(/\w*[^\w]*$/);F&&(k-=F[0].length);break}case"deleteWordForward":{let F=T.substring(w).match(/^[^\w]*\w*/);F&&(O+=F[0].length);break}case"deleteContentBackward":w===I&&(k-=1);break;case"deleteContentForward":w===I&&(O+=1);break}b.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,change:v||"",willCommit:!1,selStart:k,selEnd:O}})}),this._setEventListeners(n,f,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],b=>b.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){let b=(this.data.rect[2]-this.data.rect[0])/c;n.classList.add("comb"),n.style.letterSpacing=`calc(${b}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},ca=class extends sn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}},ua=class extends sn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,n=e.id,r=t.getValue(n,{value:e.exportValue===e.fieldValue}).value;typeof r=="string"&&(r=r!=="Off",t.setValue(n,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let a=document.createElement("input");return Dn.add(a),a.setAttribute("data-element-id",n),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=Ls,a.addEventListener("change",c=>{let{name:u,checked:f}=c.target;for(let g of this._getElementsByName(u,n)){let m=f&&g.exportValue===e.exportValue;g.domElement&&(g.domElement.checked=m),t.setValue(g.id,{value:m})}t.setValue(n,{value:f})}),a.addEventListener("resetform",c=>{let u=e.defaultFieldValue||"Off";c.target.checked=u===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",c=>{let u={value(f){f.target.checked=f.detail.value!=="Off",t.setValue(n,{value:f.target.checked})}};this._dispatchEventFromSandbox(u,c)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],c=>c.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}},Gr=class extends sn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,n=e.id,r=t.getValue(n,{value:e.fieldValue===e.buttonValue}).value;if(typeof r=="string"&&(r=r!==e.buttonValue,t.setValue(n,{value:r})),r)for(let c of this._getElementsByName(e.fieldName,n))t.setValue(c.id,{value:!1});let a=document.createElement("input");if(Dn.add(a),a.setAttribute("data-element-id",n),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.tabIndex=Ls,a.addEventListener("change",c=>{let{name:u,checked:f}=c.target;for(let g of this._getElementsByName(u,n))t.setValue(g.id,{value:!1});t.setValue(n,{value:f})}),a.addEventListener("resetform",c=>{let u=e.defaultFieldValue;c.target.checked=u!=null&&u===e.buttonValue}),this.enableScripting&&this.hasJSActions){let c=e.buttonValue;a.addEventListener("updatefromsandbox",u=>{let f={value:g=>{let m=c===g.detail.value;for(let b of this._getElementsByName(g.target.name)){let v=m&&b.id===n;b.domElement&&(b.domElement.checked=v),t.setValue(b.id,{value:v})}}};this._dispatchEventFromSandbox(f,u)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],u=>u.target.checked)}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}},ha=class extends Br{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({},n)})),t}},da=class extends sn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,n=t.getValue(e,{value:this.data.fieldValue}),r=document.createElement("select");Dn.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=Ls;let a=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",m=>{let b=this.data.defaultFieldValue;for(let v of r.options)v.selected=v.value===b});for(let m of this.data.options){let b=document.createElement("option");b.textContent=m.displayValue,b.value=m.exportValue,n.value.includes(m.exportValue)&&(b.setAttribute("selected",!0),a=!1),r.append(b)}let c=null;if(a){let m=document.createElement("option");m.value=" ",m.setAttribute("hidden",!0),m.setAttribute("selected",!0),r.prepend(m),c=()=>{m.remove(),r.removeEventListener("input",c),c=null},r.addEventListener("input",c)}let u=m=>{let b=m?"value":"textContent",{options:v,multiple:S}=r;return S?Array.prototype.filter.call(v,T=>T.selected).map(T=>T[b]):v.selectedIndex===-1?null:v[v.selectedIndex][b]},f=u(!1),g=m=>{let b=m.target.options;return Array.prototype.map.call(b,v=>({displayValue:v.textContent,exportValue:v.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",m=>{let b={value(v){c?.();let S=v.detail.value,T=new Set(Array.isArray(S)?S:[S]);for(let w of r.options)w.selected=T.has(w.value);t.setValue(e,{value:u(!0)}),f=u(!1)},multipleSelection(v){r.multiple=!0},remove(v){let S=r.options,T=v.detail.remove;S[T].selected=!1,r.remove(T),S.length>0&&Array.prototype.findIndex.call(S,I=>I.selected)===-1&&(S[0].selected=!0),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},clear(v){for(;r.length!==0;)r.remove(0);t.setValue(e,{value:null,items:[]}),f=u(!1)},insert(v){let{index:S,displayValue:T,exportValue:w}=v.detail.insert,I=r.children[S],k=document.createElement("option");k.textContent=T,k.value=w,I?I.before(k):r.append(k),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},items(v){let{items:S}=v.detail;for(;r.length!==0;)r.remove(0);for(let T of S){let{displayValue:w,exportValue:I}=T,k=document.createElement("option");k.textContent=w,k.value=I,r.append(k)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},indices(v){let S=new Set(v.detail.indices);for(let T of v.target.options)T.selected=S.has(T.index);t.setValue(e,{value:u(!0)}),f=u(!1)},editable(v){v.target.disabled=!v.detail.editable}};this._dispatchEventFromSandbox(b,m)}),r.addEventListener("input",m=>{let b=u(!0),v=u(!1);t.setValue(e,{value:b}),m.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,change:v,changeEx:b,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],m=>m.target.value)):r.addEventListener("input",function(m){t.setValue(e,{value:u(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},Ps=class extends Qt{constructor(t){let{data:e,elements:n}=t;super(t,{isRenderable:Qt._hasPopupData(e)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new fa({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(let n of this.elements)n.popup=t,n.container.ariaHasPopup="dialog",e.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(n=>`${_a}${n}`).join(",")),this.container}},fa=class{#t=this.#k.bind(this);#e=this.#E.bind(this);#n=this.#I.bind(this);#s=this.#A.bind(this);#i=null;#r=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=!1;#f=null;#o=null;#p=null;#m=null;#g=null;#b=null;#x=!1;constructor({container:t,color:e,elements:n,titleObj:r,modificationDate:a,contentsObj:c,richText:u,parent:f,rect:g,parentRect:m,open:b}){this.#r=t,this.#g=r,this.#l=c,this.#m=u,this.#c=f,this.#i=e,this.#p=g,this.#d=m,this.#u=n,this.#a=Sr.toDateObject(a),this.trigger=n.flatMap(v=>v.getElementsToTriggerPopup());for(let v of this.trigger)v.addEventListener("click",this.#s),v.addEventListener("mouseenter",this.#n),v.addEventListener("mouseleave",this.#e),v.classList.add("popupTriggerArea");for(let v of n)v.container?.addEventListener("keydown",this.#t);this.#r.hidden=!0,b&&this.#A()}render(){if(this.#f)return;let t=this.#f=document.createElement("div");if(t.className="popup",this.#i){let a=t.style.outlineColor=St.makeHexColor(...this.#i);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`:t.style.backgroundColor=St.makeHexColor(...this.#i.map(u=>Math.floor(.7*(255-u)+u)))}let e=document.createElement("span");e.className="header";let n=document.createElement("h1");if(e.append(n),{dir:n.dir,str:n.textContent}=this.#g,t.append(e),this.#a){let a=document.createElement("span");a.classList.add("popupDate"),a.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),a.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#a.valueOf()})),e.append(a)}let r=this.#y;if(r)Ur.render({xfaHtml:r,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let a=this._formatContents(this.#l);t.append(a)}this.#r.append(t)}get#y(){let t=this.#m,e=this.#l;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#S(){return this.#y?.attributes?.style?.fontSize||0}get#T(){return this.#y?.attributes?.style?.color||null}#w(t){let e=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},r={style:{color:this.#T,fontSize:this.#S?`calc(${this.#S}px * var(--scale-factor))`:""}};for(let a of t.split(`
|
|
5
|
+
`))e.push({name:"span",value:a,attributes:r});return n}_formatContents({str:t,dir:e}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=e;let r=t.split(/(?:\r\n?|\n)/);for(let a=0,c=r.length;a<c;++a){let u=r[a];n.append(document.createTextNode(u)),a<c-1&&n.append(document.createElement("br"))}return n}#k(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#h)&&this.#A()}updateEdited({rect:t,popupContent:e}){this.#b||={contentsObj:this.#l,richText:this.#m},t&&(this.#o=null),e&&(this.#m=this.#w(e),this.#l=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#b&&({contentsObj:this.#l,richText:this.#m}=this.#b,this.#b=null,this.#f?.remove(),this.#f=null,this.#o=null)}#P(){if(this.#o!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:r,pageY:a}}}=this.#c,c=!!this.#d,u=c?this.#d:this.#p;for(let T of this.#u)if(!u||St.intersect(T.data.rect,u)!==null){u=T.data.rect,c=!0;break}let f=St.normalizeRect([u[0],t[3]-u[1]+t[1],u[2],t[3]-u[3]+t[1]]),m=c?u[2]-u[0]+5:0,b=f[0]+m,v=f[1];this.#o=[100*(b-r)/e,100*(v-a)/n];let{style:S}=this.#r;S.left=`${this.#o[0]}%`,S.top=`${this.#o[1]}%`}#A(){this.#h=!this.#h,this.#h?(this.#I(),this.#r.addEventListener("click",this.#s),this.#r.addEventListener("keydown",this.#t)):(this.#E(),this.#r.removeEventListener("click",this.#s),this.#r.removeEventListener("keydown",this.#t))}#I(){this.#f||this.render(),this.isVisible?this.#h&&this.#r.classList.add("focused"):(this.#P(),this.#r.hidden=!1,this.#r.style.zIndex=parseInt(this.#r.style.zIndex)+1e3)}#E(){this.#r.classList.remove("focused"),!(this.#h||!this.isVisible)&&(this.#r.hidden=!0,this.#r.style.zIndex=parseInt(this.#r.style.zIndex)-1e3)}forceHide(){this.#x=this.isVisible,this.#x&&(this.#r.hidden=!0)}maybeShow(){this.#x&&(this.#f||this.#I(),this.#x=!1,this.#r.hidden=!1)}get isVisible(){return this.#r.hidden===!1}},Hr=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Rt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let n=document.createElement("span");n.textContent=e,t.append(n)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},pa=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:n}=mn(t.rect),r=this.svgFactory.create(e,n,!0),a=this.#t=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ga=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:n}=mn(t.rect),r=this.svgFactory.create(e,n,!0),a=t.borderStyle.width,c=this.#t=this.svgFactory.createElement("svg:rect");return c.setAttribute("x",a/2),c.setAttribute("y",a/2),c.setAttribute("width",e-a),c.setAttribute("height",n-a),c.setAttribute("stroke-width",a||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),r.append(c),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ma=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:n}=mn(t.rect),r=this.svgFactory.create(e,n,!0),a=t.borderStyle.width,c=this.#t=this.svgFactory.createElement("svg:ellipse");return c.setAttribute("cx",e/2),c.setAttribute("cy",n/2),c.setAttribute("rx",e/2-a/2),c.setAttribute("ry",n/2-a/2),c.setAttribute("stroke-width",a||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),r.append(c),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},jr=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:n,popupRef:r}}=this;if(!e)return this.container;let{width:a,height:c}=mn(t),u=this.svgFactory.create(a,c,!0),f=[];for(let m=0,b=e.length;m<b;m+=2){let v=e[m]-t[0],S=t[3]-e[m+1];f.push(`${v},${S}`)}f=f.join(" ");let g=this.#t=this.svgFactory.createElement(this.svgElementName);return g.setAttribute("points",f),g.setAttribute("stroke-width",n.width||1),g.setAttribute("stroke","transparent"),g.setAttribute("fill","transparent"),u.append(g),this.container.append(u),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ba=class extends jr{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},ya=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},Rs=class extends Qt{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Rt.HIGHLIGHT:Rt.INK}#n(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:n,borderStyle:r,popupRef:a}}=this,{transform:c,width:u,height:f}=this.#n(e,t),g=this.svgFactory.create(u,f,!0),m=this.#t=this.svgFactory.createElement("svg:g");g.append(m),m.setAttribute("stroke-width",r.width||1),m.setAttribute("stroke-linecap","round"),m.setAttribute("stroke-linejoin","round"),m.setAttribute("stroke-miterlimit",10),m.setAttribute("stroke","transparent"),m.setAttribute("fill","transparent"),m.setAttribute("transform",c);for(let b=0,v=n.length;b<v;b++){let S=this.svgFactory.createElement(this.svgElementName);this.#e.push(S),S.setAttribute("points",n[b].join(",")),m.append(S)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(g),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:n,rect:r}=t,a=this.#t;if(e>=0&&a.setAttribute("stroke-width",e||1),n)for(let c=0,u=this.#e.length;c<u;c++)this.#e[c].setAttribute("points",n[c].join(","));if(r){let{transform:c,width:u,height:f}=this.#n(this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${u} ${f}`),a.setAttribute("transform",c)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},Vr=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Rt.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}},va=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}},xa=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}},Sa=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}},$r=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Rt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},Aa=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0});let{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,n;e.hasAppearance||e.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),n.addEventListener("dblclick",this.#e.bind(this)),this.#t=n;let{isMac:r}=ne.platform;return t.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),t.append(n),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},Ta=class{#t=null;#e=null;#n=new Map;#s=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:n,annotationEditorUIManager:r,page:a,viewport:c,structTreeLayer:u}){this.div=t,this.#t=e,this.#e=n,this.#s=u||null,this.page=a,this.viewport=c,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#n.size>0}async#i(t,e){let n=t.firstChild||t,r=n.id=`${_a}${e}`,a=await this.#s?.getAriaAttributes(r);if(a)for(let[c,u]of a)n.setAttribute(c,u);this.div.append(t),this.#t?.moveElementInDOM(this.div,t,n,!1)}async render(t){let{annotations:e}=t,n=this.div;Mn(n,this.viewport);let r=new Map,a={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Is,annotationStorage:t.annotationStorage||new Cs,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let c of e){if(c.noHTML)continue;let u=c.annotationType===ee.POPUP;if(u){let m=r.get(c.id);if(!m)continue;a.elements=m}else{let{width:m,height:b}=mn(c.rect);if(m<=0||b<=0)continue}a.data=c;let f=oa.create(a);if(!f.isRenderable)continue;if(!u&&c.popupRef){let m=r.get(c.popupRef);m?m.push(f):r.set(c.popupRef,[f])}let g=f.render();c.hidden&&(g.style.visibility="hidden"),await this.#i(g,c.id),f._isEditable&&(this.#n.set(f.data.id,f),this._annotationEditorUIManager?.renderAnnotationElement(f))}this.#r()}update({viewport:t}){let e=this.div;this.viewport=t,Mn(e,{rotation:t.rotation}),this.#r(),e.hidden=!1}#r(){if(!this.#e)return;let t=this.div;for(let[e,n]of this.#e){let r=t.querySelector(`[data-annotation-id="${e}"]`);if(!r)continue;n.className="annotationContent";let{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(n):a.classList.contains("annotationContent")?a.after(n):a.before(n):r.append(n)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(t){return this.#n.get(t)}},mr=/\r\n?|\n/g,Ca=class o extends Xt{#t;#e="";#n=`${this.id}-editor`;#s=null;#i;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=o.prototype,e=a=>a.isEmpty(),n=Fn.TRANSLATE_SMALL,r=Fn.TRANSLATE_BIG;return Ot(this,"_keyboardManager",new Ln([[["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:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}]]))}static _type="freetext";static _editorType=Rt.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||o._defaultColor||Xt._defaultLineColor,this.#i=t.fontSize||o._defaultFontSize}static initialize(t,e){Xt.initialize(t,e);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Mt.FREETEXT_SIZE:o._defaultFontSize=e;break;case Mt.FREETEXT_COLOR:o._defaultColor=e;break}}updateParams(t,e){switch(t){case Mt.FREETEXT_SIZE:this.#r(e);break;case Mt.FREETEXT_COLOR:this.#l(e);break}}static get defaultPropertiesToUpdate(){return[[Mt.FREETEXT_SIZE,o._defaultFontSize],[Mt.FREETEXT_COLOR,o._defaultColor||Xt._defaultLineColor]]}get propertiesToUpdate(){return[[Mt.FREETEXT_SIZE,this.#i],[Mt.FREETEXT_COLOR,this.#t]]}#r(t){let e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-this.#i)*this.parentScale),this.#i=r,this.#u()},n=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){let e=r=>{this.#t=this.editorDiv.style.color=r},n=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-o._internalPadding*t,-(o._internalPadding+this.#i)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Rt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;let t=this._uiManager.combinedSignal(this.#s);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#n),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#a(){let t=[];this.editorDiv.normalize();let e=null;for(let n of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&n.nodeName==="BR"||(t.push(o.#c(n)),e=n);return t.join(`
|
|
6
|
+
`)}#u(){let[t,e]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:r,div:a}=this,c=a.style.display,u=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),n=a.getBoundingClientRect(),a.remove(),a.style.display=c,a.classList.toggle("hidden",u)}this.rotation%180===this.parentRotation%180?(this.width=n.width/t,this.height=n.height/e):(this.width=n.height/t,this.height=n.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#e,e=this.#e=this.#a().trimEnd();if(t===e)return;let n=r=>{if(this.#e=r,!r){this.remove();return}this.#d(),this._uiManager.rebuild(this),this.#u()};this.addCommands({cmd:()=>{n(e)},undo:()=>{n(t)},mustExec:!1}),this.#u()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){o._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.#n),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ar(this,this.div,["dblclick","keydown"]),this.width){let[r,a]=this.parentDimensions;if(this.annotationElementId){let{position:c}=this._initialData,[u,f]=this.getInitialTranslation();[u,f]=this.pageTranslationToScreen(u,f);let[g,m]=this.pageDimensions,[b,v]=this.pageTranslation,S,T;switch(this.rotation){case 0:S=t+(c[0]-b)/g,T=e+this.height-(c[1]-v)/m;break;case 90:S=t+(c[0]-b)/g,T=e-(c[1]-v)/m,[u,f]=[f,-u];break;case 180:S=t-this.width+(c[0]-b)/g,T=e-(c[1]-v)/m,[u,f]=[-u,-f];break;case 270:S=t+(c[0]-b-this.height*m)/g,T=e+(c[1]-v-this.width*g)/m,[u,f]=[-f,u];break}this.setAt(S*r,T*a,u,f)}else this.setAt(t*r,e*a,this.width*r,this.height*a);this.#d(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#c(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(mr,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:n}=e;if(n.length===1&&n[0]==="text/plain")return;t.preventDefault();let r=o.#f(e.getData("text")||"").replaceAll(mr,`
|
|
7
7
|
`);if(!r)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let c=a.getRangeAt(0);if(!r.includes(`
|
|
8
|
-
`)){c.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:u,startOffset:f}=c,g=[],m=[];if(u.nodeType===Node.TEXT_NODE){let S=u.parentElement;if(m.push(u.nodeValue.slice(f).replaceAll(
|
|
8
|
+
`)){c.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:u,startOffset:f}=c,g=[],m=[];if(u.nodeType===Node.TEXT_NODE){let S=u.parentElement;if(m.push(u.nodeValue.slice(f).replaceAll(mr,"")),S!==this.editorDiv){let T=g;for(let w of this.editorDiv.childNodes){if(w===S){T=m;continue}T.push(o.#c(w))}}g.push(u.nodeValue.slice(0,f).replaceAll(mr,""))}else if(u===this.editorDiv){let S=g,T=0;for(let w of this.editorDiv.childNodes)T++===f&&(S=m),S.push(o.#c(w))}this.#e=`${g.join(`
|
|
9
9
|
`)}${r}${m.join(`
|
|
10
|
-
`)}`,this.#d();let
|
|
11
|
-
`)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#h(){return this.#e.replaceAll("\xA0"," ")}static#f(t){return t.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,
|
|
12
|
-
`),position:S,pageIndex:T-1,rect:f.slice(0),rotation:g,id:m,deleted:!1,popupRef:
|
|
13
|
-
`)){let c=document.createElement("div");c.append(a?document.createTextNode(a):document.createElement("br")),e.append(c)}let r=o._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(r,r),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}},lt=class{static PRECISION=1e-4;toSVGPath(){Vt("Abstract method `toSVGPath` must be implemented.")}get box(){Vt("Abstract getter `box` must be implemented.")}serialize(t,e){Vt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,r,a,c){c||=new Float32Array(t.length);for(let u=0,f=t.length;u<f;u+=2)c[u]=e+t[u]*r,c[u+1]=s+t[u+1]*a;return c}static _rescaleAndSwap(t,e,s,r,a,c){c||=new Float32Array(t.length);for(let u=0,f=t.length;u<f;u+=2)c[u]=e+t[u+1]*r,c[u+1]=s+t[u]*a;return c}static _translate(t,e,s,r){r||=new Float32Array(t.length);for(let a=0,c=t.length;a<c;a+=2)r[a]=e+t[a],r[a+1]=s+t[a+1];return r}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,r,a){switch(a){case 90:return[1-e/s,t/r];case 180:return[1-t/s,1-e/r];case 270:return[e/s,1-t/r];default:return[t/s,e/r]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,r,a,c){return[(t+5*s)/6,(e+5*r)/6,(5*s+a)/6,(5*r+c)/6,(s+a)/2,(r+c)/2]}},Br=class o{#t;#e=[];#n;#s;#i=[];#r=new Float32Array(18);#l;#a;#u;#c;#d;#h;#f=[];static#o=8;static#p=2;static#m=o.#o+o.#p;constructor({x:t,y:e},s,r,a,c,u=0){this.#t=s,this.#h=a*r,this.#s=c,this.#r.set([NaN,NaN,NaN,NaN,t,e],6),this.#n=u,this.#c=o.#o*r,this.#u=o.#m*r,this.#d=r,this.#f.push(t,e)}isEmpty(){return isNaN(this.#r[8])}#g(){let t=this.#r.subarray(4,6),e=this.#r.subarray(16,18),[s,r,a,c]=this.#t;return[(this.#l+(t[0]-e[0])/2-s)/a,(this.#a+(t[1]-e[1])/2-r)/c,(this.#l+(e[0]-t[0])/2-s)/a,(this.#a+(e[1]-t[1])/2-r)/c]}add({x:t,y:e}){this.#l=t,this.#a=e;let[s,r,a,c]=this.#t,[u,f,g,m]=this.#r.subarray(8,12),y=t-g,v=e-m,S=Math.hypot(y,v);if(S<this.#u)return!1;let T=S-this.#c,w=T/S,I=w*y,k=w*v,L=u,M=f;u=g,f=m,g+=I,m+=k,this.#f?.push(t,e);let N=-k/T,F=I/T,B=N*this.#h,G=F*this.#h;return this.#r.set(this.#r.subarray(2,8),0),this.#r.set([g+B,m+G],4),this.#r.set(this.#r.subarray(14,18),12),this.#r.set([g-B,m-G],16),isNaN(this.#r[6])?(this.#i.length===0&&(this.#r.set([u+B,f+G],2),this.#i.push(NaN,NaN,NaN,NaN,(u+B-s)/a,(f+G-r)/c),this.#r.set([u-B,f-G],14),this.#e.push(NaN,NaN,NaN,NaN,(u-B-s)/a,(f-G-r)/c)),this.#r.set([L,M,u,f,g,m],6),!this.isEmpty()):(this.#r.set([L,M,u,f,g,m],6),Math.abs(Math.atan2(M-f,L-u)-Math.atan2(k,I))<Math.PI/2?([u,f,g,m]=this.#r.subarray(2,6),this.#i.push(NaN,NaN,NaN,NaN,((u+g)/2-s)/a,((f+m)/2-r)/c),[u,f,L,M]=this.#r.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((L+u)/2-s)/a,((M+f)/2-r)/c),!0):([L,M,u,f,g,m]=this.#r.subarray(0,6),this.#i.push(((L+5*u)/6-s)/a,((M+5*f)/6-r)/c,((5*u+g)/6-s)/a,((5*f+m)/6-r)/c,((u+g)/2-s)/a,((f+m)/2-r)/c),[g,m,u,f,L,M]=this.#r.subarray(12,18),this.#e.push(((L+5*u)/6-s)/a,((M+5*f)/6-r)/c,((5*u+g)/6-s)/a,((5*f+m)/6-r)/c,((u+g)/2-s)/a,((f+m)/2-r)/c),!0))}toSVGPath(){if(this.isEmpty())return"";let t=this.#i,e=this.#e;if(isNaN(this.#r[6])&&!this.isEmpty())return this.#y();let s=[];s.push(`M${t[4]} ${t[5]}`);for(let r=6;r<t.length;r+=6)isNaN(t[r])?s.push(`L${t[r+4]} ${t[r+5]}`):s.push(`C${t[r]} ${t[r+1]} ${t[r+2]} ${t[r+3]} ${t[r+4]} ${t[r+5]}`);this.#b(s);for(let r=e.length-6;r>=6;r-=6)isNaN(e[r])?s.push(`L${e[r+4]} ${e[r+5]}`):s.push(`C${e[r]} ${e[r+1]} ${e[r+2]} ${e[r+3]} ${e[r+4]} ${e[r+5]}`);return this.#x(s),s.join(" ")}#y(){let[t,e,s,r]=this.#t,[a,c,u,f]=this.#g();return`M${(this.#r[2]-t)/s} ${(this.#r[3]-e)/r} L${(this.#r[4]-t)/s} ${(this.#r[5]-e)/r} L${a} ${c} L${u} ${f} L${(this.#r[16]-t)/s} ${(this.#r[17]-e)/r} L${(this.#r[14]-t)/s} ${(this.#r[15]-e)/r} Z`}#x(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){let[e,s,r,a]=this.#t,c=this.#r.subarray(4,6),u=this.#r.subarray(16,18),[f,g,m,y]=this.#g();t.push(`L${(c[0]-e)/r} ${(c[1]-s)/a} L${f} ${g} L${m} ${y} L${(u[0]-e)/r} ${(u[1]-s)/a}`)}newFreeDrawOutline(t,e,s,r,a,c){return new Gr(t,e,s,r,a,c)}getOutlines(){let t=this.#i,e=this.#e,s=this.#r,[r,a,c,u]=this.#t,f=new Float32Array((this.#f?.length??0)+2);for(let y=0,v=f.length-2;y<v;y+=2)f[y]=(this.#f[y]-r)/c,f[y+1]=(this.#f[y+1]-a)/u;if(f[f.length-2]=(this.#l-r)/c,f[f.length-1]=(this.#a-a)/u,isNaN(s[6])&&!this.isEmpty())return this.#S(f);let g=new Float32Array(this.#i.length+24+this.#e.length),m=t.length;for(let y=0;y<m;y+=2){if(isNaN(t[y])){g[y]=g[y+1]=NaN;continue}g[y]=t[y],g[y+1]=t[y+1]}m=this.#E(g,m);for(let y=e.length-6;y>=6;y-=6)for(let v=0;v<6;v+=2){if(isNaN(e[y+v])){g[m]=g[m+1]=NaN,m+=2;continue}g[m]=e[y+v],g[m+1]=e[y+v+1],m+=2}return this.#T(g,m),this.newFreeDrawOutline(g,f,this.#t,this.#d,this.#n,this.#s)}#S(t){let e=this.#r,[s,r,a,c]=this.#t,[u,f,g,m]=this.#g(),y=new Float32Array(36);return y.set([NaN,NaN,NaN,NaN,(e[2]-s)/a,(e[3]-r)/c,NaN,NaN,NaN,NaN,(e[4]-s)/a,(e[5]-r)/c,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,g,m,NaN,NaN,NaN,NaN,(e[16]-s)/a,(e[17]-r)/c,NaN,NaN,NaN,NaN,(e[14]-s)/a,(e[15]-r)/c],0),this.newFreeDrawOutline(y,t,this.#t,this.#d,this.#n,this.#s)}#T(t,e){let s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#E(t,e){let s=this.#r.subarray(4,6),r=this.#r.subarray(16,18),[a,c,u,f]=this.#t,[g,m,y,v]=this.#g();return t.set([NaN,NaN,NaN,NaN,(s[0]-a)/u,(s[1]-c)/f,NaN,NaN,NaN,NaN,g,m,NaN,NaN,NaN,NaN,y,v,NaN,NaN,NaN,NaN,(r[0]-a)/u,(r[1]-c)/f],e),e+=24}},Gr=class extends lt{#t;#e=new Float32Array(4);#n;#s;#i;#r;#l;constructor(t,e,s,r,a,c){super(),this.#l=t,this.#i=e,this.#t=s,this.#r=r,this.#n=a,this.#s=c,this.lastPoint=[NaN,NaN],this.#a(c);let[u,f,g,m]=this.#e;for(let y=0,v=t.length;y<v;y+=2)t[y]=(t[y]-u)/g,t[y+1]=(t[y+1]-f)/m;for(let y=0,v=e.length;y<v;y+=2)e[y]=(e[y]-u)/g,e[y+1]=(e[y+1]-f)/m}toSVGPath(){let t=[`M${this.#l[4]} ${this.#l[5]}`];for(let e=6,s=this.#l.length;e<s;e+=6){if(isNaN(this.#l[e])){t.push(`L${this.#l[e+4]} ${this.#l[e+5]}`);continue}t.push(`C${this.#l[e]} ${this.#l[e+1]} ${this.#l[e+2]} ${this.#l[e+3]} ${this.#l[e+4]} ${this.#l[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,r],a){let c=s-t,u=r-e,f,g;switch(a){case 0:f=lt._rescale(this.#l,t,r,c,-u),g=lt._rescale(this.#i,t,r,c,-u);break;case 90:f=lt._rescaleAndSwap(this.#l,t,e,c,u),g=lt._rescaleAndSwap(this.#i,t,e,c,u);break;case 180:f=lt._rescale(this.#l,s,e,-c,u),g=lt._rescale(this.#i,s,e,-c,u);break;case 270:f=lt._rescaleAndSwap(this.#l,s,r,-c,-u),g=lt._rescaleAndSwap(this.#i,s,r,-c,-u);break}return{outline:Array.from(f),points:[Array.from(g)]}}#a(t){let e=this.#l,s=e[4],r=e[5],a=s,c=r,u=s,f=r,g=s,m=r,y=t?Math.max:Math.min;for(let S=6,T=e.length;S<T;S+=6){if(isNaN(e[S]))a=Math.min(a,e[S+4]),c=Math.min(c,e[S+5]),u=Math.max(u,e[S+4]),f=Math.max(f,e[S+5]),m<e[S+5]?(g=e[S+4],m=e[S+5]):m===e[S+5]&&(g=y(g,e[S+4]));else{let w=bt.bezierBoundingBox(s,r,...e.slice(S,S+6));a=Math.min(a,w[0]),c=Math.min(c,w[1]),u=Math.max(u,w[2]),f=Math.max(f,w[3]),m<w[3]?(g=w[2],m=w[3]):m===w[3]&&(g=y(g,w[2]))}s=e[S+4],r=e[S+5]}let v=this.#e;v[0]=a-this.#n,v[1]=c-this.#n,v[2]=u-a+2*this.#n,v[3]=f-c+2*this.#n,this.lastPoint=[g,m]}get box(){return this.#e}newOutliner(t,e,s,r,a,c=0){return new Br(t,e,s,r,a,c)}getNewOutline(t,e){let[s,r,a,c]=this.#e,[u,f,g,m]=this.#t,y=a*g,v=c*m,S=s*g+u,T=r*m+f,w=this.newOutliner({x:this.#i[0]*y+S,y:this.#i[1]*v+T},this.#t,this.#r,t,this.#s,e??this.#n);for(let I=2;I<this.#i.length;I+=2)w.add({x:this.#i[I]*y+S,y:this.#i[I+1]*v+T});return w.getOutlines()}},ws=class{#t;#e;#n=[];#s=[];constructor(t,e=0,s=0,r=!0){let a=1/0,c=-1/0,u=1/0,f=-1/0,m=10**-4;for(let{x:k,y:L,width:M,height:N}of t){let F=Math.floor((k-e)/m)*m,B=Math.ceil((k+M+e)/m)*m,G=Math.floor((L-e)/m)*m,$=Math.ceil((L+N+e)/m)*m,z=[F,G,$,!0],J=[B,G,$,!1];this.#n.push(z,J),a=Math.min(a,F),c=Math.max(c,B),u=Math.min(u,G),f=Math.max(f,$)}let y=c-a+2*s,v=f-u+2*s,S=a-s,T=u-s,w=this.#n.at(r?-1:-2),I=[w[0],w[2]];for(let k of this.#n){let[L,M,N]=k;k[0]=(L-S)/y,k[1]=(M-T)/v,k[2]=(N-T)/v}this.#t=new Float32Array([S,T,y,v]),this.#e=I}getOutlines(){this.#n.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);let t=[];for(let e of this.#n)e[3]?(t.push(...this.#u(e)),this.#l(e)):(this.#a(e),t.push(...this.#u(e)));return this.#i(t)}#i(t){let e=[],s=new Set;for(let c of t){let[u,f,g]=c;e.push([u,f,c],[u,g,c])}e.sort((c,u)=>c[1]-u[1]||c[0]-u[0]);for(let c=0,u=e.length;c<u;c+=2){let f=e[c][2],g=e[c+1][2];f.push(g),g.push(f),s.add(f),s.add(g)}let r=[],a;for(;s.size>0;){let c=s.values().next().value,[u,f,g,m,y]=c;s.delete(c);let v=u,S=f;for(a=[u,g],r.push(a);;){let T;if(s.has(m))T=m;else if(s.has(y))T=y;else break;s.delete(T),[u,f,g,m,y]=T,v!==u&&(a.push(v,S,u,S===f?f:g),v=u),S=S===f?g:f}a.push(v,S)}return new ca(r,this.#t,this.#e)}#r(t){let e=this.#s,s=0,r=e.length-1;for(;s<=r;){let a=s+r>>1,c=e[a][0];if(c===t)return a;c<t?s=a+1:r=a-1}return r+1}#l([,t,e]){let s=this.#r(t);this.#s.splice(s,0,[t,e])}#a([,t,e]){let s=this.#r(t);for(let r=s;r<this.#s.length;r++){let[a,c]=this.#s[r];if(a!==t)break;if(a===t&&c===e){this.#s.splice(r,1);return}}for(let r=s-1;r>=0;r--){let[a,c]=this.#s[r];if(a!==t)break;if(a===t&&c===e){this.#s.splice(r,1);return}}}#u(t){let[e,s,r]=t,a=[[e,s,r]],c=this.#r(r);for(let u=0;u<c;u++){let[f,g]=this.#s[u];for(let m=0,y=a.length;m<y;m++){let[,v,S]=a[m];if(!(g<=v||S<=f)){if(v>=f){if(S>g)a[m][1]=g;else{if(y===1)return[];a.splice(m,1),m--,y--}continue}a[m][2]=f,S>g&&a.push([e,g,S])}}}return a}},ca=class extends lt{#t;#e;constructor(t,e,s){super(),this.#e=t,this.#t=e,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#e){let[s,r]=e;t.push(`M${s} ${r}`);for(let a=2;a<e.length;a+=2){let c=e[a],u=e[a+1];c===s?(t.push(`V${u}`),r=u):u===r&&(t.push(`H${c}`),s=c)}t.push("Z")}return t.join(" ")}serialize([t,e,s,r],a){let c=[],u=s-t,f=r-e;for(let g of this.#e){let m=new Array(g.length);for(let y=0;y<g.length;y+=2)m[y]=t+g[y]*u,m[y+1]=r-g[y+1]*f;c.push(m)}return c}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}},ks=class extends Br{newFreeDrawOutline(t,e,s,r,a,c){return new ua(t,e,s,r,a,c)}},ua=class extends Gr{newOutliner(t,e,s,r,a,c=0){return new ks(t,e,s,r,a,c)}},Hr=class o{#t=null;#e=null;#n;#s=null;#i=!1;#r=!1;#l=null;#a;#u=null;#c=null;#d;static#h=null;static get _keyboardManager(){return Pt(this,"_keyboardManager",new In([[["Escape","mac+Escape"],o.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],o.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],o.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],o.prototype._moveToPrevious],[["Home","mac+Home"],o.prototype._moveToBeginning],[["End","mac+End"],o.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#r=!1,this.#d=Lt.HIGHLIGHT_COLOR,this.#l=t):(this.#r=!0,this.#d=Lt.HIGHLIGHT_DEFAULT_COLOR),this.#c=t?._uiManager||e,this.#a=this.#c._eventBus,this.#n=t?.color||this.#c?.highlightColors.values().next().value||"#FFFF98",o.#h||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);let e=this.#c._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});let s=this.#e=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#n,t.append(s),t}renderMainDropdown(){let t=this.#s=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){let t=document.createElement("div"),e=this.#c._signal;t.addEventListener("contextmenu",He,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(let[s,r]of this.#c.highlightColors){let a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",r),a.title=s,a.setAttribute("data-l10n-id",o.#h[s]);let c=document.createElement("span");a.append(c),c.className="swatch",c.style.backgroundColor=r,a.setAttribute("aria-selected",r===this.#n),a.addEventListener("click",this.#o.bind(this,r),{signal:e}),t.append(a)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#o(t,e){e.stopPropagation(),this.#a.dispatch("switchannotationeditorparams",{source:this,type:this.#d,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");e&&this.#o(e,t)}_moveToNext(t){if(!this.#y){this.#m(t);return}if(t.target===this.#t){this.#s.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#s?.firstChild||t.target===this.#t){this.#y&&this._hideDropdownFromKeyboard();return}this.#y||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#y){this.#m(t);return}this.#s.firstChild?.focus()}_moveToEnd(t){if(!this.#y){this.#m(t);return}this.#s.lastChild?.focus()}#p(t){o._keyboardManager.exec(this,t)}#m(t){if(this.#y){this.hideDropdown();return}if(this.#i=t.detail===0,this.#u||(this.#u=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#c.combinedSignal(this.#u)})),this.#s){this.#s.classList.remove("hidden");return}let e=this.#s=this.#f();this.#t.append(e)}#g(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#u?.abort(),this.#u=null}get#y(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#r){if(!this.#y){this.#l?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#i})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;let e=this.#c.highlightColors.values();for(let s of this.#s.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}},jr=class o extends Xt{#t=null;#e=0;#n;#s=null;#i=null;#r=null;#l=null;#a=0;#u=null;#c=null;#d=null;#h=!1;#f=null;#o;#p=null;#m="";#g;#y="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Rt.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=o.prototype;return Pt(this,"_keyboardManager",new In([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||o._defaultColor,this.#g=t.thickness||o._defaultThickness,this.#o=t.opacity||o._defaultOpacity,this.#n=t.boxes||null,this.#y=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#h=!0,this.#b(t),this.#R()):this.#n&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#l=t.focusNode,this.#a=t.focusOffset,this.#x(),this.#R(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#h?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#y}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#x(){let t=new ws(this.#n,.001);this.#c=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#c.box;let e=new ws(this.#n,.0025,.001,this._uiManager.direction==="ltr");this.#r=e.getOutlines();let{lastPoint:s}=this.#r;this.#f=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#b({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#c=t;let r=1.5;if(this.#r=t.getNewOutline(this.#g/2+r,.0025),e>=0)this.#d=e,this.#s=s,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},!0);else if(this.parent){let m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#d,{bbox:o.#A(this.#c.box,(m-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:o.#A(this.#r.box,m),path:{d:this.#r.toSVGPath()}})}let[a,c,u,f]=t.box;switch(this.rotation){case 0:this.x=a,this.y=c,this.width=u,this.height=f;break;case 90:{let[m,y]=this.parentDimensions;this.x=c,this.y=1-a,this.width=u*y/m,this.height=f*m/y;break}case 180:this.x=1-a,this.y=1-c,this.width=u,this.height=f;break;case 270:{let[m,y]=this.parentDimensions;this.x=1-c,this.y=a,this.width=u*y/m,this.height=f*m/y;break}}let{lastPoint:g}=this.#r;this.#f=[(g[0]-a)/u,(g[1]-c)/f]}static initialize(t,e){Xt.initialize(t,e),o._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Lt.HIGHLIGHT_DEFAULT_COLOR:o._defaultColor=e;break;case Lt.HIGHLIGHT_THICKNESS:o._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case Lt.HIGHLIGHT_COLOR:this.#S(e);break;case Lt.HIGHLIGHT_THICKNESS:this.#T(e);break}}static get defaultPropertiesToUpdate(){return[[Lt.HIGHLIGHT_DEFAULT_COLOR,o._defaultColor],[Lt.HIGHLIGHT_THICKNESS,o._defaultThickness]]}get propertiesToUpdate(){return[[Lt.HIGHLIGHT_COLOR,this.color||o._defaultColor],[Lt.HIGHLIGHT_THICKNESS,this.#g||o._defaultThickness],[Lt.HIGHLIGHT_FREE,this.#h]]}#S(t){let e=(a,c)=>{this.color=a,this.#o=c,this.parent?.drawLayer.updateProperties(this.#d,{root:{fill:a,"fill-opacity":c}}),this.#i?.updateColor(a)},s=this.color,r=this.#o;this.addCommands({cmd:e.bind(this,t,o._defaultOpacity),undo:e.bind(this,s,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Lt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#T(t){let e=this.#g,s=r=>{this.#g=r,this.#E(r)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Lt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){let t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#i=new Hr({editor:this}),t.addColorPicker(this.#i)),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.#O())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#O())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#k(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#R(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#k():t&&(this.#R(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#E(t){if(!this.#h)return;this.#b({highlightOutlines:this.#c.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#k(){this.#d===null||!this.parent||(this.parent.drawLayer.remove(this.#d),this.#d=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#R(t=this.parent){this.#d===null&&({id:this.#d,clipPathId:this.#s}=t.drawLayer.draw({bbox:this.#c.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#h},path:{d:this.#c.toSVGPath()}},!1,!0),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#h},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},this.#h),this.#u&&(this.#u.style.clipPath=this.#s))}static#A([t,e,s,r],a){switch(a){case 90:return[1-e-r,t,r,s];case 180:return[1-t-s,1-e-r,s,r];case 270:return[e,1-t-s,r,s]}return[t,e,s,r]}rotate(t){let{drawLayer:e}=this.parent,s;this.#h?(t=(t-this.rotation+360)%360,s=o.#A(this.#c.box,t)):s=o.#A([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#d,{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:o.#A(this.#r.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#h?t.classList.add("free"):this.div.addEventListener("keydown",this.#I.bind(this),{signal:this._uiManager._signal});let e=this.#u=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#s;let[s,r]=this.parentDimensions;return this.setDims(this.width*s,this.height*r),mr(this,this.#u,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#I(t){o._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#w(!0);break;case 1:case 3:this.#w(!1);break}}#w(t){if(!this.#t)return;let e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#l,this.#a)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#h||this.#w(!1))}get _mustFixPosition(){return!this.#h}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#d,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#O(){return this.#h?this.rotation:0}#D(){if(this.#h)return null;let[t,e]=this.pageDimensions,[s,r]=this.pageTranslation,a=this.#n,c=new Float32Array(a.length*8),u=0;for(let{x:f,y:g,width:m,height:y}of a){let v=f*t+s,S=(1-g)*e+r;c[u]=c[u+4]=v,c[u+1]=c[u+3]=S,c[u+2]=c[u+6]=v+m*t,c[u+5]=c[u+7]=S-y*e,u+=8}return c}#_(t){return this.#c.serialize(t,this.#O())}static startHighlighting(t,e,{target:s,x:r,y:a}){let{x:c,y:u,width:f,height:g}=s.getBoundingClientRect(),m=new AbortController,y=t.combinedSignal(m),v=S=>{m.abort(),this.#v(t,S)};window.addEventListener("blur",v,{signal:y}),window.addEventListener("pointerup",v,{signal:y}),window.addEventListener("pointerdown",Ee,{capture:!0,passive:!1,signal:y}),window.addEventListener("contextmenu",He,{signal:y}),s.addEventListener("pointermove",this.#C.bind(this,t),{signal:y}),this._freeHighlight=new ks({x:r,y:a},[c,u,f,g],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#C(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#v(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,s){let r=null;if(t instanceof Nr){let{data:{quadPoints:T,rect:w,rotation:I,id:k,color:L,opacity:M,popupRef:N},parent:{page:{pageNumber:F}}}=t;r=t={annotationType:Rt.HIGHLIGHT,color:Array.from(L),opacity:M,quadPoints:T,boxes:null,pageIndex:F-1,rect:w.slice(0),rotation:I,id:k,deleted:!1,popupRef:N}}else if(t instanceof Es){let{data:{inkLists:T,rect:w,rotation:I,id:k,color:L,borderStyle:{rawWidth:M},popupRef:N},parent:{page:{pageNumber:F}}}=t;r=t={annotationType:Rt.HIGHLIGHT,color:Array.from(L),thickness:M,inkLists:T,boxes:null,pageIndex:F-1,rect:w.slice(0),rotation:I,id:k,deleted:!1,popupRef:N}}let{color:a,quadPoints:c,inkLists:u,opacity:f}=t,g=await super.deserialize(t,e,s);g.color=bt.makeHexColor(...a),g.#o=f||1,u&&(g.#g=t.thickness),g.annotationElementId=t.id||null,g._initialData=r;let[m,y]=g.pageDimensions,[v,S]=g.pageTranslation;if(c){let T=g.#n=[];for(let w=0;w<c.length;w+=8)T.push({x:(c[w]-v)/m,y:1-(c[w+1]-S)/y,width:(c[w+2]-c[w])/m,height:(c[w+1]-c[w+5])/y});g.#x(),g.#R(),g.rotate(g.rotation)}else if(u){g.#h=!0;let T=u[0],w={x:T[0]-v,y:y-(T[1]-S)},I=new ks(w,[0,0,m,y],1,g.#g/2,!0,.001);for(let M=0,N=T.length;M<N;M+=2)w.x=T[M]-v,w.y=y-(T[M+1]-S),I.add(w);let{id:k,clipPathId:L}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:g.color,"fill-opacity":g._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:I.toSVGPath()}},!0,!0);g.#b({highlightOutlines:I.getOutlines(),highlightId:k,clipPathId:L}),g.#R()}return g}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=this.getRect(0,0),s=Xt._colorManager.convert(this.color),r={annotationType:Rt.HIGHLIGHT,color:s,opacity:this.#o,thickness:this.#g,quadPoints:this.#D(),outlines:this.#_(e),pageIndex:this.pageIndex,rect:e,rotation:this.#O(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#M(r)?null:(r.id=this.annotationElementId,r)}#M(t){let{color:e}=this._initialData;return t.color.some((s,r)=>s!==e[r])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},ha=class{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,s]of Object.entries(t))this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){let t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){Vt("Not implemented")}},da=class o extends Xt{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#s=null;static#i=null;static#r=NaN;static#l=null;static#a=null;static#u=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#c(t),this.#f())}#c({drawOutlines:t,drawId:e,drawingOptions:s}){this.#t=t,this._drawingOptions||=s,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#d(t,this.parent),this.#m(t.box)}#d(t,e){let{id:s}=e.drawLayer.draw(o._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}static _mergeSVGProperties(t,e){let s=new Set(Object.keys(t));for(let[r,a]of Object.entries(e))s.has(r)?Object.assign(t[r],a):t[r]=a;return t}static getDefaultDrawingOptions(t){Vt("Not implemented")}static get typesMap(){Vt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(o.#n.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[s,r]of this.typesMap)t.push([s,e[r]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[s,r]of this.constructor.typesMap)t.push([s,e[r]]);return t}_updateProperty(t,e,s){let r=this._drawingOptions,a=r[e],c=u=>{r.updateProperty(e,u);let f=this.#t.updateProperty(e,u);f&&this.#m(f),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:c.bind(this,s),undo:c.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#h(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#h()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#h(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#d(this.#t,t)}}#o([t,e,s,r]){let{parentDimensions:[a,c],rotation:u}=this;switch(u){case 90:return[e,1-t,s*(c/a),r*(a/c)];case 180:return[1-t,1-e,s,r];case 270:return[1-e,t,s*(c/a),r*(a/c)];default:return[t,e,s,r]}}#p(){let{x:t,y:e,width:s,height:r,parentDimensions:[a,c],rotation:u}=this;switch(u){case 90:return[1-e,t,s*(a/c),r*(c/a)];case 180:return[1-t,1-e,s,r];case 270:return[e,1-t,s*(a/c),r*(c/a)];default:return[t,e,s,r]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#o(t),this.div){this.fixAndSetPosition();let[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}this._onResized()}#g(){let{x:t,y:e,width:s,height:r,rotation:a,parentRotation:c,parentDimensions:[u,f]}=this;switch((a*4+c)/90){case 1:return[1-e-r,t,r,s];case 2:return[1-t-s,1-e-r,s,r];case 3:return[e,1-t-s,r,s];case 4:return[t,e-s*(u/f),r*(f/u),s*(u/f)];case 5:return[1-e,t,s*(u/f),r*(f/u)];case 6:return[1-t-r*(f/u),1-e,r*(f/u),s*(u/f)];case 7:return[e-s*(u/f),1-t-r*(f/u),s*(u/f),r*(f/u)];case 8:return[t-s,e-r,s,r];case 9:return[1-e,t-s,r,s];case 10:return[1-t,1-e,s,r];case 11:return[e-r,1-t,r,s];case 12:return[t-r*(f/u),e,r*(f/u),s*(u/f)];case 13:return[1-e-s*(u/f),t-r*(f/u),s*(u/f),r*(f/u)];case 14:return[1-t,1-e-s*(u/f),r*(f/u),s*(u/f)];case 15:return[e,1-t,s*(u/f),r*(f/u)];default:return[t,e,s,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";let[s,r]=this.parentDimensions;return this.setDims(this.width*s,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,s,r,a){Vt("Not implemented")}static startDrawing(t,e,s,r){let{target:a,offsetX:c,offsetY:u,pointerId:f,pointerType:g}=r;if(o.#l&&o.#l!==g)return;let{viewport:{rotation:m}}=t,{width:y,height:v}=a.getBoundingClientRect(),S=o.#s=new AbortController,T=t.combinedSignal(S);if(o.#r||=f,o.#l??=g,window.addEventListener("pointerup",w=>{o.#r===w.pointerId?this._endDraw(w):o.#a?.delete(w.pointerId)},{signal:T}),window.addEventListener("pointercancel",w=>{o.#r===w.pointerId?this._currentParent.endDrawingSession():o.#a?.delete(w.pointerId)},{signal:T}),window.addEventListener("pointerdown",w=>{o.#l===w.pointerType&&((o.#a||=new Set).add(w.pointerId),o.#n.isCancellable()&&(o.#n.removeLastElement(),o.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:T}),window.addEventListener("contextmenu",He,{signal:T}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:T}),a.addEventListener("touchmove",w=>{w.timeStamp===o.#u&&Ee(w)},{signal:T}),t.toggleDrawing(),e._editorUndoBar?.hide(),o.#n){t.drawLayer.updateProperties(this._currentDrawId,o.#n.startNew(c,u,y,v,m));return}e.updateUIForDefaultProperties(this),o.#n=this.createDrawerInstance(c,u,y,v,m),o.#i=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(o.#i.toSVGProperties(),o.#n.defaultSVGProperties),!0,!1)}static _drawMove(t){if(o.#u=-1,!o.#n)return;let{offsetX:e,offsetY:s,pointerId:r}=t;if(o.#r===r){if(o.#a?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,o.#n.add(e,s)),o.#u=t.timeStamp,Ee(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,o.#n=null,o.#i=null,o.#l=null,o.#u=NaN),o.#s&&(o.#s.abort(),o.#s=null,o.#r=NaN,o.#a=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,o.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let s=o.#n,r=this._currentDrawId,a=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(r,s.setLastElement(a))},undo:()=>{e.drawLayer.updateProperties(r,s.removeLastElement())},mustExec:!1,type:Lt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Lt.DRAW_STEP),!o.#n.isEmpty()){let{pageDimensions:[s,r],scale:a}=e,c=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:o.#n.getOutlines(s*a,r*a,a,this._INNER_MARGIN),drawingOptions:o.#i,mustBeCommitted:!t});return this._cleanup(!0),c}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,r,a,c){Vt("Not implemented")}static async deserialize(t,e,s){let{rawDims:{pageWidth:r,pageHeight:a,pageX:c,pageY:u}}=e.viewport,f=this.deserializeDraw(c,u,r,a,this._INNER_MARGIN,t),g=await super.deserialize(t,e,s);return g.createDrawingOptions(t),g.#c({drawOutlines:f}),g.#f(),g.onScaleChanging(),g.rotate(),g}serializeDraw(t){let[e,s]=this.pageTranslation,[r,a]=this.pageDimensions;return this.#t.serialize([e,s,r,a],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},fa=class{#t=new Float64Array(6);#e;#n;#s;#i;#r;#l="";#a=0;#u=new Vr;#c;#d;constructor(t,e,s,r,a,c){this.#c=s,this.#d=r,this.#s=a,this.#i=c,[t,e]=this.#h(t,e);let u=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#n=[{line:u,points:this.#r}],this.#t.set(u,0)}updateProperty(t,e){t==="stroke-width"&&(this.#i=e)}#h(t,e){return lt._normalizePoint(t,e,this.#c,this.#d,this.#s)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#r.length<=10}add(t,e){[t,e]=this.#h(t,e);let[s,r,a,c]=this.#t.subarray(2,6),u=t-a,f=e-c;return Math.hypot(this.#c*u,this.#d*f)<=2?null:(this.#r.push(t,e),isNaN(s)?(this.#t.set([a,c,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([s,r,a,c,t,e],0),this.#e.push(...lt.createBezierPoints(s,r,a,c,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){let s=this.add(t,e);return s||(this.#r.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,r,a){this.#c=s,this.#d=r,this.#s=a,[t,e]=this.#h(t,e);let c=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e];let u=this.#n.at(-1);return u&&(u.line=new Float32Array(u.line),u.points=new Float32Array(u.points)),this.#n.push({line:c,points:this.#r}),this.#t.set(c,0),this.#a=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(t){return this.#n?(this.#n.push(t),this.#e=t.line,this.#r=t.points,this.#a=0,{path:{d:this.toSVGPath()}}):this.#u.setLastElement(t)}removeLastElement(){if(!this.#n)return this.#u.removeLastElement();this.#n.pop(),this.#l="";for(let t=0,e=this.#n.length;t<e;t++){let{line:s,points:r}=this.#n[t];this.#e=s,this.#r=r,this.#a=0,this.toSVGPath()}return{path:{d:this.#l}}}toSVGPath(){let t=lt.svgRound(this.#e[4]),e=lt.svgRound(this.#e[5]);if(this.#r.length===2)return this.#l=`${this.#l} M ${t} ${e} Z`,this.#l;if(this.#r.length<=6){let r=this.#l.lastIndexOf("M");this.#l=`${this.#l.slice(0,r)} M ${t} ${e}`,this.#a=6}if(this.#r.length===4){let r=lt.svgRound(this.#e[10]),a=lt.svgRound(this.#e[11]);return this.#l=`${this.#l} L ${r} ${a}`,this.#a=12,this.#l}let s=[];this.#a===0&&(s.push(`M ${t} ${e}`),this.#a=6);for(let r=this.#a,a=this.#e.length;r<a;r+=6){let[c,u,f,g,m,y]=this.#e.slice(r,r+6).map(lt.svgRound);s.push(`C${c} ${u} ${f} ${g} ${m} ${y}`)}return this.#l+=s.join(" "),this.#a=this.#e.length,this.#l}getOutlines(t,e,s,r){let a=this.#n.at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),this.#u.build(this.#n,t,e,s,this.#s,this.#i,r),this.#t=null,this.#e=null,this.#n=null,this.#l=null,this.#u}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},Vr=class o extends lt{#t;#e=0;#n;#s;#i;#r;#l;#a;#u;build(t,e,s,r,a,c,u){this.#i=e,this.#r=s,this.#l=r,this.#a=a,this.#u=c,this.#n=u??0,this.#s=t,this.#h()}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#s){if(t.push(`M${lt.svgRound(e[4])} ${lt.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12){t.push(`L${lt.svgRound(e[10])} ${lt.svgRound(e[11])}`);continue}for(let s=6,r=e.length;s<r;s+=6){let[a,c,u,f,g,m]=e.subarray(s,s+6).map(lt.svgRound);t.push(`C${a} ${c} ${u} ${f} ${g} ${m}`)}}return t.join("")}serialize([t,e,s,r],a){let c=[],u=[],[f,g,m,y]=this.#d(),v,S,T,w,I,k,L,M,N;switch(this.#a){case 0:N=lt._rescale,v=t,S=e+r,T=s,w=-r,I=t+f*s,k=e+(1-g-y)*r,L=t+(f+m)*s,M=e+(1-g)*r;break;case 90:N=lt._rescaleAndSwap,v=t,S=e,T=s,w=r,I=t+g*s,k=e+f*r,L=t+(g+y)*s,M=e+(f+m)*r;break;case 180:N=lt._rescale,v=t+s,S=e,T=-s,w=r,I=t+(1-f-m)*s,k=e+g*r,L=t+(1-f)*s,M=e+(g+y)*r;break;case 270:N=lt._rescaleAndSwap,v=t+s,S=e+r,T=-s,w=-r,I=t+(1-g-y)*s,k=e+(1-f-m)*r,L=t+(1-g)*s,M=e+(1-f)*r;break}for(let{line:F,points:B}of this.#s)c.push(N(F,v,S,T,w,a?new Array(F.length):null)),u.push(N(B,v,S,T,w,a?new Array(B.length):null));return{lines:c,points:u,rect:[I,k,L,M]}}static deserialize(t,e,s,r,a,{paths:{lines:c,points:u},rotation:f,thickness:g}){let m=[],y,v,S,T,w;switch(f){case 0:w=lt._rescale,y=-t/s,v=e/r+1,S=1/s,T=-1/r;break;case 90:w=lt._rescaleAndSwap,y=-e/r,v=-t/s,S=1/r,T=1/s;break;case 180:w=lt._rescale,y=t/s+1,v=-e/r,S=-1/s,T=1/r;break;case 270:w=lt._rescaleAndSwap,y=e/r+1,v=t/s+1,S=-1/r,T=-1/s;break}if(!c){c=[];for(let k of u){let L=k.length;if(L===2){c.push(new Float32Array([NaN,NaN,NaN,NaN,k[0],k[1]]));continue}if(L===4){c.push(new Float32Array([NaN,NaN,NaN,NaN,k[0],k[1],NaN,NaN,NaN,NaN,k[2],k[3]]));continue}let M=new Float32Array(3*(L-2));c.push(M);let[N,F,B,G]=k.subarray(0,4);M.set([NaN,NaN,NaN,NaN,N,F],0);for(let $=4;$<L;$+=2){let z=k[$],J=k[$+1];M.set(lt.createBezierPoints(N,F,B,G,z,J),($-2)*3),[N,F,B,G]=[B,G,z,J]}}}for(let k=0,L=c.length;k<L;k++)m.push({line:w(c[k].map(M=>M??NaN),y,v,S,T),points:w(u[k].map(M=>M??NaN),y,v,S,T)});let I=new o;return I.build(m,s,r,1,f,g,a),I}#c(t=this.#u){let e=this.#n+t/2*this.#l;return this.#a%180===0?[e/this.#i,e/this.#r]:[e/this.#r,e/this.#i]}#d(){let[t,e,s,r]=this.#t,[a,c]=this.#c(0);return[t+a,e+c,s-2*a,r-2*c]}#h(){let t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:r}of this.#s){if(r.length<=12){for(let u=4,f=r.length;u<f;u+=6){let[g,m]=r.subarray(u,u+2);t[0]=Math.min(t[0],g),t[1]=Math.min(t[1],m),t[2]=Math.max(t[2],g),t[3]=Math.max(t[3],m)}continue}let a=r[4],c=r[5];for(let u=6,f=r.length;u<f;u+=6){let[g,m,y,v,S,T]=r.subarray(u,u+6);bt.bezierBoundingBox(a,c,g,m,y,v,S,T,t),a=S,c=T}}let[e,s]=this.#c();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-s)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+s)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,s]=this.#c();this.#u=t;let[r,a]=this.#c(),[c,u]=[r-e,a-s],f=this.#t;return f[0]-=c,f[1]-=u,f[2]+=2*c,f[3]+=2*u,f}updateParentDimensions([t,e],s){let[r,a]=this.#c();this.#i=t,this.#r=e,this.#l=s;let[c,u]=this.#c(),f=c-r,g=u-a,m=this.#t;return m[0]-=f,m[1]-=g,m[2]+=2*f,m[3]+=2*g,m}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(lt.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${lt.svgRound(t)} ${lt.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,s=0,r=0,a=0,c=0,u=0,f=0;switch(this.#e){case 90:r=e/t,a=-t/e,u=t;break;case 180:s=-1,c=-1,u=t,f=e;break;case 270:r=-e/t,a=t/e,f=e;break;default:return""}return`matrix(${s} ${r} ${a} ${c} ${lt.svgRound(u)} ${lt.svgRound(f)})`}getPathResizingSVGProperties([t,e,s,r]){let[a,c]=this.#c(),[u,f,g,m]=this.#t;if(Math.abs(g-a)<=lt.PRECISION||Math.abs(m-c)<=lt.PRECISION){let w=t+s/2-(u+g/2),I=e+r/2-(f+m/2);return{path:{"transform-origin":`${lt.svgRound(t)} ${lt.svgRound(e)}`,transform:`${this.rotationTransform} translate(${w} ${I})`}}}let y=(s-2*a)/(g-2*a),v=(r-2*c)/(m-2*c),S=g/s,T=m/r;return{path:{"transform-origin":`${lt.svgRound(u)} ${lt.svgRound(f)}`,transform:`${this.rotationTransform} scale(${S} ${T}) translate(${lt.svgRound(a)} ${lt.svgRound(c)}) scale(${y} ${v}) translate(${lt.svgRound(-a)} ${lt.svgRound(-c)})`}}}getPathResizedSVGProperties([t,e,s,r]){let[a,c]=this.#c(),u=this.#t,[f,g,m,y]=u;if(u[0]=t,u[1]=e,u[2]=s,u[3]=r,Math.abs(m-a)<=lt.PRECISION||Math.abs(y-c)<=lt.PRECISION){let I=t+s/2-(f+m/2),k=e+r/2-(g+y/2);for(let{line:L,points:M}of this.#s)lt._translate(L,I,k,L),lt._translate(M,I,k,M);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${lt.svgRound(t)} ${lt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let v=(s-2*a)/(m-2*a),S=(r-2*c)/(y-2*c),T=-v*(f+a)+t+a,w=-S*(g+c)+e+c;if(v!==1||S!==1||T!==0||w!==0)for(let{line:I,points:k}of this.#s)lt._rescale(I,T,w,v,S,I),lt._rescale(k,T,w,v,S,k);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${lt.svgRound(t)} ${lt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){let[r,a]=s,c=this.#t,u=t-c[0],f=e-c[1];if(this.#i===r&&this.#r===a)for(let{line:g,points:m}of this.#s)lt._translate(g,u,f,g),lt._translate(m,u,f,m);else{let g=this.#i/r,m=this.#r/a;this.#i=r,this.#r=a;for(let{line:y,points:v}of this.#s)lt._rescale(y,u,f,g,m,y),lt._rescale(v,u,f,g,m,v);c[2]*=g,c[3]*=m}return c[0]=t,c[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${lt.svgRound(t)} ${lt.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${lt.svgRound(t[0])} ${lt.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}},pa=class o extends ha{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:Xt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){let t=new o(this.#t);return t.updateAll(this),t}},ga=class o extends da{static _type="ink";static _editorType=Rt.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){Xt.initialize(t,e),this._defaultDrawingOptions=new pa(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Pt(this,"typesMap",new Map([[Lt.INK_THICKNESS,"stroke-width"],[Lt.INK_COLOR,"stroke"],[Lt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,r,a){return new fa(t,e,s,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,r,a,c){return Vr.deserialize(t,e,s,r,a,c)}static async deserialize(t,e,s){let r=null;if(t instanceof Es){let{data:{inkLists:c,rect:u,rotation:f,id:g,color:m,opacity:y,borderStyle:{rawWidth:v},popupRef:S},parent:{page:{pageNumber:T}}}=t;r=t={annotationType:Rt.INK,color:Array.from(m),thickness:v,opacity:y,paths:{points:c},boxes:null,pageIndex:T-1,rect:u.slice(0),rotation:f,id:g,deleted:!1,popupRef:S}}let a=await super.deserialize(t,e,s);return a.annotationElementId=t.id||null,a._initialData=r,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=o.getDefaultDrawingOptions({stroke:bt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:s,rect:r}=this.serializeDraw(t),{_drawingOptions:{stroke:a,"stroke-opacity":c,"stroke-width":u}}=this,f={annotationType:Rt.INK,color:Xt._colorManager.convert(a),opacity:c,thickness:u,paths:{lines:e,points:s},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?f:this.annotationElementId&&!this.#t(f)?null:(f.id=this.annotationElementId,f)}#t(t){let{color:e,thickness:s,opacity:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((c,u)=>c!==e[u])||t.thickness!==s||t.opacity!==r||t.pageIndex!==a}renderAnnotationElement(t){let{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e}),null}},ma=class o extends Xt{#t=null;#e=null;#n=null;#s=null;#i=null;#r="";#l=null;#a=null;#u=!1;#c=!1;static _type="stamp";static _editorType=Rt.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#s=t.bitmapUrl,this.#i=t.bitmapFile}static initialize(t,e){Xt.initialize(t,e)}static get supportedTypes(){return Pt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return Pt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(Rt.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#u=t.isSvg),t.file&&(this.#r=t.file.name),this.#o()}#h(){if(this.#n=null,this._uiManager.enableWaiting(!1),!!this.#l){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");let{data:r,width:a,height:c}=t||this.copyCanvas(null,null,!0).imageData,u=await s.guess({name:"altText",request:{data:r,width:a,height:c,channels:r.length/(a*c)}});if(!u)throw new Error("No response from the AI service.");if(u.error)throw new Error("Error from the AI service.");if(u.cancel)return null;if(!u.output)throw new Error("No valid response from the AI service.");let f=u.output;return await this.setGuessedAltText(f),e&&!this.hasAltTextData()&&(this.altTextData={alt:f,decorative:!1}),f}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#d(s,!0)).finally(()=>this.#h());return}if(this.#s){let s=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(s).then(r=>this.#d(r)).finally(()=>this.#h());return}if(this.#i){let s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(s).then(r=>this.#d(r)).finally(()=>this.#h());return}let t=document.createElement("input");t.type="file",t.accept=o.supportedTypesStr;let e=this._uiManager._signal;this.#n=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let r=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(r)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#h()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#l?.remove(),this.#l=null,this.#a&&(clearTimeout(this.#a),this.#a=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#f();return}super.rebuild(),this.div!==null&&(this.#e&&this.#l===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#n||this.#t||this.#s||this.#i||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#o():this.#f(),this.width&&!this.annotationElementId){let[s,r]=this.parentDimensions;this.setAt(t*s,e*r,this.width*s,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#a!==null&&clearTimeout(this.#a);let t=200;this.#a=setTimeout(()=>{this.#a=null,this.#m()},t)}#o(){let{div:t}=this,{width:e,height:s}=this.#t,[r,a]=this.pageDimensions,c=.75;if(this.width)e=this.width*r,s=this.height*a;else if(e>c*r||s>c*a){let m=Math.min(c*r/e,c*a/s);e*=m,s*=m}let[u,f]=this.parentDimensions;this.setDims(e*u/r,s*f/a),this._uiManager.enableWaiting(!1);let g=this.#l=document.createElement("canvas");g.setAttribute("role","img"),this.addContainer(g),this.width=e/r,this.height=s/a,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#c||(this.parent.addUndoableEditor(this),this.#c=!0),this._reportTelemetry({action:"inserted_image"}),this.#r&&g.setAttribute("aria-label",this.#r)}copyCanvas(t,e,s=!1){t||(t=224);let{width:r,height:a}=this.#t,c=new bs,u=this.#t,f=r,g=a,m=null;if(e){if(r>e||a>e){let B=Math.min(e/r,e/a);f=Math.floor(r*B),g=Math.floor(a*B)}m=document.createElement("canvas");let v=m.width=Math.ceil(f*c.sx),S=m.height=Math.ceil(g*c.sy);this.#u||(u=this.#p(v,S));let T=m.getContext("2d");T.filter=this._uiManager.hcmFilter;let w="white",I="#cfcfd8";this._uiManager.hcmFilter!=="none"?I="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(w="#8f8f9d",I="#42414d");let k=15,L=k*c.sx,M=k*c.sy,N=new OffscreenCanvas(L*2,M*2),F=N.getContext("2d");F.fillStyle=w,F.fillRect(0,0,L*2,M*2),F.fillStyle=I,F.fillRect(0,0,L,M),F.fillRect(L,M,L,M),T.fillStyle=T.createPattern(N,"repeat"),T.fillRect(0,0,v,S),T.drawImage(u,0,0,u.width,u.height,0,0,v,S)}let y=null;if(s){let v,S;if(c.symmetric&&u.width<t&&u.height<t)v=u.width,S=u.height;else if(u=this.#t,r>t||a>t){let I=Math.min(t/r,t/a);v=Math.floor(r*I),S=Math.floor(a*I),this.#u||(u=this.#p(v,S))}let w=new OffscreenCanvas(v,S).getContext("2d",{willReadFrequently:!0});w.drawImage(u,0,0,u.width,u.height,0,0,v,S),y={width:v,height:S,data:w.getImageData(0,0,v,S).data}}return{canvas:m,width:f,height:g,imageData:y}}#p(t,e){let{width:s,height:r}=this.#t,a=s,c=r,u=this.#t;for(;a>2*t||c>2*e;){let f=a,g=c;a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),c>2*e&&(c=c>=16384?Math.floor(c/2)-1:Math.ceil(c/2));let m=new OffscreenCanvas(a,c);m.getContext("2d").drawImage(u,0,0,f,g,0,0,a,c),u=m.transferToImageBitmap()}return u}#m(){let[t,e]=this.parentDimensions,{width:s,height:r}=this,a=new bs,c=Math.ceil(s*t*a.sx),u=Math.ceil(r*e*a.sy),f=this.#l;if(!f||f.width===c&&f.height===u)return;f.width=c,f.height=u;let g=this.#u?this.#t:this.#p(c,u),m=f.getContext("2d");m.filter=this._uiManager.hcmFilter,m.drawImage(g,0,0,g.width,g.height,0,0,c,u)}getImageForAltText(){return this.#l}#g(t){if(t){if(this.#u){let r=this._uiManager.imageManager.getSvgUrl(this.#e);if(r)return r}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#u){let[e,s]=this.pageDimensions,r=Math.round(this.width*e*pn.PDF_TO_CSS_UNITS),a=Math.round(this.height*s*pn.PDF_TO_CSS_UNITS),c=new OffscreenCanvas(r,a);return c.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,r,a),c.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let r=null;if(t instanceof Ur){let{data:{rect:T,rotation:w,id:I,structParent:k,popupRef:L},container:M,parent:{page:{pageNumber:N}}}=t,F=M.querySelector("canvas"),B=s.imageManager.getFromCanvas(M.id,F);F.remove();let G=(await e._structTree.getAriaAttributes(`${xa}${I}`))?.get("aria-label")||"";r=t={annotationType:Rt.STAMP,bitmapId:B.id,bitmap:B.bitmap,pageIndex:N-1,rect:T.slice(0),rotation:w,id:I,deleted:!1,accessibilityData:{decorative:!1,altText:G},isSvg:!1,structParent:k,popupRef:L}}let a=await super.deserialize(t,e,s),{rect:c,bitmap:u,bitmapUrl:f,bitmapId:g,isSvg:m,accessibilityData:y}=t;g&&s.imageManager.isValidId(g)?(a.#e=g,u&&(a.#t=u)):a.#s=f,a.#u=m;let[v,S]=a.pageDimensions;return a.width=(c[2]-c[0])/v,a.height=(c[3]-c[1])/S,a.annotationElementId=t.id||null,y&&(a.altTextData=y),a._initialData=r,a.#c=!!r,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let s={annotationType:Rt.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#u,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#g(!0),s.accessibilityData=this.serializeAltText(!0),s;let{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(s.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){let u=this.#y(s);if(u.isSame)return null;u.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,e===null)return s;e.stamps||=new Map;let c=this.#u?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:c,serialized:s}),s.bitmap=this.#g(!1);else if(this.#u){let u=e.stamps.get(this.#e);c>u.area&&(u.area=c,u.serialized.bitmap.close(),u.serialized.bitmap=this.#g(!1))}return s}#y(t){let{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,r=t.pageIndex===e,a=(t.accessibilityData?.alt||"")===s;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}},ya=class o{#t;#e=!1;#n=null;#s=null;#i=null;#r=new Map;#l=!1;#a=!1;#u=!1;#c=null;#d=null;#h=null;#f=null;#o;static _initialized=!1;static#p=new Map([la,ga,ma,jr].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:r,accessibilityManager:a,annotationLayer:c,drawLayer:u,textLayer:f,viewport:g,l10n:m}){let y=[...o.#p.values()];if(!o._initialized){o._initialized=!0;for(let v of y)v.initialize(m,t)}t.registerEditorTypes(y),this.#o=t,this.pageIndex=e,this.div=s,this.#t=a,this.#n=c,this.viewport=g,this.#h=f,this.drawLayer=u,this._structTree=r,this.#o.addLayer(this)}get isEmpty(){return this.#r.size===0}get isInvisible(){return this.isEmpty&&this.#o.getMode()===Rt.NONE}updateToolbar(t){this.#o.updateToolbar(t)}updateMode(t=this.#o.getMode()){switch(this.#b(),t){case Rt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Rt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Rt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;for(let s of o.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}setEditingState(t){this.#o.setEditingState(t)}addCommands(t){this.#o.addCommands(t)}cleanUndoStack(t){this.#o.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#n?.div.classList.toggle("disabled",!t)}async enable(){this.#u=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let s of this.#r.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#o.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#n){this.#u=!1;return}let e=this.#n.getEditableAnnotations();for(let s of e){if(s.hide(),this.#o.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;let r=await this.deserialize(s);r&&(this.addOrRebuild(r),r.enableEditing())}this.#u=!1}disable(){this.#a=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let r of this.#r.values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){t.set(r.annotationElementId,r);continue}else e.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}if(this.#n){let r=this.#n.getEditableAnnotations();for(let a of r){let{id:c}=a.data;if(this.#o.isDeletedAnnotationElement(c))continue;let u=e.get(c);if(u){u.resetAnnotationElement(a),u.show(!1),a.show();continue}u=t.get(c),u&&(this.#o.addChangedExistingAnnotation(u),u.renderAnnotationElement(a)&&u.show(!1)),a.show()}}this.#b(),this.isEmpty&&(this.div.hidden=!0);let{classList:s}=this.div;for(let r of o.#p.values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#a=!1}getEditableAnnotation(t){return this.#n?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#o.getActive()!==t&&this.#o.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#f){this.#f=new AbortController;let t=this.#o.combinedSignal(this.#f);this.#h.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#h?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#h.div.classList.remove("highlighting"))}#m(t){this.#o.unselectAll();let{target:e}=t;if(e===this.#h.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#h.div.contains(e)){let{isMac:s}=ne.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#o.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),this.toggleDrawing(),jr.startHighlighting(this,this.#o.direction==="ltr",{target:this.#h.div,x:t.x,y:t.y}),this.#h.div.addEventListener("pointerup",()=>{this.#h.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),t.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;let t=this.#o.combinedSignal(this.#s);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#s?.abort(),this.#s=null}attach(t){this.#r.set(t.id,t);let{annotationElementId:e}=t;e&&this.#o.isDeletedAnnotationElement(e)&&this.#o.removeDeletedAnnotationElement(t)}detach(t){this.#r.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#a&&t.annotationElementId&&this.#o.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#o.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#o.addDeletedAnnotationElement(t.annotationElementId),Xt.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.#o.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#u),this.#o.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#i&&(t._focusEventsAllowed=!1,this.#i=setTimeout(()=>{this.#i=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){let e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return this.#o.getId()}get#g(){return o.#p.get(this.#o.getMode())}combinedSignal(t){return this.#o.combinedSignal(t)}#y(t){let e=this.#g;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#o.updateToolbar(t),this.#o.updateMode(t);let{offsetX:s,offsetY:r}=this.#x(),a=this.getNextId(),c=this.#y({parent:this,id:a,x:s,y:r,uiManager:this.#o,isCentered:!0,...e});c&&this.add(c)}async deserialize(t){return await o.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#o)||null}createAndAddNewEditor(t,e,s={}){let r=this.getNextId(),a=this.#y({parent:this,id:r,x:t.offsetX,y:t.offsetY,uiManager:this.#o,isCentered:e,...s});return a&&this.add(a),a}#x(){let{x:t,y:e,width:s,height:r}=this.div.getBoundingClientRect(),a=Math.max(0,t),c=Math.max(0,e),u=Math.min(window.innerWidth,t+s),f=Math.min(window.innerHeight,e+r),g=(a+u)/2-t,m=(c+f)/2-e,[y,v]=this.viewport.rotation%180===0?[g,m]:[m,g];return{offsetX:y,offsetY:v}}addNewEditor(){this.createAndAddNewEditor(this.#x(),!0)}setSelected(t){this.#o.setSelected(t)}toggleSelected(t){this.#o.toggleSelected(t)}unselect(t){this.#o.unselect(t)}pointerup(t){let{isMac:e}=ne.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#l&&(this.#l=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#o.getMode()===Rt.STAMP){this.#o.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#o.getMode()===Rt.HIGHLIGHT&&this.enableTextSelection(),this.#l){this.#l=!1;return}let{isMac:e}=ne.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#l=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}let s=this.#o.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#c){this.#g.startDrawing(this,this.#o,!1,t);return}this.#o.setCurrentDrawingSession(this),this.#c=new AbortController;let e=this.#o.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#d=null,this.commitOrRemove())},{signal:e}),this.#g.startDrawing(this,this.#o,!1,t)}pause(t){if(t){let{activeElement:e}=document;this.div.contains(e)&&(this.#d=e);return}this.#d&&setTimeout(()=>{this.#d?.focus(),this.#d=null},0)}endDrawingSession(t=!1){return this.#c?(this.#o.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#d=null,this.#g.endDrawing(t)):null}findNewParent(t,e,s){let r=this.#o.findParent(e,s);return r===null||r===this?!1:(r.changeParent(t),!0)}commitOrRemove(){return this.#c?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#c&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#i&&(clearTimeout(this.#i),this.#i=null);for(let t of this.#r.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#r.clear(),this.#o.removeLayer(this)}#b(){for(let t of this.#r.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,kn(this.div,t);for(let e of this.#o.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#o.commitOrRemove(),this.#b();let e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,kn(this.div,{rotation:s}),e!==s)for(let r of this.#r.values())r.rotate(s)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#o.viewParameters.realScale}},ba=class o{#t=null;#e=0;#n=new Map;#s=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#n.size>0)for(let e of this.#n.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return Pt(this,"_svgFactory",new Ts)}static#i(t,[e,s,r,a]){let{style:c}=t;c.top=`${100*s}%`,c.left=`${100*e}%`,c.width=`${100*r}%`,c.height=`${100*a}%`}#r(){let t=o._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#l(t,e){let s=o._svgFactory.createElement("clipPath");t.append(s);let r=`clip_${e}`;s.setAttribute("id",r),s.setAttribute("clipPathUnits","objectBoundingBox");let a=o._svgFactory.createElement("use");return s.append(a),a.setAttribute("href",`#${e}`),a.classList.add("clip"),r}#a(t,e){for(let[s,r]of Object.entries(e))r===null?t.removeAttribute(s):t.setAttribute(s,r)}draw(t,e=!1,s=!1){let r=this.#e++,a=this.#r(),c=o._svgFactory.createElement("defs");a.append(c);let u=o._svgFactory.createElement("path");c.append(u);let f=`path_p${this.pageIndex}_${r}`;u.setAttribute("id",f),u.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#s.set(r,u);let g=s?this.#l(c,f):null,m=o._svgFactory.createElement("use");return a.append(m),m.setAttribute("href",`#${f}`),this.updateProperties(a,t),this.#n.set(r,a),{id:r,clipPathId:`url(#${g})`}}drawOutline(t,e){let s=this.#e++,r=this.#r(),a=o._svgFactory.createElement("defs");r.append(a);let c=o._svgFactory.createElement("path");a.append(c);let u=`path_p${this.pageIndex}_${s}`;c.setAttribute("id",u),c.setAttribute("vector-effect","non-scaling-stroke");let f;if(e){let y=o._svgFactory.createElement("mask");a.append(y),f=`mask_p${this.pageIndex}_${s}`,y.setAttribute("id",f),y.setAttribute("maskUnits","objectBoundingBox");let v=o._svgFactory.createElement("rect");y.append(v),v.setAttribute("width","1"),v.setAttribute("height","1"),v.setAttribute("fill","white");let S=o._svgFactory.createElement("use");y.append(S),S.setAttribute("href",`#${u}`),S.setAttribute("stroke","none"),S.setAttribute("fill","black"),S.setAttribute("fill-rule","nonzero"),S.classList.add("mask")}let g=o._svgFactory.createElement("use");r.append(g),g.setAttribute("href",`#${u}`),f&&g.setAttribute("mask",`url(#${f})`);let m=g.cloneNode();return r.append(m),g.classList.add("mainOutline"),m.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#n.set(s,r),s}finalizeDraw(t,e){this.#s.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:s,bbox:r,rootClass:a,path:c}=e,u=typeof t=="number"?this.#n.get(t):t;if(u){if(s&&this.#a(u,s),r&&o.#i(u,r),a){let{classList:f}=u;for(let[g,m]of Object.entries(a))f.toggle(g,m)}if(c){let g=u.firstChild.firstChild;this.#a(g,c)}}}updateParent(t,e){if(e===this)return;let s=this.#n.get(t);s&&(e.#t.append(s),this.#n.delete(t),e.#n.set(t,s))}remove(t){this.#s.delete(t),this.#t!==null&&(this.#n.get(t).remove(),this.#n.delete(t))}destroy(){this.#t=null;for(let t of this.#n.values())t.remove();this.#n.clear(),this.#s.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:ws};py=Et.AbortException,gy=Et.AnnotationEditorLayer,my=Et.AnnotationEditorParamsType,yy=Et.AnnotationEditorType,by=Et.AnnotationEditorUIManager,vy=Et.AnnotationLayer,Jr=Et.AnnotationMode,xy=Et.ColorPicker,Sy=Et.DOMSVGFactory,Ay=Et.DrawLayer,Ty=Et.FeatureTest,Cy=Et.GlobalWorkerOptions,Ey=Et.ImageKind,wy=Et.InvalidPDFException,ky=Et.MissingPDFException,Iy=Et.OPS,Ry=Et.OutputScale,Py=Et.PDFDataRangeTransport,Oy=Et.PDFDateString,Ly=Et.PDFWorker,My=Et.PasswordResponses,Dy=Et.PermissionFlag,Fy=Et.PixelsPerInch,_y=Et.RenderingCancelledException,Ny=Et.TextLayer,Uy=Et.TouchManager,By=Et.UnexpectedResponseException,Gy=Et.Util,Hy=Et.VerbosityLevel,jy=Et.XfaLayer,Vy=Et.build,$y=Et.createValidAbsoluteUrl,zy=Et.fetchData,Wy=Et.getDocument,Xy=Et.getFilenameFromUrl,Yy=Et.getPdfFilenameFromUrl,Ky=Et.getXfaPageViewport,Zy=Et.isDataScheme,Qy=Et.isPdfFile,Jy=Et.noContextMenu,qy=Et.normalizeUnicode,tb=Et.setLayerDimensions,eb=Et.shadow,nb=Et.stopEvent,sb=Et.version});var ka=l0((fu,ei)=>{var du=(()=>{var o=Object.defineProperty,t=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,r=(n,i)=>{for(var l in i)o(n,l,{get:i[l],enumerable:!0})},a=(n,i,l,h)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of e(i))!s.call(n,d)&&d!==l&&o(n,d,{get:()=>i[d],enumerable:!(h=t(i,d))||h.enumerable});return n},c=n=>a(o({},"__esModule",{value:!0}),n),u={};r(u,{BoundingBox:()=>pt,Font:()=>Ec,Glyph:()=>Gn,Path:()=>st,_parse:()=>it,load:()=>qm,loadSync:()=>t0,parse:()=>Jm});var f=0,g=-3;function m(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function y(n,i){this.source=n,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=i,this.destLen=0,this.ltree=new m,this.dtree=new m}var v=new m,S=new m,T=new Uint8Array(30),w=new Uint16Array(30),I=new Uint8Array(30),k=new Uint16Array(30),L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),M=new m,N=new Uint8Array(320);function F(n,i,l,h){var d,p;for(d=0;d<l;++d)n[d]=0;for(d=0;d<30-l;++d)n[d+l]=d/l|0;for(p=h,d=0;d<30;++d)i[d]=p,p+=1<<n[d]}function B(n,i){var l;for(l=0;l<7;++l)n.table[l]=0;for(n.table[7]=24,n.table[8]=152,n.table[9]=112,l=0;l<24;++l)n.trans[l]=256+l;for(l=0;l<144;++l)n.trans[24+l]=l;for(l=0;l<8;++l)n.trans[168+l]=280+l;for(l=0;l<112;++l)n.trans[176+l]=144+l;for(l=0;l<5;++l)i.table[l]=0;for(i.table[5]=32,l=0;l<32;++l)i.trans[l]=l}var G=new Uint16Array(16);function $(n,i,l,h){var d,p;for(d=0;d<16;++d)n.table[d]=0;for(d=0;d<h;++d)n.table[i[l+d]]++;for(n.table[0]=0,p=0,d=0;d<16;++d)G[d]=p,p+=n.table[d];for(d=0;d<h;++d)i[l+d]&&(n.trans[G[i[l+d]]++]=d)}function z(n){n.bitcount--||(n.tag=n.source[n.sourceIndex++],n.bitcount=7);var i=n.tag&1;return n.tag>>>=1,i}function J(n,i,l){if(!i)return l;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var h=n.tag&65535>>>16-i;return n.tag>>>=i,n.bitcount-=i,h+l}function et(n,i){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var l=0,h=0,d=0,p=n.tag;do h=2*h+(p&1),p>>>=1,++d,l+=i.table[d],h-=i.table[d];while(h>=0);return n.tag=p,n.bitcount-=d,i.trans[l+h]}function nt(n,i,l){var h,d,p,b,x,A;for(h=J(n,5,257),d=J(n,5,1),p=J(n,4,4),b=0;b<19;++b)N[b]=0;for(b=0;b<p;++b){var E=J(n,3,0);N[L[b]]=E}for($(M,N,0,19),x=0;x<h+d;){var C=et(n,M);switch(C){case 16:var P=N[x-1];for(A=J(n,2,3);A;--A)N[x++]=P;break;case 17:for(A=J(n,3,3);A;--A)N[x++]=0;break;case 18:for(A=J(n,7,11);A;--A)N[x++]=0;break;default:N[x++]=C;break}}$(i,N,0,h),$(l,N,h,d)}function xt(n,i,l){for(;;){var h=et(n,i);if(h===256)return f;if(h<256)n.dest[n.destLen++]=h;else{var d,p,b,x;for(h-=257,d=J(n,T[h],w[h]),p=et(n,l),b=n.destLen-J(n,I[p],k[p]),x=b;x<b+d;++x)n.dest[n.destLen++]=n.dest[x]}}}function vt(n){for(var i,l,h;n.bitcount>8;)n.sourceIndex--,n.bitcount-=8;if(i=n.source[n.sourceIndex+1],i=256*i+n.source[n.sourceIndex],l=n.source[n.sourceIndex+3],l=256*l+n.source[n.sourceIndex+2],i!==(~l&65535))return g;for(n.sourceIndex+=4,h=i;h;--h)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,f}function St(n,i){var l=new y(n,i),h,d,p;do{switch(h=z(l),d=J(l,2,0),d){case 0:p=vt(l);break;case 1:p=xt(l,v,S);break;case 2:nt(l,l.ltree,l.dtree),p=xt(l,l.ltree,l.dtree);break;default:p=g}if(p!==f)throw new Error("Data error")}while(!h);return l.destLen<l.dest.length?typeof l.dest.slice=="function"?l.dest.slice(0,l.destLen):l.dest.subarray(0,l.destLen):l.dest}B(v,S),F(T,w,4,3),F(I,k,2,1),T[28]=0,w[28]=258;function W(n,i,l,h,d){return Math.pow(1-d,3)*n+3*Math.pow(1-d,2)*d*i+3*(1-d)*Math.pow(d,2)*l+Math.pow(d,3)*h}function K(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}K.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},K.prototype.addPoint=function(n,i){typeof n=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=n,this.x2=n),n<this.x1&&(this.x1=n),n>this.x2&&(this.x2=n)),typeof i=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=i,this.y2=i),i<this.y1&&(this.y1=i),i>this.y2&&(this.y2=i))},K.prototype.addX=function(n){this.addPoint(n,null)},K.prototype.addY=function(n){this.addPoint(null,n)},K.prototype.addBezier=function(n,i,l,h,d,p,b,x){let A=[n,i],E=[l,h],C=[d,p],P=[b,x];this.addPoint(n,i),this.addPoint(b,x);for(let R=0;R<=1;R++){let D=6*A[R]-12*E[R]+6*C[R],O=-3*A[R]+9*E[R]-9*C[R]+3*P[R],_=3*E[R]-3*A[R];if(O===0){if(D===0)continue;let At=-_/D;0<At&&At<1&&(R===0&&this.addX(W(A[R],E[R],C[R],P[R],At)),R===1&&this.addY(W(A[R],E[R],C[R],P[R],At)));continue}let V=Math.pow(D,2)-4*_*O;if(V<0)continue;let mt=(-D+Math.sqrt(V))/(2*O);0<mt&&mt<1&&(R===0&&this.addX(W(A[R],E[R],C[R],P[R],mt)),R===1&&this.addY(W(A[R],E[R],C[R],P[R],mt)));let ht=(-D-Math.sqrt(V))/(2*O);0<ht&&ht<1&&(R===0&&this.addX(W(A[R],E[R],C[R],P[R],ht)),R===1&&this.addY(W(A[R],E[R],C[R],P[R],ht)))}},K.prototype.addQuad=function(n,i,l,h,d,p){let b=n+.6666666666666666*(l-n),x=i+2/3*(h-i),A=b+1/3*(d-n),E=x+1/3*(p-i);this.addBezier(n,i,b,x,A,E,d,p)};var pt=K;function ft(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var X={};function gt(n,i){let l=Math.floor(n),h=n-l;if(X[i]||(X[i]={}),X[i][h]!==void 0){let p=X[i][h];return l+p}let d=+(Math.round(h+"e+"+i)+"e-"+i);return X[i][h]=d,l+d}function Z(n){let i=[[]],l=0,h=0;for(let d=0;d<n.length;d+=1){let p=i[i.length-1],b=n[d],x=p[0],A=p[1],E=p[p.length-1],C=n[d+1];p.push(b),b.type==="M"?(l=b.x,h=b.y):b.type==="L"&&(!C||C.type==="Z")?Math.abs(b.x-l)>1||Math.abs(b.y-h)>1||p.pop():b.type==="L"&&E&&E.x===b.x&&E.y===b.y?p.pop():b.type==="Z"&&(x&&A&&E&&x.type==="M"&&A.type==="L"&&E.type==="L"&&E.x===x.x&&E.y===x.y&&(p.shift(),p[0].type="M"),d+1<n.length&&i.push([]))}return n=[].concat.apply([],i),n}function tt(n){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},n)}function ct(n){return parseInt(n)===n&&(n={decimalPlaces:n,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},n)}ft.prototype.fromSVG=function(n,i={}){typeof SVGPathElement<"u"&&n instanceof SVGPathElement&&(n=n.getAttribute("d")),i=tt(i),this.commands=[];let l="0123456789",h="MmLlQqCcZzHhVv",d="SsTtAa",p="-+",b={},x=[""],A=!1;function E(O){return O.filter(_=>_.length).map(_=>{let V=parseFloat(_);return(i.decimalPlaces||i.decimalPlaces===0)&&(V=gt(V,i.decimalPlaces)),V})}function C(O){if(!this.commands.length)return O;let _=this.commands[this.commands.length-1];for(let V=0;V<O.length;V++)O[V]+=_[V&1?"y":"x"];return O}function P(){if(b.type===void 0)return;let O=b.type.toUpperCase(),_=O!=="Z"&&b.type.toUpperCase()!==b.type,V=E(x);if(x=[""],!V.length&&O!=="Z")return;_&&O!=="H"&&O!=="V"&&(V=C.apply(this,[V]));let mt=this.commands.length&&this.commands[this.commands.length-1].x||0,ht=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(O){case"M":this.moveTo(...V);break;case"L":this.lineTo(...V);break;case"V":for(let At=0;At<V.length;At++){let kt=0;_&&(kt=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(mt,V[At]+kt)}break;case"H":for(let At=0;At<V.length;At++){let kt=0;_&&(kt=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(V[At]+kt,ht)}break;case"C":this.bezierCurveTo(...V);break;case"Q":this.quadraticCurveTo(...V);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let At in this.commands[this.commands.length-1])this.commands[this.commands.length-1][At]===void 0&&(this.commands[this.commands.length-1][At]=0)}for(let O=0;O<n.length;O++){let _=n.charAt(O),V=x[x.length-1];if(l.indexOf(_)>-1)x[x.length-1]+=_;else if(p.indexOf(_)>-1)if(!b.type&&!this.commands.length&&(b.type="L"),_==="-")!b.type||V.indexOf("-")>0?A=!0:V.length?x.push("-"):x[x.length-1]=_;else if(!b.type||V.length>0)A=!0;else continue;else if(h.indexOf(_)>-1)b.type?(P.apply(this),b={type:_}):b.type=_;else{if(d.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+h.split("").join(", ")+".");` ,
|
|
14
|
-
\r\f\v`.indexOf(_)>-1?x.push(""):_==="."?!b.type||V.indexOf(_)>-1?A=!0:x[x.length-1]+=_:A=!0}if(A)throw new Error("Unexpected character: "+_+" at offset "+O)}P.apply(this),i.optimize&&(this.commands=Z(this.commands));let R=i.flipY,D=i.flipYBase;if(R===!0&&i.flipYBase===void 0){let O=this.getBoundingBox();D=O.y1+O.y2}for(let O in this.commands){let _=this.commands[O];for(let V in _)["x","x1","x2"].includes(V)?this.commands[O][V]=i.x+_[V]*i.scale:["y","y1","y2"].includes(V)&&(this.commands[O][V]=i.y+(R?D-_[V]:_[V])*i.scale)}return this},ft.fromSVG=function(n,i){return new ft().fromSVG(n,i)},ft.prototype.moveTo=function(n,i){this.commands.push({type:"M",x:n,y:i})},ft.prototype.lineTo=function(n,i){this.commands.push({type:"L",x:n,y:i})},ft.prototype.curveTo=ft.prototype.bezierCurveTo=function(n,i,l,h,d,p){this.commands.push({type:"C",x1:n,y1:i,x2:l,y2:h,x:d,y:p})},ft.prototype.quadTo=ft.prototype.quadraticCurveTo=function(n,i,l,h){this.commands.push({type:"Q",x1:n,y1:i,x:l,y:h})},ft.prototype.close=ft.prototype.closePath=function(){this.commands.push({type:"Z"})},ft.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof pt){let i=n;this.moveTo(i.x1,i.y1),this.lineTo(i.x2,i.y1),this.lineTo(i.x2,i.y2),this.lineTo(i.x1,i.y2),this.close();return}Array.prototype.push.apply(this.commands,n)},ft.prototype.getBoundingBox=function(){let n=new pt,i=0,l=0,h=0,d=0;for(let p=0;p<this.commands.length;p++){let b=this.commands[p];switch(b.type){case"M":n.addPoint(b.x,b.y),i=h=b.x,l=d=b.y;break;case"L":n.addPoint(b.x,b.y),h=b.x,d=b.y;break;case"Q":n.addQuad(h,d,b.x1,b.y1,b.x,b.y),h=b.x,d=b.y;break;case"C":n.addBezier(h,d,b.x1,b.y1,b.x2,b.y2,b.x,b.y),h=b.x,d=b.y;break;case"Z":h=i,d=l;break;default:throw new Error("Unexpected path command "+b.type)}}return n.isEmpty()&&n.addPoint(0,0),n},ft.prototype.draw=function(n){let i=this._layers;if(i&&i.length){for(let h=0;h<i.length;h++)this.draw.call(i[h],n);return}let l=this._image;if(l){n.drawImage(l.image,l.x,l.y,l.width,l.height);return}n.beginPath();for(let h=0;h<this.commands.length;h+=1){let d=this.commands[h];d.type==="M"?n.moveTo(d.x,d.y):d.type==="L"?n.lineTo(d.x,d.y):d.type==="C"?n.bezierCurveTo(d.x1,d.y1,d.x2,d.y2,d.x,d.y):d.type==="Q"?n.quadraticCurveTo(d.x1,d.y1,d.x,d.y):d.type==="Z"&&this.stroke&&this.strokeWidth&&n.closePath()}this.fill&&(n.fillStyle=this.fill,n.fill()),this.stroke&&(n.strokeStyle=this.stroke,n.lineWidth=this.strokeWidth,n.stroke())},ft.prototype.toPathData=function(n){n=ct(n);function i(x){let A=gt(x,n.decimalPlaces);return Math.round(x)===A?""+A:A.toFixed(n.decimalPlaces)}function l(){let x="";for(let A=0;A<arguments.length;A+=1){let E=arguments[A];E>=0&&A>0&&(x+=" "),x+=i(E)}return x}let h=this.commands;n.optimize&&(h=JSON.parse(JSON.stringify(this.commands)),h=Z(h));let d=n.flipY,p=n.flipYBase;if(d===!0&&p===void 0){let x=new ft;x.extend(h);let A=x.getBoundingBox();p=A.y1+A.y2}let b="";for(let x=0;x<h.length;x+=1){let A=h[x];A.type==="M"?b+="M"+l(A.x,d?p-A.y:A.y):A.type==="L"?b+="L"+l(A.x,d?p-A.y:A.y):A.type==="C"?b+="C"+l(A.x1,d?p-A.y1:A.y1,A.x2,d?p-A.y2:A.y2,A.x,d?p-A.y:A.y):A.type==="Q"?b+="Q"+l(A.x1,d?p-A.y1:A.y1,A.x,d?p-A.y:A.y):A.type==="Z"&&(b+="Z")}return b},ft.prototype.toSVG=function(n,i){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),i||(i=this.toPathData(n));let l='<path d="';return l+=i,l+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?l+=' fill="none"':l+=' fill="'+this.fill+'"'),this.stroke&&(l+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),l+="/>",l},ft.prototype.toDOMElement=function(n,i){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),i||(i=this.toPathData(n));let l=document.createElementNS("http://www.w3.org/2000/svg","path");return l.setAttribute("d",i),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?l.setAttribute("fill","none"):l.setAttribute("fill",this.fill)),this.stroke&&(l.setAttribute("stroke",this.stroke),l.setAttribute("stroke-width",this.strokeWidth)),l};var st=ft;function Y(n){throw new Error(n)}function j(n,i){n||Y(i)}var H={fail:Y,argument:j,assert:j},Tt=32768,Ot=2147483648,Ct=-32768,zt=32767+1/65536,Nt={},q={},at={};function Ft(n){return function(){return n}}q.BYTE=function(n){return H.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]},at.BYTE=Ft(1),q.CHAR=function(n){return[n.charCodeAt(0)]},at.CHAR=Ft(1),q.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let i=[];for(let l=0;l<n.length;l+=1)i[l]=n.charCodeAt(l);return i},at.CHARARRAY=function(n){return typeof n>"u"?0:n.length},q.USHORT=function(n){return[n>>8&255,n&255]},at.USHORT=Ft(2),q.SHORT=function(n){return n>=Tt&&(n=-(2*Tt-n)),[n>>8&255,n&255]},at.SHORT=Ft(2),q.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]},at.UINT24=Ft(3),q.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]},at.ULONG=Ft(4),q.LONG=function(n){return n>=Ot&&(n=-(2*Ot-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]},at.LONG=Ft(4),q.FLOAT=function(n){if(n>zt||n<Ct)throw new Error(`Value ${n} is outside the range of representable values in 16.16 format`);let i=Math.round(n*65536)<<0;return q.ULONG(i)},at.FLOAT=at.ULONG,q.FIXED=q.ULONG,at.FIXED=at.ULONG,q.FWORD=q.SHORT,at.FWORD=at.SHORT,q.UFWORD=q.USHORT,at.UFWORD=at.USHORT,q.F2DOT14=function(n){return q.USHORT(n*16384)},at.F2DOT14=at.USHORT,q.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]},at.LONGDATETIME=Ft(8),q.TAG=function(n){return H.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]},at.TAG=Ft(4),q.Card8=q.BYTE,at.Card8=at.BYTE,q.Card16=q.USHORT,at.Card16=at.USHORT,q.OffSize=q.BYTE,at.OffSize=at.BYTE,q.SID=q.USHORT,at.SID=at.USHORT,q.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?q.NUMBER16(n):q.NUMBER32(n)},at.NUMBER=function(n){return q.NUMBER(n).length},q.NUMBER16=function(n){return[28,n>>8&255,n&255]},at.NUMBER16=Ft(3),q.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]},at.NUMBER32=Ft(5),q.REAL=function(n){let i=n.toString(),l=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(i);if(l){let p=parseFloat("1e"+((l[2]?+l[2]:0)+l[1].length));i=(Math.round(n*p)/p).toString()}let h="";for(let p=0,b=i.length;p<b;p+=1){let x=i[p];x==="e"?h+=i[++p]==="-"?"c":"b":x==="."?h+="a":x==="-"?h+="e":h+=x}h+=h.length&1?"f":"ff";let d=[30];for(let p=0,b=h.length;p<b;p+=2)d.push(parseInt(h.substr(p,2),16));return d},at.REAL=function(n){return q.REAL(n).length},q.NAME=q.CHARARRAY,at.NAME=at.CHARARRAY,q.STRING=q.CHARARRAY,at.STRING=at.CHARARRAY,Nt.UTF8=function(n,i,l){let h=[],d=l;for(let p=0;p<d;p++,i+=1)h[p]=n.getUint8(i);return String.fromCharCode.apply(null,h)},Nt.UTF16=function(n,i,l){let h=[],d=l/2;for(let p=0;p<d;p++,i+=2)h[p]=n.getUint16(i);return String.fromCharCode.apply(null,h)},q.UTF16=function(n){let i=[];for(let l=0;l<n.length;l+=1){let h=n.charCodeAt(l);i[i.length]=h>>8&255,i[i.length]=h&255}return i},at.UTF16=function(n){return n.length*2};var Me={"x-mac-croatian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\u0160\u2122\xB4\xA8\u2260\u017D\xD8\u221E\xB1\u2264\u2265\u2206\xB5\u2202\u2211\u220F\u0161\u222B\xAA\xBA\u03A9\u017E\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u0106\xAB\u010C\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\uF8FF\xA9\u2044\u20AC\u2039\u203A\xC6\xBB\u2013\xB7\u201A\u201E\u2030\xC2\u0107\xC1\u010D\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u0111\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u03C0\xCB\u02DA\xB8\xCA\xE6\u02C7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\xB0\u0490\xA3\xA7\u2022\xB6\u0406\xAE\xA9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\xB1\u2264\u2265\u0456\xB5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E","x-mac-gaelic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u1E02\xB1\u2264\u2265\u1E03\u010A\u010B\u1E0A\u1E0B\u1E1E\u1E1F\u0120\u0121\u1E40\xE6\xF8\u1E41\u1E56\u1E57\u027C\u0192\u017F\u1E60\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u1E61\u1E9B\xFF\u0178\u1E6A\u20AC\u2039\u203A\u0176\u0177\u1E6B\xB7\u1EF2\u1EF3\u204A\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u2663\xD2\xDA\xDB\xD9\u0131\xDD\xFD\u0174\u0175\u1E84\u1E85\u1E80\u1E81\u1E82\u1E83","x-mac-greek":"\xC4\xB9\xB2\xC9\xB3\xD6\xDC\u0385\xE0\xE2\xE4\u0384\xA8\xE7\xE9\xE8\xEA\xEB\xA3\u2122\xEE\xEF\u2022\xBD\u2030\xF4\xF6\xA6\u20AC\xF9\xFB\xFC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\xDF\xAE\xA9\u03A3\u03AA\xA7\u2260\xB0\xB7\u0391\xB1\u2264\u2265\xA5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\xAC\u039F\u03A1\u2248\u03A4\xAB\xBB\u2026\xA0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\xF7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\xAD","x-mac-icelandic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\xDD\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\xD0\xF0\xDE\xFE\xFD\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140A\u140B\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144E\u144F\u1450\u1451\u1455\u1456\u1466\u146D\u146E\u146F\u1470\u1472\u1473\u1483\u148B\u148C\u148D\u148E\u1490\u1491\xB0\u14A1\u14A5\u14A6\u2022\xB6\u14A7\xAE\xA9\u2122\u14A8\u14AA\u14AB\u14BB\u14C2\u14C3\u14C4\u14C5\u14C7\u14C8\u14D0\u14EF\u14F0\u14F1\u14F2\u14F4\u14F5\u1505\u14D5\u14D6\u14D7\u14D8\u14DA\u14DB\u14EA\u1528\u1529\u152A\u152B\u152D\u2026\xA0\u152E\u153E\u1555\u1556\u1557\u2013\u2014\u201C\u201D\u2018\u2019\u1558\u1559\u155A\u155D\u1546\u1547\u1548\u1549\u154B\u154C\u1550\u157F\u1580\u1581\u1582\u1583\u1584\u1585\u158F\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15A0\u15A1\u15A2\u15A3\u15A4\u15A5\u15A6\u157C\u0141\u0142","x-mac-ce":"\xC4\u0100\u0101\xC9\u0104\xD6\xDC\xE1\u0105\u010C\xE4\u010D\u0106\u0107\xE9\u0179\u017A\u010E\xED\u010F\u0112\u0113\u0116\xF3\u0117\xF4\xF6\xF5\xFA\u011A\u011B\xFC\u2020\xB0\u0118\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\u0119\xA8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\xAC\u221A\u0144\u0147\u2206\xAB\xBB\u2026\xA0\u0148\u0150\xD5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\xC1\u0164\u0165\xCD\u017D\u017E\u016A\xD3\xD4\u016B\u016E\xDA\u016F\u0170\u0171\u0172\u0173\xDD\xFD\u0137\u017B\u0141\u017C\u0122\u02C7",macintosh:"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\uFB01\uFB02\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-romanian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\u0102\u0218\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\u0103\u0219\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\u021A\u021B\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-turkish":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\uF8A0\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7"};Nt.MACSTRING=function(n,i,l,h){let d=Me[h];if(d===void 0)return;let p="";for(let b=0;b<l;b++){let x=n.getUint8(i+b);x<=127?p+=String.fromCharCode(x):p+=d[x&127]}return p};var nn=typeof WeakMap=="function"&&new WeakMap,Ze,gh=function(n){if(!Ze){Ze={};for(let d in Me)Ze[d]=new String(d)}let i=Ze[n];if(i===void 0)return;if(nn){let d=nn.get(i);if(d!==void 0)return d}let l=Me[n];if(l===void 0)return;let h={};for(let d=0;d<l.length;d++)h[l.charCodeAt(d)]=d+128;return nn&&nn.set(i,h),h};q.MACSTRING=function(n,i){let l=gh(i);if(l===void 0)return;let h=[];for(let d=0;d<n.length;d++){let p=n.charCodeAt(d);if(p>=128&&(p=l[p],p===void 0))return;h[d]=p}return h},at.MACSTRING=function(n,i){let l=q.MACSTRING(n,i);return l!==void 0?l.length:0};function hi(n){return n>=-128&&n<=127}function mh(n,i,l){let h=0,d=n.length;for(;i<d&&h<64&&n[i]===0;)++i,++h;return l.push(128|h-1),i}function yh(n,i,l){let h=0,d=n.length,p=i;for(;p<d&&h<64;){let b=n[p];if(!hi(b)||b===0&&p+1<d&&n[p+1]===0)break;++p,++h}l.push(h-1);for(let b=i;b<p;++b)l.push(n[b]+256&255);return p}function bh(n,i,l){let h=0,d=n.length,p=i;for(;p<d&&h<64;){let b=n[p];if(b===0||hi(b)&&p+1<d&&hi(n[p+1]))break;++p,++h}l.push(64|h-1);for(let b=i;b<p;++b){let x=n[b];l.push(x+65536>>8&255,x+256&255)}return p}q.VARDELTAS=function(n){let i=0,l=[];for(;i<n.length;){let h=n[i];h===0?i=mh(n,i,l):h>=-128&&h<=127?i=yh(n,i,l):i=bh(n,i,l)}return l},q.INDEX=function(n){let i=1,l=[i],h=[];for(let x=0;x<n.length;x+=1){let A=q.OBJECT(n[x]);Array.prototype.push.apply(h,A),i+=A.length,l.push(i)}if(h.length===0)return[0,0];let d=[],p=1+Math.floor(Math.log(i)/Math.log(2))/8|0,b=[void 0,q.BYTE,q.USHORT,q.UINT24,q.ULONG][p];for(let x=0;x<l.length;x+=1){let A=b(l[x]);Array.prototype.push.apply(d,A)}return Array.prototype.concat(q.Card16(n.length),q.OffSize(p),d,h)},at.INDEX=function(n){return q.INDEX(n).length},q.DICT=function(n){let i=[],l=Object.keys(n),h=l.length;for(let d=0;d<h;d+=1){let p=parseInt(l[d],0),b=n[p],x=q.OPERAND(b.value,b.type),A=q.OPERATOR(p);for(let E=0;E<x.length;E++)i.push(x[E]);for(let E=0;E<A.length;E++)i.push(A[E])}return i},at.DICT=function(n){return q.DICT(n).length},q.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]},q.OPERAND=function(n,i){let l=[];if(Array.isArray(i))for(let h=0;h<i.length;h+=1){H.argument(n.length===i.length,"Not enough arguments given for type"+i);let d=q.OPERAND(n[h],i[h]);for(let p=0;p<d.length;p++)l.push(d[p])}else if(i==="SID"){let h=q.NUMBER(n);for(let d=0;d<h.length;d++)l.push(h[d])}else if(i==="offset"){let h=q.NUMBER32(n);for(let d=0;d<h.length;d++)l.push(h[d])}else if(i==="number"){let h=q.NUMBER(n);for(let d=0;d<h.length;d++)l.push(h[d])}else if(i==="real"){let h=q.REAL(n);for(let d=0;d<h.length;d++)l.push(h[d])}else throw new Error("Unknown operand type "+i);return l},q.OP=q.BYTE,at.OP=at.BYTE;var Fs=typeof WeakMap=="function"&&new WeakMap;q.CHARSTRING=function(n){if(Fs){let h=Fs.get(n);if(h!==void 0)return h}let i=[],l=n.length;for(let h=0;h<l;h+=1){let d=n[h],p=q[d.type](d.value);for(let b=0;b<p.length;b++)i.push(p[b])}return Fs&&Fs.set(n,i),i},at.CHARSTRING=function(n){return q.CHARSTRING(n).length},q.OBJECT=function(n){let i=q[n.type];return H.argument(i!==void 0,"No encoding function for type "+n.type),i(n.value)},at.OBJECT=function(n){let i=at[n.type];return H.argument(i!==void 0,"No sizeOf function for type "+n.type),i(n.value)},q.TABLE=function(n){let i=[],l=(n.fields||[]).length,h=[],d=[];for(let p=0;p<l;p+=1){let b=n.fields[p],x=q[b.type];H.argument(x!==void 0,"No encoding function for field type "+b.type+" ("+b.name+")");let A=n[b.name];A===void 0&&(A=b.value);let E=x(A);if(b.type==="TABLE")A.fields!==null&&(d.push(i.length),h.push(E)),i.push(0,0);else for(let C=0;C<E.length;C++)i.push(E[C])}for(let p=0;p<h.length;p+=1){let b=d[p],x=i.length;H.argument(x<65536,"Table "+n.tableName+" too big."),i[b]=x>>8,i[b+1]=x&255;for(let A=0;A<h[p].length;A++)i.push(h[p][A])}return i},at.TABLE=function(n){let i=0,l=(n.fields||[]).length;for(let h=0;h<l;h+=1){let d=n.fields[h],p=at[d.type];H.argument(p!==void 0,"No sizeOf function for field type "+d.type+" ("+d.name+")");let b=n[d.name];b===void 0&&(b=d.value),i+=p(b),d.type==="TABLE"&&(i+=2)}return i},q.RECORD=q.TABLE,at.RECORD=at.TABLE,q.LITERAL=function(n){return n},at.LITERAL=function(n){return n.length};function Kt(n,i,l){if(i&&i.length)for(let h=0;h<i.length;h+=1){let d=i[h];this[d.name]=d.value}if(this.tableName=n,this.fields=i,l){let h=Object.keys(l);for(let d=0;d<h.length;d+=1){let p=h[d],b=l[p];this[p]!==void 0&&(this[p]=b)}}}Kt.prototype.encode=function(){return q.TABLE(this)},Kt.prototype.sizeOf=function(){return at.TABLE(this)};function Nn(n,i,l){l===void 0&&(l=i.length);let h=new Array(i.length+1);h[0]={name:n+"Count",type:"USHORT",value:l};for(let d=0;d<i.length;d++)h[d+1]={name:n+d,type:"USHORT",value:i[d]};return h}function di(n,i,l){let h=i.length,d=new Array(h+1);d[0]={name:n+"Count",type:"USHORT",value:h};for(let p=0;p<h;p++)d[p+1]={name:n+p,type:"TABLE",value:l(i[p],p)};return d}function Un(n,i,l){let h=i.length,d=[];d[0]={name:n+"Count",type:"USHORT",value:h};for(let p=0;p<h;p++)d=d.concat(l(i[p],p));return d}function _s(n){n.format===1?Kt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Nn("glyph",n.glyphs))):n.format===2?Kt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Un("rangeRecord",n.ranges,function(i,l){return[{name:"startGlyphID"+l,type:"USHORT",value:i.start},{name:"endGlyphID"+l,type:"USHORT",value:i.end},{name:"startCoverageIndex"+l,type:"USHORT",value:i.index}]}))):H.assert(!1,"Coverage format must be 1 or 2.")}_s.prototype=Object.create(Kt.prototype),_s.prototype.constructor=_s;function Ns(n){Kt.call(this,"scriptListTable",Un("scriptRecord",n,function(i,l){let h=i.script,d=h.defaultLangSys;return H.assert(!!d,"Unable to write GSUB: script "+i.tag+" has no default language system."),[{name:"scriptTag"+l,type:"TAG",value:i.tag},{name:"script"+l,type:"TABLE",value:new Kt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Kt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:d.reqFeatureIndex}].concat(Nn("featureIndex",d.featureIndexes)))}].concat(Un("langSys",h.langSysRecords,function(p,b){let x=p.langSys;return[{name:"langSysTag"+b,type:"TAG",value:p.tag},{name:"langSys"+b,type:"TABLE",value:new Kt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:x.reqFeatureIndex}].concat(Nn("featureIndex",x.featureIndexes)))}]})))}]}))}Ns.prototype=Object.create(Kt.prototype),Ns.prototype.constructor=Ns;function Us(n){Kt.call(this,"featureListTable",Un("featureRecord",n,function(i,l){let h=i.feature;return[{name:"featureTag"+l,type:"TAG",value:i.tag},{name:"feature"+l,type:"TABLE",value:new Kt("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(Nn("lookupListIndex",h.lookupListIndexes)))}]}))}Us.prototype=Object.create(Kt.prototype),Us.prototype.constructor=Us;function Bs(n,i){Kt.call(this,"lookupListTable",di("lookup",n,function(l){let h=i[l.lookupType];return H.assert(!!h,"Unable to write GSUB lookup type "+l.lookupType+" tables."),new Kt("lookupTable",[{name:"lookupType",type:"USHORT",value:l.lookupType},{name:"lookupFlag",type:"USHORT",value:l.lookupFlag}].concat(di("subtable",l.subtables,h)))}))}Bs.prototype=Object.create(Kt.prototype),Bs.prototype.constructor=Bs;function Gs(n){n.format===1?Kt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:n.startGlyph}].concat(Nn("glyph",n.classes))):n.format===2?Kt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Un("rangeRecord",n.ranges,function(i,l){return[{name:"startGlyphID"+l,type:"USHORT",value:i.start},{name:"endGlyphID"+l,type:"USHORT",value:i.end},{name:"class"+l,type:"USHORT",value:i.classId}]}))):H.assert(!1,"Class format must be 1 or 2.")}Gs.prototype=Object.create(Kt.prototype),Gs.prototype.constructor=Gs;var Q={Table:Kt,Record:Kt,Coverage:_s,ClassDef:Gs,ScriptList:Ns,FeatureList:Us,LookupList:Bs,ushortList:Nn,tableList:di,recordList:Un};function $a(n,i){return n.getUint8(i)}function Hs(n,i){return n.getUint16(i,!1)}function vh(n,i){return n.getInt16(i,!1)}function za(n,i){return(n.getUint16(i)<<8)+n.getUint8(i+2)}function fi(n,i){return n.getUint32(i,!1)}function xh(n,i){return n.getInt32(i,!1)}function Wa(n,i){let l=n.getInt16(i,!1),h=n.getUint16(i+2,!1);return l+h/65535}function Sh(n,i){let l="";for(let h=i;h<i+4;h+=1)l+=String.fromCharCode(n.getInt8(h));return l}function Ah(n,i,l){let h=0;for(let d=0;d<l;d+=1)h<<=8,h+=n.getUint8(i+d);return h}function Th(n,i,l){let h=[];for(let d=i;d<l;d+=1)h.push(n.getUint8(d));return h}function Ch(n){let i="";for(let l=0;l<n.length;l+=1)i+=String.fromCharCode(n[l]);return i}var Eh={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},se={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function U(n,i){this.data=n,this.offset=i,this.relativeOffset=0}U.prototype.parseByte=function(){let n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},U.prototype.parseChar=function(){let n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},U.prototype.parseCard8=U.prototype.parseByte,U.prototype.parseUShort=function(){let n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},U.prototype.parseCard16=U.prototype.parseUShort,U.prototype.parseSID=U.prototype.parseUShort,U.prototype.parseOffset16=U.prototype.parseUShort,U.prototype.parseShort=function(){let n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},U.prototype.parseF2Dot14=function(){let n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n},U.prototype.parseUInt24=function(){let n=za(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,n},U.prototype.parseULong=function(){let n=fi(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},U.prototype.parseLong=function(){let n=xh(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},U.prototype.parseOffset32=U.prototype.parseULong,U.prototype.parseFixed=function(){let n=Wa(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},U.prototype.parseString=function(n){let i=this.data,l=this.offset+this.relativeOffset,h="";this.relativeOffset+=n;for(let d=0;d<n;d++)h+=String.fromCharCode(i.getUint8(l+d));return h},U.prototype.parseTag=function(){return this.parseString(4)},U.prototype.parseLongDateTime=function(){let n=fi(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n},U.prototype.parseVersion=function(n){let i=Hs(this.data,this.offset+this.relativeOffset),l=Hs(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),i+l/n/10},U.prototype.skip=function(n,i){i===void 0&&(i=1),this.relativeOffset+=Eh[n]*i},U.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());let i=new Array(n),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<n;d++)i[d]=l.getUint32(h),h+=4;return this.relativeOffset+=n*4,i},U.prototype.parseOffset16List=U.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());let i=new Array(n),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<n;d++)i[d]=l.getUint16(h),h+=2;return this.relativeOffset+=n*2,i},U.prototype.parseShortList=function(n){let i=new Array(n),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<n;d++)i[d]=l.getInt16(h),h+=2;return this.relativeOffset+=n*2,i},U.prototype.parseByteList=function(n){let i=new Array(n),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<n;d++)i[d]=l.getUint8(h++);return this.relativeOffset+=n,i},U.prototype.parseList=function(n,i){i||(i=n,n=this.parseUShort());let l=new Array(n);for(let h=0;h<n;h++)l[h]=i.call(this);return l},U.prototype.parseList32=function(n,i){i||(i=n,n=this.parseULong());let l=new Array(n);for(let h=0;h<n;h++)l[h]=i.call(this);return l},U.prototype.parseRecordList=function(n,i){i||(i=n,n=this.parseUShort());let l=new Array(n),h=Object.keys(i);for(let d=0;d<n;d++){let p={};for(let b=0;b<h.length;b++){let x=h[b],A=i[x];p[x]=A.call(this)}l[d]=p}return l},U.prototype.parseRecordList32=function(n,i){i||(i=n,n=this.parseULong());let l=new Array(n),h=Object.keys(i);for(let d=0;d<n;d++){let p={};for(let b=0;b<h.length;b++){let x=h[b],A=i[x];p[x]=A.call(this)}l[d]=p}return l},U.prototype.parseTupleRecords=function(n,i){let l=[];for(let h=0;h<n;h++){let d=[];for(let p=0;p<i;p++)d.push(this.parseF2Dot14());l.push(d)}return l},U.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);{let i=Object.keys(n),l={};for(let h=0;h<i.length;h++){let d=i[h],p=n[d];l[d]=p.call(this)}return l}},U.prototype.parseValueRecord=function(n){if(n===void 0&&(n=this.parseUShort()),n===0)return;let i={};return n&1&&(i.xPlacement=this.parseShort()),n&2&&(i.yPlacement=this.parseShort()),n&4&&(i.xAdvance=this.parseShort()),n&8&&(i.yAdvance=this.parseShort()),n&16&&(i.xPlaDevice=void 0,this.parseShort()),n&32&&(i.yPlaDevice=void 0,this.parseShort()),n&64&&(i.xAdvDevice=void 0,this.parseShort()),n&128&&(i.yAdvDevice=void 0,this.parseShort()),i},U.prototype.parseValueRecordList=function(){let n=this.parseUShort(),i=this.parseUShort(),l=new Array(i);for(let h=0;h<i;h++)l[h]=this.parseValueRecord(n);return l},U.prototype.parsePointer=function(n){let i=this.parseOffset16();if(i>0)return new U(this.data,this.offset+i).parseStruct(n)},U.prototype.parsePointer32=function(n){let i=this.parseOffset32();if(i>0)return new U(this.data,this.offset+i).parseStruct(n)},U.prototype.parseListOfLists=function(n){let i=this.parseOffset16List(),l=i.length,h=this.relativeOffset,d=new Array(l);for(let p=0;p<l;p++){let b=i[p];if(b===0){d[p]=void 0;continue}if(this.relativeOffset=b,n){let x=this.parseOffset16List(),A=new Array(x.length);for(let E=0;E<x.length;E++)this.relativeOffset=b+x[E],A[E]=n.call(this);d[p]=A}else d[p]=this.parseUShortList()}return this.relativeOffset=h,d},U.prototype.parseCoverage=function(){let n=this.offset+this.relativeOffset,i=this.parseUShort(),l=this.parseUShort();if(i===1)return{format:1,glyphs:this.parseUShortList(l)};if(i===2){let h=new Array(l);for(let d=0;d<l;d++)h[d]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:h}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")},U.prototype.parseClassDef=function(){let n=this.offset+this.relativeOffset,i=this.parseUShort();return i===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:i===2?{format:2,ranges:this.parseRecordList({start:U.uShort,end:U.uShort,classId:U.uShort})}:(console.warn(`0x${n.toString(16)}: This font file uses an invalid ClassDef format of ${i}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:i})},U.list=function(n,i){return function(){return this.parseList(n,i)}},U.list32=function(n,i){return function(){return this.parseList32(n,i)}},U.recordList=function(n,i){return function(){return this.parseRecordList(n,i)}},U.recordList32=function(n,i){return function(){return this.parseRecordList32(n,i)}},U.pointer=function(n){return function(){return this.parsePointer(n)}},U.pointer32=function(n){return function(){return this.parsePointer32(n)}},U.tag=U.prototype.parseTag,U.byte=U.prototype.parseByte,U.uShort=U.offset16=U.prototype.parseUShort,U.uShortList=U.prototype.parseUShortList,U.uInt24=U.prototype.parseUInt24,U.uLong=U.offset32=U.prototype.parseULong,U.uLongList=U.prototype.parseULongList,U.fixed=U.prototype.parseFixed,U.f2Dot14=U.prototype.parseF2Dot14,U.struct=U.prototype.parseStruct,U.coverage=U.prototype.parseCoverage,U.classDef=U.prototype.parseClassDef;var Xa={reserved:U.uShort,reqFeatureIndex:U.uShort,featureIndexes:U.uShortList};U.prototype.parseScriptList=function(){return this.parsePointer(U.recordList({tag:U.tag,script:U.pointer({defaultLangSys:U.pointer(Xa),langSysRecords:U.recordList({tag:U.tag,langSys:U.pointer(Xa)})})}))||[]},U.prototype.parseFeatureList=function(){return this.parsePointer(U.recordList({tag:U.tag,feature:U.pointer({featureParams:U.offset16,lookupListIndexes:U.uShortList})}))||[]},U.prototype.parseLookupList=function(n){return this.parsePointer(U.list(U.pointer(function(){let i=this.parseUShort();H.argument(1<=i&&i<=9,"GPOS/GSUB lookup type "+i+" unknown.");let l=this.parseUShort(),h=l&16;return{lookupType:i,lookupFlag:l,subtables:this.parseList(U.pointer(n[i])),markFilteringSet:h?this.parseUShort():void 0}})))||[]},U.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let n=this.parseUShort(),i=this.parseUShort();return H.argument(n===1&&i<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:U.offset32,featureTableSubstitutionOffset:U.offset32})})||[]},U.prototype.parseVariationStore=function(){let n=this.relativeOffset,i=this.parseUShort(),l={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=n+i+2,l},U.prototype.parseItemVariationStore=function(){let n=this.relativeOffset,i={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},l=this.parseOffset32(),h=this.parseUShort(),d=this.parseULongList(h);this.relativeOffset=n+l,i.variationRegions=this.parseVariationRegionList();for(let p=0;p<h;p++){let b=d[p];this.relativeOffset=n+b,i.itemVariationSubtables.push(this.parseItemVariationSubtable())}return i},U.prototype.parseVariationRegionList=function(){let n=this.parseUShort(),i=this.parseUShort();return this.parseRecordList(i,{regionAxes:U.recordList(n,{startCoord:U.f2Dot14,peakCoord:U.f2Dot14,endCoord:U.f2Dot14})})},U.prototype.parseItemVariationSubtable=function(){let n=this.parseUShort(),i=this.parseUShort(),l=this.parseUShortList(),h=l.length;return{regionIndexes:l,deltaSets:n&&h?this.parseDeltaSets(n,i,h):[]}},U.prototype.parseDeltaSetIndexMap=function(){let n=this.parseByte(),i=this.parseByte(),l=[],h=0;switch(n){case 0:h=this.parseUShort();break;case 1:h=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${n}`)}if(!h)return{format:n,entryFormat:i};let d=(i&se.INNER_INDEX_BIT_COUNT_MASK)+1,p=((i&se.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let b=0;b<h;b++){let x;if(p===1)x=this.parseByte();else if(p===2)x=this.parseUShort();else if(p===3)x=this.parseUInt24();else if(p===4)x=this.parseULong();else throw new Error(`Invalid entry size of ${p}`);let A=x>>d,E=x&(1<<d)-1;l.push({outerIndex:A,innerIndex:E})}return{format:n,entryFormat:i,map:l}},U.prototype.parseDeltaSets=function(n,i,l){let h=Array.from({length:n},()=>[]),d=i&se.LONG_WORDS,p=i&se.WORD_DELTA_COUNT_MASK;if(p>l)throw Error("wordCount must be less than or equal to regionIndexCount");let b=(d?this.parseLong:this.parseShort).bind(this),x=(d?this.parseShort:this.parseChar).bind(this);for(let A=0;A<n;A++)for(let E=0;E<l;E++)E<p?h[A].push(b()):h[A].push(x());return h},U.prototype.parseTupleVariationStoreList=function(n,i,l){let h=this.parseUShort(),p=this.parseUShort()&1,b=this.parseOffset32(),x=(p?this.parseULong:this.parseUShort).bind(this),A={},E=x();p||(E*=2);let C;for(let P=0;P<h;P++){C=x(),p||(C*=2);let R=C-E;A[P]=R?this.parseTupleVariationStore(b+E,n,i,l,P):void 0,E=C}return A},U.prototype.parseTupleVariationStore=function(n,i,l,h,d){let p=this.relativeOffset;this.relativeOffset=n,l==="cvar"&&(this.relativeOffset+=4);let b=this.parseUShort(),x=!!(b&se.SHARED_POINT_NUMBERS),A=b&se.COUNT_MASK,E=this.parseOffset16(),C=[],P=[];for(let O=0;O<A;O++){let _=this.parseTupleVariationHeader(i,l);C.push(_)}this.relativeOffset!==n+E&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${n+E}, actually ${this.relativeOffset}`),this.relativeOffset=n+E),x&&(P=this.parsePackedPointNumbers());let R=this.relativeOffset;for(let O=0;O<A;O++){let _=C[O];_.privatePoints=[],this.relativeOffset=R,l==="cvar"&&!_.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),_.flags.privatePointNumbers&&(_.privatePoints=this.parsePackedPointNumbers()),delete _.flags;let V=this.offset,mt=this.relativeOffset,ht=At=>{let kt,_t,Bt=()=>{let Gt=0;if(l==="gvar"){if(Gt=_.privatePoints.length||P.length,!Gt){let Jt=h.get(d);Jt.path,Gt=Jt.points.length,Gt+=4}}else l==="cvar"&&(Gt=h.length);this.offset=V,this.relativeOffset=mt,kt=this.parsePackedDeltas(Gt),l==="gvar"&&(_t=this.parsePackedDeltas(Gt))};return{configurable:!0,get:function(){return kt===void 0&&Bt(),At==="deltasY"?_t:kt},set:function(Gt){kt===void 0&&Bt(),At==="deltasY"?_t=Gt:kt=Gt}}};Object.defineProperty(_,"deltas",ht.call(this,"deltas")),l==="gvar"&&Object.defineProperty(_,"deltasY",ht.call(this,"deltasY")),R+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=p;let D={headers:C};return D.sharedPoints=P,D},U.prototype.parseTupleVariationHeader=function(n,i){let l=this.parseUShort(),h=this.parseUShort(),d=!!(h&se.EMBEDDED_PEAK_TUPLE),p=!!(h&se.INTERMEDIATE_REGION),b=!!(h&se.PRIVATE_POINT_NUMBERS),x=d?void 0:h&se.TUPLE_INDEX_MASK,A=d?this.parseTupleRecords(1,n)[0]:void 0,E=p?this.parseTupleRecords(1,n)[0]:void 0,C=p?this.parseTupleRecords(1,n)[0]:void 0,P={variationDataSize:l,peakTuple:A,intermediateStartTuple:E,intermediateEndTuple:C,flags:{embeddedPeakTuple:d,intermediateRegion:p,privatePointNumbers:b}};return i==="gvar"&&(P.sharedTupleRecordsIndex=x),P},U.prototype.parsePackedPointNumbers=function(){let n=this.parseByte(),i=[],l=n;if(n>=128){let d=this.parseByte();l=(n&se.POINT_RUN_COUNT_MASK)<<8|d}let h=0;for(;i.length<l;){let d=this.parseByte(),p=!!(d&se.POINTS_ARE_WORDS),b=(d&se.POINT_RUN_COUNT_MASK)+1;for(let x=0;x<b&&i.length<l;x++){let A;p?A=this.parseUShort():A=this.parseByte(),h=h+A,i.push(h)}}return i},U.prototype.parsePackedDeltas=function(n){let i=[];for(;i.length<n;){let l=this.parseByte(),h=!!(l&se.DELTAS_ARE_ZERO),d=!!(l&se.DELTAS_ARE_WORDS),p=(l&se.DELTA_RUN_COUNT_MASK)+1;for(let b=0;b<p&&i.length<n;b++)h?i.push(0):d?i.push(this.parseShort()):i.push(this.parseChar())}return i};var it={getByte:$a,getCard8:$a,getUShort:Hs,getCard16:Hs,getShort:vh,getUInt24:za,getULong:fi,getFixed:Wa,getTag:Sh,getOffset:Ah,getBytes:Th,bytesToString:Ch,Parser:U},js=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Ya={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},wh={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Ka={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function kh(n,i,l){switch(n){case 0:if(i===65535)return"und";if(l)return l[i];break;case 1:return Ya[i];case 3:return Ka[i]}}var pi="utf-16",Ih={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Rh={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function gi(n,i,l){switch(n){case 0:return pi;case 1:return Rh[l]||Ih[i];case 3:if(i===1||i===10)return pi;break}}var Za={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function Ph(n){return Za[n]}function Oh(n,i,l){let h={},d=new it.Parser(n,i),p=d.parseUShort(),b=d.parseUShort(),x=d.offset+d.parseUShort();for(let A=0;A<b;A++){let E=d.parseUShort(),C=d.parseUShort(),P=d.parseUShort(),R=d.parseUShort(),D=js[R]||R,O=d.parseUShort(),_=d.parseUShort(),V=kh(E,P,l),mt=gi(E,C,P),ht=Ph(E);if(mt!==void 0&&V!==void 0&&ht!==void 0){let At;if(mt===pi?At=Nt.UTF16(n,x+_,O):At=Nt.MACSTRING(n,x+_,O,mt),At){let kt=h[ht];kt===void 0&&(kt=h[ht]={});let _t=kt[D];_t===void 0&&(_t=kt[D]={}),_t[V]=At}}}return p===1&&d.parseUShort(),h}function Vs(n){let i={};for(let l in n)i[n[l]]=parseInt(l);return i}function Qa(n,i,l,h,d,p){return new Q.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:i},{name:"languageID",type:"USHORT",value:l},{name:"nameID",type:"USHORT",value:h},{name:"length",type:"USHORT",value:d},{name:"offset",type:"USHORT",value:p}])}function Lh(n,i){let l=n.length,h=i.length-l+1;t:for(let d=0;d<h;d++)for(;d<h;d++){for(let p=0;p<l;p++)if(i[d+p]!==n[p])continue t;return d}return-1}function Ja(n,i){let l=Lh(n,i);if(l<0){l=i.length;let h=0,d=n.length;for(;h<d;++h)i.push(n[h])}return l}function Mh(n,i){let l=Vs(Za),h=Vs(Ya),d=Vs(Ka),p=[],b=[];for(let A in n){let E,C=[],P={},R=Vs(js),D=l[A];for(let O in n[A]){let _=R[O];if(_===void 0&&(_=O),E=parseInt(_),isNaN(E))throw new Error('Name table entry "'+O+'" does not exist, see nameTableNames for complete list.');P[E]=n[A][O],C.push(E)}for(let O=0;O<C.length;O++){E=C[O];let _=P[E];for(let V in _){let mt=_[V];if(D===1||D===0){let ht=h[V],At=wh[ht],kt=gi(D,At,ht),_t=q.MACSTRING(mt,kt);if(D===0&&(ht=i.indexOf(V),ht<0&&(ht=i.length,i.push(V)),At=4,_t=q.UTF16(mt)),_t!==void 0){let Bt=Ja(_t,b);p.push(Qa(D,At,ht,E,_t.length,Bt))}}if(D===3){let ht=d[V];if(ht!==void 0){let At=q.UTF16(mt),kt=Ja(At,b);p.push(Qa(3,1,ht,E,At.length,kt))}}}}}p.sort(function(A,E){return A.platformID-E.platformID||A.encodingID-E.encodingID||A.languageID-E.languageID||A.nameID-E.nameID});let x=new Q.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:p.length},{name:"stringOffset",type:"USHORT",value:6+p.length*12}]);for(let A=0;A<p.length;A++)x.fields.push({name:"record_"+A,type:"RECORD",value:p[A]});return x.fields.push({name:"strings",type:"LITERAL",value:b}),x}function $s(n,i,l=[]){if(i<256&&i in js){if(l.length&&!l.includes(parseInt(i)))return;i=js[i]}for(let h in n)for(let d in n[h])if(d===i||parseInt(d)===i)return n[h][d]}var qa={parse:Oh,make:Mh,getNameByID:$s};function Dh(n,i,l,h){n.length=i.parseUShort(),n.language=i.parseUShort()-1;let d=i.parseByteList(n.length),p=Object.assign({},d),b=gi(l,h,n.language),x=Me[b];for(let A=0;A<x.length;A++)p[x.charCodeAt(A)]=d[128+A];n.glyphIndexMap=p}function Fh(n,i,l){i.parseUShort(),n.length=i.parseULong(),n.language=i.parseULong();let h;n.groupCount=h=i.parseULong(),n.glyphIndexMap={};for(let d=0;d<h;d+=1){let p=i.parseULong(),b=i.parseULong(),x=i.parseULong();for(let A=p;A<=b;A+=1)n.glyphIndexMap[A]=x,l===12&&x++}}function _h(n,i,l,h,d){n.length=i.parseUShort(),n.language=i.parseUShort();let p;n.segCount=p=i.parseUShort()>>1,i.skip("uShort",3),n.glyphIndexMap={};let b=new it.Parser(l,h+d+14),x=new it.Parser(l,h+d+16+p*2),A=new it.Parser(l,h+d+16+p*4),E=new it.Parser(l,h+d+16+p*6),C=h+d+16+p*8;for(let P=0;P<p-1;P+=1){let R,D=b.parseUShort(),O=x.parseUShort(),_=A.parseShort(),V=E.parseUShort();for(let mt=O;mt<=D;mt+=1)V!==0?(C=E.offset+E.relativeOffset-2,C+=V,C+=(mt-O)*2,R=it.getUShort(l,C),R!==0&&(R=R+_&65535)):R=mt+_&65535,n.glyphIndexMap[mt]=R}}function Nh(n,i){let l={};i.skip("uLong");let h=i.parseULong();for(let d=0;d<h;d+=1){let p=i.parseUInt24(),b={varSelector:p},x=i.parseOffset32(),A=i.parseOffset32(),E=i.relativeOffset;x&&(i.relativeOffset=x,b.defaultUVS=i.parseStruct({ranges:function(){return i.parseRecordList32({startUnicodeValue:i.parseUInt24,additionalCount:i.parseByte})}})),A&&(i.relativeOffset=A,b.nonDefaultUVS=i.parseStruct({uvsMappings:function(){let C={},P=i.parseRecordList32({unicodeValue:i.parseUInt24,glyphID:i.parseUShort});for(let R=0;R<P.length;R+=1)C[P[R].unicodeValue]=P[R];return C}})),l[p]=b,i.relativeOffset=E}n.varSelectorList=l}function Uh(n,i){let l={};l.version=it.getUShort(n,i),H.argument(l.version===0,"cmap table version should be 0."),l.numTables=it.getUShort(n,i+2);let h=null,d=-1,p=-1,b=null,x=null,A=[0,1,2,3,4,6],E=[0,1,10];for(let P=l.numTables-1;P>=0;P-=1)if(b=it.getUShort(n,i+4+P*8),x=it.getUShort(n,i+4+P*8+2),b===3&&E.includes(x)||b===0&&A.includes(x)||b===1&&x===0){if(p>0)continue;if(p=it.getULong(n,i+4+P*8+4),h)break}else if(b===0&&x===5){if(d=it.getULong(n,i+4+P*8+4),h=new it.Parser(n,i+d),h.parseUShort()!==14)d=-1,h=null;else if(p>0)break}if(p===-1)throw new Error("No valid cmap sub-tables found.");let C=new it.Parser(n,i+p);if(l.format=C.parseUShort(),l.format===0)Dh(l,C,b,x);else if(l.format===12||l.format===13)Fh(l,C,l.format);else if(l.format===4)_h(l,C,n,i,p);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+l.format+", platformId "+b+", encodingId "+x+").");return h&&Nh(l,h),l}function Bh(n,i,l){n.segments.push({end:i,start:i,delta:-(i-l),offset:0,glyphIndex:l})}function Gh(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Hh(n){if(n.length===0)return n;let i=[n[0]];for(let l=1;l<n.length;l++){let h=i[i.length-1],d=n[l];h.end+1===d.start&&h.delta===d.delta&&d.end!==65535?h.end=d.end:i.push(d)}return i}function jh(n){let i=!0,l;for(l=n.length-1;l>0;l-=1)if(n.get(l).unicode>65535){i=!1;break}let h=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:i?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:i?12:20}];i||h.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),h.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let d=new Q.Table("cmap",h);for(d.segments=[],l=0;l<n.length;l+=1){let D=n.get(l);for(let O=0;O<D.unicodes.length;O+=1)Bh(d,D.unicodes[O],l)}d.segments.sort(function(D,O){return D.start-O.start}),d.segments=Hh(d.segments),Gh(d);let p=d.segments.length,b=0,x=[],A=[],E=[],C=[],P=[],R=[];for(l=0;l<p;l+=1){let D=d.segments[l];D.end<=65535&&D.start<=65535?(x.push({name:"end_"+l,type:"USHORT",value:D.end}),A.push({name:"start_"+l,type:"USHORT",value:D.start}),E.push({name:"idDelta_"+l,type:"SHORT",value:D.delta}),C.push({name:"idRangeOffset_"+l,type:"USHORT",value:D.offset}),D.glyphId!==void 0&&P.push({name:"glyph_"+l,type:"USHORT",value:D.glyphId})):b+=1,!i&&D.glyphIndex!==void 0&&(R.push({name:"cmap12Start_"+l,type:"ULONG",value:D.start}),R.push({name:"cmap12End_"+l,type:"ULONG",value:D.end}),R.push({name:"cmap12Glyph_"+l,type:"ULONG",value:D.glyphIndex}))}d.segCountX2=(p-b)*2,d.searchRange=Math.pow(2,Math.floor(Math.log(p-b)/Math.log(2)))*2,d.entrySelector=Math.log(d.searchRange/2)/Math.log(2),d.rangeShift=d.segCountX2-d.searchRange;for(let D=0;D<x.length;D++)d.fields.push(x[D]);d.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let D=0;D<A.length;D++)d.fields.push(A[D]);for(let D=0;D<E.length;D++)d.fields.push(E[D]);for(let D=0;D<C.length;D++)d.fields.push(C[D]);for(let D=0;D<P.length;D++)d.fields.push(P[D]);if(d.cmap4Length=14+x.length*2+2+A.length*2+E.length*2+C.length*2+P.length*2,!i){let D=16+R.length*4;d.cmap12Offset=20+d.cmap4Length,d.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:D},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:R.length/3});for(let O=0;O<R.length;O++)d.fields.push(R[O])}return d}var tl={parse:Uh,make:jh},zs=[".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","266 ff","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"],Vh=[".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"],$h=[".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"],zh=[".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"],mi=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Wh=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],yn=[".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 el(n){this.font=n}el.prototype.charToGlyphIndex=function(n){let i=n.codePointAt(0),l=this.font.glyphs;if(l)for(let h=0;h<l.length;h+=1){let d=l.get(h);for(let p=0;p<d.unicodes.length;p+=1)if(d.unicodes[p]===i)return h}return null};function nl(n){this.cmap=n}nl.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function sl(n,i){this.encoding=n,this.charset=i}sl.prototype.charToGlyphIndex=function(n){let i=n.codePointAt(0),l=this.encoding[i];return this.charset.indexOf(l)};function yi(n){switch(n.version){case 1:this.names=yn.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(let i=0;i<n.numberOfGlyphs;i++)n.glyphNameIndex[i]<yn.length?this.names[i]=yn[n.glyphNameIndex[i]]:this.names[i]=n.names[n.glyphNameIndex[i]-yn.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(let i=0;i<n.numberOfGlyphs;i++)this.names[i]=yn[i+n.glyphNameIndex[i]];break;case 3:this.names=[];break;default:this.names=[];break}}yi.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)},yi.prototype.glyphIndexToName=function(n){return this.names[n]};function Xh(n){let i,l=n.tables.cmap.glyphIndexMap,h=Object.keys(l);for(let d=0;d<h.length;d+=1){let p=h[d],b=l[p];i=n.glyphs.get(b),i.addUnicode(parseInt(p))}for(let d=0;d<n.glyphs.length;d+=1)i=n.glyphs.get(d),n.cffEncoding?i.name=n.cffEncoding.charset[d]:n.glyphNames.names&&(i.name=n.glyphNames.glyphIndexToName(d))}function Yh(n){n._IndexToUnicodeMap={};let i=n.tables.cmap.glyphIndexMap,l=Object.keys(i);for(let h=0;h<l.length;h+=1){let d=l[h],p=i[d];n._IndexToUnicodeMap[p]===void 0?n._IndexToUnicodeMap[p]={unicodes:[parseInt(d)]}:n._IndexToUnicodeMap[p].unicodes.push(parseInt(d))}}function Kh(n,i){i.lowMemory?Yh(n):Xh(n)}function Zh(n,i,l,h,d){n.beginPath(),n.moveTo(i,l),n.lineTo(h,d),n.stroke()}var bn={line:Zh};function Qh(n,i){let l=new U(n,i),h=l.parseShort();h!==0&&console.warn("Only CPALv0 is currently fully supported.");let d=l.parseShort(),p=l.parseShort(),b=l.parseShort(),x=l.parseOffset32(),A=l.parseUShortList(p);l.relativeOffset=x;let E=l.parseULongList(b);return l.relativeOffset=x,{version:h,numPaletteEntries:d,colorRecords:E,colorRecordIndices:A}}function Jh({version:n=0,numPaletteEntries:i=0,colorRecords:l=[],colorRecordIndices:h=[0]}){return H.argument(n===0,"Only CPALv0 are supported."),H.argument(l.length,"No colorRecords given."),H.argument(h.length,"No colorRecordIndices given."),h.length>1&&H.argument(i,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new Q.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:i||l.length},{name:"numPalettes",type:"USHORT",value:h.length},{name:"numColorRecords",type:"USHORT",value:l.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*h.length},...h.map((d,p)=>({name:"colorRecordIndices_"+p,type:"USHORT",value:d})),...l.map((d,p)=>({name:"colorRecords_"+p,type:"ULONG",value:d}))])}function rl(n){var i=(n&4278190080)>>24,l=(n&16711680)>>16,h=(n&65280)>>8,d=n&255;return i=i+256&255,l=l+256&255,h=h+256&255,d=(d+256&255)/255,{b:i,g:l,r:h,a:d}}function bi(n,i,l=0,h="hexa"){if(i==65535)return"currentColor";let d=n&&n.tables&&n.tables.cpal;if(!d)return"currentColor";if(l>d.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${d.colorRecordIndices.length}, index: ${i})`);if(i>d.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${d.numPaletteEntries}, index: ${i})`);let p=d.colorRecordIndices[l]+i;if(p>d.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${d.colorRecords.length}, lookupIndex: ${p})`);let b=rl(d.colorRecords[p]);return h==="bgra"?b:Bn(b,h)}function De(n){return("0"+parseInt(n).toString(16)).slice(-2)}function qh(n){let i=n.r/255,l=n.g/255,h=n.b/255,d=Math.max(i,l,h),p=Math.min(i,l,h),b,x,A=(d+p)/2;if(d===p)b=x=0;else{let E=d-p;switch(x=A>.5?E/(2-d-p):E/(d+p),d){case i:b=(l-h)/E+(l<h?6:0);break;case l:b=(h-i)/E+2;break;case h:b=(i-l)/E+4;break}b/=6}return{h:b*360,s:x*100,l:A*100}}function td(n){let{h:i,s:l,l:h,a:d}=n;i=i%360,l/=100,h/=100;let p=(1-Math.abs(2*h-1))*l,b=p*(1-Math.abs(i/60%2-1)),x=h-p/2,A=0,E=0,C=0;return 0<=i&&i<60?(A=p,E=b,C=0):60<=i&&i<120?(A=b,E=p,C=0):120<=i&&i<180?(A=0,E=p,C=b):180<=i&&i<240?(A=0,E=b,C=p):240<=i&&i<300?(A=b,E=0,C=p):300<=i&&i<=360&&(A=p,E=0,C=b),{r:Math.round((A+x)*255),g:Math.round((E+x)*255),b:Math.round((C+x)*255),a:d}}function il(n){return parseInt(`0x${De(n.b)}${De(n.g)}${De(n.r)}${De(n.a*255)}`,16)}function Ws(n,i="hexa"){let l=i=="raw"||i=="cpal",h=Number.isInteger(n),d=!0;if(h&&l||n==="currentColor")return n;if(typeof n=="object"){if(i=="bgra")return n;if(l)return il(n)}else if(!h&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(n.trim())){switch(n=n.trim().substring(1),n.length){case 3:n={r:parseInt(n[0].repeat(2),16),g:parseInt(n[1].repeat(2),16),b:parseInt(n[2].repeat(2),16),a:1};break;case 4:n={r:parseInt(n[0].repeat(2),16),g:parseInt(n[1].repeat(2),16),b:parseInt(n[2].repeat(2),16),a:parseInt(n[3].repeat(2),16)/255};break;case 6:n={r:parseInt(n[0]+n[1],16),g:parseInt(n[2]+n[3],16),b:parseInt(n[4]+n[5],16),a:1};break;case 8:n={r:parseInt(n[0]+n[1],16),g:parseInt(n[2]+n[3],16),b:parseInt(n[4]+n[5],16),a:parseInt(n[6]+n[7],16)/255};break}if(i=="bgra")return n}else if(typeof document<"u"&&/^[a-z]+$/i.test(n)){let p=document.createElement("canvas").getContext("2d");p.fillStyle=n;let b=Bn(p.fillStyle,"hexa");b==="#000000ff"&&n.toLowerCase()!=="black"?d=!1:n=b}else{n=n.trim();let p=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(p.test(n)){let b=n.match(p).filter(x=>typeof x<"u");n={r:Math.round(parseFloat(b[1])/(b[2]?.39215686274509803:1)),g:Math.round(parseFloat(b[3])/(b[4]?.39215686274509803:1)),b:Math.round(parseFloat(b[5])/(b[6]?.39215686274509803:1)),a:b[7]?parseFloat(b[7])/(b[8]?100:1):1}}else{let b=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(b.test(n)){let x=n.match(b).filter(A=>typeof A<"u");n=td({h:parseFloat(x[1])*(x[2]==="turn"?360:1),s:parseFloat(x[3]),l:parseFloat(x[4]),a:x[5]?parseFloat(x[5])/(x[6]?100:1):1})}else d=!1}}if(!d)throw new Error(`Invalid color format: ${n}`);return Bn(n,i)}function Bn(n,i="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(i=="raw"||i=="cpal")return n;n=rl(n)}else typeof n!="object"&&(n=Ws(n,"bgra"));let l=["hsl","hsla"].includes(i)?qh(n):null;switch(i){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${De(n.r)}${De(n.g)}${De(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${De(n.r)}${De(n.g)}${De(n.b)}${De(n.a*255)}`;case"hsl":return`hsl(${l.h.toFixed(2)}, ${l.s.toFixed(2)}%, ${l.l.toFixed(2)}%)`;case"hsla":return`hsla(${l.h.toFixed(2)}, ${l.s.toFixed(2)}%, ${l.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return il(n);default:throw new Error("Unknown color format: "+i)}}var ol={parse:Qh,make:Jh,getPaletteColor:bi,parseColor:Ws,formatColor:Bn};function ed(n,i){let l=i||new st;return{configurable:!0,get:function(){return typeof l=="function"&&(l=l()),l},set:function(h){l=h}}}function re(n){this.bindConstructorValues(n)}re.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",ed(this,n.path))},re.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)},re.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},re.prototype.getPath=function(n,i,l,h,d){n=n!==void 0?n:0,i=i!==void 0?i:0,l=l!==void 0?l:72,h=Object.assign({},d&&d.defaultRenderOptions,h);let p,b,x=h.xScale,A=h.yScale,E=1/(this.path.unitsPerEm||1e3)*l,C=this;d&&d.variation&&(C=d.variation.getTransform(this,h.variation),p=C.path.commands),h.hinting&&d&&d.hinting&&(b=C.path&&d.hinting.exec(C,l,h)),b?(p=d.hinting.getCommands(b),n=Math.round(n),i=Math.round(i),x=A=1):(p=C.path.commands,x===void 0&&(x=E),A===void 0&&(A=E));let P=new st;if(h.drawSVG){let R=this.getSvgImage(d);if(R){let D=new st;return D._image={image:R.image,x:n+R.leftSideBearing*E,y:i-R.baseline*E,width:R.image.width*E,height:R.image.height*E},P._layers=[D],P}}if(h.drawLayers){let R=this.getLayers(d);if(R&&R.length){P._layers=[];for(let D=0;D<R.length;D+=1){let O=R[D],_=bi(d,O.paletteIndex,h.usePalette);_==="currentColor"?_=h.fill||"black":_=Bn(_,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:_}),P._layers.push(this.getPath.call(O.glyph,n,i,l,h,d))}return P}}P.fill=h.fill||this.path.fill,P.stroke=this.path.stroke,P.strokeWidth=this.path.strokeWidth*E;for(let R=0;R<p.length;R+=1){let D=p[R];D.type==="M"?P.moveTo(n+D.x*x,i+-D.y*A):D.type==="L"?P.lineTo(n+D.x*x,i+-D.y*A):D.type==="Q"?P.quadraticCurveTo(n+D.x1*x,i+-D.y1*A,n+D.x*x,i+-D.y*A):D.type==="C"?P.curveTo(n+D.x1*x,i+-D.y1*A,n+D.x2*x,i+-D.y2*A,n+D.x*x,i+-D.y*A):D.type==="Z"&&P.stroke&&P.strokeWidth&&P.closePath()}return P},re.prototype.getLayers=function(n){if(!n)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return n.layers.get(this.index)},re.prototype.getSvgImage=function(n){if(!n)throw new Error("The font object is required to read the svg table in order to get the image.");return n.svgImages.get(this.index)},re.prototype.getContours=function(n=null){if(this.points===void 0&&!n)return[];let i=[],l=[],h=n||this.points;for(let d=0;d<h.length;d+=1){let p=h[d];l.push(p),p.lastPointOfContour&&(i.push(l),l=[])}return H.argument(l.length===0,"There are still points left in the current contour."),i},re.prototype.getMetrics=function(){let n=this.path.commands,i=[],l=[];for(let d=0;d<n.length;d+=1){let p=n[d];p.type!=="Z"&&(i.push(p.x),l.push(p.y)),(p.type==="Q"||p.type==="C")&&(i.push(p.x1),l.push(p.y1)),p.type==="C"&&(i.push(p.x2),l.push(p.y2))}let h={xMin:Math.min.apply(null,i),yMin:Math.min.apply(null,l),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,l),leftSideBearing:this.leftSideBearing};return isFinite(h.xMin)||(h.xMin=0),isFinite(h.xMax)||(h.xMax=this.advanceWidth),isFinite(h.yMin)||(h.yMin=0),isFinite(h.yMax)||(h.yMax=0),h.rightSideBearing=this.advanceWidth-h.leftSideBearing-(h.xMax-h.xMin),h},re.prototype.draw=function(n,i,l,h,d,p){d=Object.assign({},p&&p.defaultRenderOptions,d),this.getPath(i,l,h,d,p).draw(n)},re.prototype.drawPoints=function(n,i,l,h,d,p){if(d=Object.assign({},p&&p.defaultRenderOptions,d),d.drawLayers){let R=this.getLayers(p);if(R&&R.length){for(let D=0;D<R.length;D+=1)R[D].glyph.index!==this.index&&this.drawPoints.call(R[D].glyph,n,i,l,h);return}}function b(R,D,O,_){n.beginPath();for(let V=0;V<R.length;V+=1)n.moveTo(D+R[V].x*_,O+R[V].y*_),n.arc(D+R[V].x*_,O+R[V].y*_,2,0,Math.PI*2,!1);n.fill()}i=i!==void 0?i:0,l=l!==void 0?l:0,h=h!==void 0?h:24;let x=1/this.path.unitsPerEm*h,A=[],E=[],P=this.path.commands;p&&p.variation&&(P=p.variation.getTransform(this,d.variation).path.commands);for(let R=0;R<P.length;R+=1){let D=P[R];D.x!==void 0&&A.push({x:D.x,y:-D.y}),D.x1!==void 0&&E.push({x:D.x1,y:-D.y1}),D.x2!==void 0&&E.push({x:D.x2,y:-D.y2})}n.fillStyle="blue",b(A,i,l,x),n.fillStyle="red",b(E,i,l,x)},re.prototype.drawMetrics=function(n,i,l,h){let d;i=i!==void 0?i:0,l=l!==void 0?l:0,h=h!==void 0?h:24,d=1/this.path.unitsPerEm*h,n.lineWidth=1,n.strokeStyle="black",bn.line(n,i,-1e4,i,1e4),bn.line(n,-1e4,l,1e4,l);let p=this.xMin||0,b=this.yMin||0,x=this.xMax||0,A=this.yMax||0,E=this.advanceWidth||0;n.strokeStyle="blue",bn.line(n,i+p*d,-1e4,i+p*d,1e4),bn.line(n,i+x*d,-1e4,i+x*d,1e4),bn.line(n,-1e4,l+-b*d,1e4,l+-b*d),bn.line(n,-1e4,l+-A*d,1e4,l+-A*d),n.strokeStyle="green",bn.line(n,i+E*d,-1e4,i+E*d,1e4)},re.prototype.toPathData=function(n,i){n=Object.assign({},{variation:i&&i.defaultRenderOptions.variation},n);let l=this;i&&i.variation&&(l=i.variation.getTransform(this,n.variation));let h=l.points&&n.pointsTransform?n.pointsTransform(l.points):l.path;return n.pathTransform&&(h=n.pathTransform(h)),h.toPathData(n)},re.prototype.fromSVG=function(n,i={}){return this.path.fromSVG(n,i)},re.prototype.toSVG=function(n,i){let l=this.toPathData.apply(this,[n,i]);return this.path.toSVG(n,l)},re.prototype.toDOMElement=function(n,i){n=Object.assign({},{variation:i&&i.defaultRenderOptions.variation},n);let l=this.path;return i&&i.variation&&(l=i.variation.getTransform(this,n.variation).path),l.toDOMElement(n)};var Gn=re;function Hn(n,i,l){Object.defineProperty(n,i,{get:function(){return typeof n[l]>"u"&&n.path,n[l]},set:function(h){n[l]=h},enumerable:!0,configurable:!0})}function Xs(n,i){if(this.font=n,this.glyphs={},Array.isArray(i))for(let l=0;l<i.length;l++){let h=i[l];h.path.unitsPerEm=n.unitsPerEm,this.glyphs[l]=h}this.length=i&&i.length||0}typeof Symbol<"u"&&Symbol.iterator&&(Xs.prototype[Symbol.iterator]=function(){let n=-1;return{next:function(){n++;let i=n>=this.length-1;return{value:this.get(n),done:i}}.bind(this)}}),Xs.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let i=this.glyphs[n],l=this.font._IndexToUnicodeMap[n];if(l)for(let h=0;h<l.unicodes.length;h++)i.addUnicode(l.unicodes[h]);this.font.cffEncoding?i.name=this.font.cffEncoding.charset[n]:this.font.glyphNames.names&&(i.name=this.font.glyphNames.glyphIndexToName(n)),this.glyphs[n].advanceWidth=this.font._hmtxTableData[n].advanceWidth,this.glyphs[n].leftSideBearing=this.font._hmtxTableData[n].leftSideBearing}else typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());return this.glyphs[n]},Xs.prototype.push=function(n,i){this.glyphs[n]=i,this.length++};function nd(n,i){return new Gn({index:i,font:n})}function sd(n,i,l,h,d,p){return function(){let b=new Gn({index:i,font:n});return b.path=function(){l(b,h,d);let x=p(n.glyphs,b);return x.unitsPerEm=n.unitsPerEm,x},Hn(b,"numberOfContours","_numberOfContours"),Hn(b,"xMin","_xMin"),Hn(b,"xMax","_xMax"),Hn(b,"yMin","_yMin"),Hn(b,"yMax","_yMax"),Hn(b,"points","_points"),b}}function rd(n,i,l,h,d){return function(){let p=new Gn({index:i,font:n});return p.path=function(){let b=l(n,p,h,d);return b.unitsPerEm=n.unitsPerEm,b},p}}var Ve={GlyphSet:Xs,glyphLoader:nd,ttfGlyphLoader:sd,cffGlyphLoader:rd};function al(n,i){if(n===i)return!0;if(Array.isArray(n)&&Array.isArray(i)){if(n.length!==i.length)return!1;for(let l=0;l<n.length;l+=1)if(!al(n[l],i[l]))return!1;return!0}else return!1}var ll=10;function Ys(n){let i;return n.length<1240?i=107:n.length<33900?i=1131:i=32768,i}function $e(n,i,l,h){let d=[],p=[],b=h>1?it.getULong(n,i):it.getCard16(n,i),x=h>1?4:2,A,E;if(b!==0){let C=it.getByte(n,i+x);A=i+(b+1)*C+x;let P=i+x+1;for(let R=0;R<b+1;R+=1)d.push(it.getOffset(n,P,C)),P+=C;E=A+d[b]}else E=i+x;for(let C=0;C<d.length-1;C+=1){let P=it.getBytes(n,A+d[C],A+d[C+1]);l&&(P=l(P,n,i,h)),p.push(P)}return{objects:p,startOffset:i,endOffset:E}}function id(n,i,l){let h=[],d=l>1?it.getULong(n,i):it.getCard16(n,i),p=l>1?4:2,b,x;if(d!==0){let A=it.getByte(n,i+p);b=i+(d+1)*A+p;let E=i+p+1;for(let C=0;C<d+1;C+=1)h.push(it.getOffset(n,E,A)),E+=A;x=b+h[d]}else x=i+p;return{offsets:h,startOffset:i,endOffset:x}}function od(n,i,l,h,d,p){let b=p>1?it.getULong(l,h):it.getCard16(l,h),x=p>1?4:2,A=0;if(b!==0){let C=it.getByte(l,h+x);A=h+(b+1)*C+x}let E=it.getBytes(l,A+i[n],A+i[n+1]);return d&&(E=d(E)),E}function ad(n){let i="",h=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let d=n.parseByte(),p=d>>4,b=d&15;if(p===15||(i+=h[p],b===15))break;i+=h[b]}return parseFloat(i)}function ld(n,i){let l,h,d,p;if(i===28)return l=n.parseByte(),h=n.parseByte(),l<<8|h;if(i===29)return l=n.parseByte(),h=n.parseByte(),d=n.parseByte(),p=n.parseByte(),l<<24|h<<16|d<<8|p;if(i===30)return ad(n);if(i>=32&&i<=246)return i-139;if(i>=247&&i<=250)return l=n.parseByte(),(i-247)*256+l+108;if(i>=251&&i<=254)return l=n.parseByte(),-(i-251)*256-l-108;throw new Error("Invalid b0 "+i)}function cd(n){let i={};for(let l=0;l<n.length;l+=1){let h=n[l][0],d=n[l][1],p;if(d.length===1?p=d[0]:p=d,Object.prototype.hasOwnProperty.call(i,h)&&!isNaN(i[h]))throw new Error("Object "+i+" already has key "+h);i[h]=p}return i}function vi(n,i,l,h){i=i!==void 0?i:0;let d=new it.Parser(n,i),p=[],b=[];l=l!==void 0?l:n.byteLength;let x=h<2?22:28;for(;d.relativeOffset<l;){let A=d.parseByte();if(A<x){if(A===12&&(A=1200+d.parseByte()),h>1&&A===23){yd(b);continue}p.push([A,b]),b=[]}else b.push(ld(d,A,h))}return cd(p)}function Jn(n,i){return i<=390?i=zs[i]:n?i=n[i-391]:i=void 0,i}function xi(n,i,l){let h={},d;for(let p=0;p<i.length;p+=1){let b=i[p];if(Array.isArray(b.type)){let x=[];x.length=b.type.length;for(let A=0;A<b.type.length;A++)d=n[b.op]!==void 0?n[b.op][A]:void 0,d===void 0&&(d=b.value!==void 0&&b.value[A]!==void 0?b.value[A]:null),b.type[A]==="SID"&&(d=Jn(l,d)),x[A]=d;h[b.name]=x}else d=n[b.op],d===void 0&&(d=b.value!==void 0?b.value:null),b.type==="SID"&&(d=Jn(l,d)),h[b.name]=d}return h}function ud(n,i){let l={};if(l.formatMajor=it.getCard8(n,i),l.formatMinor=it.getCard8(n,i+1),l.formatMajor>2)throw new Error(`Unsupported CFF table version ${l.formatMajor}.${l.formatMinor}`);return l.size=it.getCard8(n,i+2),l.formatMajor<2?(l.offsetSize=it.getCard8(n,i+3),l.startOffset=i,l.endOffset=i+4):(l.topDictLength=it.getCard16(n,i+3),l.endOffset=i+8),l}var cl=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],ul=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],hl=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],dl=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],hd=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function dd(n,i,l,h){let d=vi(n,i,n.byteLength,h);return xi(d,h>1?ul:cl,l)}function Si(n,i,l,h,d){let p=vi(n,i,l,d);return xi(p,d>1?dl:hl,h)}function fd(n,i,l){let h=vi(n,i,void 0,l);return xi(h,hd)}function pd(n,i,l){let h=[];for(let d=0;d<l.length;d++){let p=new DataView(new Uint8Array(l[d]).buffer),b=fd(p,0,2),x=b.private[0],A=b.private[1];if(x!==0&&A!==0){let E=Si(n,A+i,x,[],2);if(E.subrs){let C=A+E.subrs,P=$e(n,C+i,void 0,2);b._subrs=P.objects,b._subrsBias=Ys(b._subrs)}b._privateDict=E}h.push(b)}return h}function Ai(n,i,l,h,d){let p=[];for(let b=0;b<l.length;b+=1){let x=new DataView(new Uint8Array(l[b]).buffer),A=dd(x,0,h,d);A._subrs=[],A._subrsBias=0,A._defaultWidthX=0,A._nominalWidthX=0;let E=d<2?A.private[0]:0,C=d<2?A.private[1]:0;if(E!==0&&C!==0){let P=Si(n,C+i,E,h,d);if(A._defaultWidthX=P.defaultWidthX,A._nominalWidthX=P.nominalWidthX,P.subrs!==0){let R=C+P.subrs,D=$e(n,R+i,void 0,d);A._subrs=D.objects,A._subrsBias=Ys(A._subrs)}A._privateDict=P}p.push(A)}return p}function gd(n,i,l,h,d){let p,b,x=new it.Parser(n,i);l-=1;let A=[".notdef"],E=x.parseCard8();if(E===0)for(let C=0;C<l;C+=1)p=x.parseSID(),d?A.push(p):A.push(Jn(h,p)||p);else if(E===1)for(;A.length<=l;){p=x.parseSID(),b=x.parseCard8();for(let C=0;C<=b;C+=1)d?A.push("cid"+("00000"+p).slice(-5)):A.push(Jn(h,p)||p),p+=1}else if(E===2)for(;A.length<=l;){p=x.parseSID(),b=x.parseCard16();for(let C=0;C<=b;C+=1)d?A.push("cid"+("00000"+p).slice(-5)):A.push(Jn(h,p)||p),p+=1}else throw new Error("Unknown charset format "+E);return A}function md(n,i){let l,h={},d=new it.Parser(n,i),p=d.parseCard8();if(p===0){let b=d.parseCard8();for(let x=0;x<b;x+=1)l=d.parseCard8(),h[l]=x}else if(p===1){let b=d.parseCard8();l=1;for(let x=0;x<b;x+=1){let A=d.parseCard8(),E=d.parseCard8();for(let C=A;C<=A+E;C+=1)h[C]=l,l+=1}}else throw new Error("Unknown encoding format "+p);return h}function yd(n){let i=n.pop();for(;n.length>i;)n.pop()}function fl(n,i){let l=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return l===2&&(i.fill=null,i.stroke="black",i.strokeWidth=n.tables.cff.topDict.strokeWidth||0),l}function Ti(n,i,l,h,d){let p,b,x,A,E=new st,C=[],P=0,R=!1,D=!1,O=0,_=0,V,mt,ht,At,kt=0,_t=[],Bt,Gt=0,Jt=n.tables.cff2||n.tables.cff;if(ht=Jt.topDict._defaultWidthX,At=Jt.topDict._nominalWidthX,d=d||n.variation&&n.variation.get(),i.getBlendPath||(i.getBlendPath=function(ot){return Ti(n,i,l,h,ot)}),n.isCIDFont||h>1){let ot=Jt.topDict._fdSelect?Jt.topDict._fdSelect[i.index]:0,ut=Jt.topDict._fdArray[ot];V=ut._subrs,mt=ut._subrsBias,h>1?(_t=Jt.topDict._vstore.itemVariationStore,kt=ut._privateDict.vsindex):(ht=ut._defaultWidthX,At=ut._nominalWidthX)}else V=Jt.topDict._subrs,mt=Jt.topDict._subrsBias;let Ne=fl(n,E),It=ht;function Ae(ot,ut){D&&Ne!==2&&E.closePath(),E.moveTo(ot,ut),D=!0}function he(){let ot;ot=(C.length&1)!==0,ot&&!R&&(It=C.shift()+At),P+=C.length>>1,C.length=0,R=!0}function yt(ot){let ut,ie,hn,rr,An,Ue,de,ke,oe,Te,fe,pe,Zt=0;for(;Zt<ot.length;){let Re=ot[Zt];switch(Zt+=1,Re){case 1:he();break;case 3:he();break;case 4:C.length>1&&!R&&(It=C.shift()+At,R=!0),_+=C.pop(),Ae(O,_);break;case 5:for(;C.length>0;)O+=C.shift(),_+=C.shift(),E.lineTo(O,_);break;case 6:for(;C.length>0&&(O+=C.shift(),E.lineTo(O,_),C.length!==0);)_+=C.shift(),E.lineTo(O,_);break;case 7:for(;C.length>0&&(_+=C.shift(),E.lineTo(O,_),C.length!==0);)O+=C.shift(),E.lineTo(O,_);break;case 8:for(;C.length>0;)p=O+C.shift(),b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),O=x+C.shift(),_=A+C.shift(),E.curveTo(p,b,x,A,O,_);break;case 10:if(An=C.pop()+mt,Ue=V[An],Ue){if(Gt>=ll){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Gt++,yt(Ue),Gt--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Re=ot[Zt],Zt+=1,Re){case 35:p=O+C.shift(),b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),de=x+C.shift(),ke=A+C.shift(),oe=de+C.shift(),Te=ke+C.shift(),fe=oe+C.shift(),pe=Te+C.shift(),O=fe+C.shift(),_=pe+C.shift(),C.shift(),E.curveTo(p,b,x,A,de,ke),E.curveTo(oe,Te,fe,pe,O,_);break;case 34:p=O+C.shift(),b=_,x=p+C.shift(),A=b+C.shift(),de=x+C.shift(),ke=A,oe=de+C.shift(),Te=A,fe=oe+C.shift(),pe=_,O=fe+C.shift(),E.curveTo(p,b,x,A,de,ke),E.curveTo(oe,Te,fe,pe,O,_);break;case 36:p=O+C.shift(),b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),de=x+C.shift(),ke=A,oe=de+C.shift(),Te=A,fe=oe+C.shift(),pe=Te+C.shift(),O=fe+C.shift(),E.curveTo(p,b,x,A,de,ke),E.curveTo(oe,Te,fe,pe,O,_);break;case 37:p=O+C.shift(),b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),de=x+C.shift(),ke=A+C.shift(),oe=de+C.shift(),Te=ke+C.shift(),fe=oe+C.shift(),pe=Te+C.shift(),Math.abs(fe-O)>Math.abs(pe-_)?O=fe+C.shift():_=pe+C.shift(),E.curveTo(p,b,x,A,de,ke),E.curveTo(oe,Te,fe,pe,O,_);break;default:console.log("Glyph "+i.index+": unknown operator 1200"+Re),C.length=0}break;case 14:if(h>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(C.length>=4){let Tn=mi[C.pop()],zn=mi[C.pop()],ir=C.pop(),or=C.pop();if(Tn&&zn){i.isComposite=!0,i.components=[];let Ic=n.cffEncoding.charset.indexOf(Tn),Rc=n.cffEncoding.charset.indexOf(zn);i.components.push({glyphIndex:Rc,dx:0,dy:0}),i.components.push({glyphIndex:Ic,dx:or,dy:ir}),E.extend(n.glyphs.get(Rc).path);let e0=n.glyphs.get(Ic),Hi=JSON.parse(JSON.stringify(e0.path.commands));for(let ji=0;ji<Hi.length;ji+=1){let We=Hi[ji];We.type!=="Z"&&(We.x+=or,We.y+=ir),(We.type==="Q"||We.type==="C")&&(We.x1+=or,We.y1+=ir),We.type==="C"&&(We.x2+=or,We.y2+=ir)}E.extend(Hi)}}else C.length>0&&!R&&(It=C.shift()+At,R=!0);D&&Ne!==2&&(E.closePath(),D=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}kt=C.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}Bt||(Bt=n.variation&&d&&n.variation.process.getBlendVector(_t,kt,d));var jt=C.pop(),me=Bt?Bt.length:_t.itemVariationSubtables[kt].regionIndexes.length,Ie=jt*me,Be=C.length-Ie,qe=Be-jt;if(Bt)for(let Tn=0;Tn<jt;Tn++){var kc=C[qe+Tn];for(let zn=0;zn<me;zn++)kc+=Bt[zn]*C[Be++];C[qe+Tn]=kc}for(;Ie--;)C.pop();break;case 18:he();break;case 19:case 20:he(),Zt+=P+7>>3;break;case 21:C.length>2&&!R&&(It=C.shift()+At,R=!0),_+=C.pop(),O+=C.pop(),Ae(O,_);break;case 22:C.length>1&&!R&&(It=C.shift()+At,R=!0),O+=C.pop(),Ae(O,_);break;case 23:he();break;case 24:for(;C.length>2;)p=O+C.shift(),b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),O=x+C.shift(),_=A+C.shift(),E.curveTo(p,b,x,A,O,_);O+=C.shift(),_+=C.shift(),E.lineTo(O,_);break;case 25:for(;C.length>6;)O+=C.shift(),_+=C.shift(),E.lineTo(O,_);p=O+C.shift(),b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),O=x+C.shift(),_=A+C.shift(),E.curveTo(p,b,x,A,O,_);break;case 26:for(C.length&1&&(O+=C.shift());C.length>0;)p=O,b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),O=x,_=A+C.shift(),E.curveTo(p,b,x,A,O,_);break;case 27:for(C.length&1&&(_+=C.shift());C.length>0;)p=O+C.shift(),b=_,x=p+C.shift(),A=b+C.shift(),O=x+C.shift(),_=A,E.curveTo(p,b,x,A,O,_);break;case 28:ut=ot[Zt],ie=ot[Zt+1],C.push((ut<<24|ie<<16)>>16),Zt+=2;break;case 29:if(An=C.pop()+n.gsubrsBias,Ue=n.gsubrs[An],Ue){if(Gt>=ll){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Gt++,yt(Ue),Gt--}break;case 30:for(;C.length>0&&(p=O,b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),O=x+C.shift(),_=A+(C.length===1?C.shift():0),E.curveTo(p,b,x,A,O,_),C.length!==0);)p=O+C.shift(),b=_,x=p+C.shift(),A=b+C.shift(),_=A+C.shift(),O=x+(C.length===1?C.shift():0),E.curveTo(p,b,x,A,O,_);break;case 31:for(;C.length>0&&(p=O+C.shift(),b=_,x=p+C.shift(),A=b+C.shift(),_=A+C.shift(),O=x+(C.length===1?C.shift():0),E.curveTo(p,b,x,A,O,_),C.length!==0);)p=O,b=_+C.shift(),x=p+C.shift(),A=b+C.shift(),O=x+C.shift(),_=A+(C.length===1?C.shift():0),E.curveTo(p,b,x,A,O,_);break;default:Re<32?console.log("Glyph "+i.index+": unknown operator "+Re):Re<247?C.push(Re-139):Re<251?(ut=ot[Zt],Zt+=1,C.push((Re-247)*256+ut+108)):Re<255?(ut=ot[Zt],Zt+=1,C.push(-(Re-251)*256-ut-108)):(ut=ot[Zt],ie=ot[Zt+1],hn=ot[Zt+2],rr=ot[Zt+3],Zt+=4,C.push((ut<<24|ie<<16|hn<<8|rr)/65536))}}}return yt(l),n.variation&&d&&(E.commands=E.commands.map(ot=>{let ut=Object.keys(ot);for(let ie=0;ie<ut.length;ie++){let hn=ut[ie];hn!=="type"&&(ot[hn]=Math.round(ot[hn]))}return ot})),R&&(i.advanceWidth=It),E}function pl(n,i,l,h,d){let p=[],b,x=new it.Parser(n,i),A=x.parseCard8();if(A===0)for(let E=0;E<l;E++){if(b=x.parseCard8(),b>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+b+" (FD count "+h+")");p.push(b)}else if(A===3||d>1&&A===4){let E=A===4?x.parseULong():x.parseCard16(),C=A===4?x.parseULong():x.parseCard16();if(C!==0)throw new Error(`CFF Table CID Font FDSelect format ${A} range has bad initial GID ${C}`);let P;for(let R=0;R<E;R++){if(b=A===4?x.parseUShort():x.parseCard8(),P=A===4?x.parseULong():x.parseCard16(),b>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+b+" (FD count "+h+")");if(P>l)throw new Error(`CFF Table CID Font FDSelect format ${d} range has bad GID ${P}`);for(;C<P;C++)p.push(b);C=P}if(P!==l)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+P)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+A);return p}function bd(n,i,l,h){let d,p=ud(n,i);p.formatMajor===2?d=l.tables.cff2={}:d=l.tables.cff={};let b=p.formatMajor>1?null:$e(n,p.endOffset,it.bytesToString),x=p.formatMajor>1?null:$e(n,b.endOffset),A=p.formatMajor>1?null:$e(n,x.endOffset,it.bytesToString),E=$e(n,p.formatMajor>1?i+p.size+p.topDictLength:A.endOffset,void 0,p.formatMajor);l.gsubrs=E.objects,l.gsubrsBias=Ys(l.gsubrs);let C;if(p.formatMajor>1){let R=i+p.size,D=it.getBytes(n,R,R+p.topDictLength);C=Ai(n,0,[D],void 0,p.formatMajor)[0]}else{let R=Ai(n,i,x.objects,A.objects,p.formatMajor);if(R.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+R.length);C=R[0]}if(d.topDict=C,C._privateDict&&(l.defaultWidthX=C._privateDict.defaultWidthX,l.nominalWidthX=C._privateDict.nominalWidthX),p.formatMajor<2&&C.ros[0]!==void 0&&C.ros[1]!==void 0&&(l.isCIDFont=!0),p.formatMajor>1){let R=C.fdArray,D=C.fdSelect;if(!R)throw new Error("This is a CFF2 font, but FDArray information is missing");let O=$e(n,i+R,null,p.formatMajor),_=pd(n,i,O.objects);C._fdArray=_,D&&(C._fdSelect=pl(n,i+D,l.numGlyphs,_.length,p.formatMajor))}else if(l.isCIDFont){let R=C.fdArray,D=C.fdSelect;if(R===0||D===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");R+=i;let O=$e(n,R),_=Ai(n,i,O.objects,A.objects,p.formatMajor);C._fdArray=_,D+=i,C._fdSelect=pl(n,D,l.numGlyphs,_.length,p.formatMajor)}if(p.formatMajor<2){let R=i+C.private[1],D=Si(n,R,C.private[0],A.objects,p.formatMajor);if(l.defaultWidthX=D.defaultWidthX,l.nominalWidthX=D.nominalWidthX,D.subrs!==0){let O=R+D.subrs,_=$e(n,O);l.subrs=_.objects,l.subrsBias=Ys(l.subrs)}else l.subrs=[],l.subrsBias=0}let P;if(h.lowMemory?(P=id(n,i+C.charStrings,p.formatMajor),l.nGlyphs=P.offsets.length-(p.formatMajor>1?1:0)):(P=$e(n,i+C.charStrings,null,p.formatMajor),l.nGlyphs=P.objects.length),p.formatMajor>1&&l.tables.maxp&&l.nGlyphs!==l.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${l.nGlyphs}) must correspond to the glyph count in the maxp table (${l.tables.maxp.numGlyphs})`),p.formatMajor<2){let R=[],D=[];C.charset===0?R=Vh:C.charset===1?R=$h:C.charset===2?R=zh:R=gd(n,i+C.charset,l.nGlyphs,A.objects,l.isCIDFont),C.encoding===0?D=mi:C.encoding===1?D=Wh:D=md(n,i+C.encoding),l.cffEncoding=new sl(D,R),l.encoding=l.encoding||l.cffEncoding}if(l.glyphs=new Ve.GlyphSet(l),h.lowMemory)l._push=function(R){let D=od(R,P.offsets,n,i+C.charStrings,void 0,p.formatMajor);l.glyphs.push(R,Ve.cffGlyphLoader(l,R,Ti,D,p.formatMajor))};else for(let R=0;R<l.nGlyphs;R+=1){let D=P.objects[R];l.glyphs.push(R,Ve.cffGlyphLoader(l,R,Ti,D,p.formatMajor))}if(C.vstore){let R=new it.Parser(n,i+C.vstore);C._vstore=R.parseVariationStore()}}function gl(n,i){let l,h=zs.indexOf(n);return h>=0&&(l=h),h=i.indexOf(n),h>=0?l=h+zs.length:(l=zs.length+i.length,i.push(n)),l}function vd(){return new Q.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function xd(n){let i=new Q.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);i.names=[];for(let l=0;l<n.length;l+=1)i.names.push({name:"name_"+l,type:"NAME",value:n[l]});return i}function ml(n,i,l){let h={};for(let d=0;d<n.length;d+=1){let p=n[d],b=i[p.name];b!==void 0&&!al(b,p.value)&&(p.type==="SID"&&(b=gl(b,l)),h[p.op]={name:p.name,type:p.type,value:b})}return h}function yl(n,i,l){let h=new Q.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=ml(l>1?ul:cl,n,i),h}function bl(n){let i=new Q.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return i.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],i}function Sd(n){let i=new Q.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);i.strings=[];for(let l=0;l<n.length;l+=1)i.strings.push({name:"string_"+l,type:"STRING",value:n[l]});return i}function Ad(){return new Q.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Td(n,i){let l=new Q.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let h=0;h<n.length;h+=1){let d=n[h],p=gl(d,i);l.fields.push({name:"glyph_"+h,type:"SID",value:p})}return l}function Cd(n,i){let l=[],h=n.path;i<2&&l.push({name:"width",type:"NUMBER",value:n.advanceWidth});let d=0,p=0;for(let b=0;b<h.commands.length;b+=1){let x,A,E=h.commands[b];if(E.type==="Q"){let C=.3333333333333333,P=2/3;E={type:"C",x:E.x,y:E.y,x1:Math.round(C*d+P*E.x1),y1:Math.round(C*p+P*E.y1),x2:Math.round(C*E.x+P*E.x1),y2:Math.round(C*E.y+P*E.y1)}}if(E.type==="M")x=Math.round(E.x-d),A=Math.round(E.y-p),l.push({name:"dx",type:"NUMBER",value:x}),l.push({name:"dy",type:"NUMBER",value:A}),l.push({name:"rmoveto",type:"OP",value:21}),d=Math.round(E.x),p=Math.round(E.y);else if(E.type==="L")x=Math.round(E.x-d),A=Math.round(E.y-p),l.push({name:"dx",type:"NUMBER",value:x}),l.push({name:"dy",type:"NUMBER",value:A}),l.push({name:"rlineto",type:"OP",value:5}),d=Math.round(E.x),p=Math.round(E.y);else if(E.type==="C"){let C=Math.round(E.x1-d),P=Math.round(E.y1-p),R=Math.round(E.x2-E.x1),D=Math.round(E.y2-E.y1);x=Math.round(E.x-E.x2),A=Math.round(E.y-E.y2),l.push({name:"dx1",type:"NUMBER",value:C}),l.push({name:"dy1",type:"NUMBER",value:P}),l.push({name:"dx2",type:"NUMBER",value:R}),l.push({name:"dy2",type:"NUMBER",value:D}),l.push({name:"dx",type:"NUMBER",value:x}),l.push({name:"dy",type:"NUMBER",value:A}),l.push({name:"rrcurveto",type:"OP",value:8}),d=Math.round(E.x),p=Math.round(E.y)}}return i<2&&l.push({name:"endchar",type:"OP",value:14}),l}function Ed(n,i){let l=new Q.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let h=0;h<n.length;h+=1){let d=n.get(h),p=Cd(d,i);l.charStrings.push({name:d.name,type:"CHARSTRING",value:p})}return l}function wd(n,i,l){let h=new Q.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=ml(l>1?dl:hl,n,i),h}function kd(n,i){let h=new Q.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),d=1/i.unitsPerEm,p={version:i.version,fullName:i.fullName,familyName:i.familyName,weight:i.weightName,fontBBox:i.fontBBox||[0,0,0,0],fontMatrix:[d,0,0,d,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},b=i&&i.topDict||{};b.paintType&&(p.paintType=b.paintType,p.strokeWidth=b.strokeWidth||0);let x={},A=[],E;for(let D=1;D<n.length;D+=1)E=n.get(D),A.push(E.name);let C=[];h.header=vd(),h.nameIndex=xd([i.postScriptName]);let P=yl(p,C);h.topDictIndex=bl(P),h.globalSubrIndex=Ad(),h.charsets=Td(A,C),h.charStringsIndex=Ed(n,1),h.privateDict=wd(x,C),h.stringIndex=Sd(C);let R=h.header.sizeOf()+h.nameIndex.sizeOf()+h.topDictIndex.sizeOf()+h.stringIndex.sizeOf()+h.globalSubrIndex.sizeOf();return p.charset=R,p.encoding=0,p.charStrings=p.charset+h.charsets.sizeOf(),p.private[1]=p.charStrings+h.charStringsIndex.sizeOf(),P=yl(p,C),h.topDictIndex=bl(P),h}var Ci={parse:bd,make:kd};function Id(n,i){let l={},h=new it.Parser(n,i);return l.version=h.parseVersion(),l.fontRevision=Math.round(h.parseFixed()*1e3)/1e3,l.checkSumAdjustment=h.parseULong(),l.magicNumber=h.parseULong(),H.argument(l.magicNumber===1594834165,"Font header has wrong magic number."),l.flags=h.parseUShort(),l.unitsPerEm=h.parseUShort(),l.created=h.parseLongDateTime(),l.modified=h.parseLongDateTime(),l.xMin=h.parseShort(),l.yMin=h.parseShort(),l.xMax=h.parseShort(),l.yMax=h.parseShort(),l.macStyle=h.parseUShort(),l.lowestRecPPEM=h.parseUShort(),l.fontDirectionHint=h.parseShort(),l.indexToLocFormat=h.parseShort(),l.glyphDataFormat=h.parseShort(),l}function Rd(n){let i=Math.round(new Date().getTime()/1e3)+2082844800,l=i,h=n.macStyle||0;return n.createdTimestamp&&(l=n.createdTimestamp+2082844800),new Q.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:l},{name:"modified",type:"LONGDATETIME",value:i},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:h},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],n)}var vl={parse:Id,make:Rd};function Pd(n,i){let l={},h=new it.Parser(n,i);return l.version=h.parseVersion(),l.ascender=h.parseShort(),l.descender=h.parseShort(),l.lineGap=h.parseShort(),l.advanceWidthMax=h.parseUShort(),l.minLeftSideBearing=h.parseShort(),l.minRightSideBearing=h.parseShort(),l.xMaxExtent=h.parseShort(),l.caretSlopeRise=h.parseShort(),l.caretSlopeRun=h.parseShort(),l.caretOffset=h.parseShort(),h.relativeOffset+=8,l.metricDataFormat=h.parseShort(),l.numberOfHMetrics=h.parseUShort(),l}function Od(n){return new Q.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],n)}var xl={parse:Pd,make:Od};function Ld(n,i,l,h,d){let p,b,x=new it.Parser(n,i);for(let A=0;A<h;A+=1){A<l&&(p=x.parseUShort(),b=x.parseShort());let E=d.get(A);E.advanceWidth=p,E.leftSideBearing=b}}function Md(n,i,l,h,d){n._hmtxTableData={};let p,b,x=new it.Parser(i,l);for(let A=0;A<d;A+=1)A<h&&(p=x.parseUShort(),b=x.parseShort()),n._hmtxTableData[A]={advanceWidth:p,leftSideBearing:b}}function Dd(n,i,l,h,d,p,b){b.lowMemory?Md(n,i,l,h,d):Ld(i,l,h,d,p)}function Fd(n){let i=new Q.Table("hmtx",[]);for(let l=0;l<n.length;l+=1){let h=n.get(l),d=h.advanceWidth||0,p=h.leftSideBearing||0;i.fields.push({name:"advanceWidth_"+l,type:"USHORT",value:d}),i.fields.push({name:"leftSideBearing_"+l,type:"SHORT",value:p})}return i}var Sl={parse:Dd,make:Fd};function _d(n){let i=new Q.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]),l="",h=12+n.length*4;for(let d=0;d<n.length;++d){let p=l.indexOf(n[d]);p<0&&(p=l.length,l+=n[d]),i.fields.push({name:"offset "+d,type:"USHORT",value:h+p}),i.fields.push({name:"length "+d,type:"USHORT",value:n[d].length})}return i.fields.push({name:"stringPool",type:"CHARARRAY",value:l}),i}function Nd(n,i){let l=new it.Parser(n,i),h=l.parseULong();H.argument(h===1,"Unsupported ltag table version."),l.skip("uLong",1);let d=l.parseULong(),p=[];for(let b=0;b<d;b++){let x="",A=i+l.parseUShort(),E=l.parseUShort();for(let C=A;C<A+E;++C)x+=String.fromCharCode(n.getInt8(C));p.push(x)}return p}var Al={make:_d,parse:Nd};function Ud(n,i){let l={},h=new it.Parser(n,i);return l.version=h.parseVersion(),l.numGlyphs=h.parseUShort(),l.version===1&&(l.maxPoints=h.parseUShort(),l.maxContours=h.parseUShort(),l.maxCompositePoints=h.parseUShort(),l.maxCompositeContours=h.parseUShort(),l.maxZones=h.parseUShort(),l.maxTwilightPoints=h.parseUShort(),l.maxStorage=h.parseUShort(),l.maxFunctionDefs=h.parseUShort(),l.maxInstructionDefs=h.parseUShort(),l.maxStackElements=h.parseUShort(),l.maxSizeOfInstructions=h.parseUShort(),l.maxComponentElements=h.parseUShort(),l.maxComponentDepth=h.parseUShort()),l}function Bd(n){return new Q.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}var Tl={parse:Ud,make:Bd},Ei=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function Gd(n){for(let i=0;i<Ei.length;i+=1){let l=Ei[i];if(n>=l.begin&&n<l.end)return i}return-1}function Hd(n,i){let l={},h=new it.Parser(n,i);l.version=h.parseUShort(),l.xAvgCharWidth=h.parseShort(),l.usWeightClass=h.parseUShort(),l.usWidthClass=h.parseUShort(),l.fsType=h.parseUShort(),l.ySubscriptXSize=h.parseShort(),l.ySubscriptYSize=h.parseShort(),l.ySubscriptXOffset=h.parseShort(),l.ySubscriptYOffset=h.parseShort(),l.ySuperscriptXSize=h.parseShort(),l.ySuperscriptYSize=h.parseShort(),l.ySuperscriptXOffset=h.parseShort(),l.ySuperscriptYOffset=h.parseShort(),l.yStrikeoutSize=h.parseShort(),l.yStrikeoutPosition=h.parseShort(),l.sFamilyClass=h.parseShort(),l.panose=[];for(let d=0;d<10;d++)l.panose[d]=h.parseByte();return l.ulUnicodeRange1=h.parseULong(),l.ulUnicodeRange2=h.parseULong(),l.ulUnicodeRange3=h.parseULong(),l.ulUnicodeRange4=h.parseULong(),l.achVendID=String.fromCharCode(h.parseByte(),h.parseByte(),h.parseByte(),h.parseByte()),l.fsSelection=h.parseUShort(),l.usFirstCharIndex=h.parseUShort(),l.usLastCharIndex=h.parseUShort(),l.sTypoAscender=h.parseShort(),l.sTypoDescender=h.parseShort(),l.sTypoLineGap=h.parseShort(),l.usWinAscent=h.parseUShort(),l.usWinDescent=h.parseUShort(),l.version>=1&&(l.ulCodePageRange1=h.parseULong(),l.ulCodePageRange2=h.parseULong()),l.version>=2&&(l.sxHeight=h.parseShort(),l.sCapHeight=h.parseShort(),l.usDefaultChar=h.parseUShort(),l.usBreakChar=h.parseUShort(),l.usMaxContent=h.parseUShort()),l}function jd(n){return new Q.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var wi={parse:Hd,make:jd,unicodeRanges:Ei,getUnicodeRange:Gd};function Vd(n,i){let l={},h=new it.Parser(n,i);switch(l.version=h.parseVersion(),l.italicAngle=h.parseFixed(),l.underlinePosition=h.parseShort(),l.underlineThickness=h.parseShort(),l.isFixedPitch=h.parseULong(),l.minMemType42=h.parseULong(),l.maxMemType42=h.parseULong(),l.minMemType1=h.parseULong(),l.maxMemType1=h.parseULong(),l.version){case 1:l.names=yn.slice();break;case 2:l.numberOfGlyphs=h.parseUShort(),l.glyphNameIndex=new Array(l.numberOfGlyphs);for(let d=0;d<l.numberOfGlyphs;d++)l.glyphNameIndex[d]=h.parseUShort();l.names=[];for(let d=0;d<l.numberOfGlyphs;d++)if(l.glyphNameIndex[d]>=yn.length){let p=h.parseChar();l.names.push(h.parseString(p))}break;case 2.5:l.numberOfGlyphs=h.parseUShort(),l.offset=new Array(l.numberOfGlyphs);for(let d=0;d<l.numberOfGlyphs;d++)l.offset[d]=h.parseChar();break}return l}function $d(n){let{italicAngle:i=Math.round((n.italicAngle||0)*65536),underlinePosition:l=0,underlineThickness:h=0,isFixedPitch:d=0,minMemType42:p=0,maxMemType42:b=0,minMemType1:x=0,maxMemType1:A=0}=n.tables.post||{};return new Q.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:i},{name:"underlinePosition",type:"FWORD",value:l},{name:"underlineThickness",type:"FWORD",value:h},{name:"isFixedPitch",type:"ULONG",value:d},{name:"minMemType42",type:"ULONG",value:p},{name:"maxMemType42",type:"ULONG",value:b},{name:"minMemType1",type:"ULONG",value:x},{name:"maxMemType1",type:"ULONG",value:A}])}var Cl={parse:Vd,make:$d},Fe=new Array(9);Fe[1]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{substFormat:1,coverage:this.parsePointer(U.coverage),deltaGlyphId:this.parseShort()};if(l===2)return{substFormat:2,coverage:this.parsePointer(U.coverage),substitute:this.parseOffset16List()};H.assert(!1,"0x"+i.toString(16)+": lookup type 1 format must be 1 or 2.")},Fe[2]=function(){let i=this.parseUShort();return H.argument(i===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(U.coverage),sequences:this.parseListOfLists()}},Fe[3]=function(){let i=this.parseUShort();return H.argument(i===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(U.coverage),alternateSets:this.parseListOfLists()}},Fe[4]=function(){let i=this.parseUShort();return H.argument(i===1,"GSUB ligature table identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(U.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var jn={sequenceIndex:U.uShort,lookupListIndex:U.uShort};Fe[5]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{substFormat:l,coverage:this.parsePointer(U.coverage),ruleSets:this.parseListOfLists(function(){let h=this.parseUShort(),d=this.parseUShort();return{input:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(d,jn)}})};if(l===2)return{substFormat:l,coverage:this.parsePointer(U.coverage),classDef:this.parsePointer(U.classDef),classSets:this.parseListOfLists(function(){let h=this.parseUShort(),d=this.parseUShort();return{classes:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(d,jn)}})};if(l===3){let h=this.parseUShort(),d=this.parseUShort();return{substFormat:l,coverages:this.parseList(h,U.pointer(U.coverage)),lookupRecords:this.parseRecordList(d,jn)}}H.assert(!1,"0x"+i.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Fe[6]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{substFormat:1,coverage:this.parsePointer(U.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(jn)}})};if(l===2)return{substFormat:2,coverage:this.parsePointer(U.coverage),backtrackClassDef:this.parsePointer(U.classDef),inputClassDef:this.parsePointer(U.classDef),lookaheadClassDef:this.parsePointer(U.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(jn)}})};if(l===3)return{substFormat:3,backtrackCoverage:this.parseList(U.pointer(U.coverage)),inputCoverage:this.parseList(U.pointer(U.coverage)),lookaheadCoverage:this.parseList(U.pointer(U.coverage)),lookupRecords:this.parseRecordList(jn)};H.assert(!1,"0x"+i.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Fe[7]=function(){let i=this.parseUShort();H.argument(i===1,"GSUB Extension Substitution subtable identifier-format must be 1");let l=this.parseUShort(),h=new U(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:l,extension:Fe[l].call(h)}},Fe[8]=function(){let i=this.parseUShort();return H.argument(i===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(U.coverage),backtrackCoverage:this.parseList(U.pointer(U.coverage)),lookaheadCoverage:this.parseList(U.pointer(U.coverage)),substitutes:this.parseUShortList()}};function zd(n,i){i=i||0;let l=new U(n,i),h=l.parseVersion(1);return H.argument(h===1||h===1.1,"Unsupported GSUB table version."),h===1?{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(Fe)}:{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(Fe),variations:l.parseFeatureVariationsList()}}var vn=new Array(9);vn[1]=function(i){if(i.substFormat===1)return new Q.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)},{name:"deltaGlyphID",type:"SHORT",value:i.deltaGlyphId}]);if(i.substFormat===2)return new Q.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)}].concat(Q.ushortList("substitute",i.substitute)));H.fail("Lookup type 1 substFormat must be 1 or 2.")},vn[2]=function(i){return H.assert(i.substFormat===1,"Lookup type 2 substFormat must be 1."),new Q.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)}].concat(Q.tableList("seqSet",i.sequences,function(l){return new Q.Table("sequenceSetTable",Q.ushortList("sequence",l))})))},vn[3]=function(i){return H.assert(i.substFormat===1,"Lookup type 3 substFormat must be 1."),new Q.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)}].concat(Q.tableList("altSet",i.alternateSets,function(l){return new Q.Table("alternateSetTable",Q.ushortList("alternate",l))})))},vn[4]=function(i){return H.assert(i.substFormat===1,"Lookup type 4 substFormat must be 1."),new Q.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)}].concat(Q.tableList("ligSet",i.ligatureSets,function(l){return new Q.Table("ligatureSetTable",Q.tableList("ligature",l,function(h){return new Q.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:h.ligGlyph}].concat(Q.ushortList("component",h.components,h.components.length+1)))}))})))},vn[5]=function(i){if(i.substFormat===1)return new Q.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)}].concat(Q.tableList("sequenceRuleSet",i.ruleSets,function(l){return l?new Q.Table("sequenceRuleSetTable",Q.tableList("sequenceRule",l,function(h){let d=Q.ushortList("seqLookup",[],h.lookupRecords.length).concat(Q.ushortList("inputSequence",h.input,h.input.length+1));[d[0],d[1]]=[d[1],d[0]];for(let p=0;p<h.lookupRecords.length;p++){let b=h.lookupRecords[p];d=d.concat({name:"sequenceIndex"+p,type:"USHORT",value:b.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:b.lookupListIndex})}return new Q.Table("sequenceRuleTable",d)})):new Q.Table("NULL",null)})));if(i.substFormat===2)return new Q.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)},{name:"classDef",type:"TABLE",value:new Q.ClassDef(i.classDef)}].concat(Q.tableList("classSeqRuleSet",i.classSets,function(l){return l?new Q.Table("classSeqRuleSetTable",Q.tableList("classSeqRule",l,function(h){let d=Q.ushortList("classes",h.classes,h.classes.length+1).concat(Q.ushortList("seqLookupCount",[],h.lookupRecords.length));for(let p=0;p<h.lookupRecords.length;p++){let b=h.lookupRecords[p];d=d.concat({name:"sequenceIndex"+p,type:"USHORT",value:b.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:b.lookupListIndex})}return new Q.Table("classSeqRuleTable",d)})):new Q.Table("NULL",null)})));if(i.substFormat===3){let l=[{name:"substFormat",type:"USHORT",value:i.substFormat}];l.push({name:"inputGlyphCount",type:"USHORT",value:i.coverages.length}),l.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let d=0;d<i.coverages.length;d++){let p=i.coverages[d];l.push({name:"inputCoverage"+d,type:"TABLE",value:new Q.Coverage(p)})}for(let d=0;d<i.lookupRecords.length;d++){let p=i.lookupRecords[d];l=l.concat({name:"sequenceIndex"+d,type:"USHORT",value:p.sequenceIndex}).concat({name:"lookupListIndex"+d,type:"USHORT",value:p.lookupListIndex})}return new Q.Table("contextualSubstitutionTable",l)}H.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},vn[6]=function(i){if(i.substFormat===1)return new Q.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new Q.Coverage(i.coverage)}].concat(Q.tableList("chainRuleSet",i.chainRuleSets,function(h){return new Q.Table("chainRuleSetTable",Q.tableList("chainRule",h,function(d){let p=Q.ushortList("backtrackGlyph",d.backtrack,d.backtrack.length).concat(Q.ushortList("inputGlyph",d.input,d.input.length+1)).concat(Q.ushortList("lookaheadGlyph",d.lookahead,d.lookahead.length)).concat(Q.ushortList("substitution",[],d.lookupRecords.length));for(let b=0;b<d.lookupRecords.length;b++){let x=d.lookupRecords[b];p=p.concat({name:"sequenceIndex"+b,type:"USHORT",value:x.sequenceIndex}).concat({name:"lookupListIndex"+b,type:"USHORT",value:x.lookupListIndex})}return new Q.Table("chainRuleTable",p)}))})));if(i.substFormat===2)H.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(i.substFormat===3){let l=[{name:"substFormat",type:"USHORT",value:i.substFormat}];l.push({name:"backtrackGlyphCount",type:"USHORT",value:i.backtrackCoverage.length});for(let d=0;d<i.backtrackCoverage.length;d++){let p=i.backtrackCoverage[d];l.push({name:"backtrackCoverage"+d,type:"TABLE",value:new Q.Coverage(p)})}l.push({name:"inputGlyphCount",type:"USHORT",value:i.inputCoverage.length});for(let d=0;d<i.inputCoverage.length;d++){let p=i.inputCoverage[d];l.push({name:"inputCoverage"+d,type:"TABLE",value:new Q.Coverage(p)})}l.push({name:"lookaheadGlyphCount",type:"USHORT",value:i.lookaheadCoverage.length});for(let d=0;d<i.lookaheadCoverage.length;d++){let p=i.lookaheadCoverage[d];l.push({name:"lookaheadCoverage"+d,type:"TABLE",value:new Q.Coverage(p)})}l.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let d=0;d<i.lookupRecords.length;d++){let p=i.lookupRecords[d];l=l.concat({name:"sequenceIndex"+d,type:"USHORT",value:p.sequenceIndex}).concat({name:"lookupListIndex"+d,type:"USHORT",value:p.lookupListIndex})}return new Q.Table("chainContextTable",l)}H.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Wd(n){return new Q.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Q.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new Q.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new Q.LookupList(n.lookups,vn)}])}var El={parse:zd,make:Wd};function Xd(n,i){let l=new it.Parser(n,i),h=l.parseULong();H.argument(h===1,"Unsupported META table version."),l.parseULong(),l.parseULong();let d=l.parseULong(),p={};for(let b=0;b<d;b++){let x=l.parseTag(),A=l.parseULong(),E=l.parseULong();if(x==="appl"||x==="bild")continue;let C=Nt.UTF8(n,i+A,E);p[x]=C}return p}function Yd(n){let i=Object.keys(n).length,l="",h=16+i*12,d=new Q.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:h},{name:"numTags",type:"ULONG",value:i}]);for(let p in n){let b=l.length;l+=n[p],d.fields.push({name:"tag "+p,type:"TAG",value:p}),d.fields.push({name:"offset "+p,type:"ULONG",value:h+b}),d.fields.push({name:"length "+p,type:"ULONG",value:n[p].length})}return d.fields.push({name:"stringPool",type:"CHARARRAY",value:l}),d}var wl={parse:Xd,make:Yd};function Kd(n,i){let l=new U(n,i),h=l.parseUShort();h!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");let d=l.parseUShort(),p=l.parseOffset32(),b=l.parseOffset32(),x=l.parseUShort();l.relativeOffset=p;let A=l.parseRecordList(d,{glyphID:U.uShort,firstLayerIndex:U.uShort,numLayers:U.uShort});l.relativeOffset=b;let E=l.parseRecordList(x,{glyphID:U.uShort,paletteIndex:U.uShort});return{version:h,baseGlyphRecords:A,layerRecords:E}}function Zd({version:n=0,baseGlyphRecords:i=[],layerRecords:l=[]}){H.argument(n===0,"Only COLRv0 supported.");let h=14,d=h+i.length*6;return new Q.Table("COLR",[{name:"version",type:"USHORT",value:n},{name:"numBaseGlyphRecords",type:"USHORT",value:i.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:h},{name:"layerRecordsOffset",type:"ULONG",value:d},{name:"numLayerRecords",type:"USHORT",value:l.length},...i.map((p,b)=>[{name:"glyphID_"+b,type:"USHORT",value:p.glyphID},{name:"firstLayerIndex_"+b,type:"USHORT",value:p.firstLayerIndex},{name:"numLayers_"+b,type:"USHORT",value:p.numLayers}]).flat(),...l.map((p,b)=>[{name:"LayerGlyphID_"+b,type:"USHORT",value:p.glyphID},{name:"paletteIndex_"+b,type:"USHORT",value:p.paletteIndex}]).flat()])}var kl={parse:Kd,make:Zd};function Qd(n,i){return[{name:"tag_"+n,type:"TAG",value:i.tag},{name:"minValue_"+n,type:"FIXED",value:i.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:i.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:i.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:i.axisNameID}]}function Jd(n,i,l){let h={},d=new it.Parser(n,i);h.tag=d.parseTag(),h.minValue=d.parseFixed(),h.defaultValue=d.parseFixed(),h.maxValue=d.parseFixed(),d.skip("uShort",1);let p=d.parseUShort();return h.axisNameID=p,h.name=$s(l,p),h}function qd(n,i,l,h={}){let d=[{name:"nameID_"+n,type:"USHORT",value:i.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let p=0;p<l.length;++p){let b=l[p].tag;d.push({name:"axis_"+n+" "+b,type:"FIXED",value:i.coordinates[b]<<16})}return h&&h.postScriptNameID&&d.push({name:"postScriptNameID_",type:"USHORT",value:i.postScriptNameID!==void 0?i.postScriptNameID:65535}),d}function tf(n,i,l,h,d){let p={},b=new it.Parser(n,i),x=b.parseUShort();p.subfamilyNameID=x,p.name=$s(h,x,[2,17]),b.skip("uShort",1),p.coordinates={};for(let E=0;E<l.length;++E)p.coordinates[l[E].tag]=b.parseFixed();if(b.relativeOffset===d)return p.postScriptNameID=void 0,p.postScriptName=void 0,p;let A=b.parseUShort();return p.postScriptNameID=A==65535?void 0:A,p.postScriptName=p.postScriptNameID!==void 0?$s(h,A,[6]):"",p}function ef(n,i){let l=new Q.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);l.offsetToData=l.sizeOf();for(let d=0;d<n.axes.length;d++)l.fields=l.fields.concat(Qd(d,n.axes[d],i));let h={};for(let d=0;d<n.instances.length;d++)if(n.instances[d].postScriptNameID!==void 0){l.instanceSize+=2,h.postScriptNameID=!0;break}for(let d=0;d<n.instances.length;d++)l.fields=l.fields.concat(qd(d,n.instances[d],n.axes,h));return l}function nf(n,i,l){let h=new it.Parser(n,i),d=h.parseULong();H.argument(d===65536,"Unsupported fvar table version.");let p=h.parseOffset16();h.skip("uShort",1);let b=h.parseUShort(),x=h.parseUShort(),A=h.parseUShort(),E=h.parseUShort(),C=[];for(let D=0;D<b;D++)C.push(Jd(n,i+p+D*x,l));let P=[],R=i+p+b*x;for(let D=0;D<A;D++)P.push(tf(n,R+D*E,C,l,E));return{axes:C,instances:P}}var Il={make:ef,parse:nf},sf={tag:U.tag,nameID:U.uShort,ordering:U.uShort},qn=new Array(5);qn[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},qn[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},qn[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},qn[4]=function(){let i=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(i,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function rf(){let n=this.parseUShort(),i=qn[n],l={format:n};return i===void 0?(console.warn(`Unknown axis value table format ${n}`),l):Object.assign(l,this.parseStruct(i.bind(this)))}function of(n,i,l){i||(i=0);let h=new it.Parser(n,i),d=h.parseUShort(),p=h.parseUShort();d!==1&&console.warn(`Unsupported STAT table version ${d}.${p}`);let b=[d,p],x=h.parseUShort(),A=h.parseUShort(),E=h.parseOffset32(),C=h.parseUShort(),P=h.parseOffset32(),R=d>1||p>0?h.parseUShort():void 0;l!==void 0&&H.argument(A>=l.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),C>0&&H.argument(A>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let D=[];for(let V=0;V<A;V++)h.offset=i+E,h.relativeOffset=V*x,D.push(h.parseStruct(sf));h.offset=i,h.relativeOffset=P;let O=h.parseUShortList(C),_=[];for(let V=0;V<C;V++)h.offset=i+P,h.relativeOffset=O[V],_.push(rf.apply(h));return{version:b,axes:D,values:_,elidedFallbackNameID:R}}var ts=new Array(5);ts[1]=function(i,l){return[{name:`format${i}`,type:"USHORT",value:1},{name:`axisIndex${i}`,type:"USHORT",value:l.axisIndex},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID},{name:`value${i}`,type:"FLOAT",value:l.value}]},ts[2]=function(i,l){return[{name:`format${i}`,type:"USHORT",value:2},{name:`axisIndex${i}`,type:"USHORT",value:l.axisIndex},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID},{name:`nominalValue${i}`,type:"FLOAT",value:l.nominalValue},{name:`rangeMinValue${i}`,type:"FLOAT",value:l.rangeMinValue},{name:`rangeMaxValue${i}`,type:"FLOAT",value:l.rangeMaxValue}]},ts[3]=function(i,l){return[{name:`format${i}`,type:"USHORT",value:3},{name:`axisIndex${i}`,type:"USHORT",value:l.axisIndex},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID},{name:`value${i}`,type:"FLOAT",value:l.value},{name:`linkedValue${i}`,type:"FLOAT",value:l.linkedValue}]},ts[4]=function(i,l){let h=[{name:`format${i}`,type:"USHORT",value:4},{name:`axisCount${i}`,type:"USHORT",value:l.axisValues.length},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID}];for(let d=0;d<l.axisValues.length;d++)h=h.concat([{name:`format${i}axisIndex${d}`,type:"USHORT",value:l.axisValues[d].axisIndex},{name:`format${i}value${d}`,type:"FLOAT",value:l.axisValues[d].value}]);return h};function af(n,i){return new Q.Record("axisRecord_"+n,[{name:"axisTag_"+n,type:"TAG",value:i.tag},{name:"axisNameID_"+n,type:"USHORT",value:i.nameID},{name:"axisOrdering_"+n,type:"USHORT",value:i.ordering}])}function lf(n,i){let l=i.format,h=ts[l];H.argument(h!==void 0,`Unknown axis value table format ${l}`);let d=h(n,i);return new Q.Table("axisValueTable_"+n,d)}function cf(n){let i=new Q.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:n.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:n.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:n.elidedFallbackNameID}]);i.designAxesOffset=i.offsetToAxisValueOffsets=i.sizeOf();for(let p=0;p<n.axes.length;p++){let b=af(p,n.axes[p]);i.offsetToAxisValueOffsets+=b.sizeOf(),i.fields=i.fields.concat(b.fields)}let l=[],h=[],d=n.values.length*2;for(let p=0;p<n.values.length;p++){let b=lf(p,n.values[p]);l.push({name:"offset_"+p,type:"USHORT",value:d}),d+=b.sizeOf(),h=h.concat(b.fields)}return i.fields=i.fields.concat(l),i.fields=i.fields.concat(h),i}var Rl={make:cf,parse:of};function uf(n,i){return new Q.Record("axisValueMap_"+n,[{name:"fromCoordinate_"+n,type:"F2DOT14",value:i.fromCoordinate},{name:"toCoordinate_"+n,type:"F2DOT14",value:i.toCoordinate}])}function hf(n,i){let l=new Q.Record("segmentMap_"+n,[{name:"positionMapCount_"+n,type:"USHORT",value:i.axisValueMaps.length}]),h=[];for(let d=0;d<i.axisValueMaps.length;d++){let p=uf(`${n}_${d}`,i.axisValueMaps[d]);h=h.concat(p.fields)}return l.fields=l.fields.concat(h),l}function df(n,i){H.argument(n.axisSegmentMaps.length===i.axes.length,"avar axis count must correspond to fvar axis count");let l=new Q.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:n.axisSegmentMaps.length}]);for(let h=0;h<n.axisSegmentMaps.length;h++){let d=hf(h,n.axisSegmentMaps[h]);l.fields=l.fields.concat(d.fields)}return l}function ff(n,i,l){i||(i=0);let h=new U(n,i),d=h.parseUShort(),p=h.parseUShort();d!==1&&console.warn(`Unsupported avar table version ${d}.${p}`),h.skip("uShort",1);let b=h.parseUShort();H.argument(b===l.axes.length,"avar axis count must correspond to fvar axis count");let x=[];for(let A=0;A<b;A++){let E=[],C=h.parseUShort();for(let P=0;P<C;P++){let R=h.parseF2Dot14(),D=h.parseF2Dot14();E.push({fromCoordinate:R,toCoordinate:D})}x.push({axisValueMaps:E})}return{version:[d,p],axisSegmentMaps:x}}var Pl={make:df,parse:ff};function pf(n,i,l,h){let d=new it.Parser(n,i),p=d.parseTupleVariationStore(d.relativeOffset,l.axes.length,"cvar",h),b=d.parseUShort(),x=d.parseUShort();return b!==1&&console.warn(`Unsupported cvar table version ${b}.${x}`),{version:[b,x],...p}}function gf(){console.warn("Writing of cvar tables is not yet supported.")}var Ol={make:gf,parse:pf};function mf(n,i,l,h){let d=new it.Parser(n,i),p=d.parseUShort(),b=d.parseUShort();p!==1&&console.warn(`Unsupported gvar table version ${p}.${b}`);let x=d.parseUShort();x!==l.axes.length&&console.warn(`axisCount ${x} in gvar table does not match the number of axes ${l.axes.length} in the fvar table!`);let A=d.parseUShort(),E=d.parsePointer32(function(){return this.parseTupleRecords(A,x)}),C=d.parseTupleVariationStoreList(x,"gvar",h);return{version:[p,b],sharedTuples:E,glyphVariations:C}}function yf(){console.warn("Writing of gvar tables is not yet supported.")}var Ll={make:yf,parse:mf};function bf(n,i){let l={},h=new it.Parser(n,i);l.version=h.parseUShort(),H.argument(l.version<=1,"Unsupported gasp table version."),l.numRanges=h.parseUShort(),l.gaspRanges=[];for(let d=0;d<l.numRanges;d++)l.gaspRanges[d]={rangeMaxPPEM:h.parseUShort(),rangeGaspBehavior:h.parseUShort()};return l}function vf(n){let i=new Q.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:n.numRanges}]);for(let l in n.gaspRanges)i.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:n.gaspRanges[l].rangeMaxPPEM}),i.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:n.gaspRanges[l].rangeGaspBehavior});return i}var Ml={parse:bf,make:vf};function xf(n,i){let l=new Map,h=n.buffer,d=new U(n,i);if(d.parseUShort()!==0)return l;d.relativeOffset=d.parseOffset32();let b=n.byteOffset+i+d.relativeOffset,x=d.parseUShort(),A=new Map;for(let E=0;E<x;E++){let C=d.parseUShort(),P=d.parseUShort(),R=b+d.parseOffset32(),D=d.parseULong(),O=A.get(R);O===void 0&&(O=new Uint8Array(h,R,D),A.set(R,O));for(let _=C;_<=P;_++)l.set(_,O)}return l}function Sf(n){let i=Array.from(n.keys()).sort(),l=[],h=[],d=new Map,p=0,b={endGlyphID:null};for(let R=0,D=i.length;R<D;R++){let O=i[R],_=n.get(O),V=d.get(_);V===void 0&&(V=p,h.push(_),d.set(_,V),p+=_.byteLength),O-1===b.endGlyphID&&V===b.svgDocOffset?b.endGlyphID=O:(b={startGlyphID:O,endGlyphID:O,svgDocOffset:V,svgDocLength:_.byteLength},l.push(b))}let x=l.length,A=h.length,E=2+x*12,C=new Array(4+x*4+A),P=0;C[P++]={name:"version",type:"USHORT",value:0},C[P++]={name:"svgDocumentListOffset",type:"ULONG",value:10},C[P++]={name:"reserved",type:"ULONG",value:0},C[P++]={name:"numEntries",type:"USHORT",value:x};for(let R=0;R<x;R++){let D="documentRecord_"+R,{startGlyphID:O,endGlyphID:_,svgDocOffset:V,svgDocLength:mt}=l[R];C[P++]={name:D+"_startGlyphID",type:"USHORT",value:O},C[P++]={name:D+"_endGlyphID",type:"USHORT",value:_},C[P++]={name:D+"_svgDocOffset",type:"ULONG",value:E+V},C[P++]={name:D+"_svgDocLength",type:"ULONG",value:mt}}for(let R=0;R<A;R++)C[P++]={name:"svgDoc_"+R,type:"LITERAL",value:h[R]};return new Q.Table("SVG ",C)}var Dl={make:Sf,parse:xf};function Fl(n){return Math.log(n)/Math.log(2)|0}function ki(n){for(;n.length%4!==0;)n.push(0);let i=0;for(let l=0;l<n.length;l+=4)i+=(n[l]<<24)+(n[l+1]<<16)+(n[l+2]<<8)+n[l+3];return i%=Math.pow(2,32),i}function _l(n,i,l,h){return new Q.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{name:"checkSum",type:"ULONG",value:i!==void 0?i:0},{name:"offset",type:"ULONG",value:l!==void 0?l:0},{name:"length",type:"ULONG",value:h!==void 0?h:0}])}function Nl(n){let i=new Q.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);i.tables=n,i.numTables=n.length;let l=Math.pow(2,Fl(i.numTables));i.searchRange=16*l,i.entrySelector=Fl(l),i.rangeShift=i.numTables*16-i.searchRange;let h=[],d=[],p=i.sizeOf()+_l().sizeOf()*i.numTables;for(;p%4!==0;)p+=1,d.push({name:"padding",type:"BYTE",value:0});for(let b=0;b<n.length;b+=1){let x=n[b];H.argument(x.tableName.length===4,"Table name"+x.tableName+" is invalid.");let A=x.sizeOf(),E=_l(x.tableName,ki(x.encode()),p,A);for(h.push({name:E.tag+" Table Record",type:"RECORD",value:E}),d.push({name:x.tableName+" table",type:"RECORD",value:x}),p+=A,H.argument(!isNaN(p),"Something went wrong calculating the offset.");p%4!==0;)p+=1,d.push({name:"padding",type:"BYTE",value:0})}return h.sort(function(b,x){return b.value.tag>x.value.tag?1:-1}),i.fields=i.fields.concat(h),i.fields=i.fields.concat(d),i}function Ul(n,i,l){for(let h=0;h<i.length;h+=1){let d=n.charToGlyphIndex(i[h]);if(d>0)return n.glyphs.get(d).getMetrics()}return l}function Af(n){let i=0;for(let l=0;l<n.length;l+=1)i+=n[l];return i/n.length}function Tf(n){let i=[],l=[],h=[],d=[],p=[],b=[],x=[],A,E=0,C=0,P=0,R=0,D=0;for(let jt=0;jt<n.glyphs.length;jt+=1){let me=n.glyphs.get(jt),Ie=me.unicode|0;if(isNaN(me.advanceWidth))throw new Error("Glyph "+me.name+" ("+jt+"): advanceWidth is not a number.");(A>Ie||A===void 0)&&Ie>0&&(A=Ie),E<Ie&&(E=Ie);let Be=wi.getUnicodeRange(Ie);if(Be<32)C|=1<<Be;else if(Be<64)P|=1<<Be-32;else if(Be<96)R|=1<<Be-64;else if(Be<123)D|=1<<Be-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(me.name===".notdef")continue;let qe=me.getMetrics();i.push(qe.xMin),l.push(qe.yMin),h.push(qe.xMax),d.push(qe.yMax),b.push(qe.leftSideBearing),x.push(qe.rightSideBearing),p.push(me.advanceWidth)}let O={xMin:Math.min.apply(null,i),yMin:Math.min.apply(null,l),xMax:Math.max.apply(null,h),yMax:Math.max.apply(null,d),advanceWidthMax:Math.max.apply(null,p),advanceWidthAvg:Af(p),minLeftSideBearing:Math.min.apply(null,b),maxLeftSideBearing:Math.max.apply(null,b),minRightSideBearing:Math.min.apply(null,x)};O.ascender=n.ascender,O.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);let V=vl.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:O.xMin,yMin:O.yMin,xMax:O.xMax,yMax:O.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),mt=xl.make({ascender:O.ascender,descender:O.descender,advanceWidthMax:O.advanceWidthMax,minLeftSideBearing:O.minLeftSideBearing,minRightSideBearing:O.minRightSideBearing,xMaxExtent:O.maxLeftSideBearing+(O.xMax-O.xMin),numberOfHMetrics:n.glyphs.length}),ht=Tl.make(n.glyphs.length),At=wi.make(Object.assign({xAvgCharWidth:Math.round(O.advanceWidthAvg),usFirstCharIndex:A,usLastCharIndex:E,ulUnicodeRange1:C,ulUnicodeRange2:P,ulUnicodeRange3:R,ulUnicodeRange4:D,sTypoAscender:O.ascender,sTypoDescender:O.descender,sTypoLineGap:0,usWinAscent:O.yMax,usWinDescent:Math.abs(O.yMin),ulCodePageRange1:1,sxHeight:Ul(n,"xyvw",{yMax:Math.round(O.ascender/2)}).yMax,sCapHeight:Ul(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",O).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),kt=Sl.make(n.glyphs),_t=tl.make(n.glyphs),Bt=n.getEnglishName("fontFamily"),Gt=n.getEnglishName("fontSubfamily"),Jt=Bt+" "+Gt,Ne=n.getEnglishName("postScriptName");Ne||(Ne=Bt.replace(/\s/g,"")+"-"+Gt);let It={};for(let jt in n.names)It[jt]=n.names[jt];It.unicode=It.unicode||{},It.macintosh=It.macintosh||{},It.windows=It.windows||{};let Ae=n.names.unicode||{},he=n.names.macintosh||{},yt=n.names.windows||{};for(let jt in It){if(It[jt]=It[jt]||{},!It[jt].uniqueID){let me=n.getEnglishName("manufacturer")||"";It[jt].uniqueID={en:`${me}: ${Jt}`}}It[jt].postScriptName||(It[jt].postScriptName={en:Ne})}It.unicode.preferredFamily||(It.unicode.preferredFamily=Ae.fontFamily||he.fontFamily||yt.fontFamily),It.macintosh.preferredFamily||(It.macintosh.preferredFamily=he.fontFamily||Ae.fontFamily||yt.fontFamily),It.windows.preferredFamily||(It.windows.preferredFamily=yt.fontFamily||Ae.fontFamily||he.fontFamily),It.unicode.preferredSubfamily||(It.unicode.preferredSubfamily=Ae.fontSubfamily||he.fontSubfamily||yt.fontSubfamily),It.macintosh.preferredSubfamily||(It.macintosh.preferredSubfamily=he.fontSubfamily||Ae.fontSubfamily||yt.fontSubfamily),It.windows.preferredSubfamily||(It.windows.preferredSubfamily=yt.fontSubfamily||Ae.fontSubfamily||he.fontSubfamily);let ot=[],ut=qa.make(It,ot),ie=ot.length>0?Al.make(ot):void 0,hn=Cl.make(n),rr=Ci.make(n.glyphs,{version:n.getEnglishName("version"),fullName:Jt,familyName:Bt,weightName:Gt,postScriptName:Ne,unitsPerEm:n.unitsPerEm,fontBBox:[0,O.yMin,O.ascender,O.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),An=n.metas&&Object.keys(n.metas).length>0?wl.make(n.metas):void 0,Ue=[V,mt,ht,At,ut,_t,hn,rr,kt];ie&&Ue.push(ie);let de={gsub:El,cpal:ol,colr:kl,stat:Rl,avar:Pl,cvar:Ol,fvar:Il,gvar:Ll,gasp:Ml,svg:Dl},ke={avar:[n.tables.fvar],fvar:[n.names]};for(let jt in de){let me=n.tables[jt];if(me){let Ie=de[jt].make.call(n,me,...ke[jt]||[]);Ie&&Ue.push(Ie)}}An&&Ue.push(An);let oe=Nl(Ue),Te=oe.encode(),fe=ki(Te),pe=oe.fields,Zt=!1;for(let jt=0;jt<pe.length;jt+=1)if(pe[jt].name==="head table"){pe[jt].value.checkSumAdjustment=2981146554-fe,Zt=!0;break}if(!Zt)throw new Error("Could not find head table with checkSum to adjust.");return oe}var Cf={make:Nl,fontToTable:Tf,computeCheckSum:ki};function Ii(n,i){let l=0,h=n.length-1;for(;l<=h;){let d=l+h>>>1,p=n[d].tag;if(p===i)return d;p<i?l=d+1:h=d-1}return-l-1}function Bl(n,i){let l=0,h=n.length-1;for(;l<=h;){let d=l+h>>>1,p=n[d];if(p===i)return d;p<i?l=d+1:h=d-1}return-l-1}function Gl(n,i){let l,h=0,d=n.length-1;for(;h<=d;){let p=h+d>>>1;l=n[p];let b=l.start;if(b===i)return l;b<i?h=p+1:d=p-1}if(h>0)return l=n[h-1],i>l.end?0:l}function Hl(n,i){this.font=n,this.tableName=i}Hl.prototype={searchTag:Ii,binSearch:Bl,getTable:function(n){let i=this.font.tables[this.tableName];return!i&&n&&(i=this.font.tables[this.tableName]=this.createDefaultTable()),i},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(i){return i.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let i=!1;for(let l=0;l<n.scripts.length;l++){let h=n.scripts[l].tag;if(h==="DFLT")return h;h==="latn"&&(i=!0)}if(i)return"latn"},getScriptTable:function(n,i){let l=this.getTable(i);if(l){n=n||"DFLT";let h=l.scripts,d=Ii(l.scripts,n);if(d>=0)return h[d].script;if(i){let p={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return h.splice(-1-d,0,p),p.script}}},getLangSysTable:function(n,i,l){let h=this.getScriptTable(n,l);if(h){if(!i||i==="dflt"||i==="DFLT")return h.defaultLangSys;let d=Ii(h.langSysRecords,i);if(d>=0)return h.langSysRecords[d].langSys;if(l){let p={tag:i,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return h.langSysRecords.splice(-1-d,0,p),p.langSys}}},getFeatureTable:function(n,i,l,h){let d=this.getLangSysTable(n,i,h);if(d){let p,b=d.featureIndexes,x=this.font.tables[this.tableName].features;for(let A=0;A<b.length;A++)if(p=x[b[A]],p.tag===l)return p.feature;if(h){let A=x.length;return H.assert(A===0||l>=x[A-1].tag,"Features must be added in alphabetical order."),p={tag:l,feature:{params:0,lookupListIndexes:[]}},x.push(p),b.push(A),p.feature}}},getLookupTables:function(n,i,l,h,d){let p=this.getFeatureTable(n,i,l,d),b=[];if(p){let x,A=p.lookupListIndexes,E=this.font.tables[this.tableName].lookups;for(let C=0;C<A.length;C++)x=E[A[C]],x.lookupType===h&&b.push(x);if(b.length===0&&d){x={lookupType:h,lookupFlag:0,subtables:[],markFilteringSet:void 0};let C=E.length;return E.push(x),A.push(C),[x]}}return b},getGlyphClass:function(n,i){switch(n.format){case 1:return n.startGlyph<=i&&i<n.startGlyph+n.classes.length?n.classes[i-n.startGlyph]:0;case 2:{let l=Gl(n.ranges,i);return l?l.classId:0}}},getCoverageIndex:function(n,i){switch(n.format){case 1:{let l=Bl(n.glyphs,i);return l>=0?l:-1}case 2:{let l=Gl(n.ranges,i);return l?l.index+i-l.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{let i=[],l=n.ranges;for(let h=0;h<l.length;h++){let d=l[h],p=d.start,b=d.end;for(let x=p;x<=b;x++)i.push(x)}return i}}};var Ks=Hl;function es(n){Ks.call(this,n,"gpos")}es.prototype=Ks.prototype,es.prototype.init=function(){let n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)},es.prototype.getKerningValue=function(n,i,l){for(let h=0;h<n.length;h++){let d=n[h].subtables;for(let p=0;p<d.length;p++){let b=d[p],x=this.getCoverageIndex(b.coverage,i);if(!(x<0))switch(b.posFormat){case 1:{let A=b.pairSets[x];for(let E=0;E<A.length;E++){let C=A[E];if(C.secondGlyph===l)return C.value1&&C.value1.xAdvance||0}break}case 2:{let A=this.getGlyphClass(b.classDef1,i),E=this.getGlyphClass(b.classDef2,l),C=b.classRecords[A][E];return C.value1&&C.value1.xAdvance||0}}}}return 0},es.prototype.getKerningTables=function(n,i){if(this.font.tables.gpos)return this.getLookupTables(n,i,"kern",2)};var Ef=es;function wf(n,i){let l=n.length;if(l!==i.length)return!1;for(let h=0;h<l;h++)if(n[h]!==i[h])return!1;return!0}function kf(n,i,l){let h=0,d=n.length-1,p=null;for(;h<=d;){let b=Math.floor((h+d)/2),x=n[b],A=x[i];if(A<l)h=b+1;else if(A>l)d=b-1;else{p=x;break}}return p}function If(n,i,l){let h=0,d=n.length-1;for(;h<=d;){let p=Math.floor((h+d)/2),b=n[p];if(b[i]<l)h=p+1;else if(b[i]>l)d=p-1;else return p}return-1}function Rf(n,i,l){let h=0,d=n.length,p=(b,x)=>b[i]-x[i];for(;h<d;){let b=h+d>>>1;p(n[b],l)<0?h=b+1:d=b}return n.splice(h,0,l),h}function jl(n){return n[0]===31&&n[1]===139&&n[2]===8}function Pf(n){let i=new DataView(n.buffer,n.byteOffset,n.byteLength),l=10,h=n.byteLength-8,d=i.getInt8(3);if(d&4&&(l+=2+i.getUint16(l,!0)),d&8)for(;l<h&&n[l++]!==0;);if(d&16)for(;l<h&&n[l++]!==0;);if(d&2&&(l+=2),l>=h)throw new Error("Can't find compressed blocks");let p=i.getUint32(i.byteLength-4,!0);return St(n.subarray(l,h),new Uint8Array(p))}function Vl(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Of(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function xe(n){Ks.call(this,n,"gsub")}function Ri(n,i,l){let h=n.subtables;for(let d=0;d<h.length;d++){let p=h[d];if(p.substFormat===i)return p}if(l)return h.push(l),l}xe.prototype=Ks.prototype,xe.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},xe.prototype.getSingle=function(n,i,l){let h=[],d=this.getLookupTables(i,l,n,1);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],E=this.expandCoverage(A.coverage),C;if(A.substFormat===1){let P=A.deltaGlyphId;for(C=0;C<E.length;C++){let R=E[C];h.push({sub:R,by:R+P})}}else{let P=A.substitute;for(C=0;C<E.length;C++)h.push({sub:E[C],by:P[C]})}}}return h},xe.prototype.getMultiple=function(n,i,l){let h=[],d=this.getLookupTables(i,l,n,2);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],E=this.expandCoverage(A.coverage),C;for(C=0;C<E.length;C++){let P=E[C],R=A.sequences[C];h.push({sub:P,by:R})}}}return h},xe.prototype.getAlternates=function(n,i,l){let h=[],d=this.getLookupTables(i,l,n,3);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],E=this.expandCoverage(A.coverage),C=A.alternateSets;for(let P=0;P<E.length;P++)h.push({sub:E[P],by:C[P]})}}return h},xe.prototype.getLigatures=function(n,i,l){let h=[],d=this.getLookupTables(i,l,n,4);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],E=this.expandCoverage(A.coverage),C=A.ligatureSets;for(let P=0;P<E.length;P++){let R=E[P],D=C[P];for(let O=0;O<D.length;O++){let _=D[O];h.push({sub:[R].concat(_.components),by:_.ligGlyph})}}}}return h},xe.prototype.addSingle=function(n,i,l,h){let d=this.getLookupTables(l,h,n,1,!0)[0],p=Ri(d,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});H.assert(p.coverage.format===1,"Single: unable to modify coverage table format "+p.coverage.format);let b=i.sub,x=this.binSearch(p.coverage.glyphs,b);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,b),p.substitute.splice(x,0,0)),p.substitute[x]=i.by},xe.prototype.addMultiple=function(n,i,l,h){H.assert(i.by instanceof Array&&i.by.length>1,'Multiple: "by" must be an array of two or more ids');let d=this.getLookupTables(l,h,n,2,!0)[0],p=Ri(d,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});H.assert(p.coverage.format===1,"Multiple: unable to modify coverage table format "+p.coverage.format);let b=i.sub,x=this.binSearch(p.coverage.glyphs,b);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,b),p.sequences.splice(x,0,0)),p.sequences[x]=i.by},xe.prototype.addAlternate=function(n,i,l,h){let d=this.getLookupTables(l,h,n,3,!0)[0],p=Ri(d,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});H.assert(p.coverage.format===1,"Alternate: unable to modify coverage table format "+p.coverage.format);let b=i.sub,x=this.binSearch(p.coverage.glyphs,b);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,b),p.alternateSets.splice(x,0,0)),p.alternateSets[x]=i.by},xe.prototype.addLigature=function(n,i,l,h){let d=this.getLookupTables(l,h,n,4,!0)[0],p=d.subtables[0];p||(p={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},d.subtables[0]=p),H.assert(p.coverage.format===1,"Ligature: unable to modify coverage table format "+p.coverage.format);let b=i.sub[0],x=i.sub.slice(1),A={ligGlyph:i.by,components:x},E=this.binSearch(p.coverage.glyphs,b);if(E>=0){let C=p.ligatureSets[E];for(let P=0;P<C.length;P++)if(wf(C[P].components,x))return;C.push(A)}else E=-1-E,p.coverage.glyphs.splice(E,0,b),p.ligatureSets.splice(E,0,[A])},xe.prototype.getFeature=function(n,i,l){if(/ss\d\d/.test(n))return this.getSingle(n,i,l);switch(n){case"aalt":case"salt":return this.getSingle(n,i,l).concat(this.getAlternates(n,i,l));case"dlig":case"liga":case"rlig":return this.getLigatures(n,i,l);case"ccmp":return this.getMultiple(n,i,l).concat(this.getLigatures(n,i,l));case"stch":return this.getMultiple(n,i,l)}},xe.prototype.add=function(n,i,l,h){if(/ss\d\d/.test(n))return this.addSingle(n,i,l,h);switch(n){case"aalt":case"salt":return typeof i.by=="number"?this.addSingle(n,i,l,h):this.addAlternate(n,i,l,h);case"dlig":case"liga":case"rlig":return this.addLigature(n,i,l,h);case"ccmp":return i.by instanceof Array?this.addMultiple(n,i,l,h):this.addLigature(n,i,l,h)}};var Lf=xe,$l=class{constructor(n){this.defaultValue=255,this.font=n}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(n){let i=[],l=this.cpal();if(!l)return i;for(let h=0;h<l.colorRecordIndices.length;h++){let d=l.colorRecordIndices[h],p=[];for(let b=d;b<d+l.numPaletteEntries;b++)p.push(Bn(l.colorRecords[b],n||"hexa"));i.push(p)}return i}toCPALcolor(n){return Array.isArray(n)?n.map(i=>Ws(i,"raw")):Ws(n,"raw")}fillPalette(n,i=[],l=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(l).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(i)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;let i=this.cpal(),l=i.numPaletteEntries+n,h=this.getAll().map(d=>this.fillPalette(d,[],l));i.numPaletteEntries=l,i.colorRecords=this.toCPALcolor(h.flat()),this.updateIndices()}get(n,i="hexa"){return this.getAll(i)[n]||null}getColor(n,i=0,l="hexa"){return bi(this.font,n,i,l)}setColor(n,i,l=0){n=parseInt(n),l=parseInt(l);let h=this.getAll("raw"),d=h[l];if(!d)throw Error(`paletteIndex ${l} out of range`);let p=this.cpal(),b=p.numPaletteEntries;Array.isArray(i)||(i=[i]),i.length+n>b&&(this.extend(i.length+n-b),h=this.getAll("raw"),d=h[l]);for(let x=0;x<i.length;x++)d[x+n]=this.toCPALcolor(i[x]);p.colorRecords=h.flat(),this.updateIndices()}add(n){if(this.ensureCPAL(n))return;let i=this.cpal(),l=i.numPaletteEntries;n&&n.length?(n=this.toCPALcolor(n),n.length>l?this.extend(n.length-l):n.length<l&&(n=this.fillPalette(n)),i.colorRecordIndices.push(i.colorRecords.length),i.colorRecords.push(...n)):(i.colorRecordIndices.push(i.colorRecords.length),i.colorRecords.push(...Array(l).fill(this.defaultValue)))}delete(n){let i=this.getAll("raw");delete i[n];let l=this.cpal();l.colorRecordIndices.pop(),l.colorRecords=i.flat()}deleteColor(n,i){if(n===i)throw Error("replacementIndex cannot be the same as colorIndex");let l=this.cpal(),h=this.getAll("raw"),d=[];if(i>l.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${l.numPaletteEntries-1}, replacementIndex: ${i})`);for(let x=0;x<h.length;x++){let E=h[x].filter((C,P)=>P!==n);d.push(E)}let p=this.font.tables.colr;if(p){let x=p.layerRecords;for(let A=0;A<x.length;A++){let E=x[A].paletteIndex;if(E>n)x[A].paletteIndex-=1;else if(E===n){let C=0;for(let P=0;P<h.length;P++)if(i>n&&i<=n+h[P].length){C++;break}x[A].paletteIndex=i-C}}this.font.tables.colr={...p,layerRecords:x}}let b=d.flat();for(let x=0;x<h.length;x++)l.colorRecordIndices[x]-=x;l.numPaletteEntries=Math.max(0,l.numPaletteEntries-1),l.colorRecords=this.toCPALcolor(b)}ensureCPAL(n){return this.cpal()?!1:(!n||!n.length?n=[this.defaultValue]:n=this.toCPALcolor(n),this.font.tables.cpal={version:0,numPaletteEntries:n.length,colorRecords:n,colorRecordIndices:[0]},!0)}updateIndices(){let n=this.cpal(),i=Math.ceil(n.colorRecords.length/n.numPaletteEntries);n.colorRecordIndices=[];for(let l=0;l<i;l++)n.colorRecordIndices.push(l*n.numPaletteEntries)}},Mf=class{constructor(n){this.font=n}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(n){let i=this.font,l=[],h=i.tables.colr,d=i.tables.cpal;if(!h||!d)return l;let p=kf(h.baseGlyphRecords,"glyphID",n);if(!p)return l;let b=p.firstLayerIndex,x=p.numLayers;for(let A=0;A<x;A++){let E=h.layerRecords[b+A];l.push({glyph:i.glyphs.get(E.glyphID),paletteIndex:E.paletteIndex})}return l}add(n,i,l){let h=this.get(n);i=Array.isArray(i)?i:[i],l===void 0||l===1/0||l>h.length?l=h.length:l<0&&(l=h.length+1+l%(h.length+1),l>=h.length+1&&(l-=h.length+1));let d=[];for(let p=0;p<l;p++){let b=Number.isInteger(h[p].glyph)?h[p].glyph:h[p].glyph.index;d.push({glyphID:b,paletteIndex:h[p].paletteIndex})}for(let p of i){let b=Number.isInteger(p.glyph)?p.glyph:p.glyph.index;d.push({glyphID:b,paletteIndex:p.paletteIndex})}for(let p=l;p<h.length;p++){let b=Number.isInteger(h[p].glyph)?h[p].glyph:h[p].glyph.index;d.push({glyphID:b,paletteIndex:h[p].paletteIndex})}this.updateColrTable(n,d)}setPaletteIndex(n,i,l){let h=this.get(n);h[i]?(h=h.map((d,p)=>({glyphID:d.glyph.index,paletteIndex:p===i?l:d.paletteIndex})),this.updateColrTable(n,h)):console.error("Invalid layer index")}remove(n,i,l=i){let h=this.get(n);h=h.map(d=>({glyphID:d.glyph.index,paletteIndex:d.paletteIndex})),h.splice(i,l-i+1),this.updateColrTable(n,h)}updateColrTable(n,i){this.ensureCOLR();let h=this.font.tables.colr,d=If(h.baseGlyphRecords,"glyphID",n);if(d===-1){let C={glyphID:n,firstLayerIndex:h.layerRecords.length,numLayers:0};d=Rf(h.baseGlyphRecords,"glyphID",C)}let b=h.baseGlyphRecords[d],x=b.numLayers,A=i.length,E=A-x;if(E>0){let C=i.slice(x).map(P=>({glyphID:P.glyphID,paletteIndex:P.paletteIndex}));h.layerRecords.splice(b.firstLayerIndex+x,0,...C)}else E<0&&h.layerRecords.splice(b.firstLayerIndex+A,-E);for(let C=0;C<Math.min(x,A);C++)h.layerRecords[b.firstLayerIndex+C]={glyphID:i[C].glyphID,paletteIndex:i[C].paletteIndex};if(b.numLayers=A,E!==0)for(let C=0;C<h.baseGlyphRecords.length;C++){let P=h.baseGlyphRecords[C];C===d||P.firstLayerIndex<b.firstLayerIndex||(h.baseGlyphRecords[C].firstLayerIndex+=E)}}},Df=class{constructor(n){this.font=n,this.cache=new WeakMap}get(n){let i=this.getOrCreateSvgImageCacheEntry(n);return i&&i.image}getAsync(n){let i=this.getOrCreateSvgImageCacheEntry(n);return i&&i.promise}getOrCreateSvgImageCacheEntry(n){let i=this.font.tables.svg;if(i===void 0)return;let l=i.get(n);if(l===void 0)return;let h=this.cache.get(l);h===void 0&&(h=Ff(l),this.cache.set(l,h));let d=h.images.get(n);return d===void 0&&(d=_f(this.font,h.template,n),d.promise.then(p=>{if(d.image=p,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(b){console.error("font.onGlyphUpdated",n,b)}}),h.images.set(n,d)),d}};function Ff(n){return{template:Nf(n).then(Gf),images:new Map}}function _f(n,i,l){return{promise:i.then(h=>{let d;typeof h=="string"?d=h:(h[4]=l,d=h.join(""));let p=Hf(d,n.unitsPerEm);return p.image.decode().then(()=>p)}),image:void 0}}var Nf=typeof DecompressionStream=="function"?Bf:Uf;function Uf(n){try{return Promise.resolve(new TextDecoder().decode(jl(n)?Pf(n):n))}catch(i){return Promise.reject(i)}}function Bf(n){if(jl(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(i){return Promise.reject(i)}}function Gf(n){let i=n.indexOf("<svg"),l=n.indexOf(">",i+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(i,l)))return n;let h=n.lastIndexOf("</svg>");return[n.substring(0,l),"<defs>",n.substring(l,h),'</defs><use href="#glyph',"",'"/>',n.substring(h)]}function Hf(n,i){let h=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,d=h.viewBox.baseVal,p=h.width.baseVal,b=h.height.baseVal,x=1,A=1;d.width>0&&d.height>0&&(p.unitType===1?(x=p.valueInSpecifiedUnits/d.width,A=b.unitType===1?b.valueInSpecifiedUnits/d.height:x):b.unitType===1?(A=b.valueInSpecifiedUnits/d.height,x=A):i&&(x=i/d.width,A=i/d.height));let E=document.createElement("div");E.style.position="fixed",E.style.visibility="hidden",E.appendChild(h),document.body.appendChild(E);let C=h.getBBox();document.body.removeChild(E);let P=(C.x-d.x)*x,R=(d.y-C.y)*A,D=C.width*x,O=C.height*A;h.setAttribute("viewBox",[C.x,C.y,C.width,C.height].join(" ")),x!==1&&h.setAttribute("width",D),A!==1&&h.setAttribute("height",O);let _=new Image(D,O);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(h.outerHTML),{leftSideBearing:P,baseline:R,image:_}}var Pi=new WeakMap;function zl(n,i,l,h,d){let p;return(i&h)>0?(p=n.parseByte(),(i&d)===0&&(p=-p),p=l+p):(i&d)>0?p=l:p=l+n.parseShort(),p}function Wl(n,i,l){let h=new it.Parser(i,l);n._numberOfContours=h.parseShort(),n._xMin=h.parseShort(),n._yMin=h.parseShort(),n._xMax=h.parseShort(),n._yMax=h.parseShort();let d,p;if(n._numberOfContours>0){let b=n.endPointIndices=[];for(let A=0;A<n._numberOfContours;A+=1)b.push(h.parseUShort());n.instructionLength=h.parseUShort(),n.instructions=[];for(let A=0;A<n.instructionLength;A+=1)n.instructions.push(h.parseByte());let x=b[b.length-1]+1;d=[];for(let A=0;A<x;A+=1)if(p=h.parseByte(),d.push(p),(p&8)>0){let E=h.parseByte();for(let C=0;C<E;C+=1)d.push(p),A+=1}if(H.argument(d.length===x,"Bad flags."),b.length>0){let A=[],E;if(x>0){for(let R=0;R<x;R+=1)p=d[R],E={},E.onCurve=!!(p&1),E.lastPointOfContour=b.indexOf(R)>=0,A.push(E);let C=0;for(let R=0;R<x;R+=1)p=d[R],E=A[R],E.x=zl(h,p,C,2,16),C=E.x;let P=0;for(let R=0;R<x;R+=1)p=d[R],E=A[R],E.y=zl(h,p,P,4,32),P=E.y}n.points=A}else n.points=[]}else if(n._numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];let b=!0;for(;b;){d=h.parseUShort();let x={glyphIndex:h.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(d&1)>0?(d&2)>0?(x.dx=h.parseShort(),x.dy=h.parseShort()):x.matchedPoints=[h.parseUShort(),h.parseUShort()]:(d&2)>0?(x.dx=h.parseChar(),x.dy=h.parseChar()):x.matchedPoints=[h.parseByte(),h.parseByte()],(d&8)>0?x.xScale=x.yScale=h.parseF2Dot14():(d&64)>0?(x.xScale=h.parseF2Dot14(),x.yScale=h.parseF2Dot14()):(d&128)>0&&(x.xScale=h.parseF2Dot14(),x.scale01=h.parseF2Dot14(),x.scale10=h.parseF2Dot14(),x.yScale=h.parseF2Dot14()),n.components.push(x),b=!!(d&32)}if(d&256){n.instructionLength=h.parseUShort(),n.instructions=[];for(let x=0;x<n.instructionLength;x+=1)n.instructions.push(h.parseByte())}}}function Zs(n,i){let l=[];for(let h=0;h<n.length;h+=1){let d=n[h],p={x:i.xScale*d.x+i.scale10*d.y+i.dx,y:i.scale01*d.x+i.yScale*d.y+i.dy,onCurve:d.onCurve,lastPointOfContour:d.lastPointOfContour};l.push(p)}return l}function jf(n){let i=[],l=[];for(let h=0;h<n.length;h+=1){let d=n[h];l.push(d),d.lastPointOfContour&&(i.push(l),l=[])}return H.argument(l.length===0,"There are still points left in the current contour."),i}function Oi(n){let i=new st;if(!n)return i;let l=jf(n);for(let h=0;h<l.length;++h){let d=l[h],p=d[d.length-1],b=d[0];if(p.onCurve)i.moveTo(p.x,p.y);else if(b.onCurve)i.moveTo(b.x,b.y);else{let x={x:(p.x+b.x)*.5,y:(p.y+b.y)*.5};i.moveTo(x.x,x.y)}for(let x=0;x<d.length;++x)if(p=b,b=d[(x+1)%d.length],p.onCurve)i.lineTo(p.x,p.y);else{let A=b;b.onCurve||(A={x:(p.x+b.x)*.5,y:(p.y+b.y)*.5}),i.quadraticCurveTo(p.x,p.y,A.x,A.y)}i.closePath()}return i}function Xl(n,i){if(i.isComposite){Pi.has(n)||Pi.set(n,new Set);let l=Pi.get(n);l.add(i.index);try{for(let h=0;h<i.components.length;h+=1){let d=i.components[h];if(l.has(d.glyphIndex))continue;let p=n.get(d.glyphIndex);if(p.getPath(),p.points){let b;if(d.matchedPoints===void 0)b=Zs(p.points,d);else{if(d.matchedPoints[0]>i.points.length-1||d.matchedPoints[1]>p.points.length-1)throw Error("Matched points out of range in "+i.name);let x=i.points[d.matchedPoints[0]],A=p.points[d.matchedPoints[1]],E={xScale:d.xScale,scale01:d.scale01,scale10:d.scale10,yScale:d.yScale,dx:0,dy:0};A=Zs([A],E)[0],E.dx=x.x-A.x,E.dy=x.y-A.y,b=Zs(p.points,E)}i.points=i.points.concat(b)}}}finally{l.delete(i.index)}}return Oi(i.points)}function Vf(n,i,l,h){let d=new Ve.GlyphSet(h);for(let p=0;p<l.length-1;p+=1){let b=l[p],x=l[p+1];b!==x?d.push(p,Ve.ttfGlyphLoader(h,p,Wl,n,i+b,Xl)):d.push(p,Ve.glyphLoader(h,p))}return d}function $f(n,i,l,h){let d=new Ve.GlyphSet(h);return h._push=function(p){let b=l[p],x=l[p+1];b!==x?d.push(p,Ve.ttfGlyphLoader(h,p,Wl,n,i+b,Xl)):d.push(p,Ve.glyphLoader(h,p))},d}function zf(n,i,l,h,d){return d.lowMemory?$f(n,i,l,h):Vf(n,i,l,h)}var Yl={getPath:Oi,parse:zf},Wf=class{constructor(n){this.font=n}normalizeCoordTags(n){for(let i in n)if(i.length<4){let l=i.padEnd(4," ");n[l]===void 0&&(n[l]=n[i]),delete n[i]}}getNormalizedCoords(n){n||(n=this.font.variation.get());let i=[];this.normalizeCoordTags(n);for(let l=0;l<this.fvar().axes.length;l++){let h=this.fvar().axes[l],d=n[h.tag];d===void 0&&(d=h.defaultValue),d<h.defaultValue?i.push((d-h.defaultValue+Number.EPSILON)/(h.defaultValue-h.minValue+Number.EPSILON)):i.push((d-h.defaultValue+Number.EPSILON)/(h.maxValue-h.defaultValue+Number.EPSILON))}if(this.avar())for(let l=0;l<this.avar().axisSegmentMaps.length;l++){let h=this.avar().axisSegmentMaps[l];for(let d=0;d<h.axisValueMaps.length;d++){let p=h.axisValueMaps[d];if(d>=1&&i[l]<p.fromCoordinate){let b=h.axisValueMaps[d-1];i[l]=((i[l]-b.fromCoordinate)*(p.toCoordinate-b.toCoordinate)+Number.EPSILON)/(p.fromCoordinate-b.fromCoordinate+Number.EPSILON)+b.toCoordinate;break}}}return i}interpolatePoints(n,i,l){if(n.length===0)return;let h=0;for(;h<n.length;){let d=h,p=h,b=n[p];for(;!b.lastPointOfContour;)b=n[++p];for(;h<=p&&!l[h];)h++;if(h>p)continue;let x=h,A=h;for(h++;h<=p;)l[h]&&(this.deltaInterpolate(A+1,h-1,A,h,i,n),A=h),h++;A===x?this.deltaShift(d,p,A,i,n):(this.deltaInterpolate(A+1,p,A,x,i,n),x>0&&this.deltaInterpolate(d,x-1,A,x,i,n)),h=p+1}}deltaInterpolate(n,i,l,h,d,p){if(n>i)return;let b=["x","y"];for(let A=0;A<b.length;A++){let E=b[A];if(d[l][E]>d[h][E]){var x=l;l=h,h=x}let C=d[l][E],P=d[h][E],R=p[l][E],D=p[h][E];if(C!==P||R===D){let O=C===P?0:(D-R)/(P-C);for(let _=n;_<=i;_++){let V=d[_][E];V<=C?V+=R-C:V>=P?V+=D-P:V=R+(V-C)*O,p[_][E]=V}}}}deltaShift(n,i,l,h,d){let p=d[l].x-h[l].x,b=d[l].y-h[l].y;if(!(p===0&&b===0))for(let x=n;x<=i;x++)x!==l&&(d[x].x+=p,d[x].y+=b)}transformComponents(n,i,l,h,d,p){let b=0;for(let x=0;x<n.components.length;x++){let A=n.components[x],E=this.font.glyphs.get(A.glyphIndex),C=Of(A),P=h.indexOf(x);P>-1&&(C.dx+=Math.round(d.deltas[P]*p),C.dy+=Math.round(d.deltasY[P]*p));let R=Zs(this.getTransform(E,l).points,C);i.splice(b,R.length,...R),b+=E.points.length}}applyTupleVariationStore(n,i,l,h="gvar",d={}){l||(l=this.font.variation.get());let p=this.getNormalizedCoords(l),{headers:b,sharedPoints:x}=n,A=this.fvar().axes.length,E;h==="gvar"?E=i.map(Vl):h==="cvar"&&(E=[...i]);for(let C=0;C<b.length;C++){let P=b[C],R=1;for(let O=0;O<A;O++){let _=[0];switch(h){case"gvar":_=P.peakTuple?P.peakTuple:this.gvar().sharedTuples[P.sharedTupleRecordsIndex];break;case"cvar":_=P.peakTuple;break}if(_[O]!==0){if(p[O]===0){R=0;break}if(P.intermediateStartTuple)if(p[O]<P.intermediateStartTuple[O]||p[O]>P.intermediateEndTuple[O]){R=0;break}else p[O]<_[O]?R=R*(p[O]-P.intermediateStartTuple[O]+Number.EPSILON)/(_[O]-P.intermediateStartTuple[O]+Number.EPSILON):R=R*(P.intermediateEndTuple[O]-p[O]+Number.EPSILON)/(P.intermediateEndTuple[O]-_[O]+Number.EPSILON);else{if(p[O]<Math.min(0,_[O])||p[O]>Math.max(0,_[O])){R=0;break}R=(R*p[O]+Number.EPSILON)/(_[O]+Number.EPSILON)}}}if(R===0)continue;let D=P.privatePoints.length?P.privatePoints:x;if(h==="gvar"&&d.glyph&&d.glyph.isComposite)this.transformComponents(d.glyph,E,l,D,P,R);else if(D.length===0)for(let O=0;O<E.length;O++){let _=E[O];h==="gvar"?E[O]={x:Math.round(_.x+P.deltas[O]*R),y:Math.round(_.y+P.deltasY[O]*R),onCurve:_.onCurve,lastPointOfContour:_.lastPointOfContour}:h==="cvar"&&(E[O]=Math.round(_+P.deltas[O]*R))}else{let O;h==="gvar"?O=E.map(Vl):h==="cvar"&&(O=E);let _=Array(i.length).fill(!1);for(let V=0;V<D.length;V++){let mt=D[V];if(mt<i.length){let ht=O[mt];h==="gvar"?(_[mt]=!0,ht.x+=P.deltas[V]*R,ht.y+=P.deltasY[V]*R):h==="cvar"&&(E[mt]=Math.round(ht+P.deltas[V]*R))}}if(h==="gvar"){this.interpolatePoints(O,E,_);for(let V=0;V<i.length;V++){let mt=O[V].x-E[V].x,ht=O[V].y-E[V].y;E[V].x=Math.round(E[V].x+mt),E[V].y=Math.round(E[V].y+ht)}}}}return E}getTransform(n,i){Number.isInteger(n)&&(n=this.font.glyphs.get(n));let l=n.getBlendPath,h=!!(n.points&&n.points.length),d=n;if(l||h){if(i||(i=this.font.variation.get()),h){let p=this.gvar()&&this.gvar().glyphVariations[n.index];if(p){let b=n.points,x=this.applyTupleVariationStore(p,b,i,"gvar",{glyph:n});d=new Gn(Object.assign({},n,{points:x,path:Oi(x)}))}}else if(l){let p=n.getBlendPath(i);d=new Gn(Object.assign({},n,{path:p}))}}return this.font.tables.hvar&&(n._advanceWidth=typeof n._advanceWidth<"u"?n._advanceWidth:n.advanceWidth,n.advanceWidth=d.advanceWidth=Math.round(n._advanceWidth+this.getVariableAdjustment(d.index,"hvar","advanceWidth",i)),n._leftSideBearing=typeof n._leftSideBearing<"u"?n._leftSideBearing:n.leftSideBearing,n.leftSideBearing=d.leftSideBearing=Math.round(n._leftSideBearing+this.getVariableAdjustment(d.index,"hvar","lsb",i))),d}getCvarTransform(n){let i=this.font.tables.cvt,l=this.cvar();return!i||!i.length||!l||!l.headers.length?i:this.applyTupleVariationStore(l,i,n,"cvar")}getVariableAdjustment(n,i,l,h){h=h||this.font.variation.get();let d,p,b=this.font.tables[i];if(!b)throw Error(`trying to get variation adjustment from non-existent table "${b}"`);if(!b.itemVariationStore)throw Error(`trying to get variation adjustment from table "${b}" which does not have an itemVariationStore`);let x=b[l]&&b[l].map.length;if(x){let A=n;A>=x&&(A=x-1),{outerIndex:d,innerIndex:p}=b[l].map[A]}else d=0,p=n;return this.getDelta(b.itemVariationStore,d,p,h)}getDelta(n,i,l,h){if(i>=n.itemVariationSubtables.length)return 0;let d=n.itemVariationSubtables[i];if(l>=d.deltaSets.length)return 0;let p=d.deltaSets[l],b=this.getBlendVector(n,i,h),x=0;for(let A=0;A<d.regionIndexes.length;A++)x+=p[A]*b[A];return x}getBlendVector(n,i,l){l||(l=this.font.variation.get());let h=n.itemVariationSubtables[i],d=this.getNormalizedCoords(l),p=[];for(let b=0;b<h.regionIndexes.length;b++){let x=1,A=h.regionIndexes[b],E=n.variationRegions[A].regionAxes;for(let C=0;C<E.length;C++){let P=E[C],R;P.startCoord>P.peakCoord||P.peakCoord>P.endCoord||P.startCoord<0&&P.endCoord>0&&P.peakCoord!==0||P.peakCoord===0?R=1:d[C]<P.startCoord||d[C]>P.endCoord?R=0:d[C]===P.peakCoord?R=1:d[C]<P.peakCoord?R=(d[C]-P.startCoord+Number.EPSILON)/(P.peakCoord-P.startCoord+Number.EPSILON):R=(P.endCoord-d[C]+Number.EPSILON)/(P.endCoord-P.peakCoord+Number.EPSILON),x*=R}p[b]=x}return p}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Xf=class{constructor(n){this.font=n,this.process=new Wf(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let n=this.getDefaultInstanceIndex();n>-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,i)=>(n[i.tag]=i.defaultValue,n),{})}getDefaultInstanceIndex(){let n=this.getDefaultCoordinates(),i=this.getInstanceIndex(n);return i<0&&(i=this.fvar().instances.findIndex(l=>l.name&&l.name.en==="Regular")),i}getInstanceIndex(n){return this.fvar().instances.findIndex(i=>Object.keys(n).every(l=>i.coordinates[l]===n[l]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let i;if(Number.isInteger(n)){let l=this.getInstance(n);if(!l)throw Error(`Invalid instance index ${n}`);i={...l.coordinates}}else i=n,this.process.normalizeCoordTags(i);i=Object.assign({},this.font.defaultRenderOptions.variation,i),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:i})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Kl=1e6,Qs=64,Js=1e4,Zl,xn,Ql,Li;function Jl(n){this.font=n,this.getCommands=function(i){return Yl.getPath(i).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Yf(n){return n}function ql(n){return Math.sign(n)*Math.round(Math.abs(n))}function Kf(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function Zf(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function Qf(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function Jf(n){return Math.sign(n)*Math.floor(Math.abs(n))}var tc=function(n){let i=this.srPeriod,l=this.srPhase,h=this.srThreshold,d=1;return n<0&&(n=-n,d=-1),n+=h-l,n=Math.trunc(n/i)*i,n+=l,n<0?l*d:n*d},ze={x:1,y:0,axis:"x",distance:function(n,i,l,h){return(l?n.xo:n.x)-(h?i.xo:i.x)},interpolate:function(n,i,l,h){let d,p,b,x,A,E,C;if(!h||h===this){if(d=n.xo-i.xo,p=n.xo-l.xo,A=i.x-i.xo,E=l.x-l.xo,b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){n.x=n.xo+(A+E)/2;return}n.x=n.xo+(A*x+E*b)/C;return}if(d=h.distance(n,i,!0,!0),p=h.distance(n,l,!0,!0),A=h.distance(i,i,!1,!0),E=h.distance(l,l,!1,!0),b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){ze.setRelative(n,n,(A+E)/2,h,!0);return}ze.setRelative(n,n,(A*x+E*b)/C,h,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,i,l,h,d){if(!h||h===this){n.x=(d?i.xo:i.x)+l;return}let p=d?i.xo:i.x,b=d?i.yo:i.y,x=p+l*h.x,A=b+l*h.y;n.x=x+(n.y-A)/h.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},Qe={x:0,y:1,axis:"y",distance:function(n,i,l,h){return(l?n.yo:n.y)-(h?i.yo:i.y)},interpolate:function(n,i,l,h){let d,p,b,x,A,E,C;if(!h||h===this){if(d=n.yo-i.yo,p=n.yo-l.yo,A=i.y-i.yo,E=l.y-l.yo,b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){n.y=n.yo+(A+E)/2;return}n.y=n.yo+(A*x+E*b)/C;return}if(d=h.distance(n,i,!0,!0),p=h.distance(n,l,!0,!0),A=h.distance(i,i,!1,!0),E=h.distance(l,l,!1,!0),b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){Qe.setRelative(n,n,(A+E)/2,h,!0);return}Qe.setRelative(n,n,(A*x+E*b)/C,h,!0)},normalSlope:0,setRelative:function(n,i,l,h,d){if(!h||h===this){n.y=(d?i.yo:i.y)+l;return}let p=d?i.xo:i.x,b=d?i.yo:i.y,x=p+l*h.x,A=b+l*h.y;n.y=A+h.normalSlope*(n.x-x)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(ze),Object.freeze(Qe);function ns(n,i){this.x=n,this.y=i,this.axis=void 0,this.slope=i/n,this.normalSlope=-n/i,Object.freeze(this)}ns.prototype.distance=function(n,i,l,h){return this.x*ze.distance(n,i,l,h)+this.y*Qe.distance(n,i,l,h)},ns.prototype.interpolate=function(n,i,l,h){let d,p,b,x,A,E,C;if(b=h.distance(n,i,!0,!0),x=h.distance(n,l,!0,!0),d=h.distance(i,i,!1,!0),p=h.distance(l,l,!1,!0),A=Math.abs(b),E=Math.abs(x),C=A+E,C===0){this.setRelative(n,n,(d+p)/2,h,!0);return}this.setRelative(n,n,(d*E+p*A)/C,h,!0)},ns.prototype.setRelative=function(n,i,l,h,d){h=h||this;let p=d?i.xo:i.x,b=d?i.yo:i.y,x=p+l*h.x,A=b+l*h.y,E=h.normalSlope,C=this.slope,P=n.x,R=n.y;n.x=(C*P-E*x+A-R)/(C-E),n.y=C*(n.x-P)+R},ns.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function ss(n,i){let l=Math.sqrt(n*n+i*i);return n/=l,i/=l,n===1&&i===0?ze:n===0&&i===1?Qe:new ns(n,i)}function Je(n,i,l,h){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(i*64)/64,this.lastPointOfContour=l,this.onCurve=h,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Je.prototype.nextTouched=function(n){let i=this.nextPointOnContour;for(;!n.touched(i)&&i!==this;)i=i.nextPointOnContour;return i},Je.prototype.prevTouched=function(n){let i=this.prevPointOnContour;for(;!n.touched(i)&&i!==this;)i=i.prevPointOnContour;return i};var rs=Object.freeze(new Je(0,0)),qf={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function sn(n,i){switch(this.env=n,this.stack=[],this.prog=i,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=ze,this.round=ql}}Jl.prototype.exec=function(n,i){if(typeof i!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let l=this.font,h=this._prepState;if(!h||h.ppem!==i){let d=this._fpgmState;if(!d){sn.prototype=qf,d=this._fpgmState=new sn("fpgm",l.tables.fpgm),d.funcs=[],d.font=l,d.instructionCount=0,d.callDepth=0;try{xn(d)}catch(b){console.log("Hinting error in FPGM:"+b),this._errorState=3;return}}sn.prototype=d,h=this._prepState=new sn("prep",l.tables.prep),h.ppem=i,h.instructionCount=0,h.callDepth=0;let p=l.variation&&l.variation.process.getCvarTransform()||l.tables.cvt;if(p){let b=h.cvt=new Array(p.length),x=i/l.unitsPerEm;for(let A=0;A<p.length;A++)b[A]=p[A]*x}else h.cvt=[];try{xn(h)}catch(b){this._errorState<2&&console.log("Hinting error in PREP:"+b),this._errorState=2}}if(!(this._errorState>1))try{return Ql(n,h)}catch(d){this._errorState<1&&(console.log("Hinting error:"+d),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},Ql=function(n,i){let l=i.ppem/i.font.unitsPerEm,h=l,d=n.components,p,b,x;if(sn.prototype=i,!d)x=new sn("glyf",n.instructions),x.instructionCount=0,x.callDepth=0,Li(n,x,l,h),b=x.gZone;else{let A=i.font;b=[],p=[];for(let E=0;E<d.length;E++){let C=d[E],P=A.glyphs.get(C.glyphIndex);x=new sn("glyf",P.instructions),x.instructionCount=0,x.callDepth=0,Li(P,x,l,h);let R=Math.round(C.dx*l),D=Math.round(C.dy*h),O=x.gZone,_=x.contours;for(let mt=0;mt<O.length;mt++){let ht=O[mt];ht.xTouched=ht.yTouched=!1,ht.xo=ht.x=ht.x+R,ht.yo=ht.y=ht.y+D}let V=b.length;b.push.apply(b,O);for(let mt=0;mt<_.length;mt++)p.push(_[mt]+V)}n.instructions&&!x.inhibitGridFit&&(x=new sn("glyf",n.instructions),x.gZone=x.z0=x.z1=x.z2=b,x.contours=p,b.push(new Je(0,0),new Je(Math.round(n.advanceWidth*l),0)),xn(x),b.length-=2)}return b},Li=function(n,i,l,h){let d=n.points||[],p=d.length,b=i.gZone=i.z0=i.z1=i.z2=[],x=i.contours=[],A;for(let P=0;P<p;P++)A=d[P],b[P]=new Je(A.x*l,A.y*h,A.lastPointOfContour,A.onCurve);let E,C;for(let P=0;P<p;P++)A=b[P],E||(E=A,x.push(P)),A.lastPointOfContour?(A.nextPointOnContour=E,E.prevPointOnContour=A,E=void 0):(C=b[P+1],A.nextPointOnContour=C,C.prevPointOnContour=A);i.inhibitGridFit||(b.push(new Je(0,0),new Je(Math.round(n.advanceWidth*l),0)),xn(i),b.length-=2)},xn=function(n){let i=n.prog;if(!i)return;let l=i.length,h;for(n.ip=0;n.ip<l;n.ip++){if(++n.instructionCount>Kl)throw new Error("Hinting instructions exceeded maximum of "+Kl);if(h=Zl[i[n.ip]],!h)throw new Error("unknown instruction: 0x"+Number(i[n.ip]).toString(16));h(n)}};function qs(n){let i=n.tZone=new Array(n.gZone.length);for(let l=0;l<i.length;l++)i[l]=new Je(0,0)}function ec(n,i){let l=n.prog,h=n.ip,d=1,p;do if(p=l[++h],p===88)d++;else if(p===89)d--;else if(p===64)h+=l[h+1]+1;else if(p===65)h+=2*l[h+1]+1;else if(p>=176&&p<=183)h+=p-176+1;else if(p>=184&&p<=191)h+=(p-184+1)*2;else if(i&&d===1&&p===27)break;while(d>0);n.ip=h}function nc(n,i){i.fv=i.pv=i.dpv=n}function sc(n,i){i.pv=i.dpv=n}function rc(n,i){i.fv=n}function ic(n,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],b=i.z1[d],x,A;n?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),i.pv=i.dpv=ss(x,A)}function oc(n,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],b=i.z1[d],x,A;n?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),i.fv=ss(x,A)}function tp(n){let i=n.stack,l=i.pop(),h=i.pop();n.pv=n.dpv=ss(h,l)}function ep(n){let i=n.stack,l=i.pop(),h=i.pop();n.fv=ss(h,l)}function np(n){let i=n.stack,l=n.pv;i.push(l.x*16384),i.push(l.y*16384)}function sp(n){let i=n.stack,l=n.fv;i.push(l.x*16384),i.push(l.y*16384)}function rp(n){n.fv=n.pv}function ip(n){let i=n.stack,l=i.pop(),h=i.pop(),d=i.pop(),p=i.pop(),b=i.pop(),x=n.z0,A=n.z1,E=x[l],C=x[h],P=A[d],R=A[p],D=n.z2[b],O=E.x,_=E.y,V=C.x,mt=C.y,ht=P.x,At=P.y,kt=R.x,_t=R.y,Bt=(O-V)*(At-_t)-(_-mt)*(ht-kt),Gt=O*mt-_*V,Jt=ht*_t-At*kt;D.x=(Gt*(ht-kt)-Jt*(O-V))/Bt,D.y=(Gt*(At-_t)-Jt*(_-mt))/Bt}function op(n){n.rp0=n.stack.pop()}function ap(n){n.rp1=n.stack.pop()}function lp(n){n.rp2=n.stack.pop()}function cp(n){let i=n.stack.pop();switch(n.zp0=i,i){case 0:n.tZone||qs(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function up(n){let i=n.stack.pop();switch(n.zp1=i,i){case 0:n.tZone||qs(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function hp(n){let i=n.stack.pop();switch(n.zp2=i,i){case 0:n.tZone||qs(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function dp(n){let i=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=i,i){case 0:n.tZone||qs(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function fp(n){n.loop=n.stack.pop(),n.loop>Js&&(n.loop=Js)}function pp(n){n.round=ql}function gp(n){n.round=Zf}function mp(n){let i=n.stack.pop();n.minDis=i/64}function yp(n){ec(n,!1)}function bp(n){let i=n.stack.pop();n.ip+=i-1}function vp(n){let i=n.stack.pop();n.cvCutIn=i/64}function xp(n){let i=n.stack;i.push(i[i.length-1])}function Mi(n){n.stack.pop()}function Sp(n){n.stack.length=0}function Ap(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(l),i.push(h)}function Tp(n){let i=n.stack;i.push(i.length)}function Cp(n){let i=n.stack,l=i.pop(),h=i.pop();if(h>Js&&(h=Js),++n.callDepth>Qs)throw new Error("Hinting call depth exceeded maximum of "+Qs);let d=n.ip,p=n.prog;n.prog=n.funcs[l];for(let b=0;b<h;b++)xn(n);n.ip=d,n.prog=p,n.callDepth--}function Ep(n){let i=n.stack.pop();if(++n.callDepth>Qs)throw new Error("Hinting call depth exceeded maximum of "+Qs);let l=n.ip,h=n.prog;n.prog=n.funcs[i],xn(n),n.ip=l,n.prog=h,n.callDepth--}function wp(n){let i=n.stack,l=i.pop();i.push(i[i.length-l])}function kp(n){let i=n.stack,l=i.pop();i.push(i.splice(i.length-l,1)[0])}function Ip(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");let i=n.stack,l=n.prog,h=n.ip,d=i.pop(),p=h;for(;l[++h]!==45;);n.ip=h,n.funcs[d]=l.slice(p+1,h)}function ac(n,i){let l=i.stack.pop(),h=i.z0[l],d=i.fv,p=i.pv,b=p.distance(h,rs);n&&(b=i.round(b)),d.setRelative(h,rs,b,p),d.touch(h),i.rp0=i.rp1=l}function lc(n,i){let l=i.z2,h=l.length-2,d,p,b;for(let x=0;x<h;x++)d=l[x],!n.touched(d)&&(p=d.prevTouched(n),p!==d&&(b=d.nextTouched(n),p===b&&n.setRelative(d,d,n.distance(p,p,!1,!0),n,!0),n.interpolate(d,p,b,n)))}function cc(n,i){let l=i.stack,h=n?i.rp1:i.rp2,d=(n?i.z0:i.z1)[h],p=i.fv,b=i.pv,x=i.loop,A=i.z2;for(;x--;){let E=l.pop(),C=A[E],P=b.distance(d,d,!1,!0);p.setRelative(C,C,P,b),p.touch(C)}i.loop=1}function uc(n,i){let l=i.stack,h=n?i.rp1:i.rp2,d=(n?i.z0:i.z1)[h],p=i.fv,b=i.pv,x=l.pop(),A=i.z2[i.contours[x]],E=A,C=b.distance(d,d,!1,!0);do E!==d&&p.setRelative(E,E,C,b),E=E.nextPointOnContour;while(E!==A)}function hc(n,i){let l=i.stack,h=n?i.rp1:i.rp2,d=(n?i.z0:i.z1)[h],p=i.fv,b=i.pv,x=l.pop(),A;switch(x){case 0:A=i.tZone;break;case 1:A=i.gZone;break;default:throw new Error("Invalid zone")}let E,C=b.distance(d,d,!1,!0),P=A.length-2;for(let R=0;R<P;R++)E=A[R],p.setRelative(E,E,C,b)}function Rp(n){let i=n.stack,l=n.loop,h=n.fv,d=i.pop()/64,p=n.z2;for(;l--;){let b=i.pop(),x=p[b];h.setRelative(x,x,d),h.touch(x)}n.loop=1}function Pp(n){let i=n.stack,l=n.rp1,h=n.rp2,d=n.loop,p=n.z0[l],b=n.z1[h],x=n.fv,A=n.dpv,E=n.z2;for(;d--;){let C=i.pop(),P=E[C];x.interpolate(P,p,b,A),x.touch(P)}n.loop=1}function dc(n,i){let l=i.stack,h=l.pop()/64,d=l.pop(),p=i.z1[d],b=i.z0[i.rp0],x=i.fv,A=i.pv;x.setRelative(p,b,h,A),x.touch(p),i.rp1=i.rp0,i.rp2=d,n&&(i.rp0=d)}function Op(n){let i=n.stack,l=n.rp0,h=n.z0[l],d=n.loop,p=n.fv,b=n.pv,x=n.z1;for(;d--;){let A=i.pop(),E=x[A];p.setRelative(E,h,0,b),p.touch(E)}n.loop=1}function Lp(n){n.round=Kf}function fc(n,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z0[d],b=i.fv,x=i.pv,A=i.cvt[h],E=x.distance(p,rs);n&&(Math.abs(E-A)<i.cvCutIn&&(E=A),E=i.round(E)),b.setRelative(p,rs,E,x),i.zp0===0&&(p.xo=p.x,p.yo=p.y),b.touch(p),i.rp0=i.rp1=d}function Mp(n){let i=n.prog,l=n.ip,h=n.stack,d=i[++l];for(let p=0;p<d;p++)h.push(i[++l]);n.ip=l}function Dp(n){let i=n.ip,l=n.prog,h=n.stack,d=l[++i];for(let p=0;p<d;p++){let b=l[++i]<<8|l[++i];b&32768&&(b=-((b^65535)+1)),h.push(b)}n.ip=i}function Fp(n){let i=n.stack,l=n.store;l||(l=n.store=[]);let h=i.pop(),d=i.pop();l[d]=h}function _p(n){let i=n.stack,l=n.store,h=i.pop(),d=l&&l[h]||0;i.push(d)}function Np(n){let i=n.stack,l=i.pop(),h=i.pop();n.cvt[h]=l/64}function Up(n){let i=n.stack,l=i.pop();i.push(n.cvt[l]*64)}function pc(n,i){let l=i.stack,h=l.pop(),d=i.z2[h];l.push(i.dpv.distance(d,rs,n,!1)*64)}function gc(n,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z1[h],b=i.z0[d],x=i.dpv.distance(b,p,n,n);i.stack.push(Math.round(x*64))}function Bp(n){n.stack.push(n.ppem)}function Gp(n){n.autoFlip=!0}function Hp(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h<l?1:0)}function jp(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h<=l?1:0)}function Vp(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h>l?1:0)}function $p(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h>=l?1:0)}function zp(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(l===h?1:0)}function Wp(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(l!==h?1:0)}function Xp(n){let i=n.stack,l=i.pop();i.push(Math.trunc(l)&1?1:0)}function Yp(n){let i=n.stack,l=i.pop();i.push(Math.trunc(l)&1?0:1)}function Kp(n){let i=n.stack.pop(),l;i||ec(n,!0)}function Zp(n){}function Qp(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(l&&h?1:0)}function Jp(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(l||h?1:0)}function qp(n){let i=n.stack,l=i.pop();i.push(l?0:1)}function Di(n,i){let l=i.stack,h=l.pop(),d=i.fv,p=i.pv,b=i.ppem,x=i.deltaBase+(n-1)*16,A=i.deltaShift,E=i.z0;for(let C=0;C<h;C++){let P=l.pop(),R=l.pop();if(x+((R&240)>>4)!==b)continue;let O=(R&15)-8;O>=0&&O++;let _=E[P];d.setRelative(_,_,O*A,p)}}function tg(n){let l=n.stack.pop();n.deltaBase=l}function eg(n){let l=n.stack.pop();n.deltaShift=Math.pow(.5,l)}function ng(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h+l)}function sg(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h-l)}function rg(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h*64/l)}function ig(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(h*l/64)}function og(n){let i=n.stack,l=i.pop();i.push(Math.abs(l))}function ag(n){let i=n.stack,l=i.pop();i.push(-l)}function lg(n){let i=n.stack,l=i.pop();i.push(Math.floor(l/64)*64)}function cg(n){let i=n.stack,l=i.pop();i.push(Math.ceil(l/64)*64)}function tr(n,i){let l=i.stack,h=l.pop();l.push(i.round(h/64)*64)}function ug(n){let i=n.stack,l=i.pop(),h=i.pop();n.cvt[h]=l*n.ppem/n.font.unitsPerEm}function Fi(n,i){let l=i.stack,h=l.pop(),d=i.ppem,p=i.deltaBase+(n-1)*16,b=i.deltaShift;for(let x=0;x<h;x++){let A=l.pop(),E=l.pop();if(p+((E&240)>>4)!==d)continue;let P=(E&15)-8;P>=0&&P++;let R=P*b;i.cvt[A]+=R}}function hg(n){let i=n.stack.pop();n.round=tc;let l;switch(i&192){case 0:l=.5;break;case 64:l=1;break;case 128:l=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=l,i&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*l;break;case 32:n.srPhase=.5*l;break;case 48:n.srPhase=.75*l;break;default:throw new Error("invalid SROUND value")}i&=15,i===0?n.srThreshold=0:n.srThreshold=(i/8-.5)*l}function dg(n){let i=n.stack.pop();n.round=tc;let l;switch(i&192){case 0:l=Math.sqrt(2)/2;break;case 64:l=Math.sqrt(2);break;case 128:l=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=l,i&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*l;break;case 32:n.srPhase=.5*l;break;case 48:n.srPhase=.75*l;break;default:throw new Error("invalid S45ROUND value")}i&=15,i===0?n.srThreshold=0:n.srThreshold=(i/8-.5)*l}function fg(n){n.round=Yf}function pg(n){n.round=Qf}function gg(n){n.round=Jf}function mg(n){let i=n.stack.pop()}function mc(n,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],b=i.z1[d],x,A;n?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),i.dpv=ss(x,A)}function yg(n){let i=n.stack,l=i.pop(),h=0;l&1&&(h=35),l&32&&(h|=4096),i.push(h)}function bg(n){let i=n.stack,l=i.pop(),h=i.pop(),d=i.pop();i.push(h),i.push(l),i.push(d)}function vg(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(Math.max(h,l))}function xg(n){let i=n.stack,l=i.pop(),h=i.pop();i.push(Math.min(h,l))}function Sg(n){let i=n.stack.pop()}function Ag(n){let i=n.stack.pop(),l=n.stack.pop();switch(i){case 1:n.inhibitGridFit=!!l;return;case 2:n.ignoreCvt=!!l;return;default:throw new Error("invalid INSTCTRL[] selector")}}function rn(n,i){let l=i.stack,h=i.prog,d=i.ip;for(let p=0;p<n;p++)l.push(h[++d]);i.ip=d}function on(n,i){let l=i.ip,h=i.prog,d=i.stack;for(let p=0;p<n;p++){let b=h[++l]<<8|h[++l];b&32768&&(b=-((b^65535)+1)),d.push(b)}i.ip=l}function dt(n,i,l,h,d,p){let b=p.stack,x=n&&b.pop(),A=b.pop(),E=p.rp0,C=p.z0[E],P=p.z1[A],R=p.minDis,D=p.fv,O=p.dpv,_,V,mt,ht;V=_=O.distance(P,C,!0,!0),mt=V>=0?1:-1,V=Math.abs(V),n&&(ht=p.cvt[x],h&&Math.abs(V-ht)<p.cvCutIn&&(V=ht)),l&&V<R&&(V=R),h&&(V=p.round(V)),D.setRelative(P,C,mt*V,O),D.touch(P),p.rp1=p.rp0,p.rp2=A,i&&(p.rp0=A)}Zl=[nc.bind(void 0,Qe),nc.bind(void 0,ze),sc.bind(void 0,Qe),sc.bind(void 0,ze),rc.bind(void 0,Qe),rc.bind(void 0,ze),ic.bind(void 0,0),ic.bind(void 0,1),oc.bind(void 0,0),oc.bind(void 0,1),tp,ep,np,sp,rp,ip,op,ap,lp,cp,up,hp,dp,fp,pp,gp,mp,yp,bp,vp,void 0,void 0,xp,Mi,Sp,Ap,Tp,wp,kp,void 0,void 0,void 0,Cp,Ep,Ip,void 0,ac.bind(void 0,0),ac.bind(void 0,1),lc.bind(void 0,Qe),lc.bind(void 0,ze),cc.bind(void 0,0),cc.bind(void 0,1),uc.bind(void 0,0),uc.bind(void 0,1),hc.bind(void 0,0),hc.bind(void 0,1),Rp,Pp,dc.bind(void 0,0),dc.bind(void 0,1),Op,Lp,fc.bind(void 0,0),fc.bind(void 0,1),Mp,Dp,Fp,_p,Np,Up,pc.bind(void 0,0),pc.bind(void 0,1),void 0,gc.bind(void 0,0),gc.bind(void 0,1),Bp,void 0,Gp,void 0,void 0,Hp,jp,Vp,$p,zp,Wp,Xp,Yp,Kp,Zp,Qp,Jp,qp,Di.bind(void 0,1),tg,eg,ng,sg,rg,ig,og,ag,lg,cg,tr.bind(void 0,0),tr.bind(void 0,1),tr.bind(void 0,2),tr.bind(void 0,3),void 0,void 0,void 0,void 0,ug,Di.bind(void 0,2),Di.bind(void 0,3),Fi.bind(void 0,1),Fi.bind(void 0,2),Fi.bind(void 0,3),hg,dg,void 0,void 0,fg,void 0,pg,gg,Mi,Mi,void 0,void 0,void 0,void 0,void 0,mg,mc.bind(void 0,0),mc.bind(void 0,1),yg,void 0,bg,vg,xg,Sg,Ag,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,rn.bind(void 0,1),rn.bind(void 0,2),rn.bind(void 0,3),rn.bind(void 0,4),rn.bind(void 0,5),rn.bind(void 0,6),rn.bind(void 0,7),rn.bind(void 0,8),on.bind(void 0,1),on.bind(void 0,2),on.bind(void 0,3),on.bind(void 0,4),on.bind(void 0,5),on.bind(void 0,6),on.bind(void 0,7),on.bind(void 0,8),dt.bind(void 0,0,0,0,0,0),dt.bind(void 0,0,0,0,0,1),dt.bind(void 0,0,0,0,0,2),dt.bind(void 0,0,0,0,0,3),dt.bind(void 0,0,0,0,1,0),dt.bind(void 0,0,0,0,1,1),dt.bind(void 0,0,0,0,1,2),dt.bind(void 0,0,0,0,1,3),dt.bind(void 0,0,0,1,0,0),dt.bind(void 0,0,0,1,0,1),dt.bind(void 0,0,0,1,0,2),dt.bind(void 0,0,0,1,0,3),dt.bind(void 0,0,0,1,1,0),dt.bind(void 0,0,0,1,1,1),dt.bind(void 0,0,0,1,1,2),dt.bind(void 0,0,0,1,1,3),dt.bind(void 0,0,1,0,0,0),dt.bind(void 0,0,1,0,0,1),dt.bind(void 0,0,1,0,0,2),dt.bind(void 0,0,1,0,0,3),dt.bind(void 0,0,1,0,1,0),dt.bind(void 0,0,1,0,1,1),dt.bind(void 0,0,1,0,1,2),dt.bind(void 0,0,1,0,1,3),dt.bind(void 0,0,1,1,0,0),dt.bind(void 0,0,1,1,0,1),dt.bind(void 0,0,1,1,0,2),dt.bind(void 0,0,1,1,0,3),dt.bind(void 0,0,1,1,1,0),dt.bind(void 0,0,1,1,1,1),dt.bind(void 0,0,1,1,1,2),dt.bind(void 0,0,1,1,1,3),dt.bind(void 0,1,0,0,0,0),dt.bind(void 0,1,0,0,0,1),dt.bind(void 0,1,0,0,0,2),dt.bind(void 0,1,0,0,0,3),dt.bind(void 0,1,0,0,1,0),dt.bind(void 0,1,0,0,1,1),dt.bind(void 0,1,0,0,1,2),dt.bind(void 0,1,0,0,1,3),dt.bind(void 0,1,0,1,0,0),dt.bind(void 0,1,0,1,0,1),dt.bind(void 0,1,0,1,0,2),dt.bind(void 0,1,0,1,0,3),dt.bind(void 0,1,0,1,1,0),dt.bind(void 0,1,0,1,1,1),dt.bind(void 0,1,0,1,1,2),dt.bind(void 0,1,0,1,1,3),dt.bind(void 0,1,1,0,0,0),dt.bind(void 0,1,1,0,0,1),dt.bind(void 0,1,1,0,0,2),dt.bind(void 0,1,1,0,0,3),dt.bind(void 0,1,1,0,1,0),dt.bind(void 0,1,1,0,1,1),dt.bind(void 0,1,1,0,1,2),dt.bind(void 0,1,1,0,1,3),dt.bind(void 0,1,1,1,0,0),dt.bind(void 0,1,1,1,0,1),dt.bind(void 0,1,1,1,0,2),dt.bind(void 0,1,1,1,0,3),dt.bind(void 0,1,1,1,1,0),dt.bind(void 0,1,1,1,1,1),dt.bind(void 0,1,1,1,1,2),dt.bind(void 0,1,1,1,1,3)];var Tg=Jl;function Vn(n){this.char=n,this.state={},this.activeState=null}function _i(n,i,l){this.contextName=l,this.startIndex=n,this.endOffset=i}function Cg(n,i,l){this.contextName=n,this.openRange=null,this.ranges=[],this.checkStart=i,this.checkEnd=l}function ue(n,i){this.context=n,this.index=i,this.length=n.length,this.current=n[i],this.backtrack=n.slice(0,i),this.lookahead=n.slice(i+1)}function er(n){this.eventId=n,this.subscribers=[]}function Eg(n){let i=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let h=0;h<i.length;h++){let d=i[h];Object.defineProperty(this.events,d,{value:new er(d)})}if(n)for(let h=0;h<i.length;h++){let d=i[h],p=n[d];typeof p=="function"&&this.events[d].subscribe(p)}let l=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let h=0;h<l.length;h++){let d=l[h];this.events[d].subscribe(this.updateContextsRanges)}}function Yt(n){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Eg.call(this,n)}Vn.prototype.setState=function(n,i){return this.state[n]=i,this.activeState={key:n,value:this.state[n]},this.activeState},Vn.prototype.getState=function(n){return this.state[n]||null},Yt.prototype.inboundIndex=function(n){return n>=0&&n<this.tokens.length},Yt.prototype.composeRUD=function(n){let l=n.map(d=>this[d[0]].apply(this,d.slice(1).concat(!0))),h=d=>typeof d=="object"&&Object.prototype.hasOwnProperty.call(d,"FAIL");if(l.every(h))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:l.filter(h)};this.dispatch("composeRUD",[l.filter(d=>!h(d))])},Yt.prototype.replaceRange=function(n,i,l,h){i=i!==null?i:this.tokens.length;let d=l.every(p=>p instanceof Vn);if(!isNaN(n)&&this.inboundIndex(n)&&d){let p=this.tokens.splice.apply(this.tokens,[n,i].concat(l));return h||this.dispatch("replaceToken",[n,i,l]),[p,l]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},Yt.prototype.replaceToken=function(n,i,l){if(!isNaN(n)&&this.inboundIndex(n)&&i instanceof Vn){let h=this.tokens.splice(n,1,i);return l||this.dispatch("replaceToken",[n,i]),[h[0],i]}else return{FAIL:"replaceToken: invalid token or index."}},Yt.prototype.removeRange=function(n,i,l){i=isNaN(i)?this.tokens.length:i;let h=this.tokens.splice(n,i);return l||this.dispatch("removeRange",[h,n,i]),h},Yt.prototype.removeToken=function(n,i){if(!isNaN(n)&&this.inboundIndex(n)){let l=this.tokens.splice(n,1);return i||this.dispatch("removeToken",[l,n]),l}else return{FAIL:"removeToken: invalid token index."}},Yt.prototype.insertToken=function(n,i,l){return n.every(d=>d instanceof Vn)?(this.tokens.splice.apply(this.tokens,[i,0].concat(n)),l||this.dispatch("insertToken",[n,i]),n):{FAIL:"insertToken: invalid token(s)."}},Yt.prototype.registerModifier=function(n,i,l){this.events.newToken.subscribe(function(h,d){let p=[h,d],b=i===null||i.apply(this,p)===!0,x=[h,d];if(b){let A=l.apply(this,x);h.setState(n,A)}}),this.registeredModifiers.push(n)},er.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}},er.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)},ue.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)},ue.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}},Yt.prototype.rangeToText=function(n){if(n instanceof _i)return this.getRangeTokens(n).map(i=>i.char).join("")},Yt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")},Yt.prototype.getContext=function(n){let i=this.registeredContexts[n];return i||null},Yt.prototype.on=function(n,i){let l=this.events[n];return l?l.subscribe(i):null},Yt.prototype.dispatch=function(n,i){let l=this.events[n];if(l instanceof er)for(let h=0;h<l.subscribers.length;h++)l.subscribers[h].apply(this,i||[])},Yt.prototype.registerContextChecker=function(n,i,l){if(this.getContext(n))return{FAIL:`context name '${n}' is already registered.`};if(typeof i!="function")return{FAIL:"missing context start check."};if(typeof l!="function")return{FAIL:"missing context end check."};let h=new Cg(n,i,l);return this.registeredContexts[n]=h,this.contextCheckers.push(h),h},Yt.prototype.getRangeTokens=function(n){let i=n.startIndex+n.endOffset;return[].concat(this.tokens.slice(n.startIndex,i))},Yt.prototype.getContextRanges=function(n){let i=this.getContext(n);return i?i.ranges:{FAIL:`context checker '${n}' is not registered.`}},Yt.prototype.resetContextsRanges=function(){let n=this.registeredContexts;for(let i in n)if(Object.prototype.hasOwnProperty.call(n,i)){let l=n[i];l.ranges=[]}},Yt.prototype.updateContextsRanges=function(){this.resetContextsRanges();let n=this.tokens.map(i=>i.char);for(let i=0;i<n.length;i++){let l=new ue(n,i);this.runContextCheck(l)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Yt.prototype.setEndOffset=function(n,i){let l=this.getContext(i).openRange.startIndex,h=new _i(l,n,i),d=this.getContext(i).ranges;return h.rangeId=`${i}.${d.length}`,d.push(h),this.getContext(i).openRange=null,h},Yt.prototype.runContextCheck=function(n){let i=n.index;for(let l=0;l<this.contextCheckers.length;l++){let h=this.contextCheckers[l],d=h.contextName,p=this.getContext(d).openRange;if(!p&&h.checkStart(n)&&(p=new _i(i,null,d),this.getContext(d).openRange=p,this.dispatch("contextStart",[d,i])),p&&h.checkEnd(n)){let b=i-p.startIndex+1,x=this.setEndOffset(b,d);this.dispatch("contextEnd",[d,x])}}},Yt.prototype.tokenize=function(n){this.tokens=[],this.resetContextsRanges();let i=Array.from(n);this.dispatch("start");for(let l=0;l<i.length;l++){let h=i[l],d=new ue(i,l);this.dispatch("next",[d]),this.runContextCheck(d);let p=new Vn(h);this.tokens.push(p),this.dispatch("newToken",[p,d])}return this.dispatch("end",[this.tokens]),this.tokens};var wg=Yt;function an(n){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(n)}function yc(n){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(n)}function ln(n){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(n)}function nr(n){return/[\u0E00-\u0E7F]/.test(n)}function sr(n){return/[A-z]/.test(n)}function kg(n){return/\s/.test(n)}function Se(n){this.font=n,this.features={}}function cn(n){this.id=n.id,this.tag=n.tag,this.substitution=n.substitution}function un(n,i){if(!n)return-1;switch(i.format){case 1:return i.glyphs.indexOf(n);case 2:{let l=i.ranges;for(let h=0;h<l.length;h++){let d=l[h];if(n>=d.start&&n<=d.end){let p=n-d.start;return d.index+p}}break}default:return-1}return-1}function Ig(n,i){return un(n,i.coverage)===-1?null:n+i.deltaGlyphId}function Rg(n,i){let l=un(n,i.coverage);return l===-1?null:i.substitute[l]}function Ni(n,i){let l=[];for(let h=0;h<n.length;h++){let d=n[h],p=i.current;p=Array.isArray(p)?p[0]:p;let b=un(p,d);b!==-1&&l.push(b)}return l.length!==n.length?-1:l}function Pg(n,i){let l=i.inputCoverage.length+i.lookaheadCoverage.length+i.backtrackCoverage.length;if(n.context.length<l)return[];let h=Ni(i.inputCoverage,n);if(h===-1)return[];let d=i.inputCoverage.length-1;if(n.lookahead.length<i.lookaheadCoverage.length)return[];let p=n.lookahead.slice(d);for(;p.length&&ln(p[0].char);)p.shift();let b=new ue(p,0),x=Ni(i.lookaheadCoverage,b),A=[].concat(n.backtrack);for(A.reverse();A.length&&ln(A[0].char);)A.shift();if(A.length<i.backtrackCoverage.length)return[];let E=new ue(A,0),C=Ni(i.backtrackCoverage,E),P=h.length===i.inputCoverage.length&&x.length===i.lookaheadCoverage.length&&C.length===i.backtrackCoverage.length,R=[];if(P)for(let D=0;D<i.lookupRecords.length;D++){let O=i.lookupRecords[D],_=O.lookupListIndex,V=this.getLookupByIndex(_);for(let mt=0;mt<V.subtables.length;mt++){let ht=V.subtables[mt],At,kt=this.getSubstitutionType(V,ht);if(kt==="71"?(kt=this.getSubstitutionType(ht,ht.extension),At=this.getLookupMethod(ht,ht.extension),ht=ht.extension):At=this.getLookupMethod(V,ht),kt==="12"){let _t=n.get(O.sequenceIndex),Bt=At(_t);Bt&&R.push(Bt)}else if(kt==="21"){let _t=n.get(O.sequenceIndex),Bt=At(_t);Bt&&R.push(Bt)}else throw new Error(`Substitution type ${kt} is not supported in chaining substitution`)}}return R}function Og(n,i){let l=n.current,h=un(l,i.coverage);if(h===-1)return null;let d,p=i.ligatureSets[h];for(let b=0;b<p.length;b++){d=p[b];for(let x=0;x<d.components.length;x++){let A=n.lookahead[x],E=d.components[x];if(A!==E)break;if(x===d.components.length-1)return d}}return null}function Lg(n,i){let l=n.current;if(un(l,i.coverage)===-1)return null;for(let d of i.ruleSets)for(let p of d){let b=!0;for(let x=0;x<p.input.length;x++)if(n.lookahead[x]!==p.input[x]){b=!1;break}if(b){let x=[];x.push(l);for(let E=0;E<p.input.length;E++)x.push(p.input[E]);let A=(E,C)=>{let{lookupListIndex:P,sequenceIndex:R}=C,{subtables:D}=this.getLookupByIndex(P);for(let O of D)un(E[R],O.coverage)!==-1&&(E[R]=O.deltaGlyphId)};for(let E=0;E<p.lookupRecords.length;E++){let C=p.lookupRecords[E];A(x,C)}return x}}return null}function Mg(n,i){if(n.context.length<i.coverages.length)return[];for(let h=0;h<i.coverages.length;h++){let d=n.get(h);if(d=Array.isArray(d)?d[0]:d,un(d,i.coverages[h])===-1)return[]}let l=[];for(let h=0;h<i.lookupRecords.length;h++){let d=i.lookupRecords[h],p=d.lookupListIndex,b=this.getLookupByIndex(p);for(let x=0;x<b.subtables.length;x++){let A=b.subtables[x],E,C=this.getSubstitutionType(b,A);if(C==="71"?(C=this.getSubstitutionType(A,A.extension),E=this.getLookupMethod(A,A.extension),A=A.extension):E=this.getLookupMethod(b,A),C==="12"){let P=n.get(d.sequenceIndex),R=E(P);R&&l.push(R)}else if(C==="21"){let P=n.get(d.sequenceIndex),R=E(P);R&&l.push(R)}}}return l}function Dg(n,i){let l=un(n,i.coverage);return l===-1?null:i.sequences[l]}Se.prototype.getDefaultScriptFeaturesIndexes=function(){let n=this.font.tables.gsub.scripts;for(let i=0;i<n.length;i++){let l=n[i];if(l.tag==="DFLT")return l.script.defaultLangSys.featureIndexes}return[]},Se.prototype.getScriptFeaturesIndexes=function(n){if(!this.font.tables.gsub)return[];if(!n)return this.getDefaultScriptFeaturesIndexes();let l=this.font.tables.gsub.scripts;for(let h=0;h<l.length;h++){let d=l[h];if(d.tag===n&&d.script.defaultLangSys)return d.script.defaultLangSys.featureIndexes;{let p=d.langSysRecords;if(p)for(let b=0;b<p.length;b++){let x=p[b];if(x.tag===n)return x.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Se.prototype.mapTagsToFeatures=function(n,i){let l={};for(let h=0;h<n.length;h++){let d=n[h].tag,p=n[h].feature;l[d]=p}this.features[i].tags=l},Se.prototype.getScriptFeatures=function(n){let i=this.features[n];if(Object.prototype.hasOwnProperty.call(this.features,n))return i;let l=this.getScriptFeaturesIndexes(n);if(!l)return null;let h=this.font.tables.gsub;return i=l.map(d=>h.features[d]),this.features[n]=i,this.mapTagsToFeatures(i,n),i},Se.prototype.getSubstitutionType=function(n,i){let l=n.lookupType.toString(),h=i.substFormat.toString();return l+h},Se.prototype.getLookupMethod=function(n,i){let l=this.getSubstitutionType(n,i);switch(l){case"11":return h=>Ig.apply(this,[h,i]);case"12":return h=>Rg.apply(this,[h,i]);case"63":return h=>Pg.apply(this,[h,i]);case"41":return h=>Og.apply(this,[h,i]);case"21":return h=>Dg.apply(this,[h,i]);case"51":return h=>Lg.apply(this,[h,i]);case"53":return h=>Mg.apply(this,[h,i]);default:throw new Error(`substitutionType : ${l} lookupType: ${n.lookupType} - substFormat: ${i.substFormat} is not yet supported`)}},Se.prototype.lookupFeature=function(n){let i=n.contextParams,l=i.index,h=this.getFeature({tag:n.tag,script:n.script});if(!h)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);let d=this.getFeatureLookups(h),p=[].concat(i.context);for(let b=0;b<d.length;b++){let x=d[b],A=this.getLookupSubtables(x);for(let E=0;E<A.length;E++){let C=A[E],P=this.getSubstitutionType(x,C),R;P==="71"?(P=this.getSubstitutionType(C,C.extension),R=this.getLookupMethod(C,C.extension),C=C.extension):R=this.getLookupMethod(x,C);let D;switch(P){case"11":D=R(i.current),D&&p.splice(l,1,new cn({id:11,tag:n.tag,substitution:D}));break;case"12":D=R(i.current),D&&p.splice(l,1,new cn({id:12,tag:n.tag,substitution:D}));break;case"63":D=R(i),Array.isArray(D)&&D.length&&p.splice(l,1,new cn({id:63,tag:n.tag,substitution:D}));break;case"41":D=R(i),D&&p.splice(l,1,new cn({id:41,tag:n.tag,substitution:D}));break;case"21":D=R(i.current),D&&p.splice(l,1,new cn({id:21,tag:n.tag,substitution:D}));break;case"51":case"53":D=R(i),Array.isArray(D)&&D.length&&p.splice(l,1,new cn({id:parseInt(P),tag:n.tag,substitution:D}));break}i=new ue(p,l),!(Array.isArray(D)&&!D.length)&&(D=null)}}return p.length?p:null},Se.prototype.supports=function(n){if(!n.script)return!1;this.getScriptFeatures(n.script);let i=Object.prototype.hasOwnProperty.call(this.features,n.script);if(!n.tag)return i;let l=this.features[n.script].some(h=>h.tag===n.tag);return i&&l},Se.prototype.getLookupSubtables=function(n){return n.subtables||null},Se.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null},Se.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Se.prototype.getFeature=function(i){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,i.script)||this.getScriptFeatures(i.script);let l=this.features[i.script];return l?l.tags[i.tag]?this.features[i.script].tags[i.tag]:null:{FAIL:`No feature for script ${i.script}`}};var Fg=Se;function _g(n){let i=n.current,l=n.get(-1);return l===null&&an(i)||!an(l)&&an(i)}function Ng(n){let i=n.get(1);return i===null||!an(i)}var Ug={startCheck:_g,endCheck:Ng};function Bg(n){let i=n.current,l=n.get(-1);return(an(i)||ln(i))&&!an(l)}function Gg(n){let i=n.get(1);switch(!0){case i===null:return!0;case(!an(i)&&!ln(i)):{let l=kg(i);if(!l)return!0;if(l){let h=!1;if(h=n.lookahead.some(d=>an(d)||ln(d)),!h)return!0}break}default:return!1}}var Hg={startCheck:Bg,endCheck:Gg};function jg(n,i,l){i[l].setState(n.tag,n.substitution)}function Vg(n,i,l){i[l].setState(n.tag,n.substitution)}function Ui(n,i,l){for(let h=0;h<n.substitution.length;h++){let d=n.substitution[h],p=i[l+h];if(Array.isArray(d)){d.length?p.setState(n.tag,d[0]):p.setState("deleted",!0);continue}p.setState(n.tag,d)}}function $g(n,i,l){let h=i[l];h.setState(n.tag,n.substitution.ligGlyph);let d=n.substitution.components.length;for(let p=0;p<d;p++)h=i[l+p+1],h.setState("deleted",!0)}var bc={11:jg,12:Vg,63:Ui,41:$g,51:Ui,53:Ui};function zg(n,i,l){n instanceof cn&&bc[n.id]&&bc[n.id](n,i,l)}var Sn=zg;function Wg(n){let i=[].concat(n.backtrack);for(let l=i.length-1;l>=0;l--){let h=i[l],d=yc(h),p=ln(h);if(!d&&!p)return!0;if(d)return!1}return!1}function Xg(n){if(yc(n.current))return!1;for(let i=0;i<n.lookahead.length;i++){let l=n.lookahead[i];if(!ln(l))return!0}return!1}function Yg(n){let i="arab",l=this.featuresTags[i],h=this.tokenizer.getRangeTokens(n);if(h.length===1)return;let d=new ue(h.map(b=>b.getState("glyphIndex")),0),p=new ue(h.map(b=>b.char),0);for(let b=0;b<h.length;b++){let x=h[b];if(ln(x.char))continue;d.setCurrentIndex(b),p.setCurrentIndex(b);let A=0;Wg(p)&&(A|=1),Xg(p)&&(A|=2);let E;switch(A){case 1:E="fina";break;case 2:E="init";break;case 3:E="medi";break}if(l.indexOf(E)===-1)continue;let C=this.query.lookupFeature({tag:E,script:i,contextParams:d});if(C instanceof Error){console.info(C.message);continue}for(let P=0;P<C.length;P++){let R=C[P];R instanceof cn&&(Sn(R,h,P),d.context[P]=R.substitution)}}}var Kg=Yg;function vc(n,i){let l=n.map(h=>h.activeState.value);return new ue(l,i||0)}function Zg(n){let i="arab",l=this.tokenizer.getRangeTokens(n),h=vc(l);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"rlig",script:i,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];Sn(x,l,d)}h=vc(l)}}}var Qg=Zg;function Jg(n){return n.index===0&&n.context.length>1}function qg(n){return n.index===n.context.length-1}var tm={startCheck:Jg,endCheck:qg};function xc(n,i){let l=n.map(h=>h.activeState.value);return new ue(l,i||0)}function em(n){let i="delf",l="ccmp",h=this.tokenizer.getRangeTokens(n),d=xc(h);for(let p=0;p<d.context.length;p++){if(!this.query.getFeature({tag:l,script:i,contextParams:d}))continue;d.setCurrentIndex(p);let b=this.query.lookupFeature({tag:l,script:i,contextParams:d});if(b.length){for(let x=0;x<b.length;x++){let A=b[x];Sn(A,h,p)}d=xc(h)}}}var nm=em;function sm(n){let i=n.current,l=n.get(-1);return l===null&&sr(i)||!sr(l)&&sr(i)}function rm(n){let i=n.get(1);return i===null||!sr(i)}var im={startCheck:sm,endCheck:rm};function Sc(n,i){let l=n.map(h=>h.activeState.value);return new ue(l,i||0)}function om(n){let i="latn",l=this.tokenizer.getRangeTokens(n),h=Sc(l);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"liga",script:i,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];Sn(x,l,d)}h=Sc(l)}}}var am=om;function lm(n){let i=n.current,l=n.get(-1);return l===null&&nr(i)||!nr(l)&&nr(i)}function cm(n){let i=n.get(1);return i===null||!nr(i)}var um={startCheck:lm,endCheck:cm};function Ac(n,i){let l=n.map(h=>h.activeState.value);return new ue(l,i||0)}function hm(n){let i="thai",l=this.tokenizer.getRangeTokens(n),h=Ac(l,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"ccmp",script:i,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];Sn(x,l,d)}h=Ac(l,d)}}}var dm=hm;function Tc(n,i){let l=n.map(h=>h.activeState.value);return new ue(l,i||0)}function fm(n){let i="thai",l=this.tokenizer.getRangeTokens(n),h=Tc(l,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"liga",script:i,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];Sn(x,l,d)}h=Tc(l,d)}}}var pm=fm;function Cc(n,i){let l=n.map(h=>h.activeState.value);return new ue(l,i||0)}function gm(n){let i="thai",l=this.tokenizer.getRangeTokens(n),h=Cc(l,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"rlig",script:i,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];Sn(x,l,d)}h=Cc(l,d)}}}var mm=gm;function Bi(n){if(n===null)return!1;let i=n.codePointAt(0);return i>=6155&&i<=6157||i>=65024&&i<=65039||i>=917760&&i<=917999}function ym(n){let i=n.current,l=n.get(1);return l===null&&Bi(i)||Bi(l)}function bm(n){let i=n.get(1);return i===null||!Bi(i)}var vm={startCheck:ym,endCheck:bm};function xm(n){let i=this.query.font,l=this.tokenizer.getRangeTokens(n);if(l[1].setState("deleted",!0),i.tables.cmap&&i.tables.cmap.varSelectorList){let h=l[0].char.codePointAt(0),d=l[1].char.codePointAt(0),p=i.tables.cmap.varSelectorList[d];if(p!==void 0&&p.nonDefaultUVS){let b=p.nonDefaultUVS.uvsMappings;if(b[h]){let x=b[h].glyphID;i.glyphs.glyphs[x]!==void 0&&l[0].setState("glyphIndex",x)}}}}var Sm=xm;function we(n){this.baseDir=n||"ltr",this.tokenizer=new wg,this.featuresTags={}}we.prototype.setText=function(n){this.text=n},we.prototype.contextChecks={ccmpReplacementCheck:tm,latinWordCheck:im,arabicWordCheck:Ug,arabicSentenceCheck:Hg,thaiWordCheck:um,unicodeVariationSequenceCheck:vm};function $n(n){let i=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,i.startCheck,i.endCheck)}function Am(){return $n.call(this,"ccmpReplacement"),$n.call(this,"latinWord"),$n.call(this,"arabicWord"),$n.call(this,"arabicSentence"),$n.call(this,"thaiWord"),$n.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function Tm(){let n=this.tokenizer.getContextRanges("arabicSentence");for(let i=0;i<n.length;i++){let l=n[i],h=this.tokenizer.getRangeTokens(l);this.tokenizer.replaceRange(l.startIndex,l.endOffset,h.reverse())}}we.prototype.registerFeatures=function(n,i){let l=i.filter(h=>this.query.supports({script:n,tag:h}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(l):this.featuresTags[n]=l},we.prototype.applyFeatures=function(n,i){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Fg(n));for(let l=0;l<i.length;l++){let h=i[l];this.query.supports({script:h.script})&&this.registerFeatures(h.script,h.tags)}},we.prototype.registerModifier=function(n,i,l){this.tokenizer.registerModifier(n,i,l)};function is(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Cm(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;is.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let l=0;l<i.length;l++){let h=i[l];Kg.call(this,h)}}function Em(){is.call(this);let n=this.tokenizer.getContextRanges("ccmpReplacement");for(let i=0;i<n.length;i++){let l=n[i];nm.call(this,l)}}function wm(){if(!this.hasFeatureEnabled("arab","rlig"))return;is.call(this);let n=this.tokenizer.getContextRanges("arabicWord");for(let i=0;i<n.length;i++){let l=n[i];Qg.call(this,l)}}function km(){if(!this.hasFeatureEnabled("latn","liga"))return;is.call(this);let n=this.tokenizer.getContextRanges("latinWord");for(let i=0;i<n.length;i++){let l=n[i];am.call(this,l)}}function Im(){let n=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let i=0;i<n.length;i++){let l=n[i];Sm.call(this,l)}}function Rm(){is.call(this);let n=this.tokenizer.getContextRanges("thaiWord");for(let i=0;i<n.length;i++){let l=n[i];this.hasFeatureEnabled("thai","liga")&&pm.call(this,l),this.hasFeatureEnabled("thai","rlig")&&mm.call(this,l),this.hasFeatureEnabled("thai","ccmp")&&dm.call(this,l)}}we.prototype.checkContextReady=function(n){return!!this.tokenizer.getContext(n)},we.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&Em.call(this),this.checkContextReady("arabicWord")&&(Cm.call(this),wm.call(this)),this.checkContextReady("latinWord")&&km.call(this),this.checkContextReady("arabicSentence")&&Tm.call(this),this.checkContextReady("thaiWord")&&Rm.call(this),this.checkContextReady("unicodeVariationSequence")&&Im.call(this)},we.prototype.hasFeatureEnabled=function(n,i){return(this.featuresTags[n]||[]).indexOf(i)!==-1},we.prototype.processText=function(n){(!this.text||this.text!==n)&&(this.setText(n),Am.call(this),this.applyFeaturesToContexts())},we.prototype.getBidiText=function(n){return this.processText(n),this.tokenizer.getText()},we.prototype.getTextGlyphs=function(n){this.processText(n);let i=[];for(let l=0;l<this.tokenizer.tokens.length;l++){let h=this.tokenizer.tokens[l];if(h.state.deleted)continue;let d=h.activeState.value;i.push(Array.isArray(d)?d[0]:d)}return i};var Pm=we;function Gi(n){return{fontFamily:{en:n.familyName||" "},fontSubfamily:{en:n.styleName||" "},fullName:{en:n.fullName||n.familyName+" "+n.styleName},postScriptName:{en:n.postScriptName||(n.familyName+n.styleName).replace(/\s/g,"")},designer:{en:n.designer||" "},designerURL:{en:n.designerURL||" "},manufacturer:{en:n.manufacturer||" "},manufacturerURL:{en:n.manufacturerURL||" "},license:{en:n.license||" "},licenseURL:{en:n.licenseURL||" "},version:{en:n.version||"Version 0.1"},description:{en:n.description||" "},copyright:{en:n.copyright||" "},trademark:{en:n.trademark||" "}}}function Ut(n){if(n=n||{},n.tables=n.tables||{},!n.empty){if(!n.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!n.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!n.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!n.ascender)throw new Error("When creating a new Font object, ascender is required.");if(n.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=Gi(n),this.names.macintosh=Gi(n),this.names.windows=Gi(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let i=0;n.fsSelection?i=n.fsSelection:(this.italicAngle<0?i|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(i|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(i|=this.fsSelectionValues.BOLD),i===0&&(i=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:i},n.tables.os2)})}this.supported=!0,this.glyphs=new Ve.GlyphSet(this,n.glyphs||[]),this.encoding=new el(this),this.position=new Ef(this),this.substitution=new Lf(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(i,l,h)=>(i[l]=h,i.fvar&&(i.gvar||i.cff2)&&!this.variation&&(this.variation=new Xf(this)),!0)}),this.palettes=new $l(this),this.layers=new Mf(this),this.svgImages=new Df(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new Tg(this):null}})}Ut.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0},Ut.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)},Ut.prototype.charToGlyph=function(n){let i=this.charToGlyphIndex(n),l=this.glyphs.get(i);return l||(l=this.glyphs.get(0)),l},Ut.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(i=>i.script==="latn"?{script:"latn",tags:i.tags.filter(l=>n[l])}:i)},Ut.prototype.stringToGlyphIndexes=function(n,i){let l=new Pm,h=p=>this.charToGlyphIndex(p.char);l.registerModifier("glyphIndex",null,h);let d=i?this.updateFeatures(i.features):this.defaultRenderOptions.features;return l.applyFeatures(this,d),l.getTextGlyphs(n)},Ut.prototype.stringToGlyphs=function(n,i){let l=this.stringToGlyphIndexes(n,i),h=l.length,d=new Array(h),p=this.glyphs.get(0);for(let b=0;b<h;b+=1)d[b]=this.glyphs.get(l[b])||p;return d},Ut.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)},Ut.prototype.nameToGlyph=function(n){let i=this.nameToGlyphIndex(n),l=this.glyphs.get(i);return l||(l=this.glyphs.get(0)),l},Ut.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""},Ut.prototype.getKerningValue=function(n,i){n=n.index||n,i=i.index||i;let l=this.position.defaultKerningTables;return l?this.position.getKerningValue(l,n,i):this.kerningPairs[n+","+i]||0},Ut.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Ut.prototype.forEachGlyph=function(n,i,l,h,d,p){i=i!==void 0?i:0,l=l!==void 0?l:0,h=h!==void 0?h:72,d=Object.assign({},this.defaultRenderOptions,d);let b=1/this.unitsPerEm*h,x=this.stringToGlyphs(n,d),A;if(d.kerning){let E=d.script||this.position.getDefaultScriptName();A=this.position.getKerningTables(E,d.language)}for(let E=0;E<x.length;E+=1){let C=x[E];if(p.call(this,C,i,l,h,d),C.advanceWidth&&(i+=C.advanceWidth*b),d.kerning&&E<x.length-1){let P=A?this.position.getKerningValue(A,C.index,x[E+1].index):this.getKerningValue(C,x[E+1]);i+=P*b}d.letterSpacing?i+=d.letterSpacing*h:d.tracking&&(i+=d.tracking/1e3*h)}return i},Ut.prototype.getPath=function(n,i,l,h,d){d=Object.assign({},this.defaultRenderOptions,d);let p=new st;if(p._layers=[],fl(this,p,h),p.stroke){let b=1/(p.unitsPerEm||1e3)*h;p.strokeWidth*=b}return this.forEachGlyph(n,i,l,h,d,(b,x,A,E)=>{let C=b.getPath(x,A,E,d,this);if(d.drawSVG||d.drawLayers){let P=C._layers;if(P&&P.length){for(let R=0;R<P.length;R++){let D=P[R];p._layers.push(D)}return}}p.extend(C)}),p},Ut.prototype.getPaths=function(n,i,l,h,d){d=Object.assign({},this.defaultRenderOptions,d);let p=[];return this.forEachGlyph(n,i,l,h,d,function(b,x,A,E){let C=b.getPath(x,A,E,d,this);p.push(C)}),p},Ut.prototype.getAdvanceWidth=function(n,i,l){return l=Object.assign({},this.defaultRenderOptions,l),this.forEachGlyph(n,0,0,i,l,function(){})},Ut.prototype.draw=function(n,i,l,h,d,p){this.getPath(i,l,h,d,p).draw(n)},Ut.prototype.drawPoints=function(n,i,l,h,d,p){p=Object.assign({},this.defaultRenderOptions,p),this.forEachGlyph(i,l,h,d,p,function(b,x,A,E){b.drawPoints(n,x,A,E,p,this)})},Ut.prototype.drawMetrics=function(n,i,l,h,d,p){p=Object.assign({},this.defaultRenderOptions,p),this.forEachGlyph(i,l,h,d,p,function(b,x,A,E){b.drawMetrics(n,x,A,E)})},Ut.prototype.getEnglishName=function(n){let i=(this.names.unicode||this.names.macintosh||this.names.windows)[n];if(i)return i.en},Ut.prototype.validate=function(){let n=[],i=this;function l(d,p){d||(console.warn(`[opentype.js] ${p}`),n.push(p))}function h(d){let p=i.getEnglishName(d);l(p&&p.trim().length>0,"No English "+d+" specified.")}if(h("fontFamily"),h("weightName"),h("manufacturer"),h("copyright"),h("version"),l(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let d=this.tables.colr.baseGlyphRecords,p=-1;for(let b=0;b<d.length;b++){let x=d[b].glyphID;if(l(p<d[b].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${x} comes after ${p}`),p>d[b].glyphID)break;p=x}}return n},Ut.prototype.toTables=function(){return Cf.fontToTable(this)},Ut.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Ut.prototype.toArrayBuffer=function(){let i=this.toTables().encode(),l=new ArrayBuffer(i.length),h=new Uint8Array(l);for(let d=0;d<i.length;d++)h[d]=i[d];return l},Ut.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Ut.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Ut.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Ut.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Ut.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var Ec=Ut;function Om(n,i){let l=new it.Parser(n,i),h=l.parseUShort(),d=l.parseUShort();h!==1&&console.warn(`Unsupported hvar table version ${h}.${d}`);let p=[h,d],b=l.parsePointer32(function(){return this.parseItemVariationStore()}),x=l.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),A=l.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),E=l.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:p,itemVariationStore:b,advanceWidth:x,lsb:A,rsb:E}}function Lm(){console.warn("Writing of hvar tables is not yet supported.")}var Mm={make:Lm,parse:Om},Dm=function(){return{coverage:this.parsePointer(U.coverage),attachPoints:this.parseList(U.pointer(U.uShortList))}},Fm=function(){var n=this.parseUShort();if(H.argument(n===1||n===2||n===3,"Unsupported CaretValue table version."),n===1)return{coordinate:this.parseShort()};if(n===2)return{pointindex:this.parseShort()};if(n===3)return{coordinate:this.parseShort()}},_m=function(){return this.parseList(U.pointer(Fm))},Nm=function(){return{coverage:this.parsePointer(U.coverage),ligGlyphs:this.parseList(U.pointer(_m))}},Um=function(){return this.parseUShort(),this.parseList(U.pointer(U.coverage))};function Bm(n,i){i=i||0;let l=new U(n,i),h=l.parseVersion(1);H.argument(h===1||h===1.2||h===1.3,"Unsupported GDEF table version.");var d={version:h,classDef:l.parsePointer(U.classDef),attachList:l.parsePointer(Dm),ligCaretList:l.parsePointer(Nm),markAttachClassDef:l.parsePointer(U.classDef)};return h>=1.2&&(d.markGlyphSets=l.parsePointer(Um)),d}var Gm={parse:Bm},_e=new Array(10);_e[1]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{posFormat:1,coverage:this.parsePointer(U.coverage),value:this.parseValueRecord()};if(l===2)return{posFormat:2,coverage:this.parsePointer(U.coverage),values:this.parseValueRecordList()};H.assert(!1,"0x"+i.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},_e[2]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();H.assert(l===1||l===2,"0x"+i.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let h=this.parsePointer(U.coverage),d=this.parseUShort(),p=this.parseUShort();if(l===1)return{posFormat:l,coverage:h,valueFormat1:d,valueFormat2:p,pairSets:this.parseList(U.pointer(U.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(d),value2:this.parseValueRecord(p)}})))};if(l===2){let b=this.parsePointer(U.classDef),x=this.parsePointer(U.classDef),A=this.parseUShort(),E=this.parseUShort();return{posFormat:l,coverage:h,valueFormat1:d,valueFormat2:p,classDef1:b,classDef2:x,class1Count:A,class2Count:E,classRecords:this.parseList(A,U.list(E,function(){return{value1:this.parseValueRecord(d),value2:this.parseValueRecord(p)}}))}}},_e[3]=function(){return{error:"GPOS Lookup 3 not supported"}},_e[4]=function(){return{error:"GPOS Lookup 4 not supported"}},_e[5]=function(){return{error:"GPOS Lookup 5 not supported"}},_e[6]=function(){return{error:"GPOS Lookup 6 not supported"}},_e[7]=function(){return{error:"GPOS Lookup 7 not supported"}},_e[8]=function(){return{error:"GPOS Lookup 8 not supported"}},_e[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Hm(n,i){i=i||0;let l=new U(n,i),h=l.parseVersion(1);return H.argument(h===1||h===1.1,"Unsupported GPOS table version "+h),h===1?{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(_e)}:{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(_e),variations:l.parseFeatureVariationsList()}}var jm=new Array(10);function Vm(n){return new Q.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Q.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new Q.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new Q.LookupList(n.lookups,jm)}])}var $m={parse:Hm,make:Vm};function zm(n){let i={};n.skip("uShort");let l=n.parseUShort();H.argument(l===0,"Unsupported kern sub-table version."),n.skip("uShort",2);let h=n.parseUShort();n.skip("uShort",3);for(let d=0;d<h;d+=1){let p=n.parseUShort(),b=n.parseUShort(),x=n.parseShort();i[p+","+b]=x}return i}function Wm(n){let i={};n.skip("uShort"),n.parseULong()>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");let d=n.parseUShort()&255;if(n.skip("uShort"),d===0){let p=n.parseUShort();n.skip("uShort",3);for(let b=0;b<p;b+=1){let x=n.parseUShort(),A=n.parseUShort(),E=n.parseShort();i[x+","+A]=E}}return i}function Xm(n,i){let l=new it.Parser(n,i),h=l.parseUShort();if(h===0)return zm(l);if(h===1)return Wm(l);throw new Error("Unsupported kern table version ("+h+").")}var Ym={parse:Xm};function Km(n,i,l,h){let d=new it.Parser(n,i),p=h?d.parseUShort:d.parseULong,b=[];for(let x=0;x<l+1;x+=1){let A=p.call(d);h&&(A*=2),b.push(A)}return b}var Zm={parse:Km};function wc(n,i){let l=[],h=12;for(let d=0;d<i;d+=1){let p=it.getTag(n,h),b=it.getULong(n,h+4),x=it.getULong(n,h+8),A=it.getULong(n,h+12);l.push({tag:p,checksum:b,offset:x,length:A,compression:!1}),h+=16}return l}function Qm(n,i){let l=[],h=44;for(let d=0;d<i;d+=1){let p=it.getTag(n,h),b=it.getULong(n,h+4),x=it.getULong(n,h+8),A=it.getULong(n,h+12),E;x<A?E="WOFF":E=!1,l.push({tag:p,offset:b,compression:E,compressedLength:x,length:A}),h+=20}return l}function Dt(n,i){if(i.compression==="WOFF"){let l=new Uint8Array(n.buffer,i.offset+2,i.compressedLength-2),h=new Uint8Array(i.length);if(St(l,h),h.byteLength!==i.length)throw new Error("Decompression error: "+i.tag+" decompressed length doesn't match recorded length");return{data:new DataView(h.buffer,0),offset:0}}else return{data:n,offset:i.offset}}function Jm(n,i={}){let l,h,d=new Ec({empty:!0});n.constructor!==ArrayBuffer&&(n=new Uint8Array(n).buffer);let p=new DataView(n,0),b,x=[],A=it.getTag(p,0);if(A==="\0\0\0"||A==="true"||A==="typ1")d.outlinesFormat="truetype",b=it.getUShort(p,4),x=wc(p,b);else if(A==="OTTO")d.outlinesFormat="cff",b=it.getUShort(p,4),x=wc(p,b);else if(A==="wOFF"){let yt=it.getTag(p,4);if(yt==="\0\0\0")d.outlinesFormat="truetype";else if(yt==="OTTO")d.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+A);b=it.getUShort(p,12),x=Qm(p,b)}else if(A==="wOF2"){let yt="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+yt)}else throw new Error("Unsupported OpenType signature "+A);let E,C,P,R,D,O,_,V,mt,ht,At,kt,_t,Bt,Gt,Jt,Ne,It;for(let yt=0;yt<b;yt+=1){let ot=x[yt],ut;switch(ot.tag){case"avar":_=ot;break;case"cmap":ut=Dt(p,ot),d.tables.cmap=tl.parse(ut.data,ut.offset),d.encoding=new nl(d.tables.cmap);break;case"cvt ":ut=Dt(p,ot),It=new it.Parser(ut.data,ut.offset),d.tables.cvt=It.parseShortList(ot.length/2);break;case"fvar":P=ot;break;case"STAT":R=ot;break;case"gvar":D=ot;break;case"cvar":O=ot;break;case"fpgm":ut=Dt(p,ot),It=new it.Parser(ut.data,ut.offset),d.tables.fpgm=It.parseByteList(ot.length);break;case"head":ut=Dt(p,ot),d.tables.head=vl.parse(ut.data,ut.offset),d.unitsPerEm=d.tables.head.unitsPerEm,l=d.tables.head.indexToLocFormat;break;case"hhea":ut=Dt(p,ot),d.tables.hhea=xl.parse(ut.data,ut.offset),d.ascender=d.tables.hhea.ascender,d.descender=d.tables.hhea.descender,d.numberOfHMetrics=d.tables.hhea.numberOfHMetrics;break;case"HVAR":_t=ot;break;case"hmtx":kt=ot;break;case"ltag":ut=Dt(p,ot),h=Al.parse(ut.data,ut.offset);break;case"COLR":ut=Dt(p,ot),d.tables.colr=kl.parse(ut.data,ut.offset);break;case"CPAL":ut=Dt(p,ot),d.tables.cpal=ol.parse(ut.data,ut.offset);break;case"maxp":ut=Dt(p,ot),d.tables.maxp=Tl.parse(ut.data,ut.offset),d.numGlyphs=d.tables.maxp.numGlyphs;break;case"name":Jt=ot;break;case"OS/2":ut=Dt(p,ot),d.tables.os2=wi.parse(ut.data,ut.offset);break;case"post":ut=Dt(p,ot),d.tables.post=Cl.parse(ut.data,ut.offset),d.glyphNames=new yi(d.tables.post);break;case"prep":ut=Dt(p,ot),It=new it.Parser(ut.data,ut.offset),d.tables.prep=It.parseByteList(ot.length);break;case"glyf":V=ot;break;case"loca":Gt=ot;break;case"CFF ":E=ot;break;case"CFF2":C=ot;break;case"kern":Bt=ot;break;case"GDEF":mt=ot;break;case"GPOS":ht=ot;break;case"GSUB":At=ot;break;case"meta":Ne=ot;break;case"gasp":try{ut=Dt(p,ot),d.tables.gasp=Ml.parse(ut.data,ut.offset)}catch(ie){console.warn("Failed to parse gasp table, skipping."),console.warn(ie)}break;case"SVG ":ut=Dt(p,ot),d.tables.svg=Dl.parse(ut.data,ut.offset);break;default:break}}let Ae=Dt(p,Jt);if(d.tables.name=qa.parse(Ae.data,Ae.offset,h),d.names=d.tables.name,V&&Gt){let yt=l===0,ot=Dt(p,Gt),ut=Zm.parse(ot.data,ot.offset,d.numGlyphs,yt),ie=Dt(p,V);d.glyphs=Yl.parse(ie.data,ie.offset,ut,d,i)}else if(E){let yt=Dt(p,E);Ci.parse(yt.data,yt.offset,d,i)}else if(C){let yt=Dt(p,C);Ci.parse(yt.data,yt.offset,d,i)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let he=Dt(p,kt);if(Sl.parse(d,he.data,he.offset,d.numberOfHMetrics,d.numGlyphs,d.glyphs,i),Kh(d,i),Bt){let yt=Dt(p,Bt);d.kerningPairs=Ym.parse(yt.data,yt.offset)}else d.kerningPairs={};if(mt){let yt=Dt(p,mt);d.tables.gdef=Gm.parse(yt.data,yt.offset)}if(ht){let yt=Dt(p,ht);d.tables.gpos=$m.parse(yt.data,yt.offset),d.position.init()}if(At){let yt=Dt(p,At);d.tables.gsub=El.parse(yt.data,yt.offset)}if(P){let yt=Dt(p,P);d.tables.fvar=Il.parse(yt.data,yt.offset,d.names)}if(R){let yt=Dt(p,R);d.tables.stat=Rl.parse(yt.data,yt.offset,d.tables.fvar)}if(D){P||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),V||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let yt=Dt(p,D);d.tables.gvar=Ll.parse(yt.data,yt.offset,d.tables.fvar,d.glyphs)}if(O){P||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),d.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),V||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let yt=Dt(p,O);d.tables.cvar=Ol.parse(yt.data,yt.offset,d.tables.fvar,d.tables.cvt||[])}if(_){P||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let yt=Dt(p,_);d.tables.avar=Pl.parse(yt.data,yt.offset,d.tables.fvar)}if(_t){P||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),kt||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let yt=Dt(p,_t);d.tables.hvar=Mm.parse(yt.data,yt.offset,d.tables.fvar)}if(Ne){let yt=Dt(p,Ne);d.tables.meta=wl.parse(yt.data,yt.offset),d.metas=d.tables.meta}return d.palettes=new $l(d),d}function qm(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function t0(){console.error('DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)')}return c(u)})();(function(o,t){typeof define=="function"&&define.amd?define(t):typeof ei=="object"&&ei.exports?ei.exports=t():o.opentype=t()})(typeof self<"u"?self:fu,()=>({...du,default:du}))});var h0="0.1.0",Oc=`https://staticimgly.com/imgly/gfonts/${h0}/dist`,os="ly.img.gfonts",as="ly.img.gfonts-fallbacks";async function d0(o){let t=o.asset.findAllSources();t.includes(os)||await o.asset.addLocalAssetSourceFromJSONURI(`${Oc}/${os}/content.json`),t.includes(as)||await o.asset.addLocalAssetSourceFromJSONURI(`${Oc}/${as}/content.json`)}async function f0(o,t,e){let s=await o.asset.findAssets(t,{page:0,query:e,perPage:1});if(!s||s.assets.length===0){let r=y0(e);for(let a of r)if(s=await o.asset.findAssets(t,{page:0,query:a,perPage:1}),s&&s.assets.length>0)break}return!s||s.assets.length===0?null:s.assets[0].payload?.typeface??null}async function p0(o,t){let e=await o.asset.findAssets(as,{page:0,query:t,perPage:1});if(!e||e.assets.length===0)return null;let s=e.assets[0],r=t.toLowerCase().trim(),a=(s.id??"").toLowerCase().trim(),c=(s.label??"").toLowerCase().trim();return a!==r&&c!==r?null:s.payload?.typeface??null}async function $i(o,t){let e=t.asset.findAllSources();if(!e.includes(os)||!e.includes(as))throw new Error(`The gfonts asset sources (${os}, ${as}) are not available. Call addGfontsAssetLibrary() first.`);let s,r=await p0(t,o.family);if(r?s=o.family:r=await f0(t,os,o.family),!r)return null;let a=r.fonts.find(c=>!!(o.style===void 0||c.style?.toLowerCase()===o.style.toLowerCase()&&(o.weight===void 0||m0(o.weight,c.weight))));return a?{typeface:r,font:a,substitutedFrom:s}:null}var g0={100:"thin",200:"extraLight",300:"light",regular:"normal",400:"normal",500:"medium",600:"semiBold",700:"bold",800:"extraBold",900:"heavy"};function Lc(o){let t=o.toLowerCase();return g0[t]??t}function m0(o,t){return t!=null&&Lc(o)===Lc(t)}function y0(o){let e=o.replace(/([A-Z])/g," $1").trim().split(" ");if(e.length<2)return[];let s=[];for(let r=e.length;r>0;r--){let a=e.slice(0,r).join(" ");s.push(a)}return s}function b0(o,t){return o.replace(/\{(\w+)\}/g,(e,s)=>{if(!(s in t))throw new Error(`Missing param "${s}" for warning template: ${o}`);return String(t[s])})}var ls=class{constructor(t){this.registry=t}messages=[];emit(t,e={}){let s=this.registry[t];this.messages.push({code:t,type:s.severity,message:b0(s.template,e),params:e})}getMessages(){return this.messages}};var Mc={DOC_PAGE_COUNT:{severity:"info",template:"PDF has {count} page(s)"},DOC_PAGE_BLOCK_COUNT:{severity:"info",template:"Page {page}: {imageCount} image, {vectorCount} vector, {textCount} text, {outlineCount} outline"},DOC_PAGE_ROTATION_DROPPED:{severity:"warning",template:"{prefix}PDF declares /Rotate {pageRotation}; the importer does not apply page rotation, so the imported page is in its un-rotated (native) orientation. Viewer-rendered output may differ from the source's display orientation."},BLOCK_KIND_UNKNOWN:{severity:"error",template:'An unknown block kind "{kind}" was encountered and was skipped.'},FONT_OPENTYPE_PARSE_FAILED:{severity:"warning",template:'{prefix}font "{fontName}" could not be parsed as OpenType{reason}. Glyph outlines will fall back to pdf.js raster paths \u2014 some shapes may render without stroke/anti-aliasing detail.'},FONT_CMAP_AUGMENTED:{severity:"info",template:'Font "{fontName}" character map was augmented (cmap patches={cmapPatches}, injected glyphs={injectedGlyphs}).'},FONT_CMAP_AUGMENT_FAILED:{severity:"warning",template:'Font "{fontName}" character map could not be augmented. Using the original font data \u2014 some glyphs may render incorrectly.'},FONT_RESOLVER_MISS:{severity:"warning",template:'Font "{fontFamily}" could not be resolved. The text was rendered as a vector outline.'},FONT_NOT_FOUND_IN_ASSETS:{severity:"warning",template:'Font "{fontFamily}" was not found in the asset library. The text was rendered as a vector outline.'},FONT_SUBSTITUTED:{severity:"info",template:'Font "{fontFamily}" was substituted with "{substitutedName}" from the asset library.'},FONT_REF_NOT_EXTRACTED:{severity:"error",template:'Text run references font "{fontRef}" which was not extracted. The text was skipped.'},TEXT_RENDER_MODE_SKIPPED:{severity:"warning",template:'Text item{pageTag}: skipped "{text}" \u2014 PDF text rendering mode {modeLabel}. This text paints no ink; for mode 7 it acts as a clipping mask for following images, an effect the importer does not currently reproduce.'},TEXT_OVERFLOW_AFTER_AUTOSIZE:{severity:"warning",template:'Text "{text}" did not fit after auto-sizing; it still overflows by {overflowLines} line(s). The text was kept; some content may be clipped.'},TEXT_CLIP_MODE_7_DROPPED:{severity:"warning",template:"{prefix}{label} at ({bbox}) {bboxSize} pt: dropped because the surrounding region was clipped by text in PDF render mode 7 (text-as-clipping-mask). The masked artwork cannot be reproduced as text-clipped content."},IMAGE_ENCODER_MISS:{severity:"warning",template:"{prefix}an image{idLabel} ({width}\xD7{height} raw pixels{kind}) could not be encoded ({reason}). The image was dropped from the imported design."},IMAGE_PDFJS_UNRESOLVED:{severity:"error",template:"{prefix}image placement {idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be resolved by pdf.js and was dropped."},IMAGE_NO_PIXELS:{severity:"warning",template:"An image element has no pixel data and was skipped."},IMAGE_FLIP_UNSUPPORTED:{severity:"warning",template:"Image flip could not be applied (engine version too old). The image will display without flip."},IMAGE_SKEW_DROPPED:{severity:"warning",template:"{prefix}an image{idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt has a skewed transform ctm={ctm}{residualStr} that cannot be represented. Placed axis-aligned \u2014 image content will appear un-skewed."},IMAGE_CLIPPED_NO_BYTES:{severity:"warning",template:"{prefix}a clipped image at {bbox} had no decoded bytes; the placement was dropped before combining clip shapes."},IMAGE_CLIP_UNUSABLE:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate, {disjointCount} disjoint from the image. The image was dropped."},IMAGE_CLIP_EMPTY_INTERSECTION:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) had an empty intersection. The image was dropped."},IMAGE_CLIP_COMBINE_FAILED:{severity:"error",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) could not be combined. The image was dropped from the imported design."},IMAGE_MASK_NO_FILL_COLOR:{severity:"warning",template:"{prefix}a stencil ImageMask paint (objId={objId}) had no current fill colour to composite with. The mask was dropped from the imported design."},IMAGE_MASK_COMPOSITE_FAIL:{severity:"warning",template:"{prefix}a stencil ImageMask (objId={objId}) at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be composited with the current fill colour (space={colourSpace}). The mask was dropped from the imported design."},IMAGE_MASK_GROUP_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectGroup batch of {count} stencil paints is not supported by the importer. The masks were dropped."},IMAGE_MASK_REPEAT_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectRepeat tiling {count} stencil paints is not supported by the importer. The masks were dropped."},CLIP_DEGENERATE_FALLBACK:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate (zero width or height). Falling back to the unclipped path."},CLIP_COMBINE_STROKE_ONLY:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no fill color (stroke-only) which cannot survive combine. Falling back to the unclipped path."},CLIP_COMBINE_FAILED:{severity:"warning",template:"{prefix}a vector path at {bbox} with {clipCount} clip path(s) could not be combined. Rendered without its clip \u2014 some content may extend beyond the intended mask."},CLIP_COMBINE_TOO_FEW_INPUTS:{severity:"warning",template:"{prefix}clip combine was called with {inputCount} input block(s) (need at least 2). The owner block was emitted without its clips."},CLIP_COMBINE_NOT_COMBINABLE:{severity:"warning",template:"{prefix}clip combine rejected {inputCount} input block(s) as not combinable (nested or incompatible shapes). The owner block was emitted without its clips."},CLIP_COMBINE_THREW:{severity:"warning",template:"{prefix}clip combine of {inputCount} input block(s) failed ({reason}). The owner block was emitted without its clips."},COLOR_TYPE_UNSUPPORTED:{severity:"warning",template:'{prefix}{subject}color of type "{colorType}" is not supported. Rendered as black.'},COLOR_SPACE_UNSUPPORTED:{severity:"warning",template:'{prefix}{elementLabel}color space "{space}" ({color}) at {bbox} is not supported. Rendered as black.'},SPOT_COLOR_NO_ALTERNATE:{severity:"warning",template:'Spot color "{name}" has no resolvable alternate; leaving at engine default.'},SPOT_COLOR_REGISTER_FAILED:{severity:"warning",template:'Failed to register spot color "{name}": {error}'},BLEND_MODE_UNSUPPORTED:{severity:"warning",template:'Blend mode "{mode}" is not supported. Using "Normal" as the default.'},SHADING_UNRESOLVED:{severity:"error",template:"{prefix}gradient shading could not be resolved by pdf.js and was removed. The painted region will be missing in the imported scene."},SHADING_MESH_UNSUPPORTED:{severity:"warning",template:"{prefix}gradient shading uses an unsupported mesh variant (PDF ShadingType 4\u20137). The region was dropped because mesh gradients can't be represented as a CE.SDK gradient fill."},SHADING_UNKNOWN_IR_TAG:{severity:"error",template:'{prefix}gradient shading reported unknown IR tag "{tag}" and was dropped.'},SHADING_INSUFFICIENT_STOPS:{severity:"warning",template:"{prefix}gradient shading produced fewer than two color stops and was dropped."},SHADING_NO_CLIP_FALLBACK_BBOX:{severity:"info",template:"{prefix}gradient shading was painted without an active clip path. Falling back to the shading /BBox; if this scene shows gradient bands outside the intended shape, file a bug."},SHADING_CLIP_DEGENERATE:{severity:"warning",template:"{prefix}gradient shading clip path was degenerate and the region was dropped."},SHADING_RADIAL_FOCAL_DROPPED:{severity:"info",template:"{prefix}radial gradient declared a non-zero inner radius (PDF Shading Type 3 focal point). It was approximated as a centered radial; the focal offset was dropped."},SHADING_UNKNOWN_RADIAL_SUBTYPE:{severity:"error",template:'{prefix}gradient shading reported unknown RadialAxial subtype "{kind}" and was dropped.'},SHADING_NO_PATTERN_REF:{severity:"error",template:"{prefix}gradient shading was emitted without a pattern reference and was dropped."}};Ta();var iu=typeof document<"u";async function On(o,t){if(iu){let r=document.createElement("canvas");return r.width=o,r.height=t,{canvas:r,ImageData:globalThis.ImageData}}let{createCanvas:e,ImageData:s}=await import("@napi-rs/canvas");return{canvas:e(o,t),ImageData:s}}async function ti(o){if(iu){let t=await new Promise(e=>o.toBlob(e,"image/png"));return t?new Uint8Array(await t.arrayBuffer()):null}return new Uint8Array(o.toBuffer("image/png"))}async function ou(o){let{canvas:t}=await On(1,1),e=t.getContext("2d"),s=o.view,r=o.getViewport({scale:1/Math.max(s[2],1)});try{await o.render({canvasContext:e,viewport:r,intent:"any",annotationMode:Jr.DISABLE}).promise}catch{}return{opList:await o.getOperatorList({annotationMode:Jr.DISABLE})}}function Ca(o,t){return au(o.objs,t)}function Ea(o,t){return au(o.commonObjs,t)}function au(o,t){return t==null?Promise.resolve(null):new Promise(e=>{let s=!1,r=c=>{s||(s=!0,e(c))};try{o.get(t,c=>r(c))}catch{r(null);return}setTimeout(()=>r(null),1e4).unref?.()})}async function lu(o,t,e={}){if(o==null)return null;let s=o.width,r=o.height;if(!s||!r)return qr("missing width/height",o,t,e),null;let{canvas:a,ImageData:c}=await On(s,r),u=a.getContext("2d");if(o.bitmap)try{u.drawImage(o.bitmap,0,0)}catch(f){let g=f&&typeof f=="object"&&"message"in f?String(f.message):String(f);return qr(`bitmap drawImage failed: ${g}`,o,t,e),null}else if(o.data){let f=ib(o);if(!f)return qr(`unknown data kind=${o.kind}`,o,t,e),null;let g=new c(f,s,r);u.putImageData(g,0,0)}else return qr("no bitmap and no data",o,t,e),null;return ti(a)}async function cu(o,t,e,s={}){if(o==null)return null;let r=o.width,a=o.height;if(!r||!a)return null;let c=wa(t);if(c==null)return null;let[u,f,g]=c,m=await rb(o);if(m==null)return null;let{canvas:y,ImageData:v}=await On(r,a),S=y.getContext("2d"),T=new Uint8ClampedArray(r*a*4);for(let I=0;I<r*a;I++)T[I*4]=u,T[I*4+1]=f,T[I*4+2]=g,T[I*4+3]=m[I];let w=new v(T,r,a);return S.putImageData(w,0,0),ti(y)}async function rb(o){let t=o.width,e=o.height,s=t*e;if(o.data){let{kind:r,data:a}=o;if(r===1){if(a.length>=s)return new Uint8ClampedArray(a.buffer,a.byteOffset,s);let c=new Uint8ClampedArray(s),u=Math.ceil(t/8);for(let f=0;f<e;f++)for(let g=0;g<t;g++){let y=a[f*u+(g>>3)]>>7-(g&7)&1;c[f*t+g]=y?255:0}return c}if(r===2){let c=new Uint8ClampedArray(s);for(let u=0;u<s;u++)c[u]=Math.round(a[u*3]*.299+a[u*3+1]*.587+a[u*3+2]*.114);return c}if(r===3){let c=new Uint8ClampedArray(s);for(let u=0;u<s;u++)c[u]=Math.round(a[u*4]*.299+a[u*4+1]*.587+a[u*4+2]*.114);return c}return null}if(o.bitmap){let{canvas:r}=await On(t,e),a=r.getContext("2d");try{a.drawImage(o.bitmap,0,0)}catch{return null}let u=a.getImageData(0,0,t,e).data,f=new Uint8ClampedArray(s);for(let g=0;g<s;g++)f[g]=Math.round(u[g*4]*.299+u[g*4+1]*.587+u[g*4+2]*.114);return f}return null}function wa(o){if(!o||typeof o!="object")return null;let{space:t,values:e}=o;if(t==="rgb"&&Array.isArray(e)&&e.length>=3)return[Math.round(mn(e[0])*255),Math.round(mn(e[1])*255),Math.round(mn(e[2])*255)];if(t==="gray"&&Array.isArray(e)&&e.length>=1){let s=Math.round(mn(e[0])*255);return[s,s,s]}if(t==="cmyk"&&Array.isArray(e)&&e.length>=4){let s=mn(e[0]),r=mn(e[1]),a=mn(e[2]),c=mn(e[3]);return[Math.round(255*(1-s)*(1-c)),Math.round(255*(1-r)*(1-c)),Math.round(255*(1-a)*(1-c))]}return null}function mn(o){return typeof o!="number"||Number.isNaN(o)||o<0?0:o>1?1:o}function qr(o,t,e,s={}){if(!e?.emit)return;let r=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",a=s.objId?` objId="${s.objId}"`:"",c=t?.width??"?",u=t?.height??"?",f=t?.kind!=null?`, kind=${t.kind}`:"";e.emit("IMAGE_ENCODER_MISS",{prefix:r,idLabel:a,width:c,height:u,kind:f,reason:o,page:s.pageIndex,objId:s.objId??null})}function ib(o){let t=o.width,e=o.height,s=o.kind,r=o.data,a=t*e,c=new Uint8ClampedArray(a*4);if(s===1){if(r.length>=a){for(let f=0;f<a;f++){let g=r[f];c[f*4]=g,c[f*4+1]=g,c[f*4+2]=g,c[f*4+3]=255}return c}let u=Math.ceil(t/8);for(let f=0;f<e;f++)for(let g=0;g<t;g++){let v=r[f*u+(g>>3)]>>7-(g&7)&1?255:0,S=(f*t+g)*4;c[S]=v,c[S+1]=v,c[S+2]=v,c[S+3]=255}return c}if(s===2){for(let u=0;u<a;u++)c[u*4]=r[u*3],c[u*4+1]=r[u*3+1],c[u*4+2]=r[u*3+2],c[u*4+3]=255;return c}return s===3?new Uint8ClampedArray(r.buffer,r.byteOffset,r.byteLength):null}async function ob(o){if(o==null)return null;let{width:t,height:e}=o;if(!t||!e)return null;let s=t*e;if(o.data){let r=new Uint8ClampedArray(s),a=Math.ceil(t/8);for(let c=0;c<e;c++)for(let u=0;u<t;u++){let g=o.data[c*a+(u>>3)]>>7-(u&7)&1;r[c*t+u]=g?0:255}return r}if(o.bitmap){let{canvas:r}=await On(t,e),a=r.getContext("2d");try{a.drawImage(o.bitmap,0,0)}catch{return null}let c=a.getImageData(0,0,t,e),u=new Uint8ClampedArray(s);for(let f=0;f<s;f++)u[f]=c.data[f*4+3];return u}return null}async function uu(o,t,e,s={}){if(o==null)return null;let r=o.width,a=o.height;if(!r||!a)return null;let c=wa(t);if(c==null)return null;let[u,f,g]=c,m=await ob(o);if(m==null)return null;let{canvas:y,ImageData:v}=await On(r,a),S=y.getContext("2d"),T=new Uint8ClampedArray(r*a*4);for(let I=0;I<r*a;I++)T[I*4]=u,T[I*4+1]=f,T[I*4+2]=g,T[I*4+3]=m[I];let w=new v(T,r,a);return S.putImageData(w,0,0),ti(y)}var ab=/^[A-Z]{6}\+/,lb=["compressed","condensed","extended","narrow","wide","cond","comp"],cb=["italic","oblique"],hu={bd:700,lt:300,md:500,rg:400,bk:900,blk:900,hv:900,th:100,hl:100};function Rs(o){let t=o.replace(ab,""),e=t.lastIndexOf("-"),s=t.lastIndexOf(","),r=Math.max(e,s);if(r<0)return{fullName:t,family:t,weight:null,style:"normal",styleSuffix:null};let a=t.slice(0,r),c=t.slice(r+1),u=ub(c);return u?{fullName:t,family:a,weight:u.weight,style:u.style,styleSuffix:c}:{fullName:t,family:t,weight:null,style:"normal",styleSuffix:null}}function ub(o){let t=o.toLowerCase(),e=!1,s="normal";for(let a of cb)if(t.includes(a)){s="italic",e=!0;break}for(let a of lb)if(t.includes(a)){e=!0;break}let r=hb(t);return r!==null&&(e=!0),e?{weight:r,style:s}:null}function hb(o){return o.includes("extrabold")||o.includes("ultrabold")?800:o.includes("semibold")||o.includes("demibold")?600:o.includes("extralight")||o.includes("ultralight")?200:o.includes("thin")||o.includes("hairline")?100:o.includes("light")?300:o.includes("medium")?500:o.includes("bold")?700:o.includes("black")||o.includes("heavy")?900:o.includes("regular")||o==="normal"||o.includes("book")||o.includes("roman")?400:Object.prototype.hasOwnProperty.call(hu,o)?hu[o]:null}var db=/^[A-Z]{6}\+/;async function pu(o,t){if(!o||!o.data||o.data.length===0)return null;let e=Rs(o.name??"");if(!e.fullName)return null;let s=o.loadedName?`${e.fullName}#${o.loadedName}`:e.fullName,r=o._parsed??null,a=r?.names,c=(a?.fontFamily?.en?.trim()||a?.fontFamily?.und?.trim()||e.family).replace(db,""),u=r?.tables?.os2,f=e.weight??u?.usWeightClass??(o.black?900:o.bold?700:400),g=o.italic?"italic":e.style,m=o.data instanceof Uint8Array?o.data:new Uint8Array(o.data),y=await mb(r,m,o.toFontChar??null,t),v=fb(y);return{postScriptName:s,family:c,weight:f,style:g,data:y,mimeType:v}}function gu(o,t){if(!Ia(o)||!t||t.length===0)return!1;for(let e of t){let s=e.unicode;if(!s||pb(s))return!1}return!0}function Ia(o){return!(!o||o.isType3Font||!o.data||o.data.length===0||!o._parsed)}function Ra(o){let t=Number(o)||400;return t<=150?"thin":t<=250?"extraLight":t<=350?"light":t<=450?"normal":t<=550?"medium":t<=650?"semiBold":t<=750?"bold":t<=850?"extraBold":"heavy"}function mu(o){let t=Rs(o?.name??""),e=o?._parsed?.tables?.os2,s=t.weight??e?.usWeightClass??(o?.black?900:o?.bold?700:400);return{style:o?.italic?"italic":t.style,weight:Ra(s)}}function fb(o){return o.length>=4&&o[0]===79&&o[1]===84&&o[2]===84&&o[3]===79?"font/otf":"font/ttf"}function pb(o){for(let t of o){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}var gb=[32,160];async function mb(o,t,e,s){if(!o)return t;let r=ni.get(o);if(r)return r;try{let{default:a}=await Promise.resolve().then(()=>Pc(ka(),1)),c=yb(o,e);for(let{glyphIndex:w,unicode:I}of c){let k=o.glyphs.get(w);if(!k)continue;let L=k;L.unicodes||(L.unicodes=L.unicode!=null?[L.unicode]:[]),L.unicodes.includes(I)||L.unicodes.push(I)}let u=[],f=o.unitsPerEm||1e3,g=Math.round(f*.25),m=o.glyphs;for(let w of gb){if(vb(o,w))continue;let I=m.length,k=new a.Glyph({name:w===32?"space":`uni${w.toString(16).toUpperCase()}`,unicode:w,advanceWidth:g,path:new a.Path});k.index=I,m.glyphs[I]=k,m.length=I+1,u.push(w)}if(c.length===0&&u.length===0)return ni.set(o,t),t;for(let w=0;w<m.length;w+=1){let I=o.glyphs.get(w);I&&(typeof I.name!="string"||I.name==="")&&(I.name=w===0?".notdef":`gid${w}`)}o.numGlyphs=m.length;let y=o.toArrayBuffer(),S=a.parse(y).toArrayBuffer(),T=new Uint8Array(S);if(ni.set(o,T),bb()){let w=o.names?.postScriptName?.en??"<unknown>",I=u.map(k=>"U+"+k.toString(16).toUpperCase()).join(",")||"none";s?.emit?.("FONT_CMAP_AUGMENTED",{fontName:w,cmapPatches:c.length,injectedGlyphs:I})}return T}catch(a){let c=o.names?.postScriptName?.en??"<unknown>",u=a&&typeof a=="object"&&"message"in a?String(a.message):String(a);return s?.emit?.("FONT_CMAP_AUGMENT_FAILED",{fontName:c,error:u}),ni.set(o,t),t}}function yb(o,t){let e=[];if(!t)return e;let r=o.tables?.cmap?.glyphIndexMap;if(!r)return e;for(let[a,c]of Object.entries(t)){let u=Number(a);if(!Number.isFinite(u)||u===c||r[u])continue;let f=r[c];f&&e.push({unicode:u,glyphIndex:f})}return e}var ni=new WeakMap;function bb(){return!!(typeof process<"u"&&process.env?.PDF2CESDK_DEBUG_FONTS||typeof globalThis<"u"&&globalThis.PDF2CESDK_DEBUG_FONTS)}function vb(o,t){try{let e=o.charToGlyphIndex(String.fromCodePoint(t));if(!e)return!1;let s=o.glyphs.get(e);return!!s&&(s.advanceWidth??0)>0}catch{return!1}}function xu(o,t,e,s){if(!o||o.length===0)return[];let r=o.map(u=>Sb(u,t,e,s)),a=[],c=null;for(let u of r)if(u){if(c&&xb(c,u)){c.items.push(u);continue}c&&a.push(yu(c,t)),c={items:[u]}}return c&&a.push(yu(c,t)),a}function xb(o,t){let e=o.items[o.items.length-1];return!(t.fontObjId!==e.fontObjId||Math.abs(t.fontSizePt-e.fontSizePt)>1||Math.abs(t.baselineYPt-e.baselineYPt)>2||t.originXPt-(e.originXPt+e.advancePt)>.5*t.fontSizePt)}function Sb(o,t,e,s){let r=t[o.fontObjId];if(!r)return null;let a=vu(e,o.textMatrix),c=[o.fontSize,0,0,o.fontSize,0,0],u=vu(a,c),f=Math.hypot(u[2],u[3]),g=a[4],m=s-a[5],y=Ab(o,r,f);return{glyph:o,fontObjId:o.fontObjId,fontSizePt:f,originXPt:g,baselineYPt:m,advancePt:y}}function Ab(o,t,e){let s=t._parsed;if(s&&o.unicode)try{let r=s.charToGlyph?.(o.unicode);if(r&&r.advanceWidth&&s.unitsPerEm)return r.advanceWidth/s.unitsPerEm*e}catch{}return .5*e}function yu(o,t){let e=o.items,s=e[0],r=e[e.length-1],c=t[s.fontObjId]?._parsed,u=bu(e.map(k=>k.fontSizePt)),f=c?.unitsPerEm??1e3,g=c?.ascender?c.ascender/f*u:.8*u,m=c?.descender?Math.abs(c.descender/f)*u:.2*u,y=s.originXPt,v=bu(e.map(k=>k.baselineYPt)),T=r.originXPt+r.advancePt-y+.05*u*e.length,w="",I=null;for(let k of e){let L=k.glyph.unicode??"";if(I){let M=I.originXPt+I.advancePt;k.originXPt-M>.2*k.fontSizePt&&!L.startsWith(" ")&&!w.endsWith(" ")&&(w+=" ")}w+=L,I=k}return{glyphs:e.map(k=>k.glyph),fontObjId:s.fontObjId,fontSizePt:u,originXPt:y,baselineYPt:v,widthPt:T,ascenderPt:g,descenderPt:m,text:w}}function bu(o){return o.length===0?0:o.reduce((t,e)=>t+e,0)/o.length}function vu(o,t){let[e,s,r,a,c,u]=o,[f,g,m,y,v,S]=t;return[e*f+r*g,s*f+a*g,e*m+r*y,s*m+a*y,e*v+r*S+c,s*v+a*S+u]}function Ht(o){return Number.isFinite(o)?o.toFixed(1):String(o)}function Oe(o){if(!o)return"(unknown position)";let t=typeof o.x=="number"?Ht(o.x):"?",e=typeof o.y=="number"?Ht(o.y):"?",s=typeof o.width=="number"?Ht(o.width):"?",r=typeof o.height=="number"?Ht(o.height):"?";return`(${t}, ${e}) ${s}\xD7${r} pt`}function Su(o){if(!o||o.length<6)return"[invalid]";let[t,e,s,r,a,c]=o;return`[a=${Ht(t)}, b=${Ht(e)}, c=${Ht(s)}, d=${Ht(r)}, e=${Ht(a)}, f=${Ht(c)}]`}function Au(o){if(o==null)return"none";if(typeof o!="object")return String(o);let t=o;if("type"in t)switch(t.type){case"rgb":return`rgb(${ge(t.r)}, ${ge(t.g)}, ${ge(t.b)})`;case"cmyk":return`cmyk(${ge(t.c)}, ${ge(t.m)}, ${ge(t.y)}, ${ge(t.k)})`;case"spot":{let e=typeof t.name=="string"?`"${t.name}"`:"(unnamed)",s=typeof t.tint=="number"?`, tint=${ge(t.tint)}`:"",r=t.fallback_rgb,a=Array.isArray(r)?`, fallback=rgb(${ge(r[0])}, ${ge(r[1])}, ${ge(r[2])})`:", no fallback";return`spot ${e}${s}${a}`}default:return`type="${String(t.type)}"`}if("space"in t&&Array.isArray(t.values)){let e=t.values.map(s=>ge(s)).join(", ");return`${String(t.space)}(${e})`}return"r"in t&&"g"in t&&"b"in t?`rgb(${ge(t.r)}, ${ge(t.g)}, ${ge(t.b)})`:"(opaque)"}function ge(o){return Number.isFinite(o)?o.toFixed(2):String(o)}function Pa(){return[]}function Tu(o,t,e,s){return[...o,{path:t,fillRule:e,ctm:s.slice()}]}function Cu(o){return o.slice()}function Eu(o){return o.pop()??Pa()}function Ps(o){return o.length===0}var Ln=Object.freeze({moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19}),u1=Object.freeze([1,0,0,1,0,0]);function Tb(o,t,e){let s=o.ops??[],r=o.coords??[],a=[],c=[],u=0,f=null,[g,m,y,v,S,T]=t,w=(I,k)=>[g*I+y*k+S,e-(m*I+v*k+T)];for(let I=0;I<s.length;I++)switch(s[I]){case Ln.rectangle:{let k=r[u++],L=r[u++],M=r[u++],N=r[u++],F=w(k,L),B=w(k+M,L),G=w(k+M,L+N),$=w(k,L+N);a.push({cmd:"M",pts:[F]}),a.push({cmd:"L",pts:[B]}),a.push({cmd:"L",pts:[G]}),a.push({cmd:"L",pts:[$]}),a.push({cmd:"Z"}),c.push(F,B,G,$);break}case Ln.moveTo:{let k=w(r[u++],r[u++]);a.push({cmd:"M",pts:[k]}),c.push(k),f=k;break}case Ln.lineTo:{let k=w(r[u++],r[u++]);a.push({cmd:"L",pts:[k]}),c.push(k),f=k;break}case Ln.curveTo:{let k=w(r[u++],r[u++]),L=w(r[u++],r[u++]),M=w(r[u++],r[u++]);a.push({cmd:"C",pts:[k,L,M]}),c.push(k,L,M),f=M;break}case Ln.curveTo2:{let k=w(r[u++],r[u++]),L=w(r[u++],r[u++]),M=f??k;a.push({cmd:"C",pts:[M,k,L]}),c.push(k,L),f=L;break}case Ln.curveTo3:{let k=w(r[u++],r[u++]),L=w(r[u++],r[u++]);a.push({cmd:"C",pts:[k,L,L]}),c.push(k,L),f=L;break}case Ln.closePath:a.push({cmd:"Z"});break;default:break}return{cmds:a,devPoints:c}}function Cb(o){if(o.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,e=1/0,s=-1/0,r=-1/0;for(let[a,c]of o)a<t&&(t=a),c<e&&(e=c),a>s&&(s=a),c>r&&(r=c);return{x:t,y:e,width:s-t,height:r-e}}function Eb(o,t,e){let s=a=>`${Math.round(a*100)/100}`,r=[];for(let a of o){if(a.cmd==="Z"){r.push("Z");continue}let c=a.pts.map(([u,f])=>`${s(u-t)} ${s(f-e)}`).join(" ");r.push(`${a.cmd} ${c}`)}return r.join(" ")}function si(o,t,e){let{cmds:s,devPoints:r}=Tb(o,t,e);if(r.length===0)return null;let a=Cb(r);return{...a,d:Eb(s,a.x,a.y),cmds:s,devPoints:r}}function Mn(o,t){let e=[];for(let s of o){let r=wb(s,t);r&&e.push(r)}return e}function wb(o,t){let e=si(o.path,o.ctm,t.heightPt);return!e||e.width<=0&&e.height<=0?null:{d:e.d,x:e.x,y:e.y,width:e.width,height:e.height,fillRule:o.fillRule}}function wu({shadingIR:o,ctm:t,clipEntry:e,remainingClips:s,pageBox:r,opacity:a,blendMode:c,logger:u,pageIndex:f}){let g=Array.isArray(o)?o[0]:null,m=f!=null?`Page ${f}: `:"";if(g==="Dummy"||g==null)return u?.emit?.("SHADING_UNRESOLVED",{prefix:m,page:f}),null;if(g==="Mesh")return u?.emit?.("SHADING_MESH_UNSUPPORTED",{prefix:m,page:f}),null;if(g!=="RadialAxial")return u?.emit?.("SHADING_UNKNOWN_IR_TAG",{prefix:m,tag:String(g),page:f}),null;let y=o,v=y[1],S=y[3],T=y[4],w=y[5],I=y[6],k=y[7],L=kb(S);if(L.length<2)return u?.emit?.("SHADING_INSUFFICIENT_STOPS",{prefix:m,page:f}),null;e==null&&u?.emit?.("SHADING_NO_CLIP_FALLBACK_BBOX",{prefix:m,page:f});let M=e?si(e.path,e.ctm,r.heightPt):null;if(!M||M.width<=0&&M.height<=0)return u?.emit?.("SHADING_CLIP_DEGENERATE",{prefix:m,page:f}),null;let N={kind:"vector-path",x:M.x,y:M.y,width:M.width,height:M.height,d:M.d,fill:null,stroke:null,strokeWidth:0,fillRule:e?.fillRule??"nonzero",opacity:1,blendMode:c??void 0};if(v==="axial"){let F=Oa(T,t,r.heightPt),B=Oa(w,t,r.heightPt);N.fill={kind:"linearGradient",start:F,end:B,stops:L}}else if(v==="radial"){typeof I=="number"&&I>.001&&u?.emit?.("SHADING_RADIAL_FOCAL_DROPPED",{prefix:m,page:f,innerRadius:I});let F=Oa(w,t,r.heightPt),B=Pb(t);N.fill={kind:"radialGradient",center:F,radius:Math.max(.001,Math.abs((k??0)*B)),stops:L}}else return u?.emit?.("SHADING_UNKNOWN_RADIAL_SUBTYPE",{prefix:m,kind:String(v),page:f}),null;if(a!=null&&a<1&&(N.opacity=a),s&&s.length>0){let F=Mn(s,r);F.length>0&&(N.clips=F)}return N}function kb(o){if(!Array.isArray(o))return[];let t=[];for(let e of o){if(!Array.isArray(e)||e.length<2)continue;let s=Rb(e[0]),r=Ib(e[1]);if(!r)continue;let a={space:"rgb",values:r};t.push({offset:s,color:a})}return t}function Ib(o){if(typeof o!="string")return null;if(o==="transparent")return[1,1,1];let t=/^#([0-9a-fA-F]{6})$/.exec(o.trim());if(!t)return null;let e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}function Rb(o){return typeof o!="number"||!Number.isFinite(o)||o<0?0:o>1?1:o}function Oa(o,t,e){let s=Array.isArray(o)?o[0]:0,r=Array.isArray(o)?o[1]:0,[a,c,u,f,g,m]=t;return{x:a*s+u*r+g,y:e-(c*s+f*r+m)}}function Pb([o,t,e,s]){return Math.sqrt(Math.abs(o*s-t*e))}var rt={setLineWidth:2,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,beginText:31,endText:32,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,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColorN:53,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,paintImageXObject:85,paintInlineImageXObject:86,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,shadingFill:62},ri=[1,0,0,1,0,0];async function Du(o,t,e={}){let s=e.textMode??"outline",r=e.docFonts??new Map,a=e.logger,c=e.pageIndex,{opList:u}=await ou(o),f=await Ob(o,u,{logger:a,pageIndex:c}),g=o.colorSpaceResources??{},{out:m,colorSnapshots:y}=await Mb(u,t,o,f,{textMode:s,docFonts:r,logger:a,pageIndex:c,colorSpaceResources:g});return{out:m,colorSnapshots:y,finalize:()=>Wb(Db(m),t)}}async function Ob(o,t,e={}){let s=new Set,r=t.fnArray,a=t.argsArray;for(let u=0;u<r.length;u++)r[u]===rt.setFont&&s.add(a[u][0]);let c={};for(let u of s){let f=await Ea(o,u);if(f&&!f.isType3Font&&f.data){let g=f.name||f.loadedName||f.fallbackName||`(font object ${u})`;f._parsed=await Lb(f.data,g,e)}c[u]=f}return c}async function Lb(o,t,e={}){try{let{default:s}=await Promise.resolve().then(()=>Pc(ka(),1)),r=o instanceof Uint8Array?o:new Uint8Array(o),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return s.parse(a)}catch(s){let r=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",a=s&&typeof s=="object"&&"message"in s?String(s.message):null,c=a?` (${a})`:"";return e.logger?.emit?.("FONT_OPENTYPE_PARSE_FAILED",{prefix:r,fontName:t,reason:c,page:e.pageIndex,error:a}),null}}async function Mb(o,t,e,s,r){let a=o.fnArray,c=o.argsArray,u=[],f=r?.colorSpaceResources??{},g=[],m=t.originShiftPt??{x:0,y:0},y=Mu(m),v=[],S=null,T=Pa(),w=[],I=null,k=[],L=[],M=null,N=[],F=[],B=[],G=[],$=0,z=!1,J=[],et=()=>J.some(X=>X.suppressing),nt=null,xt=null,vt=null,St=X=>{let gt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.log?.(`${gt}${X}`,"warning")},W=X=>{if(!Array.isArray(X)||X.length<4)return"(unknown bbox)";let[gt,Z,tt,ct]=X,st=gt/72,Y=(t.heightPt-ct)/72,j=Math.abs(tt-gt)/72,H=Math.abs(ct-Z)/72;return`(${st.toFixed(2)} in, ${Y.toFixed(2)} in) ${j.toFixed(2)}\xD7${H.toFixed(2)} in`},K=()=>{if(y.blendMode!=null&&y.blendMode!=="source-over")return y.blendMode;for(let X=N.length-1;X>=0;X--){let gt=N[X];if(gt!=null&>!=="source-over")return gt}return y.blendMode},pt=()=>{if(y.fillAlpha!=null&&y.fillAlpha<1)return y.fillAlpha;for(let X=F.length-1;X>=0;X--){let gt=F[X];if(gt!=null&><1)return gt}return y.fillAlpha},ft=()=>{M&&M.glyphs.length>0?Fb(M,s,t,r):M&&Dn(M.placeholder),M=null};for(let X=0;X<a.length;X++){let gt=a[X],Z=c[X];switch(gt){case rt.save:v.push(y),y=$b(y),w.push(Cu(T));break;case rt.restore:y=v.pop()??Mu(m),T=Eu(w);break;case rt.paintFormXObjectBegin:N.push(y.blendMode),F.push(y.fillAlpha),B.push({blendMode:y.blendMode,fillAlpha:y.fillAlpha});break;case rt.paintFormXObjectEnd:{N.pop(),F.pop();let tt=B.pop();tt&&(y.blendMode=tt.blendMode,tt.fillAlpha!=null&&(y.fillAlpha=tt.fillAlpha));break}case rt.beginGroup:{let tt=Z?.[0]??{},ct=tt.smask!=null;G.push(ct),ct&&$++,J.push({candidate:z&&!ct,suppressing:!1}),ct&&tt.smask?.subtype==="Luminosity"&&(nt={groupBbox:Array.isArray(tt.bbox)?tt.bbox.slice():null,captured:null,abort:!1,abortReason:null}),z&&!ct&&xt!=null&&vt==null&&(vt={mask:xt,color:y.fillColor,formBbox:Array.isArray(tt.bbox)?tt.bbox.slice():null,alpha:null},xt=null),z=!1;break}case rt.endGroup:{let tt=G.pop();tt&&$--;let ct=J.pop();if(tt&&nt!=null&&(nt.abort?St(`a luminosity SMask group at ${W(nt.groupBbox)} ${nt.abortReason}. The shadow was dropped from the imported design.`):nt.captured==null?St(`a luminosity SMask group at ${W(nt.groupBbox)} has no grayscale image content. The shadow was dropped from the imported design.`):xt={groupBbox:nt.groupBbox,captured:nt.captured},nt=null),ct&&ct.candidate&&vt!=null){let{mask:st,color:Y,formBbox:j,alpha:H}=vt;if(vt=null,!Y||Y.space!=="rgb"&&Y.space!=="cmyk"&&Y.space!=="gray")St(`a luminosity SMask at ${W(j)} modulates a non-solid fill (${Y?.space??"unknown"}); compositing isn't supported. The shadow was dropped from the imported design.`);else{let Tt={kind:"image",_placeholderIndex:u.length};u.push(Tt);let Ot=H??1;k.push({placeholder:Tt,objId:st.captured.objId,inline:null,ctm:st.captured.ctm,opacity:Ot,blendMode:null,clips:null,compositeWith:Y})}}break}case rt.transform:y.ctm=je(y.ctm,Z);break;case rt.setLineWidth:y.lineWidth=Z[0];break;case rt.setFillRGBColor:y.fillColor=Ru(Z);break;case rt.setStrokeRGBColor:y.strokeColor=Ru(Z);break;case rt.setFillCMYKColor:y.fillColor={space:"cmyk",values:[Z[0],Z[1],Z[2],Z[3]]};break;case rt.setStrokeCMYKColor:y.strokeColor={space:"cmyk",values:[Z[0],Z[1],Z[2],Z[3]]};break;case rt.setFillGray:y.fillColor={space:"gray",values:[Z[0]]};break;case rt.setStrokeGray:y.strokeColor={space:"gray",values:[Z[0]]};break;case rt.setFillColorSpace:y.fillColorSpaceName=Z?.[0]??null;break;case rt.setStrokeColorSpace:y.strokeColorSpaceName=Z?.[0]??null;break;case rt.setFillColorN:{let{key:tt,components:ct}=Pu(Z);y.fillColor=Ou(tt??y.fillColorSpaceName,ct,f,y.fillColor);break}case rt.setStrokeColorN:{let{key:tt,components:ct}=Pu(Z);y.strokeColor=Ou(tt??y.strokeColorSpaceName,ct,f,y.strokeColor);break}case rt.setGState:{let tt=!1,ct=!1,st=null;for(let[Y,j]of Z[0]??[])Y==="BM"&&j==="multiply"&&(tt=!0),Y==="ca"&&typeof j=="number"&&(j<1&&(ct=!0),st=j);if(tt&&ct&&J.length>0){let Y=J[J.length-1];Y.candidate&&!Y.suppressing&&(Y.suppressing=!0)}vt!=null&&st!=null&&st<(vt.alpha??1)&&(vt.alpha=st);for(let[Y,j]of Z[0]??[])if(Y==="SMask"&&(j===!0?z=!0:(j===!1||j==null)&&(z=!1)),Y==="ca"&&typeof j=="number")y.fillAlpha=j;else if(Y==="CA"&&typeof j=="number")y.strokeAlpha=j;else if(Y==="LW"&&typeof j=="number")y.lineWidth=j;else if(Y==="BM"){if(typeof j=="string"&&j!=="")y.blendMode=j;else if(Array.isArray(j)){for(let H of j)if(typeof H=="string"&&H!==""){y.blendMode=H;break}}}break}case rt.constructPath:S={ops:Z[0],coords:Z[1],minMax:Z[2]};break;case rt.clip:I="nonzero";break;case rt.eoClip:I="evenodd";break;case rt.fill:case rt.eoFill:case rt.stroke:case rt.closeStroke:case rt.fillStroke:case rt.eoFillStroke:case rt.closeFillStroke:case rt.closeEOFillStroke:case rt.endPath:{if(I&&S!=null&&(T=Tu(T,S,I,y.ctm),I=null),S==null)break;let tt=Ub(gt);if(tt){if(y.textClipActive){Zn(r,y.ctm,t,`vector ${tt}`),S=null;break}if($>0&&nt!=null&&(nt.abort=!0,nt.abortReason="contains vector paint operations (only single-grayscale-image masks are supported)"),$>0||et()){S=null;break}let ct=Lu(S,tt,y,t);if(ct){ct.blendMode=K();let st=pt();st!=null&&st<1&&(ct.opacity=st),Iu(ct,T,t),u.push(ct)}}S=null;break}case rt.paintImageXObject:{if($>0&&nt!=null&&(nt.captured!=null?(nt.abort=!0,nt.abortReason="contains multiple paintImageXObject calls; only single-grayscale-image masks are supported"):nt.captured={objId:Z[0],ctm:y.ctm.slice()}),$>0||et())break;if(y.textClipActive){Zn(r,y.ctm,t,`image objId="${Z[0]}"`);break}let tt={kind:"image",_placeholderIndex:u.length};u.push(tt),k.push({placeholder:tt,objId:Z[0],inline:null,ctm:y.ctm.slice(),opacity:pt(),blendMode:K(),clips:Ps(T)?null:Mn(T,t)});break}case rt.paintInlineImageXObject:{if($>0&&nt!=null&&(nt.abort=!0,nt.abortReason="contains an inline image (only image-xobject masks are supported)"),$>0||et())break;if(y.textClipActive){Zn(r,y.ctm,t,"inline image");break}let tt={kind:"image",_placeholderIndex:u.length};u.push(tt),k.push({placeholder:tt,objId:null,inline:Z[0],ctm:y.ctm.slice(),opacity:pt(),blendMode:K(),clips:Ps(T)?null:Mn(T,t)});break}case rt.paintImageMaskXObject:{if($>0&&nt!=null&&(nt.abort=!0,nt.abortReason="contains a paintImageMaskXObject (only single-grayscale-image masks are supported)"),$>0||et())break;let ct=(Z[0]??{}).data;if(y.textClipActive){Zn(r,y.ctm,t,`image mask objId="${ct}"`);break}if(y.fillColor==null){let Y=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:Y,objId:ct??null,page:r.pageIndex});break}let st={kind:"image",_placeholderIndex:u.length};u.push(st),k.push({placeholder:st,objId:ct,inline:null,stencilFill:y.fillColor,ctm:y.ctm.slice(),opacity:pt(),blendMode:K(),clips:Ps(T)?null:Mn(T,t)});break}case rt.paintSolidColorImageMask:{if($>0&&nt!=null&&(nt.abort=!0,nt.abortReason="contains a paintSolidColorImageMask (only single-grayscale-image masks are supported)"),$>0||et())break;if(y.textClipActive){Zn(r,y.ctm,t,"solid-colour image mask");break}if(y.fillColor==null){let st=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:st,objId:null,page:r.pageIndex});break}let tt={ops:[rt.rectangle],coords:[0,0,1,1]},ct=Lu(tt,{fill:!0,stroke:!1,fillRule:"nonzero"},y,t);if(ct){ct.blendMode=K();let st=pt();st!=null&&st<1&&(ct.opacity=st),Iu(ct,T,t),u.push(ct)}break}case rt.paintImageMaskXObjectGroup:{if($>0&&nt!=null&&(nt.abort=!0,nt.abortReason="contains a paintImageMaskXObjectGroup (only single-grayscale-image masks are supported)"),$>0||et())break;let tt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",ct=Array.isArray(Z[0])?Z[0].length:0;r.logger?.emit?.("IMAGE_MASK_GROUP_UNSUPPORTED",{prefix:tt,count:ct,page:r.pageIndex});break}case rt.paintImageMaskXObjectRepeat:{if($>0&&nt!=null&&(nt.abort=!0,nt.abortReason="contains a paintImageMaskXObjectRepeat (only single-grayscale-image masks are supported)"),$>0||et())break;let tt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",ct=Z[5],st=Array.isArray(ct)?Math.floor(ct.length/2):0;r.logger?.emit?.("IMAGE_MASK_REPEAT_UNSUPPORTED",{prefix:tt,count:st,page:r.pageIndex});break}case rt.shadingFill:{if($>0&&nt!=null&&(nt.abort=!0,nt.abortReason="contains a shading fill (only single-grayscale-image masks are supported)"),$>0||et())break;if(y.textClipActive){Zn(r,y.ctm,t,"shading fill");break}let tt={kind:"vector-path",_placeholderIndex:u.length};u.push(tt);let ct=T.length>0?T[T.length-1]:null,st=T.length>1?T.slice(0,-1):[];L.push({placeholder:tt,patternId:Z?.[0],ctm:y.ctm.slice(),clipEntry:ct??null,remainingClips:st,opacity:pt(),blendMode:K()});break}case rt.beginText:y.textMatrix=ri.slice(),y.textLineMatrix=ri.slice();break;case rt.endText:ft();break;case rt.setFont:y.fontObjId=Z[0],y.fontSize=Z[1];break;case rt.setTextMatrix:y.textMatrix=[Z[0],Z[1],Z[2],Z[3],Z[4],Z[5]],y.textLineMatrix=y.textMatrix.slice();break;case rt.moveText:{y.textLineMatrix=je(y.textLineMatrix,[1,0,0,1,Z[0],Z[1]]),y.textMatrix=y.textLineMatrix.slice();break}case rt.setLeadingMoveText:{y.textLeading=-Z[1],y.textLineMatrix=je(y.textLineMatrix,[1,0,0,1,Z[0],Z[1]]),y.textMatrix=y.textLineMatrix.slice();break}case rt.nextLine:{y.textLineMatrix=je(y.textLineMatrix,[1,0,0,1,0,-y.textLeading]),y.textMatrix=y.textLineMatrix.slice();break}case rt.setLeading:y.textLeading=Z[0];break;case rt.setCharSpacing:y.charSpacing=Z[0];break;case rt.setWordSpacing:y.wordSpacing=Z[0];break;case rt.setHScale:y.textHScale=Z[0]/100;break;case rt.setTextRise:y.textRise=Z[0];break;case rt.setTextRenderingMode:y.textRenderingMode=Z[0]??0;break;case rt.showText:case rt.nextLineShowText:case rt.nextLineSetSpacingShowText:case rt.showSpacedText:{let tt=(gt===rt.showText||gt===rt.nextLineShowText,Z[0]);if(y.textRenderingMode===7&&(y.textClipActive=!0),!M){let st={_placeholder:!0};u.push(st),M={placeholder:st,ctm:y.ctm.slice(),fillColor:y.fillColor,fillAlpha:y.fillAlpha,fontObjIdFirst:y.fontObjId,textString:"",glyphs:[]}}let ct=(()=>{let st=je(y.ctm,y.textMatrix),Y={fontObjId:y.fontObjId??"",baselineX:st[4],baselineY:st[5],fill:ii(y.fillColor,y.fillAlpha),text:"",placeholder:M.placeholder,renderMode:y.textRenderingMode};return g.push(Y),Y})();for(let st of tt){if(typeof st=="number"){let Ot=-st*.001*y.fontSize*y.textHScale;y.textMatrix[4]+=Ot*y.textMatrix[0],y.textMatrix[5]+=Ot*y.textMatrix[1];continue}M.textString+=st.unicode??"",ct.text+=st.unicode??"",st.isInFont!==!1&&M.glyphs.push({operatorListId:st.operatorListId,fontChar:st.fontChar,unicode:st.unicode,fontObjId:y.fontObjId??"",fontSize:y.fontSize,textMatrix:y.textMatrix.slice()});let j=(y.fontObjId!=null?s[y.fontObjId]:null)?.fontMatrix?.[0]??.001,Tt=((st.width??0)*j*y.fontSize+y.charSpacing+(st.isSpace?y.wordSpacing:0))*y.textHScale;y.textMatrix[4]+=Tt*y.textMatrix[0],y.textMatrix[5]+=Tt*y.textMatrix[1]}break}default:break}}ft();for(let X of k){let gt=X.inline;if(!gt){let ct=typeof X.objId=="string"&&X.objId.startsWith("g_"),st=typeof X.objId=="string"?X.objId:null;gt=await(ct?Ea(e,st):Ca(e,st))}if(!gt){let ct=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",st=Os(X.ctm,t.heightPt),Y=X.objId?`objId="${X.objId}"`:"inline image";r.logger?.emit?.("IMAGE_PDFJS_UNRESOLVED",{prefix:ct,idLabel:Y,bboxX:Ht(st.x),bboxY:Ht(st.y),bboxW:Ht(st.w),bboxH:Ht(st.h),page:r.pageIndex,objId:X.objId??null}),Dn(X.placeholder);continue}let Z=null;if(X.stencilFill){if(Z=await uu(gt,X.stencilFill,r.logger,{objId:typeof X.objId=="string"?X.objId:null,pageIndex:r.pageIndex}),!Z){let ct=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",st=Os(X.ctm,t.heightPt),Y=X.stencilFill?.space??"unknown";r.logger?.emit?.("IMAGE_MASK_COMPOSITE_FAIL",{prefix:ct,objId:X.objId??null,bboxX:Ht(st.x),bboxY:Ht(st.y),bboxW:Ht(st.w),bboxH:Ht(st.h),colourSpace:Y,page:r.pageIndex}),Dn(X.placeholder);continue}}else if(X.compositeWith){if(Z=await cu(gt,X.compositeWith,r.logger,{objId:typeof X.objId=="string"?X.objId:null,pageIndex:r.pageIndex}),!Z){let ct=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",st=Os(X.ctm,t.heightPt),Y=X.compositeWith?.space??"unknown",j=gt?.kind,H=j!=null?`kind=${j}`:"bitmap";r.logger?.log?.(`${ct}a luminosity SMask at (${st.x.toFixed(2)} in, ${st.y.toFixed(2)} in) ${st.w.toFixed(2)}\xD7${st.h.toFixed(2)} in could not be composited (mask ${H}, fill colour space "${Y}"). The shadow was dropped from the imported design.`,"warning"),Dn(X.placeholder);continue}}else if(Z=await lu(gt,r.logger,{objId:typeof X.objId=="string"?X.objId:null,ctm:X.ctm,pageIndex:r.pageIndex}),!Z){Dn(X.placeholder);continue}let tt=Os(X.ctm,t.heightPt,{logger:r.logger,pageIndex:r.pageIndex,objId:X.objId});Object.assign(X.placeholder,{kind:"image",x:tt.x,y:tt.y,width:tt.w,height:tt.h,mimeType:"image/png",bytes:Z,opacity:X.opacity??1,...Math.abs(tt.rotation)>1e-6?{rotation:tt.rotation}:{},...tt.flipHorizontal?{flipHorizontal:!0}:{},...tt.flipVertical?{flipVertical:!0}:{},...X.blendMode?{blendMode:X.blendMode}:{},...X.clips&&X.clips.length>0?{clips:X.clips}:{}})}for(let X of L){let gt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";if(typeof X.patternId!="string"){r.logger?.emit?.("SHADING_NO_PATTERN_REF",{prefix:gt,page:r.pageIndex}),Dn(X.placeholder);continue}let Z=await Ca(e,X.patternId),tt=wu({shadingIR:Z,ctm:X.ctm,clipEntry:X.clipEntry,remainingClips:X.remainingClips,pageBox:t,opacity:X.opacity,blendMode:X.blendMode,logger:r.logger,pageIndex:r.pageIndex});if(!tt){Dn(X.placeholder);continue}Object.assign(X.placeholder,tt)}return{out:u,colorSnapshots:g}}function Db(o){let t=[];for(let e of o)if(!e._removed){if(e._placeholder){Array.isArray(e._replacements)&&t.push(...e._replacements);continue}t.push(e)}return t}function Fb(o,t,e,s){let r=s?.textMode??"outline",a=[];if(o.placeholder._replacements=a,r==="outline"){let u=ku(o,o.glyphs,t,e);u&&a.push(u);return}let c=xu(o.glyphs,t,o.ctm,e.heightPt);for(let u of c){let f=t[u.fontObjId];if(gu(f,u.glyphs))continue;if(r==="editable"){let m=f?.name??u.fontObjId;throw new Error(`textMode 'editable': embeddability gate failed for font ${m} (text: ${JSON.stringify(u.text)})`)}let g=ku(o,u.glyphs,t,e);g&&a.push(g)}}function ku(o,t,e,s){if(!t||t.length===0)return null;let r=[],a=[],c=0,u=0,f="";for(let St of t){let W=e[St.fontObjId];if(!W)continue;let K=W.fontMatrix??[.001,0,0,.001,0,0],pt=[St.fontSize,0,0,St.fontSize,0,0],ft=je(pt,K);ft=je(St.textMatrix,ft),ft=je(o.ctm,ft);let X=null;if(W.isType3Font?X=_b(W,St.operatorListId):W._parsed&&(X=Nb(W,St)),X){let Z=Fu(X,ft,s.heightPt);r.push(...Z.cmds),a.push(...Z.devPoints)}let gt=je(o.ctm,je(St.textMatrix,pt));c+=Math.hypot(gt[2],gt[3]),u+=1,f+=St.unicode??""}let g=u>0?c/u:0,m=1/0,y=1/0,v=-1/0,S=-1/0;for(let[St,W]of a)St<m&&(m=St),W<y&&(y=W),St>v&&(v=St),W>S&&(S=W);Number.isFinite(m)||(m=y=v=S=0);let T=e[t[0].fontObjId],{style:w,weight:I}=mu(T),k=Rs(T?.name??""),L=k.family||k.fullName,M=je(o.ctm,t[0].textMatrix),N=M[4],F=s.heightPt-M[5],B=-Math.atan2(M[1],M[0]),G=Math.cos(-B),$=Math.sin(-B),z=1/0,J=1/0,et=-1/0,nt=-1/0;for(let[St,W]of a){let K=St*G-W*$,pt=St*$+W*G;K<z&&(z=K),pt<J&&(J=pt),K>et&&(et=K),pt>nt&&(nt=pt)}let xt=Number.isFinite(z)?Math.max(0,et-z):0,vt=Number.isFinite(J)?Math.max(0,nt-J):0;return{kind:"text-outline",x:m,y,width:Math.max(0,v-m),height:Math.max(0,S-y),d:_u(r,m,y),text:f,fontFamily:L,fontSize:g,fontStyle:w,fontWeight:I,fill:ii(o.fillColor,o.fillAlpha),opacity:o.fillAlpha!=null&&o.fillAlpha<1?o.fillAlpha:1,textOriginX:N,textOriginY:F,rotation:B,unrotWidth:xt,unrotHeight:vt}}function _b(o,t){let e=o?.charProcOperatorList?.[t];if(!e)return null;let s=e.fnArray,r=e.argsArray,a={ops:[],coords:[]};for(let c=0;c<s.length;c++)if(s[c]===rt.constructPath){let u=r[c];a.ops.push(...u[0]),a.coords.push(...u[1])}return a.ops.length===0?null:a}function Nb(o,t){let e=o._parsed;if(!e)return null;let s=null,r=e.encoding,a=m=>{if(m==null)return-1;let y=r?.cmap?.glyphIndexMap?.[m];if(typeof y=="number")return y;try{let v=r?.charToGlyphIndex?.(m);return typeof v=="number"?v:-1}catch{return-1}},c=t.fontChar?t.fontChar.codePointAt(0):null,u=a(c);if(u>0&&(s=e.glyphs.get(u)),!s)try{t.fontChar&&(s=e.charToGlyph(t.fontChar))}catch{}if((!s||s.index===0)&&t.unicode)try{let m=e.charToGlyph(t.unicode);m&&m.index>0&&(s=m)}catch{}if(!s||!s.path||s.index===0)return null;let f=[],g=[];for(let m of s.path.commands)switch(m.type){case"M":f.push(rt.moveTo),g.push(m.x,m.y);break;case"L":f.push(rt.lineTo),g.push(m.x,m.y);break;case"C":f.push(rt.curveTo),g.push(m.x1,m.y1,m.x2,m.y2,m.x,m.y);break;case"Q":{f.push(rt.curveTo),g.push(m.x1,m.y1,m.x1,m.y1,m.x,m.y);break}case"Z":f.push(rt.closePath);break;default:break}return f.length===0?null:{ops:f,coords:g}}function Dn(o){o._removed=!0}function Iu(o,t,e){if(Ps(t))return;let s=Mn(t,e);s.length>0&&(o.clips=s)}function Ru(o){return{space:"rgb",values:[o[0]/255,o[1]/255,o[2]/255]}}function Pu(o){if(!Array.isArray(o)||o.length===0)return{key:null,components:[]};let t=o[o.length-1];return typeof t=="string"||t===null?{key:typeof t=="string"?t:null,components:o.slice(0,-1)}:{key:null,components:o}}function Ou(o,t,e,s){if(o==null)return s;switch(o){case"DeviceGray":return{space:"gray",values:[t?.[0]??0]};case"DeviceRGB":return{space:"rgb",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0]};case"DeviceCMYK":return{space:"cmyk",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0,t?.[3]??0]}}let r=e[o];if(!r)return s;if(r.kind==="separation"){let a=t?.[0]??1,c=Array.isArray(r.solid)?r.solid:[],u=c.map(f=>f*a);return{space:"spot",name:r.name,tint:a,alternateSpace:r.alternateSpace,solid:c,values:u}}if(r.kind==="deviceN"){let a=Array.isArray(r.solid)?r.solid:[];return r.alternateSpace==="DeviceCMYK"?{space:"cmyk",values:a.slice(0,4)}:r.alternateSpace==="DeviceGray"?{space:"gray",values:a.slice(0,1)}:{space:"rgb",values:a.slice(0,3)}}return s}function Ub(o){switch(o){case rt.fill:return{fill:!0,stroke:!1,fillRule:"nonzero"};case rt.eoFill:return{fill:!0,stroke:!1,fillRule:"evenodd"};case rt.stroke:case rt.closeStroke:return{fill:!1,stroke:!0,fillRule:"nonzero"};case rt.fillStroke:case rt.closeFillStroke:return{fill:!0,stroke:!0,fillRule:"nonzero"};case rt.eoFillStroke:case rt.closeEOFillStroke:return{fill:!0,stroke:!0,fillRule:"evenodd"};default:return null}}function Lu(o,t,e,s){let r=Bb(o,e.ctm,s.heightPt);if(!r)return null;let{devPoints:a,cmds:c}=r;if(a.length===0)return null;let u=1/0,f=1/0,g=-1/0,m=-1/0;for(let[N,F]of a)N<u&&(u=N),F<f&&(f=F),N>g&&(g=N),F>m&&(m=F);let y=g-u,v=m-f;if(y<=0&&v<=0)return null;let S=t.stroke?Math.abs(zb(e.ctm)*e.lineWidth):0,T=t.stroke&&y<=0?S:0,w=t.stroke&&v<=0?S:0,I=u-T/2,k=f-w/2,L=y+T,M=v+w;return{kind:"vector-path",x:I,y:k,width:L,height:M,d:_u(c,I,k),fill:t.fill?ii(e.fillColor,e.fillAlpha):null,stroke:t.stroke?ii(e.strokeColor,e.strokeAlpha):null,strokeWidth:S,fillRule:t.fillRule,opacity:1,blendMode:e.blendMode}}function Bb(o,t,e){return Fu(o,t,e)}function Fu(o,t,e){let s=o.ops??[],r=o.coords??[],a=[],c=[],u=0,f=null,g=(m,y)=>{let[v,S,T,w,I,k]=t;return[v*m+T*y+I,e-(S*m+w*y+k)]};for(let m=0;m<s.length;m++)switch(s[m]){case rt.rectangle:{let v=r[u++],S=r[u++],T=r[u++],w=r[u++],I=g(v,S),k=g(v+T,S),L=g(v+T,S+w),M=g(v,S+w);c.push({cmd:"M",pts:[I]}),c.push({cmd:"L",pts:[k]}),c.push({cmd:"L",pts:[L]}),c.push({cmd:"L",pts:[M]}),c.push({cmd:"Z"}),a.push(I,k,L,M);break}case rt.moveTo:{let v=g(r[u++],r[u++]);c.push({cmd:"M",pts:[v]}),a.push(v),f=v;break}case rt.lineTo:{let v=g(r[u++],r[u++]);c.push({cmd:"L",pts:[v]}),a.push(v),f=v;break}case rt.curveTo:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]),T=g(r[u++],r[u++]);c.push({cmd:"C",pts:[v,S,T]}),a.push(v,S,T),f=T;break}case rt.curveTo2:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]),T=f??v;c.push({cmd:"C",pts:[T,v,S]}),a.push(v,S),f=S;break}case rt.curveTo3:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]);c.push({cmd:"C",pts:[v,S,S]}),a.push(v,S),f=S;break}case rt.closePath:c.push({cmd:"Z"});break;default:break}return{devPoints:a,cmds:c}}function _u(o,t,e){let s=a=>`${Math.round(a*100)/100}`,r=[];for(let a of o){if(a.cmd==="Z"){r.push("Z");continue}let c=(a.pts??[]).map(([u,f])=>`${s(u-t)} ${s(f-e)}`).join(" ");r.push(`${a.cmd} ${c}`)}return r.join(" ")}var Gb=.01,Hb=.05;function Zn(o,t,e,s){let r=o?.pageIndex!=null?`Page ${o.pageIndex}: `:"",a=Os(t,e.heightPt);o?.logger?.emit?.("TEXT_CLIP_MODE_7_DROPPED",{prefix:r,label:s,bbox:`${Ht(a.x)}, ${Ht(a.y)}`,bboxSize:`${Ht(a.w)}\xD7${Ht(a.h)}`,page:o?.pageIndex})}function Os(o,t,e=null){let[s,r,a,c,u,f]=o,g=Math.hypot(s,r),m=Math.hypot(a,c),y=Math.atan2(-r,s);if(Math.abs(r)<1e-6&&Math.abs(a)<1e-6||Math.abs(y)<Hb)return jb(o,t);let S=g>0&&m>0?(s*a+r*c)/(g*m):0;if(!(Math.abs(S)<Gb)||!(g>0&&m>0))return Vb(o,t,e,S);let T=u+(s+a)*.5,w=f+(r+c)*.5,I=Math.atan2(-r,s),k=s*c-r*a<0;return{x:T-g*.5,y:t-w-m*.5,w:g,h:m,rotation:I,flipHorizontal:!1,flipVertical:k}}function jb(o,t){let[e,s,r,a,c,u]=o,f=[c,c+e,c+r,c+e+r],g=[u,u+s,u+a,u+s+a],m=Math.min(...f),y=Math.max(...f),v=Math.min(...g),S=Math.max(...g);return{x:m,y:t-S,w:y-m,h:S-v,rotation:0,flipHorizontal:e<0,flipVertical:a<0}}function Vb(o,t,e=null,s=null){let[r,a,c,u,f,g]=o,m=[f,f+r,f+c,f+r+c],y=[g,g+a,g+u,g+a+u],v=Math.min(...m),S=Math.max(...m),T=Math.min(...y),w=Math.max(...y),I={x:v,y:t-w,w:S-v,h:w-T,rotation:0,flipHorizontal:!1,flipVertical:!1};if(e?.logger?.emit){let k=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",L=s!=null?`, residual=${Ht(s)}`:"",M=e.objId?` objId="${e.objId}"`:"";e.logger.emit("IMAGE_SKEW_DROPPED",{prefix:k,idLabel:M,bboxX:Ht(I.x),bboxY:Ht(I.y),bboxW:Ht(I.w),bboxH:Ht(I.h),ctm:Su(o),residualStr:L,page:e.pageIndex,objId:e.objId??null})}return I}function ii(o,t){return o==null?null:t==null||t===1?o:{...o,alpha:t}}function Mu(o={x:0,y:0}){return{ctm:[1,0,0,1,-o.x,-o.y],fillColor:{space:"gray",values:[0]},strokeColor:{space:"gray",values:[0]},fillColorSpaceName:null,strokeColorSpaceName:null,fillAlpha:1,strokeAlpha:1,lineWidth:1,blendMode:null,textMatrix:ri.slice(),textLineMatrix:ri.slice(),fontObjId:null,fontSize:0,charSpacing:0,wordSpacing:0,textHScale:1,textRise:0,textLeading:0,textRenderingMode:0,textClipActive:!1}}function $b(o){return{ctm:o.ctm.slice(),fillColor:o.fillColor,strokeColor:o.strokeColor,fillColorSpaceName:o.fillColorSpaceName,strokeColorSpaceName:o.strokeColorSpaceName,fillAlpha:o.fillAlpha,strokeAlpha:o.strokeAlpha,lineWidth:o.lineWidth,blendMode:o.blendMode,textMatrix:o.textMatrix.slice(),textLineMatrix:o.textLineMatrix.slice(),fontObjId:o.fontObjId,fontSize:o.fontSize,charSpacing:o.charSpacing,wordSpacing:o.wordSpacing,textHScale:o.textHScale,textRise:o.textRise,textLeading:o.textLeading,textRenderingMode:o.textRenderingMode,textClipActive:o.textClipActive}}function zb([o,t,e,s]){return(Math.hypot(o,t)+Math.hypot(e,s))/2}function je(o,t){let[e,s,r,a,c,u]=o,[f,g,m,y,v,S]=t;return[e*f+r*g,s*f+a*g,e*m+r*y,s*m+a*y,e*v+r*S+c,s*v+a*S+u]}function Wb(o,t){return o.filter(e=>{if(e.kind!=="vector-path")return!0;let s=e.fill;return!(s&&"alpha"in s&&s.alpha===0&&!e.stroke||Xb(e,t))})}function Xb(o,t){if(o.kind!=="vector-path"||o.stroke||!o.fill||o.fill.space!=="rgb")return!1;let[e,s,r]=o.fill.values;if(!(e>=.98&&s>=.98&&r>=.98))return!1;let a=1;return Math.abs(o.x)<=a&&Math.abs(o.y)<=a&&Math.abs(o.width-t.widthPt)<=a&&Math.abs(o.height-t.heightPt)<=a}var Yb=.05,Kb=1.5,Nu=1;async function Uu(o,t){let e=await o.getTextContent({includeMarkedContent:!1,disableNormalization:!0}),s=[],r={cursor:0,consumed:new Set};for(let a of e.items){if(a.type||!a.str||a.str.trim()===""||sv(a.str))continue;let c=nv(o,a.fontName);if(!Ia(c))continue;let u=e.styles?.[a.fontName],f=await Zb(a,c,u,t,r);if(!f||!f.run)continue;let g=f.placeholder;g&&Array.isArray(g._replacements)?g._replacements.push(f.run):s.push(f.run)}return s}async function Zb(o,t,e,s,r){let[a,c,u,f,g,m]=o.transform,y=Math.hypot(u,f);if(!(y>0))return null;let v=Math.atan2(c,a),S=s.pageBox.originShiftPt??{x:0,y:0},T=g-S.x,w=m-S.y,{ascentRatio:I,descentRatio:k}=ev(e,t),L=y*I,M=y*k,N=o.width+y*Yb,F=L+M,B=Math.cos(v),G=Math.sin(v),$=N/2,z=(L-M)/2,J=T+$*B-z*G,et=w+$*G+z*B,nt=J-$,xt=s.pageBox.heightPt-et-F/2,vt=F/2,St=nt-vt*G,W=xt+vt*(1-B),K=await pu(t,s.logger);if(!K)return null;s.docFonts.has(K.postScriptName)||s.docFonts.set(K.postScriptName,K);let pt=Jb({fontObjId:o.fontName,baselineX:T,baselineY:w,widthPt:o.width,str:o.str},s.colorSnapshots,r);if(pt==null)return null;if(pt.renderMode===3||pt.renderMode===7){let ct=s.pageIndex!=null?` on page ${s.pageIndex}`:"",st=pt.renderMode===7?"7 (add to clipping path)":"3 (invisible)";return s.logger?.emit?.("TEXT_RENDER_MODE_SKIPPED",{pageTag:ct,text:Qb(o.str,60),modeLabel:st,page:s.pageIndex,renderMode:pt.renderMode}),null}let{fill:ft,colorSpans:X}=pt,gt=ft?.alpha,Z=gt!=null&><1?gt:1,tt={kind:"text-run",x:St,y:W,width:N,height:F,text:o.str,fontRef:K.postScriptName,fontSize:y,rotation:-v,fill:ft,...X?{colorSpans:X}:{},baselineXPt:T,baselineYPt:w,advanceWidthPt:o.width};return tt.opacity=Z,{run:tt,placeholder:pt.placeholder??null}}function Qb(o,t){return typeof o!="string"?"":o.length>t?`${o.slice(0,t)}\u2026`:o}function Jb(o,t,e){let s=[],r=[],a=e.cursor,c=o.str.length,u=0;for(let S=e.cursor;S<t.length;S++){if(e.consumed.has(S)||!La(t[S])||!Ma(t[S],o))continue;let T=t[S].text?.length??0;if(u>=c)break;s.push(t[S]),r.push(S),u+=T,a=S+1}if(s.length===0)for(let S=0;S<t.length;S++){if(e.consumed.has(S)||!La(t[S])||!Ma(t[S],o))continue;let T=t[S].text?.length??0;if(u>=c)break;s.push(t[S]),r.push(S),u+=T}else e.cursor=a;if(s.length===0){for(let S=0;S<t.length;S++)if(e.consumed.has(S)&&La(t[S])&&Ma(t[S],o))return null;return{fill:null,colorSpans:void 0,renderMode:0,placeholder:null}}for(let S of r)e.consumed.add(S);let f=s[0].renderMode??0,g=s[0].placeholder??null,m=s[0].fill??null;if(s.every(S=>Da(S.fill??null,m)))return{fill:m,colorSpans:void 0,renderMode:f,placeholder:g};let v=s.reduce((S,T)=>S+(T.text?.length??0),0);if(v===o.str.length&&v>0){let S=[],T=0;for(let w of s){let I=w.text?.length??0;if(I===0)continue;let k=T,L=T+I;T=L;let M=S[S.length-1];M&&Da(M.fill,w.fill??null)?M.to=L:S.push({from:k,to:L,fill:w.fill??null})}return S.length===0?{fill:m,colorSpans:void 0,renderMode:f,placeholder:g}:{fill:S[0].fill,colorSpans:S,renderMode:f,placeholder:g}}return qb(o,s,m,f,g)}function qb(o,t,e,s,r){let a=o.str.length;if(o.widthPt<=0||a===0)return{fill:e,colorSpans:void 0,renderMode:s,placeholder:r};let c=t.map(f=>({from:Math.max(0,Math.min(a,Math.round((f.baselineX-o.baselineX)/o.widthPt*a))),fill:f.fill??null}));c.sort((f,g)=>f.from-g.from);let u=[];for(let f=0;f<c.length;f++){let g=c[f].from,m=f+1<c.length?c[f+1].from:a;if(g>=m)continue;let y=u[u.length-1];y&&Da(y.fill,c[f].fill)?y.to=m:u.push({from:g,to:m,fill:c[f].fill})}return u.length===0?{fill:e,colorSpans:void 0,renderMode:s,placeholder:r}:{fill:u[0].fill,colorSpans:u,renderMode:s,placeholder:r}}function La(o){if(!o)return!1;let t=o.fill;return t?(t.alpha??1)>0:!1}function Da(o,t){if(o==null&&t==null)return!0;if(o==null||t==null||o.space!==t.space||(o.alpha??1)!==(t.alpha??1)||!o.values||!t.values||o.values.length!==t.values.length)return!1;for(let e=0;e<o.values.length;e++)if(Math.abs(o.values[e]-t.values[e])>1e-6)return!1;return!0}function Ma(o,t){if(o.fontObjId!==t.fontObjId||Math.abs(o.baselineY-t.baselineY)>Kb)return!1;let e=Nu+tv(o.text);return!(o.baselineX<t.baselineX-e||o.baselineX>t.baselineX+t.widthPt+Nu)}function tv(o){if(!o)return 0;let t=0;for(let e of o)if(e===" "||e===" "||e==="\xA0")t++;else break;return t*5}function ev(o,t){if(Number.isFinite(o?.ascent)&&Number.isFinite(o?.descent))return{ascentRatio:o.ascent,descentRatio:Math.abs(o.descent)};let e=t?._parsed,s=e?.unitsPerEm,r=e?.tables?.hhea,a=r?.ascender,c=r?.descender;return typeof s=="number"&&Number.isFinite(s)&&s>0&&Number.isFinite(a)&&Number.isFinite(c)?{ascentRatio:a/s,descentRatio:Math.abs(c)/s}:{ascentRatio:.8,descentRatio:.2}}function nv(o,t){if(!t)return null;try{if(o.commonObjs.has(t))return o.commonObjs.get(t)}catch{}return null}function sv(o){for(let t of o){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}var Fa=2;function rv(o){let t=o?.imglyPatchVersion??null;if(t!==Fa)throw new Error(`[@imgly/pdf-importer] @imgly/pdfjs-dist patch missing or outdated (got ${t??"none"}, expected ${Fa}). The patched APIs (trimBox, bleedBox, colorSpaceResources, native CMYK args) are required for correct color and geometry import. Pin @imgly/pdfjs-dist to 4.10.38-imgly.${Fa} or newer and reinstall.`)}function Bu(){return typeof process<"u"&&typeof process.versions?.node=="string"}async function iv(){let o=new URL("./pdf.worker.mjs",import.meta.url);if(!Bu())return o.href;let{existsSync:t}=await import("node:fs");if(t(o)){let{fileURLToPath:s}=await import("node:url");return s(o)}let{createRequire:e}=await import("node:module");return e(import.meta.url).resolve("@imgly/pdfjs-dist/legacy/build/pdf.worker.mjs")}async function ov(){let o=new URL("./standard_fonts/FoxitFixed.pfb",import.meta.url),t=new URL("./standard_fonts/",import.meta.url);if(!Bu())return t.href;let{existsSync:e}=await import("node:fs");if(e(o)){let{fileURLToPath:a}=await import("node:url");return a(t)}let{createRequire:s}=await import("node:module"),r=s(import.meta.url).resolve("@imgly/pdfjs-dist/standard_fonts/FoxitFixed.pfb");return r.slice(0,r.lastIndexOf("/")+1)}async function Gu(o,t={}){let e=t.pdfjsModule??await Promise.resolve().then(()=>(Ta(),ru));e.GlobalWorkerOptions.workerSrc=t.workerSrc??await iv();let s=t.standardFontDataUrl??await ov(),r=t.textMode??"outline",a=o instanceof Uint8Array?o:(()=>{let m=o;return new Uint8Array(m.buffer??o,m.byteOffset??0,m.byteLength??m.length)})(),u=await e.getDocument({data:a,password:t.password,disableFontFace:!0,useSystemFonts:!1,isEvalSupported:!1,fontExtraProperties:!0,standardFontDataUrl:s}).promise,f=new Map,g=[];for(let m=1;m<=u.numPages;m++){let y=await u.getPage(m);m===1&&rv(y),g.push(await av(y,{textMode:r,docFonts:f,logger:t.logger,pageIndex:m})),y.cleanup()}return await u.destroy(),{source:t.source??"unknown",pages:g,fonts:f}}async function av(o,t){let e=o.trimBox,s=o.bleedBox,r=o.view??[0,0,0,0],a=r[2]-r[0],c=r[3]-r[1],u={x:r[0],y:r[1]},f={widthPt:a,heightPt:c,originShiftPt:u},g=null,m={left:0,top:0,right:0,bottom:0},y=!1;e&&(g={xPt:e[0]-r[0],yPt:r[3]-e[3],widthPt:e[2]-e[0],heightPt:e[3]-e[1]},s&&(m={left:Math.max(0,e[0]-s[0]),bottom:Math.max(0,e[1]-s[1]),right:Math.max(0,s[2]-e[2]),top:Math.max(0,s[3]-e[3])},y=!0));let{colorSnapshots:v,finalize:S}=await Du(o,f,t),T=t.textMode==="outline"?[]:await Uu(o,{pageBox:f,docFonts:t.docFonts,colorSnapshots:v,logger:t.logger,pageIndex:t.pageIndex}),w=S();T.length>0&&w.push(...T);let I=o.rotate??0;if(I!==0){let k=t.pageIndex!=null?`Page ${t.pageIndex}: `:"";t.logger?.emit?.("DOC_PAGE_ROTATION_DROPPED",{prefix:k,pageRotation:I,page:t.pageIndex})}return{widthPt:a,heightPt:c,rotation:I,trimPt:g,bleedPt:m,hasBleed:y,blocks:w}}var Le=Object.freeze({IMAGE:"image",VECTOR_PATH:"vector-path",TEXT_OUTLINE:"text-outline",TEXT_RUN:"text-run"}),lv=72,$t=o=>o/lv;var Hu=Object.freeze({"source-over":null,normal:null,multiply:"Multiply",screen:"Screen",overlay:"Overlay",darken:"Darken",lighten:"Lighten","color-dodge":"ColorDodge","color-burn":"ColorBurn","hard-light":"HardLight","soft-light":"SoftLight",difference:"Difference",exclusion:"Exclusion",hue:"Hue",saturation:"Saturation",color:"Color",luminosity:"Luminosity"});function oi(o,t){return o==null||o===""?null:Object.prototype.hasOwnProperty.call(Hu,o)?Hu[o]:(t?.emit?.("BLEND_MODE_UNSUPPORTED",{mode:o}),null)}function ai(o,t,e,s){let r=o.block.createShape("vector_path");o.block.setString(r,"vector_path/path",t);try{o.block.setFloat(r,"vector_path/width",e),o.block.setFloat(r,"vector_path/height",s)}catch{}return r}var li=Symbol("COMBINE_EMPTY_INTERSECTION");function Na(o,t,e){if(!Array.isArray(t)||t.length<2)return e?.logger?.emit?.("CLIP_COMBINE_TOO_FEW_INPUTS",{prefix:_a(e),inputCount:t?.length??0,label:e?.label??null}),null;if(!o.block.isCombinable(t))return e?.logger?.emit?.("CLIP_COMBINE_NOT_COMBINABLE",{prefix:_a(e),inputCount:t.length,label:e?.label??null}),null;try{return o.block.combine(t,"Intersection")}catch(s){let r=s&&typeof s=="object"&&"message"in s?String(s.message):String(s);return cv(r)?li:(e?.logger?.emit?.("CLIP_COMBINE_THREW",{prefix:_a(e),inputCount:t.length,reason:r,label:e?.label??null}),null)}}function cv(o){return typeof o=="string"&&o.includes("empty shape")}function _a(o){return o?.label?`${o.label}: `:""}function Ls(o,t){for(let e of t)try{o.block.isValid?.(e)!==!1&&o.block.destroy(e)}catch{}}function uv(){return{scaleRatio:1,translationX:0,translationY:0,rotation:0}}function ju(o){return o.scaleRatio===1&&o.translationX===0&&o.translationY===0&&o.rotation===0}function Vu(o,t){if(hv(o,t))return uv();let s=1/Math.max(t.width/o.width,t.height/o.height),r=o.x+o.width/2,a=o.y+o.height/2,c=t.x+t.width/2,u=t.y+t.height/2,f=t.width/2,g=t.height/2,m=f===0?0:(r-c)/f,y=g===0?0:(a-u)/g;return{scaleRatio:s,translationX:m,translationY:y,rotation:0}}function $u(o,t){let e=Math.max(o.x,t.x),s=Math.max(o.y,t.y),r=Math.min(o.x+o.width,t.x+t.width),a=Math.min(o.y+o.height,t.y+t.height);return{x:e,y:s,width:r-e,height:a-s}}function hv(o,t){return o.x===t.x&&o.y===t.y&&o.width===t.width&&o.height===t.height}function Qn(o,t,e,s){if(!e?.bytes||e.bytes.length===0)return s?.logger?.emit?.("IMAGE_NO_PIXELS",{}),!1;let r=o.block.createFill("image"),a=o.editor.createBuffer(),c=e.bytes instanceof Uint8Array?e.bytes:new Uint8Array(e.bytes);return o.editor.setBufferData(a,0,c),o.block.setString(r,"fill/image/imageFileURI",a),o.block.setFill(t,r),!0}function zu(o,t,e,s){if(!(!e?.flipHorizontal&&!e?.flipVertical))try{o.block.getGlobalBoundingBoxX(t),e.flipHorizontal&&o.block.flipCropHorizontal(t),e.flipVertical&&o.block.flipCropVertical(t)}catch{s?.logger?.emit?.("IMAGE_FLIP_UNSUPPORTED",{})}}var _n=Symbol("EMITTED_DROPPED");function Zu(o,t,e,s,r){if(!t?.bytes||t.bytes.length===0)return r?.logger?.emit?.("IMAGE_CLIPPED_NO_BYTES",{prefix:Fn(r),bbox:Oe(t),page:r?.pageIndex}),null;let a=e.filter(g=>Ms(g)),c=e.filter(g=>!Ms(g)&&!Ku(g,t)),u=e.filter(g=>!Ms(g)&&Ku(g,t));if(u.length===0)return r?.logger?.emit?.("IMAGE_CLIP_UNUSABLE",{prefix:Fn(r),bbox:Oe(t),clipCount:e.length,degenerateCount:a.length,disjointCount:c.length,page:r?.pageIndex}),_n;let f=dv(u,t);return f.length===1?Ju(o,t,f[0],r):yv(o,t,f,s,r)}function dv(o,t){let e=[],s=new Set;for(let r of o)fv(r,t)||s.has(r.d)||(s.add(r.d),e.push(r));return e.length>0?e:[o[0]]}function fv(o,t){if(!pv(o.d))return!1;let e=.001;return o.x<=t.x+e&&o.y<=t.y+e&&o.x+o.width+e>=t.x+t.width&&o.y+o.height+e>=t.y+t.height}function pv(o){if(typeof o!="string")return!1;let t=o.split(/\s+/),e=[],s=[],r=0;for(;r<t.length;){let u=t[r++];if(!(u==="Z"||u==="z")){if(u==="M"||u==="L"){let f=parseFloat(t[r++]),g=parseFloat(t[r++]);if(Number.isNaN(f)||Number.isNaN(g))return!1;e.push(f),s.push(g);continue}return!1}}if(e.length!==4&&e.length!==5)return!1;let a=.001,c=u=>{let f=[];for(let g of u)f.some(m=>Math.abs(m-g)<=a)||f.push(g);return f};return c(e).length===2&&c(s).length===2}function Qu(o,t,e,s,r){let a=e.filter(y=>Ms(y)),c=e.filter(y=>!Ms(y));if(c.length===0)return r?.logger?.emit?.("CLIP_DEGENERATE_FALLBACK",{prefix:Fn(r),bbox:Oe(t),clipCount:e.length,degenerateCount:a.length,page:r?.pageIndex}),null;if(!t.fill)return r?.logger?.emit?.("CLIP_COMBINE_STROKE_ONLY",{prefix:Fn(r),bbox:Oe(t),clipCount:e.length,page:r?.pageIndex}),null;let u=[];for(let y of c){let v=th(o,y);o.block.appendChild(s,v),u.push(v)}let f={x:t.x,y:t.y,width:t.width,height:t.height},g=Cv(o,t.d,f,t.fill,t.opacity);o.block.appendChild(s,g);let m=Na(o,[g,...u],{logger:r?.logger,label:`${Fn(r)}vector path at ${Oe(t)}`});return m===li?(Ls(o,[g,...u]),_n):m==null?(Ls(o,[g,...u]),null):(gv(o,m,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(m,t.opacity),Ua(o,m,t.blendMode,r?.logger),m)}function gv(o,t,e){let s=e.fill,r=s?.kind;if(r==="linearGradient"||r==="radialGradient"){mv(o,t,e);return}let a=o.block.createFill("color");o.block.setColor(a,"fill/color/value",Ba(s)),o.block.setFill(t,a)}function mv(o,t,e){let s=e.fill,r=s.kind==="linearGradient"?"gradient/linear":"gradient/radial",a=o.block.createFill(r),c=(s.stops??[]).map(g=>({color:Ba(g.color),stop:g.offset}));o.block.setGradientColorStops(a,"fill/gradient/colors",c);let u=e.width>0?e.width:1,f=e.height>0?e.height:1;if(s.kind==="linearGradient")o.block.setFloat(a,"fill/gradient/linear/startPointX",(s.start.x-e.x)/u),o.block.setFloat(a,"fill/gradient/linear/startPointY",(s.start.y-e.y)/f),o.block.setFloat(a,"fill/gradient/linear/endPointX",(s.end.x-e.x)/u),o.block.setFloat(a,"fill/gradient/linear/endPointY",(s.end.y-e.y)/f);else{let g=Math.max(.001,Math.min(u,f));o.block.setFloat(a,"fill/gradient/radial/centerPointX",(s.center.x-e.x)/u),o.block.setFloat(a,"fill/gradient/radial/centerPointY",(s.center.y-e.y)/f),o.block.setFloat(a,"fill/gradient/radial/radius",s.radius/g)}o.block.setFill(t,a)}function Ua(o,t,e,s){let r=oi(e,s);r!=null&&(typeof o.block.supportsBlendMode=="function"&&!o.block.supportsBlendMode(t)||o.block.setBlendMode(t,r))}function Ju(o,t,e,s){let r=o.block.create("graphic"),a=wv(e,t),c=ai(o,a,t.width,t.height);return o.block.setShape(r,c),Qn(o,r,t),ui(o,r,t),t.rotation&&Math.abs(t.rotation)>1e-6&&o.block.setRotation(r,t.rotation),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(r,t.opacity),Ua(o,r,t.blendMode,s?.logger),r}function yv(o,t,e,s,r){if(t.rotation&&Math.abs(t.rotation)>1e-6){let g=bv(o,t,e,s,r);if(g!==qu)return g}let c=Tv(o,t);o.block.appendChild(s,c);let u=[];for(let g of e){let m=th(o,g);o.block.appendChild(s,m),u.push(m)}let f=Na(o,[c,...u],{logger:r?.logger,label:`${Fn(r)}clipped image at ${Oe(t)}`});return f===li?(Ls(o,[c,...u]),_n):f==null?(Ls(o,[c,...u]),null):(Qn(o,f,t),Ev(o,f,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(f,t.opacity),Ua(o,f,t.blendMode,r?.logger),f)}var qu=Symbol("UNHANDLED");function bv(o,t,e,s,r){let a=vv(e);if(a==null)return qu;if(a.points.length<3)return r?.logger?.emit?.("IMAGE_CLIP_EMPTY_INTERSECTION",{prefix:Fn(r),bbox:Oe(t),clipCount:e.length,page:r?.pageIndex}),_n;let c=Av(a.points);return Ju(o,t,c,r)}function vv(o){if(o.length===0)return null;let t=Wu(o[0]);if(t==null)return null;for(let e=1;e<o.length;e++){let s=Wu(o[e]);if(s==null)return null;if(t=xv(t,s),t.length===0)return{points:[]}}return{points:t}}function Wu(o){let t=o.d.split(/\s+/),e=[],s=0;for(;s<t.length;){let r=t[s++];if(!(r==="Z"||r==="z")){if(r==="M"||r==="L"){let a=parseFloat(t[s++]),c=parseFloat(t[s++]);if(Number.isNaN(a)||Number.isNaN(c))return null;let u=o.x+a,f=o.y+c,g=e[e.length-1];if(g&&Math.abs(g[0]-u)<1e-6&&Math.abs(g[1]-f)<1e-6)continue;e.push([u,f]);continue}return null}}return e}function xv(o,t){if(t.length<3)return[];let e=Math.sign(Sv(t))||1,s=o.slice();for(let r=0;r<t.length&&s.length!==0;r++){let a=t[r],c=t[(r+1)%t.length],u=s;s=[];let f=u[u.length-1];for(let g of u){let m=Xu(g,a,c)*e>=-1e-9,y=Xu(f,a,c)*e>=-1e-9;m?(y||s.push(Yu(f,g,a,c)),s.push(g)):y&&s.push(Yu(f,g,a,c)),f=g}}return s}function Sv(o){let t=0;for(let e=0;e<o.length;e++){let[s,r]=o[e],[a,c]=o[(e+1)%o.length];t+=s*c-a*r}return t*.5}function Xu(o,t,e){return(e[0]-t[0])*(o[1]-t[1])-(e[1]-t[1])*(o[0]-t[0])}function Yu(o,t,e,s){let r=s[0]-e[0],a=s[1]-e[1],c=t[0]-o[0],u=t[1]-o[1],f=r*u-c*a;if(Math.abs(f)<1e-12)return t.slice();let g=(r*(e[1]-o[1])-a*(e[0]-o[0]))/f;return[o[0]+g*c,o[1]+g*u]}function Av(o){let t=1/0,e=1/0,s=-1/0,r=-1/0;for(let[u,f]of o)u<t&&(t=u),f<e&&(e=f),u>s&&(s=u),f>r&&(r=f);let a=u=>`${Math.round(u*100)/100}`,c=[];for(let u=0;u<o.length;u++){let[f,g]=o[u];c.push(`${u===0?"M":"L"} ${a(f-t)} ${a(g-e)}`)}return c.push("Z"),{d:c.join(" "),x:t,y:e,width:s-t,height:r-e,fillRule:"nonzero"}}function Tv(o,t){let e=o.block.create("graphic");return o.block.setShape(e,o.block.createShape("rect")),Qn(o,e,t),ui(o,e,t),t.rotation&&Math.abs(t.rotation)>1e-6&&o.block.setRotation(e,t.rotation),e}function th(o,t){let e=o.block.create("graphic"),s=ai(o,t.d,t.width,t.height);return o.block.setShape(e,s),o.block.setFill(e,eh(o)),ui(o,e,t),e}function Cv(o,t,e,s,r){let a=o.block.create("graphic"),c=ai(o,t,e.width,e.height);o.block.setShape(a,c);let u=s?.kind;if(s&&!(u==="linearGradient"||u==="radialGradient")){let g=o.block.createFill("color");o.block.setColor(g,"fill/color/value",Ba(s)),o.block.setFill(a,g)}else o.block.setFill(a,eh(o));return ui(o,a,e),r!=null&&r!==1&&o.block.setOpacity(a,r),a}function eh(o){let t=o.block.createFill("color");return o.block.setColor(t,"fill/color/value",{r:0,g:0,b:0,a:0}),t}function Ev(o,t,e){let s={x:ci(o.block.getPositionX(t)),y:ci(o.block.getPositionY(t)),width:ci(o.block.getWidth(t)),height:ci(o.block.getHeight(t))},r={x:e.x,y:e.y,width:e.width,height:e.height},a=Vu(r,s);if(!ju(a))try{o.block.setContentFillMode(t,"Crop"),o.block.setCropScaleRatio(t,a.scaleRatio),o.block.setCropTranslationX(t,a.translationX),o.block.setCropTranslationY(t,a.translationY),a.rotation!==0&&o.block.setCropRotation(t,a.rotation)}catch{}}function ui(o,t,e){o.block.setPositionX(t,$t(e.x)),o.block.setPositionY(t,$t(e.y)),o.block.setWidth(t,$t(e.width)),o.block.setHeight(t,$t(e.height))}function ci(o){return o*72}function wv(o,t){let e=t.rotation??0;if(Math.abs(e)<1e-6)return Iv(o.d,o.x-t.x,o.y-t.y);let s=t.x+t.width*.5,r=t.y+t.height*.5,a=Math.cos(e),c=Math.sin(e),u=(f,g)=>{let m=f+o.x-s,y=g+o.y-r,v=a*m+c*y,S=-c*m+a*y;return[v+t.width*.5,S+t.height*.5]};return kv(o.d,u)}function kv(o,t){let e=c=>`${Math.round(c*100)/100}`,s=o.split(/\s+/),r=[],a=0;for(;a<s.length;){let c=s[a++];if(c==="Z"||c==="z"){r.push("Z");continue}if(c==="M"||c==="L"){let[u,f]=t(parseFloat(s[a++]),parseFloat(s[a++]));r.push(`${c} ${e(u)} ${e(f)}`);continue}if(c==="C"){let[u,f]=t(parseFloat(s[a++]),parseFloat(s[a++])),[g,m]=t(parseFloat(s[a++]),parseFloat(s[a++])),[y,v]=t(parseFloat(s[a++]),parseFloat(s[a++]));r.push(`C ${e(u)} ${e(f)} ${e(g)} ${e(m)} ${e(y)} ${e(v)}`);continue}r.push(c)}return r.join(" ")}function Iv(o,t,e){let s=u=>`${Math.round(u*100)/100}`,r=o.split(/\s+/),a=[],c=0;for(;c<r.length;){let u=r[c++];if(u==="Z"||u==="z"){a.push("Z");continue}if(u==="M"||u==="L"){let f=parseFloat(r[c++]),g=parseFloat(r[c++]);a.push(`${u} ${s(f+t)} ${s(g+e)}`);continue}if(u==="C"){let f=parseFloat(r[c++]),g=parseFloat(r[c++]),m=parseFloat(r[c++]),y=parseFloat(r[c++]),v=parseFloat(r[c++]),S=parseFloat(r[c++]);a.push(`C ${s(f+t)} ${s(g+e)} ${s(m+t)} ${s(y+e)} ${s(v+t)} ${s(S+e)}`);continue}a.push(u)}return a.join(" ")}function Ms(o){return!(o.width>0&&o.height>0)}function Ku(o,t){let e=$u({x:o.x,y:o.y,width:o.width,height:o.height},{x:t.x,y:t.y,width:t.width,height:t.height});return e.width>0&&e.height>0}function Fn(o){return o?.pageIndex!=null?`Page ${o.pageIndex}: `:""}function Ba(o){if(!o)return{r:0,g:0,b:0,a:1};if(o.space==="rgb"){let[e,s,r]=o.values;return{r:e,g:s,b:r,a:1}}if(o.space==="gray"){let[e]=o.values;return{r:e,g:e,b:e,a:1}}if(o.space==="cmyk"){let[e,s,r,a]=o.values;return{c:e,m:s,y:r,k:a,tint:1}}let t=o;return t.space==="spot"?{name:t.name,tint:t.tint??1,externalReference:""}:{r:0,g:0,b:0,a:1}}var nh=new WeakMap;async function ih(o,t,e={}){let s=o.scene.create("VerticalStack");o.scene.setDesignUnit("Inch");let r=o.block.findByType("stack")[0];o.block.setFloat(r,"stack/spacing",Yv),o.block.setBool(r,"stack/spacingInScreenspace",Kv);let a=[],c={fontResolver:e.fontResolver??null,logger:e.logger??null,resolverCache:new Map,textRuns:a},u=e.pageBounds??"trim";ex(o,t,c.logger);for(let f=0;f<t.pages.length;f++){let g=t.pages[f];c.pageIndex=f+1;let m=o.block.create("page");o.block.setWidth(m,$t(g.widthPt)),o.block.setHeight(m,$t(g.heightPt)),o.block.appendChild(r,m);for(let y of g.blocks){let v=await Pv(o,y,t,m,c);v!=null&&(o.block.appendChild(m,v),y.kind===Le.IMAGE&&zu(o,v,y,{logger:c.logger??void 0}),y.kind===Le.TEXT_RUN&&a.push({id:v,ir:y}))}Rv(o,m,g,u)}return Qv(o,a,c),s}function Rv(o,t,e,s){if(s==="media"||!e.trimPt)return;let{xPt:r,yPt:a,widthPt:c,heightPt:u}=e.trimPt,f=$t(r),g=$t(a);if(f!==0||g!==0)for(let m of o.block.getChildren(t))o.block.setPositionX(m,o.block.getPositionX(m)-f),o.block.setPositionY(m,o.block.getPositionY(m)-g);o.block.setWidth(t,$t(c)),o.block.setHeight(t,$t(u)),e.hasBleed&&(o.block.setBool(t,"page/marginEnabled",!0),o.block.setFloat(t,"page/margin/top",$t(e.bleedPt.top)),o.block.setFloat(t,"page/margin/bottom",$t(e.bleedPt.bottom)),o.block.setFloat(t,"page/margin/left",$t(e.bleedPt.left)),o.block.setFloat(t,"page/margin/right",$t(e.bleedPt.right)))}async function Pv(o,t,e,s,r){switch(t.kind){case Le.IMAGE:return Ov(o,t,s,r);case Le.VECTOR_PATH:return oh(o,t,s,r);case Le.TEXT_OUTLINE:return await Mv(o,t,r);case Le.TEXT_RUN:return Zv(o,t,e,r);default:return r?.logger?.emit?.("BLOCK_KIND_UNKNOWN",{kind:t.kind}),null}}function Ov(o,t,e,s){if(t.clips?.length){let c=Zu(o,t,t.clips,e,{logger:s?.logger??void 0,pageIndex:s?.pageIndex});return c===_n?null:c??(s?.logger?.emit?.("IMAGE_CLIP_COMBINE_FAILED",{prefix:Ha(s),bbox:Oe(t),clipCount:t.clips.length,page:s?.pageIndex}),null)}let r=o.block.create("graphic"),a=o.block.createShape("rect");if(o.block.setShape(r,a),!Qn(o,r,t,{logger:s?.logger??void 0})){try{o.block.destroy(r)}catch{}return null}return uh(o,r,t),t.rotation&&Math.abs(t.rotation)>1e-6&&o.block.setRotation(r,t.rotation),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(r,t.opacity),ah(o,r,t.blendMode,s),r}function oh(o,t,e,s){if(t.clips?.length){let c=Qu(o,t,t.clips,e,{logger:s?.logger??void 0,pageIndex:s?.pageIndex});if(c===_n)return null;if(c!=null)return c;s?.logger?.emit?.("CLIP_COMBINE_FAILED",{prefix:Ha(s),bbox:Oe(t),clipCount:t.clips.length,page:s?.pageIndex})}let r=o.block.create("graphic"),a=o.block.createShape("vector_path");o.block.setString(a,"vector_path/path",t.d);try{o.block.setFloat(a,"vector_path/width",t.width),o.block.setFloat(a,"vector_path/height",t.height)}catch{}if(o.block.setShape(r,a),t.fill){let c=t.fill.kind;if(c==="linearGradient"||c==="radialGradient")Lv(o,r,t,s);else{let u=o.block.createFill("color");o.block.setColor(u,"fill/color/value",Ds(t.fill,s,t,"vector path fill")),o.block.setFill(r,u)}}else o.block.setFillEnabled(r,!1);return t.stroke&&(o.block.setStrokeEnabled(r,!0),o.block.setStrokeColor(r,Ds(t.stroke,s,t,"vector path stroke")),t.strokeWidth!=null&&o.block.setStrokeWidth(r,$t(t.strokeWidth))),uh(o,r,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(r,t.opacity),ah(o,r,t.blendMode,s),r}function ah(o,t,e,s){let r=oi(e,s?.logger??void 0);r!=null&&(typeof o.block.supportsBlendMode=="function"&&!o.block.supportsBlendMode(t)||o.block.setBlendMode(t,r))}function Lv(o,t,e,s){let r=e.fill,a=r.kind==="linearGradient"?"gradient/linear":"gradient/radial",c=o.block.createFill(a),u=(r.stops??[]).map(m=>({color:Ds(m.color,s,e,"vector path gradient stop"),stop:m.offset}));o.block.setGradientColorStops(c,"fill/gradient/colors",u);let f=e.width>0?e.width:1,g=e.height>0?e.height:1;if(r.kind==="linearGradient")o.block.setFloat(c,"fill/gradient/linear/startPointX",(r.start.x-e.x)/f),o.block.setFloat(c,"fill/gradient/linear/startPointY",(r.start.y-e.y)/g),o.block.setFloat(c,"fill/gradient/linear/endPointX",(r.end.x-e.x)/f),o.block.setFloat(c,"fill/gradient/linear/endPointY",(r.end.y-e.y)/g);else{let m=Math.max(.001,Math.min(f,g));o.block.setFloat(c,"fill/gradient/radial/centerPointX",(r.center.x-e.x)/f),o.block.setFloat(c,"fill/gradient/radial/centerPointY",(r.center.y-e.y)/g),o.block.setFloat(c,"fill/gradient/radial/radius",r.radius/m)}o.block.setFill(t,c)}async function Mv(o,t,e){let s=await Dv(o,t,e);if(s){let a=await Bv(o,t,s,e);return a!=null&&e?.textRuns&&e.textRuns.push({id:a,ir:{kind:Le.TEXT_RUN,x:t.x,y:t.y,width:t.width,height:t.height,text:t.text,fontRef:t.fontFamily,fontSize:t.fontSize,rotation:0,fill:t.fill}}),a}let r=oh(o,{kind:Le.VECTOR_PATH,x:t.x,y:t.y,width:t.width,height:t.height,d:t.d,fill:t.fill,stroke:null,strokeWidth:0,opacity:t.opacity},0,e);if(r!=null){let a=_v(t,e);Uv(o,r,t,a)}return r}async function Dv(o,t,e){if(!e||!e.fontResolver||!t.fontFamily)return null;let s=t.fontStyle??"normal",r=t.fontWeight??"normal",a=`${t.fontFamily}|${s}|${r}`,c=e.resolverCache.get(a);if(c!==void 0)return c;let u=null;try{u=await e.fontResolver({family:t.fontFamily,style:s,weight:r},o)}catch{e.logger?.emit?.("FONT_RESOLVER_MISS",{fontFamily:t.fontFamily}),u=null}return u?e.logger?.emit?.("FONT_SUBSTITUTED",{fontFamily:t.fontFamily,substitutedName:u.typeface?.name??"?"}):e.logger?.emit?.("FONT_NOT_FOUND_IN_ASSETS",{fontFamily:t.fontFamily}),e.resolverCache.set(a,u),u}async function Fv(o,t,e,s){let r=t?.font?.uri,a=o.editor;if(!r||typeof a?.getFontMetrics!="function"||!s)return null;s.fontMetricsCache||(s.fontMetricsCache=new Map);let c=s.fontMetricsCache.get(r);if(c===void 0){try{c=await a.getFontMetrics(r)}catch{c=null}s.fontMetricsCache.set(r,c)}return!c||!c.unitsPerEm||c.ascender==null?null:c.ascender/c.unitsPerEm*e}function _v(o,t){return!t||!t.fontResolver?"resolver-disabled":o.fontFamily?"resolver-miss":"no-font-family"}var Nv="ly.img.pdf-importer.text";function Uv(o,t,e,s){if(typeof o.block?.setMetadata!="function")return;let r=(a,c)=>{if(!(c==null||c===""))try{o.block.setMetadata(t,`${Nv}.${a}`,String(c))}catch{}};r("content",e.text),r("fontFamily",e.fontFamily),typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)&&r("fontSize",e.fontSize),r("fontStyle",e.fontStyle),r("fontWeight",e.fontWeight),r("fallbackReason",s)}function lh(o,t,e,s,r){let a=o.block.create("text");return Hv(o,a,s),e(o,a),jv(o,a,t,r),t.rotation&&o.block.setRotation(a,t.rotation),a}async function Bv(o,t,e,s){let r=await Gv(o,t,e,s);return lh(o,t,(a,c)=>{let u=a.block;if(typeof u.setTypeface=="function"&&u.setTypeface(c,e.typeface),typeof u.setTextFontStyle=="function"&&e.font?.style)try{u.setTextFontStyle(c,e.font.style)}catch{}if(typeof u.setTextFontWeight=="function"&&e.font?.weight)try{u.setTextFontWeight(c,e.font.weight)}catch{}},r,s)}async function Gv(o,t,e,s){if(!(Math.abs(t.rotation??0)>1e-6)){if(!Number.isFinite(t.textOriginX)&&!Number.isFinite(t.textOriginY))return t;let T={};if(Number.isFinite(t.textOriginX)&&(T.x=t.textOriginX),Number.isFinite(t.textOriginY)){let w=await Fv(o,e,t.fontSize,s);w!=null&&(T.y=(t.textOriginY??0)-w)}return{...t,...T}}let a=t.unrotWidth!=null&&Number.isFinite(t.unrotWidth)&&t.unrotWidth>0?t.unrotWidth:t.width,c=t.unrotHeight!=null&&Number.isFinite(t.unrotHeight)&&t.unrotHeight>0?t.unrotHeight:t.height,u=t.rotation??0,f=Math.sin(u),g=Math.cos(u),m=t.x+t.width/2,y=t.y+t.height/2,v=m-a/2+c/2*f,S=y-c/2*g;return{...t,x:v,y:S,width:a,height:c}}function Hv(o,t,e){o.block.setPositionX(t,$t(e.x)),o.block.setPositionY(t,$t(e.y)),o.block.setWidth(t,$t(e.width)),typeof o.block.setWidthMode=="function"&&o.block.setWidthMode(t,"Absolute"),typeof o.block.setHeightMode=="function"&&o.block.setHeightMode(t,"Auto")}function jv(o,t,e,s){typeof o.block.setTextFontSize=="function"?o.block.setTextFontSize(t,e.fontSize):o.block.setFloat(t,"text/fontSize",e.fontSize),typeof o.block.replaceText=="function"?o.block.replaceText(t,e.text):o.block.setString(t,"text/text",e.text),ch(o,t,e,s);let r=e.opacity;r!=null&&r!==1&&o.block.setOpacity(t,r)}function ch(o,t,e,s){let r=e.colorSpans;if(Array.isArray(r)&&r.length>0){if(typeof o.block.setTextColor=="function")for(let a of r){if(!a.fill)continue;let c=Ds(a.fill,s,e,"text");o.block.setTextColor(t,c,a.from,a.to)}}else if(e.fill){let a=Ds(e.fill,s,e,"text");if(typeof o.block.setTextColor=="function")o.block.setTextColor(t,a);else try{o.block.setColor(t,"fill/color/value",a)}catch{}}}var Vv=!0,$v=-.01,sh=-.15,zv=15,Wv=1.05,rh=1.5,Xv=9,Yv=32,Kv=!0;function Zv(o,t,e,s){let r=e.fonts?.get?.(t.fontRef);if(!r)return s?.logger?.emit?.("FONT_REF_NOT_EXTRACTED",{fontRef:t.fontRef}),null;let{uri:a,typeface:c}=tx(o,r);return lh(o,t,(u,f)=>{typeof u.block.setFont=="function"&&u.block.setFont(f,a,c)},t,s)}function Qv(o,t,e){if(Vv&&typeof o.block.getTextVisibleLineCount=="function")for(let{id:s,ir:r}of t)Jv(o,s,r,e)}function Jv(o,t,e,s){let r=$t(e.width),a=Ga(o,t,e,s);if(a<=1)return;let c=0;for(let f=0;f<zv&&(c=Math.max(sh,c+$v),o.block.setFloat(t,"text/letterSpacing",c),a=Ga(o,t,e,s),!(a<=1||c<=sh));f++);if(a<=1)return;let u=1;for(let f=0;f<Xv&&(u=Math.min(rh,u*Wv),o.block.setWidth(t,r*u),a=Ga(o,t,e,s),!(a<=1||u>=rh));f++);a>1&&s?.logger?.emit?.("TEXT_OVERFLOW_AFTER_AUTOSIZE",{text:qv(e.text,30),overflowLines:a-1})}function Ga(o,t,e,s){typeof o.block.replaceText=="function"?o.block.replaceText(t,e.text):o.block.setString(t,"text/text",e.text),ch(o,t,e,s);try{return o.block.getTextVisibleLineCount(t)}catch{return 1}}function qv(o,t){return o.length>t?o.slice(0,t-1)+"\u2026":o}function tx(o,t){let e=nh.get(o);e||(e=new Map,nh.set(o,e));let s=e.get(t.postScriptName);if(s)return s;let r=o.editor.createBuffer(),a=t.data instanceof Uint8Array?t.data:new Uint8Array(t.data);o.editor.setBufferData(r,0,a);let c={name:t.postScriptName,fonts:[{uri:r,subFamily:t.family,weight:Ra(t.weight),style:t.style??"normal"}]},u={uri:r,typeface:c};return e.set(t.postScriptName,u),u}function uh(o,t,e){o.block.setPositionX(t,$t(e.x)),o.block.setPositionY(t,$t(e.y)),o.block.setWidth(t,$t(e.width)),o.block.setHeight(t,$t(e.height))}function ex(o,t,e){if(!o?.editor?.setSpotColorCMYK)return;let s=new Map,r=a=>{let c=a;!c||c.space!=="spot"||!c.name||s.has(c.name)||s.set(c.name,{alt:c.alternateSpace??"DeviceCMYK",solid:Array.isArray(c.solid)?c.solid:[]})};for(let a of t.pages??[])for(let c of a.blocks??[])r(c.fill),r(c.stroke);for(let[a,c]of s)try{if(c.alt==="DeviceCMYK"&&c.solid.length>=4){let[u,f,g,m]=c.solid;o.editor.setSpotColorCMYK(a,u,f,g,m)}else if(c.alt==="DeviceGray"&&c.solid.length>=1){let u=c.solid[0];o.editor.setSpotColorRGB(a,u,u,u)}else if(c.alt==="DeviceRGB"&&c.solid.length>=3){let[u,f,g]=c.solid;o.editor.setSpotColorRGB(a,u,f,g)}else e?.emit?.("SPOT_COLOR_NO_ALTERNATE",{name:a})}catch(u){let f=u&&typeof u=="object"&&"message"in u?String(u.message):String(u);e?.emit?.("SPOT_COLOR_REGISTER_FAILED",{name:a,error:f})}}function Ds(o,t,e,s){if(!o)return{r:0,g:0,b:0,a:1};if(o.space==="rgb"){let[a,c,u]=o.values;return{r:a,g:c,b:u,a:1}}if(o.space==="gray"){let[a]=o.values;return{r:a,g:a,b:a,a:1}}if(o.space==="cmyk"){let[a,c,u,f]=o.values;return{c:a,m:c,y:u,k:f,tint:1}}let r=o;return r.space==="spot"?{name:r.name,tint:r.tint??1,externalReference:""}:(t?.logger?.emit?.("COLOR_SPACE_UNSUPPORTED",{prefix:Ha(t),elementLabel:nx(s),space:r.space,color:Au(o),bbox:Oe(e),page:t?.pageIndex,element:s??null}),{r:0,g:0,b:0,a:1})}function Ha(o){return o?.pageIndex!=null?`Page ${o.pageIndex}: `:""}function nx(o){return o?`${o} `:""}function fh(o){let t=[],e=null,s=()=>{e&&(e.runs.length===1?t.push(e.runs[0]):t.push(cx(e.runs)),e=null)};for(let r of o){if(r.kind!==Le.TEXT_RUN){s(),t.push(r);continue}let a=r;if(!e){e={runs:[a]};continue}let c=e.runs[e.runs.length-1];ox(c,a)?e.runs.push(a):(s(),e={runs:[a]})}return s(),t}var sx=.15,rx=.5,ix=.5;function ox(o,t){return o.fontRef!==t.fontRef||Math.abs(o.fontSize-t.fontSize)>.5||Math.abs((o.rotation??0)-(t.rotation??0))>.001?!1:o.baselineXPt!=null&&o.baselineYPt!=null&&o.advanceWidthPt!=null&&t.baselineXPt!=null&&t.baselineYPt!=null?ax(o,t):lx(o,t)}function ax(o,t){let e=o.fontSize||10,s=o.rotation??0,r=Math.cos(s),a=Math.sin(s),c=o.baselineXPt,u=o.baselineYPt,f=o.advanceWidthPt,g=t.baselineXPt,m=t.baselineYPt,y=c+f*r,v=u+f*a,S=g-y,T=m-v,w=S*r+T*a,I=-S*a+T*r;return!(Math.abs(I)>rx*e||w<-ix*e||w>sx*e)}function lx(o,t){let e=o.fontSize||10,s=o.rotation??0,r=Math.cos(s),a=Math.sin(s),c=t.x+t.width/2-(o.x+o.width/2),u=t.y+t.height/2-(o.y+o.height/2);if(Math.abs(c*-a+u*r)>.5*e)return!1;let g=Math.abs(c*r+u*a),m=(o.width+t.width)/2;return!(g>m)}function cx(o){let t=o[0],e=Math.min(...o.map(m=>m.x)),s=Math.min(...o.map(m=>m.y)),r=Math.max(...o.map(m=>m.x+m.width)),a=Math.max(...o.map(m=>m.y+m.height)),c="",u=[];for(let m of o){let y=c.length;if(Array.isArray(m.colorSpans)&&m.colorSpans.length>0)for(let v of m.colorSpans)u.push({from:y+v.from,to:y+v.to,fill:v.fill??null});else u.push({from:y,to:y+m.text.length,fill:m.fill??null});c+=m.text}let f=[];for(let m of u){let y=f[f.length-1];y&&ja(y.fill,m.fill)&&y.to===m.from?y.to=m.to:f.push({...m})}let g=f.every(m=>ja(m.fill,f[0].fill));return{...t,x:e,y:s,width:r-e,height:a-s,text:c,...g?{}:{colorSpans:f}}}var ux=.5,hh=.3;function ph(o){let t=[],e=null,s=()=>{e&&(e.length===1?t.push(e[0]):t.push(dx(e)),e=null)};for(let r of o){if(r.kind!==Le.TEXT_OUTLINE){s(),t.push(r);continue}let a=r;if(!e){e=[a];continue}let c=e[e.length-1];hx(c,a)?e.push(a):(s(),e=[a])}return s(),t}function hx(o,t){if(!o.fontFamily||!t.fontFamily||o.fontFamily!==t.fontFamily||Math.abs((o.fontSize??0)-(t.fontSize??0))>.5||(o.fontStyle??"normal")!==(t.fontStyle??"normal")||(o.fontWeight??"normal")!==(t.fontWeight??"normal")||!ja(o.fill,t.fill))return!1;let e=o.fontSize||10;if(Math.abs(o.y-t.y)>e*hh||Math.abs(o.y+o.height-(t.y+t.height))>e*hh)return!1;let s=o.x+o.width,r=t.x-s,a=e*ux;return!(r>a||r<-a)}function ja(o,t){if(o==null&&t==null)return!0;if(o==null||t==null||o.space!==t.space||(o.alpha??1)!==(t.alpha??1)||!o.values||!t.values||o.values.length!==t.values.length)return!1;for(let e=0;e<o.values.length;e++)if(Math.abs(o.values[e]-t.values[e])>1e-6)return!1;return!0}function dx(o){let t=o[0],e=Math.min(...o.map(m=>m.x)),s=Math.min(...o.map(m=>m.y)),r=Math.max(...o.map(m=>m.x+m.width)),a=Math.max(...o.map(m=>m.y+m.height)),c=o.map(m=>m.text??"").join(""),u=o.map(m=>fx(m.d??"",m.x-e,m.y-s)).filter(m=>m.length>0).join(" "),f=o.map(m=>m.textOriginX).filter(m=>Number.isFinite(m)),g=f.length>0?Math.min(...f):void 0;return{...t,x:e,y:s,width:r-e,height:a-s,text:c,d:u,textOriginX:g}}function fx(o,t,e){if(!o)return"";if(Math.abs(t)<1e-9&&Math.abs(e)<1e-9)return o;let s=o.trim().split(/\s+/),r=[],a=0;for(;a<s.length;){let c=s[a];if(c==="Z"||c==="z"){r.push(c),a++;continue}if(/^[A-Za-z]$/.test(c)){let u=c,f=px(u);r.push(u);for(let g=0;g<f;g++){let m=Number(s[a+1+g*2]),y=Number(s[a+2+g*2]);if(!Number.isFinite(m)||!Number.isFinite(y)){r.push(s[a+1+g*2],s[a+2+g*2]);continue}r.push(dh(m+t),dh(y+e))}a+=1+f*2;continue}r.push(c),a++}return r.join(" ")}function px(o){switch(o){case"M":case"m":case"L":case"l":case"T":case"t":return 1;case"Q":case"q":case"S":case"s":return 2;case"C":case"c":return 3;default:return 0}}function dh(o){return`${Math.round(o*100)/100}`}var Va=class o{engine;pdfBytes;fontResolver;pageBounds;logger=new ls(Mc);constructor(t,e,s,r="trim"){this.engine=t,this.pdfBytes=e,this.fontResolver=s??$i,this.pageBounds=r}static async fromFile(t,e,s){let r;e instanceof ArrayBuffer?r=e:r=await e.arrayBuffer();let a=new Uint8Array(r);return typeof s=="function"?new o(t,a,s):new o(t,a,s?.fontResolver,s?.pageBounds)}async parse(){let t=this.engine,e=await Gu(this.pdfBytes,{textMode:"auto",logger:this.logger});this.logger.emit("DOC_PAGE_COUNT",{count:e.pages.length});for(let r=0;r<e.pages.length;r++){let a=gx(e.pages[r].blocks);this.logger.emit("DOC_PAGE_BLOCK_COUNT",{page:r,imageCount:a.image,vectorCount:a.vector,textCount:a.text,outlineCount:a.outline})}for(let r of e.pages)r.blocks=ph(r.blocks),r.blocks=fh(r.blocks);return{scene:await ih(t,e,{fontResolver:this.fontResolver,logger:this.logger,pageBounds:this.pageBounds}),logger:this.logger}}getLogger(){return this.logger}};function gx(o){let t={image:0,vector:0,text:0,outline:0};for(let e of o)e.kind==="image"?t.image++:e.kind==="vector-path"?t.vector++:e.kind==="text-run"?t.text++:e.kind==="text-outline"&&t.outline++;return t}export{ls as Logger,Va as PDFParser,d0 as addGfontsAssetLibrary};
|
|
10
|
+
`)}`,this.#d();let b=new Range,v=g.reduce((S,T)=>S+T.length,0);for(let{firstChild:S}of this.editorDiv.childNodes)if(S.nodeType===Node.TEXT_NODE){let T=S.nodeValue.length;if(v<=T){b.setStart(S,v),b.setEnd(S,v);break}v-=T}a.removeAllRanges(),a.addRange(b)}#d(){if(this.editorDiv.replaceChildren(),!!this.#e)for(let t of this.#e.split(`
|
|
11
|
+
`)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#h(){return this.#e.replaceAll("\xA0"," ")}static#f(t){return t.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,n){let r=null;if(t instanceof Hr){let{data:{defaultAppearanceData:{fontSize:c,fontColor:u},rect:f,rotation:g,id:m,popupRef:b},textContent:v,textPosition:S,parent:{page:{pageNumber:T}}}=t;if(!v||v.length===0)return null;r=t={annotationType:Rt.FREETEXT,color:Array.from(u),fontSize:c,value:v.join(`
|
|
12
|
+
`),position:S,pageIndex:T-1,rect:f.slice(0),rotation:g,id:m,deleted:!1,popupRef:b}}let a=await super.deserialize(t,e,n);return a.#i=t.fontSize,a.#t=St.makeHexColor(...t.color),a.#e=o.#f(t.value),a.annotationElementId=t.id||null,a._initialData=r,a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=o._internalPadding*this.parentScale,n=this.getRect(e,e),r=Xt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),a={annotationType:Rt.FREETEXT,color:r,fontSize:this.#i,value:this.#h(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?a:this.annotationElementId&&!this.#o(a)?null:(a.id=this.annotationElementId,a)}#o(t){let{value:e,fontSize:n,color:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==n||t.color.some((c,u)=>c!==r[u])||t.pageIndex!==a}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(this.deleted)return e;let{style:n}=e;n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#t,e.replaceChildren();for(let a of this.#e.split(`
|
|
13
|
+
`)){let c=document.createElement("div");c.append(a?document.createTextNode(a):document.createElement("br")),e.append(c)}let r=o._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(r,r),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}},ht=class{static PRECISION=1e-4;toSVGPath(){$t("Abstract method `toSVGPath` must be implemented.")}get box(){$t("Abstract getter `box` must be implemented.")}serialize(t,e){$t("Abstract method `serialize` must be implemented.")}static _rescale(t,e,n,r,a,c){c||=new Float32Array(t.length);for(let u=0,f=t.length;u<f;u+=2)c[u]=e+t[u]*r,c[u+1]=n+t[u+1]*a;return c}static _rescaleAndSwap(t,e,n,r,a,c){c||=new Float32Array(t.length);for(let u=0,f=t.length;u<f;u+=2)c[u]=e+t[u+1]*r,c[u+1]=n+t[u]*a;return c}static _translate(t,e,n,r){r||=new Float32Array(t.length);for(let a=0,c=t.length;a<c;a+=2)r[a]=e+t[a],r[a+1]=n+t[a+1];return r}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,n,r,a){switch(a){case 90:return[1-e/n,t/r];case 180:return[1-t/n,1-e/r];case 270:return[e/n,1-t/r];default:return[t/n,e/r]}}static _normalizePagePoint(t,e,n){switch(n){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,n,r,a,c){return[(t+5*n)/6,(e+5*r)/6,(5*n+a)/6,(5*r+c)/6,(n+a)/2,(r+c)/2]}},zr=class o{#t;#e=[];#n;#s;#i=[];#r=new Float32Array(18);#l;#a;#u;#c;#d;#h;#f=[];static#o=8;static#p=2;static#m=o.#o+o.#p;constructor({x:t,y:e},n,r,a,c,u=0){this.#t=n,this.#h=a*r,this.#s=c,this.#r.set([NaN,NaN,NaN,NaN,t,e],6),this.#n=u,this.#c=o.#o*r,this.#u=o.#m*r,this.#d=r,this.#f.push(t,e)}isEmpty(){return isNaN(this.#r[8])}#g(){let t=this.#r.subarray(4,6),e=this.#r.subarray(16,18),[n,r,a,c]=this.#t;return[(this.#l+(t[0]-e[0])/2-n)/a,(this.#a+(t[1]-e[1])/2-r)/c,(this.#l+(e[0]-t[0])/2-n)/a,(this.#a+(e[1]-t[1])/2-r)/c]}add({x:t,y:e}){this.#l=t,this.#a=e;let[n,r,a,c]=this.#t,[u,f,g,m]=this.#r.subarray(8,12),b=t-g,v=e-m,S=Math.hypot(b,v);if(S<this.#u)return!1;let T=S-this.#c,w=T/S,I=w*b,k=w*v,O=u,F=f;u=g,f=m,g+=I,m+=k,this.#f?.push(t,e);let _=-k/T,D=I/T,G=_*this.#h,j=D*this.#h;return this.#r.set(this.#r.subarray(2,8),0),this.#r.set([g+G,m+j],4),this.#r.set(this.#r.subarray(14,18),12),this.#r.set([g-G,m-j],16),isNaN(this.#r[6])?(this.#i.length===0&&(this.#r.set([u+G,f+j],2),this.#i.push(NaN,NaN,NaN,NaN,(u+G-n)/a,(f+j-r)/c),this.#r.set([u-G,f-j],14),this.#e.push(NaN,NaN,NaN,NaN,(u-G-n)/a,(f-j-r)/c)),this.#r.set([O,F,u,f,g,m],6),!this.isEmpty()):(this.#r.set([O,F,u,f,g,m],6),Math.abs(Math.atan2(F-f,O-u)-Math.atan2(k,I))<Math.PI/2?([u,f,g,m]=this.#r.subarray(2,6),this.#i.push(NaN,NaN,NaN,NaN,((u+g)/2-n)/a,((f+m)/2-r)/c),[u,f,O,F]=this.#r.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((O+u)/2-n)/a,((F+f)/2-r)/c),!0):([O,F,u,f,g,m]=this.#r.subarray(0,6),this.#i.push(((O+5*u)/6-n)/a,((F+5*f)/6-r)/c,((5*u+g)/6-n)/a,((5*f+m)/6-r)/c,((u+g)/2-n)/a,((f+m)/2-r)/c),[g,m,u,f,O,F]=this.#r.subarray(12,18),this.#e.push(((O+5*u)/6-n)/a,((F+5*f)/6-r)/c,((5*u+g)/6-n)/a,((5*f+m)/6-r)/c,((u+g)/2-n)/a,((f+m)/2-r)/c),!0))}toSVGPath(){if(this.isEmpty())return"";let t=this.#i,e=this.#e;if(isNaN(this.#r[6])&&!this.isEmpty())return this.#b();let n=[];n.push(`M${t[4]} ${t[5]}`);for(let r=6;r<t.length;r+=6)isNaN(t[r])?n.push(`L${t[r+4]} ${t[r+5]}`):n.push(`C${t[r]} ${t[r+1]} ${t[r+2]} ${t[r+3]} ${t[r+4]} ${t[r+5]}`);this.#y(n);for(let r=e.length-6;r>=6;r-=6)isNaN(e[r])?n.push(`L${e[r+4]} ${e[r+5]}`):n.push(`C${e[r]} ${e[r+1]} ${e[r+2]} ${e[r+3]} ${e[r+4]} ${e[r+5]}`);return this.#x(n),n.join(" ")}#b(){let[t,e,n,r]=this.#t,[a,c,u,f]=this.#g();return`M${(this.#r[2]-t)/n} ${(this.#r[3]-e)/r} L${(this.#r[4]-t)/n} ${(this.#r[5]-e)/r} L${a} ${c} L${u} ${f} L${(this.#r[16]-t)/n} ${(this.#r[17]-e)/r} L${(this.#r[14]-t)/n} ${(this.#r[15]-e)/r} Z`}#x(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#y(t){let[e,n,r,a]=this.#t,c=this.#r.subarray(4,6),u=this.#r.subarray(16,18),[f,g,m,b]=this.#g();t.push(`L${(c[0]-e)/r} ${(c[1]-n)/a} L${f} ${g} L${m} ${b} L${(u[0]-e)/r} ${(u[1]-n)/a}`)}newFreeDrawOutline(t,e,n,r,a,c){return new Wr(t,e,n,r,a,c)}getOutlines(){let t=this.#i,e=this.#e,n=this.#r,[r,a,c,u]=this.#t,f=new Float32Array((this.#f?.length??0)+2);for(let b=0,v=f.length-2;b<v;b+=2)f[b]=(this.#f[b]-r)/c,f[b+1]=(this.#f[b+1]-a)/u;if(f[f.length-2]=(this.#l-r)/c,f[f.length-1]=(this.#a-a)/u,isNaN(n[6])&&!this.isEmpty())return this.#S(f);let g=new Float32Array(this.#i.length+24+this.#e.length),m=t.length;for(let b=0;b<m;b+=2){if(isNaN(t[b])){g[b]=g[b+1]=NaN;continue}g[b]=t[b],g[b+1]=t[b+1]}m=this.#w(g,m);for(let b=e.length-6;b>=6;b-=6)for(let v=0;v<6;v+=2){if(isNaN(e[b+v])){g[m]=g[m+1]=NaN,m+=2;continue}g[m]=e[b+v],g[m+1]=e[b+v+1],m+=2}return this.#T(g,m),this.newFreeDrawOutline(g,f,this.#t,this.#d,this.#n,this.#s)}#S(t){let e=this.#r,[n,r,a,c]=this.#t,[u,f,g,m]=this.#g(),b=new Float32Array(36);return b.set([NaN,NaN,NaN,NaN,(e[2]-n)/a,(e[3]-r)/c,NaN,NaN,NaN,NaN,(e[4]-n)/a,(e[5]-r)/c,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,g,m,NaN,NaN,NaN,NaN,(e[16]-n)/a,(e[17]-r)/c,NaN,NaN,NaN,NaN,(e[14]-n)/a,(e[15]-r)/c],0),this.newFreeDrawOutline(b,t,this.#t,this.#d,this.#n,this.#s)}#T(t,e){let n=this.#e;return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+=6}#w(t,e){let n=this.#r.subarray(4,6),r=this.#r.subarray(16,18),[a,c,u,f]=this.#t,[g,m,b,v]=this.#g();return t.set([NaN,NaN,NaN,NaN,(n[0]-a)/u,(n[1]-c)/f,NaN,NaN,NaN,NaN,g,m,NaN,NaN,NaN,NaN,b,v,NaN,NaN,NaN,NaN,(r[0]-a)/u,(r[1]-c)/f],e),e+=24}},Wr=class extends ht{#t;#e=new Float32Array(4);#n;#s;#i;#r;#l;constructor(t,e,n,r,a,c){super(),this.#l=t,this.#i=e,this.#t=n,this.#r=r,this.#n=a,this.#s=c,this.lastPoint=[NaN,NaN],this.#a(c);let[u,f,g,m]=this.#e;for(let b=0,v=t.length;b<v;b+=2)t[b]=(t[b]-u)/g,t[b+1]=(t[b+1]-f)/m;for(let b=0,v=e.length;b<v;b+=2)e[b]=(e[b]-u)/g,e[b+1]=(e[b+1]-f)/m}toSVGPath(){let t=[`M${this.#l[4]} ${this.#l[5]}`];for(let e=6,n=this.#l.length;e<n;e+=6){if(isNaN(this.#l[e])){t.push(`L${this.#l[e+4]} ${this.#l[e+5]}`);continue}t.push(`C${this.#l[e]} ${this.#l[e+1]} ${this.#l[e+2]} ${this.#l[e+3]} ${this.#l[e+4]} ${this.#l[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,n,r],a){let c=n-t,u=r-e,f,g;switch(a){case 0:f=ht._rescale(this.#l,t,r,c,-u),g=ht._rescale(this.#i,t,r,c,-u);break;case 90:f=ht._rescaleAndSwap(this.#l,t,e,c,u),g=ht._rescaleAndSwap(this.#i,t,e,c,u);break;case 180:f=ht._rescale(this.#l,n,e,-c,u),g=ht._rescale(this.#i,n,e,-c,u);break;case 270:f=ht._rescaleAndSwap(this.#l,n,r,-c,-u),g=ht._rescaleAndSwap(this.#i,n,r,-c,-u);break}return{outline:Array.from(f),points:[Array.from(g)]}}#a(t){let e=this.#l,n=e[4],r=e[5],a=n,c=r,u=n,f=r,g=n,m=r,b=t?Math.max:Math.min;for(let S=6,T=e.length;S<T;S+=6){if(isNaN(e[S]))a=Math.min(a,e[S+4]),c=Math.min(c,e[S+5]),u=Math.max(u,e[S+4]),f=Math.max(f,e[S+5]),m<e[S+5]?(g=e[S+4],m=e[S+5]):m===e[S+5]&&(g=b(g,e[S+4]));else{let w=St.bezierBoundingBox(n,r,...e.slice(S,S+6));a=Math.min(a,w[0]),c=Math.min(c,w[1]),u=Math.max(u,w[2]),f=Math.max(f,w[3]),m<w[3]?(g=w[2],m=w[3]):m===w[3]&&(g=b(g,w[2]))}n=e[S+4],r=e[S+5]}let v=this.#e;v[0]=a-this.#n,v[1]=c-this.#n,v[2]=u-a+2*this.#n,v[3]=f-c+2*this.#n,this.lastPoint=[g,m]}get box(){return this.#e}newOutliner(t,e,n,r,a,c=0){return new zr(t,e,n,r,a,c)}getNewOutline(t,e){let[n,r,a,c]=this.#e,[u,f,g,m]=this.#t,b=a*g,v=c*m,S=n*g+u,T=r*m+f,w=this.newOutliner({x:this.#i[0]*b+S,y:this.#i[1]*v+T},this.#t,this.#r,t,this.#s,e??this.#n);for(let I=2;I<this.#i.length;I+=2)w.add({x:this.#i[I]*b+S,y:this.#i[I+1]*v+T});return w.getOutlines()}},Os=class{#t;#e;#n=[];#s=[];constructor(t,e=0,n=0,r=!0){let a=1/0,c=-1/0,u=1/0,f=-1/0,m=10**-4;for(let{x:k,y:O,width:F,height:_}of t){let D=Math.floor((k-e)/m)*m,G=Math.ceil((k+F+e)/m)*m,j=Math.floor((O-e)/m)*m,W=Math.ceil((O+_+e)/m)*m,$=[D,j,W,!0],Z=[G,j,W,!1];this.#n.push($,Z),a=Math.min(a,D),c=Math.max(c,G),u=Math.min(u,j),f=Math.max(f,W)}let b=c-a+2*n,v=f-u+2*n,S=a-n,T=u-n,w=this.#n.at(r?-1:-2),I=[w[0],w[2]];for(let k of this.#n){let[O,F,_]=k;k[0]=(O-S)/b,k[1]=(F-T)/v,k[2]=(_-T)/v}this.#t=new Float32Array([S,T,b,v]),this.#e=I}getOutlines(){this.#n.sort((e,n)=>e[0]-n[0]||e[1]-n[1]||e[2]-n[2]);let t=[];for(let e of this.#n)e[3]?(t.push(...this.#u(e)),this.#l(e)):(this.#a(e),t.push(...this.#u(e)));return this.#i(t)}#i(t){let e=[],n=new Set;for(let c of t){let[u,f,g]=c;e.push([u,f,c],[u,g,c])}e.sort((c,u)=>c[1]-u[1]||c[0]-u[0]);for(let c=0,u=e.length;c<u;c+=2){let f=e[c][2],g=e[c+1][2];f.push(g),g.push(f),n.add(f),n.add(g)}let r=[],a;for(;n.size>0;){let c=n.values().next().value,[u,f,g,m,b]=c;n.delete(c);let v=u,S=f;for(a=[u,g],r.push(a);;){let T;if(n.has(m))T=m;else if(n.has(b))T=b;else break;n.delete(T),[u,f,g,m,b]=T,v!==u&&(a.push(v,S,u,S===f?f:g),v=u),S=S===f?g:f}a.push(v,S)}return new wa(r,this.#t,this.#e)}#r(t){let e=this.#s,n=0,r=e.length-1;for(;n<=r;){let a=n+r>>1,c=e[a][0];if(c===t)return a;c<t?n=a+1:r=a-1}return r+1}#l([,t,e]){let n=this.#r(t);this.#s.splice(n,0,[t,e])}#a([,t,e]){let n=this.#r(t);for(let r=n;r<this.#s.length;r++){let[a,c]=this.#s[r];if(a!==t)break;if(a===t&&c===e){this.#s.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[a,c]=this.#s[r];if(a!==t)break;if(a===t&&c===e){this.#s.splice(r,1);return}}}#u(t){let[e,n,r]=t,a=[[e,n,r]],c=this.#r(r);for(let u=0;u<c;u++){let[f,g]=this.#s[u];for(let m=0,b=a.length;m<b;m++){let[,v,S]=a[m];if(!(g<=v||S<=f)){if(v>=f){if(S>g)a[m][1]=g;else{if(b===1)return[];a.splice(m,1),m--,b--}continue}a[m][2]=f,S>g&&a.push([e,g,S])}}}return a}},wa=class extends ht{#t;#e;constructor(t,e,n){super(),this.#e=t,this.#t=e,this.lastPoint=n}toSVGPath(){let t=[];for(let e of this.#e){let[n,r]=e;t.push(`M${n} ${r}`);for(let a=2;a<e.length;a+=2){let c=e[a],u=e[a+1];c===n?(t.push(`V${u}`),r=u):u===r&&(t.push(`H${c}`),n=c)}t.push("Z")}return t.join(" ")}serialize([t,e,n,r],a){let c=[],u=n-t,f=r-e;for(let g of this.#e){let m=new Array(g.length);for(let b=0;b<g.length;b+=2)m[b]=t+g[b]*u,m[b+1]=r-g[b+1]*f;c.push(m)}return c}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}},Ms=class extends zr{newFreeDrawOutline(t,e,n,r,a,c){return new Ea(t,e,n,r,a,c)}},Ea=class extends Wr{newOutliner(t,e,n,r,a,c=0){return new Ms(t,e,n,r,a,c)}},Xr=class o{#t=null;#e=null;#n;#s=null;#i=!1;#r=!1;#l=null;#a;#u=null;#c=null;#d;static#h=null;static get _keyboardManager(){return Ot(this,"_keyboardManager",new Ln([[["Escape","mac+Escape"],o.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],o.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],o.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],o.prototype._moveToPrevious],[["Home","mac+Home"],o.prototype._moveToBeginning],[["End","mac+End"],o.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#r=!1,this.#d=Mt.HIGHLIGHT_COLOR,this.#l=t):(this.#r=!0,this.#d=Mt.HIGHLIGHT_DEFAULT_COLOR),this.#c=t?._uiManager||e,this.#a=this.#c._eventBus,this.#n=t?.color||this.#c?.highlightColors.values().next().value||"#FFFF98",o.#h||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);let e=this.#c._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});let n=this.#e=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#n,t.append(n),t}renderMainDropdown(){let t=this.#s=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){let t=document.createElement("div"),e=this.#c._signal;t.addEventListener("contextmenu",He,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(let[n,r]of this.#c.highlightColors){let a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",r),a.title=n,a.setAttribute("data-l10n-id",o.#h[n]);let c=document.createElement("span");a.append(c),c.className="swatch",c.style.backgroundColor=r,a.setAttribute("aria-selected",r===this.#n),a.addEventListener("click",this.#o.bind(this,r),{signal:e}),t.append(a)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#o(t,e){e.stopPropagation(),this.#a.dispatch("switchannotationeditorparams",{source:this,type:this.#d,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");e&&this.#o(e,t)}_moveToNext(t){if(!this.#b){this.#m(t);return}if(t.target===this.#t){this.#s.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#s?.firstChild||t.target===this.#t){this.#b&&this._hideDropdownFromKeyboard();return}this.#b||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#b){this.#m(t);return}this.#s.firstChild?.focus()}_moveToEnd(t){if(!this.#b){this.#m(t);return}this.#s.lastChild?.focus()}#p(t){o._keyboardManager.exec(this,t)}#m(t){if(this.#b){this.hideDropdown();return}if(this.#i=t.detail===0,this.#u||(this.#u=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#c.combinedSignal(this.#u)})),this.#s){this.#s.classList.remove("hidden");return}let e=this.#s=this.#f();this.#t.append(e)}#g(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#u?.abort(),this.#u=null}get#b(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#r){if(!this.#b){this.#l?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#i})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;let e=this.#c.highlightColors.values();for(let n of this.#s.children)n.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}},Yr=class o extends Xt{#t=null;#e=0;#n;#s=null;#i=null;#r=null;#l=null;#a=0;#u=null;#c=null;#d=null;#h=!1;#f=null;#o;#p=null;#m="";#g;#b="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Rt.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=o.prototype;return Ot(this,"_keyboardManager",new Ln([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||o._defaultColor,this.#g=t.thickness||o._defaultThickness,this.#o=t.opacity||o._defaultOpacity,this.#n=t.boxes||null,this.#b=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#h=!0,this.#y(t),this.#P()):this.#n&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#l=t.focusNode,this.#a=t.focusOffset,this.#x(),this.#P(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#h?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#b}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#x(){let t=new Os(this.#n,.001);this.#c=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#c.box;let e=new Os(this.#n,.0025,.001,this._uiManager.direction==="ltr");this.#r=e.getOutlines();let{lastPoint:n}=this.#r;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#y({highlightOutlines:t,highlightId:e,clipPathId:n}){this.#c=t;let r=1.5;if(this.#r=t.getNewOutline(this.#g/2+r,.0025),e>=0)this.#d=e,this.#s=n,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},!0);else if(this.parent){let m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#d,{bbox:o.#A(this.#c.box,(m-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:o.#A(this.#r.box,m),path:{d:this.#r.toSVGPath()}})}let[a,c,u,f]=t.box;switch(this.rotation){case 0:this.x=a,this.y=c,this.width=u,this.height=f;break;case 90:{let[m,b]=this.parentDimensions;this.x=c,this.y=1-a,this.width=u*b/m,this.height=f*m/b;break}case 180:this.x=1-a,this.y=1-c,this.width=u,this.height=f;break;case 270:{let[m,b]=this.parentDimensions;this.x=1-c,this.y=a,this.width=u*b/m,this.height=f*m/b;break}}let{lastPoint:g}=this.#r;this.#f=[(g[0]-a)/u,(g[1]-c)/f]}static initialize(t,e){Xt.initialize(t,e),o._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Mt.HIGHLIGHT_DEFAULT_COLOR:o._defaultColor=e;break;case Mt.HIGHLIGHT_THICKNESS:o._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case Mt.HIGHLIGHT_COLOR:this.#S(e);break;case Mt.HIGHLIGHT_THICKNESS:this.#T(e);break}}static get defaultPropertiesToUpdate(){return[[Mt.HIGHLIGHT_DEFAULT_COLOR,o._defaultColor],[Mt.HIGHLIGHT_THICKNESS,o._defaultThickness]]}get propertiesToUpdate(){return[[Mt.HIGHLIGHT_COLOR,this.color||o._defaultColor],[Mt.HIGHLIGHT_THICKNESS,this.#g||o._defaultThickness],[Mt.HIGHLIGHT_FREE,this.#h]]}#S(t){let e=(a,c)=>{this.color=a,this.#o=c,this.parent?.drawLayer.updateProperties(this.#d,{root:{fill:a,"fill-opacity":c}}),this.#i?.updateColor(a)},n=this.color,r=this.#o;this.addCommands({cmd:e.bind(this,t,o._defaultOpacity),undo:e.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#T(t){let e=this.#g,n=r=>{this.#g=r,this.#w(r)};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){let t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#i=new Xr({editor:this}),t.addColorPicker(this.#i)),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.#O())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#O())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#k(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#P(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#k():t&&(this.#P(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#w(t){if(!this.#h)return;this.#y({highlightOutlines:this.#c.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)}#k(){this.#d===null||!this.parent||(this.parent.drawLayer.remove(this.#d),this.#d=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#P(t=this.parent){this.#d===null&&({id:this.#d,clipPathId:this.#s}=t.drawLayer.draw({bbox:this.#c.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#h},path:{d:this.#c.toSVGPath()}},!1,!0),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#h},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},this.#h),this.#u&&(this.#u.style.clipPath=this.#s))}static#A([t,e,n,r],a){switch(a){case 90:return[1-e-r,t,r,n];case 180:return[1-t-n,1-e-r,n,r];case 270:return[e,1-t-n,r,n]}return[t,e,n,r]}rotate(t){let{drawLayer:e}=this.parent,n;this.#h?(t=(t-this.rotation+360)%360,n=o.#A(this.#c.box,t)):n=o.#A([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#d,{bbox:n,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:o.#A(this.#r.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#h?t.classList.add("free"):this.div.addEventListener("keydown",this.#I.bind(this),{signal:this._uiManager._signal});let e=this.#u=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#s;let[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),Ar(this,this.#u,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#I(t){o._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#E(!0);break;case 1:case 3:this.#E(!1);break}}#E(t){if(!this.#t)return;let e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#l,this.#a)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#h||this.#E(!1))}get _mustFixPosition(){return!this.#h}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#d,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#O(){return this.#h?this.rotation:0}#F(){if(this.#h)return null;let[t,e]=this.pageDimensions,[n,r]=this.pageTranslation,a=this.#n,c=new Float32Array(a.length*8),u=0;for(let{x:f,y:g,width:m,height:b}of a){let v=f*t+n,S=(1-g)*e+r;c[u]=c[u+4]=v,c[u+1]=c[u+3]=S,c[u+2]=c[u+6]=v+m*t,c[u+5]=c[u+7]=S-b*e,u+=8}return c}#_(t){return this.#c.serialize(t,this.#O())}static startHighlighting(t,e,{target:n,x:r,y:a}){let{x:c,y:u,width:f,height:g}=n.getBoundingClientRect(),m=new AbortController,b=t.combinedSignal(m),v=S=>{m.abort(),this.#v(t,S)};window.addEventListener("blur",v,{signal:b}),window.addEventListener("pointerup",v,{signal:b}),window.addEventListener("pointerdown",Ee,{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",He,{signal:b}),n.addEventListener("pointermove",this.#C.bind(this,t),{signal:b}),this._freeHighlight=new Ms({x:r,y:a},[c,u,f,g],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#C(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#v(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,n){let r=null;if(t instanceof Vr){let{data:{quadPoints:T,rect:w,rotation:I,id:k,color:O,opacity:F,popupRef:_},parent:{page:{pageNumber:D}}}=t;r=t={annotationType:Rt.HIGHLIGHT,color:Array.from(O),opacity:F,quadPoints:T,boxes:null,pageIndex:D-1,rect:w.slice(0),rotation:I,id:k,deleted:!1,popupRef:_}}else if(t instanceof Rs){let{data:{inkLists:T,rect:w,rotation:I,id:k,color:O,borderStyle:{rawWidth:F},popupRef:_},parent:{page:{pageNumber:D}}}=t;r=t={annotationType:Rt.HIGHLIGHT,color:Array.from(O),thickness:F,inkLists:T,boxes:null,pageIndex:D-1,rect:w.slice(0),rotation:I,id:k,deleted:!1,popupRef:_}}let{color:a,quadPoints:c,inkLists:u,opacity:f}=t,g=await super.deserialize(t,e,n);g.color=St.makeHexColor(...a),g.#o=f||1,u&&(g.#g=t.thickness),g.annotationElementId=t.id||null,g._initialData=r;let[m,b]=g.pageDimensions,[v,S]=g.pageTranslation;if(c){let T=g.#n=[];for(let w=0;w<c.length;w+=8)T.push({x:(c[w]-v)/m,y:1-(c[w+1]-S)/b,width:(c[w+2]-c[w])/m,height:(c[w+1]-c[w+5])/b});g.#x(),g.#P(),g.rotate(g.rotation)}else if(u){g.#h=!0;let T=u[0],w={x:T[0]-v,y:b-(T[1]-S)},I=new Ms(w,[0,0,m,b],1,g.#g/2,!0,.001);for(let F=0,_=T.length;F<_;F+=2)w.x=T[F]-v,w.y=b-(T[F+1]-S),I.add(w);let{id:k,clipPathId:O}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:g.color,"fill-opacity":g._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:I.toSVGPath()}},!0,!0);g.#y({highlightOutlines:I.getOutlines(),highlightId:k,clipPathId:O}),g.#P()}return g}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=this.getRect(0,0),n=Xt._colorManager.convert(this.color),r={annotationType:Rt.HIGHLIGHT,color:n,opacity:this.#o,thickness:this.#g,quadPoints:this.#F(),outlines:this.#_(e),pageIndex:this.pageIndex,rect:e,rotation:this.#O(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#L(r)?null:(r.id=this.annotationElementId,r)}#L(t){let{color:e}=this._initialData;return t.color.some((n,r)=>n!==e[r])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},ka=class{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,n]of Object.entries(t))this.updateProperty(e,n)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){let t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){$t("Not implemented")}},Ia=class o extends Xt{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#s=null;static#i=null;static#r=NaN;static#l=null;static#a=null;static#u=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#c(t),this.#f())}#c({drawOutlines:t,drawId:e,drawingOptions:n}){this.#t=t,this._drawingOptions||=n,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#d(t,this.parent),this.#m(t.box)}#d(t,e){let{id:n}=e.drawLayer.draw(o._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(t,e){let n=new Set(Object.keys(t));for(let[r,a]of Object.entries(e))n.has(r)?Object.assign(t[r],a):t[r]=a;return t}static getDefaultDrawingOptions(t){$t("Not implemented")}static get typesMap(){$t("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let n=this.typesMap.get(t);n&&this._defaultDrawingOptions.updateProperty(n,e),this._currentParent&&(o.#n.updateProperty(n,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let n=this.constructor.typesMap.get(t);n&&this._updateProperty(t,n,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)t.push([n,e[r]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[n,r]of this.constructor.typesMap)t.push([n,e[r]]);return t}_updateProperty(t,e,n){let r=this._drawingOptions,a=r[e],c=u=>{r.updateProperty(e,u);let f=this.#t.updateProperty(e,u);f&&this.#m(f),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:c.bind(this,n),undo:c.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#h(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#h()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#h(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#d(this.#t,t)}}#o([t,e,n,r]){let{parentDimensions:[a,c],rotation:u}=this;switch(u){case 90:return[e,1-t,n*(c/a),r*(a/c)];case 180:return[1-t,1-e,n,r];case 270:return[1-e,t,n*(c/a),r*(a/c)];default:return[t,e,n,r]}}#p(){let{x:t,y:e,width:n,height:r,parentDimensions:[a,c],rotation:u}=this;switch(u){case 90:return[1-e,t,n*(a/c),r*(c/a)];case 180:return[1-t,1-e,n,r];case 270:return[e,1-t,n*(a/c),r*(c/a)];default:return[t,e,n,r]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#o(t),this.div){this.fixAndSetPosition();let[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)}this._onResized()}#g(){let{x:t,y:e,width:n,height:r,rotation:a,parentRotation:c,parentDimensions:[u,f]}=this;switch((a*4+c)/90){case 1:return[1-e-r,t,r,n];case 2:return[1-t-n,1-e-r,n,r];case 3:return[e,1-t-n,r,n];case 4:return[t,e-n*(u/f),r*(f/u),n*(u/f)];case 5:return[1-e,t,n*(u/f),r*(f/u)];case 6:return[1-t-r*(f/u),1-e,r*(f/u),n*(u/f)];case 7:return[e-n*(u/f),1-t-r*(f/u),n*(u/f),r*(f/u)];case 8:return[t-n,e-r,n,r];case 9:return[1-e,t-n,r,n];case 10:return[1-t,1-e,n,r];case 11:return[e-r,1-t,r,n];case 12:return[t-r*(f/u),e,r*(f/u),n*(u/f)];case 13:return[1-e-n*(u/f),t-r*(f/u),n*(u/f),r*(f/u)];case 14:return[1-t,1-e-n*(u/f),r*(f/u),n*(u/f)];case 15:return[e,1-t,n*(u/f),r*(f/u)];default:return[t,e,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";let[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,n,r,a){$t("Not implemented")}static startDrawing(t,e,n,r){let{target:a,offsetX:c,offsetY:u,pointerId:f,pointerType:g}=r;if(o.#l&&o.#l!==g)return;let{viewport:{rotation:m}}=t,{width:b,height:v}=a.getBoundingClientRect(),S=o.#s=new AbortController,T=t.combinedSignal(S);if(o.#r||=f,o.#l??=g,window.addEventListener("pointerup",w=>{o.#r===w.pointerId?this._endDraw(w):o.#a?.delete(w.pointerId)},{signal:T}),window.addEventListener("pointercancel",w=>{o.#r===w.pointerId?this._currentParent.endDrawingSession():o.#a?.delete(w.pointerId)},{signal:T}),window.addEventListener("pointerdown",w=>{o.#l===w.pointerType&&((o.#a||=new Set).add(w.pointerId),o.#n.isCancellable()&&(o.#n.removeLastElement(),o.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:T}),window.addEventListener("contextmenu",He,{signal:T}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:T}),a.addEventListener("touchmove",w=>{w.timeStamp===o.#u&&Ee(w)},{signal:T}),t.toggleDrawing(),e._editorUndoBar?.hide(),o.#n){t.drawLayer.updateProperties(this._currentDrawId,o.#n.startNew(c,u,b,v,m));return}e.updateUIForDefaultProperties(this),o.#n=this.createDrawerInstance(c,u,b,v,m),o.#i=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(o.#i.toSVGProperties(),o.#n.defaultSVGProperties),!0,!1)}static _drawMove(t){if(o.#u=-1,!o.#n)return;let{offsetX:e,offsetY:n,pointerId:r}=t;if(o.#r===r){if(o.#a?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,o.#n.add(e,n)),o.#u=t.timeStamp,Ee(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,o.#n=null,o.#i=null,o.#l=null,o.#u=NaN),o.#s&&(o.#s.abort(),o.#s=null,o.#r=NaN,o.#a=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,o.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let n=o.#n,r=this._currentDrawId,a=n.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(r,n.setLastElement(a))},undo:()=>{e.drawLayer.updateProperties(r,n.removeLastElement())},mustExec:!1,type:Mt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Mt.DRAW_STEP),!o.#n.isEmpty()){let{pageDimensions:[n,r],scale:a}=e,c=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:o.#n.getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:o.#i,mustBeCommitted:!t});return this._cleanup(!0),c}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,n,r,a,c){$t("Not implemented")}static async deserialize(t,e,n){let{rawDims:{pageWidth:r,pageHeight:a,pageX:c,pageY:u}}=e.viewport,f=this.deserializeDraw(c,u,r,a,this._INNER_MARGIN,t),g=await super.deserialize(t,e,n);return g.createDrawingOptions(t),g.#c({drawOutlines:f}),g.#f(),g.onScaleChanging(),g.rotate(),g}serializeDraw(t){let[e,n]=this.pageTranslation,[r,a]=this.pageDimensions;return this.#t.serialize([e,n,r,a],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Pa=class{#t=new Float64Array(6);#e;#n;#s;#i;#r;#l="";#a=0;#u=new Kr;#c;#d;constructor(t,e,n,r,a,c){this.#c=n,this.#d=r,this.#s=a,this.#i=c,[t,e]=this.#h(t,e);let u=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#n=[{line:u,points:this.#r}],this.#t.set(u,0)}updateProperty(t,e){t==="stroke-width"&&(this.#i=e)}#h(t,e){return ht._normalizePoint(t,e,this.#c,this.#d,this.#s)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#r.length<=10}add(t,e){[t,e]=this.#h(t,e);let[n,r,a,c]=this.#t.subarray(2,6),u=t-a,f=e-c;return Math.hypot(this.#c*u,this.#d*f)<=2?null:(this.#r.push(t,e),isNaN(n)?(this.#t.set([a,c,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([n,r,a,c,t,e],0),this.#e.push(...ht.createBezierPoints(n,r,a,c,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){let n=this.add(t,e);return n||(this.#r.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,r,a){this.#c=n,this.#d=r,this.#s=a,[t,e]=this.#h(t,e);let c=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e];let u=this.#n.at(-1);return u&&(u.line=new Float32Array(u.line),u.points=new Float32Array(u.points)),this.#n.push({line:c,points:this.#r}),this.#t.set(c,0),this.#a=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(t){return this.#n?(this.#n.push(t),this.#e=t.line,this.#r=t.points,this.#a=0,{path:{d:this.toSVGPath()}}):this.#u.setLastElement(t)}removeLastElement(){if(!this.#n)return this.#u.removeLastElement();this.#n.pop(),this.#l="";for(let t=0,e=this.#n.length;t<e;t++){let{line:n,points:r}=this.#n[t];this.#e=n,this.#r=r,this.#a=0,this.toSVGPath()}return{path:{d:this.#l}}}toSVGPath(){let t=ht.svgRound(this.#e[4]),e=ht.svgRound(this.#e[5]);if(this.#r.length===2)return this.#l=`${this.#l} M ${t} ${e} Z`,this.#l;if(this.#r.length<=6){let r=this.#l.lastIndexOf("M");this.#l=`${this.#l.slice(0,r)} M ${t} ${e}`,this.#a=6}if(this.#r.length===4){let r=ht.svgRound(this.#e[10]),a=ht.svgRound(this.#e[11]);return this.#l=`${this.#l} L ${r} ${a}`,this.#a=12,this.#l}let n=[];this.#a===0&&(n.push(`M ${t} ${e}`),this.#a=6);for(let r=this.#a,a=this.#e.length;r<a;r+=6){let[c,u,f,g,m,b]=this.#e.slice(r,r+6).map(ht.svgRound);n.push(`C${c} ${u} ${f} ${g} ${m} ${b}`)}return this.#l+=n.join(" "),this.#a=this.#e.length,this.#l}getOutlines(t,e,n,r){let a=this.#n.at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),this.#u.build(this.#n,t,e,n,this.#s,this.#i,r),this.#t=null,this.#e=null,this.#n=null,this.#l=null,this.#u}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},Kr=class o extends ht{#t;#e=0;#n;#s;#i;#r;#l;#a;#u;build(t,e,n,r,a,c,u){this.#i=e,this.#r=n,this.#l=r,this.#a=a,this.#u=c,this.#n=u??0,this.#s=t,this.#h()}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#s){if(t.push(`M${ht.svgRound(e[4])} ${ht.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12){t.push(`L${ht.svgRound(e[10])} ${ht.svgRound(e[11])}`);continue}for(let n=6,r=e.length;n<r;n+=6){let[a,c,u,f,g,m]=e.subarray(n,n+6).map(ht.svgRound);t.push(`C${a} ${c} ${u} ${f} ${g} ${m}`)}}return t.join("")}serialize([t,e,n,r],a){let c=[],u=[],[f,g,m,b]=this.#d(),v,S,T,w,I,k,O,F,_;switch(this.#a){case 0:_=ht._rescale,v=t,S=e+r,T=n,w=-r,I=t+f*n,k=e+(1-g-b)*r,O=t+(f+m)*n,F=e+(1-g)*r;break;case 90:_=ht._rescaleAndSwap,v=t,S=e,T=n,w=r,I=t+g*n,k=e+f*r,O=t+(g+b)*n,F=e+(f+m)*r;break;case 180:_=ht._rescale,v=t+n,S=e,T=-n,w=r,I=t+(1-f-m)*n,k=e+g*r,O=t+(1-f)*n,F=e+(g+b)*r;break;case 270:_=ht._rescaleAndSwap,v=t+n,S=e+r,T=-n,w=-r,I=t+(1-g-b)*n,k=e+(1-f-m)*r,O=t+(1-g)*n,F=e+(1-f)*r;break}for(let{line:D,points:G}of this.#s)c.push(_(D,v,S,T,w,a?new Array(D.length):null)),u.push(_(G,v,S,T,w,a?new Array(G.length):null));return{lines:c,points:u,rect:[I,k,O,F]}}static deserialize(t,e,n,r,a,{paths:{lines:c,points:u},rotation:f,thickness:g}){let m=[],b,v,S,T,w;switch(f){case 0:w=ht._rescale,b=-t/n,v=e/r+1,S=1/n,T=-1/r;break;case 90:w=ht._rescaleAndSwap,b=-e/r,v=-t/n,S=1/r,T=1/n;break;case 180:w=ht._rescale,b=t/n+1,v=-e/r,S=-1/n,T=1/r;break;case 270:w=ht._rescaleAndSwap,b=e/r+1,v=t/n+1,S=-1/r,T=-1/n;break}if(!c){c=[];for(let k of u){let O=k.length;if(O===2){c.push(new Float32Array([NaN,NaN,NaN,NaN,k[0],k[1]]));continue}if(O===4){c.push(new Float32Array([NaN,NaN,NaN,NaN,k[0],k[1],NaN,NaN,NaN,NaN,k[2],k[3]]));continue}let F=new Float32Array(3*(O-2));c.push(F);let[_,D,G,j]=k.subarray(0,4);F.set([NaN,NaN,NaN,NaN,_,D],0);for(let W=4;W<O;W+=2){let $=k[W],Z=k[W+1];F.set(ht.createBezierPoints(_,D,G,j,$,Z),(W-2)*3),[_,D,G,j]=[G,j,$,Z]}}}for(let k=0,O=c.length;k<O;k++)m.push({line:w(c[k].map(F=>F??NaN),b,v,S,T),points:w(u[k].map(F=>F??NaN),b,v,S,T)});let I=new o;return I.build(m,n,r,1,f,g,a),I}#c(t=this.#u){let e=this.#n+t/2*this.#l;return this.#a%180===0?[e/this.#i,e/this.#r]:[e/this.#r,e/this.#i]}#d(){let[t,e,n,r]=this.#t,[a,c]=this.#c(0);return[t+a,e+c,n-2*a,r-2*c]}#h(){let t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:r}of this.#s){if(r.length<=12){for(let u=4,f=r.length;u<f;u+=6){let[g,m]=r.subarray(u,u+2);t[0]=Math.min(t[0],g),t[1]=Math.min(t[1],m),t[2]=Math.max(t[2],g),t[3]=Math.max(t[3],m)}continue}let a=r[4],c=r[5];for(let u=6,f=r.length;u<f;u+=6){let[g,m,b,v,S,T]=r.subarray(u,u+6);St.bezierBoundingBox(a,c,g,m,b,v,S,T,t),a=S,c=T}}let[e,n]=this.#c();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-n)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+n)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,n]=this.#c();this.#u=t;let[r,a]=this.#c(),[c,u]=[r-e,a-n],f=this.#t;return f[0]-=c,f[1]-=u,f[2]+=2*c,f[3]+=2*u,f}updateParentDimensions([t,e],n){let[r,a]=this.#c();this.#i=t,this.#r=e,this.#l=n;let[c,u]=this.#c(),f=c-r,g=u-a,m=this.#t;return m[0]-=f,m[1]-=g,m[2]+=2*f,m[3]+=2*g,m}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(ht.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,n=0,r=0,a=0,c=0,u=0,f=0;switch(this.#e){case 90:r=e/t,a=-t/e,u=t;break;case 180:n=-1,c=-1,u=t,f=e;break;case 270:r=-e/t,a=t/e,f=e;break;default:return""}return`matrix(${n} ${r} ${a} ${c} ${ht.svgRound(u)} ${ht.svgRound(f)})`}getPathResizingSVGProperties([t,e,n,r]){let[a,c]=this.#c(),[u,f,g,m]=this.#t;if(Math.abs(g-a)<=ht.PRECISION||Math.abs(m-c)<=ht.PRECISION){let w=t+n/2-(u+g/2),I=e+r/2-(f+m/2);return{path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`,transform:`${this.rotationTransform} translate(${w} ${I})`}}}let b=(n-2*a)/(g-2*a),v=(r-2*c)/(m-2*c),S=g/n,T=m/r;return{path:{"transform-origin":`${ht.svgRound(u)} ${ht.svgRound(f)}`,transform:`${this.rotationTransform} scale(${S} ${T}) translate(${ht.svgRound(a)} ${ht.svgRound(c)}) scale(${b} ${v}) translate(${ht.svgRound(-a)} ${ht.svgRound(-c)})`}}}getPathResizedSVGProperties([t,e,n,r]){let[a,c]=this.#c(),u=this.#t,[f,g,m,b]=u;if(u[0]=t,u[1]=e,u[2]=n,u[3]=r,Math.abs(m-a)<=ht.PRECISION||Math.abs(b-c)<=ht.PRECISION){let I=t+n/2-(f+m/2),k=e+r/2-(g+b/2);for(let{line:O,points:F}of this.#s)ht._translate(O,I,k,O),ht._translate(F,I,k,F);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let v=(n-2*a)/(m-2*a),S=(r-2*c)/(b-2*c),T=-v*(f+a)+t+a,w=-S*(g+c)+e+c;if(v!==1||S!==1||T!==0||w!==0)for(let{line:I,points:k}of this.#s)ht._rescale(I,T,w,v,S,I),ht._rescale(k,T,w,v,S,k);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],n){let[r,a]=n,c=this.#t,u=t-c[0],f=e-c[1];if(this.#i===r&&this.#r===a)for(let{line:g,points:m}of this.#s)ht._translate(g,u,f,g),ht._translate(m,u,f,m);else{let g=this.#i/r,m=this.#r/a;this.#i=r,this.#r=a;for(let{line:b,points:v}of this.#s)ht._rescale(b,u,f,g,m,b),ht._rescale(v,u,f,g,m,v);c[2]*=g,c[3]*=m}return c[0]=t,c[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ht.svgRound(t[0])} ${ht.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}},Ra=class o extends ka{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:Xt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){let t=new o(this.#t);return t.updateAll(this),t}},Oa=class o extends Ia{static _type="ink";static _editorType=Rt.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){Xt.initialize(t,e),this._defaultDrawingOptions=new Ra(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Ot(this,"typesMap",new Map([[Mt.INK_THICKNESS,"stroke-width"],[Mt.INK_COLOR,"stroke"],[Mt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,n,r,a){return new Pa(t,e,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,n,r,a,c){return Kr.deserialize(t,e,n,r,a,c)}static async deserialize(t,e,n){let r=null;if(t instanceof Rs){let{data:{inkLists:c,rect:u,rotation:f,id:g,color:m,opacity:b,borderStyle:{rawWidth:v},popupRef:S},parent:{page:{pageNumber:T}}}=t;r=t={annotationType:Rt.INK,color:Array.from(m),thickness:v,opacity:b,paths:{points:c},boxes:null,pageIndex:T-1,rect:u.slice(0),rotation:f,id:g,deleted:!1,popupRef:S}}let a=await super.deserialize(t,e,n);return a.annotationElementId=t.id||null,a._initialData=r,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:n}=this;e.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:n}){this._drawingOptions=o.getDefaultDrawingOptions({stroke:St.makeHexColor(...t),"stroke-width":e,"stroke-opacity":n})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:n,rect:r}=this.serializeDraw(t),{_drawingOptions:{stroke:a,"stroke-opacity":c,"stroke-width":u}}=this,f={annotationType:Rt.INK,color:Xt._colorManager.convert(a),opacity:c,thickness:u,paths:{lines:e,points:n},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?f:this.annotationElementId&&!this.#t(f)?null:(f.id=this.annotationElementId,f)}#t(t){let{color:e,thickness:n,opacity:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((c,u)=>c!==e[u])||t.thickness!==n||t.opacity!==r||t.pageIndex!==a}renderAnnotationElement(t){let{points:e,rect:n}=this.serializeDraw(!1);return t.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:e}),null}},Ma=class o extends Xt{#t=null;#e=null;#n=null;#s=null;#i=null;#r="";#l=null;#a=null;#u=!1;#c=!1;static _type="stamp";static _editorType=Rt.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#s=t.bitmapUrl,this.#i=t.bitmapFile}static initialize(t,e){Xt.initialize(t,e)}static get supportedTypes(){return Ot(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return Ot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(Rt.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#u=t.isSvg),t.file&&(this.#r=t.file.name),this.#o()}#h(){if(this.#n=null,this._uiManager.enableWaiting(!1),!!this.#l){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");let{data:r,width:a,height:c}=t||this.copyCanvas(null,null,!0).imageData,u=await n.guess({name:"altText",request:{data:r,width:a,height:c,channels:r.length/(a*c)}});if(!u)throw new Error("No response from the AI service.");if(u.error)throw new Error("Error from the AI service.");if(u.cancel)return null;if(!u.output)throw new Error("No valid response from the AI service.");let f=u.output;return await this.setGuessedAltText(f),e&&!this.hasAltTextData()&&(this.altTextData={alt:f,decorative:!1}),f}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(n=>this.#d(n,!0)).finally(()=>this.#h());return}if(this.#s){let n=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(n).then(r=>this.#d(r)).finally(()=>this.#h());return}if(this.#i){let n=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(n).then(r=>this.#d(r)).finally(()=>this.#h());return}let t=document.createElement("input");t.type="file",t.accept=o.supportedTypesStr;let e=this._uiManager._signal;this.#n=new Promise(n=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let r=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(r)}n()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),n()},{signal:e})}).finally(()=>this.#h()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#l?.remove(),this.#l=null,this.#a&&(clearTimeout(this.#a),this.#a=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#f();return}super.rebuild(),this.div!==null&&(this.#e&&this.#l===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#n||this.#t||this.#s||this.#i||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#o():this.#f(),this.width&&!this.annotationElementId){let[n,r]=this.parentDimensions;this.setAt(t*n,e*r,this.width*n,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#a!==null&&clearTimeout(this.#a);let t=200;this.#a=setTimeout(()=>{this.#a=null,this.#m()},t)}#o(){let{div:t}=this,{width:e,height:n}=this.#t,[r,a]=this.pageDimensions,c=.75;if(this.width)e=this.width*r,n=this.height*a;else if(e>c*r||n>c*a){let m=Math.min(c*r/e,c*a/n);e*=m,n*=m}let[u,f]=this.parentDimensions;this.setDims(e*u/r,n*f/a),this._uiManager.enableWaiting(!1);let g=this.#l=document.createElement("canvas");g.setAttribute("role","img"),this.addContainer(g),this.width=e/r,this.height=n/a,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#c||(this.parent.addUndoableEditor(this),this.#c=!0),this._reportTelemetry({action:"inserted_image"}),this.#r&&g.setAttribute("aria-label",this.#r)}copyCanvas(t,e,n=!1){t||(t=224);let{width:r,height:a}=this.#t,c=new Ts,u=this.#t,f=r,g=a,m=null;if(e){if(r>e||a>e){let G=Math.min(e/r,e/a);f=Math.floor(r*G),g=Math.floor(a*G)}m=document.createElement("canvas");let v=m.width=Math.ceil(f*c.sx),S=m.height=Math.ceil(g*c.sy);this.#u||(u=this.#p(v,S));let T=m.getContext("2d");T.filter=this._uiManager.hcmFilter;let w="white",I="#cfcfd8";this._uiManager.hcmFilter!=="none"?I="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(w="#8f8f9d",I="#42414d");let k=15,O=k*c.sx,F=k*c.sy,_=new OffscreenCanvas(O*2,F*2),D=_.getContext("2d");D.fillStyle=w,D.fillRect(0,0,O*2,F*2),D.fillStyle=I,D.fillRect(0,0,O,F),D.fillRect(O,F,O,F),T.fillStyle=T.createPattern(_,"repeat"),T.fillRect(0,0,v,S),T.drawImage(u,0,0,u.width,u.height,0,0,v,S)}let b=null;if(n){let v,S;if(c.symmetric&&u.width<t&&u.height<t)v=u.width,S=u.height;else if(u=this.#t,r>t||a>t){let I=Math.min(t/r,t/a);v=Math.floor(r*I),S=Math.floor(a*I),this.#u||(u=this.#p(v,S))}let w=new OffscreenCanvas(v,S).getContext("2d",{willReadFrequently:!0});w.drawImage(u,0,0,u.width,u.height,0,0,v,S),b={width:v,height:S,data:w.getImageData(0,0,v,S).data}}return{canvas:m,width:f,height:g,imageData:b}}#p(t,e){let{width:n,height:r}=this.#t,a=n,c=r,u=this.#t;for(;a>2*t||c>2*e;){let f=a,g=c;a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),c>2*e&&(c=c>=16384?Math.floor(c/2)-1:Math.ceil(c/2));let m=new OffscreenCanvas(a,c);m.getContext("2d").drawImage(u,0,0,f,g,0,0,a,c),u=m.transferToImageBitmap()}return u}#m(){let[t,e]=this.parentDimensions,{width:n,height:r}=this,a=new Ts,c=Math.ceil(n*t*a.sx),u=Math.ceil(r*e*a.sy),f=this.#l;if(!f||f.width===c&&f.height===u)return;f.width=c,f.height=u;let g=this.#u?this.#t:this.#p(c,u),m=f.getContext("2d");m.filter=this._uiManager.hcmFilter,m.drawImage(g,0,0,g.width,g.height,0,0,c,u)}getImageForAltText(){return this.#l}#g(t){if(t){if(this.#u){let r=this._uiManager.imageManager.getSvgUrl(this.#e);if(r)return r}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#u){let[e,n]=this.pageDimensions,r=Math.round(this.width*e*bn.PDF_TO_CSS_UNITS),a=Math.round(this.height*n*bn.PDF_TO_CSS_UNITS),c=new OffscreenCanvas(r,a);return c.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,r,a),c.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,n){let r=null;if(t instanceof $r){let{data:{rect:T,rotation:w,id:I,structParent:k,popupRef:O},container:F,parent:{page:{pageNumber:_}}}=t,D=F.querySelector("canvas"),G=n.imageManager.getFromCanvas(F.id,D);D.remove();let j=(await e._structTree.getAriaAttributes(`${_a}${I}`))?.get("aria-label")||"";r=t={annotationType:Rt.STAMP,bitmapId:G.id,bitmap:G.bitmap,pageIndex:_-1,rect:T.slice(0),rotation:w,id:I,deleted:!1,accessibilityData:{decorative:!1,altText:j},isSvg:!1,structParent:k,popupRef:O}}let a=await super.deserialize(t,e,n),{rect:c,bitmap:u,bitmapUrl:f,bitmapId:g,isSvg:m,accessibilityData:b}=t;g&&n.imageManager.isValidId(g)?(a.#e=g,u&&(a.#t=u)):a.#s=f,a.#u=m;let[v,S]=a.pageDimensions;return a.width=(c[2]-c[0])/v,a.height=(c[3]-c[1])/S,a.annotationElementId=t.id||null,b&&(a.altTextData=b),a._initialData=r,a.#c=!!r,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n={annotationType:Rt.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#u,structTreeParentId:this._structTreeParentId};if(t)return n.bitmapUrl=this.#g(!0),n.accessibilityData=this.serializeAltText(!0),n;let{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(n.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){let u=this.#b(n);if(u.isSame)return null;u.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,e===null)return n;e.stamps||=new Map;let c=this.#u?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:c,serialized:n}),n.bitmap=this.#g(!1);else if(this.#u){let u=e.stamps.get(this.#e);c>u.area&&(u.area=c,u.serialized.bitmap.close(),u.serialized.bitmap=this.#g(!1))}return n}#b(t){let{pageIndex:e,accessibilityData:{altText:n}}=this._initialData,r=t.pageIndex===e,a=(t.accessibilityData?.alt||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}},La=class o{#t;#e=!1;#n=null;#s=null;#i=null;#r=new Map;#l=!1;#a=!1;#u=!1;#c=null;#d=null;#h=null;#f=null;#o;static _initialized=!1;static#p=new Map([Ca,Oa,Ma,Yr].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:n,structTreeLayer:r,accessibilityManager:a,annotationLayer:c,drawLayer:u,textLayer:f,viewport:g,l10n:m}){let b=[...o.#p.values()];if(!o._initialized){o._initialized=!0;for(let v of b)v.initialize(m,t)}t.registerEditorTypes(b),this.#o=t,this.pageIndex=e,this.div=n,this.#t=a,this.#n=c,this.viewport=g,this.#h=f,this.drawLayer=u,this._structTree=r,this.#o.addLayer(this)}get isEmpty(){return this.#r.size===0}get isInvisible(){return this.isEmpty&&this.#o.getMode()===Rt.NONE}updateToolbar(t){this.#o.updateToolbar(t)}updateMode(t=this.#o.getMode()){switch(this.#y(),t){case Rt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Rt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Rt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;for(let n of o.#p.values())e.toggle(`${n._type}Editing`,t===n._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}setEditingState(t){this.#o.setEditingState(t)}addCommands(t){this.#o.addCommands(t)}cleanUndoStack(t){this.#o.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#n?.div.classList.toggle("disabled",!t)}async enable(){this.#u=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let n of this.#r.values())n.enableEditing(),n.show(!0),n.annotationElementId&&(this.#o.removeChangedExistingAnnotation(n),t.add(n.annotationElementId));if(!this.#n){this.#u=!1;return}let e=this.#n.getEditableAnnotations();for(let n of e){if(n.hide(),this.#o.isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;let r=await this.deserialize(n);r&&(this.addOrRebuild(r),r.enableEditing())}this.#u=!1}disable(){this.#a=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let r of this.#r.values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){t.set(r.annotationElementId,r);continue}else e.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}if(this.#n){let r=this.#n.getEditableAnnotations();for(let a of r){let{id:c}=a.data;if(this.#o.isDeletedAnnotationElement(c))continue;let u=e.get(c);if(u){u.resetAnnotationElement(a),u.show(!1),a.show();continue}u=t.get(c),u&&(this.#o.addChangedExistingAnnotation(u),u.renderAnnotationElement(a)&&u.show(!1)),a.show()}}this.#y(),this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let r of o.#p.values())n.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#a=!1}getEditableAnnotation(t){return this.#n?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#o.getActive()!==t&&this.#o.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#f){this.#f=new AbortController;let t=this.#o.combinedSignal(this.#f);this.#h.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#h?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#h.div.classList.remove("highlighting"))}#m(t){this.#o.unselectAll();let{target:e}=t;if(e===this.#h.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#h.div.contains(e)){let{isMac:n}=ne.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#o.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),this.toggleDrawing(),Yr.startHighlighting(this,this.#o.direction==="ltr",{target:this.#h.div,x:t.x,y:t.y}),this.#h.div.addEventListener("pointerup",()=>{this.#h.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),t.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;let t=this.#o.combinedSignal(this.#s);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#s?.abort(),this.#s=null}attach(t){this.#r.set(t.id,t);let{annotationElementId:e}=t;e&&this.#o.isDeletedAnnotationElement(e)&&this.#o.removeDeletedAnnotationElement(t)}detach(t){this.#r.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#a&&t.annotationElementId&&this.#o.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#o.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#o.addDeletedAnnotationElement(t.annotationElementId),Xt.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.#o.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#u),this.#o.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#i&&(t._focusEventsAllowed=!1,this.#i=setTimeout(()=>{this.#i=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){let e=()=>t._uiManager.rebuild(t),n=()=>{t.remove()};this.addCommands({cmd:e,undo:n,mustExec:!1})}getNextId(){return this.#o.getId()}get#g(){return o.#p.get(this.#o.getMode())}combinedSignal(t){return this.#o.combinedSignal(t)}#b(t){let e=this.#g;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#o.updateToolbar(t),this.#o.updateMode(t);let{offsetX:n,offsetY:r}=this.#x(),a=this.getNextId(),c=this.#b({parent:this,id:a,x:n,y:r,uiManager:this.#o,isCentered:!0,...e});c&&this.add(c)}async deserialize(t){return await o.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#o)||null}createAndAddNewEditor(t,e,n={}){let r=this.getNextId(),a=this.#b({parent:this,id:r,x:t.offsetX,y:t.offsetY,uiManager:this.#o,isCentered:e,...n});return a&&this.add(a),a}#x(){let{x:t,y:e,width:n,height:r}=this.div.getBoundingClientRect(),a=Math.max(0,t),c=Math.max(0,e),u=Math.min(window.innerWidth,t+n),f=Math.min(window.innerHeight,e+r),g=(a+u)/2-t,m=(c+f)/2-e,[b,v]=this.viewport.rotation%180===0?[g,m]:[m,g];return{offsetX:b,offsetY:v}}addNewEditor(){this.createAndAddNewEditor(this.#x(),!0)}setSelected(t){this.#o.setSelected(t)}toggleSelected(t){this.#o.toggleSelected(t)}unselect(t){this.#o.unselect(t)}pointerup(t){let{isMac:e}=ne.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#l&&(this.#l=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#o.getMode()===Rt.STAMP){this.#o.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#o.getMode()===Rt.HIGHLIGHT&&this.enableTextSelection(),this.#l){this.#l=!1;return}let{isMac:e}=ne.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#l=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}let n=this.#o.getActive();this.#e=!n||n.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#c){this.#g.startDrawing(this,this.#o,!1,t);return}this.#o.setCurrentDrawingSession(this),this.#c=new AbortController;let e=this.#o.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:n})=>{n&&!this.div.contains(n)&&(this.#d=null,this.commitOrRemove())},{signal:e}),this.#g.startDrawing(this,this.#o,!1,t)}pause(t){if(t){let{activeElement:e}=document;this.div.contains(e)&&(this.#d=e);return}this.#d&&setTimeout(()=>{this.#d?.focus(),this.#d=null},0)}endDrawingSession(t=!1){return this.#c?(this.#o.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#d=null,this.#g.endDrawing(t)):null}findNewParent(t,e,n){let r=this.#o.findParent(e,n);return r===null||r===this?!1:(r.changeParent(t),!0)}commitOrRemove(){return this.#c?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#c&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#i&&(clearTimeout(this.#i),this.#i=null);for(let t of this.#r.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#r.clear(),this.#o.removeLayer(this)}#y(){for(let t of this.#r.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Mn(this.div,t);for(let e of this.#o.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#o.commitOrRemove(),this.#y();let e=this.viewport.rotation,n=t.rotation;if(this.viewport=t,Mn(this.div,{rotation:n}),e!==n)for(let r of this.#r.values())r.rotate(n)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#o.viewParameters.realScale}},Fa=class o{#t=null;#e=0;#n=new Map;#s=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#n.size>0)for(let e of this.#n.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return Ot(this,"_svgFactory",new Is)}static#i(t,[e,n,r,a]){let{style:c}=t;c.top=`${100*n}%`,c.left=`${100*e}%`,c.width=`${100*r}%`,c.height=`${100*a}%`}#r(){let t=o._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#l(t,e){let n=o._svgFactory.createElement("clipPath");t.append(n);let r=`clip_${e}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");let a=o._svgFactory.createElement("use");return n.append(a),a.setAttribute("href",`#${e}`),a.classList.add("clip"),r}#a(t,e){for(let[n,r]of Object.entries(e))r===null?t.removeAttribute(n):t.setAttribute(n,r)}draw(t,e=!1,n=!1){let r=this.#e++,a=this.#r(),c=o._svgFactory.createElement("defs");a.append(c);let u=o._svgFactory.createElement("path");c.append(u);let f=`path_p${this.pageIndex}_${r}`;u.setAttribute("id",f),u.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#s.set(r,u);let g=n?this.#l(c,f):null,m=o._svgFactory.createElement("use");return a.append(m),m.setAttribute("href",`#${f}`),this.updateProperties(a,t),this.#n.set(r,a),{id:r,clipPathId:`url(#${g})`}}drawOutline(t,e){let n=this.#e++,r=this.#r(),a=o._svgFactory.createElement("defs");r.append(a);let c=o._svgFactory.createElement("path");a.append(c);let u=`path_p${this.pageIndex}_${n}`;c.setAttribute("id",u),c.setAttribute("vector-effect","non-scaling-stroke");let f;if(e){let b=o._svgFactory.createElement("mask");a.append(b),f=`mask_p${this.pageIndex}_${n}`,b.setAttribute("id",f),b.setAttribute("maskUnits","objectBoundingBox");let v=o._svgFactory.createElement("rect");b.append(v),v.setAttribute("width","1"),v.setAttribute("height","1"),v.setAttribute("fill","white");let S=o._svgFactory.createElement("use");b.append(S),S.setAttribute("href",`#${u}`),S.setAttribute("stroke","none"),S.setAttribute("fill","black"),S.setAttribute("fill-rule","nonzero"),S.classList.add("mask")}let g=o._svgFactory.createElement("use");r.append(g),g.setAttribute("href",`#${u}`),f&&g.setAttribute("mask",`url(#${f})`);let m=g.cloneNode();return r.append(m),g.classList.add("mainOutline"),m.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#n.set(n,r),n}finalizeDraw(t,e){this.#s.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:n,bbox:r,rootClass:a,path:c}=e,u=typeof t=="number"?this.#n.get(t):t;if(u){if(n&&this.#a(u,n),r&&o.#i(u,r),a){let{classList:f}=u;for(let[g,m]of Object.entries(a))f.toggle(g,m)}if(c){let g=u.firstChild.firstChild;this.#a(g,c)}}}updateParent(t,e){if(e===this)return;let n=this.#n.get(t);n&&(e.#t.append(n),this.#n.delete(t),e.#n.set(t,n))}remove(t){this.#s.delete(t),this.#t!==null&&(this.#n.get(t).remove(),this.#n.delete(t))}destroy(){this.#t=null;for(let t of this.#n.values())t.remove();this.#n.clear(),this.#s.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:Os};$y=wt.AbortException,zy=wt.AnnotationEditorLayer,Wy=wt.AnnotationEditorParamsType,Xy=wt.AnnotationEditorType,Yy=wt.AnnotationEditorUIManager,Ky=wt.AnnotationLayer,Ba=wt.AnnotationMode,Zy=wt.ColorPicker,Qy=wt.DOMSVGFactory,Jy=wt.DrawLayer,qy=wt.FeatureTest,t0=wt.GlobalWorkerOptions,e0=wt.ImageKind,n0=wt.InvalidPDFException,s0=wt.MissingPDFException,r0=wt.OPS,i0=wt.OutputScale,o0=wt.PDFDataRangeTransport,a0=wt.PDFDateString,l0=wt.PDFWorker,c0=wt.PasswordResponses,u0=wt.PermissionFlag,h0=wt.PixelsPerInch,d0=wt.RenderingCancelledException,f0=wt.TextLayer,p0=wt.TouchManager,g0=wt.UnexpectedResponseException,m0=wt.Util,b0=wt.VerbosityLevel,y0=wt.XfaLayer,v0=wt.build,x0=wt.createValidAbsoluteUrl,S0=wt.fetchData,A0=wt.getDocument,T0=wt.getFilenameFromUrl,C0=wt.getPdfFilenameFromUrl,w0=wt.getXfaPageViewport,E0=wt.isDataScheme,k0=wt.isPdfFile,I0=wt.noContextMenu,P0=wt.normalizeUnicode,R0=wt.setLayerDimensions,O0=wt.shadow,M0=wt.stopEvent,L0=wt.version});var za=Ub((_u,oi)=>{var Du=(()=>{var o=Object.defineProperty,t=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,r=(s,i)=>{for(var l in i)o(s,l,{get:i[l],enumerable:!0})},a=(s,i,l,h)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of e(i))!n.call(s,d)&&d!==l&&o(s,d,{get:()=>i[d],enumerable:!(h=t(i,d))||h.enumerable});return s},c=s=>a(o({},"__esModule",{value:!0}),s),u={};r(u,{BoundingBox:()=>bt,Font:()=>$c,Glyph:()=>$n,Path:()=>it,_parse:()=>rt,load:()=>Pb,loadSync:()=>Rb,parse:()=>Ib});var f=0,g=-3;function m(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function b(s,i){this.source=s,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=i,this.destLen=0,this.ltree=new m,this.dtree=new m}var v=new m,S=new m,T=new Uint8Array(30),w=new Uint16Array(30),I=new Uint8Array(30),k=new Uint16Array(30),O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),F=new m,_=new Uint8Array(320);function D(s,i,l,h){var d,p;for(d=0;d<l;++d)s[d]=0;for(d=0;d<30-l;++d)s[d+l]=d/l|0;for(p=h,d=0;d<30;++d)i[d]=p,p+=1<<s[d]}function G(s,i){var l;for(l=0;l<7;++l)s.table[l]=0;for(s.table[7]=24,s.table[8]=152,s.table[9]=112,l=0;l<24;++l)s.trans[l]=256+l;for(l=0;l<144;++l)s.trans[24+l]=l;for(l=0;l<8;++l)s.trans[168+l]=280+l;for(l=0;l<112;++l)s.trans[176+l]=144+l;for(l=0;l<5;++l)i.table[l]=0;for(i.table[5]=32,l=0;l<32;++l)i.trans[l]=l}var j=new Uint16Array(16);function W(s,i,l,h){var d,p;for(d=0;d<16;++d)s.table[d]=0;for(d=0;d<h;++d)s.table[i[l+d]]++;for(s.table[0]=0,p=0,d=0;d<16;++d)j[d]=p,p+=s.table[d];for(d=0;d<h;++d)i[l+d]&&(s.trans[j[i[l+d]]++]=d)}function $(s){s.bitcount--||(s.tag=s.source[s.sourceIndex++],s.bitcount=7);var i=s.tag&1;return s.tag>>>=1,i}function Z(s,i,l){if(!i)return l;for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var h=s.tag&65535>>>16-i;return s.tag>>>=i,s.bitcount-=i,h+l}function q(s,i){for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var l=0,h=0,d=0,p=s.tag;do h=2*h+(p&1),p>>>=1,++d,l+=i.table[d],h-=i.table[d];while(h>=0);return s.tag=p,s.bitcount-=d,i.trans[l+h]}function yt(s,i,l){var h,d,p,y,x,A;for(h=Z(s,5,257),d=Z(s,5,1),p=Z(s,4,4),y=0;y<19;++y)_[y]=0;for(y=0;y<p;++y){var E=Z(s,3,0);_[O[y]]=E}for(W(F,_,0,19),x=0;x<h+d;){var C=q(s,F);switch(C){case 16:var R=_[x-1];for(A=Z(s,2,3);A;--A)_[x++]=R;break;case 17:for(A=Z(s,3,3);A;--A)_[x++]=0;break;case 18:for(A=Z(s,7,11);A;--A)_[x++]=0;break;default:_[x++]=C;break}}W(i,_,0,h),W(l,_,h,d)}function et(s,i,l){for(;;){var h=q(s,i);if(h===256)return f;if(h<256)s.dest[s.destLen++]=h;else{var d,p,y,x;for(h-=257,d=Z(s,T[h],w[h]),p=q(s,l),y=s.destLen-Z(s,I[p],k[p]),x=y;x<y+d;++x)s.dest[s.destLen++]=s.dest[x]}}}function Tt(s){for(var i,l,h;s.bitcount>8;)s.sourceIndex--,s.bitcount-=8;if(i=s.source[s.sourceIndex+1],i=256*i+s.source[s.sourceIndex],l=s.source[s.sourceIndex+3],l=256*l+s.source[s.sourceIndex+2],i!==(~l&65535))return g;for(s.sourceIndex+=4,h=i;h;--h)s.dest[s.destLen++]=s.source[s.sourceIndex++];return s.bitcount=0,f}function dt(s,i){var l=new b(s,i),h,d,p;do{switch(h=$(l),d=Z(l,2,0),d){case 0:p=Tt(l);break;case 1:p=et(l,v,S);break;case 2:yt(l,l.ltree,l.dtree),p=et(l,l.ltree,l.dtree);break;default:p=g}if(p!==f)throw new Error("Data error")}while(!h);return l.destLen<l.dest.length?typeof l.dest.slice=="function"?l.dest.slice(0,l.destLen):l.dest.subarray(0,l.destLen):l.dest}G(v,S),D(T,w,4,3),D(I,k,2,1),T[28]=0,w[28]=258;function Y(s,i,l,h,d){return Math.pow(1-d,3)*s+3*Math.pow(1-d,2)*d*i+3*(1-d)*Math.pow(d,2)*l+Math.pow(d,3)*h}function K(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}K.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},K.prototype.addPoint=function(s,i){typeof s=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=s,this.x2=s),s<this.x1&&(this.x1=s),s>this.x2&&(this.x2=s)),typeof i=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=i,this.y2=i),i<this.y1&&(this.y1=i),i>this.y2&&(this.y2=i))},K.prototype.addX=function(s){this.addPoint(s,null)},K.prototype.addY=function(s){this.addPoint(null,s)},K.prototype.addBezier=function(s,i,l,h,d,p,y,x){let A=[s,i],E=[l,h],C=[d,p],R=[y,x];this.addPoint(s,i),this.addPoint(y,x);for(let P=0;P<=1;P++){let L=6*A[P]-12*E[P]+6*C[P],M=-3*A[P]+9*E[P]-9*C[P]+3*R[P],N=3*E[P]-3*A[P];if(M===0){if(L===0)continue;let At=-N/L;0<At&&At<1&&(P===0&&this.addX(Y(A[P],E[P],C[P],R[P],At)),P===1&&this.addY(Y(A[P],E[P],C[P],R[P],At)));continue}let z=Math.pow(L,2)-4*N*M;if(z<0)continue;let vt=(-L+Math.sqrt(z))/(2*M);0<vt&&vt<1&&(P===0&&this.addX(Y(A[P],E[P],C[P],R[P],vt)),P===1&&this.addY(Y(A[P],E[P],C[P],R[P],vt)));let pt=(-L-Math.sqrt(z))/(2*M);0<pt&&pt<1&&(P===0&&this.addX(Y(A[P],E[P],C[P],R[P],pt)),P===1&&this.addY(Y(A[P],E[P],C[P],R[P],pt)))}},K.prototype.addQuad=function(s,i,l,h,d,p){let y=s+.6666666666666666*(l-s),x=i+2/3*(h-i),A=y+1/3*(d-s),E=x+1/3*(p-i);this.addBezier(s,i,y,x,A,E,d,p)};var bt=K;function lt(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var kt={};function X(s,i){let l=Math.floor(s),h=s-l;if(kt[i]||(kt[i]={}),kt[i][h]!==void 0){let p=kt[i][h];return l+p}let d=+(Math.round(h+"e+"+i)+"e-"+i);return kt[i][h]=d,l+d}function ot(s){let i=[[]],l=0,h=0;for(let d=0;d<s.length;d+=1){let p=i[i.length-1],y=s[d],x=p[0],A=p[1],E=p[p.length-1],C=s[d+1];p.push(y),y.type==="M"?(l=y.x,h=y.y):y.type==="L"&&(!C||C.type==="Z")?Math.abs(y.x-l)>1||Math.abs(y.y-h)>1||p.pop():y.type==="L"&&E&&E.x===y.x&&E.y===y.y?p.pop():y.type==="Z"&&(x&&A&&E&&x.type==="M"&&A.type==="L"&&E.type==="L"&&E.x===x.x&&E.y===x.y&&(p.shift(),p[0].type="M"),d+1<s.length&&i.push([]))}return s=[].concat.apply([],i),s}function Q(s){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},s)}function nt(s){return parseInt(s)===s&&(s={decimalPlaces:s,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},s)}lt.prototype.fromSVG=function(s,i={}){typeof SVGPathElement<"u"&&s instanceof SVGPathElement&&(s=s.getAttribute("d")),i=Q(i),this.commands=[];let l="0123456789",h="MmLlQqCcZzHhVv",d="SsTtAa",p="-+",y={},x=[""],A=!1;function E(M){return M.filter(N=>N.length).map(N=>{let z=parseFloat(N);return(i.decimalPlaces||i.decimalPlaces===0)&&(z=X(z,i.decimalPlaces)),z})}function C(M){if(!this.commands.length)return M;let N=this.commands[this.commands.length-1];for(let z=0;z<M.length;z++)M[z]+=N[z&1?"y":"x"];return M}function R(){if(y.type===void 0)return;let M=y.type.toUpperCase(),N=M!=="Z"&&y.type.toUpperCase()!==y.type,z=E(x);if(x=[""],!z.length&&M!=="Z")return;N&&M!=="H"&&M!=="V"&&(z=C.apply(this,[z]));let vt=this.commands.length&&this.commands[this.commands.length-1].x||0,pt=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(M){case"M":this.moveTo(...z);break;case"L":this.lineTo(...z);break;case"V":for(let At=0;At<z.length;At++){let It=0;N&&(It=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(vt,z[At]+It)}break;case"H":for(let At=0;At<z.length;At++){let It=0;N&&(It=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(z[At]+It,pt)}break;case"C":this.bezierCurveTo(...z);break;case"Q":this.quadraticCurveTo(...z);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let At in this.commands[this.commands.length-1])this.commands[this.commands.length-1][At]===void 0&&(this.commands[this.commands.length-1][At]=0)}for(let M=0;M<s.length;M++){let N=s.charAt(M),z=x[x.length-1];if(l.indexOf(N)>-1)x[x.length-1]+=N;else if(p.indexOf(N)>-1)if(!y.type&&!this.commands.length&&(y.type="L"),N==="-")!y.type||z.indexOf("-")>0?A=!0:z.length?x.push("-"):x[x.length-1]=N;else if(!y.type||z.length>0)A=!0;else continue;else if(h.indexOf(N)>-1)y.type?(R.apply(this),y={type:N}):y.type=N;else{if(d.indexOf(N)>-1)throw new Error("Unsupported path command: "+N+". Currently supported commands are "+h.split("").join(", ")+".");` ,
|
|
14
|
+
\r\f\v`.indexOf(N)>-1?x.push(""):N==="."?!y.type||z.indexOf(N)>-1?A=!0:x[x.length-1]+=N:A=!0}if(A)throw new Error("Unexpected character: "+N+" at offset "+M)}R.apply(this),i.optimize&&(this.commands=ot(this.commands));let P=i.flipY,L=i.flipYBase;if(P===!0&&i.flipYBase===void 0){let M=this.getBoundingBox();L=M.y1+M.y2}for(let M in this.commands){let N=this.commands[M];for(let z in N)["x","x1","x2"].includes(z)?this.commands[M][z]=i.x+N[z]*i.scale:["y","y1","y2"].includes(z)&&(this.commands[M][z]=i.y+(P?L-N[z]:N[z])*i.scale)}return this},lt.fromSVG=function(s,i){return new lt().fromSVG(s,i)},lt.prototype.moveTo=function(s,i){this.commands.push({type:"M",x:s,y:i})},lt.prototype.lineTo=function(s,i){this.commands.push({type:"L",x:s,y:i})},lt.prototype.curveTo=lt.prototype.bezierCurveTo=function(s,i,l,h,d,p){this.commands.push({type:"C",x1:s,y1:i,x2:l,y2:h,x:d,y:p})},lt.prototype.quadTo=lt.prototype.quadraticCurveTo=function(s,i,l,h){this.commands.push({type:"Q",x1:s,y1:i,x:l,y:h})},lt.prototype.close=lt.prototype.closePath=function(){this.commands.push({type:"Z"})},lt.prototype.extend=function(s){if(s.commands)s=s.commands;else if(s instanceof bt){let i=s;this.moveTo(i.x1,i.y1),this.lineTo(i.x2,i.y1),this.lineTo(i.x2,i.y2),this.lineTo(i.x1,i.y2),this.close();return}Array.prototype.push.apply(this.commands,s)},lt.prototype.getBoundingBox=function(){let s=new bt,i=0,l=0,h=0,d=0;for(let p=0;p<this.commands.length;p++){let y=this.commands[p];switch(y.type){case"M":s.addPoint(y.x,y.y),i=h=y.x,l=d=y.y;break;case"L":s.addPoint(y.x,y.y),h=y.x,d=y.y;break;case"Q":s.addQuad(h,d,y.x1,y.y1,y.x,y.y),h=y.x,d=y.y;break;case"C":s.addBezier(h,d,y.x1,y.y1,y.x2,y.y2,y.x,y.y),h=y.x,d=y.y;break;case"Z":h=i,d=l;break;default:throw new Error("Unexpected path command "+y.type)}}return s.isEmpty()&&s.addPoint(0,0),s},lt.prototype.draw=function(s){let i=this._layers;if(i&&i.length){for(let h=0;h<i.length;h++)this.draw.call(i[h],s);return}let l=this._image;if(l){s.drawImage(l.image,l.x,l.y,l.width,l.height);return}s.beginPath();for(let h=0;h<this.commands.length;h+=1){let d=this.commands[h];d.type==="M"?s.moveTo(d.x,d.y):d.type==="L"?s.lineTo(d.x,d.y):d.type==="C"?s.bezierCurveTo(d.x1,d.y1,d.x2,d.y2,d.x,d.y):d.type==="Q"?s.quadraticCurveTo(d.x1,d.y1,d.x,d.y):d.type==="Z"&&this.stroke&&this.strokeWidth&&s.closePath()}this.fill&&(s.fillStyle=this.fill,s.fill()),this.stroke&&(s.strokeStyle=this.stroke,s.lineWidth=this.strokeWidth,s.stroke())},lt.prototype.toPathData=function(s){s=nt(s);function i(x){let A=X(x,s.decimalPlaces);return Math.round(x)===A?""+A:A.toFixed(s.decimalPlaces)}function l(){let x="";for(let A=0;A<arguments.length;A+=1){let E=arguments[A];E>=0&&A>0&&(x+=" "),x+=i(E)}return x}let h=this.commands;s.optimize&&(h=JSON.parse(JSON.stringify(this.commands)),h=ot(h));let d=s.flipY,p=s.flipYBase;if(d===!0&&p===void 0){let x=new lt;x.extend(h);let A=x.getBoundingBox();p=A.y1+A.y2}let y="";for(let x=0;x<h.length;x+=1){let A=h[x];A.type==="M"?y+="M"+l(A.x,d?p-A.y:A.y):A.type==="L"?y+="L"+l(A.x,d?p-A.y:A.y):A.type==="C"?y+="C"+l(A.x1,d?p-A.y1:A.y1,A.x2,d?p-A.y2:A.y2,A.x,d?p-A.y:A.y):A.type==="Q"?y+="Q"+l(A.x1,d?p-A.y1:A.y1,A.x,d?p-A.y:A.y):A.type==="Z"&&(y+="Z")}return y},lt.prototype.toSVG=function(s,i){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),i||(i=this.toPathData(s));let l='<path d="';return l+=i,l+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?l+=' fill="none"':l+=' fill="'+this.fill+'"'),this.stroke&&(l+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),l+="/>",l},lt.prototype.toDOMElement=function(s,i){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),i||(i=this.toPathData(s));let l=document.createElementNS("http://www.w3.org/2000/svg","path");return l.setAttribute("d",i),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?l.setAttribute("fill","none"):l.setAttribute("fill",this.fill)),this.stroke&&(l.setAttribute("stroke",this.stroke),l.setAttribute("stroke-width",this.strokeWidth)),l};var it=lt;function V(s){throw new Error(s)}function H(s,i){s||V(i)}var U={fail:V,argument:H,assert:H},at=32768,Ct=2147483648,gt=-32768,jt=32767+1/65536,Ft={},tt={},ut={};function _t(s){return function(){return s}}tt.BYTE=function(s){return U.argument(s>=0&&s<=255,"Byte value should be between 0 and 255."),[s]},ut.BYTE=_t(1),tt.CHAR=function(s){return[s.charCodeAt(0)]},ut.CHAR=_t(1),tt.CHARARRAY=function(s){(s===null||typeof s>"u")&&(s="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let i=[];for(let l=0;l<s.length;l+=1)i[l]=s.charCodeAt(l);return i},ut.CHARARRAY=function(s){return typeof s>"u"?0:s.length},tt.USHORT=function(s){return[s>>8&255,s&255]},ut.USHORT=_t(2),tt.SHORT=function(s){return s>=at&&(s=-(2*at-s)),[s>>8&255,s&255]},ut.SHORT=_t(2),tt.UINT24=function(s){return[s>>16&255,s>>8&255,s&255]},ut.UINT24=_t(3),tt.ULONG=function(s){return[s>>24&255,s>>16&255,s>>8&255,s&255]},ut.ULONG=_t(4),tt.LONG=function(s){return s>=Ct&&(s=-(2*Ct-s)),[s>>24&255,s>>16&255,s>>8&255,s&255]},ut.LONG=_t(4),tt.FLOAT=function(s){if(s>jt||s<gt)throw new Error(`Value ${s} is outside the range of representable values in 16.16 format`);let i=Math.round(s*65536)<<0;return tt.ULONG(i)},ut.FLOAT=ut.ULONG,tt.FIXED=tt.ULONG,ut.FIXED=ut.ULONG,tt.FWORD=tt.SHORT,ut.FWORD=ut.SHORT,tt.UFWORD=tt.USHORT,ut.UFWORD=ut.USHORT,tt.F2DOT14=function(s){return tt.USHORT(s*16384)},ut.F2DOT14=ut.USHORT,tt.LONGDATETIME=function(s){return[0,0,0,0,s>>24&255,s>>16&255,s>>8&255,s&255]},ut.LONGDATETIME=_t(8),tt.TAG=function(s){return U.argument(s.length===4,"Tag should be exactly 4 ASCII characters."),[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)]},ut.TAG=_t(4),tt.Card8=tt.BYTE,ut.Card8=ut.BYTE,tt.Card16=tt.USHORT,ut.Card16=ut.USHORT,tt.OffSize=tt.BYTE,ut.OffSize=ut.BYTE,tt.SID=tt.USHORT,ut.SID=ut.USHORT,tt.NUMBER=function(s){return s>=-107&&s<=107?[s+139]:s>=108&&s<=1131?(s=s-108,[(s>>8)+247,s&255]):s>=-1131&&s<=-108?(s=-s-108,[(s>>8)+251,s&255]):s>=-32768&&s<=32767?tt.NUMBER16(s):tt.NUMBER32(s)},ut.NUMBER=function(s){return tt.NUMBER(s).length},tt.NUMBER16=function(s){return[28,s>>8&255,s&255]},ut.NUMBER16=_t(3),tt.NUMBER32=function(s){return[29,s>>24&255,s>>16&255,s>>8&255,s&255]},ut.NUMBER32=_t(5),tt.REAL=function(s){let i=s.toString(),l=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(i);if(l){let p=parseFloat("1e"+((l[2]?+l[2]:0)+l[1].length));i=(Math.round(s*p)/p).toString()}let h="";for(let p=0,y=i.length;p<y;p+=1){let x=i[p];x==="e"?h+=i[++p]==="-"?"c":"b":x==="."?h+="a":x==="-"?h+="e":h+=x}h+=h.length&1?"f":"ff";let d=[30];for(let p=0,y=h.length;p<y;p+=2)d.push(parseInt(h.substr(p,2),16));return d},ut.REAL=function(s){return tt.REAL(s).length},tt.NAME=tt.CHARARRAY,ut.NAME=ut.CHARARRAY,tt.STRING=tt.CHARARRAY,ut.STRING=ut.CHARARRAY,Ft.UTF8=function(s,i,l){let h=[],d=l;for(let p=0;p<d;p++,i+=1)h[p]=s.getUint8(i);return String.fromCharCode.apply(null,h)},Ft.UTF16=function(s,i,l){let h=[],d=l/2;for(let p=0;p<d;p++,i+=2)h[p]=s.getUint16(i);return String.fromCharCode.apply(null,h)},tt.UTF16=function(s){let i=[];for(let l=0;l<s.length;l+=1){let h=s.charCodeAt(l);i[i.length]=h>>8&255,i[i.length]=h&255}return i},ut.UTF16=function(s){return s.length*2};var Le={"x-mac-croatian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\u0160\u2122\xB4\xA8\u2260\u017D\xD8\u221E\xB1\u2264\u2265\u2206\xB5\u2202\u2211\u220F\u0161\u222B\xAA\xBA\u03A9\u017E\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u0106\xAB\u010C\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\uF8FF\xA9\u2044\u20AC\u2039\u203A\xC6\xBB\u2013\xB7\u201A\u201E\u2030\xC2\u0107\xC1\u010D\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u0111\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u03C0\xCB\u02DA\xB8\xCA\xE6\u02C7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\xB0\u0490\xA3\xA7\u2022\xB6\u0406\xAE\xA9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\xB1\u2264\u2265\u0456\xB5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E","x-mac-gaelic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u1E02\xB1\u2264\u2265\u1E03\u010A\u010B\u1E0A\u1E0B\u1E1E\u1E1F\u0120\u0121\u1E40\xE6\xF8\u1E41\u1E56\u1E57\u027C\u0192\u017F\u1E60\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u1E61\u1E9B\xFF\u0178\u1E6A\u20AC\u2039\u203A\u0176\u0177\u1E6B\xB7\u1EF2\u1EF3\u204A\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u2663\xD2\xDA\xDB\xD9\u0131\xDD\xFD\u0174\u0175\u1E84\u1E85\u1E80\u1E81\u1E82\u1E83","x-mac-greek":"\xC4\xB9\xB2\xC9\xB3\xD6\xDC\u0385\xE0\xE2\xE4\u0384\xA8\xE7\xE9\xE8\xEA\xEB\xA3\u2122\xEE\xEF\u2022\xBD\u2030\xF4\xF6\xA6\u20AC\xF9\xFB\xFC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\xDF\xAE\xA9\u03A3\u03AA\xA7\u2260\xB0\xB7\u0391\xB1\u2264\u2265\xA5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\xAC\u039F\u03A1\u2248\u03A4\xAB\xBB\u2026\xA0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\xF7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\xAD","x-mac-icelandic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\xDD\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\xD0\xF0\xDE\xFE\xFD\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140A\u140B\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144E\u144F\u1450\u1451\u1455\u1456\u1466\u146D\u146E\u146F\u1470\u1472\u1473\u1483\u148B\u148C\u148D\u148E\u1490\u1491\xB0\u14A1\u14A5\u14A6\u2022\xB6\u14A7\xAE\xA9\u2122\u14A8\u14AA\u14AB\u14BB\u14C2\u14C3\u14C4\u14C5\u14C7\u14C8\u14D0\u14EF\u14F0\u14F1\u14F2\u14F4\u14F5\u1505\u14D5\u14D6\u14D7\u14D8\u14DA\u14DB\u14EA\u1528\u1529\u152A\u152B\u152D\u2026\xA0\u152E\u153E\u1555\u1556\u1557\u2013\u2014\u201C\u201D\u2018\u2019\u1558\u1559\u155A\u155D\u1546\u1547\u1548\u1549\u154B\u154C\u1550\u157F\u1580\u1581\u1582\u1583\u1584\u1585\u158F\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15A0\u15A1\u15A2\u15A3\u15A4\u15A5\u15A6\u157C\u0141\u0142","x-mac-ce":"\xC4\u0100\u0101\xC9\u0104\xD6\xDC\xE1\u0105\u010C\xE4\u010D\u0106\u0107\xE9\u0179\u017A\u010E\xED\u010F\u0112\u0113\u0116\xF3\u0117\xF4\xF6\xF5\xFA\u011A\u011B\xFC\u2020\xB0\u0118\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\u0119\xA8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\xAC\u221A\u0144\u0147\u2206\xAB\xBB\u2026\xA0\u0148\u0150\xD5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\xC1\u0164\u0165\xCD\u017D\u017E\u016A\xD3\xD4\u016B\u016E\xDA\u016F\u0170\u0171\u0172\u0173\xDD\xFD\u0137\u017B\u0141\u017C\u0122\u02C7",macintosh:"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\uFB01\uFB02\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-romanian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\u0102\u0218\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\u0103\u0219\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\u021A\u021B\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-turkish":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\uF8A0\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7"};Ft.MACSTRING=function(s,i,l,h){let d=Le[h];if(d===void 0)return;let p="";for(let y=0;y<l;y++){let x=s.getUint8(i+y);x<=127?p+=String.fromCharCode(x):p+=d[x&127]}return p};var rn=typeof WeakMap=="function"&&new WeakMap,Je,zh=function(s){if(!Je){Je={};for(let d in Le)Je[d]=new String(d)}let i=Je[s];if(i===void 0)return;if(rn){let d=rn.get(i);if(d!==void 0)return d}let l=Le[s];if(l===void 0)return;let h={};for(let d=0;d<l.length;d++)h[l.charCodeAt(d)]=d+128;return rn&&rn.set(i,h),h};tt.MACSTRING=function(s,i){let l=zh(i);if(l===void 0)return;let h=[];for(let d=0;d<s.length;d++){let p=s.charCodeAt(d);if(p>=128&&(p=l[p],p===void 0))return;h[d]=p}return h},ut.MACSTRING=function(s,i){let l=tt.MACSTRING(s,i);return l!==void 0?l.length:0};function wi(s){return s>=-128&&s<=127}function Wh(s,i,l){let h=0,d=s.length;for(;i<d&&h<64&&s[i]===0;)++i,++h;return l.push(128|h-1),i}function Xh(s,i,l){let h=0,d=s.length,p=i;for(;p<d&&h<64;){let y=s[p];if(!wi(y)||y===0&&p+1<d&&s[p+1]===0)break;++p,++h}l.push(h-1);for(let y=i;y<p;++y)l.push(s[y]+256&255);return p}function Yh(s,i,l){let h=0,d=s.length,p=i;for(;p<d&&h<64;){let y=s[p];if(y===0||wi(y)&&p+1<d&&wi(s[p+1]))break;++p,++h}l.push(64|h-1);for(let y=i;y<p;++y){let x=s[y];l.push(x+65536>>8&255,x+256&255)}return p}tt.VARDELTAS=function(s){let i=0,l=[];for(;i<s.length;){let h=s[i];h===0?i=Wh(s,i,l):h>=-128&&h<=127?i=Xh(s,i,l):i=Yh(s,i,l)}return l},tt.INDEX=function(s){let i=1,l=[i],h=[];for(let x=0;x<s.length;x+=1){let A=tt.OBJECT(s[x]);Array.prototype.push.apply(h,A),i+=A.length,l.push(i)}if(h.length===0)return[0,0];let d=[],p=1+Math.floor(Math.log(i)/Math.log(2))/8|0,y=[void 0,tt.BYTE,tt.USHORT,tt.UINT24,tt.ULONG][p];for(let x=0;x<l.length;x+=1){let A=y(l[x]);Array.prototype.push.apply(d,A)}return Array.prototype.concat(tt.Card16(s.length),tt.OffSize(p),d,h)},ut.INDEX=function(s){return tt.INDEX(s).length},tt.DICT=function(s){let i=[],l=Object.keys(s),h=l.length;for(let d=0;d<h;d+=1){let p=parseInt(l[d],0),y=s[p],x=tt.OPERAND(y.value,y.type),A=tt.OPERATOR(p);for(let E=0;E<x.length;E++)i.push(x[E]);for(let E=0;E<A.length;E++)i.push(A[E])}return i},ut.DICT=function(s){return tt.DICT(s).length},tt.OPERATOR=function(s){return s<1200?[s]:[12,s-1200]},tt.OPERAND=function(s,i){let l=[];if(Array.isArray(i))for(let h=0;h<i.length;h+=1){U.argument(s.length===i.length,"Not enough arguments given for type"+i);let d=tt.OPERAND(s[h],i[h]);for(let p=0;p<d.length;p++)l.push(d[p])}else if(i==="SID"){let h=tt.NUMBER(s);for(let d=0;d<h.length;d++)l.push(h[d])}else if(i==="offset"){let h=tt.NUMBER32(s);for(let d=0;d<h.length;d++)l.push(h[d])}else if(i==="number"){let h=tt.NUMBER(s);for(let d=0;d<h.length;d++)l.push(h[d])}else if(i==="real"){let h=tt.REAL(s);for(let d=0;d<h.length;d++)l.push(h[d])}else throw new Error("Unknown operand type "+i);return l},tt.OP=tt.BYTE,ut.OP=ut.BYTE;var Hs=typeof WeakMap=="function"&&new WeakMap;tt.CHARSTRING=function(s){if(Hs){let h=Hs.get(s);if(h!==void 0)return h}let i=[],l=s.length;for(let h=0;h<l;h+=1){let d=s[h],p=tt[d.type](d.value);for(let y=0;y<p.length;y++)i.push(p[y])}return Hs&&Hs.set(s,i),i},ut.CHARSTRING=function(s){return tt.CHARSTRING(s).length},tt.OBJECT=function(s){let i=tt[s.type];return U.argument(i!==void 0,"No encoding function for type "+s.type),i(s.value)},ut.OBJECT=function(s){let i=ut[s.type];return U.argument(i!==void 0,"No sizeOf function for type "+s.type),i(s.value)},tt.TABLE=function(s){let i=[],l=(s.fields||[]).length,h=[],d=[];for(let p=0;p<l;p+=1){let y=s.fields[p],x=tt[y.type];U.argument(x!==void 0,"No encoding function for field type "+y.type+" ("+y.name+")");let A=s[y.name];A===void 0&&(A=y.value);let E=x(A);if(y.type==="TABLE")A.fields!==null&&(d.push(i.length),h.push(E)),i.push(0,0);else for(let C=0;C<E.length;C++)i.push(E[C])}for(let p=0;p<h.length;p+=1){let y=d[p],x=i.length;U.argument(x<65536,"Table "+s.tableName+" too big."),i[y]=x>>8,i[y+1]=x&255;for(let A=0;A<h[p].length;A++)i.push(h[p][A])}return i},ut.TABLE=function(s){let i=0,l=(s.fields||[]).length;for(let h=0;h<l;h+=1){let d=s.fields[h],p=ut[d.type];U.argument(p!==void 0,"No sizeOf function for field type "+d.type+" ("+d.name+")");let y=s[d.name];y===void 0&&(y=d.value),i+=p(y),d.type==="TABLE"&&(i+=2)}return i},tt.RECORD=tt.TABLE,ut.RECORD=ut.TABLE,tt.LITERAL=function(s){return s},ut.LITERAL=function(s){return s.length};function Kt(s,i,l){if(i&&i.length)for(let h=0;h<i.length;h+=1){let d=i[h];this[d.name]=d.value}if(this.tableName=s,this.fields=i,l){let h=Object.keys(l);for(let d=0;d<h.length;d+=1){let p=h[d],y=l[p];this[p]!==void 0&&(this[p]=y)}}}Kt.prototype.encode=function(){return tt.TABLE(this)},Kt.prototype.sizeOf=function(){return ut.TABLE(this)};function Hn(s,i,l){l===void 0&&(l=i.length);let h=new Array(i.length+1);h[0]={name:s+"Count",type:"USHORT",value:l};for(let d=0;d<i.length;d++)h[d+1]={name:s+d,type:"USHORT",value:i[d]};return h}function Ei(s,i,l){let h=i.length,d=new Array(h+1);d[0]={name:s+"Count",type:"USHORT",value:h};for(let p=0;p<h;p++)d[p+1]={name:s+p,type:"TABLE",value:l(i[p],p)};return d}function jn(s,i,l){let h=i.length,d=[];d[0]={name:s+"Count",type:"USHORT",value:h};for(let p=0;p<h;p++)d=d.concat(l(i[p],p));return d}function js(s){s.format===1?Kt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Hn("glyph",s.glyphs))):s.format===2?Kt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(jn("rangeRecord",s.ranges,function(i,l){return[{name:"startGlyphID"+l,type:"USHORT",value:i.start},{name:"endGlyphID"+l,type:"USHORT",value:i.end},{name:"startCoverageIndex"+l,type:"USHORT",value:i.index}]}))):U.assert(!1,"Coverage format must be 1 or 2.")}js.prototype=Object.create(Kt.prototype),js.prototype.constructor=js;function Vs(s){Kt.call(this,"scriptListTable",jn("scriptRecord",s,function(i,l){let h=i.script,d=h.defaultLangSys;return U.assert(!!d,"Unable to write GSUB: script "+i.tag+" has no default language system."),[{name:"scriptTag"+l,type:"TAG",value:i.tag},{name:"script"+l,type:"TABLE",value:new Kt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Kt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:d.reqFeatureIndex}].concat(Hn("featureIndex",d.featureIndexes)))}].concat(jn("langSys",h.langSysRecords,function(p,y){let x=p.langSys;return[{name:"langSysTag"+y,type:"TAG",value:p.tag},{name:"langSys"+y,type:"TABLE",value:new Kt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:x.reqFeatureIndex}].concat(Hn("featureIndex",x.featureIndexes)))}]})))}]}))}Vs.prototype=Object.create(Kt.prototype),Vs.prototype.constructor=Vs;function $s(s){Kt.call(this,"featureListTable",jn("featureRecord",s,function(i,l){let h=i.feature;return[{name:"featureTag"+l,type:"TAG",value:i.tag},{name:"feature"+l,type:"TABLE",value:new Kt("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(Hn("lookupListIndex",h.lookupListIndexes)))}]}))}$s.prototype=Object.create(Kt.prototype),$s.prototype.constructor=$s;function zs(s,i){Kt.call(this,"lookupListTable",Ei("lookup",s,function(l){let h=i[l.lookupType];return U.assert(!!h,"Unable to write GSUB lookup type "+l.lookupType+" tables."),new Kt("lookupTable",[{name:"lookupType",type:"USHORT",value:l.lookupType},{name:"lookupFlag",type:"USHORT",value:l.lookupFlag}].concat(Ei("subtable",l.subtables,h)))}))}zs.prototype=Object.create(Kt.prototype),zs.prototype.constructor=zs;function Ws(s){s.format===1?Kt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:s.startGlyph}].concat(Hn("glyph",s.classes))):s.format===2?Kt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(jn("rangeRecord",s.ranges,function(i,l){return[{name:"startGlyphID"+l,type:"USHORT",value:i.start},{name:"endGlyphID"+l,type:"USHORT",value:i.end},{name:"class"+l,type:"USHORT",value:i.classId}]}))):U.assert(!1,"Class format must be 1 or 2.")}Ws.prototype=Object.create(Kt.prototype),Ws.prototype.constructor=Ws;var J={Table:Kt,Record:Kt,Coverage:js,ClassDef:Ws,ScriptList:Vs,FeatureList:$s,LookupList:zs,ushortList:Hn,tableList:Ei,recordList:jn};function cl(s,i){return s.getUint8(i)}function Xs(s,i){return s.getUint16(i,!1)}function Kh(s,i){return s.getInt16(i,!1)}function ul(s,i){return(s.getUint16(i)<<8)+s.getUint8(i+2)}function ki(s,i){return s.getUint32(i,!1)}function Zh(s,i){return s.getInt32(i,!1)}function hl(s,i){let l=s.getInt16(i,!1),h=s.getUint16(i+2,!1);return l+h/65535}function Qh(s,i){let l="";for(let h=i;h<i+4;h+=1)l+=String.fromCharCode(s.getInt8(h));return l}function Jh(s,i,l){let h=0;for(let d=0;d<l;d+=1)h<<=8,h+=s.getUint8(i+d);return h}function qh(s,i,l){let h=[];for(let d=i;d<l;d+=1)h.push(s.getUint8(d));return h}function td(s){let i="";for(let l=0;l<s.length;l+=1)i+=String.fromCharCode(s[l]);return i}var ed={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},re={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function B(s,i){this.data=s,this.offset=i,this.relativeOffset=0}B.prototype.parseByte=function(){let s=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,s},B.prototype.parseChar=function(){let s=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,s},B.prototype.parseCard8=B.prototype.parseByte,B.prototype.parseUShort=function(){let s=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,s},B.prototype.parseCard16=B.prototype.parseUShort,B.prototype.parseSID=B.prototype.parseUShort,B.prototype.parseOffset16=B.prototype.parseUShort,B.prototype.parseShort=function(){let s=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,s},B.prototype.parseF2Dot14=function(){let s=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,s},B.prototype.parseUInt24=function(){let s=ul(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,s},B.prototype.parseULong=function(){let s=ki(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},B.prototype.parseLong=function(){let s=Zh(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},B.prototype.parseOffset32=B.prototype.parseULong,B.prototype.parseFixed=function(){let s=hl(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},B.prototype.parseString=function(s){let i=this.data,l=this.offset+this.relativeOffset,h="";this.relativeOffset+=s;for(let d=0;d<s;d++)h+=String.fromCharCode(i.getUint8(l+d));return h},B.prototype.parseTag=function(){return this.parseString(4)},B.prototype.parseLongDateTime=function(){let s=ki(this.data,this.offset+this.relativeOffset+4);return s-=2082844800,this.relativeOffset+=8,s},B.prototype.parseVersion=function(s){let i=Xs(this.data,this.offset+this.relativeOffset),l=Xs(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,s===void 0&&(s=4096),i+l/s/10},B.prototype.skip=function(s,i){i===void 0&&(i=1),this.relativeOffset+=ed[s]*i},B.prototype.parseULongList=function(s){s===void 0&&(s=this.parseULong());let i=new Array(s),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)i[d]=l.getUint32(h),h+=4;return this.relativeOffset+=s*4,i},B.prototype.parseOffset16List=B.prototype.parseUShortList=function(s){s===void 0&&(s=this.parseUShort());let i=new Array(s),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)i[d]=l.getUint16(h),h+=2;return this.relativeOffset+=s*2,i},B.prototype.parseShortList=function(s){let i=new Array(s),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)i[d]=l.getInt16(h),h+=2;return this.relativeOffset+=s*2,i},B.prototype.parseByteList=function(s){let i=new Array(s),l=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)i[d]=l.getUint8(h++);return this.relativeOffset+=s,i},B.prototype.parseList=function(s,i){i||(i=s,s=this.parseUShort());let l=new Array(s);for(let h=0;h<s;h++)l[h]=i.call(this);return l},B.prototype.parseList32=function(s,i){i||(i=s,s=this.parseULong());let l=new Array(s);for(let h=0;h<s;h++)l[h]=i.call(this);return l},B.prototype.parseRecordList=function(s,i){i||(i=s,s=this.parseUShort());let l=new Array(s),h=Object.keys(i);for(let d=0;d<s;d++){let p={};for(let y=0;y<h.length;y++){let x=h[y],A=i[x];p[x]=A.call(this)}l[d]=p}return l},B.prototype.parseRecordList32=function(s,i){i||(i=s,s=this.parseULong());let l=new Array(s),h=Object.keys(i);for(let d=0;d<s;d++){let p={};for(let y=0;y<h.length;y++){let x=h[y],A=i[x];p[x]=A.call(this)}l[d]=p}return l},B.prototype.parseTupleRecords=function(s,i){let l=[];for(let h=0;h<s;h++){let d=[];for(let p=0;p<i;p++)d.push(this.parseF2Dot14());l.push(d)}return l},B.prototype.parseStruct=function(s){if(typeof s=="function")return s.call(this);{let i=Object.keys(s),l={};for(let h=0;h<i.length;h++){let d=i[h],p=s[d];l[d]=p.call(this)}return l}},B.prototype.parseValueRecord=function(s){if(s===void 0&&(s=this.parseUShort()),s===0)return;let i={};return s&1&&(i.xPlacement=this.parseShort()),s&2&&(i.yPlacement=this.parseShort()),s&4&&(i.xAdvance=this.parseShort()),s&8&&(i.yAdvance=this.parseShort()),s&16&&(i.xPlaDevice=void 0,this.parseShort()),s&32&&(i.yPlaDevice=void 0,this.parseShort()),s&64&&(i.xAdvDevice=void 0,this.parseShort()),s&128&&(i.yAdvDevice=void 0,this.parseShort()),i},B.prototype.parseValueRecordList=function(){let s=this.parseUShort(),i=this.parseUShort(),l=new Array(i);for(let h=0;h<i;h++)l[h]=this.parseValueRecord(s);return l},B.prototype.parsePointer=function(s){let i=this.parseOffset16();if(i>0)return new B(this.data,this.offset+i).parseStruct(s)},B.prototype.parsePointer32=function(s){let i=this.parseOffset32();if(i>0)return new B(this.data,this.offset+i).parseStruct(s)},B.prototype.parseListOfLists=function(s){let i=this.parseOffset16List(),l=i.length,h=this.relativeOffset,d=new Array(l);for(let p=0;p<l;p++){let y=i[p];if(y===0){d[p]=void 0;continue}if(this.relativeOffset=y,s){let x=this.parseOffset16List(),A=new Array(x.length);for(let E=0;E<x.length;E++)this.relativeOffset=y+x[E],A[E]=s.call(this);d[p]=A}else d[p]=this.parseUShortList()}return this.relativeOffset=h,d},B.prototype.parseCoverage=function(){let s=this.offset+this.relativeOffset,i=this.parseUShort(),l=this.parseUShort();if(i===1)return{format:1,glyphs:this.parseUShortList(l)};if(i===2){let h=new Array(l);for(let d=0;d<l;d++)h[d]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:h}}throw new Error("0x"+s.toString(16)+": Coverage format must be 1 or 2.")},B.prototype.parseClassDef=function(){let s=this.offset+this.relativeOffset,i=this.parseUShort();return i===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:i===2?{format:2,ranges:this.parseRecordList({start:B.uShort,end:B.uShort,classId:B.uShort})}:(console.warn(`0x${s.toString(16)}: This font file uses an invalid ClassDef format of ${i}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:i})},B.list=function(s,i){return function(){return this.parseList(s,i)}},B.list32=function(s,i){return function(){return this.parseList32(s,i)}},B.recordList=function(s,i){return function(){return this.parseRecordList(s,i)}},B.recordList32=function(s,i){return function(){return this.parseRecordList32(s,i)}},B.pointer=function(s){return function(){return this.parsePointer(s)}},B.pointer32=function(s){return function(){return this.parsePointer32(s)}},B.tag=B.prototype.parseTag,B.byte=B.prototype.parseByte,B.uShort=B.offset16=B.prototype.parseUShort,B.uShortList=B.prototype.parseUShortList,B.uInt24=B.prototype.parseUInt24,B.uLong=B.offset32=B.prototype.parseULong,B.uLongList=B.prototype.parseULongList,B.fixed=B.prototype.parseFixed,B.f2Dot14=B.prototype.parseF2Dot14,B.struct=B.prototype.parseStruct,B.coverage=B.prototype.parseCoverage,B.classDef=B.prototype.parseClassDef;var dl={reserved:B.uShort,reqFeatureIndex:B.uShort,featureIndexes:B.uShortList};B.prototype.parseScriptList=function(){return this.parsePointer(B.recordList({tag:B.tag,script:B.pointer({defaultLangSys:B.pointer(dl),langSysRecords:B.recordList({tag:B.tag,langSys:B.pointer(dl)})})}))||[]},B.prototype.parseFeatureList=function(){return this.parsePointer(B.recordList({tag:B.tag,feature:B.pointer({featureParams:B.offset16,lookupListIndexes:B.uShortList})}))||[]},B.prototype.parseLookupList=function(s){return this.parsePointer(B.list(B.pointer(function(){let i=this.parseUShort();U.argument(1<=i&&i<=9,"GPOS/GSUB lookup type "+i+" unknown.");let l=this.parseUShort(),h=l&16;return{lookupType:i,lookupFlag:l,subtables:this.parseList(B.pointer(s[i])),markFilteringSet:h?this.parseUShort():void 0}})))||[]},B.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let s=this.parseUShort(),i=this.parseUShort();return U.argument(s===1&&i<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:B.offset32,featureTableSubstitutionOffset:B.offset32})})||[]},B.prototype.parseVariationStore=function(){let s=this.relativeOffset,i=this.parseUShort(),l={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=s+i+2,l},B.prototype.parseItemVariationStore=function(){let s=this.relativeOffset,i={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},l=this.parseOffset32(),h=this.parseUShort(),d=this.parseULongList(h);this.relativeOffset=s+l,i.variationRegions=this.parseVariationRegionList();for(let p=0;p<h;p++){let y=d[p];this.relativeOffset=s+y,i.itemVariationSubtables.push(this.parseItemVariationSubtable())}return i},B.prototype.parseVariationRegionList=function(){let s=this.parseUShort(),i=this.parseUShort();return this.parseRecordList(i,{regionAxes:B.recordList(s,{startCoord:B.f2Dot14,peakCoord:B.f2Dot14,endCoord:B.f2Dot14})})},B.prototype.parseItemVariationSubtable=function(){let s=this.parseUShort(),i=this.parseUShort(),l=this.parseUShortList(),h=l.length;return{regionIndexes:l,deltaSets:s&&h?this.parseDeltaSets(s,i,h):[]}},B.prototype.parseDeltaSetIndexMap=function(){let s=this.parseByte(),i=this.parseByte(),l=[],h=0;switch(s){case 0:h=this.parseUShort();break;case 1:h=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${s}`)}if(!h)return{format:s,entryFormat:i};let d=(i&re.INNER_INDEX_BIT_COUNT_MASK)+1,p=((i&re.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let y=0;y<h;y++){let x;if(p===1)x=this.parseByte();else if(p===2)x=this.parseUShort();else if(p===3)x=this.parseUInt24();else if(p===4)x=this.parseULong();else throw new Error(`Invalid entry size of ${p}`);let A=x>>d,E=x&(1<<d)-1;l.push({outerIndex:A,innerIndex:E})}return{format:s,entryFormat:i,map:l}},B.prototype.parseDeltaSets=function(s,i,l){let h=Array.from({length:s},()=>[]),d=i&re.LONG_WORDS,p=i&re.WORD_DELTA_COUNT_MASK;if(p>l)throw Error("wordCount must be less than or equal to regionIndexCount");let y=(d?this.parseLong:this.parseShort).bind(this),x=(d?this.parseShort:this.parseChar).bind(this);for(let A=0;A<s;A++)for(let E=0;E<l;E++)E<p?h[A].push(y()):h[A].push(x());return h},B.prototype.parseTupleVariationStoreList=function(s,i,l){let h=this.parseUShort(),p=this.parseUShort()&1,y=this.parseOffset32(),x=(p?this.parseULong:this.parseUShort).bind(this),A={},E=x();p||(E*=2);let C;for(let R=0;R<h;R++){C=x(),p||(C*=2);let P=C-E;A[R]=P?this.parseTupleVariationStore(y+E,s,i,l,R):void 0,E=C}return A},B.prototype.parseTupleVariationStore=function(s,i,l,h,d){let p=this.relativeOffset;this.relativeOffset=s,l==="cvar"&&(this.relativeOffset+=4);let y=this.parseUShort(),x=!!(y&re.SHARED_POINT_NUMBERS),A=y&re.COUNT_MASK,E=this.parseOffset16(),C=[],R=[];for(let M=0;M<A;M++){let N=this.parseTupleVariationHeader(i,l);C.push(N)}this.relativeOffset!==s+E&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${s+E}, actually ${this.relativeOffset}`),this.relativeOffset=s+E),x&&(R=this.parsePackedPointNumbers());let P=this.relativeOffset;for(let M=0;M<A;M++){let N=C[M];N.privatePoints=[],this.relativeOffset=P,l==="cvar"&&!N.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),N.flags.privatePointNumbers&&(N.privatePoints=this.parsePackedPointNumbers()),delete N.flags;let z=this.offset,vt=this.relativeOffset,pt=At=>{let It,Nt,Bt=()=>{let Gt=0;if(l==="gvar"){if(Gt=N.privatePoints.length||R.length,!Gt){let Jt=h.get(d);Jt.path,Gt=Jt.points.length,Gt+=4}}else l==="cvar"&&(Gt=h.length);this.offset=z,this.relativeOffset=vt,It=this.parsePackedDeltas(Gt),l==="gvar"&&(Nt=this.parsePackedDeltas(Gt))};return{configurable:!0,get:function(){return It===void 0&&Bt(),At==="deltasY"?Nt:It},set:function(Gt){It===void 0&&Bt(),At==="deltasY"?Nt=Gt:It=Gt}}};Object.defineProperty(N,"deltas",pt.call(this,"deltas")),l==="gvar"&&Object.defineProperty(N,"deltasY",pt.call(this,"deltasY")),P+=N.variationDataSize,delete N.variationDataSize}this.relativeOffset=p;let L={headers:C};return L.sharedPoints=R,L},B.prototype.parseTupleVariationHeader=function(s,i){let l=this.parseUShort(),h=this.parseUShort(),d=!!(h&re.EMBEDDED_PEAK_TUPLE),p=!!(h&re.INTERMEDIATE_REGION),y=!!(h&re.PRIVATE_POINT_NUMBERS),x=d?void 0:h&re.TUPLE_INDEX_MASK,A=d?this.parseTupleRecords(1,s)[0]:void 0,E=p?this.parseTupleRecords(1,s)[0]:void 0,C=p?this.parseTupleRecords(1,s)[0]:void 0,R={variationDataSize:l,peakTuple:A,intermediateStartTuple:E,intermediateEndTuple:C,flags:{embeddedPeakTuple:d,intermediateRegion:p,privatePointNumbers:y}};return i==="gvar"&&(R.sharedTupleRecordsIndex=x),R},B.prototype.parsePackedPointNumbers=function(){let s=this.parseByte(),i=[],l=s;if(s>=128){let d=this.parseByte();l=(s&re.POINT_RUN_COUNT_MASK)<<8|d}let h=0;for(;i.length<l;){let d=this.parseByte(),p=!!(d&re.POINTS_ARE_WORDS),y=(d&re.POINT_RUN_COUNT_MASK)+1;for(let x=0;x<y&&i.length<l;x++){let A;p?A=this.parseUShort():A=this.parseByte(),h=h+A,i.push(h)}}return i},B.prototype.parsePackedDeltas=function(s){let i=[];for(;i.length<s;){let l=this.parseByte(),h=!!(l&re.DELTAS_ARE_ZERO),d=!!(l&re.DELTAS_ARE_WORDS),p=(l&re.DELTA_RUN_COUNT_MASK)+1;for(let y=0;y<p&&i.length<s;y++)h?i.push(0):d?i.push(this.parseShort()):i.push(this.parseChar())}return i};var rt={getByte:cl,getCard8:cl,getUShort:Xs,getCard16:Xs,getShort:Kh,getUInt24:ul,getULong:ki,getFixed:hl,getTag:Qh,getOffset:Jh,getBytes:qh,bytesToString:td,Parser:B},Ys=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],fl={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},nd={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},pl={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function sd(s,i,l){switch(s){case 0:if(i===65535)return"und";if(l)return l[i];break;case 1:return fl[i];case 3:return pl[i]}}var Ii="utf-16",rd={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},id={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Pi(s,i,l){switch(s){case 0:return Ii;case 1:return id[l]||rd[i];case 3:if(i===1||i===10)return Ii;break}}var gl={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function od(s){return gl[s]}function ad(s,i,l){let h={},d=new rt.Parser(s,i),p=d.parseUShort(),y=d.parseUShort(),x=d.offset+d.parseUShort();for(let A=0;A<y;A++){let E=d.parseUShort(),C=d.parseUShort(),R=d.parseUShort(),P=d.parseUShort(),L=Ys[P]||P,M=d.parseUShort(),N=d.parseUShort(),z=sd(E,R,l),vt=Pi(E,C,R),pt=od(E);if(vt!==void 0&&z!==void 0&&pt!==void 0){let At;if(vt===Ii?At=Ft.UTF16(s,x+N,M):At=Ft.MACSTRING(s,x+N,M,vt),At){let It=h[pt];It===void 0&&(It=h[pt]={});let Nt=It[L];Nt===void 0&&(Nt=It[L]={}),Nt[z]=At}}}return p===1&&d.parseUShort(),h}function Ks(s){let i={};for(let l in s)i[s[l]]=parseInt(l);return i}function ml(s,i,l,h,d,p){return new J.Record("NameRecord",[{name:"platformID",type:"USHORT",value:s},{name:"encodingID",type:"USHORT",value:i},{name:"languageID",type:"USHORT",value:l},{name:"nameID",type:"USHORT",value:h},{name:"length",type:"USHORT",value:d},{name:"offset",type:"USHORT",value:p}])}function ld(s,i){let l=s.length,h=i.length-l+1;t:for(let d=0;d<h;d++)for(;d<h;d++){for(let p=0;p<l;p++)if(i[d+p]!==s[p])continue t;return d}return-1}function bl(s,i){let l=ld(s,i);if(l<0){l=i.length;let h=0,d=s.length;for(;h<d;++h)i.push(s[h])}return l}function cd(s,i){let l=Ks(gl),h=Ks(fl),d=Ks(pl),p=[],y=[];for(let A in s){let E,C=[],R={},P=Ks(Ys),L=l[A];for(let M in s[A]){let N=P[M];if(N===void 0&&(N=M),E=parseInt(N),isNaN(E))throw new Error('Name table entry "'+M+'" does not exist, see nameTableNames for complete list.');R[E]=s[A][M],C.push(E)}for(let M=0;M<C.length;M++){E=C[M];let N=R[E];for(let z in N){let vt=N[z];if(L===1||L===0){let pt=h[z],At=nd[pt],It=Pi(L,At,pt),Nt=tt.MACSTRING(vt,It);if(L===0&&(pt=i.indexOf(z),pt<0&&(pt=i.length,i.push(z)),At=4,Nt=tt.UTF16(vt)),Nt!==void 0){let Bt=bl(Nt,y);p.push(ml(L,At,pt,E,Nt.length,Bt))}}if(L===3){let pt=d[z];if(pt!==void 0){let At=tt.UTF16(vt),It=bl(At,y);p.push(ml(3,1,pt,E,At.length,It))}}}}}p.sort(function(A,E){return A.platformID-E.platformID||A.encodingID-E.encodingID||A.languageID-E.languageID||A.nameID-E.nameID});let x=new J.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:p.length},{name:"stringOffset",type:"USHORT",value:6+p.length*12}]);for(let A=0;A<p.length;A++)x.fields.push({name:"record_"+A,type:"RECORD",value:p[A]});return x.fields.push({name:"strings",type:"LITERAL",value:y}),x}function Zs(s,i,l=[]){if(i<256&&i in Ys){if(l.length&&!l.includes(parseInt(i)))return;i=Ys[i]}for(let h in s)for(let d in s[h])if(d===i||parseInt(d)===i)return s[h][d]}var yl={parse:ad,make:cd,getNameByID:Zs};function ud(s,i,l,h){s.length=i.parseUShort(),s.language=i.parseUShort()-1;let d=i.parseByteList(s.length),p=Object.assign({},d),y=Pi(l,h,s.language),x=Le[y];for(let A=0;A<x.length;A++)p[x.charCodeAt(A)]=d[128+A];s.glyphIndexMap=p}function hd(s,i,l){i.parseUShort(),s.length=i.parseULong(),s.language=i.parseULong();let h;s.groupCount=h=i.parseULong(),s.glyphIndexMap={};for(let d=0;d<h;d+=1){let p=i.parseULong(),y=i.parseULong(),x=i.parseULong();for(let A=p;A<=y;A+=1)s.glyphIndexMap[A]=x,l===12&&x++}}function dd(s,i,l,h,d){s.length=i.parseUShort(),s.language=i.parseUShort();let p;s.segCount=p=i.parseUShort()>>1,i.skip("uShort",3),s.glyphIndexMap={};let y=new rt.Parser(l,h+d+14),x=new rt.Parser(l,h+d+16+p*2),A=new rt.Parser(l,h+d+16+p*4),E=new rt.Parser(l,h+d+16+p*6),C=h+d+16+p*8;for(let R=0;R<p-1;R+=1){let P,L=y.parseUShort(),M=x.parseUShort(),N=A.parseShort(),z=E.parseUShort();for(let vt=M;vt<=L;vt+=1)z!==0?(C=E.offset+E.relativeOffset-2,C+=z,C+=(vt-M)*2,P=rt.getUShort(l,C),P!==0&&(P=P+N&65535)):P=vt+N&65535,s.glyphIndexMap[vt]=P}}function fd(s,i){let l={};i.skip("uLong");let h=i.parseULong();for(let d=0;d<h;d+=1){let p=i.parseUInt24(),y={varSelector:p},x=i.parseOffset32(),A=i.parseOffset32(),E=i.relativeOffset;x&&(i.relativeOffset=x,y.defaultUVS=i.parseStruct({ranges:function(){return i.parseRecordList32({startUnicodeValue:i.parseUInt24,additionalCount:i.parseByte})}})),A&&(i.relativeOffset=A,y.nonDefaultUVS=i.parseStruct({uvsMappings:function(){let C={},R=i.parseRecordList32({unicodeValue:i.parseUInt24,glyphID:i.parseUShort});for(let P=0;P<R.length;P+=1)C[R[P].unicodeValue]=R[P];return C}})),l[p]=y,i.relativeOffset=E}s.varSelectorList=l}function pd(s,i){let l={};l.version=rt.getUShort(s,i),U.argument(l.version===0,"cmap table version should be 0."),l.numTables=rt.getUShort(s,i+2);let h=null,d=-1,p=-1,y=null,x=null,A=[0,1,2,3,4,6],E=[0,1,10];for(let R=l.numTables-1;R>=0;R-=1)if(y=rt.getUShort(s,i+4+R*8),x=rt.getUShort(s,i+4+R*8+2),y===3&&E.includes(x)||y===0&&A.includes(x)||y===1&&x===0){if(p>0)continue;if(p=rt.getULong(s,i+4+R*8+4),h)break}else if(y===0&&x===5){if(d=rt.getULong(s,i+4+R*8+4),h=new rt.Parser(s,i+d),h.parseUShort()!==14)d=-1,h=null;else if(p>0)break}if(p===-1)throw new Error("No valid cmap sub-tables found.");let C=new rt.Parser(s,i+p);if(l.format=C.parseUShort(),l.format===0)ud(l,C,y,x);else if(l.format===12||l.format===13)hd(l,C,l.format);else if(l.format===4)dd(l,C,s,i,p);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+l.format+", platformId "+y+", encodingId "+x+").");return h&&fd(l,h),l}function gd(s,i,l){s.segments.push({end:i,start:i,delta:-(i-l),offset:0,glyphIndex:l})}function md(s){s.segments.push({end:65535,start:65535,delta:1,offset:0})}function bd(s){if(s.length===0)return s;let i=[s[0]];for(let l=1;l<s.length;l++){let h=i[i.length-1],d=s[l];h.end+1===d.start&&h.delta===d.delta&&d.end!==65535?h.end=d.end:i.push(d)}return i}function yd(s){let i=!0,l;for(l=s.length-1;l>0;l-=1)if(s.get(l).unicode>65535){i=!1;break}let h=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:i?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:i?12:20}];i||h.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),h.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let d=new J.Table("cmap",h);for(d.segments=[],l=0;l<s.length;l+=1){let L=s.get(l);for(let M=0;M<L.unicodes.length;M+=1)gd(d,L.unicodes[M],l)}d.segments.sort(function(L,M){return L.start-M.start}),d.segments=bd(d.segments),md(d);let p=d.segments.length,y=0,x=[],A=[],E=[],C=[],R=[],P=[];for(l=0;l<p;l+=1){let L=d.segments[l];L.end<=65535&&L.start<=65535?(x.push({name:"end_"+l,type:"USHORT",value:L.end}),A.push({name:"start_"+l,type:"USHORT",value:L.start}),E.push({name:"idDelta_"+l,type:"SHORT",value:L.delta}),C.push({name:"idRangeOffset_"+l,type:"USHORT",value:L.offset}),L.glyphId!==void 0&&R.push({name:"glyph_"+l,type:"USHORT",value:L.glyphId})):y+=1,!i&&L.glyphIndex!==void 0&&(P.push({name:"cmap12Start_"+l,type:"ULONG",value:L.start}),P.push({name:"cmap12End_"+l,type:"ULONG",value:L.end}),P.push({name:"cmap12Glyph_"+l,type:"ULONG",value:L.glyphIndex}))}d.segCountX2=(p-y)*2,d.searchRange=Math.pow(2,Math.floor(Math.log(p-y)/Math.log(2)))*2,d.entrySelector=Math.log(d.searchRange/2)/Math.log(2),d.rangeShift=d.segCountX2-d.searchRange;for(let L=0;L<x.length;L++)d.fields.push(x[L]);d.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let L=0;L<A.length;L++)d.fields.push(A[L]);for(let L=0;L<E.length;L++)d.fields.push(E[L]);for(let L=0;L<C.length;L++)d.fields.push(C[L]);for(let L=0;L<R.length;L++)d.fields.push(R[L]);if(d.cmap4Length=14+x.length*2+2+A.length*2+E.length*2+C.length*2+R.length*2,!i){let L=16+P.length*4;d.cmap12Offset=20+d.cmap4Length,d.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:L},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:P.length/3});for(let M=0;M<P.length;M++)d.fields.push(P[M])}return d}var vl={parse:pd,make:yd},Qs=[".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","266 ff","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"],vd=[".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"],xd=[".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"],Sd=[".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"],Ri=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Ad=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],An=[".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 xl(s){this.font=s}xl.prototype.charToGlyphIndex=function(s){let i=s.codePointAt(0),l=this.font.glyphs;if(l)for(let h=0;h<l.length;h+=1){let d=l.get(h);for(let p=0;p<d.unicodes.length;p+=1)if(d.unicodes[p]===i)return h}return null};function Sl(s){this.cmap=s}Sl.prototype.charToGlyphIndex=function(s){return this.cmap.glyphIndexMap[s.codePointAt(0)]||0};function Al(s,i){this.encoding=s,this.charset=i}Al.prototype.charToGlyphIndex=function(s){let i=s.codePointAt(0),l=this.encoding[i];return this.charset.indexOf(l)};function Oi(s){switch(s.version){case 1:this.names=An.slice();break;case 2:this.names=new Array(s.numberOfGlyphs);for(let i=0;i<s.numberOfGlyphs;i++)s.glyphNameIndex[i]<An.length?this.names[i]=An[s.glyphNameIndex[i]]:this.names[i]=s.names[s.glyphNameIndex[i]-An.length];break;case 2.5:this.names=new Array(s.numberOfGlyphs);for(let i=0;i<s.numberOfGlyphs;i++)this.names[i]=An[i+s.glyphNameIndex[i]];break;case 3:this.names=[];break;default:this.names=[];break}}Oi.prototype.nameToGlyphIndex=function(s){return this.names.indexOf(s)},Oi.prototype.glyphIndexToName=function(s){return this.names[s]};function Td(s){let i,l=s.tables.cmap.glyphIndexMap,h=Object.keys(l);for(let d=0;d<h.length;d+=1){let p=h[d],y=l[p];i=s.glyphs.get(y),i.addUnicode(parseInt(p))}for(let d=0;d<s.glyphs.length;d+=1)i=s.glyphs.get(d),s.cffEncoding?i.name=s.cffEncoding.charset[d]:s.glyphNames.names&&(i.name=s.glyphNames.glyphIndexToName(d))}function Cd(s){s._IndexToUnicodeMap={};let i=s.tables.cmap.glyphIndexMap,l=Object.keys(i);for(let h=0;h<l.length;h+=1){let d=l[h],p=i[d];s._IndexToUnicodeMap[p]===void 0?s._IndexToUnicodeMap[p]={unicodes:[parseInt(d)]}:s._IndexToUnicodeMap[p].unicodes.push(parseInt(d))}}function wd(s,i){i.lowMemory?Cd(s):Td(s)}function Ed(s,i,l,h,d){s.beginPath(),s.moveTo(i,l),s.lineTo(h,d),s.stroke()}var Tn={line:Ed};function kd(s,i){let l=new B(s,i),h=l.parseShort();h!==0&&console.warn("Only CPALv0 is currently fully supported.");let d=l.parseShort(),p=l.parseShort(),y=l.parseShort(),x=l.parseOffset32(),A=l.parseUShortList(p);l.relativeOffset=x;let E=l.parseULongList(y);return l.relativeOffset=x,{version:h,numPaletteEntries:d,colorRecords:E,colorRecordIndices:A}}function Id({version:s=0,numPaletteEntries:i=0,colorRecords:l=[],colorRecordIndices:h=[0]}){return U.argument(s===0,"Only CPALv0 are supported."),U.argument(l.length,"No colorRecords given."),U.argument(h.length,"No colorRecordIndices given."),h.length>1&&U.argument(i,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new J.Table("CPAL",[{name:"version",type:"USHORT",value:s},{name:"numPaletteEntries",type:"USHORT",value:i||l.length},{name:"numPalettes",type:"USHORT",value:h.length},{name:"numColorRecords",type:"USHORT",value:l.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*h.length},...h.map((d,p)=>({name:"colorRecordIndices_"+p,type:"USHORT",value:d})),...l.map((d,p)=>({name:"colorRecords_"+p,type:"ULONG",value:d}))])}function Tl(s){var i=(s&4278190080)>>24,l=(s&16711680)>>16,h=(s&65280)>>8,d=s&255;return i=i+256&255,l=l+256&255,h=h+256&255,d=(d+256&255)/255,{b:i,g:l,r:h,a:d}}function Mi(s,i,l=0,h="hexa"){if(i==65535)return"currentColor";let d=s&&s.tables&&s.tables.cpal;if(!d)return"currentColor";if(l>d.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${d.colorRecordIndices.length}, index: ${i})`);if(i>d.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${d.numPaletteEntries}, index: ${i})`);let p=d.colorRecordIndices[l]+i;if(p>d.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${d.colorRecords.length}, lookupIndex: ${p})`);let y=Tl(d.colorRecords[p]);return h==="bgra"?y:Vn(y,h)}function Fe(s){return("0"+parseInt(s).toString(16)).slice(-2)}function Pd(s){let i=s.r/255,l=s.g/255,h=s.b/255,d=Math.max(i,l,h),p=Math.min(i,l,h),y,x,A=(d+p)/2;if(d===p)y=x=0;else{let E=d-p;switch(x=A>.5?E/(2-d-p):E/(d+p),d){case i:y=(l-h)/E+(l<h?6:0);break;case l:y=(h-i)/E+2;break;case h:y=(i-l)/E+4;break}y/=6}return{h:y*360,s:x*100,l:A*100}}function Rd(s){let{h:i,s:l,l:h,a:d}=s;i=i%360,l/=100,h/=100;let p=(1-Math.abs(2*h-1))*l,y=p*(1-Math.abs(i/60%2-1)),x=h-p/2,A=0,E=0,C=0;return 0<=i&&i<60?(A=p,E=y,C=0):60<=i&&i<120?(A=y,E=p,C=0):120<=i&&i<180?(A=0,E=p,C=y):180<=i&&i<240?(A=0,E=y,C=p):240<=i&&i<300?(A=y,E=0,C=p):300<=i&&i<=360&&(A=p,E=0,C=y),{r:Math.round((A+x)*255),g:Math.round((E+x)*255),b:Math.round((C+x)*255),a:d}}function Cl(s){return parseInt(`0x${Fe(s.b)}${Fe(s.g)}${Fe(s.r)}${Fe(s.a*255)}`,16)}function Js(s,i="hexa"){let l=i=="raw"||i=="cpal",h=Number.isInteger(s),d=!0;if(h&&l||s==="currentColor")return s;if(typeof s=="object"){if(i=="bgra")return s;if(l)return Cl(s)}else if(!h&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(s.trim())){switch(s=s.trim().substring(1),s.length){case 3:s={r:parseInt(s[0].repeat(2),16),g:parseInt(s[1].repeat(2),16),b:parseInt(s[2].repeat(2),16),a:1};break;case 4:s={r:parseInt(s[0].repeat(2),16),g:parseInt(s[1].repeat(2),16),b:parseInt(s[2].repeat(2),16),a:parseInt(s[3].repeat(2),16)/255};break;case 6:s={r:parseInt(s[0]+s[1],16),g:parseInt(s[2]+s[3],16),b:parseInt(s[4]+s[5],16),a:1};break;case 8:s={r:parseInt(s[0]+s[1],16),g:parseInt(s[2]+s[3],16),b:parseInt(s[4]+s[5],16),a:parseInt(s[6]+s[7],16)/255};break}if(i=="bgra")return s}else if(typeof document<"u"&&/^[a-z]+$/i.test(s)){let p=document.createElement("canvas").getContext("2d");p.fillStyle=s;let y=Vn(p.fillStyle,"hexa");y==="#000000ff"&&s.toLowerCase()!=="black"?d=!1:s=y}else{s=s.trim();let p=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(p.test(s)){let y=s.match(p).filter(x=>typeof x<"u");s={r:Math.round(parseFloat(y[1])/(y[2]?.39215686274509803:1)),g:Math.round(parseFloat(y[3])/(y[4]?.39215686274509803:1)),b:Math.round(parseFloat(y[5])/(y[6]?.39215686274509803:1)),a:y[7]?parseFloat(y[7])/(y[8]?100:1):1}}else{let y=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(y.test(s)){let x=s.match(y).filter(A=>typeof A<"u");s=Rd({h:parseFloat(x[1])*(x[2]==="turn"?360:1),s:parseFloat(x[3]),l:parseFloat(x[4]),a:x[5]?parseFloat(x[5])/(x[6]?100:1):1})}else d=!1}}if(!d)throw new Error(`Invalid color format: ${s}`);return Vn(s,i)}function Vn(s,i="hexa"){if(s==="currentColor")return s;if(Number.isInteger(s)){if(i=="raw"||i=="cpal")return s;s=Tl(s)}else typeof s!="object"&&(s=Js(s,"bgra"));let l=["hsl","hsla"].includes(i)?Pd(s):null;switch(i){case"rgba":return`rgba(${s.r}, ${s.g}, ${s.b}, ${parseFloat(s.a.toFixed(3))})`;case"rgb":return`rgb(${s.r}, ${s.g}, ${s.b})`;case"hex":case"hex6":case"hex-6":return`#${Fe(s.r)}${Fe(s.g)}${Fe(s.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Fe(s.r)}${Fe(s.g)}${Fe(s.b)}${Fe(s.a*255)}`;case"hsl":return`hsl(${l.h.toFixed(2)}, ${l.s.toFixed(2)}%, ${l.l.toFixed(2)}%)`;case"hsla":return`hsla(${l.h.toFixed(2)}, ${l.s.toFixed(2)}%, ${l.l.toFixed(2)}%, ${parseFloat(s.a.toFixed(3))})`;case"bgra":return s;case"raw":case"cpal":return Cl(s);default:throw new Error("Unknown color format: "+i)}}var wl={parse:kd,make:Id,getPaletteColor:Mi,parseColor:Js,formatColor:Vn};function Od(s,i){let l=i||new it;return{configurable:!0,get:function(){return typeof l=="function"&&(l=l()),l},set:function(h){l=h}}}function ie(s){this.bindConstructorValues(s)}ie.prototype.bindConstructorValues=function(s){if(this.index=s.index||0,s.name===".notdef"?s.unicode=void 0:s.name===".null"&&(s.unicode=0),s.unicode===0&&s.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=s.name||null,this.unicode=s.unicode,this.unicodes=s.unicodes||(s.unicode!==void 0?[s.unicode]:[]),"xMin"in s&&(this.xMin=s.xMin),"yMin"in s&&(this.yMin=s.yMin),"xMax"in s&&(this.xMax=s.xMax),"yMax"in s&&(this.yMax=s.yMax),"advanceWidth"in s&&(this.advanceWidth=s.advanceWidth),"leftSideBearing"in s&&(this.leftSideBearing=s.leftSideBearing),"points"in s&&(this.points=s.points),Object.defineProperty(this,"path",Od(this,s.path))},ie.prototype.addUnicode=function(s){this.unicodes.length===0&&(this.unicode=s),this.unicodes.push(s)},ie.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},ie.prototype.getPath=function(s,i,l,h,d){s=s!==void 0?s:0,i=i!==void 0?i:0,l=l!==void 0?l:72,h=Object.assign({},d&&d.defaultRenderOptions,h);let p,y,x=h.xScale,A=h.yScale,E=1/(this.path.unitsPerEm||1e3)*l,C=this;d&&d.variation&&(C=d.variation.getTransform(this,h.variation),p=C.path.commands),h.hinting&&d&&d.hinting&&(y=C.path&&d.hinting.exec(C,l,h)),y?(p=d.hinting.getCommands(y),s=Math.round(s),i=Math.round(i),x=A=1):(p=C.path.commands,x===void 0&&(x=E),A===void 0&&(A=E));let R=new it;if(h.drawSVG){let P=this.getSvgImage(d);if(P){let L=new it;return L._image={image:P.image,x:s+P.leftSideBearing*E,y:i-P.baseline*E,width:P.image.width*E,height:P.image.height*E},R._layers=[L],R}}if(h.drawLayers){let P=this.getLayers(d);if(P&&P.length){R._layers=[];for(let L=0;L<P.length;L+=1){let M=P[L],N=Mi(d,M.paletteIndex,h.usePalette);N==="currentColor"?N=h.fill||"black":N=Vn(N,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:N}),R._layers.push(this.getPath.call(M.glyph,s,i,l,h,d))}return R}}R.fill=h.fill||this.path.fill,R.stroke=this.path.stroke,R.strokeWidth=this.path.strokeWidth*E;for(let P=0;P<p.length;P+=1){let L=p[P];L.type==="M"?R.moveTo(s+L.x*x,i+-L.y*A):L.type==="L"?R.lineTo(s+L.x*x,i+-L.y*A):L.type==="Q"?R.quadraticCurveTo(s+L.x1*x,i+-L.y1*A,s+L.x*x,i+-L.y*A):L.type==="C"?R.curveTo(s+L.x1*x,i+-L.y1*A,s+L.x2*x,i+-L.y2*A,s+L.x*x,i+-L.y*A):L.type==="Z"&&R.stroke&&R.strokeWidth&&R.closePath()}return R},ie.prototype.getLayers=function(s){if(!s)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return s.layers.get(this.index)},ie.prototype.getSvgImage=function(s){if(!s)throw new Error("The font object is required to read the svg table in order to get the image.");return s.svgImages.get(this.index)},ie.prototype.getContours=function(s=null){if(this.points===void 0&&!s)return[];let i=[],l=[],h=s||this.points;for(let d=0;d<h.length;d+=1){let p=h[d];l.push(p),p.lastPointOfContour&&(i.push(l),l=[])}return U.argument(l.length===0,"There are still points left in the current contour."),i},ie.prototype.getMetrics=function(){let s=this.path.commands,i=[],l=[];for(let d=0;d<s.length;d+=1){let p=s[d];p.type!=="Z"&&(i.push(p.x),l.push(p.y)),(p.type==="Q"||p.type==="C")&&(i.push(p.x1),l.push(p.y1)),p.type==="C"&&(i.push(p.x2),l.push(p.y2))}let h={xMin:Math.min.apply(null,i),yMin:Math.min.apply(null,l),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,l),leftSideBearing:this.leftSideBearing};return isFinite(h.xMin)||(h.xMin=0),isFinite(h.xMax)||(h.xMax=this.advanceWidth),isFinite(h.yMin)||(h.yMin=0),isFinite(h.yMax)||(h.yMax=0),h.rightSideBearing=this.advanceWidth-h.leftSideBearing-(h.xMax-h.xMin),h},ie.prototype.draw=function(s,i,l,h,d,p){d=Object.assign({},p&&p.defaultRenderOptions,d),this.getPath(i,l,h,d,p).draw(s)},ie.prototype.drawPoints=function(s,i,l,h,d,p){if(d=Object.assign({},p&&p.defaultRenderOptions,d),d.drawLayers){let P=this.getLayers(p);if(P&&P.length){for(let L=0;L<P.length;L+=1)P[L].glyph.index!==this.index&&this.drawPoints.call(P[L].glyph,s,i,l,h);return}}function y(P,L,M,N){s.beginPath();for(let z=0;z<P.length;z+=1)s.moveTo(L+P[z].x*N,M+P[z].y*N),s.arc(L+P[z].x*N,M+P[z].y*N,2,0,Math.PI*2,!1);s.fill()}i=i!==void 0?i:0,l=l!==void 0?l:0,h=h!==void 0?h:24;let x=1/this.path.unitsPerEm*h,A=[],E=[],R=this.path.commands;p&&p.variation&&(R=p.variation.getTransform(this,d.variation).path.commands);for(let P=0;P<R.length;P+=1){let L=R[P];L.x!==void 0&&A.push({x:L.x,y:-L.y}),L.x1!==void 0&&E.push({x:L.x1,y:-L.y1}),L.x2!==void 0&&E.push({x:L.x2,y:-L.y2})}s.fillStyle="blue",y(A,i,l,x),s.fillStyle="red",y(E,i,l,x)},ie.prototype.drawMetrics=function(s,i,l,h){let d;i=i!==void 0?i:0,l=l!==void 0?l:0,h=h!==void 0?h:24,d=1/this.path.unitsPerEm*h,s.lineWidth=1,s.strokeStyle="black",Tn.line(s,i,-1e4,i,1e4),Tn.line(s,-1e4,l,1e4,l);let p=this.xMin||0,y=this.yMin||0,x=this.xMax||0,A=this.yMax||0,E=this.advanceWidth||0;s.strokeStyle="blue",Tn.line(s,i+p*d,-1e4,i+p*d,1e4),Tn.line(s,i+x*d,-1e4,i+x*d,1e4),Tn.line(s,-1e4,l+-y*d,1e4,l+-y*d),Tn.line(s,-1e4,l+-A*d,1e4,l+-A*d),s.strokeStyle="green",Tn.line(s,i+E*d,-1e4,i+E*d,1e4)},ie.prototype.toPathData=function(s,i){s=Object.assign({},{variation:i&&i.defaultRenderOptions.variation},s);let l=this;i&&i.variation&&(l=i.variation.getTransform(this,s.variation));let h=l.points&&s.pointsTransform?s.pointsTransform(l.points):l.path;return s.pathTransform&&(h=s.pathTransform(h)),h.toPathData(s)},ie.prototype.fromSVG=function(s,i={}){return this.path.fromSVG(s,i)},ie.prototype.toSVG=function(s,i){let l=this.toPathData.apply(this,[s,i]);return this.path.toSVG(s,l)},ie.prototype.toDOMElement=function(s,i){s=Object.assign({},{variation:i&&i.defaultRenderOptions.variation},s);let l=this.path;return i&&i.variation&&(l=i.variation.getTransform(this,s.variation).path),l.toDOMElement(s)};var $n=ie;function zn(s,i,l){Object.defineProperty(s,i,{get:function(){return typeof s[l]>"u"&&s.path,s[l]},set:function(h){s[l]=h},enumerable:!0,configurable:!0})}function qs(s,i){if(this.font=s,this.glyphs={},Array.isArray(i))for(let l=0;l<i.length;l++){let h=i[l];h.path.unitsPerEm=s.unitsPerEm,this.glyphs[l]=h}this.length=i&&i.length||0}typeof Symbol<"u"&&Symbol.iterator&&(qs.prototype[Symbol.iterator]=function(){let s=-1;return{next:function(){s++;let i=s>=this.length-1;return{value:this.get(s),done:i}}.bind(this)}}),qs.prototype.get=function(s){if(this.font._push&&this.glyphs[s]===void 0){this.font._push(s),typeof this.glyphs[s]=="function"&&(this.glyphs[s]=this.glyphs[s]());let i=this.glyphs[s],l=this.font._IndexToUnicodeMap[s];if(l)for(let h=0;h<l.unicodes.length;h++)i.addUnicode(l.unicodes[h]);this.font.cffEncoding?i.name=this.font.cffEncoding.charset[s]:this.font.glyphNames.names&&(i.name=this.font.glyphNames.glyphIndexToName(s)),this.glyphs[s].advanceWidth=this.font._hmtxTableData[s].advanceWidth,this.glyphs[s].leftSideBearing=this.font._hmtxTableData[s].leftSideBearing}else typeof this.glyphs[s]=="function"&&(this.glyphs[s]=this.glyphs[s]());return this.glyphs[s]},qs.prototype.push=function(s,i){this.glyphs[s]=i,this.length++};function Md(s,i){return new $n({index:i,font:s})}function Ld(s,i,l,h,d,p){return function(){let y=new $n({index:i,font:s});return y.path=function(){l(y,h,d);let x=p(s.glyphs,y);return x.unitsPerEm=s.unitsPerEm,x},zn(y,"numberOfContours","_numberOfContours"),zn(y,"xMin","_xMin"),zn(y,"xMax","_xMax"),zn(y,"yMin","_yMin"),zn(y,"yMax","_yMax"),zn(y,"points","_points"),y}}function Fd(s,i,l,h,d){return function(){let p=new $n({index:i,font:s});return p.path=function(){let y=l(s,p,h,d);return y.unitsPerEm=s.unitsPerEm,y},p}}var $e={GlyphSet:qs,glyphLoader:Md,ttfGlyphLoader:Ld,cffGlyphLoader:Fd};function El(s,i){if(s===i)return!0;if(Array.isArray(s)&&Array.isArray(i)){if(s.length!==i.length)return!1;for(let l=0;l<s.length;l+=1)if(!El(s[l],i[l]))return!1;return!0}else return!1}var kl=10;function tr(s){let i;return s.length<1240?i=107:s.length<33900?i=1131:i=32768,i}function ze(s,i,l,h){let d=[],p=[],y=h>1?rt.getULong(s,i):rt.getCard16(s,i),x=h>1?4:2,A,E;if(y!==0){let C=rt.getByte(s,i+x);A=i+(y+1)*C+x;let R=i+x+1;for(let P=0;P<y+1;P+=1)d.push(rt.getOffset(s,R,C)),R+=C;E=A+d[y]}else E=i+x;for(let C=0;C<d.length-1;C+=1){let R=rt.getBytes(s,A+d[C],A+d[C+1]);l&&(R=l(R,s,i,h)),p.push(R)}return{objects:p,startOffset:i,endOffset:E}}function Dd(s,i,l){let h=[],d=l>1?rt.getULong(s,i):rt.getCard16(s,i),p=l>1?4:2,y,x;if(d!==0){let A=rt.getByte(s,i+p);y=i+(d+1)*A+p;let E=i+p+1;for(let C=0;C<d+1;C+=1)h.push(rt.getOffset(s,E,A)),E+=A;x=y+h[d]}else x=i+p;return{offsets:h,startOffset:i,endOffset:x}}function _d(s,i,l,h,d,p){let y=p>1?rt.getULong(l,h):rt.getCard16(l,h),x=p>1?4:2,A=0;if(y!==0){let C=rt.getByte(l,h+x);A=h+(y+1)*C+x}let E=rt.getBytes(l,A+i[s],A+i[s+1]);return d&&(E=d(E)),E}function Nd(s){let i="",h=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let d=s.parseByte(),p=d>>4,y=d&15;if(p===15||(i+=h[p],y===15))break;i+=h[y]}return parseFloat(i)}function Ud(s,i){let l,h,d,p;if(i===28)return l=s.parseByte(),h=s.parseByte(),l<<8|h;if(i===29)return l=s.parseByte(),h=s.parseByte(),d=s.parseByte(),p=s.parseByte(),l<<24|h<<16|d<<8|p;if(i===30)return Nd(s);if(i>=32&&i<=246)return i-139;if(i>=247&&i<=250)return l=s.parseByte(),(i-247)*256+l+108;if(i>=251&&i<=254)return l=s.parseByte(),-(i-251)*256-l-108;throw new Error("Invalid b0 "+i)}function Bd(s){let i={};for(let l=0;l<s.length;l+=1){let h=s[l][0],d=s[l][1],p;if(d.length===1?p=d[0]:p=d,Object.prototype.hasOwnProperty.call(i,h)&&!isNaN(i[h]))throw new Error("Object "+i+" already has key "+h);i[h]=p}return i}function Li(s,i,l,h){i=i!==void 0?i:0;let d=new rt.Parser(s,i),p=[],y=[];l=l!==void 0?l:s.byteLength;let x=h<2?22:28;for(;d.relativeOffset<l;){let A=d.parseByte();if(A<x){if(A===12&&(A=1200+d.parseByte()),h>1&&A===23){Xd(y);continue}p.push([A,y]),y=[]}else y.push(Ud(d,A,h))}return Bd(p)}function rs(s,i){return i<=390?i=Qs[i]:s?i=s[i-391]:i=void 0,i}function Fi(s,i,l){let h={},d;for(let p=0;p<i.length;p+=1){let y=i[p];if(Array.isArray(y.type)){let x=[];x.length=y.type.length;for(let A=0;A<y.type.length;A++)d=s[y.op]!==void 0?s[y.op][A]:void 0,d===void 0&&(d=y.value!==void 0&&y.value[A]!==void 0?y.value[A]:null),y.type[A]==="SID"&&(d=rs(l,d)),x[A]=d;h[y.name]=x}else d=s[y.op],d===void 0&&(d=y.value!==void 0?y.value:null),y.type==="SID"&&(d=rs(l,d)),h[y.name]=d}return h}function Gd(s,i){let l={};if(l.formatMajor=rt.getCard8(s,i),l.formatMinor=rt.getCard8(s,i+1),l.formatMajor>2)throw new Error(`Unsupported CFF table version ${l.formatMajor}.${l.formatMinor}`);return l.size=rt.getCard8(s,i+2),l.formatMajor<2?(l.offsetSize=rt.getCard8(s,i+3),l.startOffset=i,l.endOffset=i+4):(l.topDictLength=rt.getCard16(s,i+3),l.endOffset=i+8),l}var Il=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Pl=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],Rl=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Ol=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],Hd=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function jd(s,i,l,h){let d=Li(s,i,s.byteLength,h);return Fi(d,h>1?Pl:Il,l)}function Di(s,i,l,h,d){let p=Li(s,i,l,d);return Fi(p,d>1?Ol:Rl,h)}function Vd(s,i,l){let h=Li(s,i,void 0,l);return Fi(h,Hd)}function $d(s,i,l){let h=[];for(let d=0;d<l.length;d++){let p=new DataView(new Uint8Array(l[d]).buffer),y=Vd(p,0,2),x=y.private[0],A=y.private[1];if(x!==0&&A!==0){let E=Di(s,A+i,x,[],2);if(E.subrs){let C=A+E.subrs,R=ze(s,C+i,void 0,2);y._subrs=R.objects,y._subrsBias=tr(y._subrs)}y._privateDict=E}h.push(y)}return h}function _i(s,i,l,h,d){let p=[];for(let y=0;y<l.length;y+=1){let x=new DataView(new Uint8Array(l[y]).buffer),A=jd(x,0,h,d);A._subrs=[],A._subrsBias=0,A._defaultWidthX=0,A._nominalWidthX=0;let E=d<2?A.private[0]:0,C=d<2?A.private[1]:0;if(E!==0&&C!==0){let R=Di(s,C+i,E,h,d);if(A._defaultWidthX=R.defaultWidthX,A._nominalWidthX=R.nominalWidthX,R.subrs!==0){let P=C+R.subrs,L=ze(s,P+i,void 0,d);A._subrs=L.objects,A._subrsBias=tr(A._subrs)}A._privateDict=R}p.push(A)}return p}function zd(s,i,l,h,d){let p,y,x=new rt.Parser(s,i);l-=1;let A=[".notdef"],E=x.parseCard8();if(E===0)for(let C=0;C<l;C+=1)p=x.parseSID(),d?A.push(p):A.push(rs(h,p)||p);else if(E===1)for(;A.length<=l;){p=x.parseSID(),y=x.parseCard8();for(let C=0;C<=y;C+=1)d?A.push("cid"+("00000"+p).slice(-5)):A.push(rs(h,p)||p),p+=1}else if(E===2)for(;A.length<=l;){p=x.parseSID(),y=x.parseCard16();for(let C=0;C<=y;C+=1)d?A.push("cid"+("00000"+p).slice(-5)):A.push(rs(h,p)||p),p+=1}else throw new Error("Unknown charset format "+E);return A}function Wd(s,i){let l,h={},d=new rt.Parser(s,i),p=d.parseCard8();if(p===0){let y=d.parseCard8();for(let x=0;x<y;x+=1)l=d.parseCard8(),h[l]=x}else if(p===1){let y=d.parseCard8();l=1;for(let x=0;x<y;x+=1){let A=d.parseCard8(),E=d.parseCard8();for(let C=A;C<=A+E;C+=1)h[C]=l,l+=1}}else throw new Error("Unknown encoding format "+p);return h}function Xd(s){let i=s.pop();for(;s.length>i;)s.pop()}function Ml(s,i){let l=s.tables.cff&&s.tables.cff.topDict&&s.tables.cff.topDict.paintType||0;return l===2&&(i.fill=null,i.stroke="black",i.strokeWidth=s.tables.cff.topDict.strokeWidth||0),l}function Ni(s,i,l,h,d){let p,y,x,A,E=new it,C=[],R=0,P=!1,L=!1,M=0,N=0,z,vt,pt,At,It=0,Nt=[],Bt,Gt=0,Jt=s.tables.cff2||s.tables.cff;if(pt=Jt.topDict._defaultWidthX,At=Jt.topDict._nominalWidthX,d=d||s.variation&&s.variation.get(),i.getBlendPath||(i.getBlendPath=function(ct){return Ni(s,i,l,h,ct)}),s.isCIDFont||h>1){let ct=Jt.topDict._fdSelect?Jt.topDict._fdSelect[i.index]:0,ft=Jt.topDict._fdArray[ct];z=ft._subrs,vt=ft._subrsBias,h>1?(Nt=Jt.topDict._vstore.itemVariationStore,It=ft._privateDict.vsindex):(pt=ft._defaultWidthX,At=ft._nominalWidthX)}else z=Jt.topDict._subrs,vt=Jt.topDict._subrsBias;let Ne=Ml(s,E),Pt=pt;function Te(ct,ft){L&&Ne!==2&&E.closePath(),E.moveTo(ct,ft),L=!0}function de(){let ct;ct=(C.length&1)!==0,ct&&!P&&(Pt=C.shift()+At),R+=C.length>>1,C.length=0,P=!0}function xt(ct){let ft,oe,fn,ur,kn,Ue,fe,Ie,ae,Ce,pe,ge,Zt=0;for(;Zt<ct.length;){let Re=ct[Zt];switch(Zt+=1,Re){case 1:de();break;case 3:de();break;case 4:C.length>1&&!P&&(Pt=C.shift()+At,P=!0),N+=C.pop(),Te(M,N);break;case 5:for(;C.length>0;)M+=C.shift(),N+=C.shift(),E.lineTo(M,N);break;case 6:for(;C.length>0&&(M+=C.shift(),E.lineTo(M,N),C.length!==0);)N+=C.shift(),E.lineTo(M,N);break;case 7:for(;C.length>0&&(N+=C.shift(),E.lineTo(M,N),C.length!==0);)M+=C.shift(),E.lineTo(M,N);break;case 8:for(;C.length>0;)p=M+C.shift(),y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),M=x+C.shift(),N=A+C.shift(),E.curveTo(p,y,x,A,M,N);break;case 10:if(kn=C.pop()+vt,Ue=z[kn],Ue){if(Gt>=kl){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Gt++,xt(Ue),Gt--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Re=ct[Zt],Zt+=1,Re){case 35:p=M+C.shift(),y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),fe=x+C.shift(),Ie=A+C.shift(),ae=fe+C.shift(),Ce=Ie+C.shift(),pe=ae+C.shift(),ge=Ce+C.shift(),M=pe+C.shift(),N=ge+C.shift(),C.shift(),E.curveTo(p,y,x,A,fe,Ie),E.curveTo(ae,Ce,pe,ge,M,N);break;case 34:p=M+C.shift(),y=N,x=p+C.shift(),A=y+C.shift(),fe=x+C.shift(),Ie=A,ae=fe+C.shift(),Ce=A,pe=ae+C.shift(),ge=N,M=pe+C.shift(),E.curveTo(p,y,x,A,fe,Ie),E.curveTo(ae,Ce,pe,ge,M,N);break;case 36:p=M+C.shift(),y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),fe=x+C.shift(),Ie=A,ae=fe+C.shift(),Ce=A,pe=ae+C.shift(),ge=Ce+C.shift(),M=pe+C.shift(),E.curveTo(p,y,x,A,fe,Ie),E.curveTo(ae,Ce,pe,ge,M,N);break;case 37:p=M+C.shift(),y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),fe=x+C.shift(),Ie=A+C.shift(),ae=fe+C.shift(),Ce=Ie+C.shift(),pe=ae+C.shift(),ge=Ce+C.shift(),Math.abs(pe-M)>Math.abs(ge-N)?M=pe+C.shift():N=ge+C.shift(),E.curveTo(p,y,x,A,fe,Ie),E.curveTo(ae,Ce,pe,ge,M,N);break;default:console.log("Glyph "+i.index+": unknown operator 1200"+Re),C.length=0}break;case 14:if(h>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(C.length>=4){let In=Ri[C.pop()],Kn=Ri[C.pop()],hr=C.pop(),dr=C.pop();if(In&&Kn){i.isComposite=!0,i.components=[];let Xc=s.cffEncoding.charset.indexOf(In),Yc=s.cffEncoding.charset.indexOf(Kn);i.components.push({glyphIndex:Yc,dx:0,dy:0}),i.components.push({glyphIndex:Xc,dx:dr,dy:hr}),E.extend(s.glyphs.get(Yc).path);let Ob=s.glyphs.get(Xc),eo=JSON.parse(JSON.stringify(Ob.path.commands));for(let no=0;no<eo.length;no+=1){let Xe=eo[no];Xe.type!=="Z"&&(Xe.x+=dr,Xe.y+=hr),(Xe.type==="Q"||Xe.type==="C")&&(Xe.x1+=dr,Xe.y1+=hr),Xe.type==="C"&&(Xe.x2+=dr,Xe.y2+=hr)}E.extend(eo)}}else C.length>0&&!P&&(Pt=C.shift()+At,P=!0);L&&Ne!==2&&(E.closePath(),L=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}It=C.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}Bt||(Bt=s.variation&&d&&s.variation.process.getBlendVector(Nt,It,d));var Vt=C.pop(),be=Bt?Bt.length:Nt.itemVariationSubtables[It].regionIndexes.length,Pe=Vt*be,Be=C.length-Pe,en=Be-Vt;if(Bt)for(let In=0;In<Vt;In++){var Wc=C[en+In];for(let Kn=0;Kn<be;Kn++)Wc+=Bt[Kn]*C[Be++];C[en+In]=Wc}for(;Pe--;)C.pop();break;case 18:de();break;case 19:case 20:de(),Zt+=R+7>>3;break;case 21:C.length>2&&!P&&(Pt=C.shift()+At,P=!0),N+=C.pop(),M+=C.pop(),Te(M,N);break;case 22:C.length>1&&!P&&(Pt=C.shift()+At,P=!0),M+=C.pop(),Te(M,N);break;case 23:de();break;case 24:for(;C.length>2;)p=M+C.shift(),y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),M=x+C.shift(),N=A+C.shift(),E.curveTo(p,y,x,A,M,N);M+=C.shift(),N+=C.shift(),E.lineTo(M,N);break;case 25:for(;C.length>6;)M+=C.shift(),N+=C.shift(),E.lineTo(M,N);p=M+C.shift(),y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),M=x+C.shift(),N=A+C.shift(),E.curveTo(p,y,x,A,M,N);break;case 26:for(C.length&1&&(M+=C.shift());C.length>0;)p=M,y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),M=x,N=A+C.shift(),E.curveTo(p,y,x,A,M,N);break;case 27:for(C.length&1&&(N+=C.shift());C.length>0;)p=M+C.shift(),y=N,x=p+C.shift(),A=y+C.shift(),M=x+C.shift(),N=A,E.curveTo(p,y,x,A,M,N);break;case 28:ft=ct[Zt],oe=ct[Zt+1],C.push((ft<<24|oe<<16)>>16),Zt+=2;break;case 29:if(kn=C.pop()+s.gsubrsBias,Ue=s.gsubrs[kn],Ue){if(Gt>=kl){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Gt++,xt(Ue),Gt--}break;case 30:for(;C.length>0&&(p=M,y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),M=x+C.shift(),N=A+(C.length===1?C.shift():0),E.curveTo(p,y,x,A,M,N),C.length!==0);)p=M+C.shift(),y=N,x=p+C.shift(),A=y+C.shift(),N=A+C.shift(),M=x+(C.length===1?C.shift():0),E.curveTo(p,y,x,A,M,N);break;case 31:for(;C.length>0&&(p=M+C.shift(),y=N,x=p+C.shift(),A=y+C.shift(),N=A+C.shift(),M=x+(C.length===1?C.shift():0),E.curveTo(p,y,x,A,M,N),C.length!==0);)p=M,y=N+C.shift(),x=p+C.shift(),A=y+C.shift(),M=x+C.shift(),N=A+(C.length===1?C.shift():0),E.curveTo(p,y,x,A,M,N);break;default:Re<32?console.log("Glyph "+i.index+": unknown operator "+Re):Re<247?C.push(Re-139):Re<251?(ft=ct[Zt],Zt+=1,C.push((Re-247)*256+ft+108)):Re<255?(ft=ct[Zt],Zt+=1,C.push(-(Re-251)*256-ft-108)):(ft=ct[Zt],oe=ct[Zt+1],fn=ct[Zt+2],ur=ct[Zt+3],Zt+=4,C.push((ft<<24|oe<<16|fn<<8|ur)/65536))}}}return xt(l),s.variation&&d&&(E.commands=E.commands.map(ct=>{let ft=Object.keys(ct);for(let oe=0;oe<ft.length;oe++){let fn=ft[oe];fn!=="type"&&(ct[fn]=Math.round(ct[fn]))}return ct})),P&&(i.advanceWidth=Pt),E}function Ll(s,i,l,h,d){let p=[],y,x=new rt.Parser(s,i),A=x.parseCard8();if(A===0)for(let E=0;E<l;E++){if(y=x.parseCard8(),y>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+y+" (FD count "+h+")");p.push(y)}else if(A===3||d>1&&A===4){let E=A===4?x.parseULong():x.parseCard16(),C=A===4?x.parseULong():x.parseCard16();if(C!==0)throw new Error(`CFF Table CID Font FDSelect format ${A} range has bad initial GID ${C}`);let R;for(let P=0;P<E;P++){if(y=A===4?x.parseUShort():x.parseCard8(),R=A===4?x.parseULong():x.parseCard16(),y>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+y+" (FD count "+h+")");if(R>l)throw new Error(`CFF Table CID Font FDSelect format ${d} range has bad GID ${R}`);for(;C<R;C++)p.push(y);C=R}if(R!==l)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+R)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+A);return p}function Yd(s,i,l,h){let d,p=Gd(s,i);p.formatMajor===2?d=l.tables.cff2={}:d=l.tables.cff={};let y=p.formatMajor>1?null:ze(s,p.endOffset,rt.bytesToString),x=p.formatMajor>1?null:ze(s,y.endOffset),A=p.formatMajor>1?null:ze(s,x.endOffset,rt.bytesToString),E=ze(s,p.formatMajor>1?i+p.size+p.topDictLength:A.endOffset,void 0,p.formatMajor);l.gsubrs=E.objects,l.gsubrsBias=tr(l.gsubrs);let C;if(p.formatMajor>1){let P=i+p.size,L=rt.getBytes(s,P,P+p.topDictLength);C=_i(s,0,[L],void 0,p.formatMajor)[0]}else{let P=_i(s,i,x.objects,A.objects,p.formatMajor);if(P.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+P.length);C=P[0]}if(d.topDict=C,C._privateDict&&(l.defaultWidthX=C._privateDict.defaultWidthX,l.nominalWidthX=C._privateDict.nominalWidthX),p.formatMajor<2&&C.ros[0]!==void 0&&C.ros[1]!==void 0&&(l.isCIDFont=!0),p.formatMajor>1){let P=C.fdArray,L=C.fdSelect;if(!P)throw new Error("This is a CFF2 font, but FDArray information is missing");let M=ze(s,i+P,null,p.formatMajor),N=$d(s,i,M.objects);C._fdArray=N,L&&(C._fdSelect=Ll(s,i+L,l.numGlyphs,N.length,p.formatMajor))}else if(l.isCIDFont){let P=C.fdArray,L=C.fdSelect;if(P===0||L===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");P+=i;let M=ze(s,P),N=_i(s,i,M.objects,A.objects,p.formatMajor);C._fdArray=N,L+=i,C._fdSelect=Ll(s,L,l.numGlyphs,N.length,p.formatMajor)}if(p.formatMajor<2){let P=i+C.private[1],L=Di(s,P,C.private[0],A.objects,p.formatMajor);if(l.defaultWidthX=L.defaultWidthX,l.nominalWidthX=L.nominalWidthX,L.subrs!==0){let M=P+L.subrs,N=ze(s,M);l.subrs=N.objects,l.subrsBias=tr(l.subrs)}else l.subrs=[],l.subrsBias=0}let R;if(h.lowMemory?(R=Dd(s,i+C.charStrings,p.formatMajor),l.nGlyphs=R.offsets.length-(p.formatMajor>1?1:0)):(R=ze(s,i+C.charStrings,null,p.formatMajor),l.nGlyphs=R.objects.length),p.formatMajor>1&&l.tables.maxp&&l.nGlyphs!==l.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${l.nGlyphs}) must correspond to the glyph count in the maxp table (${l.tables.maxp.numGlyphs})`),p.formatMajor<2){let P=[],L=[];C.charset===0?P=vd:C.charset===1?P=xd:C.charset===2?P=Sd:P=zd(s,i+C.charset,l.nGlyphs,A.objects,l.isCIDFont),C.encoding===0?L=Ri:C.encoding===1?L=Ad:L=Wd(s,i+C.encoding),l.cffEncoding=new Al(L,P),l.encoding=l.encoding||l.cffEncoding}if(l.glyphs=new $e.GlyphSet(l),h.lowMemory)l._push=function(P){let L=_d(P,R.offsets,s,i+C.charStrings,void 0,p.formatMajor);l.glyphs.push(P,$e.cffGlyphLoader(l,P,Ni,L,p.formatMajor))};else for(let P=0;P<l.nGlyphs;P+=1){let L=R.objects[P];l.glyphs.push(P,$e.cffGlyphLoader(l,P,Ni,L,p.formatMajor))}if(C.vstore){let P=new rt.Parser(s,i+C.vstore);C._vstore=P.parseVariationStore()}}function Fl(s,i){let l,h=Qs.indexOf(s);return h>=0&&(l=h),h=i.indexOf(s),h>=0?l=h+Qs.length:(l=Qs.length+i.length,i.push(s)),l}function Kd(){return new J.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function Zd(s){let i=new J.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);i.names=[];for(let l=0;l<s.length;l+=1)i.names.push({name:"name_"+l,type:"NAME",value:s[l]});return i}function Dl(s,i,l){let h={};for(let d=0;d<s.length;d+=1){let p=s[d],y=i[p.name];y!==void 0&&!El(y,p.value)&&(p.type==="SID"&&(y=Fl(y,l)),h[p.op]={name:p.name,type:p.type,value:y})}return h}function _l(s,i,l){let h=new J.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=Dl(l>1?Pl:Il,s,i),h}function Nl(s){let i=new J.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return i.topDicts=[{name:"topDict_0",type:"TABLE",value:s}],i}function Qd(s){let i=new J.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);i.strings=[];for(let l=0;l<s.length;l+=1)i.strings.push({name:"string_"+l,type:"STRING",value:s[l]});return i}function Jd(){return new J.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function qd(s,i){let l=new J.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let h=0;h<s.length;h+=1){let d=s[h],p=Fl(d,i);l.fields.push({name:"glyph_"+h,type:"SID",value:p})}return l}function tf(s,i){let l=[],h=s.path;i<2&&l.push({name:"width",type:"NUMBER",value:s.advanceWidth});let d=0,p=0;for(let y=0;y<h.commands.length;y+=1){let x,A,E=h.commands[y];if(E.type==="Q"){let C=.3333333333333333,R=2/3;E={type:"C",x:E.x,y:E.y,x1:Math.round(C*d+R*E.x1),y1:Math.round(C*p+R*E.y1),x2:Math.round(C*E.x+R*E.x1),y2:Math.round(C*E.y+R*E.y1)}}if(E.type==="M")x=Math.round(E.x-d),A=Math.round(E.y-p),l.push({name:"dx",type:"NUMBER",value:x}),l.push({name:"dy",type:"NUMBER",value:A}),l.push({name:"rmoveto",type:"OP",value:21}),d=Math.round(E.x),p=Math.round(E.y);else if(E.type==="L")x=Math.round(E.x-d),A=Math.round(E.y-p),l.push({name:"dx",type:"NUMBER",value:x}),l.push({name:"dy",type:"NUMBER",value:A}),l.push({name:"rlineto",type:"OP",value:5}),d=Math.round(E.x),p=Math.round(E.y);else if(E.type==="C"){let C=Math.round(E.x1-d),R=Math.round(E.y1-p),P=Math.round(E.x2-E.x1),L=Math.round(E.y2-E.y1);x=Math.round(E.x-E.x2),A=Math.round(E.y-E.y2),l.push({name:"dx1",type:"NUMBER",value:C}),l.push({name:"dy1",type:"NUMBER",value:R}),l.push({name:"dx2",type:"NUMBER",value:P}),l.push({name:"dy2",type:"NUMBER",value:L}),l.push({name:"dx",type:"NUMBER",value:x}),l.push({name:"dy",type:"NUMBER",value:A}),l.push({name:"rrcurveto",type:"OP",value:8}),d=Math.round(E.x),p=Math.round(E.y)}}return i<2&&l.push({name:"endchar",type:"OP",value:14}),l}function ef(s,i){let l=new J.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let h=0;h<s.length;h+=1){let d=s.get(h),p=tf(d,i);l.charStrings.push({name:d.name,type:"CHARSTRING",value:p})}return l}function nf(s,i,l){let h=new J.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=Dl(l>1?Ol:Rl,s,i),h}function sf(s,i){let h=new J.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),d=1/i.unitsPerEm,p={version:i.version,fullName:i.fullName,familyName:i.familyName,weight:i.weightName,fontBBox:i.fontBBox||[0,0,0,0],fontMatrix:[d,0,0,d,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},y=i&&i.topDict||{};y.paintType&&(p.paintType=y.paintType,p.strokeWidth=y.strokeWidth||0);let x={},A=[],E;for(let L=1;L<s.length;L+=1)E=s.get(L),A.push(E.name);let C=[];h.header=Kd(),h.nameIndex=Zd([i.postScriptName]);let R=_l(p,C);h.topDictIndex=Nl(R),h.globalSubrIndex=Jd(),h.charsets=qd(A,C),h.charStringsIndex=ef(s,1),h.privateDict=nf(x,C),h.stringIndex=Qd(C);let P=h.header.sizeOf()+h.nameIndex.sizeOf()+h.topDictIndex.sizeOf()+h.stringIndex.sizeOf()+h.globalSubrIndex.sizeOf();return p.charset=P,p.encoding=0,p.charStrings=p.charset+h.charsets.sizeOf(),p.private[1]=p.charStrings+h.charStringsIndex.sizeOf(),R=_l(p,C),h.topDictIndex=Nl(R),h}var Ui={parse:Yd,make:sf};function rf(s,i){let l={},h=new rt.Parser(s,i);return l.version=h.parseVersion(),l.fontRevision=Math.round(h.parseFixed()*1e3)/1e3,l.checkSumAdjustment=h.parseULong(),l.magicNumber=h.parseULong(),U.argument(l.magicNumber===1594834165,"Font header has wrong magic number."),l.flags=h.parseUShort(),l.unitsPerEm=h.parseUShort(),l.created=h.parseLongDateTime(),l.modified=h.parseLongDateTime(),l.xMin=h.parseShort(),l.yMin=h.parseShort(),l.xMax=h.parseShort(),l.yMax=h.parseShort(),l.macStyle=h.parseUShort(),l.lowestRecPPEM=h.parseUShort(),l.fontDirectionHint=h.parseShort(),l.indexToLocFormat=h.parseShort(),l.glyphDataFormat=h.parseShort(),l}function of(s){let i=Math.round(new Date().getTime()/1e3)+2082844800,l=i,h=s.macStyle||0;return s.createdTimestamp&&(l=s.createdTimestamp+2082844800),new J.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:l},{name:"modified",type:"LONGDATETIME",value:i},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:h},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],s)}var Ul={parse:rf,make:of};function af(s,i){let l={},h=new rt.Parser(s,i);return l.version=h.parseVersion(),l.ascender=h.parseShort(),l.descender=h.parseShort(),l.lineGap=h.parseShort(),l.advanceWidthMax=h.parseUShort(),l.minLeftSideBearing=h.parseShort(),l.minRightSideBearing=h.parseShort(),l.xMaxExtent=h.parseShort(),l.caretSlopeRise=h.parseShort(),l.caretSlopeRun=h.parseShort(),l.caretOffset=h.parseShort(),h.relativeOffset+=8,l.metricDataFormat=h.parseShort(),l.numberOfHMetrics=h.parseUShort(),l}function lf(s){return new J.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],s)}var Bl={parse:af,make:lf};function cf(s,i,l,h,d){let p,y,x=new rt.Parser(s,i);for(let A=0;A<h;A+=1){A<l&&(p=x.parseUShort(),y=x.parseShort());let E=d.get(A);E.advanceWidth=p,E.leftSideBearing=y}}function uf(s,i,l,h,d){s._hmtxTableData={};let p,y,x=new rt.Parser(i,l);for(let A=0;A<d;A+=1)A<h&&(p=x.parseUShort(),y=x.parseShort()),s._hmtxTableData[A]={advanceWidth:p,leftSideBearing:y}}function hf(s,i,l,h,d,p,y){y.lowMemory?uf(s,i,l,h,d):cf(i,l,h,d,p)}function df(s){let i=new J.Table("hmtx",[]);for(let l=0;l<s.length;l+=1){let h=s.get(l),d=h.advanceWidth||0,p=h.leftSideBearing||0;i.fields.push({name:"advanceWidth_"+l,type:"USHORT",value:d}),i.fields.push({name:"leftSideBearing_"+l,type:"SHORT",value:p})}return i}var Gl={parse:hf,make:df};function ff(s){let i=new J.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:s.length}]),l="",h=12+s.length*4;for(let d=0;d<s.length;++d){let p=l.indexOf(s[d]);p<0&&(p=l.length,l+=s[d]),i.fields.push({name:"offset "+d,type:"USHORT",value:h+p}),i.fields.push({name:"length "+d,type:"USHORT",value:s[d].length})}return i.fields.push({name:"stringPool",type:"CHARARRAY",value:l}),i}function pf(s,i){let l=new rt.Parser(s,i),h=l.parseULong();U.argument(h===1,"Unsupported ltag table version."),l.skip("uLong",1);let d=l.parseULong(),p=[];for(let y=0;y<d;y++){let x="",A=i+l.parseUShort(),E=l.parseUShort();for(let C=A;C<A+E;++C)x+=String.fromCharCode(s.getInt8(C));p.push(x)}return p}var Hl={make:ff,parse:pf};function gf(s,i){let l={},h=new rt.Parser(s,i);return l.version=h.parseVersion(),l.numGlyphs=h.parseUShort(),l.version===1&&(l.maxPoints=h.parseUShort(),l.maxContours=h.parseUShort(),l.maxCompositePoints=h.parseUShort(),l.maxCompositeContours=h.parseUShort(),l.maxZones=h.parseUShort(),l.maxTwilightPoints=h.parseUShort(),l.maxStorage=h.parseUShort(),l.maxFunctionDefs=h.parseUShort(),l.maxInstructionDefs=h.parseUShort(),l.maxStackElements=h.parseUShort(),l.maxSizeOfInstructions=h.parseUShort(),l.maxComponentElements=h.parseUShort(),l.maxComponentDepth=h.parseUShort()),l}function mf(s){return new J.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:s}])}var jl={parse:gf,make:mf},Bi=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function bf(s){for(let i=0;i<Bi.length;i+=1){let l=Bi[i];if(s>=l.begin&&s<l.end)return i}return-1}function yf(s,i){let l={},h=new rt.Parser(s,i);l.version=h.parseUShort(),l.xAvgCharWidth=h.parseShort(),l.usWeightClass=h.parseUShort(),l.usWidthClass=h.parseUShort(),l.fsType=h.parseUShort(),l.ySubscriptXSize=h.parseShort(),l.ySubscriptYSize=h.parseShort(),l.ySubscriptXOffset=h.parseShort(),l.ySubscriptYOffset=h.parseShort(),l.ySuperscriptXSize=h.parseShort(),l.ySuperscriptYSize=h.parseShort(),l.ySuperscriptXOffset=h.parseShort(),l.ySuperscriptYOffset=h.parseShort(),l.yStrikeoutSize=h.parseShort(),l.yStrikeoutPosition=h.parseShort(),l.sFamilyClass=h.parseShort(),l.panose=[];for(let d=0;d<10;d++)l.panose[d]=h.parseByte();return l.ulUnicodeRange1=h.parseULong(),l.ulUnicodeRange2=h.parseULong(),l.ulUnicodeRange3=h.parseULong(),l.ulUnicodeRange4=h.parseULong(),l.achVendID=String.fromCharCode(h.parseByte(),h.parseByte(),h.parseByte(),h.parseByte()),l.fsSelection=h.parseUShort(),l.usFirstCharIndex=h.parseUShort(),l.usLastCharIndex=h.parseUShort(),l.sTypoAscender=h.parseShort(),l.sTypoDescender=h.parseShort(),l.sTypoLineGap=h.parseShort(),l.usWinAscent=h.parseUShort(),l.usWinDescent=h.parseUShort(),l.version>=1&&(l.ulCodePageRange1=h.parseULong(),l.ulCodePageRange2=h.parseULong()),l.version>=2&&(l.sxHeight=h.parseShort(),l.sCapHeight=h.parseShort(),l.usDefaultChar=h.parseUShort(),l.usBreakChar=h.parseUShort(),l.usMaxContent=h.parseUShort()),l}function vf(s){return new J.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],s)}var Gi={parse:yf,make:vf,unicodeRanges:Bi,getUnicodeRange:bf};function xf(s,i){let l={},h=new rt.Parser(s,i);switch(l.version=h.parseVersion(),l.italicAngle=h.parseFixed(),l.underlinePosition=h.parseShort(),l.underlineThickness=h.parseShort(),l.isFixedPitch=h.parseULong(),l.minMemType42=h.parseULong(),l.maxMemType42=h.parseULong(),l.minMemType1=h.parseULong(),l.maxMemType1=h.parseULong(),l.version){case 1:l.names=An.slice();break;case 2:l.numberOfGlyphs=h.parseUShort(),l.glyphNameIndex=new Array(l.numberOfGlyphs);for(let d=0;d<l.numberOfGlyphs;d++)l.glyphNameIndex[d]=h.parseUShort();l.names=[];for(let d=0;d<l.numberOfGlyphs;d++)if(l.glyphNameIndex[d]>=An.length){let p=h.parseChar();l.names.push(h.parseString(p))}break;case 2.5:l.numberOfGlyphs=h.parseUShort(),l.offset=new Array(l.numberOfGlyphs);for(let d=0;d<l.numberOfGlyphs;d++)l.offset[d]=h.parseChar();break}return l}function Sf(s){let{italicAngle:i=Math.round((s.italicAngle||0)*65536),underlinePosition:l=0,underlineThickness:h=0,isFixedPitch:d=0,minMemType42:p=0,maxMemType42:y=0,minMemType1:x=0,maxMemType1:A=0}=s.tables.post||{};return new J.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:i},{name:"underlinePosition",type:"FWORD",value:l},{name:"underlineThickness",type:"FWORD",value:h},{name:"isFixedPitch",type:"ULONG",value:d},{name:"minMemType42",type:"ULONG",value:p},{name:"maxMemType42",type:"ULONG",value:y},{name:"minMemType1",type:"ULONG",value:x},{name:"maxMemType1",type:"ULONG",value:A}])}var Vl={parse:xf,make:Sf},De=new Array(9);De[1]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{substFormat:1,coverage:this.parsePointer(B.coverage),deltaGlyphId:this.parseShort()};if(l===2)return{substFormat:2,coverage:this.parsePointer(B.coverage),substitute:this.parseOffset16List()};U.assert(!1,"0x"+i.toString(16)+": lookup type 1 format must be 1 or 2.")},De[2]=function(){let i=this.parseUShort();return U.argument(i===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(B.coverage),sequences:this.parseListOfLists()}},De[3]=function(){let i=this.parseUShort();return U.argument(i===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(B.coverage),alternateSets:this.parseListOfLists()}},De[4]=function(){let i=this.parseUShort();return U.argument(i===1,"GSUB ligature table identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(B.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Wn={sequenceIndex:B.uShort,lookupListIndex:B.uShort};De[5]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{substFormat:l,coverage:this.parsePointer(B.coverage),ruleSets:this.parseListOfLists(function(){let h=this.parseUShort(),d=this.parseUShort();return{input:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(d,Wn)}})};if(l===2)return{substFormat:l,coverage:this.parsePointer(B.coverage),classDef:this.parsePointer(B.classDef),classSets:this.parseListOfLists(function(){let h=this.parseUShort(),d=this.parseUShort();return{classes:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(d,Wn)}})};if(l===3){let h=this.parseUShort(),d=this.parseUShort();return{substFormat:l,coverages:this.parseList(h,B.pointer(B.coverage)),lookupRecords:this.parseRecordList(d,Wn)}}U.assert(!1,"0x"+i.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},De[6]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{substFormat:1,coverage:this.parsePointer(B.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Wn)}})};if(l===2)return{substFormat:2,coverage:this.parsePointer(B.coverage),backtrackClassDef:this.parsePointer(B.classDef),inputClassDef:this.parsePointer(B.classDef),lookaheadClassDef:this.parsePointer(B.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Wn)}})};if(l===3)return{substFormat:3,backtrackCoverage:this.parseList(B.pointer(B.coverage)),inputCoverage:this.parseList(B.pointer(B.coverage)),lookaheadCoverage:this.parseList(B.pointer(B.coverage)),lookupRecords:this.parseRecordList(Wn)};U.assert(!1,"0x"+i.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},De[7]=function(){let i=this.parseUShort();U.argument(i===1,"GSUB Extension Substitution subtable identifier-format must be 1");let l=this.parseUShort(),h=new B(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:l,extension:De[l].call(h)}},De[8]=function(){let i=this.parseUShort();return U.argument(i===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(B.coverage),backtrackCoverage:this.parseList(B.pointer(B.coverage)),lookaheadCoverage:this.parseList(B.pointer(B.coverage)),substitutes:this.parseUShortList()}};function Af(s,i){i=i||0;let l=new B(s,i),h=l.parseVersion(1);return U.argument(h===1||h===1.1,"Unsupported GSUB table version."),h===1?{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(De)}:{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(De),variations:l.parseFeatureVariationsList()}}var Cn=new Array(9);Cn[1]=function(i){if(i.substFormat===1)return new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)},{name:"deltaGlyphID",type:"SHORT",value:i.deltaGlyphId}]);if(i.substFormat===2)return new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)}].concat(J.ushortList("substitute",i.substitute)));U.fail("Lookup type 1 substFormat must be 1 or 2.")},Cn[2]=function(i){return U.assert(i.substFormat===1,"Lookup type 2 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)}].concat(J.tableList("seqSet",i.sequences,function(l){return new J.Table("sequenceSetTable",J.ushortList("sequence",l))})))},Cn[3]=function(i){return U.assert(i.substFormat===1,"Lookup type 3 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)}].concat(J.tableList("altSet",i.alternateSets,function(l){return new J.Table("alternateSetTable",J.ushortList("alternate",l))})))},Cn[4]=function(i){return U.assert(i.substFormat===1,"Lookup type 4 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)}].concat(J.tableList("ligSet",i.ligatureSets,function(l){return new J.Table("ligatureSetTable",J.tableList("ligature",l,function(h){return new J.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:h.ligGlyph}].concat(J.ushortList("component",h.components,h.components.length+1)))}))})))},Cn[5]=function(i){if(i.substFormat===1)return new J.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)}].concat(J.tableList("sequenceRuleSet",i.ruleSets,function(l){return l?new J.Table("sequenceRuleSetTable",J.tableList("sequenceRule",l,function(h){let d=J.ushortList("seqLookup",[],h.lookupRecords.length).concat(J.ushortList("inputSequence",h.input,h.input.length+1));[d[0],d[1]]=[d[1],d[0]];for(let p=0;p<h.lookupRecords.length;p++){let y=h.lookupRecords[p];d=d.concat({name:"sequenceIndex"+p,type:"USHORT",value:y.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:y.lookupListIndex})}return new J.Table("sequenceRuleTable",d)})):new J.Table("NULL",null)})));if(i.substFormat===2)return new J.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)},{name:"classDef",type:"TABLE",value:new J.ClassDef(i.classDef)}].concat(J.tableList("classSeqRuleSet",i.classSets,function(l){return l?new J.Table("classSeqRuleSetTable",J.tableList("classSeqRule",l,function(h){let d=J.ushortList("classes",h.classes,h.classes.length+1).concat(J.ushortList("seqLookupCount",[],h.lookupRecords.length));for(let p=0;p<h.lookupRecords.length;p++){let y=h.lookupRecords[p];d=d.concat({name:"sequenceIndex"+p,type:"USHORT",value:y.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:y.lookupListIndex})}return new J.Table("classSeqRuleTable",d)})):new J.Table("NULL",null)})));if(i.substFormat===3){let l=[{name:"substFormat",type:"USHORT",value:i.substFormat}];l.push({name:"inputGlyphCount",type:"USHORT",value:i.coverages.length}),l.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let d=0;d<i.coverages.length;d++){let p=i.coverages[d];l.push({name:"inputCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}for(let d=0;d<i.lookupRecords.length;d++){let p=i.lookupRecords[d];l=l.concat({name:"sequenceIndex"+d,type:"USHORT",value:p.sequenceIndex}).concat({name:"lookupListIndex"+d,type:"USHORT",value:p.lookupListIndex})}return new J.Table("contextualSubstitutionTable",l)}U.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},Cn[6]=function(i){if(i.substFormat===1)return new J.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new J.Coverage(i.coverage)}].concat(J.tableList("chainRuleSet",i.chainRuleSets,function(h){return new J.Table("chainRuleSetTable",J.tableList("chainRule",h,function(d){let p=J.ushortList("backtrackGlyph",d.backtrack,d.backtrack.length).concat(J.ushortList("inputGlyph",d.input,d.input.length+1)).concat(J.ushortList("lookaheadGlyph",d.lookahead,d.lookahead.length)).concat(J.ushortList("substitution",[],d.lookupRecords.length));for(let y=0;y<d.lookupRecords.length;y++){let x=d.lookupRecords[y];p=p.concat({name:"sequenceIndex"+y,type:"USHORT",value:x.sequenceIndex}).concat({name:"lookupListIndex"+y,type:"USHORT",value:x.lookupListIndex})}return new J.Table("chainRuleTable",p)}))})));if(i.substFormat===2)U.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(i.substFormat===3){let l=[{name:"substFormat",type:"USHORT",value:i.substFormat}];l.push({name:"backtrackGlyphCount",type:"USHORT",value:i.backtrackCoverage.length});for(let d=0;d<i.backtrackCoverage.length;d++){let p=i.backtrackCoverage[d];l.push({name:"backtrackCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}l.push({name:"inputGlyphCount",type:"USHORT",value:i.inputCoverage.length});for(let d=0;d<i.inputCoverage.length;d++){let p=i.inputCoverage[d];l.push({name:"inputCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}l.push({name:"lookaheadGlyphCount",type:"USHORT",value:i.lookaheadCoverage.length});for(let d=0;d<i.lookaheadCoverage.length;d++){let p=i.lookaheadCoverage[d];l.push({name:"lookaheadCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}l.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let d=0;d<i.lookupRecords.length;d++){let p=i.lookupRecords[d];l=l.concat({name:"sequenceIndex"+d,type:"USHORT",value:p.sequenceIndex}).concat({name:"lookupListIndex"+d,type:"USHORT",value:p.lookupListIndex})}return new J.Table("chainContextTable",l)}U.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Tf(s){return new J.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(s.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(s.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(s.lookups,Cn)}])}var $l={parse:Af,make:Tf};function Cf(s,i){let l=new rt.Parser(s,i),h=l.parseULong();U.argument(h===1,"Unsupported META table version."),l.parseULong(),l.parseULong();let d=l.parseULong(),p={};for(let y=0;y<d;y++){let x=l.parseTag(),A=l.parseULong(),E=l.parseULong();if(x==="appl"||x==="bild")continue;let C=Ft.UTF8(s,i+A,E);p[x]=C}return p}function wf(s){let i=Object.keys(s).length,l="",h=16+i*12,d=new J.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:h},{name:"numTags",type:"ULONG",value:i}]);for(let p in s){let y=l.length;l+=s[p],d.fields.push({name:"tag "+p,type:"TAG",value:p}),d.fields.push({name:"offset "+p,type:"ULONG",value:h+y}),d.fields.push({name:"length "+p,type:"ULONG",value:s[p].length})}return d.fields.push({name:"stringPool",type:"CHARARRAY",value:l}),d}var zl={parse:Cf,make:wf};function Ef(s,i){let l=new B(s,i),h=l.parseUShort();h!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");let d=l.parseUShort(),p=l.parseOffset32(),y=l.parseOffset32(),x=l.parseUShort();l.relativeOffset=p;let A=l.parseRecordList(d,{glyphID:B.uShort,firstLayerIndex:B.uShort,numLayers:B.uShort});l.relativeOffset=y;let E=l.parseRecordList(x,{glyphID:B.uShort,paletteIndex:B.uShort});return{version:h,baseGlyphRecords:A,layerRecords:E}}function kf({version:s=0,baseGlyphRecords:i=[],layerRecords:l=[]}){U.argument(s===0,"Only COLRv0 supported.");let h=14,d=h+i.length*6;return new J.Table("COLR",[{name:"version",type:"USHORT",value:s},{name:"numBaseGlyphRecords",type:"USHORT",value:i.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:h},{name:"layerRecordsOffset",type:"ULONG",value:d},{name:"numLayerRecords",type:"USHORT",value:l.length},...i.map((p,y)=>[{name:"glyphID_"+y,type:"USHORT",value:p.glyphID},{name:"firstLayerIndex_"+y,type:"USHORT",value:p.firstLayerIndex},{name:"numLayers_"+y,type:"USHORT",value:p.numLayers}]).flat(),...l.map((p,y)=>[{name:"LayerGlyphID_"+y,type:"USHORT",value:p.glyphID},{name:"paletteIndex_"+y,type:"USHORT",value:p.paletteIndex}]).flat()])}var Wl={parse:Ef,make:kf};function If(s,i){return[{name:"tag_"+s,type:"TAG",value:i.tag},{name:"minValue_"+s,type:"FIXED",value:i.minValue<<16},{name:"defaultValue_"+s,type:"FIXED",value:i.defaultValue<<16},{name:"maxValue_"+s,type:"FIXED",value:i.maxValue<<16},{name:"flags_"+s,type:"USHORT",value:0},{name:"nameID_"+s,type:"USHORT",value:i.axisNameID}]}function Pf(s,i,l){let h={},d=new rt.Parser(s,i);h.tag=d.parseTag(),h.minValue=d.parseFixed(),h.defaultValue=d.parseFixed(),h.maxValue=d.parseFixed(),d.skip("uShort",1);let p=d.parseUShort();return h.axisNameID=p,h.name=Zs(l,p),h}function Rf(s,i,l,h={}){let d=[{name:"nameID_"+s,type:"USHORT",value:i.subfamilyNameID},{name:"flags_"+s,type:"USHORT",value:0}];for(let p=0;p<l.length;++p){let y=l[p].tag;d.push({name:"axis_"+s+" "+y,type:"FIXED",value:i.coordinates[y]<<16})}return h&&h.postScriptNameID&&d.push({name:"postScriptNameID_",type:"USHORT",value:i.postScriptNameID!==void 0?i.postScriptNameID:65535}),d}function Of(s,i,l,h,d){let p={},y=new rt.Parser(s,i),x=y.parseUShort();p.subfamilyNameID=x,p.name=Zs(h,x,[2,17]),y.skip("uShort",1),p.coordinates={};for(let E=0;E<l.length;++E)p.coordinates[l[E].tag]=y.parseFixed();if(y.relativeOffset===d)return p.postScriptNameID=void 0,p.postScriptName=void 0,p;let A=y.parseUShort();return p.postScriptNameID=A==65535?void 0:A,p.postScriptName=p.postScriptNameID!==void 0?Zs(h,A,[6]):"",p}function Mf(s,i){let l=new J.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:s.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:s.instances.length},{name:"instanceSize",type:"USHORT",value:4+s.axes.length*4}]);l.offsetToData=l.sizeOf();for(let d=0;d<s.axes.length;d++)l.fields=l.fields.concat(If(d,s.axes[d],i));let h={};for(let d=0;d<s.instances.length;d++)if(s.instances[d].postScriptNameID!==void 0){l.instanceSize+=2,h.postScriptNameID=!0;break}for(let d=0;d<s.instances.length;d++)l.fields=l.fields.concat(Rf(d,s.instances[d],s.axes,h));return l}function Lf(s,i,l){let h=new rt.Parser(s,i),d=h.parseULong();U.argument(d===65536,"Unsupported fvar table version.");let p=h.parseOffset16();h.skip("uShort",1);let y=h.parseUShort(),x=h.parseUShort(),A=h.parseUShort(),E=h.parseUShort(),C=[];for(let L=0;L<y;L++)C.push(Pf(s,i+p+L*x,l));let R=[],P=i+p+y*x;for(let L=0;L<A;L++)R.push(Of(s,P+L*E,C,l,E));return{axes:C,instances:R}}var Xl={make:Mf,parse:Lf},Ff={tag:B.tag,nameID:B.uShort,ordering:B.uShort},is=new Array(5);is[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},is[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},is[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},is[4]=function(){let i=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(i,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function Df(){let s=this.parseUShort(),i=is[s],l={format:s};return i===void 0?(console.warn(`Unknown axis value table format ${s}`),l):Object.assign(l,this.parseStruct(i.bind(this)))}function _f(s,i,l){i||(i=0);let h=new rt.Parser(s,i),d=h.parseUShort(),p=h.parseUShort();d!==1&&console.warn(`Unsupported STAT table version ${d}.${p}`);let y=[d,p],x=h.parseUShort(),A=h.parseUShort(),E=h.parseOffset32(),C=h.parseUShort(),R=h.parseOffset32(),P=d>1||p>0?h.parseUShort():void 0;l!==void 0&&U.argument(A>=l.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),C>0&&U.argument(A>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let L=[];for(let z=0;z<A;z++)h.offset=i+E,h.relativeOffset=z*x,L.push(h.parseStruct(Ff));h.offset=i,h.relativeOffset=R;let M=h.parseUShortList(C),N=[];for(let z=0;z<C;z++)h.offset=i+R,h.relativeOffset=M[z],N.push(Df.apply(h));return{version:y,axes:L,values:N,elidedFallbackNameID:P}}var os=new Array(5);os[1]=function(i,l){return[{name:`format${i}`,type:"USHORT",value:1},{name:`axisIndex${i}`,type:"USHORT",value:l.axisIndex},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID},{name:`value${i}`,type:"FLOAT",value:l.value}]},os[2]=function(i,l){return[{name:`format${i}`,type:"USHORT",value:2},{name:`axisIndex${i}`,type:"USHORT",value:l.axisIndex},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID},{name:`nominalValue${i}`,type:"FLOAT",value:l.nominalValue},{name:`rangeMinValue${i}`,type:"FLOAT",value:l.rangeMinValue},{name:`rangeMaxValue${i}`,type:"FLOAT",value:l.rangeMaxValue}]},os[3]=function(i,l){return[{name:`format${i}`,type:"USHORT",value:3},{name:`axisIndex${i}`,type:"USHORT",value:l.axisIndex},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID},{name:`value${i}`,type:"FLOAT",value:l.value},{name:`linkedValue${i}`,type:"FLOAT",value:l.linkedValue}]},os[4]=function(i,l){let h=[{name:`format${i}`,type:"USHORT",value:4},{name:`axisCount${i}`,type:"USHORT",value:l.axisValues.length},{name:`flags${i}`,type:"USHORT",value:l.flags},{name:`valueNameID${i}`,type:"USHORT",value:l.valueNameID}];for(let d=0;d<l.axisValues.length;d++)h=h.concat([{name:`format${i}axisIndex${d}`,type:"USHORT",value:l.axisValues[d].axisIndex},{name:`format${i}value${d}`,type:"FLOAT",value:l.axisValues[d].value}]);return h};function Nf(s,i){return new J.Record("axisRecord_"+s,[{name:"axisTag_"+s,type:"TAG",value:i.tag},{name:"axisNameID_"+s,type:"USHORT",value:i.nameID},{name:"axisOrdering_"+s,type:"USHORT",value:i.ordering}])}function Uf(s,i){let l=i.format,h=os[l];U.argument(h!==void 0,`Unknown axis value table format ${l}`);let d=h(s,i);return new J.Table("axisValueTable_"+s,d)}function Bf(s){let i=new J.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:s.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:s.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:s.elidedFallbackNameID}]);i.designAxesOffset=i.offsetToAxisValueOffsets=i.sizeOf();for(let p=0;p<s.axes.length;p++){let y=Nf(p,s.axes[p]);i.offsetToAxisValueOffsets+=y.sizeOf(),i.fields=i.fields.concat(y.fields)}let l=[],h=[],d=s.values.length*2;for(let p=0;p<s.values.length;p++){let y=Uf(p,s.values[p]);l.push({name:"offset_"+p,type:"USHORT",value:d}),d+=y.sizeOf(),h=h.concat(y.fields)}return i.fields=i.fields.concat(l),i.fields=i.fields.concat(h),i}var Yl={make:Bf,parse:_f};function Gf(s,i){return new J.Record("axisValueMap_"+s,[{name:"fromCoordinate_"+s,type:"F2DOT14",value:i.fromCoordinate},{name:"toCoordinate_"+s,type:"F2DOT14",value:i.toCoordinate}])}function Hf(s,i){let l=new J.Record("segmentMap_"+s,[{name:"positionMapCount_"+s,type:"USHORT",value:i.axisValueMaps.length}]),h=[];for(let d=0;d<i.axisValueMaps.length;d++){let p=Gf(`${s}_${d}`,i.axisValueMaps[d]);h=h.concat(p.fields)}return l.fields=l.fields.concat(h),l}function jf(s,i){U.argument(s.axisSegmentMaps.length===i.axes.length,"avar axis count must correspond to fvar axis count");let l=new J.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:s.axisSegmentMaps.length}]);for(let h=0;h<s.axisSegmentMaps.length;h++){let d=Hf(h,s.axisSegmentMaps[h]);l.fields=l.fields.concat(d.fields)}return l}function Vf(s,i,l){i||(i=0);let h=new B(s,i),d=h.parseUShort(),p=h.parseUShort();d!==1&&console.warn(`Unsupported avar table version ${d}.${p}`),h.skip("uShort",1);let y=h.parseUShort();U.argument(y===l.axes.length,"avar axis count must correspond to fvar axis count");let x=[];for(let A=0;A<y;A++){let E=[],C=h.parseUShort();for(let R=0;R<C;R++){let P=h.parseF2Dot14(),L=h.parseF2Dot14();E.push({fromCoordinate:P,toCoordinate:L})}x.push({axisValueMaps:E})}return{version:[d,p],axisSegmentMaps:x}}var Kl={make:jf,parse:Vf};function $f(s,i,l,h){let d=new rt.Parser(s,i),p=d.parseTupleVariationStore(d.relativeOffset,l.axes.length,"cvar",h),y=d.parseUShort(),x=d.parseUShort();return y!==1&&console.warn(`Unsupported cvar table version ${y}.${x}`),{version:[y,x],...p}}function zf(){console.warn("Writing of cvar tables is not yet supported.")}var Zl={make:zf,parse:$f};function Wf(s,i,l,h){let d=new rt.Parser(s,i),p=d.parseUShort(),y=d.parseUShort();p!==1&&console.warn(`Unsupported gvar table version ${p}.${y}`);let x=d.parseUShort();x!==l.axes.length&&console.warn(`axisCount ${x} in gvar table does not match the number of axes ${l.axes.length} in the fvar table!`);let A=d.parseUShort(),E=d.parsePointer32(function(){return this.parseTupleRecords(A,x)}),C=d.parseTupleVariationStoreList(x,"gvar",h);return{version:[p,y],sharedTuples:E,glyphVariations:C}}function Xf(){console.warn("Writing of gvar tables is not yet supported.")}var Ql={make:Xf,parse:Wf};function Yf(s,i){let l={},h=new rt.Parser(s,i);l.version=h.parseUShort(),U.argument(l.version<=1,"Unsupported gasp table version."),l.numRanges=h.parseUShort(),l.gaspRanges=[];for(let d=0;d<l.numRanges;d++)l.gaspRanges[d]={rangeMaxPPEM:h.parseUShort(),rangeGaspBehavior:h.parseUShort()};return l}function Kf(s){let i=new J.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:s.numRanges}]);for(let l in s.gaspRanges)i.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:s.gaspRanges[l].rangeMaxPPEM}),i.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:s.gaspRanges[l].rangeGaspBehavior});return i}var Jl={parse:Yf,make:Kf};function Zf(s,i){let l=new Map,h=s.buffer,d=new B(s,i);if(d.parseUShort()!==0)return l;d.relativeOffset=d.parseOffset32();let y=s.byteOffset+i+d.relativeOffset,x=d.parseUShort(),A=new Map;for(let E=0;E<x;E++){let C=d.parseUShort(),R=d.parseUShort(),P=y+d.parseOffset32(),L=d.parseULong(),M=A.get(P);M===void 0&&(M=new Uint8Array(h,P,L),A.set(P,M));for(let N=C;N<=R;N++)l.set(N,M)}return l}function Qf(s){let i=Array.from(s.keys()).sort(),l=[],h=[],d=new Map,p=0,y={endGlyphID:null};for(let P=0,L=i.length;P<L;P++){let M=i[P],N=s.get(M),z=d.get(N);z===void 0&&(z=p,h.push(N),d.set(N,z),p+=N.byteLength),M-1===y.endGlyphID&&z===y.svgDocOffset?y.endGlyphID=M:(y={startGlyphID:M,endGlyphID:M,svgDocOffset:z,svgDocLength:N.byteLength},l.push(y))}let x=l.length,A=h.length,E=2+x*12,C=new Array(4+x*4+A),R=0;C[R++]={name:"version",type:"USHORT",value:0},C[R++]={name:"svgDocumentListOffset",type:"ULONG",value:10},C[R++]={name:"reserved",type:"ULONG",value:0},C[R++]={name:"numEntries",type:"USHORT",value:x};for(let P=0;P<x;P++){let L="documentRecord_"+P,{startGlyphID:M,endGlyphID:N,svgDocOffset:z,svgDocLength:vt}=l[P];C[R++]={name:L+"_startGlyphID",type:"USHORT",value:M},C[R++]={name:L+"_endGlyphID",type:"USHORT",value:N},C[R++]={name:L+"_svgDocOffset",type:"ULONG",value:E+z},C[R++]={name:L+"_svgDocLength",type:"ULONG",value:vt}}for(let P=0;P<A;P++)C[R++]={name:"svgDoc_"+P,type:"LITERAL",value:h[P]};return new J.Table("SVG ",C)}var ql={make:Qf,parse:Zf};function tc(s){return Math.log(s)/Math.log(2)|0}function Hi(s){for(;s.length%4!==0;)s.push(0);let i=0;for(let l=0;l<s.length;l+=4)i+=(s[l]<<24)+(s[l+1]<<16)+(s[l+2]<<8)+s[l+3];return i%=Math.pow(2,32),i}function ec(s,i,l,h){return new J.Record("Table Record",[{name:"tag",type:"TAG",value:s!==void 0?s:""},{name:"checkSum",type:"ULONG",value:i!==void 0?i:0},{name:"offset",type:"ULONG",value:l!==void 0?l:0},{name:"length",type:"ULONG",value:h!==void 0?h:0}])}function nc(s){let i=new J.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);i.tables=s,i.numTables=s.length;let l=Math.pow(2,tc(i.numTables));i.searchRange=16*l,i.entrySelector=tc(l),i.rangeShift=i.numTables*16-i.searchRange;let h=[],d=[],p=i.sizeOf()+ec().sizeOf()*i.numTables;for(;p%4!==0;)p+=1,d.push({name:"padding",type:"BYTE",value:0});for(let y=0;y<s.length;y+=1){let x=s[y];U.argument(x.tableName.length===4,"Table name"+x.tableName+" is invalid.");let A=x.sizeOf(),E=ec(x.tableName,Hi(x.encode()),p,A);for(h.push({name:E.tag+" Table Record",type:"RECORD",value:E}),d.push({name:x.tableName+" table",type:"RECORD",value:x}),p+=A,U.argument(!isNaN(p),"Something went wrong calculating the offset.");p%4!==0;)p+=1,d.push({name:"padding",type:"BYTE",value:0})}return h.sort(function(y,x){return y.value.tag>x.value.tag?1:-1}),i.fields=i.fields.concat(h),i.fields=i.fields.concat(d),i}function sc(s,i,l){for(let h=0;h<i.length;h+=1){let d=s.charToGlyphIndex(i[h]);if(d>0)return s.glyphs.get(d).getMetrics()}return l}function Jf(s){let i=0;for(let l=0;l<s.length;l+=1)i+=s[l];return i/s.length}function qf(s){let i=[],l=[],h=[],d=[],p=[],y=[],x=[],A,E=0,C=0,R=0,P=0,L=0;for(let Vt=0;Vt<s.glyphs.length;Vt+=1){let be=s.glyphs.get(Vt),Pe=be.unicode|0;if(isNaN(be.advanceWidth))throw new Error("Glyph "+be.name+" ("+Vt+"): advanceWidth is not a number.");(A>Pe||A===void 0)&&Pe>0&&(A=Pe),E<Pe&&(E=Pe);let Be=Gi.getUnicodeRange(Pe);if(Be<32)C|=1<<Be;else if(Be<64)R|=1<<Be-32;else if(Be<96)P|=1<<Be-64;else if(Be<123)L|=1<<Be-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(be.name===".notdef")continue;let en=be.getMetrics();i.push(en.xMin),l.push(en.yMin),h.push(en.xMax),d.push(en.yMax),y.push(en.leftSideBearing),x.push(en.rightSideBearing),p.push(be.advanceWidth)}let M={xMin:Math.min.apply(null,i),yMin:Math.min.apply(null,l),xMax:Math.max.apply(null,h),yMax:Math.max.apply(null,d),advanceWidthMax:Math.max.apply(null,p),advanceWidthAvg:Jf(p),minLeftSideBearing:Math.min.apply(null,y),maxLeftSideBearing:Math.max.apply(null,y),minRightSideBearing:Math.min.apply(null,x)};M.ascender=s.ascender,M.descender=s.descender;let N=0;s.weightClass>=600&&(N|=s.macStyleValues.BOLD),s.italicAngle<0&&(N|=s.macStyleValues.ITALIC);let z=Ul.make({flags:3,unitsPerEm:s.unitsPerEm,xMin:M.xMin,yMin:M.yMin,xMax:M.xMax,yMax:M.yMax,lowestRecPPEM:3,macStyle:N,createdTimestamp:s.createdTimestamp}),vt=Bl.make({ascender:M.ascender,descender:M.descender,advanceWidthMax:M.advanceWidthMax,minLeftSideBearing:M.minLeftSideBearing,minRightSideBearing:M.minRightSideBearing,xMaxExtent:M.maxLeftSideBearing+(M.xMax-M.xMin),numberOfHMetrics:s.glyphs.length}),pt=jl.make(s.glyphs.length),At=Gi.make(Object.assign({xAvgCharWidth:Math.round(M.advanceWidthAvg),usFirstCharIndex:A,usLastCharIndex:E,ulUnicodeRange1:C,ulUnicodeRange2:R,ulUnicodeRange3:P,ulUnicodeRange4:L,sTypoAscender:M.ascender,sTypoDescender:M.descender,sTypoLineGap:0,usWinAscent:M.yMax,usWinDescent:Math.abs(M.yMin),ulCodePageRange1:1,sxHeight:sc(s,"xyvw",{yMax:Math.round(M.ascender/2)}).yMax,sCapHeight:sc(s,"HIKLEFJMNTZBDPRAGOQSUVWXY",M).yMax,usDefaultChar:s.hasChar(" ")?32:0,usBreakChar:s.hasChar(" ")?32:0},s.tables.os2)),It=Gl.make(s.glyphs),Nt=vl.make(s.glyphs),Bt=s.getEnglishName("fontFamily"),Gt=s.getEnglishName("fontSubfamily"),Jt=Bt+" "+Gt,Ne=s.getEnglishName("postScriptName");Ne||(Ne=Bt.replace(/\s/g,"")+"-"+Gt);let Pt={};for(let Vt in s.names)Pt[Vt]=s.names[Vt];Pt.unicode=Pt.unicode||{},Pt.macintosh=Pt.macintosh||{},Pt.windows=Pt.windows||{};let Te=s.names.unicode||{},de=s.names.macintosh||{},xt=s.names.windows||{};for(let Vt in Pt){if(Pt[Vt]=Pt[Vt]||{},!Pt[Vt].uniqueID){let be=s.getEnglishName("manufacturer")||"";Pt[Vt].uniqueID={en:`${be}: ${Jt}`}}Pt[Vt].postScriptName||(Pt[Vt].postScriptName={en:Ne})}Pt.unicode.preferredFamily||(Pt.unicode.preferredFamily=Te.fontFamily||de.fontFamily||xt.fontFamily),Pt.macintosh.preferredFamily||(Pt.macintosh.preferredFamily=de.fontFamily||Te.fontFamily||xt.fontFamily),Pt.windows.preferredFamily||(Pt.windows.preferredFamily=xt.fontFamily||Te.fontFamily||de.fontFamily),Pt.unicode.preferredSubfamily||(Pt.unicode.preferredSubfamily=Te.fontSubfamily||de.fontSubfamily||xt.fontSubfamily),Pt.macintosh.preferredSubfamily||(Pt.macintosh.preferredSubfamily=de.fontSubfamily||Te.fontSubfamily||xt.fontSubfamily),Pt.windows.preferredSubfamily||(Pt.windows.preferredSubfamily=xt.fontSubfamily||Te.fontSubfamily||de.fontSubfamily);let ct=[],ft=yl.make(Pt,ct),oe=ct.length>0?Hl.make(ct):void 0,fn=Vl.make(s),ur=Ui.make(s.glyphs,{version:s.getEnglishName("version"),fullName:Jt,familyName:Bt,weightName:Gt,postScriptName:Ne,unitsPerEm:s.unitsPerEm,fontBBox:[0,M.yMin,M.ascender,M.advanceWidthMax],topDict:s.tables.cff&&s.tables.cff.topDict||{}}),kn=s.metas&&Object.keys(s.metas).length>0?zl.make(s.metas):void 0,Ue=[z,vt,pt,At,ft,Nt,fn,ur,It];oe&&Ue.push(oe);let fe={gsub:$l,cpal:wl,colr:Wl,stat:Yl,avar:Kl,cvar:Zl,fvar:Xl,gvar:Ql,gasp:Jl,svg:ql},Ie={avar:[s.tables.fvar],fvar:[s.names]};for(let Vt in fe){let be=s.tables[Vt];if(be){let Pe=fe[Vt].make.call(s,be,...Ie[Vt]||[]);Pe&&Ue.push(Pe)}}kn&&Ue.push(kn);let ae=nc(Ue),Ce=ae.encode(),pe=Hi(Ce),ge=ae.fields,Zt=!1;for(let Vt=0;Vt<ge.length;Vt+=1)if(ge[Vt].name==="head table"){ge[Vt].value.checkSumAdjustment=2981146554-pe,Zt=!0;break}if(!Zt)throw new Error("Could not find head table with checkSum to adjust.");return ae}var tp={make:nc,fontToTable:qf,computeCheckSum:Hi};function ji(s,i){let l=0,h=s.length-1;for(;l<=h;){let d=l+h>>>1,p=s[d].tag;if(p===i)return d;p<i?l=d+1:h=d-1}return-l-1}function rc(s,i){let l=0,h=s.length-1;for(;l<=h;){let d=l+h>>>1,p=s[d];if(p===i)return d;p<i?l=d+1:h=d-1}return-l-1}function ic(s,i){let l,h=0,d=s.length-1;for(;h<=d;){let p=h+d>>>1;l=s[p];let y=l.start;if(y===i)return l;y<i?h=p+1:d=p-1}if(h>0)return l=s[h-1],i>l.end?0:l}function oc(s,i){this.font=s,this.tableName=i}oc.prototype={searchTag:ji,binSearch:rc,getTable:function(s){let i=this.font.tables[this.tableName];return!i&&s&&(i=this.font.tables[this.tableName]=this.createDefaultTable()),i},getScriptNames:function(){let s=this.getTable();return s?s.scripts.map(function(i){return i.tag}):[]},getDefaultScriptName:function(){let s=this.getTable();if(!s)return;let i=!1;for(let l=0;l<s.scripts.length;l++){let h=s.scripts[l].tag;if(h==="DFLT")return h;h==="latn"&&(i=!0)}if(i)return"latn"},getScriptTable:function(s,i){let l=this.getTable(i);if(l){s=s||"DFLT";let h=l.scripts,d=ji(l.scripts,s);if(d>=0)return h[d].script;if(i){let p={tag:s,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return h.splice(-1-d,0,p),p.script}}},getLangSysTable:function(s,i,l){let h=this.getScriptTable(s,l);if(h){if(!i||i==="dflt"||i==="DFLT")return h.defaultLangSys;let d=ji(h.langSysRecords,i);if(d>=0)return h.langSysRecords[d].langSys;if(l){let p={tag:i,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return h.langSysRecords.splice(-1-d,0,p),p.langSys}}},getFeatureTable:function(s,i,l,h){let d=this.getLangSysTable(s,i,h);if(d){let p,y=d.featureIndexes,x=this.font.tables[this.tableName].features;for(let A=0;A<y.length;A++)if(p=x[y[A]],p.tag===l)return p.feature;if(h){let A=x.length;return U.assert(A===0||l>=x[A-1].tag,"Features must be added in alphabetical order."),p={tag:l,feature:{params:0,lookupListIndexes:[]}},x.push(p),y.push(A),p.feature}}},getLookupTables:function(s,i,l,h,d){let p=this.getFeatureTable(s,i,l,d),y=[];if(p){let x,A=p.lookupListIndexes,E=this.font.tables[this.tableName].lookups;for(let C=0;C<A.length;C++)x=E[A[C]],x.lookupType===h&&y.push(x);if(y.length===0&&d){x={lookupType:h,lookupFlag:0,subtables:[],markFilteringSet:void 0};let C=E.length;return E.push(x),A.push(C),[x]}}return y},getGlyphClass:function(s,i){switch(s.format){case 1:return s.startGlyph<=i&&i<s.startGlyph+s.classes.length?s.classes[i-s.startGlyph]:0;case 2:{let l=ic(s.ranges,i);return l?l.classId:0}}},getCoverageIndex:function(s,i){switch(s.format){case 1:{let l=rc(s.glyphs,i);return l>=0?l:-1}case 2:{let l=ic(s.ranges,i);return l?l.index+i-l.start:-1}}},expandCoverage:function(s){if(s.format===1)return s.glyphs;{let i=[],l=s.ranges;for(let h=0;h<l.length;h++){let d=l[h],p=d.start,y=d.end;for(let x=p;x<=y;x++)i.push(x)}return i}}};var er=oc;function as(s){er.call(this,s,"gpos")}as.prototype=er.prototype,as.prototype.init=function(){let s=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(s)},as.prototype.getKerningValue=function(s,i,l){for(let h=0;h<s.length;h++){let d=s[h].subtables;for(let p=0;p<d.length;p++){let y=d[p],x=this.getCoverageIndex(y.coverage,i);if(!(x<0))switch(y.posFormat){case 1:{let A=y.pairSets[x];for(let E=0;E<A.length;E++){let C=A[E];if(C.secondGlyph===l)return C.value1&&C.value1.xAdvance||0}break}case 2:{let A=this.getGlyphClass(y.classDef1,i),E=this.getGlyphClass(y.classDef2,l),C=y.classRecords[A][E];return C.value1&&C.value1.xAdvance||0}}}}return 0},as.prototype.getKerningTables=function(s,i){if(this.font.tables.gpos)return this.getLookupTables(s,i,"kern",2)};var ep=as;function np(s,i){let l=s.length;if(l!==i.length)return!1;for(let h=0;h<l;h++)if(s[h]!==i[h])return!1;return!0}function sp(s,i,l){let h=0,d=s.length-1,p=null;for(;h<=d;){let y=Math.floor((h+d)/2),x=s[y],A=x[i];if(A<l)h=y+1;else if(A>l)d=y-1;else{p=x;break}}return p}function rp(s,i,l){let h=0,d=s.length-1;for(;h<=d;){let p=Math.floor((h+d)/2),y=s[p];if(y[i]<l)h=p+1;else if(y[i]>l)d=p-1;else return p}return-1}function ip(s,i,l){let h=0,d=s.length,p=(y,x)=>y[i]-x[i];for(;h<d;){let y=h+d>>>1;p(s[y],l)<0?h=y+1:d=y}return s.splice(h,0,l),h}function ac(s){return s[0]===31&&s[1]===139&&s[2]===8}function op(s){let i=new DataView(s.buffer,s.byteOffset,s.byteLength),l=10,h=s.byteLength-8,d=i.getInt8(3);if(d&4&&(l+=2+i.getUint16(l,!0)),d&8)for(;l<h&&s[l++]!==0;);if(d&16)for(;l<h&&s[l++]!==0;);if(d&2&&(l+=2),l>=h)throw new Error("Can't find compressed blocks");let p=i.getUint32(i.byteLength-4,!0);return dt(s.subarray(l,h),new Uint8Array(p))}function lc(s){return{x:s.x,y:s.y,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour}}function ap(s){return{glyphIndex:s.glyphIndex,xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:s.dx,dy:s.dy}}function Se(s){er.call(this,s,"gsub")}function Vi(s,i,l){let h=s.subtables;for(let d=0;d<h.length;d++){let p=h[d];if(p.substFormat===i)return p}if(l)return h.push(l),l}Se.prototype=er.prototype,Se.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Se.prototype.getSingle=function(s,i,l){let h=[],d=this.getLookupTables(i,l,s,1);for(let p=0;p<d.length;p++){let y=d[p].subtables;for(let x=0;x<y.length;x++){let A=y[x],E=this.expandCoverage(A.coverage),C;if(A.substFormat===1){let R=A.deltaGlyphId;for(C=0;C<E.length;C++){let P=E[C];h.push({sub:P,by:P+R})}}else{let R=A.substitute;for(C=0;C<E.length;C++)h.push({sub:E[C],by:R[C]})}}}return h},Se.prototype.getMultiple=function(s,i,l){let h=[],d=this.getLookupTables(i,l,s,2);for(let p=0;p<d.length;p++){let y=d[p].subtables;for(let x=0;x<y.length;x++){let A=y[x],E=this.expandCoverage(A.coverage),C;for(C=0;C<E.length;C++){let R=E[C],P=A.sequences[C];h.push({sub:R,by:P})}}}return h},Se.prototype.getAlternates=function(s,i,l){let h=[],d=this.getLookupTables(i,l,s,3);for(let p=0;p<d.length;p++){let y=d[p].subtables;for(let x=0;x<y.length;x++){let A=y[x],E=this.expandCoverage(A.coverage),C=A.alternateSets;for(let R=0;R<E.length;R++)h.push({sub:E[R],by:C[R]})}}return h},Se.prototype.getLigatures=function(s,i,l){let h=[],d=this.getLookupTables(i,l,s,4);for(let p=0;p<d.length;p++){let y=d[p].subtables;for(let x=0;x<y.length;x++){let A=y[x],E=this.expandCoverage(A.coverage),C=A.ligatureSets;for(let R=0;R<E.length;R++){let P=E[R],L=C[R];for(let M=0;M<L.length;M++){let N=L[M];h.push({sub:[P].concat(N.components),by:N.ligGlyph})}}}}return h},Se.prototype.addSingle=function(s,i,l,h){let d=this.getLookupTables(l,h,s,1,!0)[0],p=Vi(d,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});U.assert(p.coverage.format===1,"Single: unable to modify coverage table format "+p.coverage.format);let y=i.sub,x=this.binSearch(p.coverage.glyphs,y);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,y),p.substitute.splice(x,0,0)),p.substitute[x]=i.by},Se.prototype.addMultiple=function(s,i,l,h){U.assert(i.by instanceof Array&&i.by.length>1,'Multiple: "by" must be an array of two or more ids');let d=this.getLookupTables(l,h,s,2,!0)[0],p=Vi(d,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});U.assert(p.coverage.format===1,"Multiple: unable to modify coverage table format "+p.coverage.format);let y=i.sub,x=this.binSearch(p.coverage.glyphs,y);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,y),p.sequences.splice(x,0,0)),p.sequences[x]=i.by},Se.prototype.addAlternate=function(s,i,l,h){let d=this.getLookupTables(l,h,s,3,!0)[0],p=Vi(d,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});U.assert(p.coverage.format===1,"Alternate: unable to modify coverage table format "+p.coverage.format);let y=i.sub,x=this.binSearch(p.coverage.glyphs,y);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,y),p.alternateSets.splice(x,0,0)),p.alternateSets[x]=i.by},Se.prototype.addLigature=function(s,i,l,h){let d=this.getLookupTables(l,h,s,4,!0)[0],p=d.subtables[0];p||(p={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},d.subtables[0]=p),U.assert(p.coverage.format===1,"Ligature: unable to modify coverage table format "+p.coverage.format);let y=i.sub[0],x=i.sub.slice(1),A={ligGlyph:i.by,components:x},E=this.binSearch(p.coverage.glyphs,y);if(E>=0){let C=p.ligatureSets[E];for(let R=0;R<C.length;R++)if(np(C[R].components,x))return;C.push(A)}else E=-1-E,p.coverage.glyphs.splice(E,0,y),p.ligatureSets.splice(E,0,[A])},Se.prototype.getFeature=function(s,i,l){if(/ss\d\d/.test(s))return this.getSingle(s,i,l);switch(s){case"aalt":case"salt":return this.getSingle(s,i,l).concat(this.getAlternates(s,i,l));case"dlig":case"liga":case"rlig":return this.getLigatures(s,i,l);case"ccmp":return this.getMultiple(s,i,l).concat(this.getLigatures(s,i,l));case"stch":return this.getMultiple(s,i,l)}},Se.prototype.add=function(s,i,l,h){if(/ss\d\d/.test(s))return this.addSingle(s,i,l,h);switch(s){case"aalt":case"salt":return typeof i.by=="number"?this.addSingle(s,i,l,h):this.addAlternate(s,i,l,h);case"dlig":case"liga":case"rlig":return this.addLigature(s,i,l,h);case"ccmp":return i.by instanceof Array?this.addMultiple(s,i,l,h):this.addLigature(s,i,l,h)}};var lp=Se,cc=class{constructor(s){this.defaultValue=255,this.font=s}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(s){let i=[],l=this.cpal();if(!l)return i;for(let h=0;h<l.colorRecordIndices.length;h++){let d=l.colorRecordIndices[h],p=[];for(let y=d;y<d+l.numPaletteEntries;y++)p.push(Vn(l.colorRecords[y],s||"hexa"));i.push(p)}return i}toCPALcolor(s){return Array.isArray(s)?s.map(i=>Js(i,"raw")):Js(s,"raw")}fillPalette(s,i=[],l=this.cpal().numPaletteEntries){return s=Number.isInteger(s)?this.get(s,"raw"):s,Object.assign(Array(l).fill(this.defaultValue),this.toCPALcolor(s).concat(this.toCPALcolor(i)))}extend(s){if(this.ensureCPAL(Array(s).fill(this.defaultValue)))return;let i=this.cpal(),l=i.numPaletteEntries+s,h=this.getAll().map(d=>this.fillPalette(d,[],l));i.numPaletteEntries=l,i.colorRecords=this.toCPALcolor(h.flat()),this.updateIndices()}get(s,i="hexa"){return this.getAll(i)[s]||null}getColor(s,i=0,l="hexa"){return Mi(this.font,s,i,l)}setColor(s,i,l=0){s=parseInt(s),l=parseInt(l);let h=this.getAll("raw"),d=h[l];if(!d)throw Error(`paletteIndex ${l} out of range`);let p=this.cpal(),y=p.numPaletteEntries;Array.isArray(i)||(i=[i]),i.length+s>y&&(this.extend(i.length+s-y),h=this.getAll("raw"),d=h[l]);for(let x=0;x<i.length;x++)d[x+s]=this.toCPALcolor(i[x]);p.colorRecords=h.flat(),this.updateIndices()}add(s){if(this.ensureCPAL(s))return;let i=this.cpal(),l=i.numPaletteEntries;s&&s.length?(s=this.toCPALcolor(s),s.length>l?this.extend(s.length-l):s.length<l&&(s=this.fillPalette(s)),i.colorRecordIndices.push(i.colorRecords.length),i.colorRecords.push(...s)):(i.colorRecordIndices.push(i.colorRecords.length),i.colorRecords.push(...Array(l).fill(this.defaultValue)))}delete(s){let i=this.getAll("raw");delete i[s];let l=this.cpal();l.colorRecordIndices.pop(),l.colorRecords=i.flat()}deleteColor(s,i){if(s===i)throw Error("replacementIndex cannot be the same as colorIndex");let l=this.cpal(),h=this.getAll("raw"),d=[];if(i>l.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${l.numPaletteEntries-1}, replacementIndex: ${i})`);for(let x=0;x<h.length;x++){let E=h[x].filter((C,R)=>R!==s);d.push(E)}let p=this.font.tables.colr;if(p){let x=p.layerRecords;for(let A=0;A<x.length;A++){let E=x[A].paletteIndex;if(E>s)x[A].paletteIndex-=1;else if(E===s){let C=0;for(let R=0;R<h.length;R++)if(i>s&&i<=s+h[R].length){C++;break}x[A].paletteIndex=i-C}}this.font.tables.colr={...p,layerRecords:x}}let y=d.flat();for(let x=0;x<h.length;x++)l.colorRecordIndices[x]-=x;l.numPaletteEntries=Math.max(0,l.numPaletteEntries-1),l.colorRecords=this.toCPALcolor(y)}ensureCPAL(s){return this.cpal()?!1:(!s||!s.length?s=[this.defaultValue]:s=this.toCPALcolor(s),this.font.tables.cpal={version:0,numPaletteEntries:s.length,colorRecords:s,colorRecordIndices:[0]},!0)}updateIndices(){let s=this.cpal(),i=Math.ceil(s.colorRecords.length/s.numPaletteEntries);s.colorRecordIndices=[];for(let l=0;l<i;l++)s.colorRecordIndices.push(l*s.numPaletteEntries)}},cp=class{constructor(s){this.font=s}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(s){let i=this.font,l=[],h=i.tables.colr,d=i.tables.cpal;if(!h||!d)return l;let p=sp(h.baseGlyphRecords,"glyphID",s);if(!p)return l;let y=p.firstLayerIndex,x=p.numLayers;for(let A=0;A<x;A++){let E=h.layerRecords[y+A];l.push({glyph:i.glyphs.get(E.glyphID),paletteIndex:E.paletteIndex})}return l}add(s,i,l){let h=this.get(s);i=Array.isArray(i)?i:[i],l===void 0||l===1/0||l>h.length?l=h.length:l<0&&(l=h.length+1+l%(h.length+1),l>=h.length+1&&(l-=h.length+1));let d=[];for(let p=0;p<l;p++){let y=Number.isInteger(h[p].glyph)?h[p].glyph:h[p].glyph.index;d.push({glyphID:y,paletteIndex:h[p].paletteIndex})}for(let p of i){let y=Number.isInteger(p.glyph)?p.glyph:p.glyph.index;d.push({glyphID:y,paletteIndex:p.paletteIndex})}for(let p=l;p<h.length;p++){let y=Number.isInteger(h[p].glyph)?h[p].glyph:h[p].glyph.index;d.push({glyphID:y,paletteIndex:h[p].paletteIndex})}this.updateColrTable(s,d)}setPaletteIndex(s,i,l){let h=this.get(s);h[i]?(h=h.map((d,p)=>({glyphID:d.glyph.index,paletteIndex:p===i?l:d.paletteIndex})),this.updateColrTable(s,h)):console.error("Invalid layer index")}remove(s,i,l=i){let h=this.get(s);h=h.map(d=>({glyphID:d.glyph.index,paletteIndex:d.paletteIndex})),h.splice(i,l-i+1),this.updateColrTable(s,h)}updateColrTable(s,i){this.ensureCOLR();let h=this.font.tables.colr,d=rp(h.baseGlyphRecords,"glyphID",s);if(d===-1){let C={glyphID:s,firstLayerIndex:h.layerRecords.length,numLayers:0};d=ip(h.baseGlyphRecords,"glyphID",C)}let y=h.baseGlyphRecords[d],x=y.numLayers,A=i.length,E=A-x;if(E>0){let C=i.slice(x).map(R=>({glyphID:R.glyphID,paletteIndex:R.paletteIndex}));h.layerRecords.splice(y.firstLayerIndex+x,0,...C)}else E<0&&h.layerRecords.splice(y.firstLayerIndex+A,-E);for(let C=0;C<Math.min(x,A);C++)h.layerRecords[y.firstLayerIndex+C]={glyphID:i[C].glyphID,paletteIndex:i[C].paletteIndex};if(y.numLayers=A,E!==0)for(let C=0;C<h.baseGlyphRecords.length;C++){let R=h.baseGlyphRecords[C];C===d||R.firstLayerIndex<y.firstLayerIndex||(h.baseGlyphRecords[C].firstLayerIndex+=E)}}},up=class{constructor(s){this.font=s,this.cache=new WeakMap}get(s){let i=this.getOrCreateSvgImageCacheEntry(s);return i&&i.image}getAsync(s){let i=this.getOrCreateSvgImageCacheEntry(s);return i&&i.promise}getOrCreateSvgImageCacheEntry(s){let i=this.font.tables.svg;if(i===void 0)return;let l=i.get(s);if(l===void 0)return;let h=this.cache.get(l);h===void 0&&(h=hp(l),this.cache.set(l,h));let d=h.images.get(s);return d===void 0&&(d=dp(this.font,h.template,s),d.promise.then(p=>{if(d.image=p,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(s)}catch(y){console.error("font.onGlyphUpdated",s,y)}}),h.images.set(s,d)),d}};function hp(s){return{template:fp(s).then(mp),images:new Map}}function dp(s,i,l){return{promise:i.then(h=>{let d;typeof h=="string"?d=h:(h[4]=l,d=h.join(""));let p=bp(d,s.unitsPerEm);return p.image.decode().then(()=>p)}),image:void 0}}var fp=typeof DecompressionStream=="function"?gp:pp;function pp(s){try{return Promise.resolve(new TextDecoder().decode(ac(s)?op(s):s))}catch(i){return Promise.reject(i)}}function gp(s){if(ac(s))return new Response(new Response(s).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(s))}catch(i){return Promise.reject(i)}}function mp(s){let i=s.indexOf("<svg"),l=s.indexOf(">",i+4)+1;if(/ id=['"]glyph\d+['"]/.test(s.substring(i,l)))return s;let h=s.lastIndexOf("</svg>");return[s.substring(0,l),"<defs>",s.substring(l,h),'</defs><use href="#glyph',"",'"/>',s.substring(h)]}function bp(s,i){let h=new DOMParser().parseFromString(s,"image/svg+xml").documentElement,d=h.viewBox.baseVal,p=h.width.baseVal,y=h.height.baseVal,x=1,A=1;d.width>0&&d.height>0&&(p.unitType===1?(x=p.valueInSpecifiedUnits/d.width,A=y.unitType===1?y.valueInSpecifiedUnits/d.height:x):y.unitType===1?(A=y.valueInSpecifiedUnits/d.height,x=A):i&&(x=i/d.width,A=i/d.height));let E=document.createElement("div");E.style.position="fixed",E.style.visibility="hidden",E.appendChild(h),document.body.appendChild(E);let C=h.getBBox();document.body.removeChild(E);let R=(C.x-d.x)*x,P=(d.y-C.y)*A,L=C.width*x,M=C.height*A;h.setAttribute("viewBox",[C.x,C.y,C.width,C.height].join(" ")),x!==1&&h.setAttribute("width",L),A!==1&&h.setAttribute("height",M);let N=new Image(L,M);return N.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(h.outerHTML),{leftSideBearing:R,baseline:P,image:N}}var $i=new WeakMap;function uc(s,i,l,h,d){let p;return(i&h)>0?(p=s.parseByte(),(i&d)===0&&(p=-p),p=l+p):(i&d)>0?p=l:p=l+s.parseShort(),p}function hc(s,i,l){let h=new rt.Parser(i,l);s._numberOfContours=h.parseShort(),s._xMin=h.parseShort(),s._yMin=h.parseShort(),s._xMax=h.parseShort(),s._yMax=h.parseShort();let d,p;if(s._numberOfContours>0){let y=s.endPointIndices=[];for(let A=0;A<s._numberOfContours;A+=1)y.push(h.parseUShort());s.instructionLength=h.parseUShort(),s.instructions=[];for(let A=0;A<s.instructionLength;A+=1)s.instructions.push(h.parseByte());let x=y[y.length-1]+1;d=[];for(let A=0;A<x;A+=1)if(p=h.parseByte(),d.push(p),(p&8)>0){let E=h.parseByte();for(let C=0;C<E;C+=1)d.push(p),A+=1}if(U.argument(d.length===x,"Bad flags."),y.length>0){let A=[],E;if(x>0){for(let P=0;P<x;P+=1)p=d[P],E={},E.onCurve=!!(p&1),E.lastPointOfContour=y.indexOf(P)>=0,A.push(E);let C=0;for(let P=0;P<x;P+=1)p=d[P],E=A[P],E.x=uc(h,p,C,2,16),C=E.x;let R=0;for(let P=0;P<x;P+=1)p=d[P],E=A[P],E.y=uc(h,p,R,4,32),R=E.y}s.points=A}else s.points=[]}else if(s._numberOfContours===0)s.points=[];else{s.isComposite=!0,s.points=[],s.components=[];let y=!0;for(;y;){d=h.parseUShort();let x={glyphIndex:h.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(d&1)>0?(d&2)>0?(x.dx=h.parseShort(),x.dy=h.parseShort()):x.matchedPoints=[h.parseUShort(),h.parseUShort()]:(d&2)>0?(x.dx=h.parseChar(),x.dy=h.parseChar()):x.matchedPoints=[h.parseByte(),h.parseByte()],(d&8)>0?x.xScale=x.yScale=h.parseF2Dot14():(d&64)>0?(x.xScale=h.parseF2Dot14(),x.yScale=h.parseF2Dot14()):(d&128)>0&&(x.xScale=h.parseF2Dot14(),x.scale01=h.parseF2Dot14(),x.scale10=h.parseF2Dot14(),x.yScale=h.parseF2Dot14()),s.components.push(x),y=!!(d&32)}if(d&256){s.instructionLength=h.parseUShort(),s.instructions=[];for(let x=0;x<s.instructionLength;x+=1)s.instructions.push(h.parseByte())}}}function nr(s,i){let l=[];for(let h=0;h<s.length;h+=1){let d=s[h],p={x:i.xScale*d.x+i.scale10*d.y+i.dx,y:i.scale01*d.x+i.yScale*d.y+i.dy,onCurve:d.onCurve,lastPointOfContour:d.lastPointOfContour};l.push(p)}return l}function yp(s){let i=[],l=[];for(let h=0;h<s.length;h+=1){let d=s[h];l.push(d),d.lastPointOfContour&&(i.push(l),l=[])}return U.argument(l.length===0,"There are still points left in the current contour."),i}function zi(s){let i=new it;if(!s)return i;let l=yp(s);for(let h=0;h<l.length;++h){let d=l[h],p=d[d.length-1],y=d[0];if(p.onCurve)i.moveTo(p.x,p.y);else if(y.onCurve)i.moveTo(y.x,y.y);else{let x={x:(p.x+y.x)*.5,y:(p.y+y.y)*.5};i.moveTo(x.x,x.y)}for(let x=0;x<d.length;++x)if(p=y,y=d[(x+1)%d.length],p.onCurve)i.lineTo(p.x,p.y);else{let A=y;y.onCurve||(A={x:(p.x+y.x)*.5,y:(p.y+y.y)*.5}),i.quadraticCurveTo(p.x,p.y,A.x,A.y)}i.closePath()}return i}function dc(s,i){if(i.isComposite){$i.has(s)||$i.set(s,new Set);let l=$i.get(s);l.add(i.index);try{for(let h=0;h<i.components.length;h+=1){let d=i.components[h];if(l.has(d.glyphIndex))continue;let p=s.get(d.glyphIndex);if(p.getPath(),p.points){let y;if(d.matchedPoints===void 0)y=nr(p.points,d);else{if(d.matchedPoints[0]>i.points.length-1||d.matchedPoints[1]>p.points.length-1)throw Error("Matched points out of range in "+i.name);let x=i.points[d.matchedPoints[0]],A=p.points[d.matchedPoints[1]],E={xScale:d.xScale,scale01:d.scale01,scale10:d.scale10,yScale:d.yScale,dx:0,dy:0};A=nr([A],E)[0],E.dx=x.x-A.x,E.dy=x.y-A.y,y=nr(p.points,E)}i.points=i.points.concat(y)}}}finally{l.delete(i.index)}}return zi(i.points)}function vp(s,i,l,h){let d=new $e.GlyphSet(h);for(let p=0;p<l.length-1;p+=1){let y=l[p],x=l[p+1];y!==x?d.push(p,$e.ttfGlyphLoader(h,p,hc,s,i+y,dc)):d.push(p,$e.glyphLoader(h,p))}return d}function xp(s,i,l,h){let d=new $e.GlyphSet(h);return h._push=function(p){let y=l[p],x=l[p+1];y!==x?d.push(p,$e.ttfGlyphLoader(h,p,hc,s,i+y,dc)):d.push(p,$e.glyphLoader(h,p))},d}function Sp(s,i,l,h,d){return d.lowMemory?xp(s,i,l,h):vp(s,i,l,h)}var fc={getPath:zi,parse:Sp},Ap=class{constructor(s){this.font=s}normalizeCoordTags(s){for(let i in s)if(i.length<4){let l=i.padEnd(4," ");s[l]===void 0&&(s[l]=s[i]),delete s[i]}}getNormalizedCoords(s){s||(s=this.font.variation.get());let i=[];this.normalizeCoordTags(s);for(let l=0;l<this.fvar().axes.length;l++){let h=this.fvar().axes[l],d=s[h.tag];d===void 0&&(d=h.defaultValue),d<h.defaultValue?i.push((d-h.defaultValue+Number.EPSILON)/(h.defaultValue-h.minValue+Number.EPSILON)):i.push((d-h.defaultValue+Number.EPSILON)/(h.maxValue-h.defaultValue+Number.EPSILON))}if(this.avar())for(let l=0;l<this.avar().axisSegmentMaps.length;l++){let h=this.avar().axisSegmentMaps[l];for(let d=0;d<h.axisValueMaps.length;d++){let p=h.axisValueMaps[d];if(d>=1&&i[l]<p.fromCoordinate){let y=h.axisValueMaps[d-1];i[l]=((i[l]-y.fromCoordinate)*(p.toCoordinate-y.toCoordinate)+Number.EPSILON)/(p.fromCoordinate-y.fromCoordinate+Number.EPSILON)+y.toCoordinate;break}}}return i}interpolatePoints(s,i,l){if(s.length===0)return;let h=0;for(;h<s.length;){let d=h,p=h,y=s[p];for(;!y.lastPointOfContour;)y=s[++p];for(;h<=p&&!l[h];)h++;if(h>p)continue;let x=h,A=h;for(h++;h<=p;)l[h]&&(this.deltaInterpolate(A+1,h-1,A,h,i,s),A=h),h++;A===x?this.deltaShift(d,p,A,i,s):(this.deltaInterpolate(A+1,p,A,x,i,s),x>0&&this.deltaInterpolate(d,x-1,A,x,i,s)),h=p+1}}deltaInterpolate(s,i,l,h,d,p){if(s>i)return;let y=["x","y"];for(let A=0;A<y.length;A++){let E=y[A];if(d[l][E]>d[h][E]){var x=l;l=h,h=x}let C=d[l][E],R=d[h][E],P=p[l][E],L=p[h][E];if(C!==R||P===L){let M=C===R?0:(L-P)/(R-C);for(let N=s;N<=i;N++){let z=d[N][E];z<=C?z+=P-C:z>=R?z+=L-R:z=P+(z-C)*M,p[N][E]=z}}}}deltaShift(s,i,l,h,d){let p=d[l].x-h[l].x,y=d[l].y-h[l].y;if(!(p===0&&y===0))for(let x=s;x<=i;x++)x!==l&&(d[x].x+=p,d[x].y+=y)}transformComponents(s,i,l,h,d,p){let y=0;for(let x=0;x<s.components.length;x++){let A=s.components[x],E=this.font.glyphs.get(A.glyphIndex),C=ap(A),R=h.indexOf(x);R>-1&&(C.dx+=Math.round(d.deltas[R]*p),C.dy+=Math.round(d.deltasY[R]*p));let P=nr(this.getTransform(E,l).points,C);i.splice(y,P.length,...P),y+=E.points.length}}applyTupleVariationStore(s,i,l,h="gvar",d={}){l||(l=this.font.variation.get());let p=this.getNormalizedCoords(l),{headers:y,sharedPoints:x}=s,A=this.fvar().axes.length,E;h==="gvar"?E=i.map(lc):h==="cvar"&&(E=[...i]);for(let C=0;C<y.length;C++){let R=y[C],P=1;for(let M=0;M<A;M++){let N=[0];switch(h){case"gvar":N=R.peakTuple?R.peakTuple:this.gvar().sharedTuples[R.sharedTupleRecordsIndex];break;case"cvar":N=R.peakTuple;break}if(N[M]!==0){if(p[M]===0){P=0;break}if(R.intermediateStartTuple)if(p[M]<R.intermediateStartTuple[M]||p[M]>R.intermediateEndTuple[M]){P=0;break}else p[M]<N[M]?P=P*(p[M]-R.intermediateStartTuple[M]+Number.EPSILON)/(N[M]-R.intermediateStartTuple[M]+Number.EPSILON):P=P*(R.intermediateEndTuple[M]-p[M]+Number.EPSILON)/(R.intermediateEndTuple[M]-N[M]+Number.EPSILON);else{if(p[M]<Math.min(0,N[M])||p[M]>Math.max(0,N[M])){P=0;break}P=(P*p[M]+Number.EPSILON)/(N[M]+Number.EPSILON)}}}if(P===0)continue;let L=R.privatePoints.length?R.privatePoints:x;if(h==="gvar"&&d.glyph&&d.glyph.isComposite)this.transformComponents(d.glyph,E,l,L,R,P);else if(L.length===0)for(let M=0;M<E.length;M++){let N=E[M];h==="gvar"?E[M]={x:Math.round(N.x+R.deltas[M]*P),y:Math.round(N.y+R.deltasY[M]*P),onCurve:N.onCurve,lastPointOfContour:N.lastPointOfContour}:h==="cvar"&&(E[M]=Math.round(N+R.deltas[M]*P))}else{let M;h==="gvar"?M=E.map(lc):h==="cvar"&&(M=E);let N=Array(i.length).fill(!1);for(let z=0;z<L.length;z++){let vt=L[z];if(vt<i.length){let pt=M[vt];h==="gvar"?(N[vt]=!0,pt.x+=R.deltas[z]*P,pt.y+=R.deltasY[z]*P):h==="cvar"&&(E[vt]=Math.round(pt+R.deltas[z]*P))}}if(h==="gvar"){this.interpolatePoints(M,E,N);for(let z=0;z<i.length;z++){let vt=M[z].x-E[z].x,pt=M[z].y-E[z].y;E[z].x=Math.round(E[z].x+vt),E[z].y=Math.round(E[z].y+pt)}}}}return E}getTransform(s,i){Number.isInteger(s)&&(s=this.font.glyphs.get(s));let l=s.getBlendPath,h=!!(s.points&&s.points.length),d=s;if(l||h){if(i||(i=this.font.variation.get()),h){let p=this.gvar()&&this.gvar().glyphVariations[s.index];if(p){let y=s.points,x=this.applyTupleVariationStore(p,y,i,"gvar",{glyph:s});d=new $n(Object.assign({},s,{points:x,path:zi(x)}))}}else if(l){let p=s.getBlendPath(i);d=new $n(Object.assign({},s,{path:p}))}}return this.font.tables.hvar&&(s._advanceWidth=typeof s._advanceWidth<"u"?s._advanceWidth:s.advanceWidth,s.advanceWidth=d.advanceWidth=Math.round(s._advanceWidth+this.getVariableAdjustment(d.index,"hvar","advanceWidth",i)),s._leftSideBearing=typeof s._leftSideBearing<"u"?s._leftSideBearing:s.leftSideBearing,s.leftSideBearing=d.leftSideBearing=Math.round(s._leftSideBearing+this.getVariableAdjustment(d.index,"hvar","lsb",i))),d}getCvarTransform(s){let i=this.font.tables.cvt,l=this.cvar();return!i||!i.length||!l||!l.headers.length?i:this.applyTupleVariationStore(l,i,s,"cvar")}getVariableAdjustment(s,i,l,h){h=h||this.font.variation.get();let d,p,y=this.font.tables[i];if(!y)throw Error(`trying to get variation adjustment from non-existent table "${y}"`);if(!y.itemVariationStore)throw Error(`trying to get variation adjustment from table "${y}" which does not have an itemVariationStore`);let x=y[l]&&y[l].map.length;if(x){let A=s;A>=x&&(A=x-1),{outerIndex:d,innerIndex:p}=y[l].map[A]}else d=0,p=s;return this.getDelta(y.itemVariationStore,d,p,h)}getDelta(s,i,l,h){if(i>=s.itemVariationSubtables.length)return 0;let d=s.itemVariationSubtables[i];if(l>=d.deltaSets.length)return 0;let p=d.deltaSets[l],y=this.getBlendVector(s,i,h),x=0;for(let A=0;A<d.regionIndexes.length;A++)x+=p[A]*y[A];return x}getBlendVector(s,i,l){l||(l=this.font.variation.get());let h=s.itemVariationSubtables[i],d=this.getNormalizedCoords(l),p=[];for(let y=0;y<h.regionIndexes.length;y++){let x=1,A=h.regionIndexes[y],E=s.variationRegions[A].regionAxes;for(let C=0;C<E.length;C++){let R=E[C],P;R.startCoord>R.peakCoord||R.peakCoord>R.endCoord||R.startCoord<0&&R.endCoord>0&&R.peakCoord!==0||R.peakCoord===0?P=1:d[C]<R.startCoord||d[C]>R.endCoord?P=0:d[C]===R.peakCoord?P=1:d[C]<R.peakCoord?P=(d[C]-R.startCoord+Number.EPSILON)/(R.peakCoord-R.startCoord+Number.EPSILON):P=(R.endCoord-d[C]+Number.EPSILON)/(R.endCoord-R.peakCoord+Number.EPSILON),x*=P}p[y]=x}return p}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Tp=class{constructor(s){this.font=s,this.process=new Ap(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let s=this.getDefaultInstanceIndex();s>-1?this.set(s):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((s,i)=>(s[i.tag]=i.defaultValue,s),{})}getDefaultInstanceIndex(){let s=this.getDefaultCoordinates(),i=this.getInstanceIndex(s);return i<0&&(i=this.fvar().instances.findIndex(l=>l.name&&l.name.en==="Regular")),i}getInstanceIndex(s){return this.fvar().instances.findIndex(i=>Object.keys(s).every(l=>i.coordinates[l]===s[l]))}getInstance(s){return this.fvar().instances&&this.fvar().instances[s]}set(s){let i;if(Number.isInteger(s)){let l=this.getInstance(s);if(!l)throw Error(`Invalid instance index ${s}`);i={...l.coordinates}}else i=s,this.process.normalizeCoordTags(i);i=Object.assign({},this.font.defaultRenderOptions.variation,i),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:i})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},pc=1e6,sr=64,rr=1e4,gc,wn,mc,Wi;function bc(s){this.font=s,this.getCommands=function(i){return fc.getPath(i).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Cp(s){return s}function yc(s){return Math.sign(s)*Math.round(Math.abs(s))}function wp(s){return Math.sign(s)*Math.round(Math.abs(s*2))/2}function Ep(s){return Math.sign(s)*(Math.round(Math.abs(s)+.5)-.5)}function kp(s){return Math.sign(s)*Math.ceil(Math.abs(s))}function Ip(s){return Math.sign(s)*Math.floor(Math.abs(s))}var vc=function(s){let i=this.srPeriod,l=this.srPhase,h=this.srThreshold,d=1;return s<0&&(s=-s,d=-1),s+=h-l,s=Math.trunc(s/i)*i,s+=l,s<0?l*d:s*d},We={x:1,y:0,axis:"x",distance:function(s,i,l,h){return(l?s.xo:s.x)-(h?i.xo:i.x)},interpolate:function(s,i,l,h){let d,p,y,x,A,E,C;if(!h||h===this){if(d=s.xo-i.xo,p=s.xo-l.xo,A=i.x-i.xo,E=l.x-l.xo,y=Math.abs(d),x=Math.abs(p),C=y+x,C===0){s.x=s.xo+(A+E)/2;return}s.x=s.xo+(A*x+E*y)/C;return}if(d=h.distance(s,i,!0,!0),p=h.distance(s,l,!0,!0),A=h.distance(i,i,!1,!0),E=h.distance(l,l,!1,!0),y=Math.abs(d),x=Math.abs(p),C=y+x,C===0){We.setRelative(s,s,(A+E)/2,h,!0);return}We.setRelative(s,s,(A*x+E*y)/C,h,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(s,i,l,h,d){if(!h||h===this){s.x=(d?i.xo:i.x)+l;return}let p=d?i.xo:i.x,y=d?i.yo:i.y,x=p+l*h.x,A=y+l*h.y;s.x=x+(s.y-A)/h.normalSlope},slope:0,touch:function(s){s.xTouched=!0},touched:function(s){return s.xTouched},untouch:function(s){s.xTouched=!1}},qe={x:0,y:1,axis:"y",distance:function(s,i,l,h){return(l?s.yo:s.y)-(h?i.yo:i.y)},interpolate:function(s,i,l,h){let d,p,y,x,A,E,C;if(!h||h===this){if(d=s.yo-i.yo,p=s.yo-l.yo,A=i.y-i.yo,E=l.y-l.yo,y=Math.abs(d),x=Math.abs(p),C=y+x,C===0){s.y=s.yo+(A+E)/2;return}s.y=s.yo+(A*x+E*y)/C;return}if(d=h.distance(s,i,!0,!0),p=h.distance(s,l,!0,!0),A=h.distance(i,i,!1,!0),E=h.distance(l,l,!1,!0),y=Math.abs(d),x=Math.abs(p),C=y+x,C===0){qe.setRelative(s,s,(A+E)/2,h,!0);return}qe.setRelative(s,s,(A*x+E*y)/C,h,!0)},normalSlope:0,setRelative:function(s,i,l,h,d){if(!h||h===this){s.y=(d?i.yo:i.y)+l;return}let p=d?i.xo:i.x,y=d?i.yo:i.y,x=p+l*h.x,A=y+l*h.y;s.y=A+h.normalSlope*(s.x-x)},slope:Number.POSITIVE_INFINITY,touch:function(s){s.yTouched=!0},touched:function(s){return s.yTouched},untouch:function(s){s.yTouched=!1}};Object.freeze(We),Object.freeze(qe);function ls(s,i){this.x=s,this.y=i,this.axis=void 0,this.slope=i/s,this.normalSlope=-s/i,Object.freeze(this)}ls.prototype.distance=function(s,i,l,h){return this.x*We.distance(s,i,l,h)+this.y*qe.distance(s,i,l,h)},ls.prototype.interpolate=function(s,i,l,h){let d,p,y,x,A,E,C;if(y=h.distance(s,i,!0,!0),x=h.distance(s,l,!0,!0),d=h.distance(i,i,!1,!0),p=h.distance(l,l,!1,!0),A=Math.abs(y),E=Math.abs(x),C=A+E,C===0){this.setRelative(s,s,(d+p)/2,h,!0);return}this.setRelative(s,s,(d*E+p*A)/C,h,!0)},ls.prototype.setRelative=function(s,i,l,h,d){h=h||this;let p=d?i.xo:i.x,y=d?i.yo:i.y,x=p+l*h.x,A=y+l*h.y,E=h.normalSlope,C=this.slope,R=s.x,P=s.y;s.x=(C*R-E*x+A-P)/(C-E),s.y=C*(s.x-R)+P},ls.prototype.touch=function(s){s.xTouched=!0,s.yTouched=!0};function cs(s,i){let l=Math.sqrt(s*s+i*i);return s/=l,i/=l,s===1&&i===0?We:s===0&&i===1?qe:new ls(s,i)}function tn(s,i,l,h){this.x=this.xo=Math.round(s*64)/64,this.y=this.yo=Math.round(i*64)/64,this.lastPointOfContour=l,this.onCurve=h,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}tn.prototype.nextTouched=function(s){let i=this.nextPointOnContour;for(;!s.touched(i)&&i!==this;)i=i.nextPointOnContour;return i},tn.prototype.prevTouched=function(s){let i=this.prevPointOnContour;for(;!s.touched(i)&&i!==this;)i=i.prevPointOnContour;return i};var us=Object.freeze(new tn(0,0)),Pp={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function on(s,i){switch(this.env=s,this.stack=[],this.prog=i,s){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=We,this.round=yc}}bc.prototype.exec=function(s,i){if(typeof i!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let l=this.font,h=this._prepState;if(!h||h.ppem!==i){let d=this._fpgmState;if(!d){on.prototype=Pp,d=this._fpgmState=new on("fpgm",l.tables.fpgm),d.funcs=[],d.font=l,d.instructionCount=0,d.callDepth=0;try{wn(d)}catch(y){console.log("Hinting error in FPGM:"+y),this._errorState=3;return}}on.prototype=d,h=this._prepState=new on("prep",l.tables.prep),h.ppem=i,h.instructionCount=0,h.callDepth=0;let p=l.variation&&l.variation.process.getCvarTransform()||l.tables.cvt;if(p){let y=h.cvt=new Array(p.length),x=i/l.unitsPerEm;for(let A=0;A<p.length;A++)y[A]=p[A]*x}else h.cvt=[];try{wn(h)}catch(y){this._errorState<2&&console.log("Hinting error in PREP:"+y),this._errorState=2}}if(!(this._errorState>1))try{return mc(s,h)}catch(d){this._errorState<1&&(console.log("Hinting error:"+d),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},mc=function(s,i){let l=i.ppem/i.font.unitsPerEm,h=l,d=s.components,p,y,x;if(on.prototype=i,!d)x=new on("glyf",s.instructions),x.instructionCount=0,x.callDepth=0,Wi(s,x,l,h),y=x.gZone;else{let A=i.font;y=[],p=[];for(let E=0;E<d.length;E++){let C=d[E],R=A.glyphs.get(C.glyphIndex);x=new on("glyf",R.instructions),x.instructionCount=0,x.callDepth=0,Wi(R,x,l,h);let P=Math.round(C.dx*l),L=Math.round(C.dy*h),M=x.gZone,N=x.contours;for(let vt=0;vt<M.length;vt++){let pt=M[vt];pt.xTouched=pt.yTouched=!1,pt.xo=pt.x=pt.x+P,pt.yo=pt.y=pt.y+L}let z=y.length;y.push.apply(y,M);for(let vt=0;vt<N.length;vt++)p.push(N[vt]+z)}s.instructions&&!x.inhibitGridFit&&(x=new on("glyf",s.instructions),x.gZone=x.z0=x.z1=x.z2=y,x.contours=p,y.push(new tn(0,0),new tn(Math.round(s.advanceWidth*l),0)),wn(x),y.length-=2)}return y},Wi=function(s,i,l,h){let d=s.points||[],p=d.length,y=i.gZone=i.z0=i.z1=i.z2=[],x=i.contours=[],A;for(let R=0;R<p;R++)A=d[R],y[R]=new tn(A.x*l,A.y*h,A.lastPointOfContour,A.onCurve);let E,C;for(let R=0;R<p;R++)A=y[R],E||(E=A,x.push(R)),A.lastPointOfContour?(A.nextPointOnContour=E,E.prevPointOnContour=A,E=void 0):(C=y[R+1],A.nextPointOnContour=C,C.prevPointOnContour=A);i.inhibitGridFit||(y.push(new tn(0,0),new tn(Math.round(s.advanceWidth*l),0)),wn(i),y.length-=2)},wn=function(s){let i=s.prog;if(!i)return;let l=i.length,h;for(s.ip=0;s.ip<l;s.ip++){if(++s.instructionCount>pc)throw new Error("Hinting instructions exceeded maximum of "+pc);if(h=gc[i[s.ip]],!h)throw new Error("unknown instruction: 0x"+Number(i[s.ip]).toString(16));h(s)}};function ir(s){let i=s.tZone=new Array(s.gZone.length);for(let l=0;l<i.length;l++)i[l]=new tn(0,0)}function xc(s,i){let l=s.prog,h=s.ip,d=1,p;do if(p=l[++h],p===88)d++;else if(p===89)d--;else if(p===64)h+=l[h+1]+1;else if(p===65)h+=2*l[h+1]+1;else if(p>=176&&p<=183)h+=p-176+1;else if(p>=184&&p<=191)h+=(p-184+1)*2;else if(i&&d===1&&p===27)break;while(d>0);s.ip=h}function Sc(s,i){i.fv=i.pv=i.dpv=s}function Ac(s,i){i.pv=i.dpv=s}function Tc(s,i){i.fv=s}function Cc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],y=i.z1[d],x,A;s?(x=p.y-y.y,A=y.x-p.x):(x=y.x-p.x,A=y.y-p.y),i.pv=i.dpv=cs(x,A)}function wc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],y=i.z1[d],x,A;s?(x=p.y-y.y,A=y.x-p.x):(x=y.x-p.x,A=y.y-p.y),i.fv=cs(x,A)}function Rp(s){let i=s.stack,l=i.pop(),h=i.pop();s.pv=s.dpv=cs(h,l)}function Op(s){let i=s.stack,l=i.pop(),h=i.pop();s.fv=cs(h,l)}function Mp(s){let i=s.stack,l=s.pv;i.push(l.x*16384),i.push(l.y*16384)}function Lp(s){let i=s.stack,l=s.fv;i.push(l.x*16384),i.push(l.y*16384)}function Fp(s){s.fv=s.pv}function Dp(s){let i=s.stack,l=i.pop(),h=i.pop(),d=i.pop(),p=i.pop(),y=i.pop(),x=s.z0,A=s.z1,E=x[l],C=x[h],R=A[d],P=A[p],L=s.z2[y],M=E.x,N=E.y,z=C.x,vt=C.y,pt=R.x,At=R.y,It=P.x,Nt=P.y,Bt=(M-z)*(At-Nt)-(N-vt)*(pt-It),Gt=M*vt-N*z,Jt=pt*Nt-At*It;L.x=(Gt*(pt-It)-Jt*(M-z))/Bt,L.y=(Gt*(At-Nt)-Jt*(N-vt))/Bt}function _p(s){s.rp0=s.stack.pop()}function Np(s){s.rp1=s.stack.pop()}function Up(s){s.rp2=s.stack.pop()}function Bp(s){let i=s.stack.pop();switch(s.zp0=i,i){case 0:s.tZone||ir(s),s.z0=s.tZone;break;case 1:s.z0=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function Gp(s){let i=s.stack.pop();switch(s.zp1=i,i){case 0:s.tZone||ir(s),s.z1=s.tZone;break;case 1:s.z1=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function Hp(s){let i=s.stack.pop();switch(s.zp2=i,i){case 0:s.tZone||ir(s),s.z2=s.tZone;break;case 1:s.z2=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function jp(s){let i=s.stack.pop();switch(s.zp0=s.zp1=s.zp2=i,i){case 0:s.tZone||ir(s),s.z0=s.z1=s.z2=s.tZone;break;case 1:s.z0=s.z1=s.z2=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function Vp(s){s.loop=s.stack.pop(),s.loop>rr&&(s.loop=rr)}function $p(s){s.round=yc}function zp(s){s.round=Ep}function Wp(s){let i=s.stack.pop();s.minDis=i/64}function Xp(s){xc(s,!1)}function Yp(s){let i=s.stack.pop();s.ip+=i-1}function Kp(s){let i=s.stack.pop();s.cvCutIn=i/64}function Zp(s){let i=s.stack;i.push(i[i.length-1])}function Xi(s){s.stack.pop()}function Qp(s){s.stack.length=0}function Jp(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l),i.push(h)}function qp(s){let i=s.stack;i.push(i.length)}function tg(s){let i=s.stack,l=i.pop(),h=i.pop();if(h>rr&&(h=rr),++s.callDepth>sr)throw new Error("Hinting call depth exceeded maximum of "+sr);let d=s.ip,p=s.prog;s.prog=s.funcs[l];for(let y=0;y<h;y++)wn(s);s.ip=d,s.prog=p,s.callDepth--}function eg(s){let i=s.stack.pop();if(++s.callDepth>sr)throw new Error("Hinting call depth exceeded maximum of "+sr);let l=s.ip,h=s.prog;s.prog=s.funcs[i],wn(s),s.ip=l,s.prog=h,s.callDepth--}function ng(s){let i=s.stack,l=i.pop();i.push(i[i.length-l])}function sg(s){let i=s.stack,l=i.pop();i.push(i.splice(i.length-l,1)[0])}function rg(s){if(s.env!=="fpgm")throw new Error("FDEF not allowed here");let i=s.stack,l=s.prog,h=s.ip,d=i.pop(),p=h;for(;l[++h]!==45;);s.ip=h,s.funcs[d]=l.slice(p+1,h)}function Ec(s,i){let l=i.stack.pop(),h=i.z0[l],d=i.fv,p=i.pv,y=p.distance(h,us);s&&(y=i.round(y)),d.setRelative(h,us,y,p),d.touch(h),i.rp0=i.rp1=l}function kc(s,i){let l=i.z2,h=l.length-2,d,p,y;for(let x=0;x<h;x++)d=l[x],!s.touched(d)&&(p=d.prevTouched(s),p!==d&&(y=d.nextTouched(s),p===y&&s.setRelative(d,d,s.distance(p,p,!1,!0),s,!0),s.interpolate(d,p,y,s)))}function Ic(s,i){let l=i.stack,h=s?i.rp1:i.rp2,d=(s?i.z0:i.z1)[h],p=i.fv,y=i.pv,x=i.loop,A=i.z2;for(;x--;){let E=l.pop(),C=A[E],R=y.distance(d,d,!1,!0);p.setRelative(C,C,R,y),p.touch(C)}i.loop=1}function Pc(s,i){let l=i.stack,h=s?i.rp1:i.rp2,d=(s?i.z0:i.z1)[h],p=i.fv,y=i.pv,x=l.pop(),A=i.z2[i.contours[x]],E=A,C=y.distance(d,d,!1,!0);do E!==d&&p.setRelative(E,E,C,y),E=E.nextPointOnContour;while(E!==A)}function Rc(s,i){let l=i.stack,h=s?i.rp1:i.rp2,d=(s?i.z0:i.z1)[h],p=i.fv,y=i.pv,x=l.pop(),A;switch(x){case 0:A=i.tZone;break;case 1:A=i.gZone;break;default:throw new Error("Invalid zone")}let E,C=y.distance(d,d,!1,!0),R=A.length-2;for(let P=0;P<R;P++)E=A[P],p.setRelative(E,E,C,y)}function ig(s){let i=s.stack,l=s.loop,h=s.fv,d=i.pop()/64,p=s.z2;for(;l--;){let y=i.pop(),x=p[y];h.setRelative(x,x,d),h.touch(x)}s.loop=1}function og(s){let i=s.stack,l=s.rp1,h=s.rp2,d=s.loop,p=s.z0[l],y=s.z1[h],x=s.fv,A=s.dpv,E=s.z2;for(;d--;){let C=i.pop(),R=E[C];x.interpolate(R,p,y,A),x.touch(R)}s.loop=1}function Oc(s,i){let l=i.stack,h=l.pop()/64,d=l.pop(),p=i.z1[d],y=i.z0[i.rp0],x=i.fv,A=i.pv;x.setRelative(p,y,h,A),x.touch(p),i.rp1=i.rp0,i.rp2=d,s&&(i.rp0=d)}function ag(s){let i=s.stack,l=s.rp0,h=s.z0[l],d=s.loop,p=s.fv,y=s.pv,x=s.z1;for(;d--;){let A=i.pop(),E=x[A];p.setRelative(E,h,0,y),p.touch(E)}s.loop=1}function lg(s){s.round=wp}function Mc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z0[d],y=i.fv,x=i.pv,A=i.cvt[h],E=x.distance(p,us);s&&(Math.abs(E-A)<i.cvCutIn&&(E=A),E=i.round(E)),y.setRelative(p,us,E,x),i.zp0===0&&(p.xo=p.x,p.yo=p.y),y.touch(p),i.rp0=i.rp1=d}function cg(s){let i=s.prog,l=s.ip,h=s.stack,d=i[++l];for(let p=0;p<d;p++)h.push(i[++l]);s.ip=l}function ug(s){let i=s.ip,l=s.prog,h=s.stack,d=l[++i];for(let p=0;p<d;p++){let y=l[++i]<<8|l[++i];y&32768&&(y=-((y^65535)+1)),h.push(y)}s.ip=i}function hg(s){let i=s.stack,l=s.store;l||(l=s.store=[]);let h=i.pop(),d=i.pop();l[d]=h}function dg(s){let i=s.stack,l=s.store,h=i.pop(),d=l&&l[h]||0;i.push(d)}function fg(s){let i=s.stack,l=i.pop(),h=i.pop();s.cvt[h]=l/64}function pg(s){let i=s.stack,l=i.pop();i.push(s.cvt[l]*64)}function Lc(s,i){let l=i.stack,h=l.pop(),d=i.z2[h];l.push(i.dpv.distance(d,us,s,!1)*64)}function Fc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z1[h],y=i.z0[d],x=i.dpv.distance(y,p,s,s);i.stack.push(Math.round(x*64))}function gg(s){s.stack.push(s.ppem)}function mg(s){s.autoFlip=!0}function bg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h<l?1:0)}function yg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h<=l?1:0)}function vg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h>l?1:0)}function xg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h>=l?1:0)}function Sg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l===h?1:0)}function Ag(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l!==h?1:0)}function Tg(s){let i=s.stack,l=i.pop();i.push(Math.trunc(l)&1?1:0)}function Cg(s){let i=s.stack,l=i.pop();i.push(Math.trunc(l)&1?0:1)}function wg(s){let i=s.stack.pop(),l;i||xc(s,!0)}function Eg(s){}function kg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l&&h?1:0)}function Ig(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l||h?1:0)}function Pg(s){let i=s.stack,l=i.pop();i.push(l?0:1)}function Yi(s,i){let l=i.stack,h=l.pop(),d=i.fv,p=i.pv,y=i.ppem,x=i.deltaBase+(s-1)*16,A=i.deltaShift,E=i.z0;for(let C=0;C<h;C++){let R=l.pop(),P=l.pop();if(x+((P&240)>>4)!==y)continue;let M=(P&15)-8;M>=0&&M++;let N=E[R];d.setRelative(N,N,M*A,p)}}function Rg(s){let l=s.stack.pop();s.deltaBase=l}function Og(s){let l=s.stack.pop();s.deltaShift=Math.pow(.5,l)}function Mg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h+l)}function Lg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h-l)}function Fg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h*64/l)}function Dg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h*l/64)}function _g(s){let i=s.stack,l=i.pop();i.push(Math.abs(l))}function Ng(s){let i=s.stack,l=i.pop();i.push(-l)}function Ug(s){let i=s.stack,l=i.pop();i.push(Math.floor(l/64)*64)}function Bg(s){let i=s.stack,l=i.pop();i.push(Math.ceil(l/64)*64)}function or(s,i){let l=i.stack,h=l.pop();l.push(i.round(h/64)*64)}function Gg(s){let i=s.stack,l=i.pop(),h=i.pop();s.cvt[h]=l*s.ppem/s.font.unitsPerEm}function Ki(s,i){let l=i.stack,h=l.pop(),d=i.ppem,p=i.deltaBase+(s-1)*16,y=i.deltaShift;for(let x=0;x<h;x++){let A=l.pop(),E=l.pop();if(p+((E&240)>>4)!==d)continue;let R=(E&15)-8;R>=0&&R++;let P=R*y;i.cvt[A]+=P}}function Hg(s){let i=s.stack.pop();s.round=vc;let l;switch(i&192){case 0:l=.5;break;case 64:l=1;break;case 128:l=2;break;default:throw new Error("invalid SROUND value")}switch(s.srPeriod=l,i&48){case 0:s.srPhase=0;break;case 16:s.srPhase=.25*l;break;case 32:s.srPhase=.5*l;break;case 48:s.srPhase=.75*l;break;default:throw new Error("invalid SROUND value")}i&=15,i===0?s.srThreshold=0:s.srThreshold=(i/8-.5)*l}function jg(s){let i=s.stack.pop();s.round=vc;let l;switch(i&192){case 0:l=Math.sqrt(2)/2;break;case 64:l=Math.sqrt(2);break;case 128:l=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(s.srPeriod=l,i&48){case 0:s.srPhase=0;break;case 16:s.srPhase=.25*l;break;case 32:s.srPhase=.5*l;break;case 48:s.srPhase=.75*l;break;default:throw new Error("invalid S45ROUND value")}i&=15,i===0?s.srThreshold=0:s.srThreshold=(i/8-.5)*l}function Vg(s){s.round=Cp}function $g(s){s.round=kp}function zg(s){s.round=Ip}function Wg(s){let i=s.stack.pop()}function Dc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],y=i.z1[d],x,A;s?(x=p.y-y.y,A=y.x-p.x):(x=y.x-p.x,A=y.y-p.y),i.dpv=cs(x,A)}function Xg(s){let i=s.stack,l=i.pop(),h=0;l&1&&(h=35),l&32&&(h|=4096),i.push(h)}function Yg(s){let i=s.stack,l=i.pop(),h=i.pop(),d=i.pop();i.push(h),i.push(l),i.push(d)}function Kg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(Math.max(h,l))}function Zg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(Math.min(h,l))}function Qg(s){let i=s.stack.pop()}function Jg(s){let i=s.stack.pop(),l=s.stack.pop();switch(i){case 1:s.inhibitGridFit=!!l;return;case 2:s.ignoreCvt=!!l;return;default:throw new Error("invalid INSTCTRL[] selector")}}function an(s,i){let l=i.stack,h=i.prog,d=i.ip;for(let p=0;p<s;p++)l.push(h[++d]);i.ip=d}function ln(s,i){let l=i.ip,h=i.prog,d=i.stack;for(let p=0;p<s;p++){let y=h[++l]<<8|h[++l];y&32768&&(y=-((y^65535)+1)),d.push(y)}i.ip=l}function mt(s,i,l,h,d,p){let y=p.stack,x=s&&y.pop(),A=y.pop(),E=p.rp0,C=p.z0[E],R=p.z1[A],P=p.minDis,L=p.fv,M=p.dpv,N,z,vt,pt;z=N=M.distance(R,C,!0,!0),vt=z>=0?1:-1,z=Math.abs(z),s&&(pt=p.cvt[x],h&&Math.abs(z-pt)<p.cvCutIn&&(z=pt)),l&&z<P&&(z=P),h&&(z=p.round(z)),L.setRelative(R,C,vt*z,M),L.touch(R),p.rp1=p.rp0,p.rp2=A,i&&(p.rp0=A)}gc=[Sc.bind(void 0,qe),Sc.bind(void 0,We),Ac.bind(void 0,qe),Ac.bind(void 0,We),Tc.bind(void 0,qe),Tc.bind(void 0,We),Cc.bind(void 0,0),Cc.bind(void 0,1),wc.bind(void 0,0),wc.bind(void 0,1),Rp,Op,Mp,Lp,Fp,Dp,_p,Np,Up,Bp,Gp,Hp,jp,Vp,$p,zp,Wp,Xp,Yp,Kp,void 0,void 0,Zp,Xi,Qp,Jp,qp,ng,sg,void 0,void 0,void 0,tg,eg,rg,void 0,Ec.bind(void 0,0),Ec.bind(void 0,1),kc.bind(void 0,qe),kc.bind(void 0,We),Ic.bind(void 0,0),Ic.bind(void 0,1),Pc.bind(void 0,0),Pc.bind(void 0,1),Rc.bind(void 0,0),Rc.bind(void 0,1),ig,og,Oc.bind(void 0,0),Oc.bind(void 0,1),ag,lg,Mc.bind(void 0,0),Mc.bind(void 0,1),cg,ug,hg,dg,fg,pg,Lc.bind(void 0,0),Lc.bind(void 0,1),void 0,Fc.bind(void 0,0),Fc.bind(void 0,1),gg,void 0,mg,void 0,void 0,bg,yg,vg,xg,Sg,Ag,Tg,Cg,wg,Eg,kg,Ig,Pg,Yi.bind(void 0,1),Rg,Og,Mg,Lg,Fg,Dg,_g,Ng,Ug,Bg,or.bind(void 0,0),or.bind(void 0,1),or.bind(void 0,2),or.bind(void 0,3),void 0,void 0,void 0,void 0,Gg,Yi.bind(void 0,2),Yi.bind(void 0,3),Ki.bind(void 0,1),Ki.bind(void 0,2),Ki.bind(void 0,3),Hg,jg,void 0,void 0,Vg,void 0,$g,zg,Xi,Xi,void 0,void 0,void 0,void 0,void 0,Wg,Dc.bind(void 0,0),Dc.bind(void 0,1),Xg,void 0,Yg,Kg,Zg,Qg,Jg,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,an.bind(void 0,1),an.bind(void 0,2),an.bind(void 0,3),an.bind(void 0,4),an.bind(void 0,5),an.bind(void 0,6),an.bind(void 0,7),an.bind(void 0,8),ln.bind(void 0,1),ln.bind(void 0,2),ln.bind(void 0,3),ln.bind(void 0,4),ln.bind(void 0,5),ln.bind(void 0,6),ln.bind(void 0,7),ln.bind(void 0,8),mt.bind(void 0,0,0,0,0,0),mt.bind(void 0,0,0,0,0,1),mt.bind(void 0,0,0,0,0,2),mt.bind(void 0,0,0,0,0,3),mt.bind(void 0,0,0,0,1,0),mt.bind(void 0,0,0,0,1,1),mt.bind(void 0,0,0,0,1,2),mt.bind(void 0,0,0,0,1,3),mt.bind(void 0,0,0,1,0,0),mt.bind(void 0,0,0,1,0,1),mt.bind(void 0,0,0,1,0,2),mt.bind(void 0,0,0,1,0,3),mt.bind(void 0,0,0,1,1,0),mt.bind(void 0,0,0,1,1,1),mt.bind(void 0,0,0,1,1,2),mt.bind(void 0,0,0,1,1,3),mt.bind(void 0,0,1,0,0,0),mt.bind(void 0,0,1,0,0,1),mt.bind(void 0,0,1,0,0,2),mt.bind(void 0,0,1,0,0,3),mt.bind(void 0,0,1,0,1,0),mt.bind(void 0,0,1,0,1,1),mt.bind(void 0,0,1,0,1,2),mt.bind(void 0,0,1,0,1,3),mt.bind(void 0,0,1,1,0,0),mt.bind(void 0,0,1,1,0,1),mt.bind(void 0,0,1,1,0,2),mt.bind(void 0,0,1,1,0,3),mt.bind(void 0,0,1,1,1,0),mt.bind(void 0,0,1,1,1,1),mt.bind(void 0,0,1,1,1,2),mt.bind(void 0,0,1,1,1,3),mt.bind(void 0,1,0,0,0,0),mt.bind(void 0,1,0,0,0,1),mt.bind(void 0,1,0,0,0,2),mt.bind(void 0,1,0,0,0,3),mt.bind(void 0,1,0,0,1,0),mt.bind(void 0,1,0,0,1,1),mt.bind(void 0,1,0,0,1,2),mt.bind(void 0,1,0,0,1,3),mt.bind(void 0,1,0,1,0,0),mt.bind(void 0,1,0,1,0,1),mt.bind(void 0,1,0,1,0,2),mt.bind(void 0,1,0,1,0,3),mt.bind(void 0,1,0,1,1,0),mt.bind(void 0,1,0,1,1,1),mt.bind(void 0,1,0,1,1,2),mt.bind(void 0,1,0,1,1,3),mt.bind(void 0,1,1,0,0,0),mt.bind(void 0,1,1,0,0,1),mt.bind(void 0,1,1,0,0,2),mt.bind(void 0,1,1,0,0,3),mt.bind(void 0,1,1,0,1,0),mt.bind(void 0,1,1,0,1,1),mt.bind(void 0,1,1,0,1,2),mt.bind(void 0,1,1,0,1,3),mt.bind(void 0,1,1,1,0,0),mt.bind(void 0,1,1,1,0,1),mt.bind(void 0,1,1,1,0,2),mt.bind(void 0,1,1,1,0,3),mt.bind(void 0,1,1,1,1,0),mt.bind(void 0,1,1,1,1,1),mt.bind(void 0,1,1,1,1,2),mt.bind(void 0,1,1,1,1,3)];var qg=bc;function Xn(s){this.char=s,this.state={},this.activeState=null}function Zi(s,i,l){this.contextName=l,this.startIndex=s,this.endOffset=i}function tm(s,i,l){this.contextName=s,this.openRange=null,this.ranges=[],this.checkStart=i,this.checkEnd=l}function he(s,i){this.context=s,this.index=i,this.length=s.length,this.current=s[i],this.backtrack=s.slice(0,i),this.lookahead=s.slice(i+1)}function ar(s){this.eventId=s,this.subscribers=[]}function em(s){let i=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let h=0;h<i.length;h++){let d=i[h];Object.defineProperty(this.events,d,{value:new ar(d)})}if(s)for(let h=0;h<i.length;h++){let d=i[h],p=s[d];typeof p=="function"&&this.events[d].subscribe(p)}let l=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let h=0;h<l.length;h++){let d=l[h];this.events[d].subscribe(this.updateContextsRanges)}}function Yt(s){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],em.call(this,s)}Xn.prototype.setState=function(s,i){return this.state[s]=i,this.activeState={key:s,value:this.state[s]},this.activeState},Xn.prototype.getState=function(s){return this.state[s]||null},Yt.prototype.inboundIndex=function(s){return s>=0&&s<this.tokens.length},Yt.prototype.composeRUD=function(s){let l=s.map(d=>this[d[0]].apply(this,d.slice(1).concat(!0))),h=d=>typeof d=="object"&&Object.prototype.hasOwnProperty.call(d,"FAIL");if(l.every(h))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:l.filter(h)};this.dispatch("composeRUD",[l.filter(d=>!h(d))])},Yt.prototype.replaceRange=function(s,i,l,h){i=i!==null?i:this.tokens.length;let d=l.every(p=>p instanceof Xn);if(!isNaN(s)&&this.inboundIndex(s)&&d){let p=this.tokens.splice.apply(this.tokens,[s,i].concat(l));return h||this.dispatch("replaceToken",[s,i,l]),[p,l]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},Yt.prototype.replaceToken=function(s,i,l){if(!isNaN(s)&&this.inboundIndex(s)&&i instanceof Xn){let h=this.tokens.splice(s,1,i);return l||this.dispatch("replaceToken",[s,i]),[h[0],i]}else return{FAIL:"replaceToken: invalid token or index."}},Yt.prototype.removeRange=function(s,i,l){i=isNaN(i)?this.tokens.length:i;let h=this.tokens.splice(s,i);return l||this.dispatch("removeRange",[h,s,i]),h},Yt.prototype.removeToken=function(s,i){if(!isNaN(s)&&this.inboundIndex(s)){let l=this.tokens.splice(s,1);return i||this.dispatch("removeToken",[l,s]),l}else return{FAIL:"removeToken: invalid token index."}},Yt.prototype.insertToken=function(s,i,l){return s.every(d=>d instanceof Xn)?(this.tokens.splice.apply(this.tokens,[i,0].concat(s)),l||this.dispatch("insertToken",[s,i]),s):{FAIL:"insertToken: invalid token(s)."}},Yt.prototype.registerModifier=function(s,i,l){this.events.newToken.subscribe(function(h,d){let p=[h,d],y=i===null||i.apply(this,p)===!0,x=[h,d];if(y){let A=l.apply(this,x);h.setState(s,A)}}),this.registeredModifiers.push(s)},ar.prototype.subscribe=function(s){return typeof s=="function"?this.subscribers.push(s)-1:{FAIL:`invalid '${this.eventId}' event handler`}},ar.prototype.unsubscribe=function(s){this.subscribers.splice(s,1)},he.prototype.setCurrentIndex=function(s){this.index=s,this.current=this.context[s],this.backtrack=this.context.slice(0,s),this.lookahead=this.context.slice(s+1)},he.prototype.get=function(s){switch(!0){case s===0:return this.current;case(s<0&&Math.abs(s)<=this.backtrack.length):return this.backtrack.slice(s)[0];case(s>0&&s<=this.lookahead.length):return this.lookahead[s-1];default:return null}},Yt.prototype.rangeToText=function(s){if(s instanceof Zi)return this.getRangeTokens(s).map(i=>i.char).join("")},Yt.prototype.getText=function(){return this.tokens.map(s=>s.char).join("")},Yt.prototype.getContext=function(s){let i=this.registeredContexts[s];return i||null},Yt.prototype.on=function(s,i){let l=this.events[s];return l?l.subscribe(i):null},Yt.prototype.dispatch=function(s,i){let l=this.events[s];if(l instanceof ar)for(let h=0;h<l.subscribers.length;h++)l.subscribers[h].apply(this,i||[])},Yt.prototype.registerContextChecker=function(s,i,l){if(this.getContext(s))return{FAIL:`context name '${s}' is already registered.`};if(typeof i!="function")return{FAIL:"missing context start check."};if(typeof l!="function")return{FAIL:"missing context end check."};let h=new tm(s,i,l);return this.registeredContexts[s]=h,this.contextCheckers.push(h),h},Yt.prototype.getRangeTokens=function(s){let i=s.startIndex+s.endOffset;return[].concat(this.tokens.slice(s.startIndex,i))},Yt.prototype.getContextRanges=function(s){let i=this.getContext(s);return i?i.ranges:{FAIL:`context checker '${s}' is not registered.`}},Yt.prototype.resetContextsRanges=function(){let s=this.registeredContexts;for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let l=s[i];l.ranges=[]}},Yt.prototype.updateContextsRanges=function(){this.resetContextsRanges();let s=this.tokens.map(i=>i.char);for(let i=0;i<s.length;i++){let l=new he(s,i);this.runContextCheck(l)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Yt.prototype.setEndOffset=function(s,i){let l=this.getContext(i).openRange.startIndex,h=new Zi(l,s,i),d=this.getContext(i).ranges;return h.rangeId=`${i}.${d.length}`,d.push(h),this.getContext(i).openRange=null,h},Yt.prototype.runContextCheck=function(s){let i=s.index;for(let l=0;l<this.contextCheckers.length;l++){let h=this.contextCheckers[l],d=h.contextName,p=this.getContext(d).openRange;if(!p&&h.checkStart(s)&&(p=new Zi(i,null,d),this.getContext(d).openRange=p,this.dispatch("contextStart",[d,i])),p&&h.checkEnd(s)){let y=i-p.startIndex+1,x=this.setEndOffset(y,d);this.dispatch("contextEnd",[d,x])}}},Yt.prototype.tokenize=function(s){this.tokens=[],this.resetContextsRanges();let i=Array.from(s);this.dispatch("start");for(let l=0;l<i.length;l++){let h=i[l],d=new he(i,l);this.dispatch("next",[d]),this.runContextCheck(d);let p=new Xn(h);this.tokens.push(p),this.dispatch("newToken",[p,d])}return this.dispatch("end",[this.tokens]),this.tokens};var nm=Yt;function cn(s){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(s)}function _c(s){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(s)}function un(s){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(s)}function lr(s){return/[\u0E00-\u0E7F]/.test(s)}function cr(s){return/[A-z]/.test(s)}function sm(s){return/\s/.test(s)}function Ae(s){this.font=s,this.features={}}function hn(s){this.id=s.id,this.tag=s.tag,this.substitution=s.substitution}function dn(s,i){if(!s)return-1;switch(i.format){case 1:return i.glyphs.indexOf(s);case 2:{let l=i.ranges;for(let h=0;h<l.length;h++){let d=l[h];if(s>=d.start&&s<=d.end){let p=s-d.start;return d.index+p}}break}default:return-1}return-1}function rm(s,i){return dn(s,i.coverage)===-1?null:s+i.deltaGlyphId}function im(s,i){let l=dn(s,i.coverage);return l===-1?null:i.substitute[l]}function Qi(s,i){let l=[];for(let h=0;h<s.length;h++){let d=s[h],p=i.current;p=Array.isArray(p)?p[0]:p;let y=dn(p,d);y!==-1&&l.push(y)}return l.length!==s.length?-1:l}function om(s,i){let l=i.inputCoverage.length+i.lookaheadCoverage.length+i.backtrackCoverage.length;if(s.context.length<l)return[];let h=Qi(i.inputCoverage,s);if(h===-1)return[];let d=i.inputCoverage.length-1;if(s.lookahead.length<i.lookaheadCoverage.length)return[];let p=s.lookahead.slice(d);for(;p.length&&un(p[0].char);)p.shift();let y=new he(p,0),x=Qi(i.lookaheadCoverage,y),A=[].concat(s.backtrack);for(A.reverse();A.length&&un(A[0].char);)A.shift();if(A.length<i.backtrackCoverage.length)return[];let E=new he(A,0),C=Qi(i.backtrackCoverage,E),R=h.length===i.inputCoverage.length&&x.length===i.lookaheadCoverage.length&&C.length===i.backtrackCoverage.length,P=[];if(R)for(let L=0;L<i.lookupRecords.length;L++){let M=i.lookupRecords[L],N=M.lookupListIndex,z=this.getLookupByIndex(N);for(let vt=0;vt<z.subtables.length;vt++){let pt=z.subtables[vt],At,It=this.getSubstitutionType(z,pt);if(It==="71"?(It=this.getSubstitutionType(pt,pt.extension),At=this.getLookupMethod(pt,pt.extension),pt=pt.extension):At=this.getLookupMethod(z,pt),It==="12"){let Nt=s.get(M.sequenceIndex),Bt=At(Nt);Bt&&P.push(Bt)}else if(It==="21"){let Nt=s.get(M.sequenceIndex),Bt=At(Nt);Bt&&P.push(Bt)}else throw new Error(`Substitution type ${It} is not supported in chaining substitution`)}}return P}function am(s,i){let l=s.current,h=dn(l,i.coverage);if(h===-1)return null;let d,p=i.ligatureSets[h];for(let y=0;y<p.length;y++){d=p[y];for(let x=0;x<d.components.length;x++){let A=s.lookahead[x],E=d.components[x];if(A!==E)break;if(x===d.components.length-1)return d}}return null}function lm(s,i){let l=s.current;if(dn(l,i.coverage)===-1)return null;for(let d of i.ruleSets)for(let p of d){let y=!0;for(let x=0;x<p.input.length;x++)if(s.lookahead[x]!==p.input[x]){y=!1;break}if(y){let x=[];x.push(l);for(let E=0;E<p.input.length;E++)x.push(p.input[E]);let A=(E,C)=>{let{lookupListIndex:R,sequenceIndex:P}=C,{subtables:L}=this.getLookupByIndex(R);for(let M of L)dn(E[P],M.coverage)!==-1&&(E[P]=M.deltaGlyphId)};for(let E=0;E<p.lookupRecords.length;E++){let C=p.lookupRecords[E];A(x,C)}return x}}return null}function cm(s,i){if(s.context.length<i.coverages.length)return[];for(let h=0;h<i.coverages.length;h++){let d=s.get(h);if(d=Array.isArray(d)?d[0]:d,dn(d,i.coverages[h])===-1)return[]}let l=[];for(let h=0;h<i.lookupRecords.length;h++){let d=i.lookupRecords[h],p=d.lookupListIndex,y=this.getLookupByIndex(p);for(let x=0;x<y.subtables.length;x++){let A=y.subtables[x],E,C=this.getSubstitutionType(y,A);if(C==="71"?(C=this.getSubstitutionType(A,A.extension),E=this.getLookupMethod(A,A.extension),A=A.extension):E=this.getLookupMethod(y,A),C==="12"){let R=s.get(d.sequenceIndex),P=E(R);P&&l.push(P)}else if(C==="21"){let R=s.get(d.sequenceIndex),P=E(R);P&&l.push(P)}}}return l}function um(s,i){let l=dn(s,i.coverage);return l===-1?null:i.sequences[l]}Ae.prototype.getDefaultScriptFeaturesIndexes=function(){let s=this.font.tables.gsub.scripts;for(let i=0;i<s.length;i++){let l=s[i];if(l.tag==="DFLT")return l.script.defaultLangSys.featureIndexes}return[]},Ae.prototype.getScriptFeaturesIndexes=function(s){if(!this.font.tables.gsub)return[];if(!s)return this.getDefaultScriptFeaturesIndexes();let l=this.font.tables.gsub.scripts;for(let h=0;h<l.length;h++){let d=l[h];if(d.tag===s&&d.script.defaultLangSys)return d.script.defaultLangSys.featureIndexes;{let p=d.langSysRecords;if(p)for(let y=0;y<p.length;y++){let x=p[y];if(x.tag===s)return x.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Ae.prototype.mapTagsToFeatures=function(s,i){let l={};for(let h=0;h<s.length;h++){let d=s[h].tag,p=s[h].feature;l[d]=p}this.features[i].tags=l},Ae.prototype.getScriptFeatures=function(s){let i=this.features[s];if(Object.prototype.hasOwnProperty.call(this.features,s))return i;let l=this.getScriptFeaturesIndexes(s);if(!l)return null;let h=this.font.tables.gsub;return i=l.map(d=>h.features[d]),this.features[s]=i,this.mapTagsToFeatures(i,s),i},Ae.prototype.getSubstitutionType=function(s,i){let l=s.lookupType.toString(),h=i.substFormat.toString();return l+h},Ae.prototype.getLookupMethod=function(s,i){let l=this.getSubstitutionType(s,i);switch(l){case"11":return h=>rm.apply(this,[h,i]);case"12":return h=>im.apply(this,[h,i]);case"63":return h=>om.apply(this,[h,i]);case"41":return h=>am.apply(this,[h,i]);case"21":return h=>um.apply(this,[h,i]);case"51":return h=>lm.apply(this,[h,i]);case"53":return h=>cm.apply(this,[h,i]);default:throw new Error(`substitutionType : ${l} lookupType: ${s.lookupType} - substFormat: ${i.substFormat} is not yet supported`)}},Ae.prototype.lookupFeature=function(s){let i=s.contextParams,l=i.index,h=this.getFeature({tag:s.tag,script:s.script});if(!h)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${s.tag}' for script '${s.script}'.`);let d=this.getFeatureLookups(h),p=[].concat(i.context);for(let y=0;y<d.length;y++){let x=d[y],A=this.getLookupSubtables(x);for(let E=0;E<A.length;E++){let C=A[E],R=this.getSubstitutionType(x,C),P;R==="71"?(R=this.getSubstitutionType(C,C.extension),P=this.getLookupMethod(C,C.extension),C=C.extension):P=this.getLookupMethod(x,C);let L;switch(R){case"11":L=P(i.current),L&&p.splice(l,1,new hn({id:11,tag:s.tag,substitution:L}));break;case"12":L=P(i.current),L&&p.splice(l,1,new hn({id:12,tag:s.tag,substitution:L}));break;case"63":L=P(i),Array.isArray(L)&&L.length&&p.splice(l,1,new hn({id:63,tag:s.tag,substitution:L}));break;case"41":L=P(i),L&&p.splice(l,1,new hn({id:41,tag:s.tag,substitution:L}));break;case"21":L=P(i.current),L&&p.splice(l,1,new hn({id:21,tag:s.tag,substitution:L}));break;case"51":case"53":L=P(i),Array.isArray(L)&&L.length&&p.splice(l,1,new hn({id:parseInt(R),tag:s.tag,substitution:L}));break}i=new he(p,l),!(Array.isArray(L)&&!L.length)&&(L=null)}}return p.length?p:null},Ae.prototype.supports=function(s){if(!s.script)return!1;this.getScriptFeatures(s.script);let i=Object.prototype.hasOwnProperty.call(this.features,s.script);if(!s.tag)return i;let l=this.features[s.script].some(h=>h.tag===s.tag);return i&&l},Ae.prototype.getLookupSubtables=function(s){return s.subtables||null},Ae.prototype.getLookupByIndex=function(s){return this.font.tables.gsub.lookups[s]||null},Ae.prototype.getFeatureLookups=function(s){return s.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Ae.prototype.getFeature=function(i){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,i.script)||this.getScriptFeatures(i.script);let l=this.features[i.script];return l?l.tags[i.tag]?this.features[i.script].tags[i.tag]:null:{FAIL:`No feature for script ${i.script}`}};var hm=Ae;function dm(s){let i=s.current,l=s.get(-1);return l===null&&cn(i)||!cn(l)&&cn(i)}function fm(s){let i=s.get(1);return i===null||!cn(i)}var pm={startCheck:dm,endCheck:fm};function gm(s){let i=s.current,l=s.get(-1);return(cn(i)||un(i))&&!cn(l)}function mm(s){let i=s.get(1);switch(!0){case i===null:return!0;case(!cn(i)&&!un(i)):{let l=sm(i);if(!l)return!0;if(l){let h=!1;if(h=s.lookahead.some(d=>cn(d)||un(d)),!h)return!0}break}default:return!1}}var bm={startCheck:gm,endCheck:mm};function ym(s,i,l){i[l].setState(s.tag,s.substitution)}function vm(s,i,l){i[l].setState(s.tag,s.substitution)}function Ji(s,i,l){for(let h=0;h<s.substitution.length;h++){let d=s.substitution[h],p=i[l+h];if(Array.isArray(d)){d.length?p.setState(s.tag,d[0]):p.setState("deleted",!0);continue}p.setState(s.tag,d)}}function xm(s,i,l){let h=i[l];h.setState(s.tag,s.substitution.ligGlyph);let d=s.substitution.components.length;for(let p=0;p<d;p++)h=i[l+p+1],h.setState("deleted",!0)}var Nc={11:ym,12:vm,63:Ji,41:xm,51:Ji,53:Ji};function Sm(s,i,l){s instanceof hn&&Nc[s.id]&&Nc[s.id](s,i,l)}var En=Sm;function Am(s){let i=[].concat(s.backtrack);for(let l=i.length-1;l>=0;l--){let h=i[l],d=_c(h),p=un(h);if(!d&&!p)return!0;if(d)return!1}return!1}function Tm(s){if(_c(s.current))return!1;for(let i=0;i<s.lookahead.length;i++){let l=s.lookahead[i];if(!un(l))return!0}return!1}function Cm(s){let i="arab",l=this.featuresTags[i],h=this.tokenizer.getRangeTokens(s);if(h.length===1)return;let d=new he(h.map(y=>y.getState("glyphIndex")),0),p=new he(h.map(y=>y.char),0);for(let y=0;y<h.length;y++){let x=h[y];if(un(x.char))continue;d.setCurrentIndex(y),p.setCurrentIndex(y);let A=0;Am(p)&&(A|=1),Tm(p)&&(A|=2);let E;switch(A){case 1:E="fina";break;case 2:E="init";break;case 3:E="medi";break}if(l.indexOf(E)===-1)continue;let C=this.query.lookupFeature({tag:E,script:i,contextParams:d});if(C instanceof Error){console.info(C.message);continue}for(let R=0;R<C.length;R++){let P=C[R];P instanceof hn&&(En(P,h,R),d.context[R]=P.substitution)}}}var wm=Cm;function Uc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Em(s){let i="arab",l=this.tokenizer.getRangeTokens(s),h=Uc(l);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"rlig",script:i,contextParams:h});if(p.length){for(let y=0;y<p.length;y++){let x=p[y];En(x,l,d)}h=Uc(l)}}}var km=Em;function Im(s){return s.index===0&&s.context.length>1}function Pm(s){return s.index===s.context.length-1}var Rm={startCheck:Im,endCheck:Pm};function Bc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Om(s){let i="delf",l="ccmp",h=this.tokenizer.getRangeTokens(s),d=Bc(h);for(let p=0;p<d.context.length;p++){if(!this.query.getFeature({tag:l,script:i,contextParams:d}))continue;d.setCurrentIndex(p);let y=this.query.lookupFeature({tag:l,script:i,contextParams:d});if(y.length){for(let x=0;x<y.length;x++){let A=y[x];En(A,h,p)}d=Bc(h)}}}var Mm=Om;function Lm(s){let i=s.current,l=s.get(-1);return l===null&&cr(i)||!cr(l)&&cr(i)}function Fm(s){let i=s.get(1);return i===null||!cr(i)}var Dm={startCheck:Lm,endCheck:Fm};function Gc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function _m(s){let i="latn",l=this.tokenizer.getRangeTokens(s),h=Gc(l);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"liga",script:i,contextParams:h});if(p.length){for(let y=0;y<p.length;y++){let x=p[y];En(x,l,d)}h=Gc(l)}}}var Nm=_m;function Um(s){let i=s.current,l=s.get(-1);return l===null&&lr(i)||!lr(l)&&lr(i)}function Bm(s){let i=s.get(1);return i===null||!lr(i)}var Gm={startCheck:Um,endCheck:Bm};function Hc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Hm(s){let i="thai",l=this.tokenizer.getRangeTokens(s),h=Hc(l,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"ccmp",script:i,contextParams:h});if(p.length){for(let y=0;y<p.length;y++){let x=p[y];En(x,l,d)}h=Hc(l,d)}}}var jm=Hm;function jc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Vm(s){let i="thai",l=this.tokenizer.getRangeTokens(s),h=jc(l,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"liga",script:i,contextParams:h});if(p.length){for(let y=0;y<p.length;y++){let x=p[y];En(x,l,d)}h=jc(l,d)}}}var $m=Vm;function Vc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function zm(s){let i="thai",l=this.tokenizer.getRangeTokens(s),h=Vc(l,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"rlig",script:i,contextParams:h});if(p.length){for(let y=0;y<p.length;y++){let x=p[y];En(x,l,d)}h=Vc(l,d)}}}var Wm=zm;function qi(s){if(s===null)return!1;let i=s.codePointAt(0);return i>=6155&&i<=6157||i>=65024&&i<=65039||i>=917760&&i<=917999}function Xm(s){let i=s.current,l=s.get(1);return l===null&&qi(i)||qi(l)}function Ym(s){let i=s.get(1);return i===null||!qi(i)}var Km={startCheck:Xm,endCheck:Ym};function Zm(s){let i=this.query.font,l=this.tokenizer.getRangeTokens(s);if(l[1].setState("deleted",!0),i.tables.cmap&&i.tables.cmap.varSelectorList){let h=l[0].char.codePointAt(0),d=l[1].char.codePointAt(0),p=i.tables.cmap.varSelectorList[d];if(p!==void 0&&p.nonDefaultUVS){let y=p.nonDefaultUVS.uvsMappings;if(y[h]){let x=y[h].glyphID;i.glyphs.glyphs[x]!==void 0&&l[0].setState("glyphIndex",x)}}}}var Qm=Zm;function ke(s){this.baseDir=s||"ltr",this.tokenizer=new nm,this.featuresTags={}}ke.prototype.setText=function(s){this.text=s},ke.prototype.contextChecks={ccmpReplacementCheck:Rm,latinWordCheck:Dm,arabicWordCheck:pm,arabicSentenceCheck:bm,thaiWordCheck:Gm,unicodeVariationSequenceCheck:Km};function Yn(s){let i=this.contextChecks[`${s}Check`];return this.tokenizer.registerContextChecker(s,i.startCheck,i.endCheck)}function Jm(){return Yn.call(this,"ccmpReplacement"),Yn.call(this,"latinWord"),Yn.call(this,"arabicWord"),Yn.call(this,"arabicSentence"),Yn.call(this,"thaiWord"),Yn.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function qm(){let s=this.tokenizer.getContextRanges("arabicSentence");for(let i=0;i<s.length;i++){let l=s[i],h=this.tokenizer.getRangeTokens(l);this.tokenizer.replaceRange(l.startIndex,l.endOffset,h.reverse())}}ke.prototype.registerFeatures=function(s,i){let l=i.filter(h=>this.query.supports({script:s,tag:h}));Object.prototype.hasOwnProperty.call(this.featuresTags,s)?this.featuresTags[s]=this.featuresTags[s].concat(l):this.featuresTags[s]=l},ke.prototype.applyFeatures=function(s,i){if(!s)throw new Error("No valid font was provided to apply features");this.query||(this.query=new hm(s));for(let l=0;l<i.length;l++){let h=i[l];this.query.supports({script:h.script})&&this.registerFeatures(h.script,h.tags)}},ke.prototype.registerModifier=function(s,i,l){this.tokenizer.registerModifier(s,i,l)};function hs(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function tb(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;hs.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let l=0;l<i.length;l++){let h=i[l];wm.call(this,h)}}function eb(){hs.call(this);let s=this.tokenizer.getContextRanges("ccmpReplacement");for(let i=0;i<s.length;i++){let l=s[i];Mm.call(this,l)}}function nb(){if(!this.hasFeatureEnabled("arab","rlig"))return;hs.call(this);let s=this.tokenizer.getContextRanges("arabicWord");for(let i=0;i<s.length;i++){let l=s[i];km.call(this,l)}}function sb(){if(!this.hasFeatureEnabled("latn","liga"))return;hs.call(this);let s=this.tokenizer.getContextRanges("latinWord");for(let i=0;i<s.length;i++){let l=s[i];Nm.call(this,l)}}function rb(){let s=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let i=0;i<s.length;i++){let l=s[i];Qm.call(this,l)}}function ib(){hs.call(this);let s=this.tokenizer.getContextRanges("thaiWord");for(let i=0;i<s.length;i++){let l=s[i];this.hasFeatureEnabled("thai","liga")&&$m.call(this,l),this.hasFeatureEnabled("thai","rlig")&&Wm.call(this,l),this.hasFeatureEnabled("thai","ccmp")&&jm.call(this,l)}}ke.prototype.checkContextReady=function(s){return!!this.tokenizer.getContext(s)},ke.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&eb.call(this),this.checkContextReady("arabicWord")&&(tb.call(this),nb.call(this)),this.checkContextReady("latinWord")&&sb.call(this),this.checkContextReady("arabicSentence")&&qm.call(this),this.checkContextReady("thaiWord")&&ib.call(this),this.checkContextReady("unicodeVariationSequence")&&rb.call(this)},ke.prototype.hasFeatureEnabled=function(s,i){return(this.featuresTags[s]||[]).indexOf(i)!==-1},ke.prototype.processText=function(s){(!this.text||this.text!==s)&&(this.setText(s),Jm.call(this),this.applyFeaturesToContexts())},ke.prototype.getBidiText=function(s){return this.processText(s),this.tokenizer.getText()},ke.prototype.getTextGlyphs=function(s){this.processText(s);let i=[];for(let l=0;l<this.tokenizer.tokens.length;l++){let h=this.tokenizer.tokens[l];if(h.state.deleted)continue;let d=h.activeState.value;i.push(Array.isArray(d)?d[0]:d)}return i};var ob=ke;function to(s){return{fontFamily:{en:s.familyName||" "},fontSubfamily:{en:s.styleName||" "},fullName:{en:s.fullName||s.familyName+" "+s.styleName},postScriptName:{en:s.postScriptName||(s.familyName+s.styleName).replace(/\s/g,"")},designer:{en:s.designer||" "},designerURL:{en:s.designerURL||" "},manufacturer:{en:s.manufacturer||" "},manufacturerURL:{en:s.manufacturerURL||" "},license:{en:s.license||" "},licenseURL:{en:s.licenseURL||" "},version:{en:s.version||"Version 0.1"},description:{en:s.description||" "},copyright:{en:s.copyright||" "},trademark:{en:s.trademark||" "}}}function Ut(s){if(s=s||{},s.tables=s.tables||{},!s.empty){if(!s.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!s.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!s.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!s.ascender)throw new Error("When creating a new Font object, ascender is required.");if(s.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=to(s),this.names.macintosh=to(s),this.names.windows=to(s),this.unitsPerEm=s.unitsPerEm||1e3,this.ascender=s.ascender,this.descender=s.descender,this.createdTimestamp=s.createdTimestamp,this.italicAngle=s.italicAngle||0,this.weightClass=s.weightClass||0;let i=0;s.fsSelection?i=s.fsSelection:(this.italicAngle<0?i|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(i|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(i|=this.fsSelectionValues.BOLD),i===0&&(i=this.fsSelectionValues.REGULAR)),(!s.panose||!Array.isArray(s.panose))&&(s.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(s.tables,{os2:Object.assign({usWeightClass:s.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:s.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:s.panose[0]||0,bSerifStyle:s.panose[1]||0,bWeight:s.panose[2]||0,bProportion:s.panose[3]||0,bContrast:s.panose[4]||0,bStrokeVariation:s.panose[5]||0,bArmStyle:s.panose[6]||0,bLetterform:s.panose[7]||0,bMidline:s.panose[8]||0,bXHeight:s.panose[9]||0,fsSelection:i},s.tables.os2)})}this.supported=!0,this.glyphs=new $e.GlyphSet(this,s.glyphs||[]),this.encoding=new xl(this),this.position=new ep(this),this.substitution=new lp(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(i,l,h)=>(i[l]=h,i.fvar&&(i.gvar||i.cff2)&&!this.variation&&(this.variation=new Tp(this)),!0)}),this.palettes=new cc(this),this.layers=new cp(this),this.svgImages=new up(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new qg(this):null}})}Ut.prototype.hasChar=function(s){return this.encoding.charToGlyphIndex(s)>0},Ut.prototype.charToGlyphIndex=function(s){return this.encoding.charToGlyphIndex(s)},Ut.prototype.charToGlyph=function(s){let i=this.charToGlyphIndex(s),l=this.glyphs.get(i);return l||(l=this.glyphs.get(0)),l},Ut.prototype.updateFeatures=function(s){return this.defaultRenderOptions.features.map(i=>i.script==="latn"?{script:"latn",tags:i.tags.filter(l=>s[l])}:i)},Ut.prototype.stringToGlyphIndexes=function(s,i){let l=new ob,h=p=>this.charToGlyphIndex(p.char);l.registerModifier("glyphIndex",null,h);let d=i?this.updateFeatures(i.features):this.defaultRenderOptions.features;return l.applyFeatures(this,d),l.getTextGlyphs(s)},Ut.prototype.stringToGlyphs=function(s,i){let l=this.stringToGlyphIndexes(s,i),h=l.length,d=new Array(h),p=this.glyphs.get(0);for(let y=0;y<h;y+=1)d[y]=this.glyphs.get(l[y])||p;return d},Ut.prototype.nameToGlyphIndex=function(s){return this.glyphNames.nameToGlyphIndex(s)},Ut.prototype.nameToGlyph=function(s){let i=this.nameToGlyphIndex(s),l=this.glyphs.get(i);return l||(l=this.glyphs.get(0)),l},Ut.prototype.glyphIndexToName=function(s){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(s):""},Ut.prototype.getKerningValue=function(s,i){s=s.index||s,i=i.index||i;let l=this.position.defaultKerningTables;return l?this.position.getKerningValue(l,s,i):this.kerningPairs[s+","+i]||0},Ut.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Ut.prototype.forEachGlyph=function(s,i,l,h,d,p){i=i!==void 0?i:0,l=l!==void 0?l:0,h=h!==void 0?h:72,d=Object.assign({},this.defaultRenderOptions,d);let y=1/this.unitsPerEm*h,x=this.stringToGlyphs(s,d),A;if(d.kerning){let E=d.script||this.position.getDefaultScriptName();A=this.position.getKerningTables(E,d.language)}for(let E=0;E<x.length;E+=1){let C=x[E];if(p.call(this,C,i,l,h,d),C.advanceWidth&&(i+=C.advanceWidth*y),d.kerning&&E<x.length-1){let R=A?this.position.getKerningValue(A,C.index,x[E+1].index):this.getKerningValue(C,x[E+1]);i+=R*y}d.letterSpacing?i+=d.letterSpacing*h:d.tracking&&(i+=d.tracking/1e3*h)}return i},Ut.prototype.getPath=function(s,i,l,h,d){d=Object.assign({},this.defaultRenderOptions,d);let p=new it;if(p._layers=[],Ml(this,p,h),p.stroke){let y=1/(p.unitsPerEm||1e3)*h;p.strokeWidth*=y}return this.forEachGlyph(s,i,l,h,d,(y,x,A,E)=>{let C=y.getPath(x,A,E,d,this);if(d.drawSVG||d.drawLayers){let R=C._layers;if(R&&R.length){for(let P=0;P<R.length;P++){let L=R[P];p._layers.push(L)}return}}p.extend(C)}),p},Ut.prototype.getPaths=function(s,i,l,h,d){d=Object.assign({},this.defaultRenderOptions,d);let p=[];return this.forEachGlyph(s,i,l,h,d,function(y,x,A,E){let C=y.getPath(x,A,E,d,this);p.push(C)}),p},Ut.prototype.getAdvanceWidth=function(s,i,l){return l=Object.assign({},this.defaultRenderOptions,l),this.forEachGlyph(s,0,0,i,l,function(){})},Ut.prototype.draw=function(s,i,l,h,d,p){this.getPath(i,l,h,d,p).draw(s)},Ut.prototype.drawPoints=function(s,i,l,h,d,p){p=Object.assign({},this.defaultRenderOptions,p),this.forEachGlyph(i,l,h,d,p,function(y,x,A,E){y.drawPoints(s,x,A,E,p,this)})},Ut.prototype.drawMetrics=function(s,i,l,h,d,p){p=Object.assign({},this.defaultRenderOptions,p),this.forEachGlyph(i,l,h,d,p,function(y,x,A,E){y.drawMetrics(s,x,A,E)})},Ut.prototype.getEnglishName=function(s){let i=(this.names.unicode||this.names.macintosh||this.names.windows)[s];if(i)return i.en},Ut.prototype.validate=function(){let s=[],i=this;function l(d,p){d||(console.warn(`[opentype.js] ${p}`),s.push(p))}function h(d){let p=i.getEnglishName(d);l(p&&p.trim().length>0,"No English "+d+" specified.")}if(h("fontFamily"),h("weightName"),h("manufacturer"),h("copyright"),h("version"),l(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let d=this.tables.colr.baseGlyphRecords,p=-1;for(let y=0;y<d.length;y++){let x=d[y].glyphID;if(l(p<d[y].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${x} comes after ${p}`),p>d[y].glyphID)break;p=x}}return s},Ut.prototype.toTables=function(){return tp.fontToTable(this)},Ut.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Ut.prototype.toArrayBuffer=function(){let i=this.toTables().encode(),l=new ArrayBuffer(i.length),h=new Uint8Array(l);for(let d=0;d<i.length;d++)h[d]=i[d];return l},Ut.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Ut.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Ut.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Ut.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Ut.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var $c=Ut;function ab(s,i){let l=new rt.Parser(s,i),h=l.parseUShort(),d=l.parseUShort();h!==1&&console.warn(`Unsupported hvar table version ${h}.${d}`);let p=[h,d],y=l.parsePointer32(function(){return this.parseItemVariationStore()}),x=l.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),A=l.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),E=l.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:p,itemVariationStore:y,advanceWidth:x,lsb:A,rsb:E}}function lb(){console.warn("Writing of hvar tables is not yet supported.")}var cb={make:lb,parse:ab},ub=function(){return{coverage:this.parsePointer(B.coverage),attachPoints:this.parseList(B.pointer(B.uShortList))}},hb=function(){var s=this.parseUShort();if(U.argument(s===1||s===2||s===3,"Unsupported CaretValue table version."),s===1)return{coordinate:this.parseShort()};if(s===2)return{pointindex:this.parseShort()};if(s===3)return{coordinate:this.parseShort()}},db=function(){return this.parseList(B.pointer(hb))},fb=function(){return{coverage:this.parsePointer(B.coverage),ligGlyphs:this.parseList(B.pointer(db))}},pb=function(){return this.parseUShort(),this.parseList(B.pointer(B.coverage))};function gb(s,i){i=i||0;let l=new B(s,i),h=l.parseVersion(1);U.argument(h===1||h===1.2||h===1.3,"Unsupported GDEF table version.");var d={version:h,classDef:l.parsePointer(B.classDef),attachList:l.parsePointer(ub),ligCaretList:l.parsePointer(fb),markAttachClassDef:l.parsePointer(B.classDef)};return h>=1.2&&(d.markGlyphSets=l.parsePointer(pb)),d}var mb={parse:gb},_e=new Array(10);_e[1]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();if(l===1)return{posFormat:1,coverage:this.parsePointer(B.coverage),value:this.parseValueRecord()};if(l===2)return{posFormat:2,coverage:this.parsePointer(B.coverage),values:this.parseValueRecordList()};U.assert(!1,"0x"+i.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},_e[2]=function(){let i=this.offset+this.relativeOffset,l=this.parseUShort();U.assert(l===1||l===2,"0x"+i.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let h=this.parsePointer(B.coverage),d=this.parseUShort(),p=this.parseUShort();if(l===1)return{posFormat:l,coverage:h,valueFormat1:d,valueFormat2:p,pairSets:this.parseList(B.pointer(B.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(d),value2:this.parseValueRecord(p)}})))};if(l===2){let y=this.parsePointer(B.classDef),x=this.parsePointer(B.classDef),A=this.parseUShort(),E=this.parseUShort();return{posFormat:l,coverage:h,valueFormat1:d,valueFormat2:p,classDef1:y,classDef2:x,class1Count:A,class2Count:E,classRecords:this.parseList(A,B.list(E,function(){return{value1:this.parseValueRecord(d),value2:this.parseValueRecord(p)}}))}}},_e[3]=function(){return{error:"GPOS Lookup 3 not supported"}},_e[4]=function(){return{error:"GPOS Lookup 4 not supported"}},_e[5]=function(){return{error:"GPOS Lookup 5 not supported"}},_e[6]=function(){return{error:"GPOS Lookup 6 not supported"}},_e[7]=function(){return{error:"GPOS Lookup 7 not supported"}},_e[8]=function(){return{error:"GPOS Lookup 8 not supported"}},_e[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function bb(s,i){i=i||0;let l=new B(s,i),h=l.parseVersion(1);return U.argument(h===1||h===1.1,"Unsupported GPOS table version "+h),h===1?{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(_e)}:{version:h,scripts:l.parseScriptList(),features:l.parseFeatureList(),lookups:l.parseLookupList(_e),variations:l.parseFeatureVariationsList()}}var yb=new Array(10);function vb(s){return new J.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(s.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(s.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(s.lookups,yb)}])}var xb={parse:bb,make:vb};function Sb(s){let i={};s.skip("uShort");let l=s.parseUShort();U.argument(l===0,"Unsupported kern sub-table version."),s.skip("uShort",2);let h=s.parseUShort();s.skip("uShort",3);for(let d=0;d<h;d+=1){let p=s.parseUShort(),y=s.parseUShort(),x=s.parseShort();i[p+","+y]=x}return i}function Ab(s){let i={};s.skip("uShort"),s.parseULong()>1&&console.warn("Only the first kern subtable is supported."),s.skip("uLong");let d=s.parseUShort()&255;if(s.skip("uShort"),d===0){let p=s.parseUShort();s.skip("uShort",3);for(let y=0;y<p;y+=1){let x=s.parseUShort(),A=s.parseUShort(),E=s.parseShort();i[x+","+A]=E}}return i}function Tb(s,i){let l=new rt.Parser(s,i),h=l.parseUShort();if(h===0)return Sb(l);if(h===1)return Ab(l);throw new Error("Unsupported kern table version ("+h+").")}var Cb={parse:Tb};function wb(s,i,l,h){let d=new rt.Parser(s,i),p=h?d.parseUShort:d.parseULong,y=[];for(let x=0;x<l+1;x+=1){let A=p.call(d);h&&(A*=2),y.push(A)}return y}var Eb={parse:wb};function zc(s,i){let l=[],h=12;for(let d=0;d<i;d+=1){let p=rt.getTag(s,h),y=rt.getULong(s,h+4),x=rt.getULong(s,h+8),A=rt.getULong(s,h+12);l.push({tag:p,checksum:y,offset:x,length:A,compression:!1}),h+=16}return l}function kb(s,i){let l=[],h=44;for(let d=0;d<i;d+=1){let p=rt.getTag(s,h),y=rt.getULong(s,h+4),x=rt.getULong(s,h+8),A=rt.getULong(s,h+12),E;x<A?E="WOFF":E=!1,l.push({tag:p,offset:y,compression:E,compressedLength:x,length:A}),h+=20}return l}function Dt(s,i){if(i.compression==="WOFF"){let l=new Uint8Array(s.buffer,i.offset+2,i.compressedLength-2),h=new Uint8Array(i.length);if(dt(l,h),h.byteLength!==i.length)throw new Error("Decompression error: "+i.tag+" decompressed length doesn't match recorded length");return{data:new DataView(h.buffer,0),offset:0}}else return{data:s,offset:i.offset}}function Ib(s,i={}){let l,h,d=new $c({empty:!0});s.constructor!==ArrayBuffer&&(s=new Uint8Array(s).buffer);let p=new DataView(s,0),y,x=[],A=rt.getTag(p,0);if(A==="\0\0\0"||A==="true"||A==="typ1")d.outlinesFormat="truetype",y=rt.getUShort(p,4),x=zc(p,y);else if(A==="OTTO")d.outlinesFormat="cff",y=rt.getUShort(p,4),x=zc(p,y);else if(A==="wOFF"){let xt=rt.getTag(p,4);if(xt==="\0\0\0")d.outlinesFormat="truetype";else if(xt==="OTTO")d.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+A);y=rt.getUShort(p,12),x=kb(p,y)}else if(A==="wOF2"){let xt="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+xt)}else throw new Error("Unsupported OpenType signature "+A);let E,C,R,P,L,M,N,z,vt,pt,At,It,Nt,Bt,Gt,Jt,Ne,Pt;for(let xt=0;xt<y;xt+=1){let ct=x[xt],ft;switch(ct.tag){case"avar":N=ct;break;case"cmap":ft=Dt(p,ct),d.tables.cmap=vl.parse(ft.data,ft.offset),d.encoding=new Sl(d.tables.cmap);break;case"cvt ":ft=Dt(p,ct),Pt=new rt.Parser(ft.data,ft.offset),d.tables.cvt=Pt.parseShortList(ct.length/2);break;case"fvar":R=ct;break;case"STAT":P=ct;break;case"gvar":L=ct;break;case"cvar":M=ct;break;case"fpgm":ft=Dt(p,ct),Pt=new rt.Parser(ft.data,ft.offset),d.tables.fpgm=Pt.parseByteList(ct.length);break;case"head":ft=Dt(p,ct),d.tables.head=Ul.parse(ft.data,ft.offset),d.unitsPerEm=d.tables.head.unitsPerEm,l=d.tables.head.indexToLocFormat;break;case"hhea":ft=Dt(p,ct),d.tables.hhea=Bl.parse(ft.data,ft.offset),d.ascender=d.tables.hhea.ascender,d.descender=d.tables.hhea.descender,d.numberOfHMetrics=d.tables.hhea.numberOfHMetrics;break;case"HVAR":Nt=ct;break;case"hmtx":It=ct;break;case"ltag":ft=Dt(p,ct),h=Hl.parse(ft.data,ft.offset);break;case"COLR":ft=Dt(p,ct),d.tables.colr=Wl.parse(ft.data,ft.offset);break;case"CPAL":ft=Dt(p,ct),d.tables.cpal=wl.parse(ft.data,ft.offset);break;case"maxp":ft=Dt(p,ct),d.tables.maxp=jl.parse(ft.data,ft.offset),d.numGlyphs=d.tables.maxp.numGlyphs;break;case"name":Jt=ct;break;case"OS/2":ft=Dt(p,ct),d.tables.os2=Gi.parse(ft.data,ft.offset);break;case"post":ft=Dt(p,ct),d.tables.post=Vl.parse(ft.data,ft.offset),d.glyphNames=new Oi(d.tables.post);break;case"prep":ft=Dt(p,ct),Pt=new rt.Parser(ft.data,ft.offset),d.tables.prep=Pt.parseByteList(ct.length);break;case"glyf":z=ct;break;case"loca":Gt=ct;break;case"CFF ":E=ct;break;case"CFF2":C=ct;break;case"kern":Bt=ct;break;case"GDEF":vt=ct;break;case"GPOS":pt=ct;break;case"GSUB":At=ct;break;case"meta":Ne=ct;break;case"gasp":try{ft=Dt(p,ct),d.tables.gasp=Jl.parse(ft.data,ft.offset)}catch(oe){console.warn("Failed to parse gasp table, skipping."),console.warn(oe)}break;case"SVG ":ft=Dt(p,ct),d.tables.svg=ql.parse(ft.data,ft.offset);break;default:break}}let Te=Dt(p,Jt);if(d.tables.name=yl.parse(Te.data,Te.offset,h),d.names=d.tables.name,z&&Gt){let xt=l===0,ct=Dt(p,Gt),ft=Eb.parse(ct.data,ct.offset,d.numGlyphs,xt),oe=Dt(p,z);d.glyphs=fc.parse(oe.data,oe.offset,ft,d,i)}else if(E){let xt=Dt(p,E);Ui.parse(xt.data,xt.offset,d,i)}else if(C){let xt=Dt(p,C);Ui.parse(xt.data,xt.offset,d,i)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let de=Dt(p,It);if(Gl.parse(d,de.data,de.offset,d.numberOfHMetrics,d.numGlyphs,d.glyphs,i),wd(d,i),Bt){let xt=Dt(p,Bt);d.kerningPairs=Cb.parse(xt.data,xt.offset)}else d.kerningPairs={};if(vt){let xt=Dt(p,vt);d.tables.gdef=mb.parse(xt.data,xt.offset)}if(pt){let xt=Dt(p,pt);d.tables.gpos=xb.parse(xt.data,xt.offset),d.position.init()}if(At){let xt=Dt(p,At);d.tables.gsub=$l.parse(xt.data,xt.offset)}if(R){let xt=Dt(p,R);d.tables.fvar=Xl.parse(xt.data,xt.offset,d.names)}if(P){let xt=Dt(p,P);d.tables.stat=Yl.parse(xt.data,xt.offset,d.tables.fvar)}if(L){R||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),z||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let xt=Dt(p,L);d.tables.gvar=Ql.parse(xt.data,xt.offset,d.tables.fvar,d.glyphs)}if(M){R||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),d.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),z||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let xt=Dt(p,M);d.tables.cvar=Zl.parse(xt.data,xt.offset,d.tables.fvar,d.tables.cvt||[])}if(N){R||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let xt=Dt(p,N);d.tables.avar=Kl.parse(xt.data,xt.offset,d.tables.fvar)}if(Nt){R||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),It||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let xt=Dt(p,Nt);d.tables.hvar=cb.parse(xt.data,xt.offset,d.tables.fvar)}if(Ne){let xt=Dt(p,Ne);d.tables.meta=zl.parse(xt.data,xt.offset),d.metas=d.tables.meta}return d.palettes=new cc(d),d}function Pb(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function Rb(){console.error('DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)')}return c(u)})();(function(o,t){typeof define=="function"&&define.amd?define(t):typeof oi=="object"&&oi.exports?oi.exports=t():o.opentype=t()})(typeof self<"u"?self:_u,()=>({...Du,default:Du}))});function Hb(o,t){return o.replace(/\{(\w+)\}/g,(e,n)=>{if(!(n in t))throw new Error(`Missing param "${n}" for warning template: ${o}`);return String(t[n])})}var ro=class{constructor(o){this.registry=o}messages=[];emit(o,t={}){let e=this.registry[o];this.messages.push({code:o,type:e.severity,message:Hb(e.template,t),params:t})}getMessages(){return this.messages}},jb="0.1.0",Zc=`https://staticimgly.com/imgly/gfonts/${jb}/dist`,ds="ly.img.gfonts",fs="ly.img.gfonts-fallbacks";async function Jc(o){let t=o.asset.findAllSources();t.includes(ds)||await o.asset.addLocalAssetSourceFromJSONURI(`${Zc}/${ds}/content.json`),t.includes(fs)||await o.asset.addLocalAssetSourceFromJSONURI(`${Zc}/${fs}/content.json`)}async function io(o,t,e){let n=t.asset.findAllSources();if(!n.includes(ds)||!n.includes(fs))throw new Error(`The gfonts asset sources (${ds}, ${fs}) are not available. Call addGfontsAssetLibrary() first.`);let r,a=await Xb(t,o.family);if(a?r=o.family:a=await Wb(t,ds,o.family),!a)return null;let c=a.fonts.find(u=>Vb(u,o));if(!c&&o.weight&&e?.closestWeightMatch){let u=o.style!==void 0?a.fonts.filter(f=>f.style?.toLowerCase()===o.style.toLowerCase()):a.fonts;u.length>0&&(c=zb(u,o.weight))}return c?{typeface:a,font:c,substitutedFrom:r}:null}var oo={100:"thin",200:"extraLight",300:"light",regular:"normal",400:"normal",500:"medium",600:"semiBold",700:"bold",800:"extraBold",900:"heavy"},pn=["thin","extraLight","light","normal","medium","semiBold","bold","extraBold","heavy"];function Vb(o,t){return!(t.style!==void 0&&o.style?.toLowerCase()!==t.style.toLowerCase()||t.weight!==void 0&&!$b(t.weight,o.weight))}function $b(o,t){if(!t)return!1;if(o===t)return!0;let e=o.toLowerCase();if(e===t)return!0;let n=oo[e];return n!==void 0&&n===t}function Qc(o){let t=o.toLowerCase();for(let e of pn)if(e.toLowerCase()===t)return e;return oo[t]??null}function zb(o,t){let e=Qc(t);if(e===null)return;let n=pn.indexOf(e);if(n===-1)return;let r=new Map;for(let f of o){if(!f.weight)continue;let g=Qc(f.weight);if(g===null)continue;let m=pn.indexOf(g);m>=0&&!r.has(m)&&r.set(m,f)}if(r.size===0)return;let a=pn.indexOf("normal"),c=pn.indexOf("medium"),u=[];if(n===a||n===c){for(let f=n;f<=c;f++)u.push(f);for(let f=a-1;f>=0;f--)u.push(f);for(let f=c+1;f<pn.length;f++)u.push(f)}else if(n<a){for(let f=n;f>=0;f--)u.push(f);for(let f=n+1;f<pn.length;f++)u.push(f)}else{for(let f=n;f<pn.length;f++)u.push(f);for(let f=n-1;f>=0;f--)u.push(f)}for(let f of u){let g=r.get(f);if(g)return g}}async function Wb(o,t,e){let n=await o.asset.findAssets(t,{page:0,query:e,perPage:1});if(!n||n.assets.length===0){let r=Yb(e);for(let a of r)if(n=await o.asset.findAssets(t,{page:0,query:a,perPage:1}),n&&n.assets.length>0)break}return!n||n.assets.length===0?null:n.assets[0].payload?.typeface??null}async function Xb(o,t){let e=await o.asset.findAssets(fs,{page:0,query:t,perPage:1});if(!e||e.assets.length===0)return null;let n=e.assets[0],r=t.toLowerCase().trim(),a=(n.id??"").toLowerCase().trim(),c=(n.label??"").toLowerCase().trim();return a!==r&&c!==r?null:n.payload?.typeface??null}function Yb(o){let e=o.replace(/([A-Z])/g," $1").trim().split(" ");if(e.length<2)return[];let n=[];for(let r=e.length;r>0;r--)n.push(e.slice(0,r).join(" "));return n}var qc={DOC_PAGE_COUNT:{severity:"info",template:"PDF has {count} page(s)"},DOC_PAGE_BLOCK_COUNT:{severity:"info",template:"Page {page}: {imageCount} image, {vectorCount} vector, {textCount} text, {outlineCount} outline"},DOC_PAGE_ROTATION_DROPPED:{severity:"warning",template:"{prefix}PDF declares /Rotate {pageRotation}; the importer does not apply page rotation, so the imported page is in its un-rotated (native) orientation. Viewer-rendered output may differ from the source's display orientation."},BLOCK_KIND_UNKNOWN:{severity:"error",template:'An unknown block kind "{kind}" was encountered and was skipped.'},FONT_OPENTYPE_PARSE_FAILED:{severity:"warning",template:'{prefix}font "{fontName}" could not be parsed as OpenType{reason}. Glyph outlines will fall back to pdf.js raster paths \u2014 some shapes may render without stroke/anti-aliasing detail.'},FONT_CMAP_AUGMENTED:{severity:"info",template:'Font "{fontName}" character map was augmented (cmap patches={cmapPatches}, injected glyphs={injectedGlyphs}).'},FONT_CMAP_AUGMENT_FAILED:{severity:"warning",template:'Font "{fontName}" character map could not be augmented. Using the original font data \u2014 some glyphs may render incorrectly.'},FONT_RESOLVER_MISS:{severity:"warning",template:'Font "{fontFamily}" could not be resolved. The text was rendered as a vector outline.'},FONT_NOT_FOUND_IN_ASSETS:{severity:"warning",template:'Font "{fontFamily}" was not found in the asset library. The text was rendered as a vector outline.'},FONT_SUBSTITUTED:{severity:"info",template:'Font "{fontFamily}" was substituted with "{substitutedName}" from the asset library.'},FONT_REF_NOT_EXTRACTED:{severity:"error",template:'Text run references font "{fontRef}" which was not extracted. The text was skipped.'},FONT_SUBSTITUTIONS_SUMMARY:{severity:"warning",template:"Substituted {count} font famil{plural} during import: {pairs}."},TEXT_OUTLINE_NO_FONT_FAMILY:{severity:"warning",template:"Text outline has no declared font family. The run was skipped."},TEXT_RUN_SKIPPED_NO_RESOLUTION:{severity:"warning",template:'No typeface or glyph outlines for "{fontFamily}"; run skipped.'},TEXT_RENDER_MODE_SKIPPED:{severity:"warning",template:'Text item{pageTag}: skipped "{text}" \u2014 PDF text rendering mode {modeLabel}. This text paints no ink; for mode 7 it acts as a clipping mask for following images, an effect the importer does not currently reproduce.'},TEXT_OVERFLOW_AFTER_AUTOSIZE:{severity:"warning",template:'Text "{text}" did not fit after auto-sizing; it still overflows by {overflowLines} line(s). The text was kept; some content may be clipped.'},TEXT_CLIP_MODE_7_DROPPED:{severity:"warning",template:"{prefix}{label} at ({bbox}) {bboxSize} pt: dropped because the surrounding region was clipped by text in PDF render mode 7 (text-as-clipping-mask). The masked artwork cannot be reproduced as text-clipped content."},IMAGE_ENCODER_MISS:{severity:"warning",template:"{prefix}an image{idLabel} ({width}\xD7{height} raw pixels{kind}) could not be encoded ({reason}). The image was dropped from the imported design."},IMAGE_PDFJS_UNRESOLVED:{severity:"error",template:"{prefix}image placement {idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be resolved by pdf.js (reason={reason}) and was dropped."},IMAGE_NO_PIXELS:{severity:"warning",template:"An image element has no pixel data and was skipped."},IMAGE_FLIP_UNSUPPORTED:{severity:"warning",template:"Image flip could not be applied (engine version too old). The image will display without flip."},IMAGE_SKEW_DROPPED:{severity:"warning",template:"{prefix}an image{idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt has a skewed transform ctm={ctm}{residualStr} that cannot be represented. Placed axis-aligned \u2014 image content will appear un-skewed."},IMAGE_CLIPPED_NO_BYTES:{severity:"warning",template:"{prefix}a clipped image at {bbox} had no decoded bytes; the placement was dropped before combining clip shapes."},IMAGE_CLIP_UNUSABLE:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate, {disjointCount} disjoint from the image. The image was dropped."},IMAGE_CLIP_EMPTY_INTERSECTION:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) had an empty intersection. The image was dropped."},IMAGE_CLIP_COMBINE_FAILED:{severity:"error",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) could not be combined. The image was dropped from the imported design."},IMAGE_MASK_NO_FILL_COLOR:{severity:"warning",template:"{prefix}a stencil ImageMask paint (objId={objId}) had no current fill colour to composite with. The mask was dropped from the imported design."},IMAGE_MASK_COMPOSITE_FAIL:{severity:"warning",template:"{prefix}a stencil ImageMask (objId={objId}) at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be composited with the current fill colour (space={colourSpace}). The mask was dropped from the imported design."},IMAGE_MASK_GROUP_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectGroup batch of {count} stencil paints is not supported by the importer. The masks were dropped."},IMAGE_MASK_REPEAT_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectRepeat tiling {count} stencil paints is not supported by the importer. The masks were dropped."},CLIP_DEGENERATE_FALLBACK:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate (zero width or height). Falling back to the unclipped path."},CLIP_COMBINE_STROKE_ONLY:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no fill color (stroke-only) which cannot survive combine. Falling back to the unclipped path."},CLIP_COMBINE_FAILED:{severity:"warning",template:"{prefix}a vector path at {bbox} with {clipCount} clip path(s) could not be combined. Rendered without its clip \u2014 some content may extend beyond the intended mask."},CLIP_COMBINE_TOO_FEW_INPUTS:{severity:"warning",template:"{prefix}clip combine was called with {inputCount} input block(s) (need at least 2). The owner block was emitted without its clips."},CLIP_COMBINE_NOT_COMBINABLE:{severity:"warning",template:"{prefix}clip combine rejected {inputCount} input block(s) as not combinable (nested or incompatible shapes). The owner block was emitted without its clips."},CLIP_COMBINE_THREW:{severity:"warning",template:"{prefix}clip combine of {inputCount} input block(s) failed ({reason}). The owner block was emitted without its clips."},COLOR_TYPE_UNSUPPORTED:{severity:"warning",template:'{prefix}{subject}color of type "{colorType}" is not supported. Rendered as black.'},COLOR_SPACE_UNSUPPORTED:{severity:"warning",template:'{prefix}{elementLabel}color space "{space}" ({color}) at {bbox} is not supported. Rendered as black.'},SPOT_COLOR_NO_ALTERNATE:{severity:"warning",template:'Spot color "{name}" has no resolvable alternate; leaving at engine default.'},SPOT_COLOR_REGISTER_FAILED:{severity:"warning",template:'Failed to register spot color "{name}": {error}'},VECTOR_PATH_FILL_RULE_UNSUPPORTED:{severity:"warning",template:"CE.SDK does not expose `{property}` on `vector_path` shapes (added in CE.SDK {sinceVersion}); the source PDF used non-zero winding fill, but imported paths render with the engine default (even-odd) winding. Self-overlapping or compound paths may render with holes inverted. Upgrade `@cesdk/engine` to {sinceVersion} or newer to preserve the source winding rule."},BLEND_MODE_UNSUPPORTED:{severity:"warning",template:'Blend mode "{mode}" is not supported. Using "Normal" as the default.'},SHADING_UNRESOLVED:{severity:"error",template:"{prefix}gradient shading could not be resolved by pdf.js and was removed. The painted region will be missing in the imported scene."},SHADING_MESH_UNSUPPORTED:{severity:"warning",template:"{prefix}gradient shading uses an unsupported mesh variant (PDF ShadingType 4\u20137). The region was dropped because mesh gradients can't be represented as a CE.SDK gradient fill."},SHADING_UNKNOWN_IR_TAG:{severity:"error",template:'{prefix}gradient shading reported unknown IR tag "{tag}" and was dropped.'},SHADING_INSUFFICIENT_STOPS:{severity:"warning",template:"{prefix}gradient shading produced fewer than two color stops and was dropped."},SHADING_NO_CLIP_FALLBACK_BBOX:{severity:"info",template:"{prefix}gradient shading was painted without an active clip path. Falling back to the shading /BBox; if this scene shows gradient bands outside the intended shape, file a bug."},SHADING_CLIP_DEGENERATE:{severity:"warning",template:"{prefix}gradient shading clip path was degenerate and the region was dropped."},SHADING_RADIAL_FOCAL_DROPPED:{severity:"info",template:"{prefix}radial gradient declared a non-zero inner radius (PDF Shading Type 3 focal point). It was approximated as a centered radial; the focal offset was dropped."},SHADING_UNKNOWN_RADIAL_SUBTYPE:{severity:"error",template:'{prefix}gradient shading reported unknown RadialAxial subtype "{kind}" and was dropped.'},SHADING_NO_PATTERN_REF:{severity:"error",template:"{prefix}gradient shading was emitted without a pattern reference and was dropped."},TILING_PATTERN_AS_IMAGE:{severity:"info",template:'{prefix}tiling pattern "{patternId}" was imported as an image (single-image tiling pattern, e.g. Skia/Chrome PDF export of an embedded bitmap).'},TILING_PATTERN_UNSUPPORTED:{severity:"warning",template:'{prefix}tiling pattern "{patternId}" contains {imageCount} image XObject(s) and {otherOpCount} other paint op(s); only single-image tiling patterns are imported. The pattern fill was dropped.'},TILING_PATTERN_UNRESOLVED:{severity:"error",template:'{prefix}tiling pattern "{patternId}" could not be resolved by pdf.js and was dropped.'},TILING_PATTERN_IMAGE_DECODE_FAILED:{severity:"warning",template:'{prefix}tiling pattern "{patternId}" referenced image "{imageObjId}" but the image bytes could not be decoded. The pattern fill was dropped.'}};Ga();async function Qe(o,t){let e=document.createElement("canvas");return e.width=o,e.height=t,{canvas:e,ImageData:globalThis.ImageData}}async function _n(o){let t=await new Promise(e=>o.toBlob(e,"image/png"));return t?new Uint8Array(await t.arrayBuffer()):null}async function wu(o){return{opList:await o.getOperatorList({annotationMode:Ba.DISABLE})}}function Nn(o,t){return Eu(o.objs,t)}function ts(o,t){return Eu(o.commonObjs,t)}function Eu(o,t){return t==null?Promise.resolve({data:null,reason:"cb-null"}):new Promise(e=>{let n=!1,r=(c,u)=>{n||(n=!0,e({data:c,reason:u}))};try{o.get(t,c=>r(c,c==null?"cb-null":"ok"))}catch{r(null,"throw");return}setTimeout(()=>r(null,"timeout"),1e4).unref?.()})}async function ii(o,t,e={}){if(o==null)return null;let n=o.width,r=o.height;if(!n||!r)return ri("missing width/height",o,t,e),null;let{canvas:a,ImageData:c}=await Qe(n,r),u=a.getContext("2d");if(o.bitmap)try{u.drawImage(o.bitmap,0,0)}catch(f){let g=f&&typeof f=="object"&&"message"in f?String(f.message):String(f);return ri(`bitmap drawImage failed: ${g}`,o,t,e),null}else if(o.data){let f=Va(o);if(!f)return ri(`unknown data kind=${o.kind}`,o,t,e),null;let g=new c(f,n,r);u.putImageData(g,0,0)}else return ri("no bitmap and no data",o,t,e),null;return _n(a)}async function ku(o,t,e,n={}){if(o==null)return null;let r=o.width,a=o.height;if(!r||!a)return null;let c=ja(t);if(c==null)return null;let[u,f,g]=c,m=await Ha(o);if(m==null)return null;let{canvas:b,ImageData:v}=await Qe(r,a),S=b.getContext("2d"),T=new Uint8ClampedArray(r*a*4);for(let I=0;I<r*a;I++)T[I*4]=u,T[I*4+1]=f,T[I*4+2]=g,T[I*4+3]=m[I];let w=new v(T,r,a);return S.putImageData(w,0,0),_n(b)}async function Ha(o){let t=o.width,e=o.height,n=t*e;if(o.data){let{kind:r,data:a}=o;if(r===1){if(a.length>=n)return new Uint8ClampedArray(a.buffer,a.byteOffset,n);let c=new Uint8ClampedArray(n),u=Math.ceil(t/8);for(let f=0;f<e;f++)for(let g=0;g<t;g++){let b=a[f*u+(g>>3)]>>7-(g&7)&1;c[f*t+g]=b?255:0}return c}if(r===2){let c=new Uint8ClampedArray(n);for(let u=0;u<n;u++)c[u]=Math.round(a[u*3]*.299+a[u*3+1]*.587+a[u*3+2]*.114);return c}if(r===3){let c=new Uint8ClampedArray(n);for(let u=0;u<n;u++)c[u]=Math.round(a[u*4]*.299+a[u*4+1]*.587+a[u*4+2]*.114);return c}return null}if(o.bitmap){let{canvas:r}=await Qe(t,e),a=r.getContext("2d");try{a.drawImage(o.bitmap,0,0)}catch{return null}let u=a.getImageData(0,0,t,e).data,f=new Uint8ClampedArray(n);for(let g=0;g<n;g++)f[g]=Math.round(u[g*4]*.299+u[g*4+1]*.587+u[g*4+2]*.114);return f}return null}function ja(o){if(!o||typeof o!="object")return null;let{space:t,values:e}=o;if(t==="rgb"&&Array.isArray(e)&&e.length>=3)return[Math.round(vn(e[0])*255),Math.round(vn(e[1])*255),Math.round(vn(e[2])*255)];if(t==="gray"&&Array.isArray(e)&&e.length>=1){let n=Math.round(vn(e[0])*255);return[n,n,n]}if(t==="cmyk"&&Array.isArray(e)&&e.length>=4){let n=vn(e[0]),r=vn(e[1]),a=vn(e[2]),c=vn(e[3]);return[Math.round(255*(1-n)*(1-c)),Math.round(255*(1-r)*(1-c)),Math.round(255*(1-a)*(1-c))]}return null}function vn(o){return typeof o!="number"||Number.isNaN(o)||o<0?0:o>1?1:o}function ri(o,t,e,n={}){if(!e?.emit)return;let r=n.pageIndex!=null?`Page ${n.pageIndex}: `:"",a=n.objId?` objId="${n.objId}"`:"",c=t?.width??"?",u=t?.height??"?",f=t?.kind!=null?`, kind=${t.kind}`:"";e.emit("IMAGE_ENCODER_MISS",{prefix:r,idLabel:a,width:c,height:u,kind:f,reason:o,page:n.pageIndex,objId:n.objId??null})}function Va(o){let t=o.width,e=o.height,n=o.kind,r=o.data,a=t*e,c=new Uint8ClampedArray(a*4);if(n===1){if(r.length>=a){for(let f=0;f<a;f++){let g=r[f];c[f*4]=g,c[f*4+1]=g,c[f*4+2]=g,c[f*4+3]=255}return c}let u=Math.ceil(t/8);for(let f=0;f<e;f++)for(let g=0;g<t;g++){let v=r[f*u+(g>>3)]>>7-(g&7)&1?255:0,S=(f*t+g)*4;c[S]=v,c[S+1]=v,c[S+2]=v,c[S+3]=255}return c}if(n===2){for(let u=0;u<a;u++)c[u*4]=r[u*3],c[u*4+1]=r[u*3+1],c[u*4+2]=r[u*3+2],c[u*4+3]=255;return c}return n===3?new Uint8ClampedArray(r.buffer,r.byteOffset,r.byteLength):null}async function F0(o){if(o==null)return null;let{width:t,height:e}=o;if(!t||!e)return null;let n=t*e;if(o.data){let r=new Uint8ClampedArray(n),a=Math.ceil(t/8);for(let c=0;c<e;c++)for(let u=0;u<t;u++){let g=o.data[c*a+(u>>3)]>>7-(u&7)&1;r[c*t+u]=g?0:255}return r}if(o.bitmap){let{canvas:r}=await Qe(t,e),a=r.getContext("2d");try{a.drawImage(o.bitmap,0,0)}catch{return null}let c=a.getImageData(0,0,t,e),u=new Uint8ClampedArray(n);for(let f=0;f<n;f++)u[f]=c.data[f*4+3];return u}return null}async function Iu(o,t,e,n={}){if(o==null)return null;let r=o.width,a=o.height;if(!r||!a)return null;let c=ja(t);if(c==null)return null;let[u,f,g]=c,m=await F0(o);if(m==null)return null;let{canvas:b,ImageData:v}=await Qe(r,a),S=b.getContext("2d"),T=new Uint8ClampedArray(r*a*4);for(let I=0;I<r*a;I++)T[I*4]=u,T[I*4+1]=f,T[I*4+2]=g,T[I*4+3]=m[I];let w=new v(T,r,a);return S.putImageData(w,0,0),_n(b)}async function Ru(o){let{imageObj:t,imageCtm:e,maskSource:n,modulatedAlpha:r}=o;if(t==null)return null;let a=t.width,c=t.height;if(!a||!c)return null;let u=Mu(r??1);if(n.kind==="shading"){let f=D0(n.ir,n.ctm);return f==null?null:Pu(a,c,e,f,u)}if(n.kind==="image"){if(n.obj==null)return null;let f=n.obj.width,g=n.obj.height;if(!f||!g)return null;let m=await Ha(n.obj);if(m==null)return null;let b=_0(n.ctm,m,f,g);return b==null?null:Pu(a,c,e,b,u)}return null}async function Ou(o,t){if(o==null)return null;let e=o.width,n=o.height;if(!e||!n||t.length!==e*n)return null;let r=null;if(o.bitmap){let{canvas:m}=await Qe(e,n),b=m.getContext("2d");try{b.drawImage(o.bitmap,0,0)}catch{return null}let v=b.getImageData(0,0,e,n);r=new Uint8ClampedArray(v.data.buffer.slice(0))}else o.data&&(r=Va(o));if(!r)return null;let a=new Uint8ClampedArray(e*n*4);for(let m=0;m<e*n;m++){a[m*4]=r[m*4],a[m*4+1]=r[m*4+1],a[m*4+2]=r[m*4+2];let b=r[m*4+3];a[m*4+3]=Math.round(b*t[m]/255)}let{canvas:c,ImageData:u}=await Qe(e,n),f=c.getContext("2d"),g=new u(a,e,n);return f.putImageData(g,0,0),_n(c)}function Pu(o,t,e,n,r){let a=new Uint8ClampedArray(o*t),[c,u,f,g,m,b]=e;for(let v=0;v<t;v++)for(let S=0;S<o;S++){let T=(S+.5)/o,w=1-(v+.5)/t,I=c*T+f*w+m,k=u*T+g*w+b,O=n(I,k);a[v*o+S]=Math.round(O*255*r)}return a}function D0(o,t){if(!Array.isArray(o)||o[0]!=="RadialAxial")return null;let e=o[1],n=o[3],r=o[4],a=o[5],c=o[6],u=o[7],f=N0(n);if(f==null)return null;let g=Lu(t);if(g==null)return null;if(e==="axial"){if(!Array.isArray(r)||!Array.isArray(a))return null;let[m,b]=r,[v,S]=a,T=v-m,w=S-b,I=T*T+w*w;return I<=0?null:(k,O)=>{let[F,_]=$a(g,k,O),D=((F-m)*T+(_-b)*w)/I,G=Math.max(0,Math.min(1,D));return f[Math.round(G*255)]/255}}if(e==="radial"){if(!Array.isArray(a)||typeof u!="number"||u<=0||Math.abs(typeof c=="number"?c:0)>.001)return null;let[b,v]=a;return(S,T)=>{let[w,I]=$a(g,S,T),k=w-b,O=I-v,_=Math.sqrt(k*k+O*O)/u,D=Math.max(0,Math.min(1,_));return f[Math.round(D*255)]/255}}return null}function _0(o,t,e,n){let r=Lu(o);return r==null?null:(a,c)=>{let[u,f]=$a(r,a,c);if(u<0||u>1||f<0||f>1)return 0;let g=Math.min(e-1,Math.floor(u*e)),m=Math.min(n-1,Math.floor((1-f)*n));return t[m*e+g]/255}}function N0(o){if(!Array.isArray(o)||o.length<2)return null;let t=[];for(let n of o){if(!Array.isArray(n)||n.length<2)continue;let r=Mu(n[0]),a=U0(n[1]);a&&t.push({offset:r,r:a[0],g:a[1],b:a[2]})}if(t.length<2)return null;t.sort((n,r)=>n.offset-r.offset);let e=new Uint8Array(256);for(let n=0;n<256;n++){let r=n/255,a=t[0],c=t[t.length-1];for(let v=0;v<t.length-1;v++)if(r>=t[v].offset&&r<=t[v+1].offset){a=t[v],c=t[v+1];break}let u=c.offset-a.offset,f=u>0?(r-a.offset)/u:0,g=a.r+(c.r-a.r)*f,m=a.g+(c.g-a.g)*f,b=a.b+(c.b-a.b)*f;e[n]=Math.round(.299*g+.587*m+.114*b)}return e}function U0(o){if(typeof o!="string")return null;if(o==="transparent")return[255,255,255];let t=/^#([0-9a-fA-F]{6})$/.exec(o.trim());if(!t)return null;let e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Mu(o){return typeof o!="number"||!Number.isFinite(o)||o<0?0:o>1?1:o}function $a(o,t,e){return[o[0]*t+o[2]*e+o[4],o[1]*t+o[3]*e+o[5]]}function Lu(o){let[t,e,n,r,a,c]=o,u=t*r-e*n;if(!Number.isFinite(u)||Math.abs(u)<1e-12)return null;let f=1/u;return[r*f,-e*f,-n*f,t*f,(n*c-r*a)*f,(e*a-t*c)*f]}var B0=/^[A-Z]{6}\+/,G0=["compressed","condensed","extended","narrow","wide","cond","comp"],H0=["italic","oblique"],Fu={bd:700,lt:300,md:500,rg:400,bk:900,blk:900,hv:900,th:100,hl:100};function Fs(o){let t=o.replace(B0,""),e=t.lastIndexOf("-"),n=t.lastIndexOf(","),r=Math.max(e,n);if(r<0)return{fullName:t,family:t,weight:null,style:"normal",styleSuffix:null};let a=t.slice(0,r),c=t.slice(r+1),u=j0(c);return u?{fullName:t,family:a,weight:u.weight,style:u.style,styleSuffix:c}:{fullName:t,family:t,weight:null,style:"normal",styleSuffix:null}}function j0(o){let t=o.toLowerCase(),e=!1,n="normal";for(let a of H0)if(t.includes(a)){n="italic",e=!0;break}for(let a of G0)if(t.includes(a)){e=!0;break}let r=V0(t);return r!==null&&(e=!0),e?{weight:r,style:n}:null}function V0(o){return o.includes("extrabold")||o.includes("ultrabold")?800:o.includes("semibold")||o.includes("demibold")?600:o.includes("extralight")||o.includes("ultralight")?200:o.includes("thin")||o.includes("hairline")?100:o.includes("light")?300:o.includes("medium")?500:o.includes("bold")?700:o.includes("black")||o.includes("heavy")?900:o.includes("regular")||o==="normal"||o.includes("book")||o.includes("roman")?400:Object.prototype.hasOwnProperty.call(Fu,o)?Fu[o]:null}var $0=/^[A-Z]{6}\+/;async function Wa(o,t){if(!o||!o.data||o.data.length===0)return null;let e=Fs(o.name??"");if(!e.fullName)return null;let n=o.loadedName?`${e.fullName}#${o.loadedName}`:e.fullName,r=o._parsed??null,a=r?.names,c=(a?.fontFamily?.en?.trim()||a?.fontFamily?.und?.trim()||e.family).replace($0,""),u=r?.tables?.os2,f=e.weight??u?.usWeightClass??(o.black?900:o.bold?700:400),g=o.italic?"italic":e.style,m=o.data instanceof Uint8Array?o.data:new Uint8Array(o.data),b=await Y0(r,m,o.toFontChar??null,t),v=z0(b);return{postScriptName:n,family:c,weight:f,style:g,data:b,mimeType:v}}function Nu(o,t){if(!li(o)||!t||t.length===0)return!1;for(let e of t){let n=e.unicode;if(!n||W0(n))return!1}return!0}function li(o){return!(!o||o.isType3Font||!o.data||o.data.length===0||!o._parsed)}function Xa(o){let t=Number(o)||400;return t<=150?"thin":t<=250?"extraLight":t<=350?"light":t<=450?"normal":t<=550?"medium":t<=650?"semiBold":t<=750?"bold":t<=850?"extraBold":"heavy"}function Uu(o){let t=Fs(o?.name??""),e=o?._parsed?.tables?.os2,n=t.weight??e?.usWeightClass??(o?.black?900:o?.bold?700:400);return{style:o?.italic?"italic":t.style,weight:Xa(n)}}function z0(o){return o.length>=4&&o[0]===79&&o[1]===84&&o[2]===84&&o[3]===79?"font/otf":"font/ttf"}function W0(o){for(let t of o){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}var X0=[32,160];async function Y0(o,t,e,n){if(!o)return t;let r=ai.get(o);if(r)return r;try{let{default:a}=await Promise.resolve().then(()=>Kc(za(),1)),c=K0(o,e);for(let{glyphIndex:w,unicode:I}of c){let k=o.glyphs.get(w);if(!k)continue;let O=k;O.unicodes||(O.unicodes=O.unicode!=null?[O.unicode]:[]),O.unicodes.includes(I)||O.unicodes.push(I)}let u=[],f=o.unitsPerEm||1e3,g=Math.round(f*.25),m=o.glyphs;for(let w of X0){if(Q0(o,w))continue;let I=m.length,k=new a.Glyph({name:w===32?"space":`uni${w.toString(16).toUpperCase()}`,unicode:w,advanceWidth:g,path:new a.Path});k.index=I,m.glyphs[I]=k,m.length=I+1,u.push(w)}if(c.length===0&&u.length===0)return ai.set(o,t),t;for(let w=0;w<m.length;w+=1){let I=o.glyphs.get(w);I&&(typeof I.name!="string"||I.name==="")&&(I.name=w===0?".notdef":`gid${w}`)}o.numGlyphs=m.length;let b=o.toArrayBuffer(),S=a.parse(b).toArrayBuffer(),T=new Uint8Array(S);if(ai.set(o,T),Z0()){let w=o.names?.postScriptName?.en??"<unknown>",I=u.map(k=>"U+"+k.toString(16).toUpperCase()).join(",")||"none";n?.emit?.("FONT_CMAP_AUGMENTED",{fontName:w,cmapPatches:c.length,injectedGlyphs:I})}return T}catch(a){let c=o.names?.postScriptName?.en??"<unknown>",u=a&&typeof a=="object"&&"message"in a?String(a.message):String(a);return n?.emit?.("FONT_CMAP_AUGMENT_FAILED",{fontName:c,error:u}),ai.set(o,t),t}}function K0(o,t){let e=[];if(!t)return e;let r=o.tables?.cmap?.glyphIndexMap;if(!r)return e;for(let[a,c]of Object.entries(t)){let u=Number(a);if(!Number.isFinite(u)||u===c||r[u])continue;let f=r[c];f&&e.push({unicode:u,glyphIndex:f})}return e}var ai=new WeakMap;function Z0(){return!!(typeof process<"u"&&process.env?.PDF2CESDK_DEBUG_FONTS||typeof globalThis<"u"&&globalThis.PDF2CESDK_DEBUG_FONTS)}function Q0(o,t){try{let e=o.charToGlyphIndex(String.fromCodePoint(t));if(!e)return!1;let n=o.glyphs.get(e);return!!n&&(n.advanceWidth??0)>0}catch{return!1}}function ju(o,t,e,n){if(!o||o.length===0)return[];let r=o.map(u=>q0(u,t,e,n)),a=[],c=null;for(let u of r)if(u){if(c&&J0(c,u)){c.items.push(u);continue}c&&a.push(Bu(c,t)),c={items:[u]}}return c&&a.push(Bu(c,t)),a}function J0(o,t){let e=o.items[o.items.length-1];return!(t.fontObjId!==e.fontObjId||Math.abs(t.fontSizePt-e.fontSizePt)>1||Math.abs(t.baselineYPt-e.baselineYPt)>2||t.originXPt-(e.originXPt+e.advancePt)>.5*t.fontSizePt)}function q0(o,t,e,n){let r=t[o.fontObjId];if(!r)return null;let a=Hu(e,o.textMatrix),c=[o.fontSize,0,0,o.fontSize,0,0],u=Hu(a,c),f=Math.hypot(u[2],u[3]),g=a[4],m=n-a[5],b=tv(o,r,f);return{glyph:o,fontObjId:o.fontObjId,fontSizePt:f,originXPt:g,baselineYPt:m,advancePt:b}}function tv(o,t,e){let n=t._parsed;if(n&&o.unicode)try{let r=n.charToGlyph?.(o.unicode);if(r&&r.advanceWidth&&n.unitsPerEm)return r.advanceWidth/n.unitsPerEm*e}catch{}return .5*e}function Bu(o,t){let e=o.items,n=e[0],r=e[e.length-1],c=t[n.fontObjId]?._parsed,u=Gu(e.map(k=>k.fontSizePt)),f=c?.unitsPerEm??1e3,g=c?.ascender?c.ascender/f*u:.8*u,m=c?.descender?Math.abs(c.descender/f)*u:.2*u,b=n.originXPt,v=Gu(e.map(k=>k.baselineYPt)),T=r.originXPt+r.advancePt-b+.05*u*e.length,w="",I=null;for(let k of e){let O=k.glyph.unicode??"";if(I){let F=I.originXPt+I.advancePt;k.originXPt-F>.2*k.fontSizePt&&!O.startsWith(" ")&&!w.endsWith(" ")&&(w+=" ")}w+=O,I=k}return{glyphs:e.map(k=>k.glyph),fontObjId:n.fontObjId,fontSizePt:u,originXPt:b,baselineYPt:v,widthPt:T,ascenderPt:g,descenderPt:m,text:w}}function Gu(o){return o.length===0?0:o.reduce((t,e)=>t+e,0)/o.length}function Hu(o,t){let[e,n,r,a,c,u]=o,[f,g,m,b,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*b,n*m+a*b,e*v+r*S+c,n*v+a*S+u]}function Ht(o){return Number.isFinite(o)?o.toFixed(1):String(o)}function Me(o){if(!o)return"(unknown position)";let t=typeof o.x=="number"?Ht(o.x):"?",e=typeof o.y=="number"?Ht(o.y):"?",n=typeof o.width=="number"?Ht(o.width):"?",r=typeof o.height=="number"?Ht(o.height):"?";return`(${t}, ${e}) ${n}\xD7${r} pt`}function Vu(o){if(!o||o.length<6)return"[invalid]";let[t,e,n,r,a,c]=o;return`[a=${Ht(t)}, b=${Ht(e)}, c=${Ht(n)}, d=${Ht(r)}, e=${Ht(a)}, f=${Ht(c)}]`}function $u(o){if(o==null)return"none";if(typeof o!="object")return String(o);let t=o;if("type"in t)switch(t.type){case"rgb":return`rgb(${me(t.r)}, ${me(t.g)}, ${me(t.b)})`;case"cmyk":return`cmyk(${me(t.c)}, ${me(t.m)}, ${me(t.y)}, ${me(t.k)})`;case"spot":{let e=typeof t.name=="string"?`"${t.name}"`:"(unnamed)",n=typeof t.tint=="number"?`, tint=${me(t.tint)}`:"",r=t.fallback_rgb,a=Array.isArray(r)?`, fallback=rgb(${me(r[0])}, ${me(r[1])}, ${me(r[2])})`:", no fallback";return`spot ${e}${n}${a}`}default:return`type="${String(t.type)}"`}if("space"in t&&Array.isArray(t.values)){let e=t.values.map(n=>me(n)).join(", ");return`${String(t.space)}(${e})`}return"r"in t&&"g"in t&&"b"in t?`rgb(${me(t.r)}, ${me(t.g)}, ${me(t.b)})`:"(opaque)"}function me(o){return Number.isFinite(o)?o.toFixed(2):String(o)}function Ya(){return[]}function zu(o,t,e,n){return[...o,{path:t,fillRule:e,ctm:n.slice()}]}function Wu(o){return o.slice()}function Xu(o){return o.pop()??Ya()}function es(o){return o.length===0}var Un=Object.freeze({moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19}),TS=Object.freeze([1,0,0,1,0,0]);function ev(o,t,e){let n=o.ops??[],r=o.coords??[],a=[],c=[],u=0,f=null,[g,m,b,v,S,T]=t,w=(I,k)=>[g*I+b*k+S,e-(m*I+v*k+T)];for(let I=0;I<n.length;I++)switch(n[I]){case Un.rectangle:{let k=r[u++],O=r[u++],F=r[u++],_=r[u++],D=w(k,O),G=w(k+F,O),j=w(k+F,O+_),W=w(k,O+_);a.push({cmd:"M",pts:[D]}),a.push({cmd:"L",pts:[G]}),a.push({cmd:"L",pts:[j]}),a.push({cmd:"L",pts:[W]}),a.push({cmd:"Z"}),c.push(D,G,j,W);break}case Un.moveTo:{let k=w(r[u++],r[u++]);a.push({cmd:"M",pts:[k]}),c.push(k),f=k;break}case Un.lineTo:{let k=w(r[u++],r[u++]);a.push({cmd:"L",pts:[k]}),c.push(k),f=k;break}case Un.curveTo:{let k=w(r[u++],r[u++]),O=w(r[u++],r[u++]),F=w(r[u++],r[u++]);a.push({cmd:"C",pts:[k,O,F]}),c.push(k,O,F),f=F;break}case Un.curveTo2:{let k=w(r[u++],r[u++]),O=w(r[u++],r[u++]),F=f??k;a.push({cmd:"C",pts:[F,k,O]}),c.push(k,O),f=O;break}case Un.curveTo3:{let k=w(r[u++],r[u++]),O=w(r[u++],r[u++]);a.push({cmd:"C",pts:[k,O,O]}),c.push(k,O),f=O;break}case Un.closePath:a.push({cmd:"Z"});break;default:break}return{cmds:a,devPoints:c}}function nv(o){if(o.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,e=1/0,n=-1/0,r=-1/0;for(let[a,c]of o)a<t&&(t=a),c<e&&(e=c),a>n&&(n=a),c>r&&(r=c);return{x:t,y:e,width:n-t,height:r-e}}function sv(o,t,e){let n=a=>`${Math.round(a*100)/100}`,r=[];for(let a of o){if(a.cmd==="Z"){r.push("Z");continue}let c=a.pts.map(([u,f])=>`${n(u-t)} ${n(f-e)}`).join(" ");r.push(`${a.cmd} ${c}`)}return r.join(" ")}function ci(o,t,e){let{cmds:n,devPoints:r}=ev(o,t,e);if(r.length===0)return null;let a=nv(r);return{...a,d:sv(n,a.x,a.y),cmds:n,devPoints:r}}function xn(o,t){let e=[];for(let n of o){let r=rv(n,t);r&&e.push(r)}return e}function rv(o,t){let e=ci(o.path,o.ctm,t.heightPt);return!e||e.width<=0&&e.height<=0?null:{d:e.d,x:e.x,y:e.y,width:e.width,height:e.height,fillRule:o.fillRule}}function Yu({shadingIR:o,ctm:t,clipEntry:e,remainingClips:n,pageBox:r,opacity:a,blendMode:c,logger:u,pageIndex:f}){let g=Array.isArray(o)?o[0]:null,m=f!=null?`Page ${f}: `:"";if(g==="Dummy"||g==null)return u?.emit?.("SHADING_UNRESOLVED",{prefix:m,page:f}),null;if(g==="Mesh")return u?.emit?.("SHADING_MESH_UNSUPPORTED",{prefix:m,page:f}),null;if(g!=="RadialAxial")return u?.emit?.("SHADING_UNKNOWN_IR_TAG",{prefix:m,tag:String(g),page:f}),null;let b=o,v=b[1],S=b[3],T=b[4],w=b[5],I=b[6],k=b[7],O=iv(S);if(O.length<2)return u?.emit?.("SHADING_INSUFFICIENT_STOPS",{prefix:m,page:f}),null;e==null&&u?.emit?.("SHADING_NO_CLIP_FALLBACK_BBOX",{prefix:m,page:f});let F=e?ci(e.path,e.ctm,r.heightPt):null;if(!F||F.width<=0&&F.height<=0)return u?.emit?.("SHADING_CLIP_DEGENERATE",{prefix:m,page:f}),null;let _={kind:"vector-path",x:F.x,y:F.y,width:F.width,height:F.height,d:F.d,fill:null,stroke:null,strokeWidth:0,fillRule:e?.fillRule??"nonzero",opacity:1,blendMode:c??void 0};if(v==="axial"){let D=Ka(T,t,r.heightPt),G=Ka(w,t,r.heightPt);_.fill={kind:"linearGradient",start:D,end:G,stops:O}}else if(v==="radial"){typeof I=="number"&&I>.001&&u?.emit?.("SHADING_RADIAL_FOCAL_DROPPED",{prefix:m,page:f,innerRadius:I});let D=Ka(w,t,r.heightPt),G=lv(t);_.fill={kind:"radialGradient",center:D,radius:Math.max(.001,Math.abs((k??0)*G)),stops:O}}else return u?.emit?.("SHADING_UNKNOWN_RADIAL_SUBTYPE",{prefix:m,kind:String(v),page:f}),null;if(a!=null&&a<1&&(_.opacity=a),n&&n.length>0){let D=xn(n,r);D.length>0&&(_.clips=D)}return _}function iv(o){if(!Array.isArray(o))return[];let t=[];for(let e of o){if(!Array.isArray(e)||e.length<2)continue;let n=av(e[0]),r=ov(e[1]);if(!r)continue;let a={space:"rgb",values:r};t.push({offset:n,color:a})}return t}function ov(o){if(typeof o!="string")return null;if(o==="transparent")return[1,1,1];let t=/^#([0-9a-fA-F]{6})$/.exec(o.trim());if(!t)return null;let e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}function av(o){return typeof o!="number"||!Number.isFinite(o)||o<0?0:o>1?1:o}function Ka(o,t,e){let n=Array.isArray(o)?o[0]:0,r=Array.isArray(o)?o[1]:0,[a,c,u,f,g,m]=t;return{x:a*n+u*r+g,y:e-(c*n+f*r+m)}}function lv([o,t,e,n]){return Math.sqrt(Math.abs(o*n-t*e))}var cv=12,uv=85,hv=10,dv=11,fv=91,pv=22,gv=23,mv=24,bv=25,yv=28,vv=29,xv=30,Sv=new Set([1,9,31,32,37,2,50,51,53,55,56,57,58,59,60,61]);async function Ku({page:o,pattern:t,logger:e,pageIndex:n}){let r=n!=null?`Page ${n}: `:"",{fnArray:a,argsArray:c}=t.operatorList,u=0,f=0,g=0,m=[],b=null,v=[1,0,0,1,0,0],S=[];for(let j=0;j<a.length;j++){let W=a[j],$=c[j]??[];switch(W){case hv:S.push(v.slice());break;case dv:v=S.pop()??[1,0,0,1,0,0];break;case cv:v=Av(v,$);break;case uv:{u++;let Z=$[0],q=Number($[1]??0)||0,yt=Number($[2]??0)||0;typeof Z=="string"&&m.push({objId:Z,ctm:v.slice(),w:q,h:yt});break}case fv:{let Z=$,q=Z[2];if(q&&q.length>=4)b={w:q[2]-q[0],h:q[3]-q[1]};else{let yt=Z[1];b=Cv(yt)}break}case pv:case gv:case mv:case bv:b!=null?(g+=Tv(b,v),b=null):f++;break;case yv:case vv:case xv:b=null;break;default:Sv.has(W)||f++}}if(m.length===0)return e?.emit?.("TILING_PATTERN_UNSUPPORTED",{prefix:r,patternId:t.patternId,imageCount:u,otherOpCount:f,page:n,reason:"no-images"}),null;m.sort((j,W)=>W.w*W.h-j.w*j.h);let T=m[0],w=10,I=T.w*T.h,k=m.slice(1).reduce((j,W)=>j+W.w*W.h,0),O=Math.abs(T.ctm[0]*T.ctm[3]-T.ctm[1]*T.ctm[2]);if(!(f===0&&I>0&&I>=w*k&&O>=g))return e?.emit?.("TILING_PATTERN_UNSUPPORTED",{prefix:r,patternId:t.patternId,imageCount:u,otherOpCount:f,page:n,reason:"not-image-dominant",primarySrcArea:I,otherSrcArea:k,primaryPaintedArea:O,rectFillArea:g}),null;let D=(await(T.objId.startsWith("g_")?ts(o,T.objId):Nn(o,T.objId))).data;if(!D)return e?.emit?.("TILING_PATTERN_IMAGE_DECODE_FAILED",{prefix:r,patternId:t.patternId,imageObjId:T.objId,page:n}),null;let G=await ii(D,e,{objId:T.objId,pageIndex:n??void 0});return G?{bytes:G,width:D.width??0,height:D.height??0}:(e?.emit?.("TILING_PATTERN_IMAGE_DECODE_FAILED",{prefix:r,patternId:t.patternId,imageObjId:T.objId,page:n}),null)}function Av(o,t){let[e,n,r,a,c,u]=o,[f,g,m,b,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*b,n*m+a*b,e*v+r*S+c,n*v+a*S+u]}function Tv(o,t){return Math.abs(t[0]*t[3]-t[1]*t[2])*o.w*o.h}function Cv(o){if(!o||o.length<2)return null;let t=1/0,e=1/0,n=-1/0,r=-1/0;for(let a=0;a+1<o.length;a+=2){let c=o[a],u=o[a+1];c<t&&(t=c),u<e&&(e=u),c>n&&(n=c),u>r&&(r=u)}return!Number.isFinite(t)||!Number.isFinite(e)?null:{w:n-t,h:r-e}}var st={setLineWidth:2,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,beginText:31,endText:32,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,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColorN:53,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,paintImageXObject:85,paintInlineImageXObject:86,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,shadingFill:62},ui=[1,0,0,1,0,0];async function nh(o,t,e={}){let n=e.textMode??"outline",r=e.docFonts??new Map,a=e.logger,c=e.pageIndex,{opList:u}=await wu(o),f=await wv(o,u,{logger:a,pageIndex:c}),g=o.colorSpaceResources??{},{out:m,colorSnapshots:b}=await kv(u,t,o,f,{textMode:n,docFonts:r,logger:a,pageIndex:c,colorSpaceResources:g});return{out:m,colorSnapshots:b,finalize:()=>$v(Iv(m),t)}}async function wv(o,t,e={}){let n=new Set,r=t.fnArray,a=t.argsArray;for(let u=0;u<r.length;u++)r[u]===st.setFont&&n.add(a[u][0]);let c={};for(let u of n){let f=(await ts(o,u)).data;if(f&&!f.isType3Font&&f.data){let g=f.name||f.loadedName||f.fallbackName||`(font object ${u})`;f._parsed=await Ev(f.data,g,e)}c[u]=f}return c}async function Ev(o,t,e={}){try{let{default:n}=await Promise.resolve().then(()=>Kc(za(),1)),r=o instanceof Uint8Array?o:new Uint8Array(o),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return n.parse(a)}catch(n){let r=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",a=n&&typeof n=="object"&&"message"in n?String(n.message):null,c=a?` (${a})`:"";return e.logger?.emit?.("FONT_OPENTYPE_PARSE_FAILED",{prefix:r,fontName:t,reason:c,page:e.pageIndex,error:a}),null}}async function kv(o,t,e,n,r){let a=o.fnArray,c=o.argsArray,u=[],f=r?.colorSpaceResources??{},g=[],m=t.originShiftPt??{x:0,y:0},b=eh(m),v=[],S=null,T=Ya(),w=[],I=null,k=[],O=[],F=[],_=null,D=[],G=[],j=[],W=[],$=0,Z=!1,q=[],yt=()=>q.some(X=>X.suppressing),et=null,Tt=null,dt=null,Y=X=>{let ot=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.log?.(`${ot}${X}`,"warning")},K=X=>{if(!Array.isArray(X)||X.length<4)return"(unknown bbox)";let[ot,Q,nt,it]=X,V=ot/72,H=(t.heightPt-it)/72,U=Math.abs(nt-ot)/72,at=Math.abs(it-Q)/72;return`(${V.toFixed(2)} in, ${H.toFixed(2)} in) ${U.toFixed(2)}\xD7${at.toFixed(2)} in`},bt=()=>{if(b.blendMode!=null&&b.blendMode!=="source-over")return b.blendMode;for(let X=D.length-1;X>=0;X--){let ot=D[X];if(ot!=null&&ot!=="source-over")return ot}return b.blendMode},lt=()=>{if(b.fillAlpha!=null&&b.fillAlpha<1)return b.fillAlpha;for(let X=G.length-1;X>=0;X--){let ot=G[X];if(ot!=null&&ot<1)return ot}return b.fillAlpha},kt=()=>{_&&_.glyphs.length>0?Pv(_,n,t,r):_&&je(_.placeholder),_=null};for(let X=0;X<a.length;X++){let ot=a[X],Q=c[X];switch(ot){case st.save:v.push(b),b=Bv(b),w.push(Wu(T));break;case st.restore:b=v.pop()??eh(m),T=Xu(w);break;case st.paintFormXObjectBegin:D.push(b.blendMode),G.push(b.fillAlpha),j.push({blendMode:b.blendMode,fillAlpha:b.fillAlpha});break;case st.paintFormXObjectEnd:{D.pop(),G.pop();let nt=j.pop();nt&&(b.blendMode=nt.blendMode,nt.fillAlpha!=null&&(b.fillAlpha=nt.fillAlpha));break}case st.beginGroup:{let nt=Q?.[0]??{},it=nt.smask!=null;W.push(it),it&&$++,q.push({candidate:Z&&!it,suppressing:!1}),it&&nt.smask?.subtype==="Luminosity"&&(et={groupBbox:Array.isArray(nt.bbox)?nt.bbox.slice():null,captured:null,abort:!1,abortReason:null}),Z&&!it&&Tt!=null&&dt==null&&(dt={mask:Tt,target:b.fillColor!=null?{kind:"solid",color:b.fillColor}:null,formBbox:Array.isArray(nt.bbox)?nt.bbox.slice():null,alpha:null,aborted:!1},Tt=null),Z=!1;break}case st.endGroup:{let nt=W.pop();nt&&$--;let it=q.pop();if(nt&&et!=null&&(et.abort?Y(`a luminosity SMask group at ${K(et.groupBbox)} ${et.abortReason}. The shadow was dropped from the imported design.`):et.captured==null?Y(`a luminosity SMask group at ${K(et.groupBbox)} has no grayscale image content. The shadow was dropped from the imported design.`):Tt={groupBbox:et.groupBbox,captured:et.captured},et=null),it&&it.candidate&&dt!=null){let{mask:V,target:H,formBbox:U,alpha:at,aborted:Ct}=dt;if(dt=null,Ct)Y(`a luminosity SMask at ${K(U)} modulates multiple images in one paint group (only single-paint targets are supported). The shadow was dropped from the imported design.`);else if(H==null)Y(`a luminosity SMask at ${K(U)} modulates an unsupported paint shape (no solid fill colour or image was captured). The shadow was dropped from the imported design.`);else if(H.kind==="solid"){let gt=H.color;if(gt.space!=="rgb"&>.space!=="cmyk"&>.space!=="gray")Y(`a luminosity SMask at ${K(U)} modulates a non-solid fill (${gt.space}); compositing isn't supported. The shadow was dropped from the imported design.`);else if(V.captured.kind!=="image")Y(`a luminosity SMask at ${K(U)} uses a shading mask against a solid fill (only image masks are supported for solid targets). The shadow was dropped from the imported design.`);else{let jt={kind:"image",_placeholderIndex:u.length};u.push(jt);let Ft=at??1;k.push({placeholder:jt,objId:V.captured.objId,inline:null,ctm:V.captured.ctm,opacity:Ft,blendMode:null,clips:null,compositeWith:gt})}}else{let gt={kind:"image",_placeholderIndex:u.length};u.push(gt),k.push({placeholder:gt,objId:H.objId,inline:null,ctm:H.ctm,opacity:1,blendMode:null,clips:null,compositeWithMask:{mask:V.captured,maskGroupBbox:V.groupBbox,modulatedAlpha:at??1}})}}break}case st.transform:b.ctm=Ve(b.ctm,Q);break;case st.setLineWidth:b.lineWidth=Q[0];break;case st.setFillRGBColor:b.fillColor=Qu(Q);break;case st.setStrokeRGBColor:b.strokeColor=Qu(Q);break;case st.setFillCMYKColor:b.fillColor={space:"cmyk",values:[Q[0],Q[1],Q[2],Q[3]]};break;case st.setStrokeCMYKColor:b.strokeColor={space:"cmyk",values:[Q[0],Q[1],Q[2],Q[3]]};break;case st.setFillGray:b.fillColor={space:"gray",values:[Q[0]]};break;case st.setStrokeGray:b.strokeColor={space:"gray",values:[Q[0]]};break;case st.setFillColorSpace:b.fillColorSpaceName=Q?.[0]??null,b.fillColorSpaceName!=="Pattern"&&(b.fillPattern=null);break;case st.setStrokeColorSpace:b.strokeColorSpaceName=Q?.[0]??null;break;case st.setFillColorN:{let nt=Hv(Q);if(nt){b.fillPattern=nt;break}let{key:it,components:V}=Ju(Q);b.fillColor=qu(it??b.fillColorSpaceName,V,f,b.fillColor);break}case st.setStrokeColorN:{let{key:nt,components:it}=Ju(Q);b.strokeColor=qu(nt??b.strokeColorSpaceName,it,f,b.strokeColor);break}case st.setGState:{let nt=!1,it=!1,V=null;for(let[H,U]of Q[0]??[])H==="BM"&&U==="multiply"&&(nt=!0),H==="ca"&&typeof U=="number"&&(U<1&&(it=!0),V=U);if(nt&&it&&q.length>0){let H=q[q.length-1];H.candidate&&!H.suppressing&&(H.suppressing=!0)}dt!=null&&V!=null&&V<(dt.alpha??1)&&(dt.alpha=V);for(let[H,U]of Q[0]??[])if(H==="SMask"&&(U===!0?Z=!0:(U===!1||U==null)&&(Z=!1)),H==="ca"&&typeof U=="number")b.fillAlpha=U;else if(H==="CA"&&typeof U=="number")b.strokeAlpha=U;else if(H==="LW"&&typeof U=="number")b.lineWidth=U;else if(H==="BM"){if(typeof U=="string"&&U!=="")b.blendMode=U;else if(Array.isArray(U)){for(let at of U)if(typeof at=="string"&&at!==""){b.blendMode=at;break}}}break}case st.constructPath:S={ops:Q[0],coords:Q[1],minMax:Q[2]};break;case st.clip:I="nonzero";break;case st.eoClip:I="evenodd";break;case st.fill:case st.eoFill:case st.stroke:case st.closeStroke:case st.fillStroke:case st.eoFillStroke:case st.closeFillStroke:case st.closeEOFillStroke:case st.endPath:{if(I&&S!=null&&(T=zu(T,S,I,b.ctm),I=null),S==null)break;let nt=Mv(ot);if(nt){if(b.textClipActive){ns(r,b.ctm,t,`vector ${nt}`),S=null;break}if($>0&&et!=null&&(et.abort=!0,et.abortReason="contains vector paint operations (only single-paint image or shading masks are supported)"),$>0||yt()){S=null;break}if(nt.fill&&b.fillPattern){let V=jv(S);if(V){let H=Vv(b.ctm,V),U={kind:"image",_placeholderIndex:u.length};u.push(U),F.push({placeholder:U,pattern:b.fillPattern,placementCtm:H,opacity:lt(),blendMode:bt(),clips:es(T)?null:xn(T,t)})}S=null;break}let it=th(S,nt,b,t);if(it){it.blendMode=bt();let V=lt();V!=null&&V<1&&(it.opacity=V),Zu(it,T,t),u.push(it)}}S=null;break}case st.paintImageXObject:{if($>0&&et!=null&&(et.captured!=null?(et.abort=!0,et.abortReason="contains multiple paint operations; only single-paint masks are supported"):et.captured={kind:"image",objId:Q[0],ctm:b.ctm.slice()}),$>0||yt())break;if(dt!=null){dt.target?.kind==="image"?(dt.target=null,dt.aborted=!0):!dt.aborted&&(dt.target==null||dt.target.kind==="solid")&&(dt.target={kind:"image",objId:Q[0],ctm:b.ctm.slice()});break}if(b.textClipActive){ns(r,b.ctm,t,`image objId="${Q[0]}"`);break}let nt={kind:"image",_placeholderIndex:u.length};u.push(nt),k.push({placeholder:nt,objId:Q[0],inline:null,ctm:b.ctm.slice(),opacity:lt(),blendMode:bt(),clips:es(T)?null:xn(T,t)});break}case st.paintInlineImageXObject:{if($>0&&et!=null&&(et.abort=!0,et.abortReason="contains an inline image (only image-xobject masks are supported)"),$>0||yt())break;if(b.textClipActive){ns(r,b.ctm,t,"inline image");break}let nt={kind:"image",_placeholderIndex:u.length};u.push(nt),k.push({placeholder:nt,objId:null,inline:Q[0],ctm:b.ctm.slice(),opacity:lt(),blendMode:bt(),clips:es(T)?null:xn(T,t)});break}case st.paintImageMaskXObject:{if($>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintImageMaskXObject (only single-paint image or shading masks are supported)"),$>0||yt())break;let it=(Q[0]??{}).data;if(b.textClipActive){ns(r,b.ctm,t,`image mask objId="${it}"`);break}if(b.fillColor==null){let H=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:H,objId:it??null,page:r.pageIndex});break}let V={kind:"image",_placeholderIndex:u.length};u.push(V),k.push({placeholder:V,objId:it,inline:null,stencilFill:b.fillColor,ctm:b.ctm.slice(),opacity:lt(),blendMode:bt(),clips:es(T)?null:xn(T,t)});break}case st.paintSolidColorImageMask:{if($>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintSolidColorImageMask (only single-paint image or shading masks are supported)"),$>0||yt())break;if(b.textClipActive){ns(r,b.ctm,t,"solid-colour image mask");break}if(b.fillColor==null){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:V,objId:null,page:r.pageIndex});break}let nt={ops:[st.rectangle],coords:[0,0,1,1]},it=th(nt,{fill:!0,stroke:!1,fillRule:"nonzero"},b,t);if(it){it.blendMode=bt();let V=lt();V!=null&&V<1&&(it.opacity=V),Zu(it,T,t),u.push(it)}break}case st.paintImageMaskXObjectGroup:{if($>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintImageMaskXObjectGroup (only single-paint image or shading masks are supported)"),$>0||yt())break;let nt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",it=Array.isArray(Q[0])?Q[0].length:0;r.logger?.emit?.("IMAGE_MASK_GROUP_UNSUPPORTED",{prefix:nt,count:it,page:r.pageIndex});break}case st.paintImageMaskXObjectRepeat:{if($>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintImageMaskXObjectRepeat (only single-paint image or shading masks are supported)"),$>0||yt())break;let nt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",it=Q[5],V=Array.isArray(it)?Math.floor(it.length/2):0;r.logger?.emit?.("IMAGE_MASK_REPEAT_UNSUPPORTED",{prefix:nt,count:V,page:r.pageIndex});break}case st.shadingFill:{if($>0&&et!=null&&(et.captured!=null?(et.abort=!0,et.abortReason="contains a shading fill plus another paint (only single-paint masks are supported)"):et.captured={kind:"shading",patternId:Q?.[0],ctm:b.ctm.slice()}),$>0||yt())break;if(b.textClipActive){ns(r,b.ctm,t,"shading fill");break}let nt={kind:"vector-path",_placeholderIndex:u.length};u.push(nt);let it=T.length>0?T[T.length-1]:null,V=T.length>1?T.slice(0,-1):[];O.push({placeholder:nt,patternId:Q?.[0],ctm:b.ctm.slice(),clipEntry:it??null,remainingClips:V,opacity:lt(),blendMode:bt()});break}case st.beginText:b.textMatrix=ui.slice(),b.textLineMatrix=ui.slice();break;case st.endText:kt();break;case st.setFont:b.fontObjId=Q[0],b.fontSize=Q[1];break;case st.setTextMatrix:b.textMatrix=[Q[0],Q[1],Q[2],Q[3],Q[4],Q[5]],b.textLineMatrix=b.textMatrix.slice();break;case st.moveText:{b.textLineMatrix=Ve(b.textLineMatrix,[1,0,0,1,Q[0],Q[1]]),b.textMatrix=b.textLineMatrix.slice();break}case st.setLeadingMoveText:{b.textLeading=-Q[1],b.textLineMatrix=Ve(b.textLineMatrix,[1,0,0,1,Q[0],Q[1]]),b.textMatrix=b.textLineMatrix.slice();break}case st.nextLine:{b.textLineMatrix=Ve(b.textLineMatrix,[1,0,0,1,0,-b.textLeading]),b.textMatrix=b.textLineMatrix.slice();break}case st.setLeading:b.textLeading=Q[0];break;case st.setCharSpacing:b.charSpacing=Q[0];break;case st.setWordSpacing:b.wordSpacing=Q[0];break;case st.setHScale:b.textHScale=Q[0]/100;break;case st.setTextRise:b.textRise=Q[0];break;case st.setTextRenderingMode:b.textRenderingMode=Q[0]??0;break;case st.showText:case st.nextLineShowText:case st.nextLineSetSpacingShowText:case st.showSpacedText:{let nt=(ot===st.showText||ot===st.nextLineShowText,Q[0]);if(b.textRenderingMode===7&&(b.textClipActive=!0),!_){let V={_placeholder:!0};u.push(V),_={placeholder:V,ctm:b.ctm.slice(),fillColor:b.fillColor,fillAlpha:b.fillAlpha,fontObjIdFirst:b.fontObjId,textString:"",glyphs:[]}}let it=(()=>{let V=Ve(b.ctm,b.textMatrix),H={fontObjId:b.fontObjId??"",baselineX:V[4],baselineY:V[5],fill:hi(b.fillColor,lt()),text:"",placeholder:_.placeholder,renderMode:b.textRenderingMode};return g.push(H),H})();for(let V of nt){if(typeof V=="number"){let gt=-V*.001*b.fontSize*b.textHScale;b.textMatrix[4]+=gt*b.textMatrix[0],b.textMatrix[5]+=gt*b.textMatrix[1];continue}_.textString+=V.unicode??"",it.text+=V.unicode??"",V.isInFont!==!1&&_.glyphs.push({operatorListId:V.operatorListId,fontChar:V.fontChar,unicode:V.unicode,fontObjId:b.fontObjId??"",fontSize:b.fontSize,textMatrix:b.textMatrix.slice()});let U=(b.fontObjId!=null?n[b.fontObjId]:null)?.fontMatrix?.[0]??.001,Ct=((V.width??0)*U*b.fontSize+b.charSpacing+(V.isSpace?b.wordSpacing:0))*b.textHScale;b.textMatrix[4]+=Ct*b.textMatrix[0],b.textMatrix[5]+=Ct*b.textMatrix[1]}break}default:break}}kt();for(let X of k){let ot=X.inline,Q="ok";if(!ot){let V=typeof X.objId=="string"&&X.objId.startsWith("g_"),H=typeof X.objId=="string"?X.objId:null,U=await(V?ts(e,H):Nn(e,H));ot=U.data,Q=U.reason}if(!ot){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",H=Sn(X.ctm,t.heightPt),U=X.objId?`objId="${X.objId}"`:"inline image";r.logger?.emit?.("IMAGE_PDFJS_UNRESOLVED",{prefix:V,idLabel:U,bboxX:Ht(H.x),bboxY:Ht(H.y),bboxW:Ht(H.w),bboxH:Ht(H.h),page:r.pageIndex,objId:X.objId??null,reason:Q}),je(X.placeholder);continue}let nt=null;if(X.stencilFill){if(nt=await Iu(ot,X.stencilFill,r.logger,{objId:typeof X.objId=="string"?X.objId:null,pageIndex:r.pageIndex}),!nt){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",H=Sn(X.ctm,t.heightPt),U=X.stencilFill?.space??"unknown";r.logger?.emit?.("IMAGE_MASK_COMPOSITE_FAIL",{prefix:V,objId:X.objId??null,bboxX:Ht(H.x),bboxY:Ht(H.y),bboxW:Ht(H.w),bboxH:Ht(H.h),colourSpace:U,page:r.pageIndex}),je(X.placeholder);continue}}else if(X.compositeWith){if(nt=await ku(ot,X.compositeWith,r.logger,{objId:typeof X.objId=="string"?X.objId:null,pageIndex:r.pageIndex}),!nt){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",H=Sn(X.ctm,t.heightPt),U=X.compositeWith?.space??"unknown",at=ot?.kind,Ct=at!=null?`kind=${at}`:"bitmap";r.logger?.log?.(`${V}a luminosity SMask at (${H.x.toFixed(2)} in, ${H.y.toFixed(2)} in) ${H.w.toFixed(2)}\xD7${H.h.toFixed(2)} in could not be composited (mask ${Ct}, fill colour space "${U}"). The shadow was dropped from the imported design.`,"warning"),je(X.placeholder);continue}}else if(X.compositeWithMask){let V=X.compositeWithMask.mask,H=null;if(V.kind==="image"){let at=typeof V.objId=="string"?V.objId:null,gt=await(typeof at=="string"&&at.startsWith("g_")?ts(e,at):Nn(e,at));gt.data!=null&&(H={kind:"image",obj:gt.data,ctm:V.ctm})}else{let at=typeof V.patternId=="string"?V.patternId:null;if(at!=null){let Ct=await Nn(e,at);Ct.data!=null&&(H={kind:"shading",ir:Ct.data,ctm:V.ctm})}}if(H==null){let at=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",Ct=Sn(X.ctm,t.heightPt);r.logger?.log?.(`${at}a luminosity SMask at (${Ct.x.toFixed(2)} in, ${Ct.y.toFixed(2)} in) could not resolve its mask source (${V.kind}). The shadow was dropped from the imported design.`,"warning"),je(X.placeholder);continue}let U=await Ru({maskSource:H,imageObj:ot,imageCtm:X.ctm,modulatedAlpha:X.compositeWithMask.modulatedAlpha,pageBox:t,logger:r.logger,pageIndex:r.pageIndex});if(!U){let at=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",Ct=Sn(X.ctm,t.heightPt);r.logger?.log?.(`${at}a luminosity SMask at (${Ct.x.toFixed(2)} in, ${Ct.y.toFixed(2)} in) failed to rasterize (${V.kind} mask shape unsupported). The shadow was dropped from the imported design.`,"warning"),je(X.placeholder);continue}if(nt=await Ou(ot,U),!nt){je(X.placeholder);continue}}else if(nt=await ii(ot,r.logger,{objId:typeof X.objId=="string"?X.objId:null,ctm:X.ctm,pageIndex:r.pageIndex}),!nt){je(X.placeholder);continue}let it=Sn(X.ctm,t.heightPt,{logger:r.logger,pageIndex:r.pageIndex,objId:X.objId});Object.assign(X.placeholder,{kind:"image",x:it.x,y:it.y,width:it.w,height:it.h,mimeType:"image/png",bytes:nt,opacity:X.opacity??1,...Math.abs(it.rotation)>1e-6?{rotation:it.rotation}:{},...it.flipHorizontal?{flipHorizontal:!0}:{},...it.flipVertical?{flipVertical:!0}:{},...X.blendMode?{blendMode:X.blendMode}:{},...X.clips&&X.clips.length>0?{clips:X.clips}:{}})}for(let X of F){let ot=await Ku({page:e,pattern:X.pattern,logger:r.logger,pageIndex:r.pageIndex});if(!ot){je(X.placeholder);continue}let Q=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("TILING_PATTERN_AS_IMAGE",{prefix:Q,patternId:X.pattern.patternId,page:r.pageIndex});let nt=Sn(X.placementCtm,t.heightPt,{logger:r.logger,pageIndex:r.pageIndex,objId:X.pattern.patternId});Object.assign(X.placeholder,{kind:"image",x:nt.x,y:nt.y,width:nt.w,height:nt.h,mimeType:"image/png",bytes:ot.bytes,opacity:X.opacity??1,...Math.abs(nt.rotation)>1e-6?{rotation:nt.rotation}:{},...nt.flipHorizontal?{flipHorizontal:!0}:{},...nt.flipVertical?{flipVertical:!0}:{},...X.blendMode?{blendMode:X.blendMode}:{},...X.clips&&X.clips.length>0?{clips:X.clips}:{}})}for(let X of O){let ot=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";if(typeof X.patternId!="string"){r.logger?.emit?.("SHADING_NO_PATTERN_REF",{prefix:ot,page:r.pageIndex}),je(X.placeholder);continue}let Q=(await Nn(e,X.patternId)).data,nt=Yu({shadingIR:Q,ctm:X.ctm,clipEntry:X.clipEntry,remainingClips:X.remainingClips,pageBox:t,opacity:X.opacity,blendMode:X.blendMode,logger:r.logger,pageIndex:r.pageIndex});if(!nt){je(X.placeholder);continue}Object.assign(X.placeholder,nt)}return{out:u,colorSnapshots:g}}function Iv(o){let t=[];for(let e of o)if(!e._removed){if(e._placeholder){Array.isArray(e._replacements)&&t.push(...e._replacements);continue}t.push(e)}return t}function Pv(o,t,e,n){let r=n?.textMode??"outline",a=[];if(o.placeholder._replacements=a,r==="outline"){let f=Za(o,o.glyphs,t,e);f&&a.push(f);return}let c=ju(o.glyphs,t,o.ctm,e.heightPt),u=[];o.placeholder._lazyGlyphOutlines=u;for(let f of c){let g=t[f.fontObjId];if(Nu(g,f.glyphs)){let b=f;u.push(()=>{let v=Za(o,b.glyphs,t,e);return!v||v.kind!=="text-outline"?null:{d:v.d,x:v.x,y:v.y,width:v.width,height:v.height}});continue}if(r==="editable"){let b=g?.name??f.fontObjId;throw new Error(`textMode 'editable': embeddability gate failed for font ${b} (text: ${JSON.stringify(f.text)})`)}let m=Za(o,f.glyphs,t,e);m&&a.push(m)}}function Za(o,t,e,n){if(!t||t.length===0)return null;let r=[],a=[],c=0,u=0,f="";for(let dt of t){let Y=e[dt.fontObjId];if(!Y)continue;let K=Y.fontMatrix??[.001,0,0,.001,0,0],bt=[dt.fontSize,0,0,dt.fontSize,0,0],lt=Ve(bt,K);lt=Ve(dt.textMatrix,lt),lt=Ve(o.ctm,lt);let kt=null;if(Y.isType3Font?kt=Rv(Y,dt.operatorListId):Y._parsed&&(kt=Ov(Y,dt)),kt){let ot=sh(kt,lt,n.heightPt);r.push(...ot.cmds),a.push(...ot.devPoints)}let X=Ve(o.ctm,Ve(dt.textMatrix,bt));c+=Math.hypot(X[2],X[3]),u+=1,f+=dt.unicode??""}let g=u>0?c/u:0,m=1/0,b=1/0,v=-1/0,S=-1/0;for(let[dt,Y]of a)dt<m&&(m=dt),Y<b&&(b=Y),dt>v&&(v=dt),Y>S&&(S=Y);Number.isFinite(m)||(m=b=v=S=0);let T=e[t[0].fontObjId],{style:w,weight:I}=Uu(T),k=Fs(T?.name??""),O=k.family||k.fullName,F=Ve(o.ctm,t[0].textMatrix),_=F[4],D=n.heightPt-F[5],G=-Math.atan2(F[1],F[0]),j=Math.cos(-G),W=Math.sin(-G),$=1/0,Z=1/0,q=-1/0,yt=-1/0;for(let[dt,Y]of a){let K=dt*j-Y*W,bt=dt*W+Y*j;K<$&&($=K),bt<Z&&(Z=bt),K>q&&(q=K),bt>yt&&(yt=bt)}let et=Number.isFinite($)?Math.max(0,q-$):0,Tt=Number.isFinite(Z)?Math.max(0,yt-Z):0;return{kind:"text-outline",x:m,y:b,width:Math.max(0,v-m),height:Math.max(0,S-b),d:rh(r,m,b),text:f,fontFamily:O,fontSize:g,fontStyle:w,fontWeight:I,fill:hi(o.fillColor,o.fillAlpha),opacity:o.fillAlpha!=null&&o.fillAlpha<1?o.fillAlpha:1,textOriginX:_,textOriginY:D,rotation:G,unrotWidth:et,unrotHeight:Tt}}function Rv(o,t){let e=o?.charProcOperatorList?.[t];if(!e)return null;let n=e.fnArray,r=e.argsArray,a={ops:[],coords:[]};for(let c=0;c<n.length;c++)if(n[c]===st.constructPath){let u=r[c];a.ops.push(...u[0]),a.coords.push(...u[1])}return a.ops.length===0?null:a}function Ov(o,t){let e=o._parsed;if(!e)return null;let n=null,r=e.encoding,a=m=>{if(m==null)return-1;let b=r?.cmap?.glyphIndexMap?.[m];if(typeof b=="number")return b;try{let v=r?.charToGlyphIndex?.(m);return typeof v=="number"?v:-1}catch{return-1}},c=t.fontChar?t.fontChar.codePointAt(0):null,u=a(c);if(u>0&&(n=e.glyphs.get(u)),!n)try{t.fontChar&&(n=e.charToGlyph(t.fontChar))}catch{}if((!n||n.index===0)&&t.unicode)try{let m=e.charToGlyph(t.unicode);m&&m.index>0&&(n=m)}catch{}if(!n||!n.path||n.index===0)return null;let f=[],g=[];for(let m of n.path.commands)switch(m.type){case"M":f.push(st.moveTo),g.push(m.x,m.y);break;case"L":f.push(st.lineTo),g.push(m.x,m.y);break;case"C":f.push(st.curveTo),g.push(m.x1,m.y1,m.x2,m.y2,m.x,m.y);break;case"Q":{f.push(st.curveTo),g.push(m.x1,m.y1,m.x1,m.y1,m.x,m.y);break}case"Z":f.push(st.closePath);break;default:break}return f.length===0?null:{ops:f,coords:g}}function je(o){o._removed=!0}function Zu(o,t,e){if(es(t))return;let n=xn(t,e);n.length>0&&(o.clips=n)}function Qu(o){return{space:"rgb",values:[o[0]/255,o[1]/255,o[2]/255]}}function Ju(o){if(!Array.isArray(o)||o.length===0)return{key:null,components:[]};let t=o[o.length-1];return typeof t=="string"||t===null?{key:typeof t=="string"?t:null,components:o.slice(0,-1)}:{key:null,components:o}}function qu(o,t,e,n){if(o==null)return n;switch(o){case"DeviceGray":return{space:"gray",values:[t?.[0]??0]};case"DeviceRGB":return{space:"rgb",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0]};case"DeviceCMYK":return{space:"cmyk",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0,t?.[3]??0]}}let r=e[o];if(!r)return n;if(r.kind==="separation"){let a=t?.[0]??1,c=Array.isArray(r.solid)?r.solid:[],u=c.map(f=>f*a);return{space:"spot",name:r.name,tint:a,alternateSpace:r.alternateSpace,solid:c,values:u}}if(r.kind==="deviceN"){let a=Array.isArray(r.solid)?r.solid:[];return r.alternateSpace==="DeviceCMYK"?{space:"cmyk",values:a.slice(0,4)}:r.alternateSpace==="DeviceGray"?{space:"gray",values:a.slice(0,1)}:{space:"rgb",values:a.slice(0,3)}}return n}function Mv(o){switch(o){case st.fill:return{fill:!0,stroke:!1,fillRule:"nonzero"};case st.eoFill:return{fill:!0,stroke:!1,fillRule:"evenodd"};case st.stroke:case st.closeStroke:return{fill:!1,stroke:!0,fillRule:"nonzero"};case st.fillStroke:case st.closeFillStroke:return{fill:!0,stroke:!0,fillRule:"nonzero"};case st.eoFillStroke:case st.closeEOFillStroke:return{fill:!0,stroke:!0,fillRule:"evenodd"};default:return null}}function th(o,t,e,n){let r=Fv(o,e.ctm,n.heightPt);if(!r)return null;let{devPoints:a,cmds:c}=r;if(a.length===0)return null;let u=1/0,f=1/0,g=-1/0,m=-1/0;for(let[_,D]of a)_<u&&(u=_),D<f&&(f=D),_>g&&(g=_),D>m&&(m=D);let b=g-u,v=m-f;if(b<=0&&v<=0)return null;let S=t.stroke?Math.abs(Gv(e.ctm)*e.lineWidth):0,T=t.stroke&&b<=0?S:0,w=t.stroke&&v<=0?S:0,I=u-T/2,k=f-w/2,O=b+T,F=v+w;return{kind:"vector-path",x:I,y:k,width:O,height:F,d:rh(c,I,k),fill:t.fill?hi(e.fillColor,e.fillAlpha):null,stroke:t.stroke?hi(e.strokeColor,e.strokeAlpha):null,strokeWidth:S,fillRule:Lv(t,c),opacity:1,blendMode:e.blendMode}}function Lv(o,t){return o.fill?"evenodd":o.fillRule}function Fv(o,t,e){return sh(o,t,e)}function sh(o,t,e){let n=o.ops??[],r=o.coords??[],a=[],c=[],u=0,f=null,g=(m,b)=>{let[v,S,T,w,I,k]=t;return[v*m+T*b+I,e-(S*m+w*b+k)]};for(let m=0;m<n.length;m++)switch(n[m]){case st.rectangle:{let v=r[u++],S=r[u++],T=r[u++],w=r[u++],I=g(v,S),k=g(v+T,S),O=g(v+T,S+w),F=g(v,S+w);c.push({cmd:"M",pts:[I]}),c.push({cmd:"L",pts:[k]}),c.push({cmd:"L",pts:[O]}),c.push({cmd:"L",pts:[F]}),c.push({cmd:"Z"}),a.push(I,k,O,F);break}case st.moveTo:{let v=g(r[u++],r[u++]);c.push({cmd:"M",pts:[v]}),a.push(v),f=v;break}case st.lineTo:{let v=g(r[u++],r[u++]);c.push({cmd:"L",pts:[v]}),a.push(v),f=v;break}case st.curveTo:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]),T=g(r[u++],r[u++]);c.push({cmd:"C",pts:[v,S,T]}),a.push(v,S,T),f=T;break}case st.curveTo2:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]),T=f??v;c.push({cmd:"C",pts:[T,v,S]}),a.push(v,S),f=S;break}case st.curveTo3:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]);c.push({cmd:"C",pts:[v,S,S]}),a.push(v,S),f=S;break}case st.closePath:c.push({cmd:"Z"});break;default:break}return{devPoints:a,cmds:c}}function rh(o,t,e){let n=a=>`${Math.round(a*100)/100}`,r=[];for(let a of o){if(a.cmd==="Z"){r.push("Z");continue}let c=(a.pts??[]).map(([u,f])=>`${n(u-t)} ${n(f-e)}`).join(" ");r.push(`${a.cmd} ${c}`)}return r.join(" ")}var Dv=.01,_v=.05;function ns(o,t,e,n){let r=o?.pageIndex!=null?`Page ${o.pageIndex}: `:"",a=Sn(t,e.heightPt);o?.logger?.emit?.("TEXT_CLIP_MODE_7_DROPPED",{prefix:r,label:n,bbox:`${Ht(a.x)}, ${Ht(a.y)}`,bboxSize:`${Ht(a.w)}\xD7${Ht(a.h)}`,page:o?.pageIndex})}function Sn(o,t,e=null){let[n,r,a,c,u,f]=o,g=Math.hypot(n,r),m=Math.hypot(a,c),b=Math.atan2(-r,n);if(Math.abs(r)<1e-6&&Math.abs(a)<1e-6||Math.abs(b)<_v)return Nv(o,t);let S=g>0&&m>0?(n*a+r*c)/(g*m):0;if(!(Math.abs(S)<Dv)||!(g>0&&m>0))return Uv(o,t,e,S);let T=u+(n+a)*.5,w=f+(r+c)*.5,I=Math.atan2(-r,n),k=n*c-r*a<0;return{x:T-g*.5,y:t-w-m*.5,w:g,h:m,rotation:I,flipHorizontal:!1,flipVertical:k}}function Nv(o,t){let[e,n,r,a,c,u]=o,f=[c,c+e,c+r,c+e+r],g=[u,u+n,u+a,u+n+a],m=Math.min(...f),b=Math.max(...f),v=Math.min(...g),S=Math.max(...g);return{x:m,y:t-S,w:b-m,h:S-v,rotation:0,flipHorizontal:e<0,flipVertical:a<0}}function Uv(o,t,e=null,n=null){let[r,a,c,u,f,g]=o,m=[f,f+r,f+c,f+r+c],b=[g,g+a,g+u,g+a+u],v=Math.min(...m),S=Math.max(...m),T=Math.min(...b),w=Math.max(...b),I={x:v,y:t-w,w:S-v,h:w-T,rotation:0,flipHorizontal:!1,flipVertical:!1};if(e?.logger?.emit){let k=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",O=n!=null?`, residual=${Ht(n)}`:"",F=e.objId?` objId="${e.objId}"`:"";e.logger.emit("IMAGE_SKEW_DROPPED",{prefix:k,idLabel:F,bboxX:Ht(I.x),bboxY:Ht(I.y),bboxW:Ht(I.w),bboxH:Ht(I.h),ctm:Vu(o),residualStr:O,page:e.pageIndex,objId:e.objId??null})}return I}function hi(o,t){return o==null?null:t==null||t===1?o:{...o,alpha:t}}function eh(o={x:0,y:0}){return{ctm:[1,0,0,1,-o.x,-o.y],fillColor:{space:"gray",values:[0]},strokeColor:{space:"gray",values:[0]},fillColorSpaceName:null,strokeColorSpaceName:null,fillPattern:null,fillAlpha:1,strokeAlpha:1,lineWidth:1,blendMode:null,textMatrix:ui.slice(),textLineMatrix:ui.slice(),fontObjId:null,fontSize:0,charSpacing:0,wordSpacing:0,textHScale:1,textRise:0,textLeading:0,textRenderingMode:0,textClipActive:!1}}function Bv(o){return{ctm:o.ctm.slice(),fillColor:o.fillColor,strokeColor:o.strokeColor,fillColorSpaceName:o.fillColorSpaceName,strokeColorSpaceName:o.strokeColorSpaceName,fillPattern:o.fillPattern,fillAlpha:o.fillAlpha,strokeAlpha:o.strokeAlpha,lineWidth:o.lineWidth,blendMode:o.blendMode,textMatrix:o.textMatrix.slice(),textLineMatrix:o.textLineMatrix.slice(),fontObjId:o.fontObjId,fontSize:o.fontSize,charSpacing:o.charSpacing,wordSpacing:o.wordSpacing,textHScale:o.textHScale,textRise:o.textRise,textLeading:o.textLeading,textRenderingMode:o.textRenderingMode,textClipActive:o.textClipActive}}function Gv([o,t,e,n]){return(Math.hypot(o,t)+Math.hypot(e,n))/2}function Hv(o){if(!Array.isArray(o)||o.length<5||o[0]!=="TilingPattern")return null;let t=o[2];if(!t||!Array.isArray(t.fnArray)||!Array.isArray(t.argsArray))return null;let e=o[3]??[1,0,0,1,0,0],n=o[4]??[0,0,0,0],r="pattern";for(let a=0;a<t.fnArray.length;a++)if(t.fnArray[a]===st.paintImageXObject){let u=t.argsArray[a]?.[0];if(typeof u=="string"){r=`pattern[${u}]`;break}}return{patternId:r,operatorList:{fnArray:t.fnArray,argsArray:t.argsArray},matrix:e,bbox:n}}function jv(o){let t=o.coords??[];if(t.length<2)return null;let e=1/0,n=1/0,r=-1/0,a=-1/0;for(let c=0;c+1<t.length;c+=2){let u=t[c],f=t[c+1];u<e&&(e=u),f<n&&(n=f),u>r&&(r=u),f>a&&(a=f)}return!Number.isFinite(e)||!Number.isFinite(n)?null:{x:e,y:n,w:r-e,h:a-n}}function Vv(o,t){let[e,n,r,a,c,u]=o,f=t.y+t.h;return[e*t.w,n*t.w,-r*t.h,-a*t.h,e*t.x+r*f+c,n*t.x+a*f+u]}function Ve(o,t){let[e,n,r,a,c,u]=o,[f,g,m,b,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*b,n*m+a*b,e*v+r*S+c,n*v+a*S+u]}function $v(o,t){return o.filter(e=>{if(e.kind!=="vector-path")return!0;let n=e.fill;return!(n&&"alpha"in n&&n.alpha===0&&!e.stroke||zv(e,t))})}function zv(o,t){if(o.kind!=="vector-path"||o.stroke||!o.fill||o.fill.space!=="rgb")return!1;let[e,n,r]=o.fill.values;if(!(e>=.98&&n>=.98&&r>=.98))return!1;let a=1;return Math.abs(o.x)<=a&&Math.abs(o.y)<=a&&Math.abs(o.width-t.widthPt)<=a&&Math.abs(o.height-t.heightPt)<=a}var Wv=.05,Xv=1.5,di=1;async function ih(o,t){let e=await o.getTextContent({includeMarkedContent:!1,disableNormalization:!0}),n=[],r={cursor:0,consumed:new Set};for(let a of e.items){if(a.type||sx(a.str))continue;if(a.str&&a.str.length>0&&a.str.trim()===""){let m=t.pageBox.originShiftPt??{x:0,y:0};Jv({fontObjId:a.fontName,baselineX:a.transform[4]-m.x,baselineY:a.transform[5]-m.y,widthPt:a.width,str:a.str,dirSignX:a.transform[0]<0?-1:1},t.colorSnapshots,r);continue}if(!a.str)continue;let c=oh(o,a.fontName);if(!li(c))continue;let u=e.styles?.[a.fontName],f=await Yv(a,c,u,t,r);if(!f||!f.run)continue;let g=f.placeholder;if(g&&Array.isArray(g._replacements)){let m=g._lazyGlyphOutlines;Array.isArray(m)&&m.length>0&&(f.run._buildGlyphOutline=m.shift()),g._replacements.push(f.run)}else n.push(f.run)}return n}async function Yv(o,t,e,n,r){let[a,c,u,f,g,m]=o.transform,b=Math.hypot(u,f);if(!(b>0))return null;let v=Math.atan2(c,a),S=n.pageBox.originShiftPt??{x:0,y:0},T=g-S.x,w=m-S.y,{ascentRatio:I,descentRatio:k}=nx(e,t),O=b*I,F=b*k,_=o.width+b*Wv,D=O+F,G=Math.cos(v),j=Math.sin(v),W=_/2,$=(O-F)/2,Z=T+W*G-$*j,q=w+W*j+$*G,yt=Z-W,et=n.pageBox.heightPt-q-D/2,Tt=D/2,dt=yt-Tt*j,Y=et+Tt*(1-G),K=await Wa(t,n.logger);if(!K)return null;n.docFonts.has(K.postScriptName)||n.docFonts.set(K.postScriptName,K);let bt=Zv({fontObjId:o.fontName,baselineX:T,baselineY:w,widthPt:o.width,str:o.str,dirSignX:a<0?-1:1},n.colorSnapshots,r);if(bt==null)return null;let lt=K,kt=bt.walkerFontObjId;if(kt&&kt!==o.fontName&&n.page){let V=oh(n.page,kt);if(V&&li(V)){let H=await Wa(V,n.logger);H&&(lt=H,n.docFonts.has(H.postScriptName)||n.docFonts.set(H.postScriptName,H))}}if(bt.renderMode===3||bt.renderMode===7){let V=n.pageIndex!=null?` on page ${n.pageIndex}`:"",H=bt.renderMode===7?"7 (add to clipping path)":"3 (invisible)";return n.logger?.emit?.("TEXT_RENDER_MODE_SKIPPED",{pageTag:V,text:Kv(o.str,60),modeLabel:H,page:n.pageIndex,renderMode:bt.renderMode}),null}let{fill:X,colorSpans:ot}=bt,Q=X?.alpha,nt=Q!=null&&Q<1?Q:1,it={kind:"text-run",x:dt,y:Y,width:_,height:D,text:o.str,fontRef:lt.postScriptName,fontSize:b,rotation:-v,fill:X,...ot?{colorSpans:ot}:{},baselineXPt:T,baselineYPt:w,advanceWidthPt:o.width};return it.opacity=nt,{run:it,placeholder:bt.placeholder??null}}function Kv(o,t){return typeof o!="string"?"":o.length>t?`${o.slice(0,t)}\u2026`:o}function Zv(o,t,e){let n=[],r=[],a=e.cursor,c=o.str.length,u=0;for(let T=e.cursor;T<t.length;T++){if(e.consumed.has(T)||!fi(t[T])||!pi(t[T],o))continue;let w=t[T].text?.length??0;if(u>=c)break;n.push(t[T]),r.push(T),u+=w,a=T+1}if(n.length===0)for(let T=0;T<t.length;T++){if(e.consumed.has(T)||!fi(t[T])||!pi(t[T],o))continue;let w=t[T].text?.length??0;if(u>=c)break;n.push(t[T]),r.push(T),u+=w}else e.cursor=a;if(n.length===0){for(let T=0;T<t.length;T++)if(e.consumed.has(T)&&fi(t[T])&&pi(t[T],o)&&tx(t[T].text,o.str))return null;return{fill:null,colorSpans:void 0,renderMode:0,placeholder:null,walkerFontObjId:null}}for(let T of r)e.consumed.add(T);let f=n[0].renderMode??0,g=n[0].placeholder??null,m=qv(n,o.str),b=n[0].fill??null;if(n.every(T=>Qa(T.fill??null,b)))return{fill:b,colorSpans:void 0,renderMode:f,placeholder:g,walkerFontObjId:m};let S=n.reduce((T,w)=>T+(w.text?.length??0),0);if(S===o.str.length&&S>0){let T=[],w=0;for(let I of n){let k=I.text?.length??0;if(k===0)continue;let O=w,F=w+k;w=F;let _=T[T.length-1];_&&Qa(_.fill,I.fill??null)?_.to=F:T.push({from:O,to:F,fill:I.fill??null})}return T.length===0?{fill:b,colorSpans:void 0,renderMode:f,placeholder:g,walkerFontObjId:m}:{fill:T[0].fill,colorSpans:T,renderMode:f,placeholder:g,walkerFontObjId:m}}return Qv(o,n,b,f,g,m)}function Qv(o,t,e,n,r,a){let c=o.str.length;if(o.widthPt<=0||c===0)return{fill:e,colorSpans:void 0,renderMode:n,placeholder:r,walkerFontObjId:a};let u=t.map(g=>({from:Math.max(0,Math.min(c,Math.round((g.baselineX-o.baselineX)/o.widthPt*c))),fill:g.fill??null}));u.sort((g,m)=>g.from-m.from);let f=[];for(let g=0;g<u.length;g++){let m=u[g].from,b=g+1<u.length?u[g+1].from:c;if(m>=b)continue;let v=f[f.length-1];v&&Qa(v.fill,u[g].fill)?v.to=b:f.push({from:m,to:b,fill:u[g].fill})}return f.length===0?{fill:e,colorSpans:void 0,renderMode:n,placeholder:r,walkerFontObjId:a}:{fill:f[0].fill,colorSpans:f,renderMode:n,placeholder:r,walkerFontObjId:a}}function Jv(o,t,e){let n=[],r=e.cursor,a=o.str.length,c=0;for(let u=e.cursor;u<t.length;u++){if(e.consumed.has(u)||!fi(t[u])||!pi(t[u],o))continue;let f=t[u].text??"";if(f.length>a-c||f.length>0&&f.trim()!==""||(n.push(u),c+=f.length,r=u+1,c>=a))break}if(n.length!==0){e.cursor=r;for(let u of n)e.consumed.add(u)}}function qv(o,t){if(o.length===0)return null;let e=t.trim();if(o.length===1&&e.length>0&&o[0].text!=null&&o[0].text.trim().length===0)return null;if(o.length===1&&o[0].fontObjId)return o[0].fontObjId;if(e.length===0)return o[0].fontObjId||null;for(let n of o){if(!n.fontObjId||!n.text)continue;let r=n.text.replace(/^\s+/,"");if(r===e||r.startsWith(e)||e.startsWith(r)&&r.length>=2)return n.fontObjId}return null}function tx(o,t){if(!o)return!1;let e=o.trim(),n=t.trim();return e.length===0||n.length===0?!1:e.includes(n)||n.includes(e)}function fi(o){if(!o)return!1;let t=o.fill;return t?(t.alpha??1)>0:!1}function Qa(o,t){if(o==null&&t==null)return!0;if(o==null||t==null||o.space!==t.space||(o.alpha??1)!==(t.alpha??1)||!o.values||!t.values||o.values.length!==t.values.length)return!1;for(let e=0;e<o.values.length;e++)if(Math.abs(o.values[e]-t.values[e])>1e-6)return!1;return!0}function pi(o,t){if(Math.abs(o.baselineY-t.baselineY)>Xv)return!1;let e=ex(o.text),n,r;return t.dirSignX<0?(n=t.baselineX-t.widthPt-di,r=t.baselineX+di+e):(n=t.baselineX-di-e,r=t.baselineX+t.widthPt+di),!(o.baselineX<n||o.baselineX>r)}function ex(o){if(!o)return 0;let t=0;for(let e of o)if(e===" "||e===" "||e==="\xA0")t++;else break;return t*5}function nx(o,t){if(Number.isFinite(o?.ascent)&&Number.isFinite(o?.descent))return{ascentRatio:o.ascent,descentRatio:Math.abs(o.descent)};let e=t?._parsed,n=e?.unitsPerEm,r=e?.tables?.hhea,a=r?.ascender,c=r?.descender;return typeof n=="number"&&Number.isFinite(n)&&n>0&&Number.isFinite(a)&&Number.isFinite(c)?{ascentRatio:a/n,descentRatio:Math.abs(c)/n}:{ascentRatio:.8,descentRatio:.2}}function oh(o,t){if(!t)return null;try{if(o.commonObjs.has(t))return o.commonObjs.get(t)}catch{}return null}function sx(o){for(let t of o){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}async function ah(){return new URL("./pdf.worker.mjs",import.meta.url).href}async function lh(){return new URL("./standard_fonts/",import.meta.url).href}var Ja=2;function rx(o){let t=o?.imglyPatchVersion??null;if(t!==Ja)throw new Error(`[@imgly/pdf-importer] @imgly/pdfjs-dist patch missing or outdated (got ${t??"none"}, expected ${Ja}). The patched APIs (trimBox, bleedBox, colorSpaceResources, native CMYK args) are required for correct color and geometry import. Pin @imgly/pdfjs-dist to 4.10.38-imgly.${Ja} or newer and reinstall.`)}async function ch(o,t={}){let e=t.pdfjsModule??await Promise.resolve().then(()=>(Ga(),Cu));e.GlobalWorkerOptions.workerSrc=t.workerSrc??await ah();let n=t.standardFontDataUrl??await lh(),r=t.textMode??"outline",a=o instanceof Uint8Array?o:(()=>{let m=o;return new Uint8Array(m.buffer??o,m.byteOffset??0,m.byteLength??m.length)})(),u=await e.getDocument({data:a,password:t.password,disableFontFace:!0,useSystemFonts:!1,isEvalSupported:!1,fontExtraProperties:!0,standardFontDataUrl:n}).promise,f=new Map,g=[];for(let m=1;m<=u.numPages;m++){let b=await u.getPage(m);m===1&&rx(b),g.push(await ix(b,{textMode:r,docFonts:f,logger:t.logger,pageIndex:m})),b.cleanup()}return await u.destroy(),{source:t.source??"unknown",pages:g,fonts:f}}async function ix(o,t){let e=o.trimBox,n=o.bleedBox,r=o.view??[0,0,0,0],a=r[2]-r[0],c=r[3]-r[1],u={x:r[0],y:r[1]},f={widthPt:a,heightPt:c,originShiftPt:u},g=null,m={left:0,top:0,right:0,bottom:0},b=!1;e&&(g={xPt:e[0]-r[0],yPt:r[3]-e[3],widthPt:e[2]-e[0],heightPt:e[3]-e[1]},n&&(m={left:Math.max(0,e[0]-n[0]),bottom:Math.max(0,e[1]-n[1]),right:Math.max(0,n[2]-e[2]),top:Math.max(0,n[3]-e[3])},b=!0));let{colorSnapshots:v,finalize:S}=await nh(o,f,t),T=t.textMode==="outline"?[]:await ih(o,{pageBox:f,docFonts:t.docFonts,colorSnapshots:v,logger:t.logger,pageIndex:t.pageIndex,page:o}),w=S();T.length>0&&w.push(...T);let I=o.rotate??0;if(I!==0){let k=t.pageIndex!=null?`Page ${t.pageIndex}: `:"";t.logger?.emit?.("DOC_PAGE_ROTATION_DROPPED",{prefix:k,pageRotation:I,page:t.pageIndex})}return{widthPt:a,heightPt:c,rotation:I,trimPt:g,bleedPt:m,hasBleed:b,blocks:w}}var se=Object.freeze({IMAGE:"image",VECTOR_PATH:"vector-path",TEXT_OUTLINE:"text-outline",TEXT_RUN:"text-run"}),ox=72,zt=o=>o/ox;var uh=Object.freeze({"source-over":null,normal:null,multiply:"Multiply",screen:"Screen",overlay:"Overlay",darken:"Darken",lighten:"Lighten","color-dodge":"ColorDodge","color-burn":"ColorBurn","hard-light":"HardLight","soft-light":"SoftLight",difference:"Difference",exclusion:"Exclusion",hue:"Hue",saturation:"Saturation",color:"Color",luminosity:"Luminosity"});function gi(o,t){return o==null||o===""?null:Object.prototype.hasOwnProperty.call(uh,o)?uh[o]:(t?.emit?.("BLEND_MODE_UNSUPPORTED",{mode:o}),null)}function mi(o,t,e,n){let r=o.block.createShape("vector_path");o.block.setString(r,"vector_path/path",t);try{o.block.setFloat(r,"vector_path/width",e),o.block.setFloat(r,"vector_path/height",n)}catch{}return r}var hh=()=>({state:"unknown",warned:!1});var bi=Symbol("COMBINE_EMPTY_INTERSECTION");function tl(o,t,e){if(!Array.isArray(t)||t.length<2)return e?.logger?.emit?.("CLIP_COMBINE_TOO_FEW_INPUTS",{prefix:qa(e),inputCount:t?.length??0,label:e?.label??null}),null;if(!o.block.isCombinable(t))return e?.logger?.emit?.("CLIP_COMBINE_NOT_COMBINABLE",{prefix:qa(e),inputCount:t.length,label:e?.label??null}),null;try{return o.block.combine(t,"Intersection")}catch(n){let r=n&&typeof n=="object"&&"message"in n?String(n.message):String(n);return ax(r)?bi:(e?.logger?.emit?.("CLIP_COMBINE_THREW",{prefix:qa(e),inputCount:t.length,reason:r,label:e?.label??null}),null)}}function ax(o){return typeof o=="string"&&o.includes("empty shape")}function qa(o){return o?.label?`${o.label}: `:""}function Ds(o,t){for(let e of t)try{o.block.isValid?.(e)!==!1&&o.block.destroy(e)}catch{}}function lx(){return{scaleRatio:1,translationX:0,translationY:0,rotation:0}}function dh(o){return o.scaleRatio===1&&o.translationX===0&&o.translationY===0&&o.rotation===0}function fh(o,t){if(cx(o,t))return lx();let n=1/Math.max(t.width/o.width,t.height/o.height),r=o.x+o.width/2,a=o.y+o.height/2,c=t.x+t.width/2,u=t.y+t.height/2,f=t.width/2,g=t.height/2,m=f===0?0:(r-c)/f,b=g===0?0:(a-u)/g;return{scaleRatio:n,translationX:m,translationY:b,rotation:0}}function ph(o,t){let e=Math.max(o.x,t.x),n=Math.max(o.y,t.y),r=Math.min(o.x+o.width,t.x+t.width),a=Math.min(o.y+o.height,t.y+t.height);return{x:e,y:n,width:r-e,height:a-n}}function cx(o,t){return o.x===t.x&&o.y===t.y&&o.width===t.width&&o.height===t.height}function ss(o,t,e,n){if(!e?.bytes||e.bytes.length===0)return n?.logger?.emit?.("IMAGE_NO_PIXELS",{}),!1;let r=o.block.createFill("image"),a=o.editor.createBuffer(),c=e.bytes instanceof Uint8Array?e.bytes:new Uint8Array(e.bytes);return o.editor.setBufferData(a,0,c),o.block.setString(r,"fill/image/imageFileURI",a),o.block.setFill(t,r),!0}function gh(o,t,e,n){if(!(!e?.flipHorizontal&&!e?.flipVertical))try{o.block.getGlobalBoundingBoxX(t),e.flipHorizontal&&o.block.flipCropHorizontal(t),e.flipVertical&&o.block.flipCropVertical(t)}catch{n?.logger?.emit?.("IMAGE_FLIP_UNSUPPORTED",{})}}var Gn=Symbol("EMITTED_DROPPED");function xh(o,t,e,n,r){if(!t?.bytes||t.bytes.length===0)return r?.logger?.emit?.("IMAGE_CLIPPED_NO_BYTES",{prefix:Bn(r),bbox:Me(t),page:r?.pageIndex}),null;let a=e.filter(g=>_s(g)),c=e.filter(g=>!_s(g)&&!vh(g,t)),u=e.filter(g=>!_s(g)&&vh(g,t));if(u.length===0)return r?.logger?.emit?.("IMAGE_CLIP_UNUSABLE",{prefix:Bn(r),bbox:Me(t),clipCount:e.length,degenerateCount:a.length,disjointCount:c.length,page:r?.pageIndex}),Gn;let f=hx(u,t);return f.length===1?Ah(o,t,f[0],r):bx(o,t,f,n,r)}function hx(o,t){let e=[],n=new Set;for(let r of o)dx(r,t)||n.has(r.d)||(n.add(r.d),e.push(r));return e.length>0?e:[o[0]]}function dx(o,t){if(!fx(o.d))return!1;let e=.001;return o.x<=t.x+e&&o.y<=t.y+e&&o.x+o.width+e>=t.x+t.width&&o.y+o.height+e>=t.y+t.height}function fx(o){if(typeof o!="string")return!1;let t=o.split(/\s+/),e=[],n=[],r=0;for(;r<t.length;){let u=t[r++];if(!(u==="Z"||u==="z")){if(u==="M"||u==="L"){let f=parseFloat(t[r++]),g=parseFloat(t[r++]);if(Number.isNaN(f)||Number.isNaN(g))return!1;e.push(f),n.push(g);continue}return!1}}if(e.length!==4&&e.length!==5)return!1;let a=.001,c=u=>{let f=[];for(let g of u)f.some(m=>Math.abs(m-g)<=a)||f.push(g);return f};return c(e).length===2&&c(n).length===2}function Sh(o,t,e,n,r){let a=e.filter(b=>_s(b)),c=e.filter(b=>!_s(b));if(c.length===0)return r?.logger?.emit?.("CLIP_DEGENERATE_FALLBACK",{prefix:Bn(r),bbox:Me(t),clipCount:e.length,degenerateCount:a.length,page:r?.pageIndex}),null;if(!t.fill)return r?.logger?.emit?.("CLIP_COMBINE_STROKE_ONLY",{prefix:Bn(r),bbox:Me(t),clipCount:e.length,page:r?.pageIndex}),null;let u=[];for(let b of c){let v=Ch(o,b);o.block.appendChild(n,v),u.push(v)}let f={x:t.x,y:t.y,width:t.width,height:t.height},g=Cx(o,t.d,f,t.fill,t.opacity);o.block.appendChild(n,g);let m=tl(o,[g,...u],{logger:r?.logger,label:`${Bn(r)}vector path at ${Me(t)}`});return m===bi?(Ds(o,[g,...u]),Gn):m==null?(Ds(o,[g,...u]),null):(gx(o,m,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(m,t.opacity),el(o,m,t.blendMode,r?.logger),px(o,m,t,r),m)}function px(o,t,e,n){let r=n?.vectorPathFillRuleSupport;if(!r)return;let a;try{a=o.block.getShape(t)}catch{return}e.fillRule,n?.logger}function gx(o,t,e){let n=e.fill,r=n?.kind;if(r==="linearGradient"||r==="radialGradient"){mx(o,t,e);return}let a=o.block.createFill("color");o.block.setColor(a,"fill/color/value",nl(n)),o.block.setFill(t,a)}function mx(o,t,e){let n=e.fill,r=n.kind==="linearGradient"?"gradient/linear":"gradient/radial",a=o.block.createFill(r),c=(n.stops??[]).map(g=>({color:nl(g.color),stop:g.offset}));o.block.setGradientColorStops(a,"fill/gradient/colors",c);let u=e.width>0?e.width:1,f=e.height>0?e.height:1;if(n.kind==="linearGradient")o.block.setFloat(a,"fill/gradient/linear/startPointX",(n.start.x-e.x)/u),o.block.setFloat(a,"fill/gradient/linear/startPointY",(n.start.y-e.y)/f),o.block.setFloat(a,"fill/gradient/linear/endPointX",(n.end.x-e.x)/u),o.block.setFloat(a,"fill/gradient/linear/endPointY",(n.end.y-e.y)/f);else{let g=Math.max(.001,Math.min(u,f));o.block.setFloat(a,"fill/gradient/radial/centerPointX",(n.center.x-e.x)/u),o.block.setFloat(a,"fill/gradient/radial/centerPointY",(n.center.y-e.y)/f),o.block.setFloat(a,"fill/gradient/radial/radius",n.radius/g)}o.block.setFill(t,a)}function el(o,t,e,n){let r=gi(e,n);r!=null&&(typeof o.block.supportsBlendMode=="function"&&!o.block.supportsBlendMode(t)||o.block.setBlendMode(t,r))}function Ah(o,t,e,n){let r=o.block.create("graphic"),a=Ex(e,t),c=mi(o,a,t.width,t.height);return o.block.setShape(r,c),ss(o,r,t),vi(o,r,t),t.rotation&&Math.abs(t.rotation)>1e-6&&o.block.setRotation(r,t.rotation),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(r,t.opacity),el(o,r,t.blendMode,n?.logger),r}function bx(o,t,e,n,r){if(t.rotation&&Math.abs(t.rotation)>1e-6){let g=yx(o,t,e,n,r);if(g!==Th)return g}let c=Tx(o,t);o.block.appendChild(n,c);let u=[];for(let g of e){let m=Ch(o,g);o.block.appendChild(n,m),u.push(m)}let f=tl(o,[c,...u],{logger:r?.logger,label:`${Bn(r)}clipped image at ${Me(t)}`});return f===bi?(Ds(o,[c,...u]),Gn):f==null?(Ds(o,[c,...u]),null):(ss(o,f,t),wx(o,f,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(f,t.opacity),el(o,f,t.blendMode,r?.logger),f)}var Th=Symbol("UNHANDLED");function yx(o,t,e,n,r){let a=vx(e);if(a==null)return Th;if(a.points.length<3)return r?.logger?.emit?.("IMAGE_CLIP_EMPTY_INTERSECTION",{prefix:Bn(r),bbox:Me(t),clipCount:e.length,page:r?.pageIndex}),Gn;let c=Ax(a.points);return Ah(o,t,c,r)}function vx(o){if(o.length===0)return null;let t=mh(o[0]);if(t==null)return null;for(let e=1;e<o.length;e++){let n=mh(o[e]);if(n==null)return null;if(t=xx(t,n),t.length===0)return{points:[]}}return{points:t}}function mh(o){let t=o.d.split(/\s+/),e=[],n=0;for(;n<t.length;){let r=t[n++];if(!(r==="Z"||r==="z")){if(r==="M"||r==="L"){let a=parseFloat(t[n++]),c=parseFloat(t[n++]);if(Number.isNaN(a)||Number.isNaN(c))return null;let u=o.x+a,f=o.y+c,g=e[e.length-1];if(g&&Math.abs(g[0]-u)<1e-6&&Math.abs(g[1]-f)<1e-6)continue;e.push([u,f]);continue}return null}}return e}function xx(o,t){if(t.length<3)return[];let e=Math.sign(Sx(t))||1,n=o.slice();for(let r=0;r<t.length&&n.length!==0;r++){let a=t[r],c=t[(r+1)%t.length],u=n;n=[];let f=u[u.length-1];for(let g of u){let m=bh(g,a,c)*e>=-1e-9,b=bh(f,a,c)*e>=-1e-9;m?(b||n.push(yh(f,g,a,c)),n.push(g)):b&&n.push(yh(f,g,a,c)),f=g}}return n}function Sx(o){let t=0;for(let e=0;e<o.length;e++){let[n,r]=o[e],[a,c]=o[(e+1)%o.length];t+=n*c-a*r}return t*.5}function bh(o,t,e){return(e[0]-t[0])*(o[1]-t[1])-(e[1]-t[1])*(o[0]-t[0])}function yh(o,t,e,n){let r=n[0]-e[0],a=n[1]-e[1],c=t[0]-o[0],u=t[1]-o[1],f=r*u-c*a;if(Math.abs(f)<1e-12)return t.slice();let g=(r*(e[1]-o[1])-a*(e[0]-o[0]))/f;return[o[0]+g*c,o[1]+g*u]}function Ax(o){let t=1/0,e=1/0,n=-1/0,r=-1/0;for(let[u,f]of o)u<t&&(t=u),f<e&&(e=f),u>n&&(n=u),f>r&&(r=f);let a=u=>`${Math.round(u*100)/100}`,c=[];for(let u=0;u<o.length;u++){let[f,g]=o[u];c.push(`${u===0?"M":"L"} ${a(f-t)} ${a(g-e)}`)}return c.push("Z"),{d:c.join(" "),x:t,y:e,width:n-t,height:r-e,fillRule:"nonzero"}}function Tx(o,t){let e=o.block.create("graphic");return o.block.setShape(e,o.block.createShape("rect")),ss(o,e,t),vi(o,e,t),t.rotation&&Math.abs(t.rotation)>1e-6&&o.block.setRotation(e,t.rotation),e}function Ch(o,t){let e=o.block.create("graphic"),n=mi(o,t.d,t.width,t.height);return o.block.setShape(e,n),o.block.setFill(e,wh(o)),vi(o,e,t),e}function Cx(o,t,e,n,r){let a=o.block.create("graphic"),c=mi(o,t,e.width,e.height);o.block.setShape(a,c);let u=n?.kind;if(n&&!(u==="linearGradient"||u==="radialGradient")){let g=o.block.createFill("color");o.block.setColor(g,"fill/color/value",nl(n)),o.block.setFill(a,g)}else o.block.setFill(a,wh(o));return vi(o,a,e),r!=null&&r!==1&&o.block.setOpacity(a,r),a}function wh(o){let t=o.block.createFill("color");return o.block.setColor(t,"fill/color/value",{r:0,g:0,b:0,a:0}),t}function wx(o,t,e){let n={x:yi(o.block.getPositionX(t)),y:yi(o.block.getPositionY(t)),width:yi(o.block.getWidth(t)),height:yi(o.block.getHeight(t))},r={x:e.x,y:e.y,width:e.width,height:e.height},a=fh(r,n);if(!dh(a))try{o.block.setContentFillMode(t,"Crop"),o.block.setCropScaleRatio(t,a.scaleRatio),o.block.setCropTranslationX(t,a.translationX),o.block.setCropTranslationY(t,a.translationY),a.rotation!==0&&o.block.setCropRotation(t,a.rotation)}catch{}}function vi(o,t,e){o.block.setPositionX(t,zt(e.x)),o.block.setPositionY(t,zt(e.y)),o.block.setWidth(t,zt(e.width)),o.block.setHeight(t,zt(e.height))}function yi(o){return o*72}function Ex(o,t){let e=t.rotation??0;if(Math.abs(e)<1e-6)return Ix(o.d,o.x-t.x,o.y-t.y);let n=t.x+t.width*.5,r=t.y+t.height*.5,a=Math.cos(e),c=Math.sin(e),u=(f,g)=>{let m=f+o.x-n,b=g+o.y-r,v=a*m+c*b,S=-c*m+a*b;return[v+t.width*.5,S+t.height*.5]};return kx(o.d,u)}function kx(o,t){let e=c=>`${Math.round(c*100)/100}`,n=o.split(/\s+/),r=[],a=0;for(;a<n.length;){let c=n[a++];if(c==="Z"||c==="z"){r.push("Z");continue}if(c==="M"||c==="L"){let[u,f]=t(parseFloat(n[a++]),parseFloat(n[a++]));r.push(`${c} ${e(u)} ${e(f)}`);continue}if(c==="C"){let[u,f]=t(parseFloat(n[a++]),parseFloat(n[a++])),[g,m]=t(parseFloat(n[a++]),parseFloat(n[a++])),[b,v]=t(parseFloat(n[a++]),parseFloat(n[a++]));r.push(`C ${e(u)} ${e(f)} ${e(g)} ${e(m)} ${e(b)} ${e(v)}`);continue}r.push(c)}return r.join(" ")}function Ix(o,t,e){let n=u=>`${Math.round(u*100)/100}`,r=o.split(/\s+/),a=[],c=0;for(;c<r.length;){let u=r[c++];if(u==="Z"||u==="z"){a.push("Z");continue}if(u==="M"||u==="L"){let f=parseFloat(r[c++]),g=parseFloat(r[c++]);a.push(`${u} ${n(f+t)} ${n(g+e)}`);continue}if(u==="C"){let f=parseFloat(r[c++]),g=parseFloat(r[c++]),m=parseFloat(r[c++]),b=parseFloat(r[c++]),v=parseFloat(r[c++]),S=parseFloat(r[c++]);a.push(`C ${n(f+t)} ${n(g+e)} ${n(m+t)} ${n(b+e)} ${n(v+t)} ${n(S+e)}`);continue}a.push(u)}return a.join(" ")}function _s(o){return!(o.width>0&&o.height>0)}function vh(o,t){let e=ph({x:o.x,y:o.y,width:o.width,height:o.height},{x:t.x,y:t.y,width:t.width,height:t.height});return e.width>0&&e.height>0}function Bn(o){return o?.pageIndex!=null?`Page ${o.pageIndex}: `:""}function nl(o){if(!o)return{r:0,g:0,b:0,a:1};if(o.space==="rgb"){let[e,n,r]=o.values;return{r:e,g:n,b:r,a:1}}if(o.space==="gray"){let[e]=o.values;return{r:e,g:e,b:e,a:1}}if(o.space==="cmyk"){let[e,n,r,a]=o.values;return{c:e,m:n,y:r,k:a,tint:1}}let t=o;return t.space==="spot"?{name:t.name,tint:t.tint??1,externalReference:""}:{r:0,g:0,b:0,a:1}}async function xi(o,t,e,n){let r=`${t.family}|${t.style??"normal"}|${t.weight??"normal"}`,a=e.get(r);if(a!==void 0)return a;let c=null;try{c=await o(t,n)}catch{c=null}return e.set(r,c),c}function Eh(o,t){if(o.substitutedFrom!=null)return!1;let n=(o.typeface?.name??"").toLowerCase().trim(),r=t.toLowerCase().trim();if(n===r)return!0;let a=c=>c.replace(/\s+/g,"");return a(n)===a(r)}var Px={name:"perfect-match-resolver",async resolve(o,t){if(!t.resolver)return{kind:"pass",reason:"no-resolver-configured"};if(!o.family)return{kind:"pass",reason:"no-font-family"};let e=await xi(t.resolver,{family:o.family,style:o.style,weight:o.weight},t.resolverCache,t.engine);return e?Eh(e,o.family)?{kind:"typeface",typeface:e.typeface,font:e.font,provenance:"perfect-match",substitutedFrom:e.substitutedFrom}:{kind:"pass",reason:"not-perfect-match"}:{kind:"pass",reason:"resolver-miss"}}},Ns=Px;var Rx={name:"embedded-subset",async resolve(o){return o.embeddedFont?{kind:"subset",embeddedFont:o.embeddedFont,provenance:"embedded-subset"}:{kind:"pass",reason:"no-embedded-font"}}},Si=Rx;var Ox={name:"any-match-resolver",async resolve(o,t){if(!t.resolver)return{kind:"pass",reason:"no-resolver-configured"};if(!o.family)return{kind:"pass",reason:"no-font-family"};let e=await xi(t.resolver,{family:o.family,style:o.style,weight:o.weight},t.resolverCache,t.engine);return e?{kind:"typeface",typeface:e.typeface,font:e.font,provenance:"any-match",substitutedFrom:e.substitutedFrom}:{kind:"pass",reason:"resolver-miss"}}},Ai=Ox;var kh=new WeakMap;function Ih(o,t,e,n){let r=o.block;if(typeof r.setTypeface=="function"&&r.setTypeface(t,e),typeof r.setTextFontStyle=="function"&&n?.style)try{r.setTextFontStyle(t,n.style)}catch{}if(typeof r.setTextFontWeight=="function"&&n?.weight)try{r.setTextFontWeight(t,n.weight)}catch{}let a=n?.uri,c=o.editor;a&&typeof c?.getFontMetrics=="function"&&c.getFontMetrics(a).catch(()=>{})}function Mx(o,t){let e=kh.get(o);e||(e=new Map,kh.set(o,e));let n=e.get(t.postScriptName);if(n)return n;let r=o.editor.createBuffer(),a=t.data instanceof Uint8Array?t.data:new Uint8Array(t.data);o.editor.setBufferData(r,0,a);let c={name:t.postScriptName,fonts:[{uri:r,subFamily:t.family,weight:Xa(t.weight),style:t.style??"normal"}]},u={uri:r,typeface:c};return e.set(t.postScriptName,u),u}function Ph(o,t,e){let{uri:n,typeface:r}=Mx(o,e);typeof o.block.setFont=="function"&&o.block.setFont(t,n,r)}var Rh="ly.img.pdf-importer.text";function sl(o,t,e,n){if(typeof o.block?.setMetadata!="function")return;let r=(c,u)=>{if(!(u==null||u===""))try{o.block.setMetadata(t,`${Rh}.${c}`,String(u))}catch{}};r("content",e.text),r("fontFamily",e.family);let a=e.source;"fontSize"in a&&typeof a.fontSize=="number"&&Number.isFinite(a.fontSize)&&r("fontSize",a.fontSize),r("fontStyle",e.style),r("fontWeight",e.weight),r("fallbackReason",n)}function Oh(o,t){return t?o.family?"resolver-miss":"no-font-family":"resolver-disabled"}var Us={name:"default",async emit(o,t,e){if(t?.kind==="typeface"){let n=await e.helpers.resolveLayoutForSubstitution(o,t),r=e.helpers.createEditableText(o,n,(c,u)=>{Ih(c,u,t.typeface,t.font)}),a=t.substitutedFrom!=null;return{blocks:[r],substituted:a,resolvedFamily:t.typeface.name}}if(t?.kind==="subset")return{blocks:[e.helpers.createEditableText(o,o.source,(r,a)=>{Ph(r,a,t.embeddedFont)})],substituted:!1,resolvedFamily:o.family};if(o.glyphPaths!=null||o.buildGlyphOutline!=null){let n=e.helpers.emitGlyphsAsVectorPath(o);if(n!=null){let r=Oh(o,!0);return sl(e.engine,n,o,r),{blocks:[n],substituted:!1}}}return e.logger?.emit?.("TEXT_RUN_SKIPPED_NO_RESOLUTION",{fontFamily:o.family}),{blocks:[],substituted:!1}}};function rl(o,t){if(o.kind===se.TEXT_RUN){let e=t.fonts?.get?.(o.fontRef);return e?{family:e.family,style:e.style??"normal",weight:e.weight!=null?Lx(e.weight):"normal",text:o.text,embeddedFont:e,buildGlyphOutline:o._buildGlyphOutline,source:o}:null}return o.fontFamily?{family:o.fontFamily,style:o.fontStyle??"normal",weight:o.fontWeight??"normal",text:o.text,glyphPaths:o.d,source:o}:null}function Lx(o){let t=Number(o)||400;return t<=150?"thin":t<=250?"extraLight":t<=350?"light":t<=450?"normal":t<=550?"medium":t<=650?"semiBold":t<=750?"bold":t<=850?"extraBold":"heavy"}function Ti(o){return{stages:o,async resolve(t,e){for(let n of o){let r=await n.resolve(t,e);if(r.kind!=="pass")return r}return null}}}function Ci(o){return{cascade:o.cascade,emission:o.emission}}var Mh=Ci({cascade:Ti([Ns,Si,Ai]),emission:Us}),Fx=Ci({cascade:Ti([Ns,Si]),emission:Us}),Dx=Ci({cascade:Ti([Ns,Ai]),emission:Us}),Bs=Mh;async function Dh(o,t,e={}){let n=o.scene.create("VerticalStack");o.scene.setDesignUnit("Inch");let r=o.block.findByType("stack")[0];o.block.setFloat(r,"stack/spacing",e1),o.block.setBool(r,"stack/spacingInScreenspace",n1);let a=[],c={fontResolver:e.fontResolver??null,fontStrategy:e.fontStrategy??Bs,logger:e.logger??null,resolverCache:new Map,textRuns:a,substitutions:new Map,vectorPathFillRuleSupport:hh()},u=e.pageBounds??"trim";o1(o,t,c.logger);for(let f=0;f<t.pages.length;f++){let g=t.pages[f];c.pageIndex=f+1;let m=o.block.create("page");o.block.setWidth(m,zt(g.widthPt)),o.block.setHeight(m,zt(g.heightPt)),o.block.appendChild(r,m);for(let b of g.blocks){let v=await Bx(o,b,t,m,c);v!=null&&(o.block.appendChild(m,v),b.kind===se.IMAGE&&gh(o,v,b,{logger:c.logger??void 0}))}Ux(o,m,g,u)}return await _x(o,a.map(({id:f})=>f)),s1(o,a,c),Nx(c),n}async function _x(o,t,e=1e4){if(typeof o.block.getState!="function"||typeof o.block.onStateChanged!="function")return;let n=a=>{try{let c=o.block.getState(a);return c.type==="Ready"||c.type==="Error"}catch{return!0}},r=t.filter(a=>!n(a));r.length!==0&&await new Promise(a=>{let c=new Set(r),u=null,f=()=>{u?.(),clearTimeout(g),a()},g=setTimeout(f,e);u=o.block.onStateChanged(r,m=>{for(let b of m)n(b)&&c.delete(b);c.size===0&&f()});for(let m of r)n(m)&&c.delete(m);c.size===0&&f()})}function Nx(o){if(o.substitutions.size===0)return;let t=Array.from(o.substitutions.entries()).map(([n,r])=>`${n} \u2192 ${r}`).join(", "),e=o.substitutions.size;o.logger?.emit?.("FONT_SUBSTITUTIONS_SUMMARY",{count:e,plural:e===1?"y":"ies",pairs:t})}function Ux(o,t,e,n){if(n==="media"||!e.trimPt)return;let{xPt:r,yPt:a,widthPt:c,heightPt:u}=e.trimPt,f=zt(r),g=zt(a);if(f!==0||g!==0)for(let m of o.block.getChildren(t))o.block.setPositionX(m,o.block.getPositionX(m)-f),o.block.setPositionY(m,o.block.getPositionY(m)-g);o.block.setWidth(t,zt(c)),o.block.setHeight(t,zt(u)),e.hasBleed&&(o.block.setBool(t,"page/marginEnabled",!0),o.block.setFloat(t,"page/margin/top",zt(e.bleedPt.top)),o.block.setFloat(t,"page/margin/bottom",zt(e.bleedPt.bottom)),o.block.setFloat(t,"page/margin/left",zt(e.bleedPt.left)),o.block.setFloat(t,"page/margin/right",zt(e.bleedPt.right)))}async function Bx(o,t,e,n,r){switch(t.kind){case se.IMAGE:return Gx(o,t,n,r);case se.VECTOR_PATH:return _h(o,t,n,r);case se.TEXT_OUTLINE:case se.TEXT_RUN:return await jx(o,t,e,r);default:return r?.logger?.emit?.("BLOCK_KIND_UNKNOWN",{kind:t.kind}),null}}function Gx(o,t,e,n){if(t.clips?.length){let c=xh(o,t,t.clips,e,{logger:n?.logger??void 0,pageIndex:n?.pageIndex});return c===Gn?null:c??(n?.logger?.emit?.("IMAGE_CLIP_COMBINE_FAILED",{prefix:ol(n),bbox:Me(t),clipCount:t.clips.length,page:n?.pageIndex}),null)}let r=o.block.create("graphic"),a=o.block.createShape("rect");if(o.block.setShape(r,a),!ss(o,r,t,{logger:n?.logger??void 0})){try{o.block.destroy(r)}catch{}return null}return Bh(o,r,t),t.rotation&&Math.abs(t.rotation)>1e-6&&o.block.setRotation(r,t.rotation),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(r,t.opacity),Nh(o,r,t.blendMode,n),r}function _h(o,t,e,n){if(t.clips?.length){let c=Sh(o,t,t.clips,e,{logger:n?.logger??void 0,pageIndex:n?.pageIndex,vectorPathFillRuleSupport:n.vectorPathFillRuleSupport});if(c===Gn)return null;if(c!=null)return c;n?.logger?.emit?.("CLIP_COMBINE_FAILED",{prefix:ol(n),bbox:Me(t),clipCount:t.clips.length,page:n?.pageIndex})}let r=o.block.create("graphic"),a=o.block.createShape("vector_path");o.block.setString(a,"vector_path/path",t.d);try{o.block.setFloat(a,"vector_path/width",t.width),o.block.setFloat(a,"vector_path/height",t.height)}catch{}if(t.fillRule,n?.logger,n.vectorPathFillRuleSupport,o.block.setShape(r,a),t.fill){let c=t.fill.kind;if(c==="linearGradient"||c==="radialGradient")Hx(o,r,t,n);else{let u=o.block.createFill("color");o.block.setColor(u,"fill/color/value",Gs(t.fill,n,t,"vector path fill")),o.block.setFill(r,u)}}else o.block.setFillEnabled(r,!1);return t.stroke&&(o.block.setStrokeEnabled(r,!0),o.block.setStrokeColor(r,Gs(t.stroke,n,t,"vector path stroke")),t.strokeWidth!=null&&o.block.setStrokeWidth(r,zt(t.strokeWidth))),Bh(o,r,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(r,t.opacity),Nh(o,r,t.blendMode,n),r}function Nh(o,t,e,n){let r=gi(e,n?.logger??void 0);r!=null&&(typeof o.block.supportsBlendMode=="function"&&!o.block.supportsBlendMode(t)||o.block.setBlendMode(t,r))}function Hx(o,t,e,n){let r=e.fill,a=r.kind==="linearGradient"?"gradient/linear":"gradient/radial",c=o.block.createFill(a),u=(r.stops??[]).map(m=>({color:Gs(m.color,n,e,"vector path gradient stop"),stop:m.offset}));o.block.setGradientColorStops(c,"fill/gradient/colors",u);let f=e.width>0?e.width:1,g=e.height>0?e.height:1;if(r.kind==="linearGradient")o.block.setFloat(c,"fill/gradient/linear/startPointX",(r.start.x-e.x)/f),o.block.setFloat(c,"fill/gradient/linear/startPointY",(r.start.y-e.y)/g),o.block.setFloat(c,"fill/gradient/linear/endPointX",(r.end.x-e.x)/f),o.block.setFloat(c,"fill/gradient/linear/endPointY",(r.end.y-e.y)/g);else{let m=Math.max(.001,Math.min(f,g));o.block.setFloat(c,"fill/gradient/radial/centerPointX",(r.center.x-e.x)/f),o.block.setFloat(c,"fill/gradient/radial/centerPointY",(r.center.y-e.y)/g),o.block.setFloat(c,"fill/gradient/radial/radius",r.radius/m)}o.block.setFill(t,c)}async function jx(o,t,e,n){let r=rl(t,e);if(!r)return n.logger?.emit?.(t.kind===se.TEXT_RUN?"FONT_REF_NOT_EXTRACTED":"TEXT_OUTLINE_NO_FONT_FAMILY",{fontRef:t.kind===se.TEXT_RUN?t.fontRef:""}),null;let a=await n.fontStrategy.cascade.resolve(r,{engine:o,resolver:n.fontResolver,resolverCache:n.resolverCache,logger:n.logger}),c=Vx(o,n),u=await n.fontStrategy.emission.emit(r,a,{engine:o,logger:n.logger,pageIndex:n.pageIndex,helpers:c});if(u.substituted&&a?.kind==="typeface"){let g=a.typeface.name??"?";n.substitutions.has(r.family)||n.substitutions.set(r.family,g)}if(u.blocks.length===0)return null;let f=u.blocks[0];return n.textRuns&&(a?.kind==="typeface"||a?.kind==="subset")&&(t.kind===se.TEXT_RUN?n.textRuns.push({id:f,ir:t}):n.textRuns.push({id:f,ir:{kind:se.TEXT_RUN,x:t.x,y:t.y,width:t.width,height:t.height,text:t.text,fontRef:t.fontFamily,fontSize:t.fontSize,rotation:0,fill:t.fill}})),f}function Vx(o,t){return{createEditableText(e,n,r){return zx(o,e.source,r,n,t)},emitGlyphsAsVectorPath(e){let n=null;if(e.glyphPaths){let c=e.source;n={d:e.glyphPaths,x:c.x,y:c.y,width:c.width,height:c.height}}else e.buildGlyphOutline&&(n=e.buildGlyphOutline());if(!n)return null;let r=e.source,a="opacity"in r&&typeof r.opacity=="number"?r.opacity:1;return _h(o,{kind:se.VECTOR_PATH,x:n.x,y:n.y,width:n.width,height:n.height,d:n.d,fill:r.fill,stroke:null,strokeWidth:0,opacity:a},0,t)},async resolveLayoutForSubstitution(e,n){return e.source.kind!==se.TEXT_OUTLINE||n.kind!=="typeface"?e.source:Wx(o,e.source,{typeface:n.typeface,font:n.font},t)}}}async function $x(o,t,e,n){let r=t?.font?.uri,a=o.editor;if(!r||typeof a?.getFontMetrics!="function"||!n)return null;n.fontMetricsCache||(n.fontMetricsCache=new Map);let c=n.fontMetricsCache.get(r);if(c===void 0){try{c=await a.getFontMetrics(r)}catch{c=null}n.fontMetricsCache.set(r,c)}return!c||!c.unitsPerEm||c.ascender==null?null:c.ascender/c.unitsPerEm*e}function zx(o,t,e,n,r){let a=o.block.create("text");return Xx(o,a,n),e(o,a),Yx(o,a,t,r),t.rotation&&o.block.setRotation(a,t.rotation),a}async function Wx(o,t,e,n){if(!(Math.abs(t.rotation??0)>1e-6)){if(!Number.isFinite(t.textOriginX)&&!Number.isFinite(t.textOriginY))return t;let T={};if(Number.isFinite(t.textOriginX)&&(T.x=t.textOriginX),Number.isFinite(t.textOriginY)){let w=await $x(o,e,t.fontSize,n);w!=null&&(T.y=(t.textOriginY??0)-w)}return{...t,...T}}let a=t.unrotWidth!=null&&Number.isFinite(t.unrotWidth)&&t.unrotWidth>0?t.unrotWidth:t.width,c=t.unrotHeight!=null&&Number.isFinite(t.unrotHeight)&&t.unrotHeight>0?t.unrotHeight:t.height,u=t.rotation??0,f=Math.sin(u),g=Math.cos(u),m=t.x+t.width/2,b=t.y+t.height/2,v=m-a/2+c/2*f,S=b-c/2*g;return{...t,x:v,y:S,width:a,height:c}}function Xx(o,t,e){o.block.setPositionX(t,zt(e.x)),o.block.setPositionY(t,zt(e.y)),o.block.setWidth(t,zt(e.width)),typeof o.block.setWidthMode=="function"&&o.block.setWidthMode(t,"Absolute"),typeof o.block.setHeightMode=="function"&&o.block.setHeightMode(t,"Auto")}function Yx(o,t,e,n){typeof o.block.setTextFontSize=="function"?o.block.setTextFontSize(t,e.fontSize):o.block.setFloat(t,"text/fontSize",e.fontSize),typeof o.block.replaceText=="function"?o.block.replaceText(t,e.text):o.block.setString(t,"text/text",e.text),Uh(o,t,e,n);let r=e.opacity;r!=null&&r!==1&&o.block.setOpacity(t,r)}function Uh(o,t,e,n){let r=e.colorSpans;if(Array.isArray(r)&&r.length>0){if(typeof o.block.setTextColor=="function")for(let a of r){if(!a.fill)continue;let c=Gs(a.fill,n,e,"text");o.block.setTextColor(t,c,a.from,a.to)}}else if(e.fill){let a=Gs(e.fill,n,e,"text");if(typeof o.block.setTextColor=="function")o.block.setTextColor(t,a);else try{o.block.setColor(t,"fill/color/value",a)}catch{}}}var Kx=!0,Zx=-.01,Lh=-.15,Qx=15,Jx=1.05,Fh=1.5,qx=9,t1=.7,e1=32,n1=!0;function s1(o,t,e){if(Kx&&typeof o.block.getTextVisibleLineCount=="function")for(let{id:n,ir:r}of t)r1(o,n,r,e)}function r1(o,t,e,n){let r=e.width;if(r<e.fontSize){let g=Math.max(1,e.text.length)*e.fontSize*t1;g>r&&(r=g,o.block.setWidth(t,zt(r)))}let a=il(o,t,e,n);if(a<=1)return;let c=0;for(let g=0;g<Qx&&(c=Math.max(Lh,c+Zx),o.block.setFloat(t,"text/letterSpacing",c),a=il(o,t,e,n),!(a<=1||c<=Lh));g++);if(a<=1)return;let u=zt(r),f=1;for(let g=0;g<qx&&(f=Math.min(Fh,f*Jx),o.block.setWidth(t,u*f),a=il(o,t,e,n),!(a<=1||f>=Fh));g++);a>1&&n?.logger?.emit?.("TEXT_OVERFLOW_AFTER_AUTOSIZE",{text:i1(e.text,30),overflowLines:a-1})}function il(o,t,e,n){typeof o.block.replaceText=="function"?o.block.replaceText(t,e.text):o.block.setString(t,"text/text",e.text),Uh(o,t,e,n);try{return o.block.getTextVisibleLineCount(t)}catch{return 1}}function i1(o,t){return o.length>t?o.slice(0,t-1)+"\u2026":o}function Bh(o,t,e){o.block.setPositionX(t,zt(e.x)),o.block.setPositionY(t,zt(e.y)),o.block.setWidth(t,zt(e.width)),o.block.setHeight(t,zt(e.height))}function o1(o,t,e){if(!o?.editor?.setSpotColorCMYK)return;let n=new Map,r=a=>{let c=a;!c||c.space!=="spot"||!c.name||n.has(c.name)||n.set(c.name,{alt:c.alternateSpace??"DeviceCMYK",solid:Array.isArray(c.solid)?c.solid:[]})};for(let a of t.pages??[])for(let c of a.blocks??[])r(c.fill),r(c.stroke);for(let[a,c]of n)try{if(c.alt==="DeviceCMYK"&&c.solid.length>=4){let[u,f,g,m]=c.solid;o.editor.setSpotColorCMYK(a,u,f,g,m)}else if(c.alt==="DeviceGray"&&c.solid.length>=1){let u=c.solid[0];o.editor.setSpotColorRGB(a,u,u,u)}else if(c.alt==="DeviceRGB"&&c.solid.length>=3){let[u,f,g]=c.solid;o.editor.setSpotColorRGB(a,u,f,g)}else e?.emit?.("SPOT_COLOR_NO_ALTERNATE",{name:a})}catch(u){let f=u&&typeof u=="object"&&"message"in u?String(u.message):String(u);e?.emit?.("SPOT_COLOR_REGISTER_FAILED",{name:a,error:f})}}function Gs(o,t,e,n){if(!o)return{r:0,g:0,b:0,a:1};if(o.space==="rgb"){let[a,c,u]=o.values;return{r:a,g:c,b:u,a:1}}if(o.space==="gray"){let[a]=o.values;return{r:a,g:a,b:a,a:1}}if(o.space==="cmyk"){let[a,c,u,f]=o.values;return{c:a,m:c,y:u,k:f,tint:1}}let r=o;return r.space==="spot"?{name:r.name,tint:r.tint??1,externalReference:""}:(t?.logger?.emit?.("COLOR_SPACE_UNSUPPORTED",{prefix:ol(t),elementLabel:a1(n),space:r.space,color:$u(o),bbox:Me(e),page:t?.pageIndex,element:n??null}),{r:0,g:0,b:0,a:1})}function ol(o){return o?.pageIndex!=null?`Page ${o.pageIndex}: `:""}function a1(o){return o?`${o} `:""}function jh(o){let t=[],e=null,n=()=>{e&&(e.runs.length===1?t.push(e.runs[0]):t.push(p1(e.runs)),e=null)};for(let r of o){if(r.kind!==se.TEXT_RUN){n(),t.push(r);continue}let a=r;if(!e){e={runs:[a]};continue}let c=e.runs[e.runs.length-1];h1(c,a)?e.runs.push(a):(n(),e={runs:[a]})}return n(),t}var l1=.15,c1=.5,u1=.5;function h1(o,t){return o.fontRef!==t.fontRef||Math.abs(o.fontSize-t.fontSize)>.5||Math.abs((o.rotation??0)-(t.rotation??0))>.001?!1:o.baselineXPt!=null&&o.baselineYPt!=null&&o.advanceWidthPt!=null&&t.baselineXPt!=null&&t.baselineYPt!=null?d1(o,t):f1(o,t)}function d1(o,t){let e=o.fontSize||10,n=o.rotation??0,r=Math.cos(n),a=Math.sin(n),c=o.baselineXPt,u=o.baselineYPt,f=o.advanceWidthPt,g=t.baselineXPt,m=t.baselineYPt,b=c+f*r,v=u+f*a,S=g-b,T=m-v,w=S*r+T*a,I=-S*a+T*r;return!(Math.abs(I)>c1*e||w<-u1*e||w>l1*e)}function f1(o,t){let e=o.fontSize||10,n=o.rotation??0,r=Math.cos(n),a=Math.sin(n),c=t.x+t.width/2-(o.x+o.width/2),u=t.y+t.height/2-(o.y+o.height/2);if(Math.abs(c*-a+u*r)>.5*e)return!1;let g=Math.abs(c*r+u*a),m=(o.width+t.width)/2;return!(g>m)}function p1(o){let t=o[0],e=Math.min(...o.map(b=>b.x)),n=Math.min(...o.map(b=>b.y)),r=Math.max(...o.map(b=>b.x+b.width)),a=Math.max(...o.map(b=>b.y+b.height)),c="",u=[];for(let b of o){let v=c.length;if(Array.isArray(b.colorSpans)&&b.colorSpans.length>0)for(let S of b.colorSpans)u.push({from:v+S.from,to:v+S.to,fill:S.fill??null});else u.push({from:v,to:v+b.text.length,fill:b.fill??null});c+=b.text}let f=[];for(let b of u){let v=f[f.length-1];v&&al(v.fill,b.fill)&&v.to===b.from?v.to=b.to:f.push({...b})}let g=f.every(b=>al(b.fill,f[0].fill)),m=g1(o);return{...t,x:e,y:n,width:r-e,height:a-n,text:c,...g?{}:{colorSpans:f},...m?{_buildGlyphOutline:m}:{}}}function g1(o){let t=o.map(e=>e._buildGlyphOutline).filter(e=>e!=null);if(t.length!==0)return()=>{let e=t.map(f=>f()).filter(f=>f!=null);if(e.length===0)return null;let n=1/0,r=1/0,a=-1/0,c=-1/0;for(let f of e)f.x<n&&(n=f.x),f.y<r&&(r=f.y),f.x+f.width>a&&(a=f.x+f.width),f.y+f.height>c&&(c=f.y+f.height);return{d:e.map(f=>$h(f.d,f.x-n,f.y-r)).filter(f=>f.length>0).join(" "),x:n,y:r,width:a-n,height:c-r}}}var m1=.5,Gh=.3;function Vh(o){let t=[],e=null,n=()=>{e&&(e.length===1?t.push(e[0]):t.push(y1(e)),e=null)};for(let r of o){if(r.kind!==se.TEXT_OUTLINE){n(),t.push(r);continue}let a=r;if(!e){e=[a];continue}let c=e[e.length-1];b1(c,a)?e.push(a):(n(),e=[a])}return n(),t}function b1(o,t){if(!o.fontFamily||!t.fontFamily||o.fontFamily!==t.fontFamily||Math.abs((o.fontSize??0)-(t.fontSize??0))>.5||(o.fontStyle??"normal")!==(t.fontStyle??"normal")||(o.fontWeight??"normal")!==(t.fontWeight??"normal")||!al(o.fill,t.fill))return!1;let e=o.fontSize||10;if(Math.abs(o.y-t.y)>e*Gh||Math.abs(o.y+o.height-(t.y+t.height))>e*Gh)return!1;let n=o.x+o.width,r=t.x-n,a=e*m1;return!(r>a||r<-a)}function al(o,t){if(o==null&&t==null)return!0;if(o==null||t==null||o.space!==t.space||(o.alpha??1)!==(t.alpha??1)||!o.values||!t.values||o.values.length!==t.values.length)return!1;for(let e=0;e<o.values.length;e++)if(Math.abs(o.values[e]-t.values[e])>1e-6)return!1;return!0}function y1(o){let t=o[0],e=Math.min(...o.map(m=>m.x)),n=Math.min(...o.map(m=>m.y)),r=Math.max(...o.map(m=>m.x+m.width)),a=Math.max(...o.map(m=>m.y+m.height)),c=o.map(m=>m.text??"").join(""),u=o.map(m=>$h(m.d??"",m.x-e,m.y-n)).filter(m=>m.length>0).join(" "),f=o.map(m=>m.textOriginX).filter(m=>Number.isFinite(m)),g=f.length>0?Math.min(...f):void 0;return{...t,x:e,y:n,width:r-e,height:a-n,text:c,d:u,textOriginX:g}}function $h(o,t,e){if(!o)return"";if(Math.abs(t)<1e-9&&Math.abs(e)<1e-9)return o;let n=o.trim().split(/\s+/),r=[],a=0;for(;a<n.length;){let c=n[a];if(c==="Z"||c==="z"){r.push(c),a++;continue}if(/^[A-Za-z]$/.test(c)){let u=c,f=v1(u);r.push(u);for(let g=0;g<f;g++){let m=Number(n[a+1+g*2]),b=Number(n[a+2+g*2]);if(!Number.isFinite(m)||!Number.isFinite(b)){r.push(n[a+1+g*2],n[a+2+g*2]);continue}r.push(Hh(m+t),Hh(b+e))}a+=1+f*2;continue}r.push(c),a++}return r.join(" ")}function v1(o){switch(o){case"M":case"m":case"L":case"l":case"T":case"t":return 1;case"Q":case"q":case"S":case"s":return 2;case"C":case"c":return 3;default:return 0}}function Hh(o){return`${Math.round(o*100)/100}`}var ll=class o{engine;pdfBytes;fontResolver;fontStrategy;pageBounds;logger=new ro(qc);constructor(t,e,n,r="trim",a=Bs){this.engine=t,this.pdfBytes=e,this.fontResolver=n??io,this.fontStrategy=a,this.pageBounds=r}static async fromFile(t,e,n){let r;e instanceof ArrayBuffer?r=e:r=await e.arrayBuffer();let a=new Uint8Array(r);return typeof n=="function"?new o(t,a,n):new o(t,a,n?.fontResolver,n?.pageBounds,n?.fontStrategy)}async parse(){let t=this.engine,e=await ch(this.pdfBytes,{textMode:"auto",logger:this.logger});this.logger.emit("DOC_PAGE_COUNT",{count:e.pages.length});for(let r=0;r<e.pages.length;r++){let a=x1(e.pages[r].blocks);this.logger.emit("DOC_PAGE_BLOCK_COUNT",{page:r,imageCount:a.image,vectorCount:a.vector,textCount:a.text,outlineCount:a.outline})}for(let r of e.pages)r.blocks=Vh(r.blocks),r.blocks=jh(r.blocks);return{scene:await Dh(t,e,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:this.pageBounds}),logger:this.logger}}getLogger(){return this.logger}};function x1(o){let t={image:0,vector:0,text:0,outline:0};for(let e of o)e.kind==="image"?t.image++:e.kind==="vector-path"?t.vector++:e.kind==="text-run"?t.text++:e.kind==="text-outline"&&t.outline++;return t}export{ro as Logger,ll as PDFParser,Jc as addGfontsAssetLibrary,Ai as anyMatchResolverStage,Dx as assetLibraryStrategy,Ti as createFontCascade,Ci as createFontStrategy,Us as defaultEmission,Bs as defaultStrategy,Mh as editableFirstStrategy,Si as embeddedSubsetStage,Fx as exactFidelityStrategy,Ns as perfectMatchResolverStage};
|