@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/dist/node.cjs ADDED
@@ -0,0 +1,15 @@
1
+ var __import_meta_url__ = require('url').pathToFileURL(__filename).href;
2
+ "use strict";var Gy=Object.create;var yr=Object.defineProperty;var Hy=Object.getOwnPropertyDescriptor;var jy=Object.getOwnPropertyNames;var Vy=Object.getPrototypeOf,$y=Object.prototype.hasOwnProperty;var zy=(o,t)=>()=>(o&&(t=o(o=0)),t);var Wy=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),eu=(o,t)=>{for(var e in t)yr(o,e,{get:t[e],enumerable:!0})},nu=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of jy(t))!$y.call(o,r)&&r!==e&&yr(o,r,{get:()=>t[r],enumerable:!(n=Hy(t,r))||n.enumerable});return o};var su=(o,t,e)=>(e=o!=null?Gy(Vy(o)):{},nu(t||!o||!o.__esModule?yr(e,"default",{value:o,enumerable:!0}):e,o)),Xy=o=>nu(yr({},"__esModule",{value:!0}),o);var Ou={};eu(Ou,{AbortException:()=>Qb,AnnotationEditorLayer:()=>Jb,AnnotationEditorParamsType:()=>qb,AnnotationEditorType:()=>t0,AnnotationEditorUIManager:()=>e0,AnnotationLayer:()=>n0,AnnotationMode:()=>ja,ColorPicker:()=>s0,DOMSVGFactory:()=>r0,DrawLayer:()=>i0,FeatureTest:()=>o0,GlobalWorkerOptions:()=>a0,ImageKind:()=>l0,InvalidPDFException:()=>c0,MissingPDFException:()=>u0,OPS:()=>h0,OutputScale:()=>d0,PDFDataRangeTransport:()=>f0,PDFDateString:()=>p0,PDFWorker:()=>g0,PasswordResponses:()=>m0,PermissionFlag:()=>y0,PixelsPerInch:()=>b0,RenderingCancelledException:()=>v0,TextLayer:()=>x0,TouchManager:()=>S0,UnexpectedResponseException:()=>A0,Util:()=>T0,VerbosityLevel:()=>C0,XfaLayer:()=>w0,build:()=>E0,createValidAbsoluteUrl:()=>k0,fetchData:()=>I0,getDocument:()=>P0,getFilenameFromUrl:()=>R0,getPdfFilenameFromUrl:()=>O0,getXfaPageViewport:()=>M0,isDataScheme:()=>L0,isPdfFile:()=>F0,noContextMenu:()=>D0,normalizeUnicode:()=>_0,setLayerDimensions:()=>N0,shadow:()=>U0,stopEvent:()=>B0,version:()=>G0});function Lt(o){var t=au[o];if(t!==void 0)return t.exports;var e=au[o]={exports:{}};return nb[o].call(e.exports,e,e.exports,Lt),e.exports}function lb(o){Number.isInteger(o)&&(si=o)}function cb(){return si}function ri(o){si>=ni.INFOS&&console.log(`Info: ${o}`)}function Et(o){si>=ni.WARNINGS&&console.log(`Warning: ${o}`)}function $t(o){throw new Error(o)}function te(o,t){o||$t(t)}function ub(o){switch(o?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function hb(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=gb(o)}catch{}let n=t?new URL(o,t):new URL(o);if(ub(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 Tu(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 ii(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 db(o){return String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255)}function Ua(o){let t=Object.create(null);for(let[e,n]of o)t[e]=n;return t}function fb(){let o=new Uint8Array(4);return o[0]=1,new Uint32Array(o.buffer,0,1)[0]===1}function pb(){try{return new Function(""),!0}catch{return!1}}function gb(o){return decodeURIComponent(escape(o))}function mb(o){return ho||(ho=/([\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,lu=new Map([["\uFB05","\u017Ft"]])),o.replaceAll(ho,(t,e,n)=>e?e.normalize("NFKC"):lu.get(n))}function yb(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let o=new Uint8Array(32);return crypto.getRandomValues(o),Tu(o)}function bb(o){return Uint8Array.prototype.toBase64?o.toBase64():btoa(Tu(o))}async function oi(o,t="text"){if(Ss(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 ai(o){let t=o.length,e=0;for(;e<t&&o[e].trim()==="";)e++;return o.substring(e,e+5).toLowerCase()==="data:"}function Ga(o){return typeof o=="string"&&/\.pdf$/i.test(o)}function vb(o){return[o]=o.split(/[#?]/,1),o.substring(o.lastIndexOf("/")+1)}function xb(o,t="document.pdf"){if(typeof o!="string")return t;if(ai(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 Ss(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 Sb(o,{scale:t=1,rotation:e=0}){let{width:n,height:r}=o.attributes.style,a=[0,0,parseInt(n),parseInt(r)];return new Cs({viewBox:a,userUnit:1,scale:t,rotation:e})}function Ha(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 Ab(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,Ha(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 Cs){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)}n&&o.setAttribute("data-main-rotation",t.rotation)}function Ir(o,t,e){for(let n of e)t.addEventListener(n,o[n].bind(o))}function uu(){}function ve(o){if(o instanceof Ze||o instanceof Ts||o instanceof On||o instanceof wr||o instanceof qn||o instanceof As)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 Ts(o.message);case"MissingPDFException":return new On(o.message);case"PasswordException":return new wr(o.message,o.code);case"UnexpectedResponseException":return new qn(o.message,o.status);case"UnknownErrorException":return new As(o.message,o.details)}return new As(o.message,o.toString())}async function Cu(o){let e=await process.getBuiltinModule("fs").promises.readFile(o);return new Uint8Array(e)}function Fo(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 fo(o,t,e,n,r,a,c,u){let f=t.coords,g=t.colors,m=o.data,y=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],bt=Math.round(T),et=Math.round(O),Tt,dt,Y,K,yt,lt,kt,X;for(let ot=bt;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),yt=S-(S-k)*Q,lt=F-(F-$)*Q,kt=_-(_-Z)*Q,X=D-(D-q)*Q;let nt=Math.round(Math.min(Tt,yt)),it=Math.round(Math.max(Tt,yt)),V=y*ot+nt*4;for(let H=nt;H<=it;H++)Q=(Tt-H)/(Tt-yt),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 Tb(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 y=0;y<g;y++,m++)fo(o,e,n[m],n[m+1],n[m+u],r[m],r[m+1],r[m+u]),fo(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)fo(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 Cb(o){switch(o[0]){case"RadialAxial":return new Do(o);case"Mesh":return new _o(o);case"Dummy":return new No}throw new Error(`Unknown IR type: ${o[0]}`)}function wb({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,y=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(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 kb(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 xr(o,t,e,n,r,a,c,u,f,g){let[m,y,v,S,T,w]=Wt(o);if(y===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,y,v,S,T,w),[j,$]}if(m===0&&S===0){let O=u*v+T,F=Math.round(O),_=c*y+w,D=Math.round(_),G=(u+g)*v+T,j=Math.abs(Math.round(G)-F)||1,W=(c+f)*y+w,$=Math.abs(Math.round(W)-D)||1;return o.setTransform(0,Math.sign(y),Math.sign(v),0,F,D),o.drawImage(t,e,n,r,a,0,0,$,j),o.setTransform(m,y,v,S,T,w),[$,j]}o.drawImage(t,e,n,r,a,c,u,f,g);let I=Math.hypot(m,y),k=Math.hypot(v,S);return[I*f,k*g]}function Ib(o){let{width:t,height:e}=o;if(t>gu||e>gu)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,y=new Uint8Array(m*e),v=0;for(let k of o.data){let O=128;for(;O>0;)y[v++]=k&O?0:255,O>>=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>n)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>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 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 mu(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,y=u.data,v,S,T,w;if(t.kind===Cr.GRAYSCALE_1BPP){let I=m.byteLength,k=new Uint32Array(y.buffer,0,y.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===Cr.RGBA_32BPP){for(S=0,w=n*xe*4,v=0;v<a;v++)y.set(m.subarray(f,f+w)),f+=w,o.putImageData(u,0,S),S+=xe;v<c&&(w=n*r*4,y.set(m.subarray(f,f+w)),o.putImageData(u,0,S))}else if(t.kind===Cr.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--;)y[g++]=m[f++],y[g++]=m[f++],y[g++]=m[f++],y[g++]=255;o.putImageData(u,0,v*xe)}else throw new Error(`bad image kind: ${t.kind}`)}function yu(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 y=0;y<c;y++){let v=y<a?xe:r;({srcPos:f}=wb({src:g,srcPos:f,dest:m,width:n,height:v,nonBlackColor:0})),o.putImageData(u,0,y*xe)}}function bs(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 Sr(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 bu(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)*yn.PDF_TO_CSS_UNITS);return e[0]<=n&&e[1]<=n}function Mb(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,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=ii(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=n("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 wu(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 li(o){try{return new URL(o).origin}catch{}return null}function Eu({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 ku(o){let t=o.get("Content-Disposition");if(t){let e=Mb(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ga(e))return e}return null}function ci(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 Iu(o){return o===200||o===206}function Pu(o,t,e){return{method:"GET",headers:o,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Ru(o){return o instanceof Uint8Array?o.buffer:o instanceof ArrayBuffer?o:(Et(`getArrayBuffer - unexpected data format: ${o}`),new Uint8Array(o).buffer)}function Lb(o){let t=o.response;return typeof t!="string"?t:ii(t).buffer}function Db(o){if(Fb.test(o))return new URL(o);let t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(o))}function zb(o={}){typeof o=="string"||o instanceof URL?o={url:o}:(o instanceof ArrayBuffer||ArrayBuffer.isView(o))&&(o={data:o});let t=new ea,{docId:e}=t,n=o.url?Wb(o.url):null,r=o.data?Xb(o.data):null,a=o.httpHeaders||null,c=o.withCredentials===!0,u=o.password??null,f=o.range instanceof Hr?o.range:null,g=Number.isInteger(o.rangeChunkSize)&&o.rangeChunkSize>0?o.rangeChunkSize:Ub,m=o.worker instanceof Jn?o.worker:null,y=o.verbosity,v=typeof o.docBaseUrl=="string"&&!ai(o.docBaseUrl)?o.docBaseUrl:null,S=typeof o.cMapUrl=="string"?o.cMapUrl:null,T=o.cMapPacked!==!1,w=o.CMapReaderFactory||jb,I=typeof o.standardFontDataUrl=="string"?o.standardFontDataUrl:null,k=o.StandardFontDataFactory||$b,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,bt=o.disableRange===!0,et=o.disableStream===!0,Tt=o.disableAutoFetch===!0,dt=o.pdfBug===!0,Y=o.CanvasFactory||Hb,K=o.FilterFactory||Vb,yt=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===Dr&&k===Ur&&S&&I&&Ss(S,document.baseURI)&&Ss(I,document.baseURI),ot=null;lb(y);let Q={canvasFactory:new Y({ownerDocument:q,enableHWA:yt}),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:y,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 Vo(f,{disableRange:bt,disableStream:et});else if(!r){if(!n)throw new Error("getDocument - no `url` parameter provided.");let U;if(ue)if(Ss(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=Gr}else U=Jo;else U=Ss(n)?Gr:Ko;H=new U({url:n,length:lt,httpHeaders:a,withCredentials:c,rangeChunkSize:g,disableRange:bt,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 ia(at,t,H,it,Q);t._transport=Ct,at.send("Ready",null)})}).catch(t._capability.reject),t}function Wb(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 Xb(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 ii(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 xu(o){return typeof o=="object"&&Number.isInteger(o?.num)&&o.num>=0&&Number.isInteger(o?.gen)&&o.gen>=0}function Su(o){return Math.floor(Math.max(0,Math.min(1,o))*255).toString(16).padStart(2,"0")}function xs(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 nb,au,wt,L1,F1,D1,_1,N1,U1,B1,G1,H1,j1,V1,$1,ue,Au,mo,sb,Tr,rb,z1,we,gn,ib,Rt,Mt,ob,le,Cr,ee,ys,ni,Ge,ab,si,bn,wr,As,Ts,On,qn,yo,Ze,ne,uo,St,ho,lu,Ba,W1,X1,Y1,K1,Z1,Q1,J1,q1,tS,eS,nS,sS,rS,iS,nn,yn,Cs,ws,Er,kr,Es,bo,vo,xo,So,Ao,Ln,To,Fn,Pr,Rr,Xt,Co,cu,Oe,Ke,Or,wo,ks,Mr,Eo,ko,vr,qt,Pn,Lr,Io,Fr,Dr,oS,_r,Po,Nr,Ur,Ro,Oo,Mo,Lo,ce,Is,Do,_o,No,hu,Uo,du,fu,Eb,pu,gu,xe,Bo,Br,Pb,Rb,Ob,vu,Qn,Rn,Go,Zn,Ho,jo,Vo,$o,zo,Gr,Wo,Xo,po,go,Yo,Ko,Zo,Qo,Fb,Jo,qo,ta,_b,be,Nb,Ps,Rs,Ub,Bb,Gb,Hb,jb,Vb,$b,ea,Hr,na,sa,ra,Jn,ia,vs,jr,oa,aa,Yb,Kb,aS,Vr,la,Os,$r,_s,Zb,Dn,ca,Qt,zr,ua,sn,ha,da,fa,Wr,pa,ga,Ms,ma,Xr,ya,ba,va,Yr,xa,Sa,Ls,Kr,Aa,Ta,Ca,Zr,wa,Ea,Ar,ka,ht,Qr,Jr,Fs,Ia,Ds,Pa,qr,ti,Ra,Oa,Ma,ei,La,Fa,Da,_a,Na,Qb,Jb,qb,t0,e0,n0,ja,s0,r0,i0,o0,a0,l0,c0,u0,h0,d0,f0,p0,g0,m0,y0,b0,v0,x0,S0,A0,T0,C0,w0,E0,k0,I0,P0,R0,O0,M0,L0,F0,D0,_0,N0,U0,B0,G0,Va=zy(()=>{nb={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),y=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),bt;if(u(G),m&&(G=y(G,{transfer:[G]}),$===Z&&(W||q)))return G;if($>=Z&&(!W||q))bt=k(G,0,Z);else{var et=W&&!q&&F?{maxByteLength:F(G)}:void 0;bt=new v(Z,et);for(var Tt=new S(G),dt=new S(bt),Y=T(Z,$),K=0;K<Y;K++)D(dt,K,_(Tt,K))}return m||g(G),bt}}),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),y=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),bt=Object.prototype,et=a.TypeError,Tt=k("toStringTag"),dt=O("TYPED_ARRAY_TAG"),Y="TypedArrayConstructor",K=n&&!!I&&g(a.opera)!=="Opera",yt=!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===bt)&&(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)){yt=!0,S(q,Tt,{configurable:!0,get:function(){return u(this)?this[dt]:void 0}});for(lt in ot)a[lt]&&y(a[lt],dt,lt)}o.exports={NATIVE_ARRAY_BUFFER_VIEWS:K,TYPED_ARRAY_TAG:yt&&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 y=n(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 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),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 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(y,v){try{return y[v]}catch{}};o.exports=n?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 n=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];!n(u,T)&&!(g&&n(g,T))&&y(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 y=m.enumerable,v=m.name!==void 0?m.name:f;if(n(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 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,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 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,y){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 y){if(F=y[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 y=arguments.length<2?u(g):m;if(r(y))return a(n(y,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,y=Math.max,v=function(S,T){this.set=S,this.size=y(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),y="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(y);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(y);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(y,v){var S=f[u(y)];return S===m?!0:S===g?!1:r(v)?n(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 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),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,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,bt,et,Tt,dt,Y=function(yt){return $&&v($,"normal",yt),new T(!0,yt)},K=function(yt){return _?(a(yt),j?W(yt[0],yt[1],Y):W(yt[0],yt[1])):j?W(yt,Y):W(yt)};if(D)$=I.iterator;else if(G)$=I;else{if(Z=y(I),!Z)throw new S(c(I)+" is not iterable");if(u(Z)){for(q=0,bt=f(I);bt>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(yt){v($,"throw",yt)}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(y){m=!0,g=y}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,y=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 y(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):y(void 0,!0)}if(G.inner)try{v(G.inner.iterator,"normal")}catch($){return v(j,"throw",$)}return j&&v(j,"normal"),y(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,y=a(n(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 n=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)||n(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 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),y=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=y(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=">",y="<",v="prototype",S="script",T=g("IE_PROTO"),w=function(){},I=function(D){return y+S+m+D+y+"/"+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,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 n=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=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:y in k?k[y]:O[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 n=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=n?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 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(y){var v=a(y);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 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 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(y,v){return a(y),c(v),r(y)&&(u?g(y,v):y.__proto__=v),y}})():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 y=a.f(u(m)),v=c.f;return v?f(y,v(m)):y}}),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),y={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
3
+ `,"\\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(y,F))k+=y[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,y=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)&&y(I,k)}):g(w.getIterator(),function(k){m(T,k)&&y(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,y=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){y(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(y){var v=n(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 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(y){if(!m.includes(y))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 y=n(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 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(y,v,S){return S?r({iterator:g(y),next:m},v):f(y,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),y=c(g).getIterator(),v=a(m);return u(y,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(y,v){if(!r(y)||a(y))return y;var S=c(y,m),T;if(S){if(v===void 0&&(v="default"),T=n(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 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"),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 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}},y=g||!m();n({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 n=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",O="Iterator",F=S("toStringTag"),_=TypeError,D=r[O],G=I||!u(D)||D.prototype!==T||!y(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),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});n({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 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),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 n=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}});n({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 n=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)}}});n({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 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),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 n=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;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,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 n(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 n=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),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),bt=u([].push),et=/^\d$/,Tt=/^[1-9]$/,dt=/^[\d-]$/,Y=/^[\t\n\r ]$/,K=0,yt=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=y(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(yt,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(bt(Ct,gt),bt(at,gt.value),H=this.until([",","]"],gt.end),$(V,H)===",")U=!0,H++;else if($(V,H)==="]"){H++;break}}return this.node(yt,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),y=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=y(Y<1?void 0:arguments[0]),yt=y(Y<2?void 0:arguments[1],"Error"),lt=new O(K,yt),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 bt in v)if(f(v,bt)){var et=v[bt],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),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"&&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=[];y(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),y=new u("a=1");(y.has("a",2)||!y.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})})},au={};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:()=>_a,AnnotationEditorParamsType:()=>Mt,AnnotationEditorType:()=>Rt,AnnotationEditorUIManager:()=>Fn,AnnotationLayer:()=>Ea,AnnotationMode:()=>gn,ColorPicker:()=>qr,DOMSVGFactory:()=>Os,DrawLayer:()=>Na,FeatureTest:()=>ne,GlobalWorkerOptions:()=>Rn,ImageKind:()=>Cr,InvalidPDFException:()=>Ts,MissingPDFException:()=>On,OPS:()=>Ge,OutputScale:()=>Es,PDFDataRangeTransport:()=>Hr,PDFDateString:()=>kr,PDFWorker:()=>Jn,PasswordResponses:()=>ab,PermissionFlag:()=>ob,PixelsPerInch:()=>yn,RenderingCancelledException:()=>ws,TextLayer:()=>Ps,TouchManager:()=>Rr,UnexpectedResponseException:()=>qn,Util:()=>St,VerbosityLevel:()=>ni,XfaLayer:()=>$r,build:()=>Kb,createValidAbsoluteUrl:()=>hb,fetchData:()=>oi,getDocument:()=>zb,getFilenameFromUrl:()=>vb,getPdfFilenameFromUrl:()=>xb,getXfaPageViewport:()=>Sb,isDataScheme:()=>ai,isPdfFile:()=>Ga,noContextMenu:()=>He,normalizeUnicode:()=>mb,setLayerDimensions:()=>Mn,shadow:()=>Ot,stopEvent:()=>Ee,version:()=>Yb});L1=Lt(4114),F1=Lt(6573),D1=Lt(8100),_1=Lt(7936),N1=Lt(7467),U1=Lt(4732),B1=Lt(9577),G1=Lt(5247),H1=Lt(4979),j1=Lt(4603),V1=Lt(7566),$1=Lt(8721),ue=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Au=[1,0,0,1,0,0],mo=[.001,0,0,.001,0,0],sb=1e7,Tr=1.35,rb=.35,z1=rb/Tr,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},ib="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},ob={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},Cr={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},ys={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},ni={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},ab={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},si=ni.WARNINGS;bn=(function(){function t(e,n){this.message=e,this.name=n}return t.prototype=new Error,t.constructor=t,t})(),wr=class extends bn{constructor(t,e){super(t,"PasswordException"),this.code=e}},As=class extends bn{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},Ts=class extends bn{constructor(t){super(t,"InvalidPDFException")}},On=class extends bn{constructor(t){super(t,"MissingPDFException")}},qn=class extends bn{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},yo=class extends bn{constructor(t){super(t,"FormatError")}},Ze=class extends bn{constructor(t){super(t,"AbortException")}};ne=class{static get isLittleEndian(){return Ot(this,"isLittleEndian",fb())}static get isEvalSupported(){return Ot(this,"isEvalSupported",pb())}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)"))}},uo=Array.from(Array(256).keys(),o=>o.toString(16).padStart(2,"0")),St=class{static makeHexColor(t,e,n){return`#${uo[t]}${uo[e]}${uo[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 y=1-g,v=g*g,S=v*g,T=y*(y*(y*t+3*g*e)+3*v*n)+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,n,r,a,c,u,f,g,m,y,v){if(Math.abs(g)<1e-12){Math.abs(m)>=1e-12&&this.#t(t,e,n,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,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}};ho=null,lu=null;Ba="pdfjs_internal_id_";W1=Lt(4628),X1=Lt(7642),Y1=Lt(8004),K1=Lt(3853),Z1=Lt(5876),Q1=Lt(2475),J1=Lt(5024),q1=Lt(1698),tS=Lt(1454),eS=Lt(8992),nS=Lt(4743),sS=Lt(3215),rS=Lt(7550),iS=Lt(8335),nn="http://www.w3.org/2000/svg",yn=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};Cs=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,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])*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,y*n,v*n,S*n,T-m*n*f-v*n*g,w-y*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)}},ws=class extends bn{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};Er=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
4
+ `);return t.join("")}};kr=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 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(n,r,a,c,u,f))}};Es=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}},bo=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}},vo=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)}};xo=class{#t=0;get id(){return`${ib}${this.#t++}`}},So=class o{#t=yb();#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 oi(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 y=n.svgUrl=c.result;u.src=await a?`${y}#svgView(preserveAspectRatio(none))`:y},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}_`)}},Ao=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))}},To=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 Ab(t),Ot(this,"_colors",t)}convert(t){let e=Ha(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 Ao;#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;#w=!1;#k=null;#P=new xo;#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,y,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.#y=m,this.#_=y||null,this.viewParameters={realScale:yn.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.#b&&(clearTimeout(this.#b),this.#b=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.#y}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.#y=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*yn.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 y=this.#X(g),v=this.#C===Rt.NONE,S=()=>{y?.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 vo(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.#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.#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 So)}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,y,v)=>({x:(m-r)/c,y:1-(g+y-n)/a,width:v/c,height:y/a});break;case"180":u=(g,m,y,v)=>({x:1-(g+y-n)/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-n)/a,width:v/c,height:y/a});break;default:u=(g,m,y,v)=>({x:(g-n)/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 n=this.#r.getRawValue(e);n&&(this.#C===Rt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(t))}},Pr=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)}},Rr=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:y,touch1Y:v}=f,S=y-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;#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;#w=!1;#k=o._zIndex++;static _borderLineWidth=-1;static _colorManager=new To;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 Co({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: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}=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,y=this.#I(this.rotation),v=(Y,K)=>[y[0]*Y+y[2]*K,y[1]*Y+y[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,[yt,lt]=this.#u;[Z,q]=this.screenToPageTranslation(Y-yt,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 bt=o._round(u*W),et=o._round(f*$);D=v(...I(bt,et));let Tt=G-D[0],dt=j-D[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=bt,this.height=et,this.x=Tt,this.y=dt,this.setDims(n*bt,r*et),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new bo(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||(Pr.initialize(o._l10n),this.#n=new Pr(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),Ir(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#T||=new Rr({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,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 O=u(v/2,S/2),F=o._round(m+O[0]),_=o._round(y+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.#b=t.clientY,this.#i=t.pointerId,this.#r=t.pointerType,window.addEventListener("pointermove",g=>{n||(n=!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,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,y=this.x*a,v=this.y*c,S=this.width*a,T=this.height*c;switch(n){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[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.#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.#E(),this.#a.classList.remove("hidden"),Ir(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()}},Co=class extends Xt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},cu=3285377520,Oe=4294901760,Ke=65535,Or=class{constructor(t){this.h1=t?t&4294967295:cu,this.h2=t?t&4294967295:cu}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,y=3432918353,v=461845907,S=y&Ke,T=v&Ke;for(let w=0;w<r;w++)w&1?(u=c[w],u=u*y&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*y&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*y&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")}},wo=Object.freeze({map:null,hash:"",transfer:void 0}),ks=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?Ua(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 Mr(this)}get serializable(){if(this.#n.size===0)return wo;let t=new Map,e=new Or,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}:wo}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(",")}}},Mr=class extends ks{#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:""})}},Eo=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 y=`lt${Date.now()}${this.loadTestFontId++}`,v=this._loadTestFont;v=r(v,976,y.length,y);let T=16,w=1482184792,I=n(v,T);for(a=0,c=y.length-3;a<c;a+=4)I=I-w+n(y,a)|0;a<y.length&&(I=I-w+n(y+"XXX",a)|0),v=r(v,T,4,db(I));let k=`url(data:font/opentype;base64,${btoa(v)});`,O=`@font-face {font-family:"${y}";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,y]){let D=this._document.createElement("span");D.textContent="Hi",D.style.fontFamily=_,F.append(D)}this._document.body.append(F),m(y,()=>{F.remove(),e.complete()})}},ko=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,${bb(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}},vr={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===vr.DATA)r.resolve(t.data);else if(t.callback===vr.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:vr.DATA,callbackId:t.callbackId,data:c})},function(c){a.postMessage({sourceName:n,targetName:r,callback:vr.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,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:n,targetName:r,stream:qt.ENQUEUE,streamId:e,chunk:g},y)},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||uu).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||uu,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}},Lr=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.")}},Io=class extends Lr{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}},Fr=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.")}},Dr=class extends Fr{async _fetch(t){let e=await oi(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ii(e)}},oS=Lt(4520),_r=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){}},Po=class extends _r{#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 y=0;y<256;y++)g[y]=f[y]/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&&(ai(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`,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 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),y),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.#y(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.#y(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]),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,O,F)=>{let _=new Array(256),D=(y-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 bt=W;bt<=Z;bt++)_[bt]=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)}#y(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,Ha(getComputedStyle(this.#c).getPropertyValue("color"))}},Nr=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.")}},Ur=class extends Nr{async _fetch(t){let e=await oi(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."))}Ro=class extends _r{},Oo=class extends Lr{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(__import_meta_url__)("@napi-rs/canvas").createCanvas(t,e)}},Mo=class extends Fr{async _fetch(t){return Cu(t)}},Lo=class extends Nr{async _fetch(t){return Cu(t)}},ce={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};Is=class{getPattern(){$t("Abstract method `getPattern` called.")}},Do=class extends Is{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),Fo(m,this._bbox),m.fillStyle=this._createGradient(m),m.fill(),a=t.createPattern(g.canvas,"no-repeat");let y=new DOMMatrix(n);a.setTransform(y)}else Fo(t,this._bbox),a=this._createGradient(t);return a}};_o=class extends Is{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,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,O=n.getCanvas("mesh",I,k),F=O.context,_=F.createImageData(y,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)Tb(_,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){Fo(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")}},No=class extends Is{getPattern(){return"hotpink"}};hu={COLORED:1,UNCOLORED:2},Uo=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),ri("TilingType: "+a);let m=e[0],y=e[1],v=e[2],S=e[3],T=v-m,w=S-y,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 bt=this.getSizeAndScale(_,this.ctx.canvas.width,O),et=this.getSizeAndScale(D,this.ctx.canvas.height,F),Tt=t.cachedCanvases.getCanvas("pattern",bt.size,et.size),dt=Tt.context,Y=u.createCanvasGraphics(dt);if(Y.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(Y,r,c),dt.translate(-bt.scale*m,-et.scale*y),Y.transform(bt.scale,0,0,et.scale,0,0),dt.save(),this.clipBbox(Y,m,y,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 yt=this.getSizeAndScale(_,this.ctx.canvas.width,O),lt=this.getSizeAndScale(D,this.ctx.canvas.height,F),kt=yt.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:yt.scale,scaleY:lt.scale,offsetX:m,offsetY:y}}return{canvas:Tt.canvas,scaleX:bt.scale,scaleY:et.scale,offsetX:m,offsetY:y}}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 hu.COLORED:let c=this.ctx;r.fillStyle=c.fillStyle,r.strokeStyle=c.strokeStyle,a.fillColor=c.fillStyle,a.strokeColor=c.strokeStyle;break;case hu.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 yo(`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}};du=16,fu=100,Eb=15,pu=10,gu=1e3,xe=16;Bo=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]}}};Br=class{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Au,this.textMatrixScale=1,this.fontMatrix=mo,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 y=St.bezierBoundingBox(e,n,r,a,c,u,f,g,m);m||this.updateRectMinMax(t,y)}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))}};Pb=["butt","round","square"],Rb=["miter","round","bevel"],Ob={},vu={},Qn=class o{constructor(t,e,n,r,a,{optionalContentConfig:c,markedContentStack:u=null},f,g){this.ctx=t,this.current=new Br(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 Bo(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(),Sr(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>pu&&typeof n=="function",m=g?Date.now()+Eb:0,y=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&&++y>pu){if(Date.now()>m)return n(),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 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,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:n,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 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||(y=this.cachedCanvases.getCanvas("maskCanvas",n,r),yu(y.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(y.canvas,Ye(_)),m=m.img,f&&c&&f.set(g,m)),_.imageSmoothingEnabled=bu(Wt(_),t.interpolate),xr(_,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=Pb[t]}setLineJoin(t){this.ctx.lineJoin=Rb[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)),bs(this.suspendedCtx,a),kb(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(),bs(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,y){let v=t.canvas,S=f-m,T=g-y;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?(bs(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(),bs(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),y=m[0]===0&&m[3]===0||m[1]===0&&m[2]===0,v=y?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)),y||a.updateRectMinMax(m,[c,u,O,F]),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,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=Ob}eoClip(){this.pendingClip=vu}beginText(){this.current.textMatrix=Au,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||mo,(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<du?g=du:e>fu&&(g=fu),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,y=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),y===le.FILL||y===le.FILL_STROKE)if(r){let I=c.getTransform();c.setTransform(...r),c.fill(this.#n(w,I,r))}else c.fill(w);if(y===le.STROKE||y===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(y===le.FILL||y===le.FILL_STROKE)&&c.fillText(t,e,n),(y===le.STROKE||y===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,y=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<y;++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,bt,et,Tt=j.width;if(v){let Y=j.vmetric||T,K=-(j.vmetric?Y[1]:Tt*.5)*w,yt=Y[2]*w;Tt=Y?-Y[0]:Tt,bt=K/c,et=(D+yt)/c}else bt=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),bt/=K}else Tt!==Y&&(bt+=(Tt-Y)/2e3*r/c)}if(this.contentVisible&&(j.isInFont||n.missingFile)){if(I&&!q)a.fillText(Z,bt,et);else if(this.paintChar(Z,bt,et,k,O),q){let Y=bt+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,y=n.fontMatrix||mo,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(...y),this.executeOperatorList(F),this.restore()),I=St.applyTransform([w.width,0],y)[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 Uo(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=Cb(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||ri("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 y=this.cachedCanvases.getCanvas(m,f,g),v=y.context;v.translate(-c,-u),v.transform(...n),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()),bs(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(),Sr(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,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),Sr(this.ctx)}else Sr(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],c,u),this.ctx.clip(),this.ctx.beginPath()}this.current=new Br(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=Ib(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,y=c.length;m<y;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),y=m.context;y.save();let v=this.getObject(c,a);yu(y,v),y.globalCompositeOperation="source-in",y.fillStyle=r?n.getPattern(y,this,Ye(e),ce.FILL):n,y.fillRect(0,0,u,f),y.restore(),e.save(),e.transform(...g),e.scale(1,-1),xr(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;mu(f,t),a=this.applyTransferMapsToCanvas(f)}let c=this._scaleImage(a,Ye(r));r.imageSmoothingEnabled=bu(Wt(r),t.interpolate),xr(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;mu(f,t),r=this.applyTransferMapsToCanvas(f)}for(let a of e)n.save(),n.transform(...a.transform),n.scale(1,-1),xr(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===vu?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,y=g*t;c=m<1?1/m:1,u=y<1?1/y: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 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: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}},Go=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 Ua(this.#t)}has(t){return this.#t.has(t)}},Zn=Symbol("INTERNAL"),Ho=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}},jo=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 Ho(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 ri("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?Ua(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new Or;for(let[e,n]of this.#e)t.update(`${e}:${n.visible}`);return this.#t=t.hexdigest()}},Vo=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 $o(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new zo(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()}},$o=class{constructor(t,e,n=!1,r=null){this._stream=t,this._done=n||!1,this._filename=Ga(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)}},zo=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)}};Gr=class{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=wu(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 Wo(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new Xo(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)}},Wo=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,Pu(n,this._withCredentials,this._abortController)).then(a=>{if(t._responseOrigin=li(a.url),!Iu(a.status))throw ci(a.status,r);this._reader=a.body.getReader(),this._headersCapability.resolve();let c=a.headers,{allowRangeRequests:u,suggestedLength:f}=Eu({responseHeaders:c,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=u,this._contentLength=f||this._contentLength,this._filename=ku(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:Ru(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},Xo=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,Pu(a,this._withCredentials,this._abortController)).then(u=>{let f=li(u.url);if(f!==t._responseOrigin)throw new Error(`Expected range response-origin "${f}" to match "${t._responseOrigin}".`);if(!Iu(u.status))throw ci(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:Ru(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},po=200,go=206;Yo=class{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:n}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=wu(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=go):r.expectedStatus=po,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||po;if(!(a===po&&n.expectedStatus===go)&&a!==n.expectedStatus){n.onError(r.status);return}let u=Lb(r);if(a===go){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()}},Ko=class{constructor(t){this._source=t,this._manager=new Yo(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 Zo(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let n=new Qo(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)}},Zo=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=li(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}=Eu({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=c||this._contentLength,this._filename=ku(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=ci(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}},Qo=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=li(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??=ci(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()}},Fb=/^[a-z][a-z0-9\-+.]+:/i;Jo=class{constructor(t){this.source=t,this.url=Db(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 qo(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new ta(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)}},qo=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)}},ta=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)}},_b=1e5,be=30,Nb=.8,Ps=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#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.#y=[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>_b){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.#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.#F(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,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.#b.values())t.remove();this.#b.clear()}}static#I(t=null){let e=this.#b.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.#b.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=be,this.#E(r,be,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,be,be),r.strokeText("g",0,0);let f=r.getImageData(0,0,be,be).data;u=0;for(let m=f.length-1-3;m>=0;m-=4)if(f[m]>0){u=Math.ceil(m/4/be);break}r.clearRect(0,0,be,be),r.strokeText("A",0,be),f=r.getImageData(0,0,be,be).data,c=0;for(let m=0,y=f.length;m<y;m+=4)if(f[m]>0){c=be-Math.floor(m/4/be);break}r.canvas.width=r.canvas.height=0;let g=c?c/(c+u):Nb;return this.#x.set(t,g),g}},Rs=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")}},Ub=65536,Bb=100,Gb=5e3,Hb=ue?Oo:Io,jb=ue?Mo:Dr,Vb=ue?Ro:Po,$b=ue?Lo:Ur;ea=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}},Hr=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(){}},na=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()}},sa=class{#t=null;#e=!1;constructor(t,e,n,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=r?new Er:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new jr,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 Cs({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:y=!1}){this._stats?.time("Overall");let v=this._transport.getRenderingIntent(n,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&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 aa({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=>Rs.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 Er),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)},Gb),!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: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:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(e instanceof ws){let r=Bb;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}},ra=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=cb()}={}){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{ri("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 ra;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)())}},ia=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 jr,this.fontLoader=new Eo({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 ks)}getRenderingIntent(t,e=gn.ENABLE,n=null,r=!1,a=!1){let c=we.DISPLAY,u=wo;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 Mr?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,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 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(),Ps.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 na(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 ko(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: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(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>sb&&(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 sa(e,a,this,this._params.pdfBug);return this.#e.set(e,c),c});return this.#n.set(e,r),r}getPageIndex(t){return xu(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 jo(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 Go(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),Ps.cleanup()}}cachedPageNumber(t){if(!xu(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#s.get(e)??null}},vs=Symbol("INITIAL_DATA"),jr=class{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:vs}}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===vs)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!==vs}delete(t){let e=this.#t[t];return!e||e.data===vs?!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!==vs&&(yield[t,e])}}},oa=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}},aa=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:y=!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=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 oa(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 ws(`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())))}},Yb="4.10.45",Kb="18f8e0416",aS=Lt(670);Vr=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=xs(t),[t,t,t]}static G_HTML([t]){let e=Su(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(xs)}static RGB_HTML(t){return`#${t.map(Su).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[xs(1-Math.min(1,t+r)),xs(1-Math.min(1,n+r)),xs(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]}},la=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.")}},Os=class extends la{_createSVG(t){return document.createElementNS(nn,t)}},$r=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 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&&Rs.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:n}),T.children?.length>0)m.push([T,-1,I]);else if(T.value){let k=document.createTextNode(T.value);u&&Rs.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}},_s=1e3,Zb=9,Dn=new WeakSet;ca=class{static create(t){switch(t.data.annotationType){case ee.LINK:return new zr(t);case ee.TEXT:return new ua(t);case ee.WIDGET:switch(t.data.fieldType){case"Tx":return new ha(t);case"Btn":return t.data.radioButton?new Wr(t):t.data.checkBox?new fa(t):new pa(t);case"Ch":return new ga(t);case"Sig":return new da(t)}return new sn(t);case ee.POPUP:return new Ms(t);case ee.FREETEXT:return new Xr(t);case ee.LINE:return new ya(t);case ee.SQUARE:return new ba(t);case ee.CIRCLE:return new va(t);case ee.POLYLINE:return new Yr(t);case ee.CARET:return new Sa(t);case ee.INK:return new Ls(t);case ee.POLYGON:return new xa(t);case ee.HIGHLIGHT:return new Kr(t);case ee.UNDERLINE:return new Aa(t);case ee.SQUIGGLY:return new Ta(t);case ee.STRIKEOUT:return new Ca(t);case ee.STAMP:return new Zr(t);case ee.FILEATTACHMENT:return new wa(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=_s);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 Ms){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 Wr){let O=`calc(${u}px * var(--scale-factor)) / calc(${f}px * var(--scale-factor))`;c.borderRadius=O}switch(e.borderStyle.style){case ys.SOLID:c.borderStyle="solid";break;case ys.DASHED:c.borderStyle="dashed";break;case ys.BEVELED:Et("Unimplemented border style: beveled");break;case ys.INSET:Et("Unimplemented border style: inset");break;case ys.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: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: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]=Vr[`${c}_HTML`](u),this.annotationStorage.setValue(this.data.id,{[n]:Vr[`${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,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],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(y),this.container.style.clipPath=`url(#${T})`}_createPopup(){let{data:t}=this,e=this.#n=new Ms({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})})}},zr=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 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(!Dn.has(v)){Et(`_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}}},ua=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||Zb,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/(Tr*r))||1,y=g/m;c=Math.min(r,f(y/Tr))}else{let g=Math.abs(this.data.rect[3]-this.data.rect[1]-u);c=Math.min(r,f(g/Tr))}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)}},ha=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(`
5
+ `)||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=_s,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 y=this.data.defaultFieldValue??"";n.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){n.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)}),n.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)}),n.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,n.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&&n.addEventListener("beforeinput",y=>{f.lastCommittedValue=null;let{data:v,target:S}=y,{value:T,selectionStart:w,selectionEnd:I}=S,k=w,O=I;switch(y.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}y.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"]],y=>y.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){let y=(this.data.rect[2]-this.data.rect[0])/c;n.classList.add("comb"),n.style.letterSpacing=`calc(${y}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}},da=class extends sn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}},fa=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=_s,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}},Wr=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=_s,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 y of this._getElementsByName(g.target.name)){let v=m&&y.id===n;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}},pa=class extends zr{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}},ga=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=_s;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,n.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}},Ms=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 ma({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=>`${Ba}${n}`).join(",")),this.container}},ma=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;#y=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: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=n,this.#a=kr.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,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=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.#b;if(r)$r.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}#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(`
6
+ `))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.#y||={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.#y&&({contentsObj:this.#l,richText:this.#m}=this.#y,this.#y=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,y=f[0]+m,v=f[1];this.#o=[100*(y-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}},Xr=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}},ya=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")}},ba=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")}},va=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")}},Yr=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,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",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")}},xa=class extends Yr{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},Sa=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}},Ls=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 y=0,v=n.length;y<v;y++){let S=this.svgFactory.createElement(this.svgElementName);this.#e.push(S),S.setAttribute("points",n[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: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")}},Kr=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}},Aa=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}},Ta=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}},Ca=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}},Zr=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}},wa=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)}},Ea=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=`${Ba}${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 Os,annotationStorage:t.annotationStorage||new ks,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}=mn(c.rect);if(m<=0||y<=0)continue}a.data=c;let f=ca.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)}},Ar=/\r\n?|\n/g,ka=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(`
7
+ `)}#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),Ir(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,[y,v]=this.pageTranslation,S,T;switch(this.rotation){case 0:S=t+(c[0]-y)/g,T=e+this.height-(c[1]-v)/m;break;case 90:S=t+(c[0]-y)/g,T=e-(c[1]-v)/m,[u,f]=[f,-u];break;case 180:S=t-this.width+(c[0]-y)/g,T=e-(c[1]-v)/m,[u,f]=[-u,-f];break;case 270:S=t+(c[0]-y-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(Ar,"")}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(Ar,`
8
+ `);if(!r)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let c=a.getRangeAt(0);if(!r.includes(`
9
+ `)){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(Ar,"")),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(Ar,""))}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(`
10
+ `)}${r}${m.join(`
11
+ `)}`,this.#d();let y=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){y.setStart(S,v),y.setEnd(S,v);break}v-=T}a.removeAllRanges(),a.addRange(y)}#d(){if(this.editorDiv.replaceChildren(),!!this.#e)for(let t of this.#e.split(`
12
+ `)){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 Xr){let{data:{defaultAppearanceData:{fontSize:c,fontColor:u},rect:f,rotation:g,id:m,popupRef:y},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(`
13
+ `),position:S,pageIndex:T-1,rect:f.slice(0),rotation:g,id:m,deleted:!1,popupRef:y}}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(`
14
+ `)){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]}},Qr=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),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,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.#y();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.#b(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(" ")}#y(){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`)}#b(t){let[e,n,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]-n)/a} L${f} ${g} L${m} ${y} L${(u[0]-e)/r} ${(u[1]-n)/a}`)}newFreeDrawOutline(t,e,n,r,a,c){return new Jr(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 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(n[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.#w(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,[n,r,a,c]=this.#t,[u,f,g,m]=this.#g(),y=new Float32Array(36);return y.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(y,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,y,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,y,v,NaN,NaN,NaN,NaN,(r[0]-a)/u,(r[1]-c)/f],e),e+=24}},Jr=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 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,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,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=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=y(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 Qr(t,e,n,r,a,c)}getNewOutline(t,e){let[n,r,a,c]=this.#e,[u,f,g,m]=this.#t,y=a*g,v=c*m,S=n*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()}},Fs=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 y=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)/y,k[1]=(F-T)/v,k[2]=(_-T)/v}this.#t=new Float32Array([S,T,y,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,y]=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(y))T=y;else break;n.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 Ia(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,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}},Ia=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 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"]}},Ds=class extends Qr{newFreeDrawOutline(t,e,n,r,a,c){return new Pa(t,e,n,r,a,c)}},Pa=class extends Jr{newOutliner(t,e,n,r,a,c=0){return new Ds(t,e,n,r,a,c)}},qr=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.#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 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}},ti=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 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.#y=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#h=!0,this.#b(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.#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 Fs(this.#n,.001);this.#c=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#c.box;let e=new Fs(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]}#b({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,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 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 qr({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.#b({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),Ir(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:y}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-y*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,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}),n.addEventListener("pointermove",this.#C.bind(this,t),{signal:y}),this._freeHighlight=new Ds({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 Kr){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 Ls){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,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.#P(),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 Ds(w,[0,0,m,y],1,g.#g/2,!0,.001);for(let F=0,_=T.length;F<_;F+=2)w.x=T[F]-v,w.y=y-(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.#b({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}},Ra=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")}},Oa=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: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: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}},Ma=class{#t=new Float64Array(6);#e;#n;#s;#i;#r;#l="";#a=0;#u=new ei;#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,y]=this.#e.slice(r,r+6).map(ht.svgRound);n.push(`C${c} ${u} ${f} ${g} ${m} ${y}`)}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]}}},ei=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,y]=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-y)*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+y)*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+y)*r;break;case 270:_=ht._rescaleAndSwap,v=t+n,S=e+r,T=-n,w=-r,I=t+(1-g-y)*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=[],y,v,S,T,w;switch(f){case 0:w=ht._rescale,y=-t/n,v=e/r+1,S=1/n,T=-1/r;break;case 90:w=ht._rescaleAndSwap,y=-e/r,v=-t/n,S=1/r,T=1/n;break;case 180:w=ht._rescale,y=t/n+1,v=-e/r,S=-1/n,T=1/r;break;case 270:w=ht._rescaleAndSwap,y=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),y,v,S,T),points:w(u[k].map(F=>F??NaN),y,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,y,v,S,T]=r.subarray(u,u+6);St.bezierBoundingBox(a,c,g,m,y,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 y=(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(${y} ${v}) translate(${ht.svgRound(-a)} ${ht.svgRound(-c)})`}}}getPathResizedSVGProperties([t,e,n,r]){let[a,c]=this.#c(),u=this.#t,[f,g,m,y]=u;if(u[0]=t,u[1]=e,u[2]=n,u[3]=r,Math.abs(m-a)<=ht.PRECISION||Math.abs(y-c)<=ht.PRECISION){let I=t+n/2-(f+m/2),k=e+r/2-(g+y/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)/(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)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:y,points:v}of this.#s)ht._rescale(y,u,f,g,m,y),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}}},La=class o extends Ra{#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}},Fa=class o extends Oa{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 La(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 Ma(t,e,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,n,r,a,c){return ei.deserialize(t,e,n,r,a,c)}static async deserialize(t,e,n){let r=null;if(t instanceof Ls){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,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}},Da=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 Es,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 y=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),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: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 Es,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*yn.PDF_TO_CSS_UNITS),a=Math.round(this.height*n*yn.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 Zr){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(`${Ba}${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:y}=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,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 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.#y(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}#y(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}},_a=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([ka,Fa,Da,ti].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 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=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.#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 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.#b(),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(),ti.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)}#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:n,offsetY:r}=this.#x(),a=this.getNextId(),c=this.#y({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.#y({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,[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 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)}#b(){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.#b();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}},Na=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 Os)}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 y=o._svgFactory.createElement("mask");a.append(y),f=`mask_p${this.pageIndex}_${n}`,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(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:Fs};Qb=wt.AbortException,Jb=wt.AnnotationEditorLayer,qb=wt.AnnotationEditorParamsType,t0=wt.AnnotationEditorType,e0=wt.AnnotationEditorUIManager,n0=wt.AnnotationLayer,ja=wt.AnnotationMode,s0=wt.ColorPicker,r0=wt.DOMSVGFactory,i0=wt.DrawLayer,o0=wt.FeatureTest,a0=wt.GlobalWorkerOptions,l0=wt.ImageKind,c0=wt.InvalidPDFException,u0=wt.MissingPDFException,h0=wt.OPS,d0=wt.OutputScale,f0=wt.PDFDataRangeTransport,p0=wt.PDFDateString,g0=wt.PDFWorker,m0=wt.PasswordResponses,y0=wt.PermissionFlag,b0=wt.PixelsPerInch,v0=wt.RenderingCancelledException,x0=wt.TextLayer,S0=wt.TouchManager,A0=wt.UnexpectedResponseException,T0=wt.Util,C0=wt.VerbosityLevel,w0=wt.XfaLayer,E0=wt.build,k0=wt.createValidAbsoluteUrl,I0=wt.fetchData,P0=wt.getDocument,R0=wt.getFilenameFromUrl,O0=wt.getPdfFilenameFromUrl,M0=wt.getXfaPageViewport,L0=wt.isDataScheme,F0=wt.isPdfFile,D0=wt.noContextMenu,_0=wt.normalizeUnicode,N0=wt.setLayerDimensions,U0=wt.shadow,B0=wt.stopEvent,G0=wt.version});var Ya=Wy((Vu,fi)=>{var ju=(()=>{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:()=>yt,Font:()=>Zc,Glyph:()=>$n,Path:()=>it,_parse:()=>rt,load:()=>Ny,loadSync:()=>Uy,parse:()=>_y});var f=0,g=-3;function m(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function y(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 bt(s,i,l){var h,d,p,b,x,A;for(h=Z(s,5,257),d=Z(s,5,1),p=Z(s,4,4),b=0;b<19;++b)_[b]=0;for(b=0;b<p;++b){var E=Z(s,3,0);_[O[b]]=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,b,x;for(h-=257,d=Z(s,T[h],w[h]),p=q(s,l),b=s.destLen-Z(s,I[p],k[p]),x=b;x<b+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 y(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:bt(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,b,x){let A=[s,i],E=[l,h],C=[d,p],R=[b,x];this.addPoint(s,i),this.addPoint(b,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 b=s+.6666666666666666*(l-s),x=i+2/3*(h-i),A=b+1/3*(d-s),E=x+1/3*(p-i);this.addBezier(s,i,b,x,A,E,d,p)};var yt=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],b=s[d],x=p[0],A=p[1],E=p[p.length-1],C=s[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<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="-+",b={},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(b.type===void 0)return;let M=b.type.toUpperCase(),N=M!=="Z"&&b.type.toUpperCase()!==b.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(!b.type&&!this.commands.length&&(b.type="L"),N==="-")!b.type||z.indexOf("-")>0?A=!0:z.length?x.push("-"):x[x.length-1]=N;else if(!b.type||z.length>0)A=!0;else continue;else if(h.indexOf(N)>-1)b.type?(R.apply(this),b={type:N}):b.type=N;else{if(d.indexOf(N)>-1)throw new Error("Unsupported path command: "+N+". Currently supported commands are "+h.split("").join(", ")+".");` ,
15
+ \r\f\v`.indexOf(N)>-1?x.push(""):N==="."?!b.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 yt){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 yt,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":s.addPoint(b.x,b.y),i=h=b.x,l=d=b.y;break;case"L":s.addPoint(b.x,b.y),h=b.x,d=b.y;break;case"Q":s.addQuad(h,d,b.x1,b.y1,b.x,b.y),h=b.x,d=b.y;break;case"C":s.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 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 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},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,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},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 b=0;b<l;b++){let x=s.getUint8(i+b);x<=127?p+=String.fromCharCode(x):p+=d[x&127]}return p};var rn=typeof WeakMap=="function"&&new WeakMap,Je,qh=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=qh(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 Pi(s){return s>=-128&&s<=127}function td(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 ed(s,i,l){let h=0,d=s.length,p=i;for(;p<d&&h<64;){let b=s[p];if(!Pi(b)||b===0&&p+1<d&&s[p+1]===0)break;++p,++h}l.push(h-1);for(let b=i;b<p;++b)l.push(s[b]+256&255);return p}function nd(s,i,l){let h=0,d=s.length,p=i;for(;p<d&&h<64;){let b=s[p];if(b===0||Pi(b)&&p+1<d&&Pi(s[p+1]))break;++p,++h}l.push(64|h-1);for(let b=i;b<p;++b){let x=s[b];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=td(s,i,l):h>=-128&&h<=127?i=ed(s,i,l):i=nd(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,b=[void 0,tt.BYTE,tt.USHORT,tt.UINT24,tt.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(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),b=s[p],x=tt.OPERAND(b.value,b.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 zs=typeof WeakMap=="function"&&new WeakMap;tt.CHARSTRING=function(s){if(zs){let h=zs.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 b=0;b<p.length;b++)i.push(p[b])}return zs&&zs.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 b=s.fields[p],x=tt[b.type];U.argument(x!==void 0,"No encoding function for field type "+b.type+" ("+b.name+")");let A=s[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;U.argument(x<65536,"Table "+s.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},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 b=s[d.name];b===void 0&&(b=d.value),i+=p(b),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],b=l[p];this[p]!==void 0&&(this[p]=b)}}}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 Ri(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 Ws(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.")}Ws.prototype=Object.create(Kt.prototype),Ws.prototype.constructor=Ws;function Xs(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,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(Hn("featureIndex",x.featureIndexes)))}]})))}]}))}Xs.prototype=Object.create(Kt.prototype),Xs.prototype.constructor=Xs;function Ys(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)))}]}))}Ys.prototype=Object.create(Kt.prototype),Ys.prototype.constructor=Ys;function Ks(s,i){Kt.call(this,"lookupListTable",Ri("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(Ri("subtable",l.subtables,h)))}))}Ks.prototype=Object.create(Kt.prototype),Ks.prototype.constructor=Ks;function Zs(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.")}Zs.prototype=Object.create(Kt.prototype),Zs.prototype.constructor=Zs;var J={Table:Kt,Record:Kt,Coverage:Ws,ClassDef:Zs,ScriptList:Xs,FeatureList:Ys,LookupList:Ks,ushortList:Hn,tableList:Ri,recordList:jn};function gl(s,i){return s.getUint8(i)}function Qs(s,i){return s.getUint16(i,!1)}function sd(s,i){return s.getInt16(i,!1)}function ml(s,i){return(s.getUint16(i)<<8)+s.getUint8(i+2)}function Oi(s,i){return s.getUint32(i,!1)}function rd(s,i){return s.getInt32(i,!1)}function yl(s,i){let l=s.getInt16(i,!1),h=s.getUint16(i+2,!1);return l+h/65535}function id(s,i){let l="";for(let h=i;h<i+4;h+=1)l+=String.fromCharCode(s.getInt8(h));return l}function od(s,i,l){let h=0;for(let d=0;d<l;d+=1)h<<=8,h+=s.getUint8(i+d);return h}function ad(s,i,l){let h=[];for(let d=i;d<l;d+=1)h.push(s.getUint8(d));return h}function ld(s){let i="";for(let l=0;l<s.length;l+=1)i+=String.fromCharCode(s[l]);return i}var cd={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=ml(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,s},B.prototype.parseULong=function(){let s=Oi(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},B.prototype.parseLong=function(){let s=rd(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},B.prototype.parseOffset32=B.prototype.parseULong,B.prototype.parseFixed=function(){let s=yl(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=Oi(this.data,this.offset+this.relativeOffset+4);return s-=2082844800,this.relativeOffset+=8,s},B.prototype.parseVersion=function(s){let i=Qs(this.data,this.offset+this.relativeOffset),l=Qs(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+=cd[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 b=0;b<h.length;b++){let x=h[b],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 b=0;b<h.length;b++){let x=h[b],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 b=i[p];if(b===0){d[p]=void 0;continue}if(this.relativeOffset=b,s){let x=this.parseOffset16List(),A=new Array(x.length);for(let E=0;E<x.length;E++)this.relativeOffset=b+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 bl={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(bl),langSysRecords:B.recordList({tag:B.tag,langSys:B.pointer(bl)})})}))||[]},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 b=d[p];this.relativeOffset=s+b,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 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: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 b=(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(b()):h[A].push(x());return h},B.prototype.parseTupleVariationStoreList=function(s,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 R=0;R<h;R++){C=x(),p||(C*=2);let P=C-E;A[R]=P?this.parseTupleVariationStore(b+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 b=this.parseUShort(),x=!!(b&re.SHARED_POINT_NUMBERS),A=b&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),b=!!(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:b}};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),b=(d&re.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},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 b=0;b<p&&i.length<s;b++)h?i.push(0):d?i.push(this.parseShort()):i.push(this.parseChar())}return i};var rt={getByte:gl,getCard8:gl,getUShort:Qs,getCard16:Qs,getShort:sd,getUInt24:ml,getULong:Oi,getFixed:yl,getTag:id,getOffset:od,getBytes:ad,bytesToString:ld,Parser:B},Js=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],vl={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"},ud={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},xl={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 hd(s,i,l){switch(s){case 0:if(i===65535)return"und";if(l)return l[i];break;case 1:return vl[i];case 3:return xl[i]}}var Mi="utf-16",dd={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"},fd={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 Li(s,i,l){switch(s){case 0:return Mi;case 1:return fd[l]||dd[i];case 3:if(i===1||i===10)return Mi;break}}var Sl={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function pd(s){return Sl[s]}function gd(s,i,l){let h={},d=new rt.Parser(s,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(),R=d.parseUShort(),P=d.parseUShort(),L=Js[P]||P,M=d.parseUShort(),N=d.parseUShort(),z=hd(E,R,l),vt=Li(E,C,R),pt=pd(E);if(vt!==void 0&&z!==void 0&&pt!==void 0){let At;if(vt===Mi?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 qs(s){let i={};for(let l in s)i[s[l]]=parseInt(l);return i}function Al(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 md(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 Tl(s,i){let l=md(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 yd(s,i){let l=qs(Sl),h=qs(vl),d=qs(xl),p=[],b=[];for(let A in s){let E,C=[],R={},P=qs(Js),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=ud[pt],It=Li(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=Tl(Nt,b);p.push(Al(L,At,pt,E,Nt.length,Bt))}}if(L===3){let pt=d[z];if(pt!==void 0){let At=tt.UTF16(vt),It=Tl(At,b);p.push(Al(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:b}),x}function tr(s,i,l=[]){if(i<256&&i in Js){if(l.length&&!l.includes(parseInt(i)))return;i=Js[i]}for(let h in s)for(let d in s[h])if(d===i||parseInt(d)===i)return s[h][d]}var Cl={parse:gd,make:yd,getNameByID:tr};function bd(s,i,l,h){s.length=i.parseUShort(),s.language=i.parseUShort()-1;let d=i.parseByteList(s.length),p=Object.assign({},d),b=Li(l,h,s.language),x=Le[b];for(let A=0;A<x.length;A++)p[x.charCodeAt(A)]=d[128+A];s.glyphIndexMap=p}function vd(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(),b=i.parseULong(),x=i.parseULong();for(let A=p;A<=b;A+=1)s.glyphIndexMap[A]=x,l===12&&x++}}function xd(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 b=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=b.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 Sd(s,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={},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]=b,i.relativeOffset=E}s.varSelectorList=l}function Ad(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,b=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(b=rt.getUShort(s,i+4+R*8),x=rt.getUShort(s,i+4+R*8+2),b===3&&E.includes(x)||b===0&&A.includes(x)||b===1&&x===0){if(p>0)continue;if(p=rt.getULong(s,i+4+R*8+4),h)break}else if(b===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)bd(l,C,b,x);else if(l.format===12||l.format===13)vd(l,C,l.format);else if(l.format===4)xd(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 "+b+", encodingId "+x+").");return h&&Sd(l,h),l}function Td(s,i,l){s.segments.push({end:i,start:i,delta:-(i-l),offset:0,glyphIndex:l})}function Cd(s){s.segments.push({end:65535,start:65535,delta:1,offset:0})}function wd(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 Ed(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)Td(d,L.unicodes[M],l)}d.segments.sort(function(L,M){return L.start-M.start}),d.segments=wd(d.segments),Cd(d);let p=d.segments.length,b=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})):b+=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-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 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 wl={parse:Ad,make:Ed},er=[".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"],kd=[".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"],Id=[".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"],Pd=[".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"],Fi=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Rd=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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 El(s){this.font=s}El.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 kl(s){this.cmap=s}kl.prototype.charToGlyphIndex=function(s){return this.cmap.glyphIndexMap[s.codePointAt(0)]||0};function Il(s,i){this.encoding=s,this.charset=i}Il.prototype.charToGlyphIndex=function(s){let i=s.codePointAt(0),l=this.encoding[i];return this.charset.indexOf(l)};function Di(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}}Di.prototype.nameToGlyphIndex=function(s){return this.names.indexOf(s)},Di.prototype.glyphIndexToName=function(s){return this.names[s]};function Od(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],b=l[p];i=s.glyphs.get(b),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 Md(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 Ld(s,i){i.lowMemory?Md(s):Od(s)}function Fd(s,i,l,h,d){s.beginPath(),s.moveTo(i,l),s.lineTo(h,d),s.stroke()}var Tn={line:Fd};function Dd(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(),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 _d({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 Pl(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 _i(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 b=Pl(d.colorRecords[p]);return h==="bgra"?b:Vn(b,h)}function Fe(s){return("0"+parseInt(s).toString(16)).slice(-2)}function Nd(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),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 Ud(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,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 Rl(s){return parseInt(`0x${Fe(s.b)}${Fe(s.g)}${Fe(s.r)}${Fe(s.a*255)}`,16)}function nr(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 Rl(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 b=Vn(p.fillStyle,"hexa");b==="#000000ff"&&s.toLowerCase()!=="black"?d=!1:s=b}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 b=s.match(p).filter(x=>typeof x<"u");s={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(s)){let x=s.match(b).filter(A=>typeof A<"u");s=Ud({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=Pl(s)}else typeof s!="object"&&(s=nr(s,"bgra"));let l=["hsl","hsla"].includes(i)?Nd(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 Rl(s);default:throw new Error("Unknown color format: "+i)}}var Ol={parse:Dd,make:_d,getPaletteColor:_i,parseColor:nr,formatColor:Vn};function Bd(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",Bd(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,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),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=_i(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 b(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",b(A,i,l,x),s.fillStyle="red",b(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,b=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+-b*d,1e4,l+-b*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 sr(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&&(sr.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)}}),sr.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]},sr.prototype.push=function(s,i){this.glyphs[s]=i,this.length++};function Gd(s,i){return new $n({index:i,font:s})}function Hd(s,i,l,h,d,p){return function(){let b=new $n({index:i,font:s});return b.path=function(){l(b,h,d);let x=p(s.glyphs,b);return x.unitsPerEm=s.unitsPerEm,x},zn(b,"numberOfContours","_numberOfContours"),zn(b,"xMin","_xMin"),zn(b,"xMax","_xMax"),zn(b,"yMin","_yMin"),zn(b,"yMax","_yMax"),zn(b,"points","_points"),b}}function jd(s,i,l,h,d){return function(){let p=new $n({index:i,font:s});return p.path=function(){let b=l(s,p,h,d);return b.unitsPerEm=s.unitsPerEm,b},p}}var $e={GlyphSet:sr,glyphLoader:Gd,ttfGlyphLoader:Hd,cffGlyphLoader:jd};function Ml(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(!Ml(s[l],i[l]))return!1;return!0}else return!1}var Ll=10;function rr(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=[],b=h>1?rt.getULong(s,i):rt.getCard16(s,i),x=h>1?4:2,A,E;if(b!==0){let C=rt.getByte(s,i+x);A=i+(b+1)*C+x;let R=i+x+1;for(let P=0;P<b+1;P+=1)d.push(rt.getOffset(s,R,C)),R+=C;E=A+d[b]}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 Vd(s,i,l){let h=[],d=l>1?rt.getULong(s,i):rt.getCard16(s,i),p=l>1?4:2,b,x;if(d!==0){let A=rt.getByte(s,i+p);b=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=b+h[d]}else x=i+p;return{offsets:h,startOffset:i,endOffset:x}}function $d(s,i,l,h,d,p){let b=p>1?rt.getULong(l,h):rt.getCard16(l,h),x=p>1?4:2,A=0;if(b!==0){let C=rt.getByte(l,h+x);A=h+(b+1)*C+x}let E=rt.getBytes(l,A+i[s],A+i[s+1]);return d&&(E=d(E)),E}function zd(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,b=d&15;if(p===15||(i+=h[p],b===15))break;i+=h[b]}return parseFloat(i)}function Wd(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 zd(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 Xd(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 Ni(s,i,l,h){i=i!==void 0?i:0;let d=new rt.Parser(s,i),p=[],b=[];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){ef(b);continue}p.push([A,b]),b=[]}else b.push(Wd(d,A,h))}return Xd(p)}function as(s,i){return i<=390?i=er[i]:s?i=s[i-391]:i=void 0,i}function Ui(s,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=s[b.op]!==void 0?s[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=as(l,d)),x[A]=d;h[b.name]=x}else d=s[b.op],d===void 0&&(d=b.value!==void 0?b.value:null),b.type==="SID"&&(d=as(l,d)),h[b.name]=d}return h}function Yd(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 Fl=[{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"}],Dl=[{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"}],_l=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Nl=[{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"}],Kd=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Zd(s,i,l,h){let d=Ni(s,i,s.byteLength,h);return Ui(d,h>1?Dl:Fl,l)}function Bi(s,i,l,h,d){let p=Ni(s,i,l,d);return Ui(p,d>1?Nl:_l,h)}function Qd(s,i,l){let h=Ni(s,i,void 0,l);return Ui(h,Kd)}function Jd(s,i,l){let h=[];for(let d=0;d<l.length;d++){let p=new DataView(new Uint8Array(l[d]).buffer),b=Qd(p,0,2),x=b.private[0],A=b.private[1];if(x!==0&&A!==0){let E=Bi(s,A+i,x,[],2);if(E.subrs){let C=A+E.subrs,R=ze(s,C+i,void 0,2);b._subrs=R.objects,b._subrsBias=rr(b._subrs)}b._privateDict=E}h.push(b)}return h}function Gi(s,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=Zd(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=Bi(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=rr(A._subrs)}A._privateDict=R}p.push(A)}return p}function qd(s,i,l,h,d){let p,b,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(as(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(as(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(as(h,p)||p),p+=1}else throw new Error("Unknown charset format "+E);return A}function tf(s,i){let l,h={},d=new rt.Parser(s,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 ef(s){let i=s.pop();for(;s.length>i;)s.pop()}function Ul(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 Hi(s,i,l,h,d){let p,b,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 Hi(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=Ul(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,pr,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(),b=N+C.shift(),x=p+C.shift(),A=b+C.shift(),M=x+C.shift(),N=A+C.shift(),E.curveTo(p,b,x,A,M,N);break;case 10:if(kn=C.pop()+vt,Ue=z[kn],Ue){if(Gt>=Ll){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(),b=N+C.shift(),x=p+C.shift(),A=b+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,b,x,A,fe,Ie),E.curveTo(ae,Ce,pe,ge,M,N);break;case 34:p=M+C.shift(),b=N,x=p+C.shift(),A=b+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,b,x,A,fe,Ie),E.curveTo(ae,Ce,pe,ge,M,N);break;case 36:p=M+C.shift(),b=N+C.shift(),x=p+C.shift(),A=b+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,b,x,A,fe,Ie),E.curveTo(ae,Ce,pe,ge,M,N);break;case 37:p=M+C.shift(),b=N+C.shift(),x=p+C.shift(),A=b+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,b,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=Fi[C.pop()],Kn=Fi[C.pop()],gr=C.pop(),mr=C.pop();if(In&&Kn){i.isComposite=!0,i.components=[];let qc=s.cffEncoding.charset.indexOf(In),tu=s.cffEncoding.charset.indexOf(Kn);i.components.push({glyphIndex:tu,dx:0,dy:0}),i.components.push({glyphIndex:qc,dx:mr,dy:gr}),E.extend(s.glyphs.get(tu).path);let By=s.glyphs.get(qc),io=JSON.parse(JSON.stringify(By.path.commands));for(let oo=0;oo<io.length;oo+=1){let Xe=io[oo];Xe.type!=="Z"&&(Xe.x+=mr,Xe.y+=gr),(Xe.type==="Q"||Xe.type==="C")&&(Xe.x1+=mr,Xe.y1+=gr),Xe.type==="C"&&(Xe.x2+=mr,Xe.y2+=gr)}E.extend(io)}}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(),ye=Bt?Bt.length:Nt.itemVariationSubtables[It].regionIndexes.length,Pe=Vt*ye,Be=C.length-Pe,en=Be-Vt;if(Bt)for(let In=0;In<Vt;In++){var Jc=C[en+In];for(let Kn=0;Kn<ye;Kn++)Jc+=Bt[Kn]*C[Be++];C[en+In]=Jc}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(),b=N+C.shift(),x=p+C.shift(),A=b+C.shift(),M=x+C.shift(),N=A+C.shift(),E.curveTo(p,b,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(),b=N+C.shift(),x=p+C.shift(),A=b+C.shift(),M=x+C.shift(),N=A+C.shift(),E.curveTo(p,b,x,A,M,N);break;case 26:for(C.length&1&&(M+=C.shift());C.length>0;)p=M,b=N+C.shift(),x=p+C.shift(),A=b+C.shift(),M=x,N=A+C.shift(),E.curveTo(p,b,x,A,M,N);break;case 27:for(C.length&1&&(N+=C.shift());C.length>0;)p=M+C.shift(),b=N,x=p+C.shift(),A=b+C.shift(),M=x+C.shift(),N=A,E.curveTo(p,b,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>=Ll){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Gt++,xt(Ue),Gt--}break;case 30:for(;C.length>0&&(p=M,b=N+C.shift(),x=p+C.shift(),A=b+C.shift(),M=x+C.shift(),N=A+(C.length===1?C.shift():0),E.curveTo(p,b,x,A,M,N),C.length!==0);)p=M+C.shift(),b=N,x=p+C.shift(),A=b+C.shift(),N=A+C.shift(),M=x+(C.length===1?C.shift():0),E.curveTo(p,b,x,A,M,N);break;case 31:for(;C.length>0&&(p=M+C.shift(),b=N,x=p+C.shift(),A=b+C.shift(),N=A+C.shift(),M=x+(C.length===1?C.shift():0),E.curveTo(p,b,x,A,M,N),C.length!==0);)p=M,b=N+C.shift(),x=p+C.shift(),A=b+C.shift(),M=x+C.shift(),N=A+(C.length===1?C.shift():0),E.curveTo(p,b,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],pr=ct[Zt+3],Zt+=4,C.push((ft<<24|oe<<16|fn<<8|pr)/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 Bl(s,i,l,h,d){let p=[],b,x=new rt.Parser(s,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 R;for(let P=0;P<E;P++){if(b=A===4?x.parseUShort():x.parseCard8(),R=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(R>l)throw new Error(`CFF Table CID Font FDSelect format ${d} range has bad GID ${R}`);for(;C<R;C++)p.push(b);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 nf(s,i,l,h){let d,p=Yd(s,i);p.formatMajor===2?d=l.tables.cff2={}:d=l.tables.cff={};let b=p.formatMajor>1?null:ze(s,p.endOffset,rt.bytesToString),x=p.formatMajor>1?null:ze(s,b.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=rr(l.gsubrs);let C;if(p.formatMajor>1){let P=i+p.size,L=rt.getBytes(s,P,P+p.topDictLength);C=Gi(s,0,[L],void 0,p.formatMajor)[0]}else{let P=Gi(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=Jd(s,i,M.objects);C._fdArray=N,L&&(C._fdSelect=Bl(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=Gi(s,i,M.objects,A.objects,p.formatMajor);C._fdArray=N,L+=i,C._fdSelect=Bl(s,L,l.numGlyphs,N.length,p.formatMajor)}if(p.formatMajor<2){let P=i+C.private[1],L=Bi(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=rr(l.subrs)}else l.subrs=[],l.subrsBias=0}let R;if(h.lowMemory?(R=Vd(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=kd:C.charset===1?P=Id:C.charset===2?P=Pd:P=qd(s,i+C.charset,l.nGlyphs,A.objects,l.isCIDFont),C.encoding===0?L=Fi:C.encoding===1?L=Rd:L=tf(s,i+C.encoding),l.cffEncoding=new Il(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,Hi,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,Hi,L,p.formatMajor))}if(C.vstore){let P=new rt.Parser(s,i+C.vstore);C._vstore=P.parseVariationStore()}}function Gl(s,i){let l,h=er.indexOf(s);return h>=0&&(l=h),h=i.indexOf(s),h>=0?l=h+er.length:(l=er.length+i.length,i.push(s)),l}function sf(){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 rf(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 Hl(s,i,l){let h={};for(let d=0;d<s.length;d+=1){let p=s[d],b=i[p.name];b!==void 0&&!Ml(b,p.value)&&(p.type==="SID"&&(b=Gl(b,l)),h[p.op]={name:p.name,type:p.type,value:b})}return h}function jl(s,i,l){let h=new J.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=Hl(l>1?Dl:Fl,s,i),h}function Vl(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 of(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 af(){return new J.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function lf(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=Gl(d,i);l.fields.push({name:"glyph_"+h,type:"SID",value:p})}return l}function cf(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 b=0;b<h.commands.length;b+=1){let x,A,E=h.commands[b];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 uf(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=cf(d,i);l.charStrings.push({name:d.name,type:"CHARSTRING",value:p})}return l}function hf(s,i,l){let h=new J.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=Hl(l>1?Nl:_l,s,i),h}function df(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]},b=i&&i.topDict||{};b.paintType&&(p.paintType=b.paintType,p.strokeWidth=b.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=sf(),h.nameIndex=rf([i.postScriptName]);let R=jl(p,C);h.topDictIndex=Vl(R),h.globalSubrIndex=af(),h.charsets=lf(A,C),h.charStringsIndex=uf(s,1),h.privateDict=hf(x,C),h.stringIndex=of(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=jl(p,C),h.topDictIndex=Vl(R),h}var ji={parse:nf,make:df};function ff(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 pf(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 $l={parse:ff,make:pf};function gf(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 mf(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 zl={parse:gf,make:mf};function yf(s,i,l,h,d){let p,b,x=new rt.Parser(s,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 bf(s,i,l,h,d){s._hmtxTableData={};let p,b,x=new rt.Parser(i,l);for(let A=0;A<d;A+=1)A<h&&(p=x.parseUShort(),b=x.parseShort()),s._hmtxTableData[A]={advanceWidth:p,leftSideBearing:b}}function vf(s,i,l,h,d,p,b){b.lowMemory?bf(s,i,l,h,d):yf(i,l,h,d,p)}function xf(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 Wl={parse:vf,make:xf};function Sf(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 Af(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 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(s.getInt8(C));p.push(x)}return p}var Xl={make:Sf,parse:Af};function Tf(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 Cf(s){return new J.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:s}])}var Yl={parse:Tf,make:Cf},Vi=[{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 wf(s){for(let i=0;i<Vi.length;i+=1){let l=Vi[i];if(s>=l.begin&&s<l.end)return i}return-1}function Ef(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 kf(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 $i={parse:Ef,make:kf,unicodeRanges:Vi,getUnicodeRange:wf};function If(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 Pf(s){let{italicAngle:i=Math.round((s.italicAngle||0)*65536),underlinePosition:l=0,underlineThickness:h=0,isFixedPitch:d=0,minMemType42:p=0,maxMemType42:b=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:b},{name:"minMemType1",type:"ULONG",value:x},{name:"maxMemType1",type:"ULONG",value:A}])}var Kl={parse:If,make:Pf},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 Rf(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 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 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 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 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 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 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 Of(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 Zl={parse:Rf,make:Of};function Mf(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 b=0;b<d;b++){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 Lf(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 b=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+b}),d.fields.push({name:"length "+p,type:"ULONG",value:s[p].length})}return d.fields.push({name:"stringPool",type:"CHARARRAY",value:l}),d}var Ql={parse:Mf,make:Lf};function Ff(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(),b=l.parseOffset32(),x=l.parseUShort();l.relativeOffset=p;let A=l.parseRecordList(d,{glyphID:B.uShort,firstLayerIndex:B.uShort,numLayers:B.uShort});l.relativeOffset=b;let E=l.parseRecordList(x,{glyphID:B.uShort,paletteIndex:B.uShort});return{version:h,baseGlyphRecords:A,layerRecords:E}}function Df({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,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 Jl={parse:Ff,make:Df};function _f(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 Nf(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=tr(l,p),h}function Uf(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 b=l[p].tag;d.push({name:"axis_"+s+" "+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 Bf(s,i,l,h,d){let p={},b=new rt.Parser(s,i),x=b.parseUShort();p.subfamilyNameID=x,p.name=tr(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?tr(h,A,[6]):"",p}function Gf(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(_f(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(Uf(d,s.instances[d],s.axes,h));return l}function Hf(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 b=h.parseUShort(),x=h.parseUShort(),A=h.parseUShort(),E=h.parseUShort(),C=[];for(let L=0;L<b;L++)C.push(Nf(s,i+p+L*x,l));let R=[],P=i+p+b*x;for(let L=0;L<A;L++)R.push(Bf(s,P+L*E,C,l,E));return{axes:C,instances:R}}var ql={make:Gf,parse:Hf},jf={tag:B.tag,nameID:B.uShort,ordering:B.uShort},ls=new Array(5);ls[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},ls[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},ls[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},ls[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 Vf(){let s=this.parseUShort(),i=ls[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 b=[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(jf));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(Vf.apply(h));return{version:b,axes:L,values:N,elidedFallbackNameID:P}}var cs=new Array(5);cs[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}]},cs[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}]},cs[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}]},cs[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 zf(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 Wf(s,i){let l=i.format,h=cs[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 Xf(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 b=zf(p,s.axes[p]);i.offsetToAxisValueOffsets+=b.sizeOf(),i.fields=i.fields.concat(b.fields)}let l=[],h=[],d=s.values.length*2;for(let p=0;p<s.values.length;p++){let b=Wf(p,s.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 tc={make:Xf,parse:$f};function Yf(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 Kf(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=Yf(`${s}_${d}`,i.axisValueMaps[d]);h=h.concat(p.fields)}return l.fields=l.fields.concat(h),l}function Zf(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=Kf(h,s.axisSegmentMaps[h]);l.fields=l.fields.concat(d.fields)}return l}function Qf(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 b=h.parseUShort();U.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 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 ec={make:Zf,parse:Qf};function Jf(s,i,l,h){let d=new rt.Parser(s,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 qf(){console.warn("Writing of cvar tables is not yet supported.")}var nc={make:qf,parse:Jf};function tp(s,i,l,h){let d=new rt.Parser(s,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 ep(){console.warn("Writing of gvar tables is not yet supported.")}var sc={make:ep,parse:tp};function np(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 sp(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 rc={parse:np,make:sp};function rp(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 b=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=b+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 ip(s){let i=Array.from(s.keys()).sort(),l=[],h=[],d=new Map,p=0,b={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===b.endGlyphID&&z===b.svgDocOffset?b.endGlyphID=M:(b={startGlyphID:M,endGlyphID:M,svgDocOffset:z,svgDocLength:N.byteLength},l.push(b))}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 ic={make:ip,parse:rp};function oc(s){return Math.log(s)/Math.log(2)|0}function zi(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 ac(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 lc(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,oc(i.numTables));i.searchRange=16*l,i.entrySelector=oc(l),i.rangeShift=i.numTables*16-i.searchRange;let h=[],d=[],p=i.sizeOf()+ac().sizeOf()*i.numTables;for(;p%4!==0;)p+=1,d.push({name:"padding",type:"BYTE",value:0});for(let b=0;b<s.length;b+=1){let x=s[b];U.argument(x.tableName.length===4,"Table name"+x.tableName+" is invalid.");let A=x.sizeOf(),E=ac(x.tableName,zi(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(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 cc(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 op(s){let i=0;for(let l=0;l<s.length;l+=1)i+=s[l];return i/s.length}function ap(s){let i=[],l=[],h=[],d=[],p=[],b=[],x=[],A,E=0,C=0,R=0,P=0,L=0;for(let Vt=0;Vt<s.glyphs.length;Vt+=1){let ye=s.glyphs.get(Vt),Pe=ye.unicode|0;if(isNaN(ye.advanceWidth))throw new Error("Glyph "+ye.name+" ("+Vt+"): advanceWidth is not a number.");(A>Pe||A===void 0)&&Pe>0&&(A=Pe),E<Pe&&(E=Pe);let Be=$i.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(ye.name===".notdef")continue;let en=ye.getMetrics();i.push(en.xMin),l.push(en.yMin),h.push(en.xMax),d.push(en.yMax),b.push(en.leftSideBearing),x.push(en.rightSideBearing),p.push(ye.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:op(p),minLeftSideBearing:Math.min.apply(null,b),maxLeftSideBearing:Math.max.apply(null,b),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=$l.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=zl.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=Yl.make(s.glyphs.length),At=$i.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:cc(s,"xyvw",{yMax:Math.round(M.ascender/2)}).yMax,sCapHeight:cc(s,"HIKLEFJMNTZBDPRAGOQSUVWXY",M).yMax,usDefaultChar:s.hasChar(" ")?32:0,usBreakChar:s.hasChar(" ")?32:0},s.tables.os2)),It=Wl.make(s.glyphs),Nt=wl.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 ye=s.getEnglishName("manufacturer")||"";Pt[Vt].uniqueID={en:`${ye}: ${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=Cl.make(Pt,ct),oe=ct.length>0?Xl.make(ct):void 0,fn=Kl.make(s),pr=ji.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?Ql.make(s.metas):void 0,Ue=[z,vt,pt,At,ft,Nt,fn,pr,It];oe&&Ue.push(oe);let fe={gsub:Zl,cpal:Ol,colr:Jl,stat:tc,avar:ec,cvar:nc,fvar:ql,gvar:sc,gasp:rc,svg:ic},Ie={avar:[s.tables.fvar],fvar:[s.names]};for(let Vt in fe){let ye=s.tables[Vt];if(ye){let Pe=fe[Vt].make.call(s,ye,...Ie[Vt]||[]);Pe&&Ue.push(Pe)}}kn&&Ue.push(kn);let ae=lc(Ue),Ce=ae.encode(),pe=zi(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 lp={make:lc,fontToTable:ap,computeCheckSum:zi};function Wi(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 uc(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 hc(s,i){let l,h=0,d=s.length-1;for(;h<=d;){let p=h+d>>>1;l=s[p];let b=l.start;if(b===i)return l;b<i?h=p+1:d=p-1}if(h>0)return l=s[h-1],i>l.end?0:l}function dc(s,i){this.font=s,this.tableName=i}dc.prototype={searchTag:Wi,binSearch:uc,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=Wi(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=Wi(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,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 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),b.push(A),p.feature}}},getLookupTables:function(s,i,l,h,d){let p=this.getFeatureTable(s,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(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=hc(s.ranges,i);return l?l.classId:0}}},getCoverageIndex:function(s,i){switch(s.format){case 1:{let l=uc(s.glyphs,i);return l>=0?l:-1}case 2:{let l=hc(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,b=d.end;for(let x=p;x<=b;x++)i.push(x)}return i}}};var ir=dc;function us(s){ir.call(this,s,"gpos")}us.prototype=ir.prototype,us.prototype.init=function(){let s=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(s)},us.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 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},us.prototype.getKerningTables=function(s,i){if(this.font.tables.gpos)return this.getLookupTables(s,i,"kern",2)};var cp=us;function up(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 hp(s,i,l){let h=0,d=s.length-1,p=null;for(;h<=d;){let b=Math.floor((h+d)/2),x=s[b],A=x[i];if(A<l)h=b+1;else if(A>l)d=b-1;else{p=x;break}}return p}function dp(s,i,l){let h=0,d=s.length-1;for(;h<=d;){let p=Math.floor((h+d)/2),b=s[p];if(b[i]<l)h=p+1;else if(b[i]>l)d=p-1;else return p}return-1}function fp(s,i,l){let h=0,d=s.length,p=(b,x)=>b[i]-x[i];for(;h<d;){let b=h+d>>>1;p(s[b],l)<0?h=b+1:d=b}return s.splice(h,0,l),h}function fc(s){return s[0]===31&&s[1]===139&&s[2]===8}function pp(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 pc(s){return{x:s.x,y:s.y,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour}}function gp(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){ir.call(this,s,"gsub")}function Xi(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=ir.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 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 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 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 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 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 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 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 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=Xi(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 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},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=Xi(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 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},Se.prototype.addAlternate=function(s,i,l,h){let d=this.getLookupTables(l,h,s,3,!0)[0],p=Xi(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 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},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 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 R=0;R<C.length;R++)if(up(C[R].components,x))return;C.push(A)}else E=-1-E,p.coverage.glyphs.splice(E,0,b),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 mp=Se,gc=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 b=d;b<d+l.numPaletteEntries;b++)p.push(Vn(l.colorRecords[b],s||"hexa"));i.push(p)}return i}toCPALcolor(s){return Array.isArray(s)?s.map(i=>nr(i,"raw")):nr(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 _i(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(),b=p.numPaletteEntries;Array.isArray(i)||(i=[i]),i.length+s>b&&(this.extend(i.length+s-b),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 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(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)}},yp=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=hp(h.baseGlyphRecords,"glyphID",s);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(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 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(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=dp(h.baseGlyphRecords,"glyphID",s);if(d===-1){let C={glyphID:s,firstLayerIndex:h.layerRecords.length,numLayers:0};d=fp(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(R=>({glyphID:R.glyphID,paletteIndex:R.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 R=h.baseGlyphRecords[C];C===d||R.firstLayerIndex<b.firstLayerIndex||(h.baseGlyphRecords[C].firstLayerIndex+=E)}}},bp=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=vp(l),this.cache.set(l,h));let d=h.images.get(s);return d===void 0&&(d=xp(this.font,h.template,s),d.promise.then(p=>{if(d.image=p,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(s)}catch(b){console.error("font.onGlyphUpdated",s,b)}}),h.images.set(s,d)),d}};function vp(s){return{template:Sp(s).then(Cp),images:new Map}}function xp(s,i,l){return{promise:i.then(h=>{let d;typeof h=="string"?d=h:(h[4]=l,d=h.join(""));let p=wp(d,s.unitsPerEm);return p.image.decode().then(()=>p)}),image:void 0}}var Sp=typeof DecompressionStream=="function"?Tp:Ap;function Ap(s){try{return Promise.resolve(new TextDecoder().decode(fc(s)?pp(s):s))}catch(i){return Promise.reject(i)}}function Tp(s){if(fc(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 Cp(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 wp(s,i){let h=new DOMParser().parseFromString(s,"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 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 Yi=new WeakMap;function mc(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 yc(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 b=s.endPointIndices=[];for(let A=0;A<s._numberOfContours;A+=1)b.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=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(U.argument(d.length===x,"Bad flags."),b.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=b.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=mc(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=mc(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 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()),s.components.push(x),b=!!(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 or(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 Ep(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 Ki(s){let i=new it;if(!s)return i;let l=Ep(s);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 bc(s,i){if(i.isComposite){Yi.has(s)||Yi.set(s,new Set);let l=Yi.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 b;if(d.matchedPoints===void 0)b=or(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=or([A],E)[0],E.dx=x.x-A.x,E.dy=x.y-A.y,b=or(p.points,E)}i.points=i.points.concat(b)}}}finally{l.delete(i.index)}}return Ki(i.points)}function kp(s,i,l,h){let d=new $e.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,$e.ttfGlyphLoader(h,p,yc,s,i+b,bc)):d.push(p,$e.glyphLoader(h,p))}return d}function Ip(s,i,l,h){let d=new $e.GlyphSet(h);return h._push=function(p){let b=l[p],x=l[p+1];b!==x?d.push(p,$e.ttfGlyphLoader(h,p,yc,s,i+b,bc)):d.push(p,$e.glyphLoader(h,p))},d}function Pp(s,i,l,h,d){return d.lowMemory?Ip(s,i,l,h):kp(s,i,l,h)}var vc={getPath:Ki,parse:Pp},Rp=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 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(s,i,l){if(s.length===0)return;let h=0;for(;h<s.length;){let d=h,p=h,b=s[p];for(;!b.lastPointOfContour;)b=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 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],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,b=d[l].y-h[l].y;if(!(p===0&&b===0))for(let x=s;x<=i;x++)x!==l&&(d[x].x+=p,d[x].y+=b)}transformComponents(s,i,l,h,d,p){let b=0;for(let x=0;x<s.components.length;x++){let A=s.components[x],E=this.font.glyphs.get(A.glyphIndex),C=gp(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=or(this.getTransform(E,l).points,C);i.splice(b,P.length,...P),b+=E.points.length}}applyTupleVariationStore(s,i,l,h="gvar",d={}){l||(l=this.font.variation.get());let p=this.getNormalizedCoords(l),{headers:b,sharedPoints:x}=s,A=this.fvar().axes.length,E;h==="gvar"?E=i.map(pc):h==="cvar"&&(E=[...i]);for(let C=0;C<b.length;C++){let R=b[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(pc):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 b=s.points,x=this.applyTupleVariationStore(p,b,i,"gvar",{glyph:s});d=new $n(Object.assign({},s,{points:x,path:Ki(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,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=s;A>=x&&(A=x-1),{outerIndex:d,innerIndex:p}=b[l].map[A]}else d=0,p=s;return this.getDelta(b.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],b=this.getBlendVector(s,i,h),x=0;for(let A=0;A<d.regionIndexes.length;A++)x+=p[A]*b[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 b=0;b<h.regionIndexes.length;b++){let x=1,A=h.regionIndexes[b],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[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}},Op=class{constructor(s){this.font=s,this.process=new Rp(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}},xc=1e6,ar=64,lr=1e4,Sc,wn,Ac,Zi;function Tc(s){this.font=s,this.getCommands=function(i){return vc.getPath(i).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Mp(s){return s}function Cc(s){return Math.sign(s)*Math.round(Math.abs(s))}function Lp(s){return Math.sign(s)*Math.round(Math.abs(s*2))/2}function Fp(s){return Math.sign(s)*(Math.round(Math.abs(s)+.5)-.5)}function Dp(s){return Math.sign(s)*Math.ceil(Math.abs(s))}function _p(s){return Math.sign(s)*Math.floor(Math.abs(s))}var wc=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,b,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,b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){s.x=s.xo+(A+E)/2;return}s.x=s.xo+(A*x+E*b)/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),b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){We.setRelative(s,s,(A+E)/2,h,!0);return}We.setRelative(s,s,(A*x+E*b)/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,b=d?i.yo:i.y,x=p+l*h.x,A=b+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,b,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,b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){s.y=s.yo+(A+E)/2;return}s.y=s.yo+(A*x+E*b)/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),b=Math.abs(d),x=Math.abs(p),C=b+x,C===0){qe.setRelative(s,s,(A+E)/2,h,!0);return}qe.setRelative(s,s,(A*x+E*b)/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,b=d?i.yo:i.y,x=p+l*h.x,A=b+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 hs(s,i){this.x=s,this.y=i,this.axis=void 0,this.slope=i/s,this.normalSlope=-s/i,Object.freeze(this)}hs.prototype.distance=function(s,i,l,h){return this.x*We.distance(s,i,l,h)+this.y*qe.distance(s,i,l,h)},hs.prototype.interpolate=function(s,i,l,h){let d,p,b,x,A,E,C;if(b=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(b),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)},hs.prototype.setRelative=function(s,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,R=s.x,P=s.y;s.x=(C*R-E*x+A-P)/(C-E),s.y=C*(s.x-R)+P},hs.prototype.touch=function(s){s.xTouched=!0,s.yTouched=!0};function ds(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 hs(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 fs=Object.freeze(new tn(0,0)),Np={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=Cc}}Tc.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=Np,d=this._fpgmState=new on("fpgm",l.tables.fpgm),d.funcs=[],d.font=l,d.instructionCount=0,d.callDepth=0;try{wn(d)}catch(b){console.log("Hinting error in FPGM:"+b),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 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{wn(h)}catch(b){this._errorState<2&&console.log("Hinting error in PREP:"+b),this._errorState=2}}if(!(this._errorState>1))try{return Ac(s,h)}catch(d){this._errorState<1&&(console.log("Hinting error:"+d),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},Ac=function(s,i){let l=i.ppem/i.font.unitsPerEm,h=l,d=s.components,p,b,x;if(on.prototype=i,!d)x=new on("glyf",s.instructions),x.instructionCount=0,x.callDepth=0,Zi(s,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],R=A.glyphs.get(C.glyphIndex);x=new on("glyf",R.instructions),x.instructionCount=0,x.callDepth=0,Zi(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=b.length;b.push.apply(b,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=b,x.contours=p,b.push(new tn(0,0),new tn(Math.round(s.advanceWidth*l),0)),wn(x),b.length-=2)}return b},Zi=function(s,i,l,h){let d=s.points||[],p=d.length,b=i.gZone=i.z0=i.z1=i.z2=[],x=i.contours=[],A;for(let R=0;R<p;R++)A=d[R],b[R]=new tn(A.x*l,A.y*h,A.lastPointOfContour,A.onCurve);let E,C;for(let R=0;R<p;R++)A=b[R],E||(E=A,x.push(R)),A.lastPointOfContour?(A.nextPointOnContour=E,E.prevPointOnContour=A,E=void 0):(C=b[R+1],A.nextPointOnContour=C,C.prevPointOnContour=A);i.inhibitGridFit||(b.push(new tn(0,0),new tn(Math.round(s.advanceWidth*l),0)),wn(i),b.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>xc)throw new Error("Hinting instructions exceeded maximum of "+xc);if(h=Sc[i[s.ip]],!h)throw new Error("unknown instruction: 0x"+Number(i[s.ip]).toString(16));h(s)}};function cr(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 Ec(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 kc(s,i){i.fv=i.pv=i.dpv=s}function Ic(s,i){i.pv=i.dpv=s}function Pc(s,i){i.fv=s}function Rc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],b=i.z1[d],x,A;s?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),i.pv=i.dpv=ds(x,A)}function Oc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],b=i.z1[d],x,A;s?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),i.fv=ds(x,A)}function Up(s){let i=s.stack,l=i.pop(),h=i.pop();s.pv=s.dpv=ds(h,l)}function Bp(s){let i=s.stack,l=i.pop(),h=i.pop();s.fv=ds(h,l)}function Gp(s){let i=s.stack,l=s.pv;i.push(l.x*16384),i.push(l.y*16384)}function Hp(s){let i=s.stack,l=s.fv;i.push(l.x*16384),i.push(l.y*16384)}function jp(s){s.fv=s.pv}function Vp(s){let i=s.stack,l=i.pop(),h=i.pop(),d=i.pop(),p=i.pop(),b=i.pop(),x=s.z0,A=s.z1,E=x[l],C=x[h],R=A[d],P=A[p],L=s.z2[b],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 zp(s){s.rp1=s.stack.pop()}function Wp(s){s.rp2=s.stack.pop()}function Xp(s){let i=s.stack.pop();switch(s.zp0=i,i){case 0:s.tZone||cr(s),s.z0=s.tZone;break;case 1:s.z0=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function Yp(s){let i=s.stack.pop();switch(s.zp1=i,i){case 0:s.tZone||cr(s),s.z1=s.tZone;break;case 1:s.z1=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function Kp(s){let i=s.stack.pop();switch(s.zp2=i,i){case 0:s.tZone||cr(s),s.z2=s.tZone;break;case 1:s.z2=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function Zp(s){let i=s.stack.pop();switch(s.zp0=s.zp1=s.zp2=i,i){case 0:s.tZone||cr(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 Qp(s){s.loop=s.stack.pop(),s.loop>lr&&(s.loop=lr)}function Jp(s){s.round=Cc}function qp(s){s.round=Fp}function tg(s){let i=s.stack.pop();s.minDis=i/64}function eg(s){Ec(s,!1)}function ng(s){let i=s.stack.pop();s.ip+=i-1}function sg(s){let i=s.stack.pop();s.cvCutIn=i/64}function rg(s){let i=s.stack;i.push(i[i.length-1])}function Qi(s){s.stack.pop()}function ig(s){s.stack.length=0}function og(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l),i.push(h)}function ag(s){let i=s.stack;i.push(i.length)}function lg(s){let i=s.stack,l=i.pop(),h=i.pop();if(h>lr&&(h=lr),++s.callDepth>ar)throw new Error("Hinting call depth exceeded maximum of "+ar);let d=s.ip,p=s.prog;s.prog=s.funcs[l];for(let b=0;b<h;b++)wn(s);s.ip=d,s.prog=p,s.callDepth--}function cg(s){let i=s.stack.pop();if(++s.callDepth>ar)throw new Error("Hinting call depth exceeded maximum of "+ar);let l=s.ip,h=s.prog;s.prog=s.funcs[i],wn(s),s.ip=l,s.prog=h,s.callDepth--}function ug(s){let i=s.stack,l=i.pop();i.push(i[i.length-l])}function hg(s){let i=s.stack,l=i.pop();i.push(i.splice(i.length-l,1)[0])}function dg(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 Mc(s,i){let l=i.stack.pop(),h=i.z0[l],d=i.fv,p=i.pv,b=p.distance(h,fs);s&&(b=i.round(b)),d.setRelative(h,fs,b,p),d.touch(h),i.rp0=i.rp1=l}function Lc(s,i){let l=i.z2,h=l.length-2,d,p,b;for(let x=0;x<h;x++)d=l[x],!s.touched(d)&&(p=d.prevTouched(s),p!==d&&(b=d.nextTouched(s),p===b&&s.setRelative(d,d,s.distance(p,p,!1,!0),s,!0),s.interpolate(d,p,b,s)))}function Fc(s,i){let l=i.stack,h=s?i.rp1:i.rp2,d=(s?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],R=b.distance(d,d,!1,!0);p.setRelative(C,C,R,b),p.touch(C)}i.loop=1}function Dc(s,i){let l=i.stack,h=s?i.rp1:i.rp2,d=(s?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 _c(s,i){let l=i.stack,h=s?i.rp1:i.rp2,d=(s?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),R=A.length-2;for(let P=0;P<R;P++)E=A[P],p.setRelative(E,E,C,b)}function fg(s){let i=s.stack,l=s.loop,h=s.fv,d=i.pop()/64,p=s.z2;for(;l--;){let b=i.pop(),x=p[b];h.setRelative(x,x,d),h.touch(x)}s.loop=1}function pg(s){let i=s.stack,l=s.rp1,h=s.rp2,d=s.loop,p=s.z0[l],b=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,b,A),x.touch(R)}s.loop=1}function Nc(s,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,s&&(i.rp0=d)}function gg(s){let i=s.stack,l=s.rp0,h=s.z0[l],d=s.loop,p=s.fv,b=s.pv,x=s.z1;for(;d--;){let A=i.pop(),E=x[A];p.setRelative(E,h,0,b),p.touch(E)}s.loop=1}function mg(s){s.round=Lp}function Uc(s,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,fs);s&&(Math.abs(E-A)<i.cvCutIn&&(E=A),E=i.round(E)),b.setRelative(p,fs,E,x),i.zp0===0&&(p.xo=p.x,p.yo=p.y),b.touch(p),i.rp0=i.rp1=d}function yg(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 bg(s){let i=s.ip,l=s.prog,h=s.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)}s.ip=i}function vg(s){let i=s.stack,l=s.store;l||(l=s.store=[]);let h=i.pop(),d=i.pop();l[d]=h}function xg(s){let i=s.stack,l=s.store,h=i.pop(),d=l&&l[h]||0;i.push(d)}function Sg(s){let i=s.stack,l=i.pop(),h=i.pop();s.cvt[h]=l/64}function Ag(s){let i=s.stack,l=i.pop();i.push(s.cvt[l]*64)}function Bc(s,i){let l=i.stack,h=l.pop(),d=i.z2[h];l.push(i.dpv.distance(d,fs,s,!1)*64)}function Gc(s,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,s,s);i.stack.push(Math.round(x*64))}function Tg(s){s.stack.push(s.ppem)}function Cg(s){s.autoFlip=!0}function wg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h<l?1:0)}function Eg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h<=l?1:0)}function kg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h>l?1:0)}function Ig(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h>=l?1:0)}function Pg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l===h?1:0)}function Rg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l!==h?1:0)}function Og(s){let i=s.stack,l=i.pop();i.push(Math.trunc(l)&1?1:0)}function Mg(s){let i=s.stack,l=i.pop();i.push(Math.trunc(l)&1?0:1)}function Lg(s){let i=s.stack.pop(),l;i||Ec(s,!0)}function Fg(s){}function Dg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l&&h?1:0)}function _g(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(l||h?1:0)}function Ng(s){let i=s.stack,l=i.pop();i.push(l?0:1)}function Ji(s,i){let l=i.stack,h=l.pop(),d=i.fv,p=i.pv,b=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)!==b)continue;let M=(P&15)-8;M>=0&&M++;let N=E[R];d.setRelative(N,N,M*A,p)}}function Ug(s){let l=s.stack.pop();s.deltaBase=l}function Bg(s){let l=s.stack.pop();s.deltaShift=Math.pow(.5,l)}function Gg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h+l)}function Hg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h-l)}function jg(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(h*64/l)}function Vg(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 zg(s){let i=s.stack,l=i.pop();i.push(-l)}function Wg(s){let i=s.stack,l=i.pop();i.push(Math.floor(l/64)*64)}function Xg(s){let i=s.stack,l=i.pop();i.push(Math.ceil(l/64)*64)}function ur(s,i){let l=i.stack,h=l.pop();l.push(i.round(h/64)*64)}function Yg(s){let i=s.stack,l=i.pop(),h=i.pop();s.cvt[h]=l*s.ppem/s.font.unitsPerEm}function qi(s,i){let l=i.stack,h=l.pop(),d=i.ppem,p=i.deltaBase+(s-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 R=(E&15)-8;R>=0&&R++;let P=R*b;i.cvt[A]+=P}}function Kg(s){let i=s.stack.pop();s.round=wc;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 Zg(s){let i=s.stack.pop();s.round=wc;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 Qg(s){s.round=Mp}function Jg(s){s.round=Dp}function qg(s){s.round=_p}function tm(s){let i=s.stack.pop()}function Hc(s,i){let l=i.stack,h=l.pop(),d=l.pop(),p=i.z2[h],b=i.z1[d],x,A;s?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),i.dpv=ds(x,A)}function em(s){let i=s.stack,l=i.pop(),h=0;l&1&&(h=35),l&32&&(h|=4096),i.push(h)}function nm(s){let i=s.stack,l=i.pop(),h=i.pop(),d=i.pop();i.push(h),i.push(l),i.push(d)}function sm(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(Math.max(h,l))}function rm(s){let i=s.stack,l=i.pop(),h=i.pop();i.push(Math.min(h,l))}function im(s){let i=s.stack.pop()}function om(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 b=h[++l]<<8|h[++l];b&32768&&(b=-((b^65535)+1)),d.push(b)}i.ip=l}function mt(s,i,l,h,d,p){let b=p.stack,x=s&&b.pop(),A=b.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)}Sc=[kc.bind(void 0,qe),kc.bind(void 0,We),Ic.bind(void 0,qe),Ic.bind(void 0,We),Pc.bind(void 0,qe),Pc.bind(void 0,We),Rc.bind(void 0,0),Rc.bind(void 0,1),Oc.bind(void 0,0),Oc.bind(void 0,1),Up,Bp,Gp,Hp,jp,Vp,$p,zp,Wp,Xp,Yp,Kp,Zp,Qp,Jp,qp,tg,eg,ng,sg,void 0,void 0,rg,Qi,ig,og,ag,ug,hg,void 0,void 0,void 0,lg,cg,dg,void 0,Mc.bind(void 0,0),Mc.bind(void 0,1),Lc.bind(void 0,qe),Lc.bind(void 0,We),Fc.bind(void 0,0),Fc.bind(void 0,1),Dc.bind(void 0,0),Dc.bind(void 0,1),_c.bind(void 0,0),_c.bind(void 0,1),fg,pg,Nc.bind(void 0,0),Nc.bind(void 0,1),gg,mg,Uc.bind(void 0,0),Uc.bind(void 0,1),yg,bg,vg,xg,Sg,Ag,Bc.bind(void 0,0),Bc.bind(void 0,1),void 0,Gc.bind(void 0,0),Gc.bind(void 0,1),Tg,void 0,Cg,void 0,void 0,wg,Eg,kg,Ig,Pg,Rg,Og,Mg,Lg,Fg,Dg,_g,Ng,Ji.bind(void 0,1),Ug,Bg,Gg,Hg,jg,Vg,$g,zg,Wg,Xg,ur.bind(void 0,0),ur.bind(void 0,1),ur.bind(void 0,2),ur.bind(void 0,3),void 0,void 0,void 0,void 0,Yg,Ji.bind(void 0,2),Ji.bind(void 0,3),qi.bind(void 0,1),qi.bind(void 0,2),qi.bind(void 0,3),Kg,Zg,void 0,void 0,Qg,void 0,Jg,qg,Qi,Qi,void 0,void 0,void 0,void 0,void 0,tm,Hc.bind(void 0,0),Hc.bind(void 0,1),em,void 0,nm,sm,rm,im,om,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 am=Tc;function Xn(s){this.char=s,this.state={},this.activeState=null}function to(s,i,l){this.contextName=l,this.startIndex=s,this.endOffset=i}function lm(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 hr(s){this.eventId=s,this.subscribers=[]}function cm(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 hr(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=[],cm.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],b=i===null||i.apply(this,p)===!0,x=[h,d];if(b){let A=l.apply(this,x);h.setState(s,A)}}),this.registeredModifiers.push(s)},hr.prototype.subscribe=function(s){return typeof s=="function"?this.subscribers.push(s)-1:{FAIL:`invalid '${this.eventId}' event handler`}},hr.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 to)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 hr)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 lm(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 to(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 to(i,null,d),this.getContext(d).openRange=p,this.dispatch("contextStart",[d,i])),p&&h.checkEnd(s)){let b=i-p.startIndex+1,x=this.setEndOffset(b,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 um=Yt;function cn(s){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(s)}function jc(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 dr(s){return/[\u0E00-\u0E7F]/.test(s)}function fr(s){return/[A-z]/.test(s)}function hm(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 dm(s,i){return dn(s,i.coverage)===-1?null:s+i.deltaGlyphId}function fm(s,i){let l=dn(s,i.coverage);return l===-1?null:i.substitute[l]}function eo(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 b=dn(p,d);b!==-1&&l.push(b)}return l.length!==s.length?-1:l}function pm(s,i){let l=i.inputCoverage.length+i.lookaheadCoverage.length+i.backtrackCoverage.length;if(s.context.length<l)return[];let h=eo(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 b=new he(p,0),x=eo(i.lookaheadCoverage,b),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=eo(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 gm(s,i){let l=s.current,h=dn(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=s.lookahead[x],E=d.components[x];if(A!==E)break;if(x===d.components.length-1)return d}}return null}function mm(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 b=!0;for(let x=0;x<p.input.length;x++)if(s.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: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 ym(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,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 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 bm(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 b=0;b<p.length;b++){let x=p[b];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=>dm.apply(this,[h,i]);case"12":return h=>fm.apply(this,[h,i]);case"63":return h=>pm.apply(this,[h,i]);case"41":return h=>gm.apply(this,[h,i]);case"21":return h=>bm.apply(this,[h,i]);case"51":return h=>mm.apply(this,[h,i]);case"53":return h=>ym.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 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],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 vm=Ae;function xm(s){let i=s.current,l=s.get(-1);return l===null&&cn(i)||!cn(l)&&cn(i)}function Sm(s){let i=s.get(1);return i===null||!cn(i)}var Am={startCheck:xm,endCheck:Sm};function Tm(s){let i=s.current,l=s.get(-1);return(cn(i)||un(i))&&!cn(l)}function Cm(s){let i=s.get(1);switch(!0){case i===null:return!0;case(!cn(i)&&!un(i)):{let l=hm(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 wm={startCheck:Tm,endCheck:Cm};function Em(s,i,l){i[l].setState(s.tag,s.substitution)}function km(s,i,l){i[l].setState(s.tag,s.substitution)}function no(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 Im(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 Vc={11:Em,12:km,63:no,41:Im,51:no,53:no};function Pm(s,i,l){s instanceof hn&&Vc[s.id]&&Vc[s.id](s,i,l)}var En=Pm;function Rm(s){let i=[].concat(s.backtrack);for(let l=i.length-1;l>=0;l--){let h=i[l],d=jc(h),p=un(h);if(!d&&!p)return!0;if(d)return!1}return!1}function Om(s){if(jc(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 Mm(s){let i="arab",l=this.featuresTags[i],h=this.tokenizer.getRangeTokens(s);if(h.length===1)return;let d=new he(h.map(b=>b.getState("glyphIndex")),0),p=new he(h.map(b=>b.char),0);for(let b=0;b<h.length;b++){let x=h[b];if(un(x.char))continue;d.setCurrentIndex(b),p.setCurrentIndex(b);let A=0;Rm(p)&&(A|=1),Om(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 Lm=Mm;function $c(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Fm(s){let i="arab",l=this.tokenizer.getRangeTokens(s),h=$c(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];En(x,l,d)}h=$c(l)}}}var Dm=Fm;function _m(s){return s.index===0&&s.context.length>1}function Nm(s){return s.index===s.context.length-1}var Um={startCheck:_m,endCheck:Nm};function zc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Bm(s){let i="delf",l="ccmp",h=this.tokenizer.getRangeTokens(s),d=zc(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];En(A,h,p)}d=zc(h)}}}var Gm=Bm;function Hm(s){let i=s.current,l=s.get(-1);return l===null&&fr(i)||!fr(l)&&fr(i)}function jm(s){let i=s.get(1);return i===null||!fr(i)}var Vm={startCheck:Hm,endCheck:jm};function Wc(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=Wc(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];En(x,l,d)}h=Wc(l)}}}var zm=$m;function Wm(s){let i=s.current,l=s.get(-1);return l===null&&dr(i)||!dr(l)&&dr(i)}function Xm(s){let i=s.get(1);return i===null||!dr(i)}var Ym={startCheck:Wm,endCheck:Xm};function Xc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Km(s){let i="thai",l=this.tokenizer.getRangeTokens(s),h=Xc(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];En(x,l,d)}h=Xc(l,d)}}}var Zm=Km;function Yc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function Qm(s){let i="thai",l=this.tokenizer.getRangeTokens(s),h=Yc(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];En(x,l,d)}h=Yc(l,d)}}}var Jm=Qm;function Kc(s,i){let l=s.map(h=>h.activeState.value);return new he(l,i||0)}function qm(s){let i="thai",l=this.tokenizer.getRangeTokens(s),h=Kc(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];En(x,l,d)}h=Kc(l,d)}}}var ty=qm;function so(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 ey(s){let i=s.current,l=s.get(1);return l===null&&so(i)||so(l)}function ny(s){let i=s.get(1);return i===null||!so(i)}var sy={startCheck:ey,endCheck:ny};function ry(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 b=p.nonDefaultUVS.uvsMappings;if(b[h]){let x=b[h].glyphID;i.glyphs.glyphs[x]!==void 0&&l[0].setState("glyphIndex",x)}}}}var iy=ry;function ke(s){this.baseDir=s||"ltr",this.tokenizer=new um,this.featuresTags={}}ke.prototype.setText=function(s){this.text=s},ke.prototype.contextChecks={ccmpReplacementCheck:Um,latinWordCheck:Vm,arabicWordCheck:Am,arabicSentenceCheck:wm,thaiWordCheck:Ym,unicodeVariationSequenceCheck:sy};function Yn(s){let i=this.contextChecks[`${s}Check`];return this.tokenizer.registerContextChecker(s,i.startCheck,i.endCheck)}function oy(){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 ay(){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 vm(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 ps(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function ly(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;ps.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let l=0;l<i.length;l++){let h=i[l];Lm.call(this,h)}}function cy(){ps.call(this);let s=this.tokenizer.getContextRanges("ccmpReplacement");for(let i=0;i<s.length;i++){let l=s[i];Gm.call(this,l)}}function uy(){if(!this.hasFeatureEnabled("arab","rlig"))return;ps.call(this);let s=this.tokenizer.getContextRanges("arabicWord");for(let i=0;i<s.length;i++){let l=s[i];Dm.call(this,l)}}function hy(){if(!this.hasFeatureEnabled("latn","liga"))return;ps.call(this);let s=this.tokenizer.getContextRanges("latinWord");for(let i=0;i<s.length;i++){let l=s[i];zm.call(this,l)}}function dy(){let s=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let i=0;i<s.length;i++){let l=s[i];iy.call(this,l)}}function fy(){ps.call(this);let s=this.tokenizer.getContextRanges("thaiWord");for(let i=0;i<s.length;i++){let l=s[i];this.hasFeatureEnabled("thai","liga")&&Jm.call(this,l),this.hasFeatureEnabled("thai","rlig")&&ty.call(this,l),this.hasFeatureEnabled("thai","ccmp")&&Zm.call(this,l)}}ke.prototype.checkContextReady=function(s){return!!this.tokenizer.getContext(s)},ke.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&cy.call(this),this.checkContextReady("arabicWord")&&(ly.call(this),uy.call(this)),this.checkContextReady("latinWord")&&hy.call(this),this.checkContextReady("arabicSentence")&&ay.call(this),this.checkContextReady("thaiWord")&&fy.call(this),this.checkContextReady("unicodeVariationSequence")&&dy.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),oy.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 py=ke;function ro(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=ro(s),this.names.macintosh=ro(s),this.names.windows=ro(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 El(this),this.position=new cp(this),this.substitution=new mp(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 Op(this)),!0)}),this.palettes=new gc(this),this.layers=new yp(this),this.svgImages=new bp(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new am(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 py,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 b=0;b<h;b+=1)d[b]=this.glyphs.get(l[b])||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 b=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*b),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*b}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=[],Ul(this,p,h),p.stroke){let b=1/(p.unitsPerEm||1e3)*h;p.strokeWidth*=b}return this.forEachGlyph(s,i,l,h,d,(b,x,A,E)=>{let C=b.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(b,x,A,E){let C=b.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(b,x,A,E){b.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(b,x,A,E){b.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 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 s},Ut.prototype.toTables=function(){return lp.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 Zc=Ut;function gy(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],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 my(){console.warn("Writing of hvar tables is not yet supported.")}var yy={make:my,parse:gy},by=function(){return{coverage:this.parsePointer(B.coverage),attachPoints:this.parseList(B.pointer(B.uShortList))}},vy=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()}},xy=function(){return this.parseList(B.pointer(vy))},Sy=function(){return{coverage:this.parsePointer(B.coverage),ligGlyphs:this.parseList(B.pointer(xy))}},Ay=function(){return this.parseUShort(),this.parseList(B.pointer(B.coverage))};function Ty(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(by),ligCaretList:l.parsePointer(Sy),markAttachClassDef:l.parsePointer(B.classDef)};return h>=1.2&&(d.markGlyphSets=l.parsePointer(Ay)),d}var Cy={parse:Ty},_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 b=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:b,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 wy(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 Ey=new Array(10);function ky(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,Ey)}])}var Iy={parse:wy,make:ky};function Py(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(),b=s.parseUShort(),x=s.parseShort();i[p+","+b]=x}return i}function Ry(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 b=0;b<p;b+=1){let x=s.parseUShort(),A=s.parseUShort(),E=s.parseShort();i[x+","+A]=E}}return i}function Oy(s,i){let l=new rt.Parser(s,i),h=l.parseUShort();if(h===0)return Py(l);if(h===1)return Ry(l);throw new Error("Unsupported kern table version ("+h+").")}var My={parse:Oy};function Ly(s,i,l,h){let d=new rt.Parser(s,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 Fy={parse:Ly};function Qc(s,i){let l=[],h=12;for(let d=0;d<i;d+=1){let p=rt.getTag(s,h),b=rt.getULong(s,h+4),x=rt.getULong(s,h+8),A=rt.getULong(s,h+12);l.push({tag:p,checksum:b,offset:x,length:A,compression:!1}),h+=16}return l}function Dy(s,i){let l=[],h=44;for(let d=0;d<i;d+=1){let p=rt.getTag(s,h),b=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:b,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 _y(s,i={}){let l,h,d=new Zc({empty:!0});s.constructor!==ArrayBuffer&&(s=new Uint8Array(s).buffer);let p=new DataView(s,0),b,x=[],A=rt.getTag(p,0);if(A==="\0\0\0"||A==="true"||A==="typ1")d.outlinesFormat="truetype",b=rt.getUShort(p,4),x=Qc(p,b);else if(A==="OTTO")d.outlinesFormat="cff",b=rt.getUShort(p,4),x=Qc(p,b);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);b=rt.getUShort(p,12),x=Dy(p,b)}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<b;xt+=1){let ct=x[xt],ft;switch(ct.tag){case"avar":N=ct;break;case"cmap":ft=Dt(p,ct),d.tables.cmap=wl.parse(ft.data,ft.offset),d.encoding=new kl(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=$l.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=zl.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=Xl.parse(ft.data,ft.offset);break;case"COLR":ft=Dt(p,ct),d.tables.colr=Jl.parse(ft.data,ft.offset);break;case"CPAL":ft=Dt(p,ct),d.tables.cpal=Ol.parse(ft.data,ft.offset);break;case"maxp":ft=Dt(p,ct),d.tables.maxp=Yl.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=$i.parse(ft.data,ft.offset);break;case"post":ft=Dt(p,ct),d.tables.post=Kl.parse(ft.data,ft.offset),d.glyphNames=new Di(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=rc.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=ic.parse(ft.data,ft.offset);break;default:break}}let Te=Dt(p,Jt);if(d.tables.name=Cl.parse(Te.data,Te.offset,h),d.names=d.tables.name,z&&Gt){let xt=l===0,ct=Dt(p,Gt),ft=Fy.parse(ct.data,ct.offset,d.numGlyphs,xt),oe=Dt(p,z);d.glyphs=vc.parse(oe.data,oe.offset,ft,d,i)}else if(E){let xt=Dt(p,E);ji.parse(xt.data,xt.offset,d,i)}else if(C){let xt=Dt(p,C);ji.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(Wl.parse(d,de.data,de.offset,d.numberOfHMetrics,d.numGlyphs,d.glyphs,i),Ld(d,i),Bt){let xt=Dt(p,Bt);d.kerningPairs=My.parse(xt.data,xt.offset)}else d.kerningPairs={};if(vt){let xt=Dt(p,vt);d.tables.gdef=Cy.parse(xt.data,xt.offset)}if(pt){let xt=Dt(p,pt);d.tables.gpos=Iy.parse(xt.data,xt.offset),d.position.init()}if(At){let xt=Dt(p,At);d.tables.gsub=Zl.parse(xt.data,xt.offset)}if(R){let xt=Dt(p,R);d.tables.fvar=ql.parse(xt.data,xt.offset,d.names)}if(P){let xt=Dt(p,P);d.tables.stat=tc.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=sc.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=nc.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=ec.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=yy.parse(xt.data,xt.offset,d.tables.fvar)}if(Ne){let xt=Dt(p,Ne);d.tables.meta=Ql.parse(xt.data,xt.offset),d.metas=d.tables.meta}return d.palettes=new gc(d),d}function Ny(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function Uy(){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 fi=="object"&&fi.exports?fi.exports=t():o.opentype=t()})(typeof self<"u"?self:Vu,()=>({...ju,default:ju}))});var E1={};eu(E1,{Logger:()=>br,PDFParser:()=>Ii,addGfontsAssetLibrary:()=>ao,anyMatchResolverStage:()=>Hs,assetLibraryStrategy:()=>Gh,createFontCascade:()=>js,createFontStrategy:()=>Vs,defaultEmission:()=>is,defaultStrategy:()=>os,editableFirstStrategy:()=>hl,embeddedSubsetStage:()=>Gs,exactFidelityStrategy:()=>Bh,perfectMatchResolverStage:()=>rs});module.exports=Xy(E1);function Yy(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 br=class{constructor(o){this.registry=o}messages=[];emit(o,t={}){let e=this.registry[o];this.messages.push({code:o,type:e.severity,message:Yy(e.template,t),params:t})}getMessages(){return this.messages}},Ky="0.1.0",ru=`https://staticimgly.com/imgly/gfonts/${Ky}/dist`,gs="ly.img.gfonts",ms="ly.img.gfonts-fallbacks";async function ao(o){let t=o.asset.findAllSources();t.includes(gs)||await o.asset.addLocalAssetSourceFromJSONURI(`${ru}/${gs}/content.json`),t.includes(ms)||await o.asset.addLocalAssetSourceFromJSONURI(`${ru}/${ms}/content.json`)}async function lo(o,t,e){let n=t.asset.findAllSources();if(!n.includes(gs)||!n.includes(ms))throw new Error(`The gfonts asset sources (${gs}, ${ms}) are not available. Call addGfontsAssetLibrary() first.`);let r,a=await tb(t,o.family);if(a?r=o.family:a=await qy(t,gs,o.family),!a)return null;let c=a.fonts.find(u=>Zy(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=Jy(u,o.weight))}return c?{typeface:a,font:c,substitutedFrom:r}:null}var co={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 Zy(o,t){return!(t.style!==void 0&&o.style?.toLowerCase()!==t.style.toLowerCase()||t.weight!==void 0&&!Qy(t.weight,o.weight))}function Qy(o,t){if(!t)return!1;if(o===t)return!0;let e=o.toLowerCase();if(e===t)return!0;let n=co[e];return n!==void 0&&n===t}function iu(o){let t=o.toLowerCase();for(let e of pn)if(e.toLowerCase()===t)return e;return co[t]??null}function Jy(o,t){let e=iu(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=iu(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 qy(o,t,e){let n=await o.asset.findAssets(t,{page:0,query:e,perPage:1});if(!n||n.assets.length===0){let r=eb(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 tb(o,t){let e=await o.asset.findAssets(ms,{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 eb(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 ou={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.'}};Va();var ui=require("@napi-rs/canvas");async function Qe(o,t){return{canvas:(0,ui.createCanvas)(o,t),ImageData:ui.ImageData}}async function _n(o){return new Uint8Array(o.toBuffer("image/png"))}async function Mu(o){return{opList:await o.getOperatorList({annotationMode:ja.DISABLE})}}function Nn(o,t){return Lu(o.objs,t)}function ts(o,t){return Lu(o.commonObjs,t)}function Lu(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 di(o,t,e={}){if(o==null)return null;let n=o.width,r=o.height;if(!n||!r)return hi("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 hi(`bitmap drawImage failed: ${g}`,o,t,e),null}else if(o.data){let f=Wa(o);if(!f)return hi(`unknown data kind=${o.kind}`,o,t,e),null;let g=new c(f,n,r);u.putImageData(g,0,0)}else return hi("no bitmap and no data",o,t,e),null;return _n(a)}async function Fu(o,t,e,n={}){if(o==null)return null;let r=o.width,a=o.height;if(!r||!a)return null;let c=za(t);if(c==null)return null;let[u,f,g]=c,m=await $a(o);if(m==null)return null;let{canvas:y,ImageData:v}=await Qe(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),_n(y)}async function $a(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 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(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 za(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 hi(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 Wa(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 H0(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 Du(o,t,e,n={}){if(o==null)return null;let r=o.width,a=o.height;if(!r||!a)return null;let c=za(t);if(c==null)return null;let[u,f,g]=c,m=await H0(o);if(m==null)return null;let{canvas:y,ImageData:v}=await Qe(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),_n(y)}async function Nu(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=Bu(r??1);if(n.kind==="shading"){let f=j0(n.ir,n.ctm);return f==null?null:_u(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 $a(n.obj);if(m==null)return null;let y=V0(n.ctm,m,f,g);return y==null?null:_u(a,c,e,y,u)}return null}async function Uu(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),y=m.getContext("2d");try{y.drawImage(o.bitmap,0,0)}catch{return null}let v=y.getImageData(0,0,e,n);r=new Uint8ClampedArray(v.data.buffer.slice(0))}else o.data&&(r=Wa(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 y=r[m*4+3];a[m*4+3]=Math.round(y*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 _u(o,t,e,n,r){let a=new Uint8ClampedArray(o*t),[c,u,f,g,m,y]=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+y,O=n(I,k);a[v*o+S]=Math.round(O*255*r)}return a}function j0(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=$0(n);if(f==null)return null;let g=Gu(t);if(g==null)return null;if(e==="axial"){if(!Array.isArray(r)||!Array.isArray(a))return null;let[m,y]=r,[v,S]=a,T=v-m,w=S-y,I=T*T+w*w;return I<=0?null:(k,O)=>{let[F,_]=Xa(g,k,O),D=((F-m)*T+(_-y)*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[y,v]=a;return(S,T)=>{let[w,I]=Xa(g,S,T),k=w-y,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 V0(o,t,e,n){let r=Gu(o);return r==null?null:(a,c)=>{let[u,f]=Xa(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 $0(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=Bu(n[0]),a=z0(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,y=a.b+(c.b-a.b)*f;e[n]=Math.round(.299*g+.587*m+.114*y)}return e}function z0(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 Bu(o){return typeof o!="number"||!Number.isFinite(o)||o<0?0:o>1?1:o}function Xa(o,t,e){return[o[0]*t+o[2]*e+o[4],o[1]*t+o[3]*e+o[5]]}function Gu(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 W0=/^[A-Z]{6}\+/,X0=["compressed","condensed","extended","narrow","wide","cond","comp"],Y0=["italic","oblique"],Hu={bd:700,lt:300,md:500,rg:400,bk:900,blk:900,hv:900,th:100,hl:100};function Ns(o){let t=o.replace(W0,""),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=K0(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 K0(o){let t=o.toLowerCase(),e=!1,n="normal";for(let a of Y0)if(t.includes(a)){n="italic",e=!0;break}for(let a of X0)if(t.includes(a)){e=!0;break}let r=Z0(t);return r!==null&&(e=!0),e?{weight:r,style:n}:null}function Z0(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 Q0=/^[A-Z]{6}\+/;async function Ka(o,t){if(!o||!o.data||o.data.length===0)return null;let e=Ns(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(Q0,""),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 ev(r,m,o.toFontChar??null,t),v=J0(y);return{postScriptName:n,family:c,weight:f,style:g,data:y,mimeType:v}}function $u(o,t){if(!gi(o)||!t||t.length===0)return!1;for(let e of t){let n=e.unicode;if(!n||q0(n))return!1}return!0}function gi(o){return!(!o||o.isType3Font||!o.data||o.data.length===0||!o._parsed)}function Za(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 zu(o){let t=Ns(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:Za(n)}}function J0(o){return o.length>=4&&o[0]===79&&o[1]===84&&o[2]===84&&o[3]===79?"font/otf":"font/ttf"}function q0(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 tv=[32,160];async function ev(o,t,e,n){if(!o)return t;let r=pi.get(o);if(r)return r;try{let{default:a}=await Promise.resolve().then(()=>su(Ya(),1)),c=nv(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 tv){if(rv(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 pi.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(pi.set(o,T),sv()){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}),pi.set(o,t),t}}function nv(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 pi=new WeakMap;function sv(){return!!(typeof process<"u"&&process.env?.PDF2CESDK_DEBUG_FONTS||typeof globalThis<"u"&&globalThis.PDF2CESDK_DEBUG_FONTS)}function rv(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 Ku(o,t,e,n){if(!o||o.length===0)return[];let r=o.map(u=>ov(u,t,e,n)),a=[],c=null;for(let u of r)if(u){if(c&&iv(c,u)){c.items.push(u);continue}c&&a.push(Wu(c,t)),c={items:[u]}}return c&&a.push(Wu(c,t)),a}function iv(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 ov(o,t,e,n){let r=t[o.fontObjId];if(!r)return null;let a=Yu(e,o.textMatrix),c=[o.fontSize,0,0,o.fontSize,0,0],u=Yu(a,c),f=Math.hypot(u[2],u[3]),g=a[4],m=n-a[5],y=av(o,r,f);return{glyph:o,fontObjId:o.fontObjId,fontSizePt:f,originXPt:g,baselineYPt:m,advancePt:y}}function av(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 Wu(o,t){let e=o.items,n=e[0],r=e[e.length-1],c=t[n.fontObjId]?._parsed,u=Xu(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=n.originXPt,v=Xu(e.map(k=>k.baselineYPt)),T=r.originXPt+r.advancePt-y+.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:y,baselineYPt:v,widthPt:T,ascenderPt:g,descenderPt:m,text:w}}function Xu(o){return o.length===0?0:o.reduce((t,e)=>t+e,0)/o.length}function Yu(o,t){let[e,n,r,a,c,u]=o,[f,g,m,y,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*y,n*m+a*y,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 Zu(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 Qu(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 Qa(){return[]}function Ju(o,t,e,n){return[...o,{path:t,fillRule:e,ctm:n.slice()}]}function qu(o){return o.slice()}function th(o){return o.pop()??Qa()}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}),PS=Object.freeze([1,0,0,1,0,0]);function lv(o,t,e){let n=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<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 cv(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 uv(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 mi(o,t,e){let{cmds:n,devPoints:r}=lv(o,t,e);if(r.length===0)return null;let a=cv(r);return{...a,d:uv(n,a.x,a.y),cmds:n,devPoints:r}}function xn(o,t){let e=[];for(let n of o){let r=hv(n,t);r&&e.push(r)}return e}function hv(o,t){let e=mi(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 eh({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 y=o,v=y[1],S=y[3],T=y[4],w=y[5],I=y[6],k=y[7],O=dv(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?mi(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=Ja(T,t,r.heightPt),G=Ja(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=Ja(w,t,r.heightPt),G=gv(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 dv(o){if(!Array.isArray(o))return[];let t=[];for(let e of o){if(!Array.isArray(e)||e.length<2)continue;let n=pv(e[0]),r=fv(e[1]);if(!r)continue;let a={space:"rgb",values:r};t.push({offset:n,color:a})}return t}function fv(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 pv(o){return typeof o!="number"||!Number.isFinite(o)||o<0?0:o>1?1:o}function Ja(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 gv([o,t,e,n]){return Math.sqrt(Math.abs(o*n-t*e))}var mv=12,yv=85,bv=10,vv=11,xv=91,Sv=22,Av=23,Tv=24,Cv=25,wv=28,Ev=29,kv=30,Iv=new Set([1,9,31,32,37,2,50,51,53,55,56,57,58,59,60,61]);async function nh({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=[],y=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 bv:S.push(v.slice());break;case vv:v=S.pop()??[1,0,0,1,0,0];break;case mv:v=Pv(v,$);break;case yv:{u++;let Z=$[0],q=Number($[1]??0)||0,bt=Number($[2]??0)||0;typeof Z=="string"&&m.push({objId:Z,ctm:v.slice(),w:q,h:bt});break}case xv:{let Z=$,q=Z[2];if(q&&q.length>=4)y={w:q[2]-q[0],h:q[3]-q[1]};else{let bt=Z[1];y=Ov(bt)}break}case Sv:case Av:case Tv:case Cv:y!=null?(g+=Rv(y,v),y=null):f++;break;case wv:case Ev:case kv:y=null;break;default:Iv.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 di(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 Pv(o,t){let[e,n,r,a,c,u]=o,[f,g,m,y,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*y,n*m+a*y,e*v+r*S+c,n*v+a*S+u]}function Rv(o,t){return Math.abs(t[0]*t[3]-t[1]*t[2])*o.w*o.h}function Ov(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},yi=[1,0,0,1,0,0];async function ch(o,t,e={}){let n=e.textMode??"outline",r=e.docFonts??new Map,a=e.logger,c=e.pageIndex,{opList:u}=await Mu(o),f=await Mv(o,u,{logger:a,pageIndex:c}),g=o.colorSpaceResources??{},{out:m,colorSnapshots:y}=await Fv(u,t,o,f,{textMode:n,docFonts:r,logger:a,pageIndex:c,colorSpaceResources:g});return{out:m,colorSnapshots:y,finalize:()=>Qv(Dv(m),t)}}async function Mv(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 Lv(f.data,g,e)}c[u]=f}return c}async function Lv(o,t,e={}){try{let{default:n}=await Promise.resolve().then(()=>su(Ya(),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 Fv(o,t,e,n,r){let a=o.fnArray,c=o.argsArray,u=[],f=r?.colorSpaceResources??{},g=[],m=t.originShiftPt??{x:0,y:0},y=lh(m),v=[],S=null,T=Qa(),w=[],I=null,k=[],O=[],F=[],_=null,D=[],G=[],j=[],W=[],$=0,Z=!1,q=[],bt=()=>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`},yt=()=>{if(y.blendMode!=null&&y.blendMode!=="source-over")return y.blendMode;for(let X=D.length-1;X>=0;X--){let ot=D[X];if(ot!=null&&ot!=="source-over")return ot}return y.blendMode},lt=()=>{if(y.fillAlpha!=null&&y.fillAlpha<1)return y.fillAlpha;for(let X=G.length-1;X>=0;X--){let ot=G[X];if(ot!=null&&ot<1)return ot}return y.fillAlpha},kt=()=>{_&&_.glyphs.length>0?_v(_,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(y),y=Wv(y),w.push(qu(T));break;case st.restore:y=v.pop()??lh(m),T=th(w);break;case st.paintFormXObjectBegin:D.push(y.blendMode),G.push(y.fillAlpha),j.push({blendMode:y.blendMode,fillAlpha:y.fillAlpha});break;case st.paintFormXObjectEnd:{D.pop(),G.pop();let nt=j.pop();nt&&(y.blendMode=nt.blendMode,nt.fillAlpha!=null&&(y.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:y.fillColor!=null?{kind:"solid",color:y.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"&&gt.space!=="cmyk"&&gt.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:y.ctm=Ve(y.ctm,Q);break;case st.setLineWidth:y.lineWidth=Q[0];break;case st.setFillRGBColor:y.fillColor=rh(Q);break;case st.setStrokeRGBColor:y.strokeColor=rh(Q);break;case st.setFillCMYKColor:y.fillColor={space:"cmyk",values:[Q[0],Q[1],Q[2],Q[3]]};break;case st.setStrokeCMYKColor:y.strokeColor={space:"cmyk",values:[Q[0],Q[1],Q[2],Q[3]]};break;case st.setFillGray:y.fillColor={space:"gray",values:[Q[0]]};break;case st.setStrokeGray:y.strokeColor={space:"gray",values:[Q[0]]};break;case st.setFillColorSpace:y.fillColorSpaceName=Q?.[0]??null,y.fillColorSpaceName!=="Pattern"&&(y.fillPattern=null);break;case st.setStrokeColorSpace:y.strokeColorSpaceName=Q?.[0]??null;break;case st.setFillColorN:{let nt=Yv(Q);if(nt){y.fillPattern=nt;break}let{key:it,components:V}=ih(Q);y.fillColor=oh(it??y.fillColorSpaceName,V,f,y.fillColor);break}case st.setStrokeColorN:{let{key:nt,components:it}=ih(Q);y.strokeColor=oh(nt??y.strokeColorSpaceName,it,f,y.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")y.fillAlpha=U;else if(H==="CA"&&typeof U=="number")y.strokeAlpha=U;else if(H==="LW"&&typeof U=="number")y.lineWidth=U;else if(H==="BM"){if(typeof U=="string"&&U!=="")y.blendMode=U;else if(Array.isArray(U)){for(let at of U)if(typeof at=="string"&&at!==""){y.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=Ju(T,S,I,y.ctm),I=null),S==null)break;let nt=Bv(ot);if(nt){if(y.textClipActive){ns(r,y.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||bt()){S=null;break}if(nt.fill&&y.fillPattern){let V=Kv(S);if(V){let H=Zv(y.ctm,V),U={kind:"image",_placeholderIndex:u.length};u.push(U),F.push({placeholder:U,pattern:y.fillPattern,placementCtm:H,opacity:lt(),blendMode:yt(),clips:es(T)?null:xn(T,t)})}S=null;break}let it=ah(S,nt,y,t);if(it){it.blendMode=yt();let V=lt();V!=null&&V<1&&(it.opacity=V),sh(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:y.ctm.slice()}),$>0||bt())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:y.ctm.slice()});break}if(y.textClipActive){ns(r,y.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:y.ctm.slice(),opacity:lt(),blendMode:yt(),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||bt())break;if(y.textClipActive){ns(r,y.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:y.ctm.slice(),opacity:lt(),blendMode:yt(),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||bt())break;let it=(Q[0]??{}).data;if(y.textClipActive){ns(r,y.ctm,t,`image mask objId="${it}"`);break}if(y.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:y.fillColor,ctm:y.ctm.slice(),opacity:lt(),blendMode:yt(),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||bt())break;if(y.textClipActive){ns(r,y.ctm,t,"solid-colour image mask");break}if(y.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=ah(nt,{fill:!0,stroke:!1,fillRule:"nonzero"},y,t);if(it){it.blendMode=yt();let V=lt();V!=null&&V<1&&(it.opacity=V),sh(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||bt())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||bt())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:y.ctm.slice()}),$>0||bt())break;if(y.textClipActive){ns(r,y.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:y.ctm.slice(),clipEntry:it??null,remainingClips:V,opacity:lt(),blendMode:yt()});break}case st.beginText:y.textMatrix=yi.slice(),y.textLineMatrix=yi.slice();break;case st.endText:kt();break;case st.setFont:y.fontObjId=Q[0],y.fontSize=Q[1];break;case st.setTextMatrix:y.textMatrix=[Q[0],Q[1],Q[2],Q[3],Q[4],Q[5]],y.textLineMatrix=y.textMatrix.slice();break;case st.moveText:{y.textLineMatrix=Ve(y.textLineMatrix,[1,0,0,1,Q[0],Q[1]]),y.textMatrix=y.textLineMatrix.slice();break}case st.setLeadingMoveText:{y.textLeading=-Q[1],y.textLineMatrix=Ve(y.textLineMatrix,[1,0,0,1,Q[0],Q[1]]),y.textMatrix=y.textLineMatrix.slice();break}case st.nextLine:{y.textLineMatrix=Ve(y.textLineMatrix,[1,0,0,1,0,-y.textLeading]),y.textMatrix=y.textLineMatrix.slice();break}case st.setLeading:y.textLeading=Q[0];break;case st.setCharSpacing:y.charSpacing=Q[0];break;case st.setWordSpacing:y.wordSpacing=Q[0];break;case st.setHScale:y.textHScale=Q[0]/100;break;case st.setTextRise:y.textRise=Q[0];break;case st.setTextRenderingMode:y.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(y.textRenderingMode===7&&(y.textClipActive=!0),!_){let V={_placeholder:!0};u.push(V),_={placeholder:V,ctm:y.ctm.slice(),fillColor:y.fillColor,fillAlpha:y.fillAlpha,fontObjIdFirst:y.fontObjId,textString:"",glyphs:[]}}let it=(()=>{let V=Ve(y.ctm,y.textMatrix),H={fontObjId:y.fontObjId??"",baselineX:V[4],baselineY:V[5],fill:bi(y.fillColor,lt()),text:"",placeholder:_.placeholder,renderMode:y.textRenderingMode};return g.push(H),H})();for(let V of nt){if(typeof V=="number"){let gt=-V*.001*y.fontSize*y.textHScale;y.textMatrix[4]+=gt*y.textMatrix[0],y.textMatrix[5]+=gt*y.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:y.fontObjId??"",fontSize:y.fontSize,textMatrix:y.textMatrix.slice()});let U=(y.fontObjId!=null?n[y.fontObjId]:null)?.fontMatrix?.[0]??.001,Ct=((V.width??0)*U*y.fontSize+y.charSpacing+(V.isSpace?y.wordSpacing:0))*y.textHScale;y.textMatrix[4]+=Ct*y.textMatrix[0],y.textMatrix[5]+=Ct*y.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 Du(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 Fu(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 Nu({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 Uu(ot,U),!nt){je(X.placeholder);continue}}else if(nt=await di(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 nh({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=eh({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 Dv(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 _v(o,t,e,n){let r=n?.textMode??"outline",a=[];if(o.placeholder._replacements=a,r==="outline"){let f=qa(o,o.glyphs,t,e);f&&a.push(f);return}let c=Ku(o.glyphs,t,o.ctm,e.heightPt),u=[];o.placeholder._lazyGlyphOutlines=u;for(let f of c){let g=t[f.fontObjId];if($u(g,f.glyphs)){let y=f;u.push(()=>{let v=qa(o,y.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 y=g?.name??f.fontObjId;throw new Error(`textMode 'editable': embeddability gate failed for font ${y} (text: ${JSON.stringify(f.text)})`)}let m=qa(o,f.glyphs,t,e);m&&a.push(m)}}function qa(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],yt=[dt.fontSize,0,0,dt.fontSize,0,0],lt=Ve(yt,K);lt=Ve(dt.textMatrix,lt),lt=Ve(o.ctm,lt);let kt=null;if(Y.isType3Font?kt=Nv(Y,dt.operatorListId):Y._parsed&&(kt=Uv(Y,dt)),kt){let ot=uh(kt,lt,n.heightPt);r.push(...ot.cmds),a.push(...ot.devPoints)}let X=Ve(o.ctm,Ve(dt.textMatrix,yt));c+=Math.hypot(X[2],X[3]),u+=1,f+=dt.unicode??""}let g=u>0?c/u:0,m=1/0,y=1/0,v=-1/0,S=-1/0;for(let[dt,Y]of a)dt<m&&(m=dt),Y<y&&(y=Y),dt>v&&(v=dt),Y>S&&(S=Y);Number.isFinite(m)||(m=y=v=S=0);let T=e[t[0].fontObjId],{style:w,weight:I}=zu(T),k=Ns(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,bt=-1/0;for(let[dt,Y]of a){let K=dt*j-Y*W,yt=dt*W+Y*j;K<$&&($=K),yt<Z&&(Z=yt),K>q&&(q=K),yt>bt&&(bt=yt)}let et=Number.isFinite($)?Math.max(0,q-$):0,Tt=Number.isFinite(Z)?Math.max(0,bt-Z):0;return{kind:"text-outline",x:m,y,width:Math.max(0,v-m),height:Math.max(0,S-y),d:hh(r,m,y),text:f,fontFamily:O,fontSize:g,fontStyle:w,fontWeight:I,fill:bi(o.fillColor,o.fillAlpha),opacity:o.fillAlpha!=null&&o.fillAlpha<1?o.fillAlpha:1,textOriginX:_,textOriginY:D,rotation:G,unrotWidth:et,unrotHeight:Tt}}function Nv(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 Uv(o,t){let e=o._parsed;if(!e)return null;let n=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&&(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 sh(o,t,e){if(es(t))return;let n=xn(t,e);n.length>0&&(o.clips=n)}function rh(o){return{space:"rgb",values:[o[0]/255,o[1]/255,o[2]/255]}}function ih(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 oh(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 Bv(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 ah(o,t,e,n){let r=Hv(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 y=g-u,v=m-f;if(y<=0&&v<=0)return null;let S=t.stroke?Math.abs(Xv(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,O=y+T,F=v+w;return{kind:"vector-path",x:I,y:k,width:O,height:F,d:hh(c,I,k),fill:t.fill?bi(e.fillColor,e.fillAlpha):null,stroke:t.stroke?bi(e.strokeColor,e.strokeAlpha):null,strokeWidth:S,fillRule:Gv(t,c),opacity:1,blendMode:e.blendMode}}function Gv(o,t){return o.fill?"evenodd":o.fillRule}function Hv(o,t,e){return uh(o,t,e)}function uh(o,t,e){let n=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<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 hh(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 jv=.01,Vv=.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),y=Math.atan2(-r,n);if(Math.abs(r)<1e-6&&Math.abs(a)<1e-6||Math.abs(y)<Vv)return $v(o,t);let S=g>0&&m>0?(n*a+r*c)/(g*m):0;if(!(Math.abs(S)<jv)||!(g>0&&m>0))return zv(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 $v(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),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 zv(o,t,e=null,n=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}: `:"",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:Zu(o),residualStr:O,page:e.pageIndex,objId:e.objId??null})}return I}function bi(o,t){return o==null?null:t==null||t===1?o:{...o,alpha:t}}function lh(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:yi.slice(),textLineMatrix:yi.slice(),fontObjId:null,fontSize:0,charSpacing:0,wordSpacing:0,textHScale:1,textRise:0,textLeading:0,textRenderingMode:0,textClipActive:!1}}function Wv(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 Xv([o,t,e,n]){return(Math.hypot(o,t)+Math.hypot(e,n))/2}function Yv(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 Kv(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 Zv(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,y,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*y,n*m+a*y,e*v+r*S+c,n*v+a*S+u]}function Qv(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||Jv(e,t))})}function Jv(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 qv=.05,tx=1.5,vi=1;async function dh(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||ux(a.str))continue;if(a.str&&a.str.length>0&&a.str.trim()===""){let m=t.pageBox.originShiftPt??{x:0,y:0};ix({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=fh(o,a.fontName);if(!gi(c))continue;let u=e.styles?.[a.fontName],f=await ex(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 ex(o,t,e,n,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=n.pageBox.originShiftPt??{x:0,y:0},T=g-S.x,w=m-S.y,{ascentRatio:I,descentRatio:k}=cx(e,t),O=y*I,F=y*k,_=o.width+y*qv,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,bt=Z-W,et=n.pageBox.heightPt-q-D/2,Tt=D/2,dt=bt-Tt*j,Y=et+Tt*(1-G),K=await Ka(t,n.logger);if(!K)return null;n.docFonts.has(K.postScriptName)||n.docFonts.set(K.postScriptName,K);let yt=sx({fontObjId:o.fontName,baselineX:T,baselineY:w,widthPt:o.width,str:o.str,dirSignX:a<0?-1:1},n.colorSnapshots,r);if(yt==null)return null;let lt=K,kt=yt.walkerFontObjId;if(kt&&kt!==o.fontName&&n.page){let V=fh(n.page,kt);if(V&&gi(V)){let H=await Ka(V,n.logger);H&&(lt=H,n.docFonts.has(H.postScriptName)||n.docFonts.set(H.postScriptName,H))}}if(yt.renderMode===3||yt.renderMode===7){let V=n.pageIndex!=null?` on page ${n.pageIndex}`:"",H=yt.renderMode===7?"7 (add to clipping path)":"3 (invisible)";return n.logger?.emit?.("TEXT_RENDER_MODE_SKIPPED",{pageTag:V,text:nx(o.str,60),modeLabel:H,page:n.pageIndex,renderMode:yt.renderMode}),null}let{fill:X,colorSpans:ot}=yt,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:y,rotation:-v,fill:X,...ot?{colorSpans:ot}:{},baselineXPt:T,baselineYPt:w,advanceWidthPt:o.width};return it.opacity=nt,{run:it,placeholder:yt.placeholder??null}}function nx(o,t){return typeof o!="string"?"":o.length>t?`${o.slice(0,t)}\u2026`:o}function sx(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)||!xi(t[T])||!Si(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)||!xi(t[T])||!Si(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)&&xi(t[T])&&Si(t[T],o)&&ax(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=ox(n,o.str),y=n[0].fill??null;if(n.every(T=>tl(T.fill??null,y)))return{fill:y,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];_&&tl(_.fill,I.fill??null)?_.to=F:T.push({from:O,to:F,fill:I.fill??null})}return T.length===0?{fill:y,colorSpans:void 0,renderMode:f,placeholder:g,walkerFontObjId:m}:{fill:T[0].fill,colorSpans:T,renderMode:f,placeholder:g,walkerFontObjId:m}}return rx(o,n,y,f,g,m)}function rx(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,y=g+1<u.length?u[g+1].from:c;if(m>=y)continue;let v=f[f.length-1];v&&tl(v.fill,u[g].fill)?v.to=y:f.push({from:m,to:y,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 ix(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)||!xi(t[u])||!Si(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 ox(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 ax(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 xi(o){if(!o)return!1;let t=o.fill;return t?(t.alpha??1)>0:!1}function tl(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 Si(o,t){if(Math.abs(o.baselineY-t.baselineY)>tx)return!1;let e=lx(o.text),n,r;return t.dirSignX<0?(n=t.baselineX-t.widthPt-vi,r=t.baselineX+vi+e):(n=t.baselineX-vi-e,r=t.baselineX+t.widthPt+vi),!(o.baselineX<n||o.baselineX>r)}function lx(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 cx(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 fh(o,t){if(!t)return null;try{if(o.commonObjs.has(t))return o.commonObjs.get(t)}catch{}return null}function ux(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 el=require("node:fs"),nl=require("node:url"),sl=require("node:module");async function ph(){let o=new URL("./pdf.worker.mjs",__import_meta_url__);return(0,el.existsSync)(o)?(0,nl.fileURLToPath)(o):(0,sl.createRequire)(__import_meta_url__).resolve("@imgly/pdfjs-dist/legacy/build/pdf.worker.mjs")}async function gh(){let o=new URL("./standard_fonts/FoxitFixed.pfb",__import_meta_url__),t=new URL("./standard_fonts/",__import_meta_url__);if((0,el.existsSync)(o))return(0,nl.fileURLToPath)(t);let e=(0,sl.createRequire)(__import_meta_url__).resolve("@imgly/pdfjs-dist/standard_fonts/FoxitFixed.pfb");return e.slice(0,e.lastIndexOf("/")+1)}var rl=2;function hx(o){let t=o?.imglyPatchVersion??null;if(t!==rl)throw new Error(`[@imgly/pdf-importer] @imgly/pdfjs-dist patch missing or outdated (got ${t??"none"}, expected ${rl}). 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.${rl} or newer and reinstall.`)}async function mh(o,t={}){let e=t.pdfjsModule??await Promise.resolve().then(()=>(Va(),Ou));e.GlobalWorkerOptions.workerSrc=t.workerSrc??await ph();let n=t.standardFontDataUrl??await gh(),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 y=await u.getPage(m);m===1&&hx(y),g.push(await dx(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 dx(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},y=!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])},y=!0));let{colorSnapshots:v,finalize:S}=await ch(o,f,t),T=t.textMode==="outline"?[]:await dh(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:y,blocks:w}}var se=Object.freeze({IMAGE:"image",VECTOR_PATH:"vector-path",TEXT_OUTLINE:"text-outline",TEXT_RUN:"text-run"}),fx=72,zt=o=>o/fx;var yh=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 Ai(o,t){return o==null||o===""?null:Object.prototype.hasOwnProperty.call(yh,o)?yh[o]:(t?.emit?.("BLEND_MODE_UNSUPPORTED",{mode:o}),null)}function Ti(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 bh=()=>({state:"unknown",warned:!1});var Ci=Symbol("COMBINE_EMPTY_INTERSECTION");function ol(o,t,e){if(!Array.isArray(t)||t.length<2)return e?.logger?.emit?.("CLIP_COMBINE_TOO_FEW_INPUTS",{prefix:il(e),inputCount:t?.length??0,label:e?.label??null}),null;if(!o.block.isCombinable(t))return e?.logger?.emit?.("CLIP_COMBINE_NOT_COMBINABLE",{prefix:il(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 px(r)?Ci:(e?.logger?.emit?.("CLIP_COMBINE_THREW",{prefix:il(e),inputCount:t.length,reason:r,label:e?.label??null}),null)}}function px(o){return typeof o=="string"&&o.includes("empty shape")}function il(o){return o?.label?`${o.label}: `:""}function Us(o,t){for(let e of t)try{o.block.isValid?.(e)!==!1&&o.block.destroy(e)}catch{}}function gx(){return{scaleRatio:1,translationX:0,translationY:0,rotation:0}}function vh(o){return o.scaleRatio===1&&o.translationX===0&&o.translationY===0&&o.rotation===0}function xh(o,t){if(mx(o,t))return gx();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,y=g===0?0:(a-u)/g;return{scaleRatio:n,translationX:m,translationY:y,rotation:0}}function Sh(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 mx(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 Ah(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 kh(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=>Bs(g)),c=e.filter(g=>!Bs(g)&&!Eh(g,t)),u=e.filter(g=>!Bs(g)&&Eh(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=bx(u,t);return f.length===1?Ph(o,t,f[0],r):Cx(o,t,f,n,r)}function bx(o,t){let e=[],n=new Set;for(let r of o)vx(r,t)||n.has(r.d)||(n.add(r.d),e.push(r));return e.length>0?e:[o[0]]}function vx(o,t){if(!xx(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 xx(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 Ih(o,t,e,n,r){let a=e.filter(y=>Bs(y)),c=e.filter(y=>!Bs(y));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 y of c){let v=Oh(o,y);o.block.appendChild(n,v),u.push(v)}let f={x:t.x,y:t.y,width:t.width,height:t.height},g=Ox(o,t.d,f,t.fill,t.opacity);o.block.appendChild(n,g);let m=ol(o,[g,...u],{logger:r?.logger,label:`${Bn(r)}vector path at ${Me(t)}`});return m===Ci?(Us(o,[g,...u]),Gn):m==null?(Us(o,[g,...u]),null):(Ax(o,m,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(m,t.opacity),al(o,m,t.blendMode,r?.logger),Sx(o,m,t,r),m)}function Sx(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 Ax(o,t,e){let n=e.fill,r=n?.kind;if(r==="linearGradient"||r==="radialGradient"){Tx(o,t,e);return}let a=o.block.createFill("color");o.block.setColor(a,"fill/color/value",ll(n)),o.block.setFill(t,a)}function Tx(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:ll(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 al(o,t,e,n){let r=Ai(e,n);r!=null&&(typeof o.block.supportsBlendMode=="function"&&!o.block.supportsBlendMode(t)||o.block.setBlendMode(t,r))}function Ph(o,t,e,n){let r=o.block.create("graphic"),a=Lx(e,t),c=Ti(o,a,t.width,t.height);return o.block.setShape(r,c),ss(o,r,t),Ei(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),al(o,r,t.blendMode,n?.logger),r}function Cx(o,t,e,n,r){if(t.rotation&&Math.abs(t.rotation)>1e-6){let g=wx(o,t,e,n,r);if(g!==Rh)return g}let c=Rx(o,t);o.block.appendChild(n,c);let u=[];for(let g of e){let m=Oh(o,g);o.block.appendChild(n,m),u.push(m)}let f=ol(o,[c,...u],{logger:r?.logger,label:`${Bn(r)}clipped image at ${Me(t)}`});return f===Ci?(Us(o,[c,...u]),Gn):f==null?(Us(o,[c,...u]),null):(ss(o,f,t),Mx(o,f,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(f,t.opacity),al(o,f,t.blendMode,r?.logger),f)}var Rh=Symbol("UNHANDLED");function wx(o,t,e,n,r){let a=Ex(e);if(a==null)return Rh;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=Px(a.points);return Ph(o,t,c,r)}function Ex(o){if(o.length===0)return null;let t=Th(o[0]);if(t==null)return null;for(let e=1;e<o.length;e++){let n=Th(o[e]);if(n==null)return null;if(t=kx(t,n),t.length===0)return{points:[]}}return{points:t}}function Th(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 kx(o,t){if(t.length<3)return[];let e=Math.sign(Ix(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=Ch(g,a,c)*e>=-1e-9,y=Ch(f,a,c)*e>=-1e-9;m?(y||n.push(wh(f,g,a,c)),n.push(g)):y&&n.push(wh(f,g,a,c)),f=g}}return n}function Ix(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 Ch(o,t,e){return(e[0]-t[0])*(o[1]-t[1])-(e[1]-t[1])*(o[0]-t[0])}function wh(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 Px(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 Rx(o,t){let e=o.block.create("graphic");return o.block.setShape(e,o.block.createShape("rect")),ss(o,e,t),Ei(o,e,t),t.rotation&&Math.abs(t.rotation)>1e-6&&o.block.setRotation(e,t.rotation),e}function Oh(o,t){let e=o.block.create("graphic"),n=Ti(o,t.d,t.width,t.height);return o.block.setShape(e,n),o.block.setFill(e,Mh(o)),Ei(o,e,t),e}function Ox(o,t,e,n,r){let a=o.block.create("graphic"),c=Ti(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",ll(n)),o.block.setFill(a,g)}else o.block.setFill(a,Mh(o));return Ei(o,a,e),r!=null&&r!==1&&o.block.setOpacity(a,r),a}function Mh(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 Mx(o,t,e){let n={x:wi(o.block.getPositionX(t)),y:wi(o.block.getPositionY(t)),width:wi(o.block.getWidth(t)),height:wi(o.block.getHeight(t))},r={x:e.x,y:e.y,width:e.width,height:e.height},a=xh(r,n);if(!vh(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 Ei(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 wi(o){return o*72}function Lx(o,t){let e=t.rotation??0;if(Math.abs(e)<1e-6)return Dx(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,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 Fx(o.d,u)}function Fx(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++])),[y,v]=t(parseFloat(n[a++]),parseFloat(n[a++]));r.push(`C ${e(u)} ${e(f)} ${e(g)} ${e(m)} ${e(y)} ${e(v)}`);continue}r.push(c)}return r.join(" ")}function Dx(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++]),y=parseFloat(r[c++]),v=parseFloat(r[c++]),S=parseFloat(r[c++]);a.push(`C ${n(f+t)} ${n(g+e)} ${n(m+t)} ${n(y+e)} ${n(v+t)} ${n(S+e)}`);continue}a.push(u)}return a.join(" ")}function Bs(o){return!(o.width>0&&o.height>0)}function Eh(o,t){let e=Sh({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 ll(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 ki(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 Lh(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 _x={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 ki(t.resolver,{family:o.family,style:o.style,weight:o.weight},t.resolverCache,t.engine);return e?Lh(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"}}},rs=_x;var Nx={name:"embedded-subset",async resolve(o){return o.embeddedFont?{kind:"subset",embeddedFont:o.embeddedFont,provenance:"embedded-subset"}:{kind:"pass",reason:"no-embedded-font"}}},Gs=Nx;var Ux={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 ki(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"}}},Hs=Ux;var Fh=new WeakMap;function Dh(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 Bx(o,t){let e=Fh.get(o);e||(e=new Map,Fh.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:Za(t.weight),style:t.style??"normal"}]},u={uri:r,typeface:c};return e.set(t.postScriptName,u),u}function _h(o,t,e){let{uri:n,typeface:r}=Bx(o,e);typeof o.block.setFont=="function"&&o.block.setFont(t,n,r)}var Nh="ly.img.pdf-importer.text";function cl(o,t,e,n){if(typeof o.block?.setMetadata!="function")return;let r=(c,u)=>{if(!(u==null||u===""))try{o.block.setMetadata(t,`${Nh}.${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 Uh(o,t){return t?o.family?"resolver-miss":"no-font-family":"resolver-disabled"}var is={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)=>{Dh(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)=>{_h(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=Uh(o,!0);return cl(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 ul(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?Gx(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 Gx(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 js(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 Vs(o){return{cascade:o.cascade,emission:o.emission}}var hl=Vs({cascade:js([rs,Gs,Hs]),emission:is}),Bh=Vs({cascade:js([rs,Gs]),emission:is}),Gh=Vs({cascade:js([rs,Hs]),emission:is}),os=hl;async function Vh(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",o1),o.block.setBool(r,"stack/spacingInScreenspace",a1);let a=[],c={fontResolver:e.fontResolver??null,fontStrategy:e.fontStrategy??os,logger:e.logger??null,resolverCache:new Map,textRuns:a,substitutions:new Map,vectorPathFillRuleSupport:bh()},u=e.pageBounds??"trim";h1(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 y of g.blocks){let v=await $x(o,y,t,m,c);v!=null&&(o.block.appendChild(m,v),y.kind===se.IMAGE&&Ah(o,v,y,{logger:c.logger??void 0}))}Vx(o,m,g,u)}return await Hx(o,a.map(({id:f})=>f)),l1(o,a,c),jx(c),n}async function Hx(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 y of m)n(y)&&c.delete(y);c.size===0&&f()});for(let m of r)n(m)&&c.delete(m);c.size===0&&f()})}function jx(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 Vx(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 $x(o,t,e,n,r){switch(t.kind){case se.IMAGE:return zx(o,t,n,r);case se.VECTOR_PATH:return $h(o,t,n,r);case se.TEXT_OUTLINE:case se.TEXT_RUN:return await Xx(o,t,e,r);default:return r?.logger?.emit?.("BLOCK_KIND_UNKNOWN",{kind:t.kind}),null}}function zx(o,t,e,n){if(t.clips?.length){let c=kh(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:fl(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 Xh(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),zh(o,r,t.blendMode,n),r}function $h(o,t,e,n){if(t.clips?.length){let c=Ih(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:fl(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")Wx(o,r,t,n);else{let u=o.block.createFill("color");o.block.setColor(u,"fill/color/value",$s(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,$s(t.stroke,n,t,"vector path stroke")),t.strokeWidth!=null&&o.block.setStrokeWidth(r,zt(t.strokeWidth))),Xh(o,r,t),t.opacity!=null&&t.opacity!==1&&o.block.setOpacity(r,t.opacity),zh(o,r,t.blendMode,n),r}function zh(o,t,e,n){let r=Ai(e,n?.logger??void 0);r!=null&&(typeof o.block.supportsBlendMode=="function"&&!o.block.supportsBlendMode(t)||o.block.setBlendMode(t,r))}function Wx(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:$s(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 Xx(o,t,e,n){let r=ul(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=Yx(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 Yx(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:Qx(o,e.source,{typeface:n.typeface,font:n.font},t)}}}async function Kx(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 Jx(o,a,n),e(o,a),qx(o,a,t,r),t.rotation&&o.block.setRotation(a,t.rotation),a}async function Qx(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 Kx(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,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 Jx(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 qx(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),Wh(o,t,e,n);let r=e.opacity;r!=null&&r!==1&&o.block.setOpacity(t,r)}function Wh(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=$s(a.fill,n,e,"text");o.block.setTextColor(t,c,a.from,a.to)}}else if(e.fill){let a=$s(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 t1=!0,e1=-.01,Hh=-.15,n1=15,s1=1.05,jh=1.5,r1=9,i1=.7,o1=32,a1=!0;function l1(o,t,e){if(t1&&typeof o.block.getTextVisibleLineCount=="function")for(let{id:n,ir:r}of t)c1(o,n,r,e)}function c1(o,t,e,n){let r=e.width;if(r<e.fontSize){let g=Math.max(1,e.text.length)*e.fontSize*i1;g>r&&(r=g,o.block.setWidth(t,zt(r)))}let a=dl(o,t,e,n);if(a<=1)return;let c=0;for(let g=0;g<n1&&(c=Math.max(Hh,c+e1),o.block.setFloat(t,"text/letterSpacing",c),a=dl(o,t,e,n),!(a<=1||c<=Hh));g++);if(a<=1)return;let u=zt(r),f=1;for(let g=0;g<r1&&(f=Math.min(jh,f*s1),o.block.setWidth(t,u*f),a=dl(o,t,e,n),!(a<=1||f>=jh));g++);a>1&&n?.logger?.emit?.("TEXT_OVERFLOW_AFTER_AUTOSIZE",{text:u1(e.text,30),overflowLines:a-1})}function dl(o,t,e,n){typeof o.block.replaceText=="function"?o.block.replaceText(t,e.text):o.block.setString(t,"text/text",e.text),Wh(o,t,e,n);try{return o.block.getTextVisibleLineCount(t)}catch{return 1}}function u1(o,t){return o.length>t?o.slice(0,t-1)+"\u2026":o}function Xh(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 h1(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 $s(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:fl(t),elementLabel:d1(n),space:r.space,color:Qu(o),bbox:Me(e),page:t?.pageIndex,element:n??null}),{r:0,g:0,b:0,a:1})}function fl(o){return o?.pageIndex!=null?`Page ${o.pageIndex}: `:""}function d1(o){return o?`${o} `:""}function Zh(o){let t=[],e=null,n=()=>{e&&(e.runs.length===1?t.push(e.runs[0]):t.push(v1(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];m1(c,a)?e.runs.push(a):(n(),e={runs:[a]})}return n(),t}var f1=.15,p1=.5,g1=.5;function m1(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?y1(o,t):b1(o,t)}function y1(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,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)>p1*e||w<-g1*e||w>f1*e)}function b1(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 v1(o){let t=o[0],e=Math.min(...o.map(y=>y.x)),n=Math.min(...o.map(y=>y.y)),r=Math.max(...o.map(y=>y.x+y.width)),a=Math.max(...o.map(y=>y.y+y.height)),c="",u=[];for(let y of o){let v=c.length;if(Array.isArray(y.colorSpans)&&y.colorSpans.length>0)for(let S of y.colorSpans)u.push({from:v+S.from,to:v+S.to,fill:S.fill??null});else u.push({from:v,to:v+y.text.length,fill:y.fill??null});c+=y.text}let f=[];for(let y of u){let v=f[f.length-1];v&&pl(v.fill,y.fill)&&v.to===y.from?v.to=y.to:f.push({...y})}let g=f.every(y=>pl(y.fill,f[0].fill)),m=x1(o);return{...t,x:e,y:n,width:r-e,height:a-n,text:c,...g?{}:{colorSpans:f},...m?{_buildGlyphOutline:m}:{}}}function x1(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=>Jh(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 S1=.5,Yh=.3;function Qh(o){let t=[],e=null,n=()=>{e&&(e.length===1?t.push(e[0]):t.push(T1(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];A1(c,a)?e.push(a):(n(),e=[a])}return n(),t}function A1(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")||!pl(o.fill,t.fill))return!1;let e=o.fontSize||10;if(Math.abs(o.y-t.y)>e*Yh||Math.abs(o.y+o.height-(t.y+t.height))>e*Yh)return!1;let n=o.x+o.width,r=t.x-n,a=e*S1;return!(r>a||r<-a)}function pl(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 T1(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=>Jh(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 Jh(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=C1(u);r.push(u);for(let g=0;g<f;g++){let m=Number(n[a+1+g*2]),y=Number(n[a+2+g*2]);if(!Number.isFinite(m)||!Number.isFinite(y)){r.push(n[a+1+g*2],n[a+2+g*2]);continue}r.push(Kh(m+t),Kh(y+e))}a+=1+f*2;continue}r.push(c),a++}return r.join(" ")}function C1(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 Kh(o){return`${Math.round(o*100)/100}`}var Ii=class o{engine;pdfBytes;fontResolver;fontStrategy;pageBounds;logger=new br(ou);constructor(t,e,n,r="trim",a=os){this.engine=t,this.pdfBytes=e,this.fontResolver=n??lo,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 mh(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=w1(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=Qh(r.blocks),r.blocks=Zh(r.blocks);return{scene:await Vh(t,e,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:this.pageBounds}),logger:this.logger}}getLogger(){return this.logger}};function w1(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}0&&(module.exports={Logger,PDFParser,addGfontsAssetLibrary,anyMatchResolverStage,assetLibraryStrategy,createFontCascade,createFontStrategy,defaultEmission,defaultStrategy,editableFirstStrategy,embeddedSubsetStage,exactFidelityStrategy,perfectMatchResolverStage});