@mercoa/react 0.0.54-rc8 → 0.0.54-rc9

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/index.umd.js CHANGED
@@ -179,7 +179,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
179
179
  ${o==="right"?"mercoa-text-right":""}
180
180
  ${o==="center"?"mercoa-text-center":""}
181
181
  mercoa-ring-inset mercoa-ring-gray-300 mercoa-border-0 mercoa-outline-0
182
- focus:mercoa-ring-1 focus:mercoa-ring-mercoa-primary focus:mercoa-border-0 focus:mercoa-outline-0 mercoa-overflow-hidden`}function Js({label:e,name:t}){return f.jsx("div",{className:"mercoa-flex mercoa-justify-between",children:f.jsx("label",{htmlFor:t,className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900 mercoa-whitespace-nowrap",children:e})})}function $e({type:e,label:t,onChange:r,onBlur:n,required:o,readOnly:a,ref:i,register:s,control:c,disabled:l,placeholder:u,optional:h,name:p,className:m,leadingIcon:g,trailingIcon:b,errors:_,dateOptions:y,min:x,max:O,step:S,noBorder:j,inputMask:P}){var B,W,K;const I=Q=>{const[re,de]=w.useState(0);return w.useLayoutEffect(()=>{var ge,H;de(((H=(ge=Q==null?void 0:Q.current)==null?void 0:ge.getBoundingClientRect())==null?void 0:H.width)??0)},[Q]),RU(Q,ge=>de(ge.contentRect.width)),re},M=w.useRef(null),E=I(M),D=Hr({leadingIcon:!!g,trailingIcon:!!b,noBorder:!!j,leadingIconSize:E<10?"sm":"md"});let A={type:e,placeholder:u,disabled:l,name:p,onChange:r,onBlur:n,readOnly:a,required:o,ref:i,className:D,min:x,max:O,step:S};s&&p&&(A={...A,...s(p,{setValueAs:Q=>Q!=null&&Q.trim?Q.trim():Q})});let z=f.jsx("input",{...A});e==="date"&&c&&p?z=f.jsx(am,{control:c,name:p,render:({field:Q})=>f.jsx(FW,{className:D,placeholderText:u,onChange:re=>Q.onChange(re),selected:Q.value?He(Q.value).toDate():null,minDate:y==null?void 0:y.minDate,maxDate:y==null?void 0:y.maxDate,filterDate:y==null?void 0:y.filterDate,readOnly:a,required:o})}):P&&c&&p?z=f.jsx(am,{control:c,name:p,render:({field:{onChange:Q,name:re,value:de}})=>f.jsx(wU,{format:P,allowEmptyFormatting:!0,mask:"_",name:re,value:de,onChange:Q,placeholder:u,className:D,readOnly:a})}):e==="currency"&&c&&p?z=f.jsx(am,{control:c,name:p,render:({field:{onChange:Q,name:re,value:de}})=>f.jsx(r$e,{decimalScale:2,thousandSeparator:!0,fixedDecimalScale:!0,name:re,value:de,onChange:Q,placeholder:u,className:D,readOnly:a})}):e==="currency"&&(e="text");const $=f.jsxs("div",{className:"mercoa-relative",children:[g&&f.jsx("div",{className:"mercoa-pointer-events-none mercoa-absolute mercoa-inset-y-0 mercoa-left-0 mercoa-flex mercoa-items-center mercoa-pl-2",ref:M,children:g}),z,b&&f.jsx("div",{className:"mercoa-absolute mercoa-inset-y-0 mercoa-right-0 mercoa-flex mercoa-items-center",children:b})]}),L=f.jsx(f.Fragment,{children:p&&((B=oX(_,p))==null?void 0:B.message)&&f.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(K=(W=oX(_,p))==null?void 0:W.message)==null?void 0:K.toString()})});return t?f.jsxs("div",{className:m,children:[f.jsx(Js,{label:t,name:p}),f.jsx("div",{className:"mercoa-mt-1",children:$}),L]}):m?f.jsxs("div",{className:m,children:[$,L]}):f.jsxs(f.Fragment,{children:[$,L]})}function PN({count:e,selected:t}){return f.jsxs("span",{className:`${t?"mercoa-bg-mercoa-primary mercoa-text-mercoa-primary-text-invert":"mercoa-bg-gray-100 mercoa-text-gray-800"} mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium`,children:[" ",e]})}async function LW(e,t){const r=[];let n=!0;for(;n;){const o=await(e==null?void 0:e.entity.user.find(t,{limit:100,startingAfter:r.length>0?r[r.length-1].id:void 0}));o?(r.push(...o.data),n=o.hasMore):n=!1}return r}function at({componentName:e}){return f.jsxs("div",{className:"mercoa-text-red-700",children:["ERROR: The ",f.jsx("pre",{className:"mercoa-inline mercoa-text-red-900",children:e})," component needs to be wrapped in a ",f.jsx("pre",{className:"mercoa-inline mercoa-text-red-900",children:"MercoaSession"}),". See"," ",f.jsx("a",{href:"https://docs.mercoa.com/sdks/react#usage",target:"_blank",className:"mercoa-text-blue-300 mercoa-underline",children:"documentation"})," ","for more information."]})}function zw(e,t){return typeof t=="string"?Number(t==null?void 0:t.replace(/,/g,"")):t}function Uw({name:e,saveAsStatus:t,addNewButton:r,form:n}){const[o,a]=w.useState(!1),{setValue:i,watch:s}=kt(),c=s("saveAsStatus");return w.useEffect(()=>{c==="CLOSE_INLINE_FORM"&&a(!1)},[c]),f.jsx("div",{className:"mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-border-gray-200",children:o?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mercoa-flex mercoa-flex-row-reverse -mercoa-mb-2",children:f.jsxs(Ue,{isEmphasized:!1,color:"gray",type:"button",size:"sm",hideOutline:!0,onClick:()=>{a(!1)},children:[f.jsx("span",{className:"mercoa-sr-only",children:"Close"}),f.jsx(gd,{className:"mercoa-size-5","aria-hidden":"true"})]})}),f.jsxs("div",{className:"mercoa-px-2 mercoa-pb-2",children:[n,f.jsxs(Ue,{size:"md",className:"mercoa-mt-2",isEmphasized:!0,onClick:()=>{i("saveAsStatus",t)},children:["Add ",e]})]})]}):f.jsx("button",{type:"button",onClick:()=>a(!0),className:"mercoa-w-full",children:r})})}function zu({onSelect:e,account:t,selected:r,icon:n,text:o}){return f.jsxs("div",{onClick:()=>{e&&e(t)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${e?"mercoa-cursor-pointer ":""}`,children:[f.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${r?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:n}),f.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[f.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),f.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:o}),f.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]})}var VW={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(d,function(){return function(r,n,o){r=r||{};var a=n.prototype,i={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function s(l,u,h,p){return a.fromToBase(l,u,h,p)}o.en.relativeTime=i,a.fromToBase=function(l,u,h,p,m){for(var g,b,_,y=h.$locale().relativeTime||i,x=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],O=x.length,S=0;S<O;S+=1){var j=x[S];j.d&&(g=p?o(l).diff(h,j.d,!0):h.diff(l,j.d,!0));var P=(r.rounding||Math.round)(Math.abs(g));if(_=g>0,P<=j.r||!j.r){P<=1&&S>0&&(j=x[S-1]);var I=y[j.l];m&&(P=m(""+P)),b=typeof I=="string"?I.replace("%d",P):I(P,u,j.l,_);break}}if(u)return b;var M=_?y.future:y.past;return typeof M=="function"?M(b):M.replace("%s",b)},a.to=function(l,u){return s(l,u,this,!0)},a.from=function(l,u){return s(l,u,this)};var c=function(l){return l.$u?o.utc():o()};a.toNow=function(l){return this.to(c(this),l)},a.fromNow=function(l){return this.from(c(this),l)}}})})(VW);var U3e=VW.exports;const N3e=mn(U3e);He.extend(N3e);function KW({readOnly:e,children:t}){var p;const r=Le(),{register:n,watch:o,setValue:a}=kt(),i=o("comments");function s(m){let g=f.jsx("div",{className:"mercoa-h-1.5 mercoa-w-1.5 mercoa-rounded-full mercoa-bg-gray-100 mercoa-ring-1 mercoa-ring-mercoa-primary"});return m.action==="APPROVE"?g=f.jsx(Fh,{className:"mercoa-size-5 mercoa-text-green-600 mercoa-bg-white","aria-hidden":"true"}):m.action==="REJECT"&&(g=f.jsx(Cl,{className:"mercoa-size-5 mercoa-text-red-600 mercoa-bg-white","aria-hidden":"true"})),g}const c={APPROVE:"approved",REJECT:"rejected",NONE:"created"},l=(i==null?void 0:i.filter(m=>m.text||m.associatedApprovalAction))??[],u={id:o("id"),createdAt:o("createdAt"),updatedAt:o("updatedAt"),user:o("creatorUser")??{id:"",name:"Email"},text:"",associatedApprovalAction:{action:G.Mercoa.ApproverAction.None,userId:((p=o("creatorUser"))==null?void 0:p.id)??""}};if(!r.client)return f.jsx(at,{componentName:"InvoiceComments"});const h=o("id")===void 0||o("id")==="new";return t?h?null:t({comments:[u,...l],addComment:m=>{a("commentText",m),a("saveAsStatus","COMMENT")}}):h?f.jsx("div",{className:"mercoa-mt-10"}):f.jsxs("div",{className:"mercoa-col-span-full",children:[f.jsx("ul",{role:"list",className:"mercoa-space-y-6 mercoa-ml-1",children:[u,...l].map((m,g)=>{var b,_;return f.jsxs("li",{className:"mercoa-relative mercoa-flex mercoa-gap-x-4",children:[f.jsx("div",{className:`${g===l.length?"mercoa-h-6":"-mercoa-bottom-6"} mercoa-absolute mercoa-left-0 mercoa-top-0 mercoa-flex mercoa-w-6 mercoa-justify-center`,children:f.jsx("div",{className:"mercoa-w-px mercoa-bg-gray-200"})}),m.text&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mercoa-relative mercoa-flex mercoa-h-8 mercoa-w-8 mercoa-flex-none mercoa-items-center mercoa-justify-center ",children:f.jsx(dC,{className:"mercoa-h-6 mercoa-w-6 mercoa-text-mercoa-primary mercoa-bg-gray-100 mercoa-rounded-full mercoa-p-1 -mercoa-ml-2"})}),f.jsxs("div",{className:"mercoa-flex-auto mercoa-rounded-mercoa mercoa-p-3 mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-200 mercoa-bg-white",children:[f.jsxs("div",{className:"mercoa-flex mercoa-justify-between mercoa-gap-x-4",children:[f.jsxs("div",{className:"mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:[f.jsx("span",{className:"mercoa-font-medium mercoa-text-gray-900",children:(b=m.user)==null?void 0:b.name})," commented"]}),f.jsx("time",{dateTime:He(m.createdAt).toISOString(),className:"mercoa-flex-none mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:He(m.createdAt).fromNow()})]}),f.jsx("p",{className:"mercoa-text-sm mercoa-leading-6 mercoa-text-gray-500",children:m.text})]})]}),m.associatedApprovalAction&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mercoa-relative mercoa-flex mercoa-h-6 mercoa-w-6 mercoa-flex-none mercoa-items-center mercoa-justify-center",children:s(m.associatedApprovalAction)}),f.jsxs("p",{className:"mercoa-flex-auto mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:[f.jsx("span",{className:"mercoa-font-medium mercoa-text-gray-900",children:(_=m.user)==null?void 0:_.name})," ",c[m.associatedApprovalAction.action]," the invoice."]}),f.jsx("time",{dateTime:He(m.createdAt).toISOString(),className:"mercoa-flex-none mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:He(m.createdAt).fromNow()})]})]},m.id)})}),!e&&f.jsx("div",{className:"mercoa-mt-6 mercoa-flex mercoa-gap-x-3",children:f.jsxs("div",{className:"mercoa-relative mercoa-flex-auto",children:[f.jsxs("div",{className:"mercoa-bg-white mercoa-overflow-hidden mercoa-rounded-mercoa mercoa-pb-12 mercoa-shadow-sm mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-300 focus:mercoa-ring-1 focus:mercoa-ring-mercoa-primary focus:mercoa-border-0 focus:mercoa-outline-0",children:[f.jsx("label",{htmlFor:"comment",className:"mercoa-sr-only",children:"Add your comment"}),f.jsx("textarea",{rows:2,...n("commentText"),className:"mercoa-block mercoa-w-full mercoa-resize-none mercoa-border-0 mercoa-bg-transparent mercoa-py-1.5 mercoa-px-2 mercoa-text-gray-900 placeholder:mercoa-text-gray-400 focus:mercoa-ring-0 sm:mercoa-text-sm sm:mercoa-leading-6 focus-visible:mercoa-outline-none",placeholder:"Add your comment..."})]}),f.jsxs("div",{className:"mercoa-absolute mercoa-inset-x-0 mercoa-bottom-0 mercoa-flex mercoa-justify-between mercoa-py-2 mercoa-pl-3 mercoa-pr-2",children:[f.jsx("div",{}),f.jsx("button",{onClick:()=>{a("saveAsStatus","COMMENT")},type:"submit",className:"mercoa-rounded-mercoa mercoa-bg-white mercoa-px-2.5 mercoa-py-1.5 mercoa-text-sm mercoa-font-semibold mercoa-text-gray-900 mercoa-shadow-sm mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-300 hover:mercoa-bg-gray-50",children:"Comment"})]})]})})]})}const HW="https://js.moov.io/v1",R3e=/^https:\/\/js\.moov\.io\/v1\/?(\?.*)?$/,XW="loadMoov.setLoadParameters was called but an existing Moov.js script already exists in the document; existing script parameters will be used",$3e=()=>{const e=document.querySelectorAll(`script[src^="${HW}"]`);for(let t=0;t<e.length;t++){const r=e[t];if(R3e.test(r.src))return r}return null},F3e=()=>{const e=document.createElement("script");e.src=HW;const t=document.head||document.body;if(!t)throw new Error("Expected document.body not to be null. Moov.js requires a <body> element.");return t.appendChild(e),e};let dT=null;const B3e=()=>(dT!==null||(dT=new Promise((e,t)=>{if(typeof window>"u"){e(null);return}if(window.Moov&&console.warn(XW),window.Moov){e(window.Moov);return}try{let r=$3e();r?console.warn(XW):r||(r=F3e()),r.addEventListener("load",()=>{window.Moov?e(window.Moov):t(new Error("Moov.js not available"))}),r.addEventListener("error",()=>{t(new Error("Failed to load Moov.js"))})}catch(r){t(r);return}})),dT),L3e=(e,t)=>e===null?null:e.apply(void 0,t),WW=Promise.resolve().then(()=>B3e());let kW=!1;WW.catch(e=>{kW||console.warn(e)});function V3e(...e){if(!window)throw new Error("@moovio/moov-js is intended for browser use only. For a server-side solution, try @moovio/node.");return kW=!0,WW.then(t=>L3e(t,e))}const GW=w.createContext({token:"",entityId:"",entity:void 0,user:void 0,users:[],customPaymentMethodSchemas:[],selectedInvoice:void 0,setSelectedInvoice:()=>{},client:void 0,refresh:async()=>{},refreshId:0,organization:void 0,moov:void 0,moovToken:void 0,moovAccountId:void 0,iframeOptions:void 0,setIframeOptions:()=>{},getNewToken:async e=>{},googleMapsApiKey:void 0,heightOffset:100,setHeightOffset:()=>{},debug:()=>{}}),K3e={success:"mercoa-bg-green-50 mercoa-text-green-700",error:"mercoa-bg-red-50 mercoa-text-red-700",info:"mercoa-bg-blue-50 mercoa-text-blue-700",warning:"mercoa-bg-yellow-50 mercoa-text-yellow-700",default:"mercoa-bg-indigo-600 mercoa-text-white",dark:"mercoa-bg-white-600 mercoa-font-gray-300"};function YW({children:e,entityId:t,entityUserId:r,token:n,endpoint:o,isAdmin:a,googleMapsApiKey:i,disableToastContainer:s,heightOffset:c,debug:l}){return f.jsxs(GW.Provider,{value:H3e({token:n,entityId:t,entityUserId:r,endpoint:o,isAdmin:a,googleMapsApiKey:i,heightOffset:c??100,debug:l??!1}),children:[s?f.jsx(f.Fragment,{}):f.jsx(sz,{toastClassName:u=>{const h=(u==null?void 0:u.type)||"default";return K3e[h]+"mercoa-relative mercoa-flex mercoa-p-1 mercoa-min-h-10 mercoa-rounded-mercoa mercoa-justify-between mercoa-overflow-hidden mercoa-cursor-pointer"},bodyClassName:()=>"mercoa-text-sm mercoa-font-medium mercoa-p-3 mercoa-m-0 mercoa-flex mercoa-items-center",position:"top-center",autoClose:3e3,hideProgressBar:!0,icon:({theme:u,type:h})=>{switch(h){case"error":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(Cl,{className:"mercoa-size-5 mercoa-text-red-400","aria-hidden":"true"})});case"info":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(cC,{className:"mercoa-size-5 mercoa-text-blue-400","aria-hidden":"true"})});case"success":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(Fh,{className:"mercoa-size-5 mercoa-text-green-400","aria-hidden":"true"})});case"warning":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(EF,{className:"mercoa-size-5 mercoa-text-yellow-400","aria-hidden":"true"})});case"default":return f.jsx("div",{className:"mercoa-flex-shrink-0"})}}}),e||f.jsx(D7,{token:n})]})}const Le=()=>w.useContext(GW);function H3e({token:e,entityId:t,entityUserId:r,endpoint:n,isAdmin:o,googleMapsApiKey:a,heightOffset:i,debug:s}){var H;const[c,l]=w.useState(),[u,h]=w.useState(),[p,m]=w.useState([]),[g,b]=w.useState(),[_,y]=w.useState(),[x,O]=w.useState(),[S,j]=w.useState(0),[P,I]=w.useState(),[M,E]=w.useState(),[D,A]=w.useState(),[z,$]=w.useState(e),[L,B]=w.useState(),[W,K]=w.useState(i);w.useEffect(()=>{K(i)},[i]);let Q="https://api.mercoa.com";const re=w.useMemo(()=>{if(typeof window<"u"&&window&&window.location&&window.location.href&&window.location.href.includes("staging.mercoa.com")&&(Q="https://api.staging.mercoa.com"),z&&z.indexOf(".")>-1)try{const R=ym(String(z));if(!R.organizationId)throw new Error("Invalid token");if(!R.entityId&&!R.userId&&!R.invoiceId&&!R.counterpartyId)throw new Error("Invalid token");if(Date.now()>=R.exp*1e3)throw new Error("Token expired")}catch(R){throw console.error(R),new Error("Invalid token")}return new G.MercoaClient({environment:n??Q,token:z})},[z]);async function de(){if(!z)return;let R=t;if(!R)try{const{entityId:Z}=ym(String(z));R=Z}catch(Z){console.error(Z)}if(R!=="undefined"){try{const Z=await re.organization.get({paymentMethods:!0,emailProvider:!0,externalAccountingSystemProvider:!0,colorScheme:!0,payeeOnboardingOptions:!0,payorOnboardingOptions:!0,metadataSchema:!0}),ae=await re.customPaymentMethodSchema.getAll();O(Z),b(ae)}catch(Z){console.error(Z),console.error("Failed to get organization data")}if(R!=="all"&&R){try{const ae=await re.entity.get(R);l(ae)}catch(ae){console.error(ae),console.error("Failed to get entity "+R)}let Z=r;if(!Z)try{const{userId:ae}=ym(String(z));Z=ae}catch(ae){console.error(ae)}try{const ae=await LW(re,R);m(ae),Z&&h(ae.find(k=>k.id===Z))}catch(ae){console.error(ae),console.error("Failed to get users for entity "+R)}!P&&!o&&re.entity.getToken(R,{}).then(async ae=>{$(ae);const{moov:k}=ym(String(ae));if(E(k.accountId),A(k.token),!(!k||!k.token||k.token==="sandbox"))try{const N=await V3e(k.token);N&&I(N)}catch(N){console.error(N)}})}}}async function ge(R){const Z=L||{options:{expiresIn:R??"12hr"}};if(Z.options||(Z.options={}),Z.options.expiresIn=R??"12hr",!(c!=null&&c.id))return;let ae="";u!=null&&u.id?ae=await re.entity.user.getToken(c.id,u.id,{...Z.options}):ae=await re.entity.getToken(c.id,{...Z.options}),$(ae)}return w.useEffect(()=>{if(!(x!=null&&x.colorScheme))return;const R=(le,U)=>{le=le.replace(/^#/,""),le.length===3&&(le=le[0]+le[0]+le[1]+le[1]+le[2]+le[2]);let[X,be,xe]=le.match(/.{2}/g);[X,be,xe]=[parseInt(X,16)+U,parseInt(be,16)+U,parseInt(xe,16)+U],X=Math.max(Math.min(255,X),0).toString(16),be=Math.max(Math.min(255,be),0).toString(16),xe=Math.max(Math.min(255,xe),0).toString(16);const Ce=(X.length<2?"0":"")+X,Te=(be.length<2?"0":"")+be,Ee=(xe.length<2?"0":"")+xe;return`#${Ce}${Te}${Ee}`},Z=x.colorScheme.logoBackgroundColor||"transparent",ae=x.colorScheme.primaryColor||"#4f46e5",k=R(ae,40),N=R(ae,-40);let q=ae,ie="#ffffff";ae==="#f8fafc"&&(q="#111827",ie="#111827"),document.documentElement.style.setProperty("--mercoa-logo-background",Z),document.documentElement.style.setProperty("--mercoa-primary",ae),document.documentElement.style.setProperty("--mercoa-primary-light",k),document.documentElement.style.setProperty("--mercoa-primary-dark",N),document.documentElement.style.setProperty("--mercoa-primary-text",q),document.documentElement.style.setProperty("--mercoa-primary-text-invert",ie),document.documentElement.style.setProperty("--mercoa-border-radius",(x.colorScheme.roundedCorners??6)+"px")},[(H=x==null?void 0:x.colorScheme)==null?void 0:H.primaryColor]),w.useEffect(()=>{I(void 0),de()},[e,t]),{refresh:de,refreshId:S,token:z,entityId:t??(c==null?void 0:c.id),entity:c,user:u,users:p,customPaymentMethodSchemas:g??[],selectedInvoice:_,setSelectedInvoice:y,client:re,organization:x,moov:P,moovAccountId:M,moovToken:D,iframeOptions:L,setIframeOptions:B,getNewToken:ge,googleMapsApiKey:a,setHeightOffset:K,heightOffset:W,debug:R=>{s&&console.log(R)}}}var qW={},JW={},EN={},QW={exports:{}};(function(e){e.exports=t,t.defunct=function(r){throw new Error("Unexpected character at index "+(this.index-1)+": "+r)};function t(r){typeof r!="function"&&(r=t.defunct);var n=[],o=[],a=0;this.state=0,this.index=0,this.input="",this.addRule=function(s,c,l){var u=s.global;if(!u){var h="g";s.multiline&&(h+="m"),s.ignoreCase&&(h+="i"),s=new RegExp(s.source,h)}return Object.prototype.toString.call(l)!=="[object Array]"&&(l=[0]),o.push({pattern:s,global:u,action:c,start:l}),this},this.setInput=function(s){return a=0,this.state=0,this.index=0,n.length=0,this.input=s,this},this.lex=function(){if(n.length)return n.shift();for(this.reject=!0;this.index<=this.input.length;){for(var s=i.call(this).splice(a),c=this.index;s.length&&this.reject;){var l=s.shift(),u=l.result,h=l.length;this.index+=h,this.reject=!1,a++;var p=l.action.apply(this,u);if(this.reject)this.index=u.index;else if(typeof p<"u")switch(Object.prototype.toString.call(p)){case"[object Array]":n=p.slice(1),p=p[0];default:return h&&(a=0),p}}var m=this.input;if(c<m.length)if(this.reject){a=0;var p=r.call(this,m.charAt(this.index++));if(typeof p<"u")return Object.prototype.toString.call(p)==="[object Array]"?(n=p.slice(1),p[0]):p}else this.index!==c&&(a=0),this.reject=!0;else if(s.length)this.reject=!0;else break}};function i(){for(var s=[],c=0,l=this.state,u=this.index,h=this.input,p=0,m=o.length;p<m;p++){var g=o[p],b=g.start,_=b.length;if(!_||b.indexOf(l)>=0||l%2&&_===1&&!b[0]){var y=g.pattern;y.lastIndex=u;var x=y.exec(h);if(x&&x.index===u){var O=s.push({result:x,action:g.action,length:x[0].length});for(g.global&&(c=O);--O>c;){var S=O-1;if(s[O].length>s[S].length){var j=s[O];s[O]=s[S],s[S]=j}}}}}return s}}})(QW);var X3e=QW.exports,TN={exports:{}};/*! http://mths.be/fromcodepoint v0.2.1 by @mathias */String.fromCodePoint||function(){var e=function(){try{var o={},a=Object.defineProperty,i=a(o,o,o)&&a}catch{}return i}(),t=String.fromCharCode,r=Math.floor,n=function(o){var a=16384,i=[],s,c,l=-1,u=arguments.length;if(!u)return"";for(var h="";++l<u;){var p=Number(arguments[l]);if(!isFinite(p)||p<0||p>1114111||r(p)!=p)throw RangeError("Invalid code point: "+p);p<=65535?i.push(p):(p-=65536,s=(p>>10)+55296,c=p%1024+56320,i.push(s,c)),(l+1==u||i.length>a)&&(h+=t.apply(null,i),i.length=0)}return h};e?e(String,"fromCodePoint",{value:n,configurable:!0,writable:!0}):String.fromCodePoint=n}(),function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=/\\(u\{([0-9A-Fa-f]+)\}|u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([1-7][0-7]{0,2}|[0-7]{2,3})|(['"tbrnfv0\\]))|\\U([0-9A-Fa-f]{8})/g,n={0:"\0",b:"\b",f:"\f",n:`
182
+ focus:mercoa-ring-1 focus:mercoa-ring-mercoa-primary focus:mercoa-border-0 focus:mercoa-outline-0 mercoa-overflow-hidden`}function Js({label:e,name:t}){return f.jsx("div",{className:"mercoa-flex mercoa-justify-between",children:f.jsx("label",{htmlFor:t,className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900 mercoa-whitespace-nowrap",children:e})})}function $e({type:e,label:t,onChange:r,onBlur:n,required:o,readOnly:a,ref:i,register:s,control:c,disabled:l,placeholder:u,optional:h,name:p,className:m,leadingIcon:g,trailingIcon:b,errors:_,dateOptions:y,min:x,max:O,step:S,noBorder:j,inputMask:P}){var B,W,K;const I=Q=>{const[re,de]=w.useState(0);return w.useLayoutEffect(()=>{var ge,H;de(((H=(ge=Q==null?void 0:Q.current)==null?void 0:ge.getBoundingClientRect())==null?void 0:H.width)??0)},[Q]),RU(Q,ge=>de(ge.contentRect.width)),re},M=w.useRef(null),E=I(M),D=Hr({leadingIcon:!!g,trailingIcon:!!b,noBorder:!!j,leadingIconSize:E<10?"sm":"md"});let A={type:e,placeholder:u,disabled:l,name:p,onChange:r,onBlur:n,readOnly:a,required:o,ref:i,className:D,min:x,max:O,step:S};s&&p&&(A={...A,...s(p,{setValueAs:Q=>Q!=null&&Q.trim?Q.trim():Q})});let z=f.jsx("input",{...A});e==="date"&&c&&p?z=f.jsx(am,{control:c,name:p,render:({field:Q})=>f.jsx(FW,{className:D,placeholderText:u,onChange:re=>Q.onChange(re),selected:Q.value?He(Q.value).toDate():null,minDate:y==null?void 0:y.minDate,maxDate:y==null?void 0:y.maxDate,filterDate:y==null?void 0:y.filterDate,readOnly:a,required:o})}):P&&c&&p?z=f.jsx(am,{control:c,name:p,render:({field:{onChange:Q,name:re,value:de}})=>f.jsx(wU,{format:P,allowEmptyFormatting:!0,mask:"_",name:re,value:de,onChange:Q,placeholder:u,className:D,readOnly:a})}):e==="currency"&&c&&p?z=f.jsx(am,{control:c,name:p,render:({field:{onChange:Q,name:re,value:de}})=>f.jsx(r$e,{decimalScale:2,thousandSeparator:!0,fixedDecimalScale:!0,name:re,value:de,onChange:Q,placeholder:u,className:D,readOnly:a})}):e==="currency"&&(e="text");const $=f.jsxs("div",{className:"mercoa-relative",children:[g&&f.jsx("div",{className:"mercoa-pointer-events-none mercoa-absolute mercoa-inset-y-0 mercoa-left-0 mercoa-flex mercoa-items-center mercoa-pl-2",ref:M,children:g}),z,b&&f.jsx("div",{className:"mercoa-absolute mercoa-inset-y-0 mercoa-right-0 mercoa-flex mercoa-items-center",children:b})]}),L=f.jsx(f.Fragment,{children:p&&((B=oX(_,p))==null?void 0:B.message)&&f.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(K=(W=oX(_,p))==null?void 0:W.message)==null?void 0:K.toString()})});return t?f.jsxs("div",{className:m,children:[f.jsx(Js,{label:t,name:p}),f.jsx("div",{className:"mercoa-mt-1",children:$}),L]}):m?f.jsxs("div",{className:m,children:[$,L]}):f.jsxs(f.Fragment,{children:[$,L]})}function PN({count:e,selected:t}){return f.jsxs("span",{className:`${t?"mercoa-bg-mercoa-primary mercoa-text-mercoa-primary-text-invert":"mercoa-bg-gray-100 mercoa-text-gray-800"} mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium`,children:[" ",e]})}async function LW(e,t){const r=[];let n=!0;for(;n;){const o=await(e==null?void 0:e.entity.user.find(t,{limit:100,startingAfter:r.length>0?r[r.length-1].id:void 0}));o?(r.push(...o.data),n=o.hasMore):n=!1}return r}function at({componentName:e}){return f.jsxs("div",{className:"mercoa-text-red-700",children:["ERROR: The ",f.jsx("pre",{className:"mercoa-inline mercoa-text-red-900",children:e})," component needs to be wrapped in a ",f.jsx("pre",{className:"mercoa-inline mercoa-text-red-900",children:"MercoaSession"}),". See"," ",f.jsx("a",{href:"https://docs.mercoa.com/sdks/react#usage",target:"_blank",className:"mercoa-text-blue-300 mercoa-underline",children:"documentation"})," ","for more information."]})}function zw(e,t){return typeof t=="string"?Number(t==null?void 0:t.replace(/,/g,"")):t}function Uw({name:e,saveAsStatus:t,addNewButton:r,form:n}){const[o,a]=w.useState(!1),{setValue:i,watch:s}=kt(),c=s("saveAsStatus");return w.useEffect(()=>{c==="CLOSE_INLINE_FORM"&&a(!1)},[c]),f.jsx("div",{className:"mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-border-gray-200",children:o?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mercoa-flex mercoa-flex-row-reverse -mercoa-mb-2",children:f.jsxs(Ue,{isEmphasized:!1,color:"gray",type:"button",size:"sm",hideOutline:!0,onClick:()=>{a(!1)},children:[f.jsx("span",{className:"mercoa-sr-only",children:"Close"}),f.jsx(gd,{className:"mercoa-size-5","aria-hidden":"true"})]})}),f.jsxs("div",{className:"mercoa-px-2 mercoa-pb-2",children:[n,f.jsxs(Ue,{size:"md",className:"mercoa-mt-2",isEmphasized:!0,onClick:()=>{i("saveAsStatus",t)},children:["Add ",e]})]})]}):f.jsx("button",{type:"button",onClick:()=>a(!0),className:"mercoa-w-full",children:r})})}function zu({onSelect:e,account:t,selected:r,icon:n,text:o}){return f.jsxs("div",{onClick:()=>{e&&e(t)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${e?"mercoa-cursor-pointer ":""}`,children:[f.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${r?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:n}),f.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[f.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),f.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:o}),f.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]})}var VW={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(d,function(){return function(r,n,o){r=r||{};var a=n.prototype,i={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function s(l,u,h,p){return a.fromToBase(l,u,h,p)}o.en.relativeTime=i,a.fromToBase=function(l,u,h,p,m){for(var g,b,_,y=h.$locale().relativeTime||i,x=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],O=x.length,S=0;S<O;S+=1){var j=x[S];j.d&&(g=p?o(l).diff(h,j.d,!0):h.diff(l,j.d,!0));var P=(r.rounding||Math.round)(Math.abs(g));if(_=g>0,P<=j.r||!j.r){P<=1&&S>0&&(j=x[S-1]);var I=y[j.l];m&&(P=m(""+P)),b=typeof I=="string"?I.replace("%d",P):I(P,u,j.l,_);break}}if(u)return b;var M=_?y.future:y.past;return typeof M=="function"?M(b):M.replace("%s",b)},a.to=function(l,u){return s(l,u,this,!0)},a.from=function(l,u){return s(l,u,this)};var c=function(l){return l.$u?o.utc():o()};a.toNow=function(l){return this.to(c(this),l)},a.fromNow=function(l){return this.from(c(this),l)}}})})(VW);var U3e=VW.exports;const N3e=mn(U3e);He.extend(N3e);function KW({readOnly:e,children:t}){var p;const r=Le(),{register:n,watch:o,setValue:a}=kt(),i=o("comments");function s(m){let g=f.jsx("div",{className:"mercoa-h-1.5 mercoa-w-1.5 mercoa-rounded-full mercoa-bg-gray-100 mercoa-ring-1 mercoa-ring-mercoa-primary"});return m.action==="APPROVE"?g=f.jsx(Fh,{className:"mercoa-size-5 mercoa-text-green-600 mercoa-bg-white","aria-hidden":"true"}):m.action==="REJECT"&&(g=f.jsx(Cl,{className:"mercoa-size-5 mercoa-text-red-600 mercoa-bg-white","aria-hidden":"true"})),g}const c={APPROVE:"approved",REJECT:"rejected",NONE:"created"},l=(i==null?void 0:i.filter(m=>m.text||m.associatedApprovalAction))??[],u={id:o("id"),createdAt:o("createdAt"),updatedAt:o("updatedAt"),user:o("creatorUser")??{id:"",name:"Email"},text:"",associatedApprovalAction:{action:G.Mercoa.ApproverAction.None,userId:((p=o("creatorUser"))==null?void 0:p.id)??""}};if(!r.client)return f.jsx(at,{componentName:"InvoiceComments"});const h=o("id")===void 0||o("id")==="new";return t?h?null:t({comments:[u,...l],addComment:m=>{a("commentText",m),a("saveAsStatus","COMMENT")}}):h?f.jsx("div",{className:"mercoa-mt-10"}):f.jsxs("div",{className:"mercoa-col-span-full",children:[f.jsx("ul",{role:"list",className:"mercoa-space-y-6 mercoa-ml-1",children:[u,...l].map((m,g)=>{var b,_;return f.jsxs("li",{className:"mercoa-relative mercoa-flex mercoa-gap-x-4",children:[f.jsx("div",{className:`${g===l.length?"mercoa-h-6":"-mercoa-bottom-6"} mercoa-absolute mercoa-left-0 mercoa-top-0 mercoa-flex mercoa-w-6 mercoa-justify-center`,children:f.jsx("div",{className:"mercoa-w-px mercoa-bg-gray-200"})}),m.text&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mercoa-relative mercoa-flex mercoa-h-8 mercoa-w-8 mercoa-flex-none mercoa-items-center mercoa-justify-center ",children:f.jsx(dC,{className:"mercoa-h-6 mercoa-w-6 mercoa-text-mercoa-primary mercoa-bg-gray-100 mercoa-rounded-full mercoa-p-1 -mercoa-ml-2"})}),f.jsxs("div",{className:"mercoa-flex-auto mercoa-rounded-mercoa mercoa-p-3 mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-200 mercoa-bg-white",children:[f.jsxs("div",{className:"mercoa-flex mercoa-justify-between mercoa-gap-x-4",children:[f.jsxs("div",{className:"mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:[f.jsx("span",{className:"mercoa-font-medium mercoa-text-gray-900",children:(b=m.user)==null?void 0:b.name})," commented"]}),f.jsx("time",{dateTime:He(m.createdAt).toISOString(),className:"mercoa-flex-none mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:He(m.createdAt).fromNow()})]}),f.jsx("p",{className:"mercoa-text-sm mercoa-leading-6 mercoa-text-gray-500",children:m.text})]})]}),m.associatedApprovalAction&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mercoa-relative mercoa-flex mercoa-h-6 mercoa-w-6 mercoa-flex-none mercoa-items-center mercoa-justify-center",children:s(m.associatedApprovalAction)}),f.jsxs("p",{className:"mercoa-flex-auto mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:[f.jsx("span",{className:"mercoa-font-medium mercoa-text-gray-900",children:(_=m.user)==null?void 0:_.name})," ",c[m.associatedApprovalAction.action]," the invoice."]}),f.jsx("time",{dateTime:He(m.createdAt).toISOString(),className:"mercoa-flex-none mercoa-py-0.5 mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:He(m.createdAt).fromNow()})]})]},m.id)})}),!e&&f.jsx("div",{className:"mercoa-mt-6 mercoa-flex mercoa-gap-x-3",children:f.jsxs("div",{className:"mercoa-relative mercoa-flex-auto",children:[f.jsxs("div",{className:"mercoa-bg-white mercoa-overflow-hidden mercoa-rounded-mercoa mercoa-pb-12 mercoa-shadow-sm mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-300 focus:mercoa-ring-1 focus:mercoa-ring-mercoa-primary focus:mercoa-border-0 focus:mercoa-outline-0",children:[f.jsx("label",{htmlFor:"comment",className:"mercoa-sr-only",children:"Add your comment"}),f.jsx("textarea",{rows:2,...n("commentText"),className:"mercoa-block mercoa-w-full mercoa-resize-none mercoa-border-0 mercoa-bg-transparent mercoa-py-1.5 mercoa-px-2 mercoa-text-gray-900 placeholder:mercoa-text-gray-400 focus:mercoa-ring-0 sm:mercoa-text-sm sm:mercoa-leading-6 focus-visible:mercoa-outline-none",placeholder:"Add your comment..."})]}),f.jsxs("div",{className:"mercoa-absolute mercoa-inset-x-0 mercoa-bottom-0 mercoa-flex mercoa-justify-between mercoa-py-2 mercoa-pl-3 mercoa-pr-2",children:[f.jsx("div",{}),f.jsx("button",{onClick:()=>{a("saveAsStatus","COMMENT")},type:"submit",className:"mercoa-rounded-mercoa mercoa-bg-white mercoa-px-2.5 mercoa-py-1.5 mercoa-text-sm mercoa-font-semibold mercoa-text-gray-900 mercoa-shadow-sm mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-300 hover:mercoa-bg-gray-50",children:"Comment"})]})]})})]})}const HW="https://js.moov.io/v1",R3e=/^https:\/\/js\.moov\.io\/v1\/?(\?.*)?$/,XW="loadMoov.setLoadParameters was called but an existing Moov.js script already exists in the document; existing script parameters will be used",$3e=()=>{const e=document.querySelectorAll(`script[src^="${HW}"]`);for(let t=0;t<e.length;t++){const r=e[t];if(R3e.test(r.src))return r}return null},F3e=()=>{const e=document.createElement("script");e.src=HW;const t=document.head||document.body;if(!t)throw new Error("Expected document.body not to be null. Moov.js requires a <body> element.");return t.appendChild(e),e};let dT=null;const B3e=()=>(dT!==null||(dT=new Promise((e,t)=>{if(typeof window>"u"){e(null);return}if(window.Moov&&console.warn(XW),window.Moov){e(window.Moov);return}try{let r=$3e();r?console.warn(XW):r||(r=F3e()),r.addEventListener("load",()=>{window.Moov?e(window.Moov):t(new Error("Moov.js not available"))}),r.addEventListener("error",()=>{t(new Error("Failed to load Moov.js"))})}catch(r){t(r);return}})),dT),L3e=(e,t)=>e===null?null:e.apply(void 0,t),WW=Promise.resolve().then(()=>B3e());let kW=!1;WW.catch(e=>{kW||console.warn(e)});function V3e(...e){if(!window)throw new Error("@moovio/moov-js is intended for browser use only. For a server-side solution, try @moovio/node.");return kW=!0,WW.then(t=>L3e(t,e))}const GW=w.createContext({token:"",entityId:"",entity:void 0,user:void 0,users:[],customPaymentMethodSchemas:[],selectedInvoice:void 0,setSelectedInvoice:()=>{},client:void 0,refresh:async()=>{},refreshId:0,organization:void 0,moov:void 0,moovToken:void 0,moovAccountId:void 0,iframeOptions:void 0,setIframeOptions:()=>{},getNewToken:async e=>{},googleMapsApiKey:void 0,heightOffset:100,setHeightOffset:()=>{},debug:()=>{}}),K3e={success:"mercoa-bg-green-50 mercoa-text-green-700",error:"mercoa-bg-red-50 mercoa-text-red-700",info:"mercoa-bg-blue-50 mercoa-text-blue-700",warning:"mercoa-bg-yellow-50 mercoa-text-yellow-700",default:"mercoa-bg-indigo-600 mercoa-text-white",dark:"mercoa-bg-white-600 mercoa-font-gray-300"};function YW({children:e,entityId:t,entityUserId:r,token:n,endpoint:o,isAdmin:a,googleMapsApiKey:i,disableToastContainer:s,heightOffset:c,debug:l}){return f.jsxs(GW.Provider,{value:H3e({token:n,entityId:t,entityUserId:r,endpoint:o,isAdmin:a,googleMapsApiKey:i,heightOffset:c??100,debug:l??!1}),children:[s?f.jsx(f.Fragment,{}):f.jsx(sz,{toastClassName:u=>{const h=(u==null?void 0:u.type)||"default";return`${K3e[h]} mercoa-relative mercoa-flex mercoa-p-1 mercoa-min-h-10 mercoa-rounded-mercoa mercoa-justify-between mercoa-overflow-hidden mercoa-cursor-pointer`},bodyClassName:()=>"mercoa-text-sm mercoa-font-medium mercoa-p-3 mercoa-m-0 mercoa-flex mercoa-items-center",position:"top-center",autoClose:3e3,hideProgressBar:!0,icon:({theme:u,type:h})=>{switch(h){case"error":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(Cl,{className:"mercoa-size-5 mercoa-text-red-400","aria-hidden":"true"})});case"info":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(cC,{className:"mercoa-size-5 mercoa-text-blue-400","aria-hidden":"true"})});case"success":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(Fh,{className:"mercoa-size-5 mercoa-text-green-400","aria-hidden":"true"})});case"warning":return f.jsx("div",{className:"mercoa-flex-shrink-0",children:f.jsx(EF,{className:"mercoa-size-5 mercoa-text-yellow-400","aria-hidden":"true"})});case"default":return f.jsx("div",{className:"mercoa-flex-shrink-0"})}}}),e||f.jsx(D7,{token:n})]})}const Le=()=>w.useContext(GW);function H3e({token:e,entityId:t,entityUserId:r,endpoint:n,isAdmin:o,googleMapsApiKey:a,heightOffset:i,debug:s}){var H;const[c,l]=w.useState(),[u,h]=w.useState(),[p,m]=w.useState([]),[g,b]=w.useState(),[_,y]=w.useState(),[x,O]=w.useState(),[S,j]=w.useState(0),[P,I]=w.useState(),[M,E]=w.useState(),[D,A]=w.useState(),[z,$]=w.useState(e),[L,B]=w.useState(),[W,K]=w.useState(i);w.useEffect(()=>{K(i)},[i]);let Q="https://api.mercoa.com";const re=w.useMemo(()=>{if(typeof window<"u"&&window&&window.location&&window.location.href&&window.location.href.includes("staging.mercoa.com")&&(Q="https://api.staging.mercoa.com"),z&&z.indexOf(".")>-1)try{const R=ym(String(z));if(!R.organizationId)throw new Error("Invalid token");if(!R.entityId&&!R.userId&&!R.invoiceId&&!R.counterpartyId)throw new Error("Invalid token");if(Date.now()>=R.exp*1e3)throw new Error("Token expired")}catch(R){throw console.error(R),new Error("Invalid token")}return new G.MercoaClient({environment:n??Q,token:z})},[z]);async function de(){if(!z)return;let R=t;if(!R)try{const{entityId:Z}=ym(String(z));R=Z}catch(Z){console.error(Z)}if(R!=="undefined"){try{const Z=await re.organization.get({paymentMethods:!0,emailProvider:!0,externalAccountingSystemProvider:!0,colorScheme:!0,payeeOnboardingOptions:!0,payorOnboardingOptions:!0,metadataSchema:!0}),ae=await re.customPaymentMethodSchema.getAll();O(Z),b(ae)}catch(Z){console.error(Z),console.error("Failed to get organization data")}if(R!=="all"&&R){try{const ae=await re.entity.get(R);l(ae)}catch(ae){console.error(ae),console.error("Failed to get entity "+R)}let Z=r;if(!Z)try{const{userId:ae}=ym(String(z));Z=ae}catch(ae){console.error(ae)}try{const ae=await LW(re,R);m(ae),Z&&h(ae.find(k=>k.id===Z))}catch(ae){console.error(ae),console.error("Failed to get users for entity "+R)}!P&&!o&&re.entity.getToken(R,{}).then(async ae=>{$(ae);const{moov:k}=ym(String(ae));if(E(k.accountId),A(k.token),!(!k||!k.token||k.token==="sandbox"))try{const N=await V3e(k.token);N&&I(N)}catch(N){console.error(N)}})}}}async function ge(R){const Z=L||{options:{expiresIn:R??"12hr"}};if(Z.options||(Z.options={}),Z.options.expiresIn=R??"12hr",!(c!=null&&c.id))return;let ae="";u!=null&&u.id?ae=await re.entity.user.getToken(c.id,u.id,{...Z.options}):ae=await re.entity.getToken(c.id,{...Z.options}),$(ae)}return w.useEffect(()=>{if(!(x!=null&&x.colorScheme))return;const R=(le,U)=>{le=le.replace(/^#/,""),le.length===3&&(le=le[0]+le[0]+le[1]+le[1]+le[2]+le[2]);let[X,be,xe]=le.match(/.{2}/g);[X,be,xe]=[parseInt(X,16)+U,parseInt(be,16)+U,parseInt(xe,16)+U],X=Math.max(Math.min(255,X),0).toString(16),be=Math.max(Math.min(255,be),0).toString(16),xe=Math.max(Math.min(255,xe),0).toString(16);const Ce=(X.length<2?"0":"")+X,Te=(be.length<2?"0":"")+be,Ee=(xe.length<2?"0":"")+xe;return`#${Ce}${Te}${Ee}`},Z=x.colorScheme.logoBackgroundColor||"transparent",ae=x.colorScheme.primaryColor||"#4f46e5",k=R(ae,40),N=R(ae,-40);let q=ae,ie="#ffffff";ae==="#f8fafc"&&(q="#111827",ie="#111827"),document.documentElement.style.setProperty("--mercoa-logo-background",Z),document.documentElement.style.setProperty("--mercoa-primary",ae),document.documentElement.style.setProperty("--mercoa-primary-light",k),document.documentElement.style.setProperty("--mercoa-primary-dark",N),document.documentElement.style.setProperty("--mercoa-primary-text",q),document.documentElement.style.setProperty("--mercoa-primary-text-invert",ie),document.documentElement.style.setProperty("--mercoa-border-radius",(x.colorScheme.roundedCorners??6)+"px")},[(H=x==null?void 0:x.colorScheme)==null?void 0:H.primaryColor]),w.useEffect(()=>{I(void 0),de()},[e,t]),{refresh:de,refreshId:S,token:z,entityId:t??(c==null?void 0:c.id),entity:c,user:u,users:p,customPaymentMethodSchemas:g??[],selectedInvoice:_,setSelectedInvoice:y,client:re,organization:x,moov:P,moovAccountId:M,moovToken:D,iframeOptions:L,setIframeOptions:B,getNewToken:ge,googleMapsApiKey:a,setHeightOffset:K,heightOffset:W,debug:R=>{s&&console.log(R)}}}var qW={},JW={},EN={},QW={exports:{}};(function(e){e.exports=t,t.defunct=function(r){throw new Error("Unexpected character at index "+(this.index-1)+": "+r)};function t(r){typeof r!="function"&&(r=t.defunct);var n=[],o=[],a=0;this.state=0,this.index=0,this.input="",this.addRule=function(s,c,l){var u=s.global;if(!u){var h="g";s.multiline&&(h+="m"),s.ignoreCase&&(h+="i"),s=new RegExp(s.source,h)}return Object.prototype.toString.call(l)!=="[object Array]"&&(l=[0]),o.push({pattern:s,global:u,action:c,start:l}),this},this.setInput=function(s){return a=0,this.state=0,this.index=0,n.length=0,this.input=s,this},this.lex=function(){if(n.length)return n.shift();for(this.reject=!0;this.index<=this.input.length;){for(var s=i.call(this).splice(a),c=this.index;s.length&&this.reject;){var l=s.shift(),u=l.result,h=l.length;this.index+=h,this.reject=!1,a++;var p=l.action.apply(this,u);if(this.reject)this.index=u.index;else if(typeof p<"u")switch(Object.prototype.toString.call(p)){case"[object Array]":n=p.slice(1),p=p[0];default:return h&&(a=0),p}}var m=this.input;if(c<m.length)if(this.reject){a=0;var p=r.call(this,m.charAt(this.index++));if(typeof p<"u")return Object.prototype.toString.call(p)==="[object Array]"?(n=p.slice(1),p[0]):p}else this.index!==c&&(a=0),this.reject=!0;else if(s.length)this.reject=!0;else break}};function i(){for(var s=[],c=0,l=this.state,u=this.index,h=this.input,p=0,m=o.length;p<m;p++){var g=o[p],b=g.start,_=b.length;if(!_||b.indexOf(l)>=0||l%2&&_===1&&!b[0]){var y=g.pattern;y.lastIndex=u;var x=y.exec(h);if(x&&x.index===u){var O=s.push({result:x,action:g.action,length:x[0].length});for(g.global&&(c=O);--O>c;){var S=O-1;if(s[O].length>s[S].length){var j=s[O];s[O]=s[S],s[S]=j}}}}}return s}}})(QW);var X3e=QW.exports,TN={exports:{}};/*! http://mths.be/fromcodepoint v0.2.1 by @mathias */String.fromCodePoint||function(){var e=function(){try{var o={},a=Object.defineProperty,i=a(o,o,o)&&a}catch{}return i}(),t=String.fromCharCode,r=Math.floor,n=function(o){var a=16384,i=[],s,c,l=-1,u=arguments.length;if(!u)return"";for(var h="";++l<u;){var p=Number(arguments[l]);if(!isFinite(p)||p<0||p>1114111||r(p)!=p)throw RangeError("Invalid code point: "+p);p<=65535?i.push(p):(p-=65536,s=(p>>10)+55296,c=p%1024+56320,i.push(s,c)),(l+1==u||i.length>a)&&(h+=t.apply(null,i),i.length=0)}return h};e?e(String,"fromCodePoint",{value:n,configurable:!0,writable:!0}):String.fromCodePoint=n}(),function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=/\\(u\{([0-9A-Fa-f]+)\}|u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([1-7][0-7]{0,2}|[0-7]{2,3})|(['"tbrnfv0\\]))|\\U([0-9A-Fa-f]{8})/g,n={0:"\0",b:"\b",f:"\f",n:`
183
183
  `,r:"\r",t:" ",v:"\v","'":"'",'"':'"',"\\":"\\"},o=function(c){return String.fromCodePoint(parseInt(c,16))},a=function(c){return String.fromCodePoint(parseInt(c,8))},i=function(c){return c.replace(r,function(l,u,h,p,m,g,b,_){return h!==void 0?o(h):p!==void 0?o(p):m!==void 0?o(m):g!==void 0?a(g):_!==void 0?o(_):n[b]})};t.default=i,e.exports=t.default}(TN,TN.exports);var W3e=TN.exports,k3e={};/*! https://mths.be/utf8js v3.0.0 by @mathias */(function(e){(function(t){var r=String.fromCharCode;function n(b){for(var _=[],y=0,x=b.length,O,S;y<x;)O=b.charCodeAt(y++),O>=55296&&O<=56319&&y<x?(S=b.charCodeAt(y++),(S&64512)==56320?_.push(((O&1023)<<10)+(S&1023)+65536):(_.push(O),y--)):_.push(O);return _}function o(b){for(var _=b.length,y=-1,x,O="";++y<_;)x=b[y],x>65535&&(x-=65536,O+=r(x>>>10&1023|55296),x=56320|x&1023),O+=r(x);return O}function a(b){if(b>=55296&&b<=57343)throw Error("Lone surrogate U+"+b.toString(16).toUpperCase()+" is not a scalar value")}function i(b,_){return r(b>>_&63|128)}function s(b){if(!(b&4294967168))return r(b);var _="";return b&4294965248?b&4294901760?b&4292870144||(_=r(b>>18&7|240),_+=i(b,12),_+=i(b,6)):(a(b),_=r(b>>12&15|224),_+=i(b,6)):_=r(b>>6&31|192),_+=r(b&63|128),_}function c(b){for(var _=n(b),y=_.length,x=-1,O,S="";++x<y;)O=_[x],S+=s(O);return S}function l(){if(m>=p)throw Error("Invalid byte index");var b=h[m]&255;if(m++,(b&192)==128)return b&63;throw Error("Invalid continuation byte")}function u(){var b,_,y,x,O;if(m>p)throw Error("Invalid byte index");if(m==p)return!1;if(b=h[m]&255,m++,!(b&128))return b;if((b&224)==192){if(_=l(),O=(b&31)<<6|_,O>=128)return O;throw Error("Invalid continuation byte")}if((b&240)==224){if(_=l(),y=l(),O=(b&15)<<12|_<<6|y,O>=2048)return a(O),O;throw Error("Invalid continuation byte")}if((b&248)==240&&(_=l(),y=l(),x=l(),O=(b&7)<<18|_<<12|y<<6|x,O>=65536&&O<=1114111))return O;throw Error("Invalid UTF-8 detected")}var h,p,m;function g(b){h=n(b),p=h.length,m=0;for(var _=[],y;(y=u())!==!1;)_.push(y);return o(_)}t.version="3.0.0",t.encode=c,t.decode=g})(e)})(k3e);const G3e=X3e,Y3e=W3e,ZW=6,q3e=7,ek=11,J3e=12,Q3e=13,Z3e=14,eKe=[[/\s*:\s*/,-1],[/\s*,\s*/,-2],[/\s*{\s*/,-3],[/\s*}\s*/,Q3e],[/\s*\[\s*/,-4],[/\s*\]\s*/,J3e],[/\s*\.\s*/,-5]];function tk(e){return e=e.replace(/\\\//,"/"),Y3e(e)}function tKe(e){let t=new G3e,r=0,n=0;return t.addRule(/"((?:\\.|[^"])*?)($|")/,(o,a)=>(r+=o.length,{type:ek,value:tk(a),row:n,col:r,single:!1})),t.addRule(/'((?:\\.|[^'])*?)($|'|(",?[ \t]*\n))/,(o,a)=>(r+=o.length,{type:ek,value:tk(a),row:n,col:r,single:!0})),t.addRule(/[\-0-9]*\.[0-9]*([eE][\+\-]?)?[0-9]*(?:\s*)/,o=>(r+=o.length,{type:ZW,value:parseFloat(o),row:n,col:r})),t.addRule(/\-?[0-9]+([eE][\+\-]?)[0-9]*(?:\s*)/,o=>(r+=o.length,{type:ZW,value:parseFloat(o),row:n,col:r})),t.addRule(/\-?[0-9]+(?:\s*)/,o=>(r+=o.length,{type:q3e,value:parseInt(o),row:n,col:r})),eKe.forEach(o=>{t.addRule(o[0],a=>(r+=a.length,{type:o[1],value:a,row:n,col:r}))}),t.addRule(/\s/,o=>{o==`
184
184
  `?(r=0,n++):r+=o.length}),t.addRule(/\S[ \t]*/,o=>(r+=o.length,{type:Z3e,value:o,row:n,col:r})),t.setInput(e),t}EN.lexString=rk;function rk(e,t){let r=tKe(e),n="";for(;n=r.lex();)t(n)}EN.getAllTokens=rKe;function rKe(e){let t=[];return rk(e,function(n){t.push(n)}),t}let nKe=EN;const AN=0,bf=1,Uu=2,CN=3,fT=4,hT=5,oKe=6,nk=7,na=8,ns=9,Nu=10,aKe=11,Bm=12,Lm=13,iKe=14,Do=15,Vm=-1,os=-2,DN=-3,vf=-4;function ok(e){e.peek==null&&Object.defineProperty(e,"peek",{enumerable:!1,value:function(){return this[this.length-1]}}),e.last==null&&Object.defineProperty(e,"last",{enumerable:!1,value:function(t){return this[this.length-(1+t)]}})}function Ze(e,t){return e&&e.hasOwnProperty("type")&&e.type==t}function rWe(e){}JW.parse=sKe;function sKe(e,t){let r=[],n=[];ok(r),ok(n);let o=function(a){n.push(a)};nKe.lexString(e,o),n[0].type==vf&&n.last(0).type!=Bm&&n.push({type:Bm,value:"]",row:-1,col:-1}),n[0].type==DN&&n.last(0).type!=Lm&&n.push({type:Lm,value:"}",row:-1,col:-1});for(let a=0;a<n.length;a++)for(""+n[a].type,r.push(n[a]);Kc(r););return r.length==1&&r[0].type==bf&&(r=[{type:Nu,value:r[0].value}]),pT(r[0],t)}function Kc(e){let t=e.pop();switch(t.type){case na:if(t.value.trim()=="true")return e.push({type:CN,value:"true"}),!0;if(t.value.trim()=="false")return e.push({type:CN,value:"false"}),!0;if(t.value.trim()=="null")return e.push({type:Do,value:null}),!0;break;case iKe:return Ze(e.peek(),na)?(e.peek().value+=t.value,!0):(e.push({type:na,value:t.value}),!0);case nk:return Ze(t,nk)&&Ze(e.peek(),na)?(e.peek().value+=t.value,!0):(t.type=Do,e.push(t),!0);case aKe:return t.type=Do,t.value=t.value,e.push(t),!0;case CN:return t.type=Do,t.value=="true"?t.value=!0:t.value=!1,e.push(t),!0;case oKe:return t.type=Do,e.push(t),!0;case Do:if(Ze(e.peek(),os))return t.type=hT,e.pop(),e.push(t),!0;if(Ze(e.peek(),Vm))return t.type=fT,e.pop(),e.push(t),!0;if(Ze(e.peek(),na)&&Ze(e.last(1),Do)){let r=e.pop();return e.peek().value+='"'+r.value+'"',e.peek().value+=t.value,!0}if(Ze(e.peek(),na)&&Ze(e.last(1),Uu)){let r=e.pop(),n=e.peek().value.pop();return n+='"'+r.value+'"',n+=t.value,e.peek().value.push(n),!0}if(Ze(e.peek(),na)&&Ze(e.last(1),bf)){let r=e.pop(),n=e.peek().value.pop();const o=t.single?"'":'"';return n.value+=o+r.value+o,n.value+=t.value,e.peek().value.push(n),!0}if(Ze(e.peek(),na)){let r=e.pop().value;return t.value=r+t.value,e.push(t),!0}break;case ns:if(Ze(t,ns)&&Ze(e.peek(),os))return t.type=hT,e.pop(),e.push(t),!0;if(Ze(e.peek(),Vm))return t.type=fT,e.pop(),e.push(t),!0;break;case Nu:if(Ze(e.peek(),os)){let r={type:hT,value:t};return e.pop(),e.push(r),!0}if(Ze(e.peek(),Vm)){let r={type:fT,value:t};return e.pop(),e.push(r),!0}if(Ze(e.peek(),na)){let r=e.pop();return e.push({type:AN,key:r.value.trim(),value:t}),!0}break;case hT:return Ze(e.peek(),Uu)?(e.peek().value.push(t.value),!0):(e.push({type:Uu,value:[t.value]}),!0);case Uu:if(Ze(e.peek(),Do)||Ze(e.peek(),ns))return t.value.unshift(e.peek().value),e.pop(),e.push(t),!0;if(Ze(e.peek(),Nu))return t.value.unshift(e.peek()),e.pop(),e.push(t),!0;if(Ze(e.peek(),na)&&(e.last(1),os)){let r=e.pop();for(e.push({type:Do,value:r.value}),""+r.value;Kc(e););return e.push(t),!0}if(Ze(e.peek(),Uu))return e.peek().value.push(t.value[0]),!0;break;case fT:if(Ze(e.peek(),na)||Ze(e.peek(),Do)||Ze(e.peek(),Uu)){let r=e.pop();return e.push({type:AN,key:r.value,value:t.value}),!0}throw new Error("Got a :value that can't be handled at line "+t.row+":"+t.col);case AN:return Ze(e.last(0),os)&&Ze(e.last(1),bf)?(e.last(1).value.push(t),e.pop(),!0):(e.push({type:bf,value:[t]}),!0);case bf:if(Ze(e.peek(),bf))return t.value.forEach(function(r){e.peek().value.push(r)}),!0;break;case Bm:if(Ze(e.peek(),Uu)&&Ze(e.last(1),vf)){let r=e.pop();return e.pop(),e.push({type:ns,value:r.value}),!0}if(Ze(e.peek(),ns)&&Ze(e.last(1),vf)){let r=e.pop();return e.pop(),e.push({type:ns,value:[r.value]}),!0}if(Ze(e.peek(),vf))return e.pop(),e.push({type:ns,value:[]}),!0;if(Ze(e.peek(),Do)&&Ze(e.last(1),vf)){let r=e.pop().value;return e.pop(),e.push({type:ns,value:[r]}),!0}if(Ze(e.peek(),Nu)&&Ze(e.last(1),vf)){let r=e.pop();return e.pop(),e.push({type:ns,value:[r]}),!0}if(Ze(e.peek(),na)&&Ze(e.last(1),os)){let r=e.pop();for(e.push({type:Do,value:r.value}),""+r.value;Kc(e););return e.push({type:Bm}),!0}if(Ze(e.peek(),os)&&(Ze(e.last(1),na)||Ze(e.last(1),Nu)||Ze(e.last(1),Do))){for(e.pop(),e.push({type:Bm,value:"]"}),""+JSON.stringify(e);Kc(e););return!0}if(Ze(e.peek(),na)&&Ze(e.last(1),vf)){let r=e.pop();return e.pop(),e.push({type:ns,value:[r.value]}),!0}if(Ze(e.peek(),os)&&Ze(e.last(1),Uu)){for(e.pop(),e.push({type:Bm}),""+JSON.stringify(e);Kc(e););return!0}break;case Lm:if(Ze(e.peek(),bf)&&Ze(e.last(1),DN)){let r=e.pop();return e.pop(),e.push({type:Nu,value:r.value}),!0}if(Ze(e.peek(),DN))return e.pop(),e.push({type:Nu,value:null}),!0;if(Ze(e.peek(),na)&&Ze(e.last(1),Vm)){let r=e.pop();for(e.push({type:Do,value:r.value}),""+r.value;Kc(e););return e.push({type:Lm}),!0}if(Ze(e.peek(),Vm)){for(e.push({type:Do,value:null});Kc(e););return e.push({type:Lm}),!0}if(Ze(e.peek(),os))return e.pop(),e.push({type:Lm}),!0;throw new Error("Found } that I can't handle at line "+t.row+":"+t.col);case os:if(Ze(e.peek(),os))return!0;if(Ze(e.peek(),na)){const r=e.pop();for(e.push({type:Do,value:r.value});Kc(e););return e.push(t),!0}if(Ze(e.peek(),Vm)){for(e.push({type:Do,value:null});Kc(e););return e.push(t),!0}}return e.push(t),!1}function pT(e,t){if(["boolean","number","string"].indexOf(typeof e)!=-1)return e;if(e===null)return null;if(Array.isArray(e)){let n=[];for(;e.length>0;)n.unshift(pT(e.pop()));return n}if(Ze(e,Nu)){let n={};return e.value===null?{}:(e.value.forEach(function(o){const a=o.key,i=pT(o.value);t&&a in n?n[a]={value:n[a],next:i}:n[a]=i}),n)}return Ze(e,ns)?pT(e.value):e.value}let cKe=JW;qW.parse=lKe;function lKe(e,t){let r=!0,n=!1;t&&("fallback"in t&&t[r]===!1&&(r=!1),n="duplicateKeys"in t&&t.duplicateKeys===!0);try{return cKe.parse(e,n)}catch(o){if(r===!1)throw o;try{let a=JSON.parse(e);return console.warn("dirty-json got valid JSON that failed with the custom parser. We're returning the valid JSON, but please file a bug report here: https://github.com/RyanMarcus/dirty-json/issues -- the JSON that caused the failure was: "+e),a}catch{throw o}}}var ak=(e=>(e.BAR="BAR",e.SECTION="SECTION",e))(ak||{}),uKe=(e=>(e.ACTIVATE="activate",e.MOVE="move",e.DEACTIVATE="deactivate",e))(uKe||{});function ik(){let e=[],t=0,r=0;return{collect(n){e.push(n),n.disableResponsive||(t+=1,r+=n.currentSize)},getResult(){return{sizeInfoArray:e,flexGrowRatio:t/r}}}}function Qs(e){return Number.isFinite(e)&&e>0}function sk(e,t,r){let{collect:n,getResult:o}=ik(),a=mT(e,t,-1,r),i=mT(e,-t,1,r),s=t-a.remainingOffset,c=-t-i.remainingOffset;function l(u,h){u.forEach(n),n(r[e]),h.forEach(n)}if(s===-c)l(a.sizeInfoArray,i.sizeInfoArray);else if(Math.abs(s)<Math.abs(c)){let u=mT(e,-s,1,r);l(a.sizeInfoArray,u.sizeInfoArray)}else{let u=mT(e,-c,-1,r);l(u.sizeInfoArray,i.sizeInfoArray)}return o()}function mT(e,t,r,n){let o=[],a=t;for(let c=e+r;s(c);c+=r)if(a){let{sizeInfo:l,remainingOffset:u}=dKe(a,n[c]);a=u,i(l)}else i(n[c]);function i(c){r===-1?o.unshift(c):o.push(c)}function s(c){return r===-1?c>=0:c<=n.length-1}return{sizeInfoArray:o,remainingOffset:a}}function dKe(e,t){if(t.isSolid)return{remainingOffset:e,sizeInfo:t};let{nextSize:r,remainingOffset:n}=fKe(t.currentSize+e,t);return{sizeInfo:{...t,currentSize:r},remainingOffset:n}}function fKe(e,{maxSize:t,minSize:r=0}){return e<r?{nextSize:r,remainingOffset:e-r}:Qs(t)&&e>t?{nextSize:t,remainingOffset:e-t}:{nextSize:e,remainingOffset:0}}var ck={x:0,y:0};function hKe(e,t){return t?{x:e.x-t.x,y:e.y-t.y}:ck}var IN={barIndex:-1,offset:0,type:"deactivate",originalCoordinate:ck,defaultSizeInfoArray:[],sizeInfoArray:[],discard:!0,flexGrowRatio:0};function pKe(e){let t=IN,r=new Set;return{dispatch(n){t=(()=>{let o={barIndex:n.barIndex,type:n.type};switch(n.type){case"activate":let{sizeInfoArray:a,flexGrowRatio:i}=e.getSizeRelatedInfo();return{...IN,...o,originalCoordinate:n.coordinate,defaultSizeInfoArray:a,sizeInfoArray:a,flexGrowRatio:i};case"move":let s=e.calculateOffset(n.coordinate,t.originalCoordinate);return{...o,...sk(n.barIndex,s,t.defaultSizeInfoArray),offset:s,originalCoordinate:t.originalCoordinate,defaultSizeInfoArray:t.defaultSizeInfoArray,discard:!1};case"deactivate":return IN}})(),r.forEach(o=>o(t))},subscribe(n){return r.add(n),()=>r.delete(n)},unsubscribeAll(){r.clear()}}}function Nw(e,t,r){e==null||e.dispatchEvent(new CustomEvent(t,{detail:r}))}var mKe=class{constructor(){Qe(this,"disposeFnSet",new Set);Qe(this,"watchResizerEvent",(e,t,r)=>{e==null||e.addEventListener(t,r);let n=()=>e==null?void 0:e.removeEventListener(t,r);return this.disposeFnSet.add(n),n});Qe(this,"reset",()=>{this.disposeFnSet.forEach(e=>e()),this.disposeFnSet.clear()})}},gKe=class{constructor(){Qe(this,"infoMap",new Map);Qe(this,"items",[])}update(t){this.infoMap.clear(),this.items.forEach(r=>r.destroy()),this.items=t,t.forEach((r,n)=>{this.infoMap.set(r.elm,{item:r,index:n})})}reset(){this.update([])}getItems(){return this.items}getItem(t){var r;return((r=this.infoMap.get(t))==null?void 0:r.item)??null}getItemIndex(t){var r;return((r=this.infoMap.get(t))==null?void 0:r.index)??null}},zN=!0;try{window.addEventListener("test",null,{get passive(){return zN={passive:!1},!0}})}catch{}function lk({size:e}){return Qs(e)}function bKe(e){let{disableResponsive:t}=e;return lk(e)&&t===void 0?!0:!!t}function vKe(e){return!!e&&e in ak}function uk(e){return t=>({"data-item-type":e,"data-item-config":JSON.stringify(t)})}function yKe(e){return Array.from(e.childNodes).map(t=>{if(!(t instanceof HTMLElement))return null;let r=t.getAttribute("data-item-type");return vKe(r)?{type:r,elm:t}:null}).filter(t=>!!t)}function dk({elm:e}){try{let t=JSON.parse(e.getAttribute("data-item-config")??"");return t&&typeof t=="object"?t:{}}catch{return{}}}function fk(e){return e*2+1}function UN(e){return e*2}var hk=class{constructor(e){Qe(this,"isDiscarded",!1);this.resizeResult=e}resizeSection(e,t){if(this.isDiscarded)return;let r=UN(e),n=this.getSize(r);if(n>=0&&t.toSize>=0){let o=t.toSize-n;r===this.resizeResult.sizeInfoArray.length-1||t.preferMoveLeftBar?this.moveBar(e-1,{withOffset:-o}):this.moveBar(e,{withOffset:o})}}moveBar(e,t){this.isDiscarded||(this.resizeResult=sk(fk(e),t.withOffset,this.resizeResult.sizeInfoArray))}discard(){this.isDiscarded=!0}isSectionResized(e){let t=UN(e);return"defaultSizeInfoArray"in this.resizeResult?this.getSize(t)!==this.resizeResult.defaultSizeInfoArray[t].currentSize:!1}isBarActivated(e){return"barIndex"in this.resizeResult?this.resizeResult.barIndex===fk(e):!1}getSectionSize(e){return this.getSize(UN(e))}getResult(){return{...this.resizeResult,discard:this.isDiscarded}}getTotalSize(){return this.resizeResult.sizeInfoArray.filter((e,t)=>e&&t%2===0).reduce((e,{currentSize:t})=>e+t,0)}getSize(e){let t=this.resizeResult.sizeInfoArray[e];return t?t.currentSize:-1}},pk=class{constructor(e,t,r){Qe(this,"_config");Qe(this,"_observer");this.type=e,this.elm=t,this.getConfig=r,this._config=this.getConfig(),this._observer=new MutationObserver(()=>this._config=this.getConfig()),this._observer.observe(t,{attributes:!0,attributeFilter:["data-item-config"]})}get config(){return this._config}destroy(){this._observer.disconnect()}},gT=class extends pk{constructor(r,n){super("BAR",r.elm,()=>_Ke(r));Qe(this,"isActive",!1);Qe(this,"isValidClick",!0);this.dispatchBarAction=n;let o=[this.attachListener(this.elm,"mousedown","activate"),this.attachListener(document,"mousemove","move"),this.attachListener(document,"mouseup","deactivate"),this.attachListener(this.elm,"touchstart","activate",zN),this.attachListener(document,"touchmove","move",zN),this.attachListener(document,"touchend","deactivate"),this.attachListener(document,"touchcancel","deactivate")];this.destroy=()=>{super.destroy(),o.forEach(a=>a())}}static getStyle({size:r}){return{flex:`0 0 ${r}px`}}attachListener(r,n,o,a){let i=s=>{this.disableUserSelectIfResizing(s,o);let{clientX:c,clientY:l}=("touches"in s?s.touches[0]:s)||{clientX:0,clientY:0};this.triggerAction(this.elm,o,{x:c,y:l})};return r.addEventListener(n,i,a),()=>r.removeEventListener(n,i,a)}disableUserSelectIfResizing(r,n){(this.isActive||n==="activate")&&r.preventDefault()}triggerAction(r,n,o){(this.isActive||n==="activate")&&this.dispatchBarAction(r,{type:n,coordinate:o}),this.isActive&&this.isValidClick&&n==="deactivate"&&(this.isValidClick=!1,Nw(r,"bar:click",null)),this.updateStatusIfNeed(r,n),this.updateClickStatus(n)}updateStatusIfNeed(r,n){let o=a=>{this.isActive!==a&&(this.isActive=a,Nw(r,"bar:status-change",{isActive:a}))};n==="activate"?o(!0):n==="deactivate"&&o(!1)}updateClickStatus(r){this.isActive&&(r==="activate"?this.isValidClick=!0:r==="move"&&(this.isValidClick=!1))}};function _Ke(e){let{size:t}=dk(e);return{size:Qs(t)?t:10}}var Rw=class extends pk{constructor(t){super("SECTION",t.elm,()=>wKe(t));Qe(this,"sizeInfo",null);Qe(this,"flexGrowRatio",0);this.updateStyle()}static getStyle({maxSize:t,minSize:r},n){let o=a=>Qs(a)?`${a}px`:void 0;return{overflow:"hidden",[n?"maxHeight":"maxWidth"]:o(t),[n?"minHeight":"minWidth"]:o(r)}}update({sizeInfo:t,flexGrowRatio:r}){this.sizeInfo=t,this.flexGrowRatio=r,this.updateStyle(),Nw(this.elm,"section:size-change",{size:t.currentSize})}updateStyle(){let{flexGrow:t,flexShrink:r,flexBasis:n}=this.getStyle();this.elm.style.flexGrow=`${t}`,this.elm.style.flexShrink=`${r}`,this.elm.style.flexBasis=`${n}px`}getStyle(){let t=Qs(this.config.size)?0:this.config.disableResponsive?1:0;if(this.sizeInfo){let{disableResponsive:r,currentSize:n}=this.sizeInfo;return{flexShrink:t,flexGrow:r?0:this.flexGrowRatio*n,flexBasis:r?n:0}}else{let r=this.config.size||this.config.defaultSize;return Qs(r)?{flexShrink:t,flexGrow:0,flexBasis:r}:{flexShrink:t,flexGrow:1,flexBasis:0}}}};function wKe(e){let{size:t,defaultSize:r,maxSize:n,minSize:o,disableResponsive:a}=dk(e);return{size:Qs(t)?t:void 0,defaultSize:Qs(r)?r:void 0,maxSize:Qs(n)?n:void 0,minSize:Qs(o)?o:void 0,disableResponsive:!!a}}var xKe=class{constructor(e){Qe(this,"styles",{container:e=>({...e,display:"flex",flexDirection:this.direction}),section:(e,t)=>({...t,...Rw.getStyle(e,this.config.vertical)}),bar:(e,t)=>({...t,...gT.getStyle(e)})});Qe(this,"attributes",{bar:uk("BAR"),section:uk("SECTION")});Qe(this,"itemsCache",new gKe);Qe(this,"eventHub",new mKe);Qe(this,"container",null);Qe(this,"barStore");Qe(this,"dispatchBarAction",(e,t)=>{let r=this.itemsCache.getItemIndex(e);r&&this.barStore.dispatch({...t,barIndex:r})});this.config=e,this.barStore=pKe({calculateOffset:(t,r)=>hKe(t,r)[this.axis],getSizeRelatedInfo:()=>this.makeSizeInfos()})}get axis(){return this.config.vertical?"y":"x"}get dimension(){return this.config.vertical?"height":"width"}get direction(){return this.config.vertical?"column":"row"}get on(){return this.eventHub.watchResizerEvent}init(e){this.dispose(),this.container=e,e&&(this.itemsCache.update(yKe(e).map(t=>{switch(t.type){case"BAR":return new gT(t,this.dispatchBarAction);case"SECTION":return new Rw(t)}})),this.initStyles(e,this.itemsCache.getItems()),this.sizeRelatedInfoChange(this.makeSizeInfos()),this.barStore.subscribe(t=>{this.monitorBarStatusChanges(t),this.sizeRelatedInfoChange(t)}))}dispose(){this.container=null,this.itemsCache.reset(),this.barStore.unsubscribeAll(),this.eventHub.reset()}getResizer(){return new hk(this.makeSizeInfos())}applyResizer(e){this.sizeRelatedInfoChange(e.getResult())}sizeRelatedInfoChange(e){e.discard||(e=(()=>{if(typeof this.config.beforeApplyResizer=="function"){let t=new hk(e);return this.config.beforeApplyResizer(t),t.getResult()}else return e})(),!e.discard&&e.sizeInfoArray.forEach(t=>{let r=this.itemsCache.getItem(t.elm);r instanceof Rw&&r.update({sizeInfo:t,flexGrowRatio:e.flexGrowRatio})}))}monitorBarStatusChanges({type:e}){switch(e){case"activate":return Nw(this.container,"column:activate",null);case"deactivate":return Nw(this.container,"column:after-resizing",null);default:return}}makeSizeInfos(){let{collect:e,getResult:t}=ik();return this.itemsCache.getItems().forEach(r=>{r instanceof gT&&e({elm:r.elm,disableResponsive:!0,isSolid:!0,currentSize:r.elm.getBoundingClientRect()[this.dimension]}),r instanceof Rw&&e({elm:r.elm,maxSize:r.config.maxSize,minSize:r.config.minSize,disableResponsive:bKe(r.config),isSolid:lk(r.config),currentSize:r.elm.getBoundingClientRect()[this.dimension]})}),t()}initStyles(e,t){Object.assign(e.style,this.styles.container()),t.forEach(r=>{r instanceof gT&&Object.assign(r.elm.style,this.styles.bar(r.config)),r instanceof Rw&&Object.assign(r.elm.style,this.styles.section(r.config))})}},mk=pe.createContext(null),jKe=typeof window=="object"?w.useLayoutEffect:w.useEffect;function OKe({vertical:e,beforeApplyResizer:t}){let r=gk(t);return w.useMemo(()=>new xKe({vertical:e,beforeApplyResizer:r}),[e,r])}function NN(){return w.useContext(mk)}function $w(e,t,r){let n=NN(),o=gk(r);w.useEffect(()=>n.on(e.current,t,a=>o(a)),[n,t,e,o])}function RN(e,t){let r=w.useRef(e);return w.useImperativeHandle(t,()=>r.current),r}function gk(e){let t=w.useRef(e);return t.current=e,w.useCallback((...r)=>{var n;return(n=t.current)==null?void 0:n.call(t,...r)},[t])}function MKe({hooks:e,params:t,children:r}){let n=e(...t);return w.createElement(w.Fragment,null,r(n))}function SKe(e,{onActivate:t,afterResizing:r}){$w(e,"column:activate",t),$w(e,"column:after-resizing",r)}var bk=pe.forwardRef(({vertical:e=!1,onActivate:t,beforeApplyResizer:r,afterResizing:n,columnResizerRef:o,style:a,...i},s)=>{let c=RN(null,s),l=OKe({vertical:e,beforeApplyResizer:r});return jKe(()=>(l.init(c.current),()=>l.dispose()),[l]),pe.useImperativeHandle(o,()=>l,[l]),pe.createElement(mk.Provider,{value:l},pe.createElement(MKe,{hooks:SKe,params:[c,{onActivate:t,afterResizing:n}]},()=>pe.createElement("div",{ref:c,...i,style:l.styles.container(a)})))}),bT=pe.forwardRef(({defaultSize:e,size:t,disableResponsive:r,minSize:n,maxSize:o,onSizeChanged:a,style:i,...s},c)=>{let l=RN(null,c),u=NN(),h={defaultSize:e,size:t,disableResponsive:r,minSize:n,maxSize:o};return $w(l,"section:size-change",p=>a==null?void 0:a(p.detail.size)),pe.createElement("div",{ref:l,...s,style:u.styles.section(h,i),...u.attributes.section(h)})}),PKe=pe.forwardRef(({top:e=0,right:t=0,bottom:r=0,left:n=0,vertical:o,style:a,...i},s)=>{let c=pe.useMemo(()=>({position:"absolute",top:-e,left:-n,right:-t,bottom:-r,WebkitTapHighlightColor:"transparent",userSelect:"none",...a}),[a,e,n,t,r,o]);return pe.createElement("div",{...i,style:c,ref:s})}),vk=pe.forwardRef(({children:e,onClick:t,expandInteractiveArea:r,onStatusChanged:n,style:o,size:a=10,...i},s)=>{let c=NN(),l=RN(null,s),u={size:a};return $w(l,"bar:click",()=>t==null?void 0:t()),$w(l,"bar:status-change",h=>n==null?void 0:n(h.detail.isActive)),pe.createElement("div",{ref:l,...i,style:c.styles.bar(u,{...o,position:"relative"}),...c.attributes.bar(u)},e,pe.createElement(PKe,{...r,vertical:c.config.vertical}))});function EKe({title:e,titleId:t,...r},n){return pe.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?pe.createElement("title",{id:t},e):null,pe.createElement("path",{fillRule:"evenodd",d:"M1.5 6a2.25 2.25 0 0 1 2.25-2.25h16.5A2.25 2.25 0 0 1 22.5 6v12a2.25 2.25 0 0 1-2.25 2.25H3.75A2.25 2.25 0 0 1 1.5 18V6ZM3 16.06V18c0 .414.336.75.75.75h16.5A.75.75 0 0 0 21 18v-1.94l-2.69-2.689a1.5 1.5 0 0 0-2.12 0l-.88.879.97.97a.75.75 0 1 1-1.06 1.06l-5.16-5.159a1.5 1.5 0 0 0-2.12 0L3 16.061Zm10.125-7.81a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0Z",clipRule:"evenodd"}))}const TKe=pe.forwardRef(EKe);var AKe=20,CKe=1,yf=1e6,yk=1e6,DKe=-7,IKe=21,zKe=!1,Fw="[big.js] ",_f=Fw+"Invalid ",vT=_f+"decimal places",UKe=_f+"rounding mode",_k=Fw+"Division by zero",vr={},Zs=void 0,NKe=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function wk(){function e(t){var r=this;if(!(r instanceof e))return t===Zs?wk():new e(t);if(t instanceof e)r.s=t.s,r.e=t.e,r.c=t.c.slice();else{if(typeof t!="string"){if(e.strict===!0&&typeof t!="bigint")throw TypeError(_f+"value");t=t===0&&1/t<0?"-0":String(t)}RKe(r,t)}r.constructor=e}return e.prototype=vr,e.DP=AKe,e.RM=CKe,e.NE=DKe,e.PE=IKe,e.strict=zKe,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}function RKe(e,t){var r,n,o;if(!NKe.test(t))throw Error(_f+"number");for(e.s=t.charAt(0)=="-"?(t=t.slice(1),-1):1,(r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),o=t.length,n=0;n<o&&t.charAt(n)=="0";)++n;if(n==o)e.c=[e.e=0];else{for(;o>0&&t.charAt(--o)=="0";);for(e.e=r-n-1,e.c=[],r=0;n<=o;)e.c[r++]=+t.charAt(n++)}return e}function wf(e,t,r,n){var o=e.c;if(r===Zs&&(r=e.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(UKe);if(t<1)n=r===3&&(n||!!o[0])||t===0&&(r===1&&o[0]>=5||r===2&&(o[0]>5||o[0]===5&&(n||o[1]!==Zs))),o.length=1,n?(e.e=e.e-t+1,o[0]=1):o[0]=e.e=0;else if(t<o.length){if(n=r===1&&o[t]>=5||r===2&&(o[t]>5||o[t]===5&&(n||o[t+1]!==Zs||o[t-1]&1))||r===3&&(n||!!o[0]),o.length=t,n){for(;++o[--t]>9;)if(o[t]=0,t===0){++e.e,o.unshift(1);break}}for(t=o.length;!o[--t];)o.pop()}return e}function Km(e,t,r){var n=e.e,o=e.c.join(""),a=o.length;if(t)o=o.charAt(0)+(a>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>a)for(n-=a;n--;)o+="0";else n<a&&(o=o.slice(0,n)+"."+o.slice(n));else a>1&&(o=o.charAt(0)+"."+o.slice(1));return e.s<0&&r?"-"+o:o}vr.abs=function(){var e=new this.constructor(this);return e.s=1,e},vr.cmp=function(e){var t,r=this,n=r.c,o=(e=new r.constructor(e)).c,a=r.s,i=e.s,s=r.e,c=e.e;if(!n[0]||!o[0])return n[0]?a:o[0]?-i:0;if(a!=i)return a;if(t=a<0,s!=c)return s>c^t?1:-1;for(i=(s=n.length)<(c=o.length)?s:c,a=-1;++a<i;)if(n[a]!=o[a])return n[a]>o[a]^t?1:-1;return s==c?0:s>c^t?1:-1},vr.div=function(e){var t=this,r=t.constructor,n=t.c,o=(e=new r(e)).c,a=t.s==e.s?1:-1,i=r.DP;if(i!==~~i||i<0||i>yf)throw Error(vT);if(!o[0])throw Error(_k);if(!n[0])return e.s=a,e.c=[e.e=0],e;var s,c,l,u,h,p=o.slice(),m=s=o.length,g=n.length,b=n.slice(0,s),_=b.length,y=e,x=y.c=[],O=0,S=i+(y.e=t.e-e.e)+1;for(y.s=a,a=S<0?0:S,p.unshift(0);_++<s;)b.push(0);do{for(l=0;l<10;l++){if(s!=(_=b.length))u=s>_?1:-1;else for(h=-1,u=0;++h<s;)if(o[h]!=b[h]){u=o[h]>b[h]?1:-1;break}if(u<0){for(c=_==s?o:p;_;){if(b[--_]<c[_]){for(h=_;h&&!b[--h];)b[h]=9;--b[h],b[_]+=10}b[_]-=c[_]}for(;!b[0];)b.shift()}else break}x[O++]=u?l:++l,b[0]&&u?b[_]=n[m]||0:b=[n[m]]}while((m++<g||b[0]!==Zs)&&a--);return!x[0]&&O!=1&&(x.shift(),y.e--,S--),O>S&&wf(y,S,r.RM,b[0]!==Zs),y},vr.eq=function(e){return this.cmp(e)===0},vr.gt=function(e){return this.cmp(e)>0},vr.gte=function(e){return this.cmp(e)>-1},vr.lt=function(e){return this.cmp(e)<0},vr.lte=function(e){return this.cmp(e)<1},vr.minus=vr.sub=function(e){var t,r,n,o,a=this,i=a.constructor,s=a.s,c=(e=new i(e)).s;if(s!=c)return e.s=-c,a.plus(e);var l=a.c.slice(),u=a.e,h=e.c,p=e.e;if(!l[0]||!h[0])return h[0]?e.s=-c:l[0]?e=new i(a):e.s=1,e;if(s=u-p){for((o=s<0)?(s=-s,n=l):(p=u,n=h),n.reverse(),c=s;c--;)n.push(0);n.reverse()}else for(r=((o=l.length<h.length)?l:h).length,s=c=0;c<r;c++)if(l[c]!=h[c]){o=l[c]<h[c];break}if(o&&(n=l,l=h,h=n,e.s=-e.s),(c=(r=h.length)-(t=l.length))>0)for(;c--;)l[t++]=0;for(c=t;r>s;){if(l[--r]<h[r]){for(t=r;t&&!l[--t];)l[t]=9;--l[t],l[r]+=10}l[r]-=h[r]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--p;return l[0]||(e.s=1,l=[p=0]),e.c=l,e.e=p,e},vr.mod=function(e){var t,r=this,n=r.constructor,o=r.s,a=(e=new n(e)).s;if(!e.c[0])throw Error(_k);return r.s=e.s=1,t=e.cmp(r)==1,r.s=o,e.s=a,t?new n(r):(o=n.DP,a=n.RM,n.DP=n.RM=0,r=r.div(e),n.DP=o,n.RM=a,this.minus(r.times(e)))},vr.neg=function(){var e=new this.constructor(this);return e.s=-e.s,e},vr.plus=vr.add=function(e){var t,r,n,o=this,a=o.constructor;if(e=new a(e),o.s!=e.s)return e.s=-e.s,o.minus(e);var i=o.e,s=o.c,c=e.e,l=e.c;if(!s[0]||!l[0])return l[0]||(s[0]?e=new a(o):e.s=o.s),e;if(s=s.slice(),t=i-c){for(t>0?(c=i,n=l):(t=-t,n=s),n.reverse();t--;)n.push(0);n.reverse()}for(s.length-l.length<0&&(n=l,l=s,s=n),t=l.length,r=0;t;s[t]%=10)r=(s[--t]=s[t]+l[t]+r)/10|0;for(r&&(s.unshift(r),++c),t=s.length;s[--t]===0;)s.pop();return e.c=s,e.e=c,e},vr.pow=function(e){var t=this,r=new t.constructor("1"),n=r,o=e<0;if(e!==~~e||e<-yk||e>yk)throw Error(_f+"exponent");for(o&&(e=-e);e&1&&(n=n.times(t)),e>>=1,!!e;)t=t.times(t);return o?r.div(n):n},vr.prec=function(e,t){if(e!==~~e||e<1||e>yf)throw Error(_f+"precision");return wf(new this.constructor(this),e,t)},vr.round=function(e,t){if(e===Zs)e=0;else if(e!==~~e||e<-yf||e>yf)throw Error(vT);return wf(new this.constructor(this),e+this.e+1,t)},vr.sqrt=function(){var e,t,r,n=this,o=n.constructor,a=n.s,i=n.e,s=new o("0.5");if(!n.c[0])return new o(n);if(a<0)throw Error(Fw+"No square root");a=Math.sqrt(n+""),a===0||a===1/0?(t=n.c.join(""),t.length+i&1||(t+="0"),a=Math.sqrt(t),i=((i+1)/2|0)-(i<0||i&1),e=new o((a==1/0?"5e":(a=a.toExponential()).slice(0,a.indexOf("e")+1))+i)):e=new o(a+""),i=e.e+(o.DP+=4);do r=e,e=s.times(r.plus(n.div(r)));while(r.c.slice(0,i).join("")!==e.c.slice(0,i).join(""));return wf(e,(o.DP-=4)+e.e+1,o.RM)},vr.times=vr.mul=function(e){var t,r=this,n=r.constructor,o=r.c,a=(e=new n(e)).c,i=o.length,s=a.length,c=r.e,l=e.e;if(e.s=r.s==e.s?1:-1,!o[0]||!a[0])return e.c=[e.e=0],e;for(e.e=c+l,i<s&&(t=o,o=a,a=t,l=i,i=s,s=l),t=new Array(l=i+s);l--;)t[l]=0;for(c=s;c--;){for(s=0,l=i+c;l>c;)s=t[l]+a[c]*o[l-c-1]+s,t[l--]=s%10,s=s/10|0;t[l]=s}for(s?++e.e:t.shift(),c=t.length;!t[--c];)t.pop();return e.c=t,e},vr.toExponential=function(e,t){var r=this,n=r.c[0];if(e!==Zs){if(e!==~~e||e<0||e>yf)throw Error(vT);for(r=wf(new r.constructor(r),++e,t);r.c.length<e;)r.c.push(0)}return Km(r,!0,!!n)},vr.toFixed=function(e,t){var r=this,n=r.c[0];if(e!==Zs){if(e!==~~e||e<0||e>yf)throw Error(vT);for(r=wf(new r.constructor(r),e+r.e+1,t),e=e+r.e+1;r.c.length<e;)r.c.push(0)}return Km(r,!1,!!n)},vr[Symbol.for("nodejs.util.inspect.custom")]=vr.toJSON=vr.toString=function(){var e=this,t=e.constructor;return Km(e,e.e<=t.NE||e.e>=t.PE,!!e.c[0])},vr.toNumber=function(){var e=Number(Km(this,!0,!0));if(this.constructor.strict===!0&&!this.eq(e.toString()))throw Error(Fw+"Imprecise conversion");return e},vr.toPrecision=function(e,t){var r=this,n=r.constructor,o=r.c[0];if(e!==Zs){if(e!==~~e||e<1||e>yf)throw Error(_f+"precision");for(r=wf(new n(r),e,t);r.c.length<e;)r.c.push(0)}return Km(r,e<=r.e||r.e<=n.NE||r.e>=n.PE,!!o)},vr.valueOf=function(){var e=this,t=e.constructor;if(t.strict===!0)throw Error(Fw+"valueOf disallowed");return Km(e,e.e<=t.NE||e.e>=t.PE,!0)};var $N=wk(),xk={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(d,function(){return function(r,n,o){var a=function(i,s){if(!s||!s.length||s.length===1&&!s[0]||s.length===1&&Array.isArray(s[0])&&!s[0].length)return null;var c;s.length===1&&s[0].length>0&&(s=s[0]),c=(s=s.filter(function(u){return u}))[0];for(var l=1;l<s.length;l+=1)s[l].isValid()&&!s[l][i](c)||(c=s[l]);return c};o.max=function(){var i=[].slice.call(arguments,0);return a("isAfter",i)},o.min=function(){var i=[].slice.call(arguments,0);return a("isBefore",i)}}})})(xk);var $Ke=xk.exports;const FKe=mn($Ke);var jk={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(d,function(){var r={year:0,month:1,day:2,hour:3,minute:4,second:5},n={};return function(o,a,i){var s,c=function(p,m,g){g===void 0&&(g={});var b=new Date(p),_=function(y,x){x===void 0&&(x={});var O=x.timeZoneName||"short",S=y+"|"+O,j=n[S];return j||(j=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:y,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:O}),n[S]=j),j}(m,g);return _.formatToParts(b)},l=function(p,m){for(var g=c(p,m),b=[],_=0;_<g.length;_+=1){var y=g[_],x=y.type,O=y.value,S=r[x];S>=0&&(b[S]=parseInt(O,10))}var j=b[3],P=j===24?0:j,I=b[0]+"-"+b[1]+"-"+b[2]+" "+P+":"+b[4]+":"+b[5]+":000",M=+p;return(i.utc(I).valueOf()-(M-=M%1e3))/6e4},u=a.prototype;u.tz=function(p,m){p===void 0&&(p=s);var g,b=this.utcOffset(),_=this.toDate(),y=_.toLocaleString("en-US",{timeZone:p}),x=Math.round((_-new Date(y))/1e3/60),O=15*-Math.round(_.getTimezoneOffset()/15)-x;if(!Number(O))g=this.utcOffset(0,m);else if(g=i(y,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(O,!0),m){var S=g.utcOffset();g=g.add(b-S,"minute")}return g.$x.$timezone=p,g},u.offsetName=function(p){var m=this.$x.$timezone||i.tz.guess(),g=c(this.valueOf(),m,{timeZoneName:p}).find(function(b){return b.type.toLowerCase()==="timezonename"});return g&&g.value};var h=u.startOf;u.startOf=function(p,m){if(!this.$x||!this.$x.$timezone)return h.call(this,p,m);var g=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return h.call(g,p,m).tz(this.$x.$timezone,!0)},i.tz=function(p,m,g){var b=g&&m,_=g||m||s,y=l(+i(),_);if(typeof p!="string")return i(p).tz(_);var x=function(P,I,M){var E=P-60*I*1e3,D=l(E,M);if(I===D)return[E,I];var A=l(E-=60*(D-I)*1e3,M);return D===A?[E,D]:[P-60*Math.min(D,A)*1e3,Math.max(D,A)]}(i.utc(p,b).valueOf(),y,_),O=x[0],S=x[1],j=i(O).utcOffset(S);return j.$x.$timezone=_,j},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(p){s=p}}})})(jk);var BKe=jk.exports;const LKe=mn(BKe);var Ok={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(d,function(){var r="minute",n=/[+-]\d\d(?::?\d\d)?/g,o=/([+-]|\d\d)/g;return function(a,i,s){var c=i.prototype;s.utc=function(b){var _={date:b,utc:!0,args:arguments};return new i(_)},c.utc=function(b){var _=s(this.toDate(),{locale:this.$L,utc:!0});return b?_.add(this.utcOffset(),r):_},c.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var l=c.parse;c.parse=function(b){b.utc&&(this.$u=!0),this.$utils().u(b.$offset)||(this.$offset=b.$offset),l.call(this,b)};var u=c.init;c.init=function(){if(this.$u){var b=this.$d;this.$y=b.getUTCFullYear(),this.$M=b.getUTCMonth(),this.$D=b.getUTCDate(),this.$W=b.getUTCDay(),this.$H=b.getUTCHours(),this.$m=b.getUTCMinutes(),this.$s=b.getUTCSeconds(),this.$ms=b.getUTCMilliseconds()}else u.call(this)};var h=c.utcOffset;c.utcOffset=function(b,_){var y=this.$utils().u;if(y(b))return this.$u?0:y(this.$offset)?h.call(this):this.$offset;if(typeof b=="string"&&(b=function(j){j===void 0&&(j="");var P=j.match(n);if(!P)return null;var I=(""+P[0]).match(o)||["-",0,0],M=I[0],E=60*+I[1]+ +I[2];return E===0?0:M==="+"?E:-E}(b),b===null))return this;var x=Math.abs(b)<=16?60*b:b,O=this;if(_)return O.$offset=x,O.$u=b===0,O;if(b!==0){var S=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(O=this.local().add(x+S,r)).$offset=x,O.$x.$localOffset=S}else O=this.utc();return O};var p=c.format;c.format=function(b){var _=b||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return p.call(this,_)},c.valueOf=function(){var b=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*b},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var m=c.toDate;c.toDate=function(b){return b==="s"&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():m.call(this)};var g=c.diff;c.diff=function(b,_,y){if(b&&this.$u===b.$u)return g.call(this,b,_,y);var x=this.local(),O=s(b).local();return g.call(x,O,_,y)}}})})(Ok);var Mk=Ok.exports;const FN=mn(Mk);var Bw={};Bw.d=(e,t)=>{for(var r in t)Bw.o(t,r)&&!Bw.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},Bw.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var bt=globalThis.pdfjsLib={};Bw.d(bt,{AbortException:()=>jf,AnnotationEditorLayer:()=>wR,AnnotationEditorParamsType:()=>_t,AnnotationEditorType:()=>Qt,AnnotationEditorUIManager:()=>Mf,AnnotationLayer:()=>F8e,AnnotationMode:()=>Ru,CMapCompressionType:()=>VN,ColorPicker:()=>LT,DOMSVGFactory:()=>YN,DrawLayer:()=>xR,FeatureTest:()=>Na,GlobalWorkerOptions:()=>kc,ImageKind:()=>yT,InvalidPDFException:()=>Pk,MissingPDFException:()=>xf,OPS:()=>as,Outliner:()=>bR,PDFDataRangeTransport:()=>iG,PDFDateString:()=>Nk,PDFWorker:()=>Xm,PasswordResponses:()=>XKe,PermissionFlag:()=>HKe,PixelsPerInch:()=>Fu,RenderingCancelledException:()=>qN,TextLayer:()=>RT,UnexpectedResponseException:()=>jT,Util:()=>rt,VerbosityLevel:()=>_T,XfaLayer:()=>uG,build:()=>y8e,createValidAbsoluteUrl:()=>YKe,fetchData:()=>TT,getDocument:()=>u8e,getFilenameFromUrl:()=>a6e,getPdfFilenameFromUrl:()=>i6e,getXfaPageViewport:()=>s6e,isDataScheme:()=>JN,isPdfFile:()=>QN,noContextMenu:()=>Ra,normalizeUnicode:()=>t6e,renderTextLayer:()=>t8e,setLayerDimensions:()=>Of,shadow:()=>ar,updateTextLayer:()=>r8e,version:()=>v8e});const oa=typeof st=="object"&&st+""=="[object process]"&&!st.versions.nw&&!(st.versions.electron&&st.type&&st.type!=="browser"),Sk=[1,0,0,1,0,0],BN=[.001,0,0,.001,0,0],VKe=1e7,LN=1.35,zi={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},Ru={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},KKe="pdfjs_internal_editor_",Qt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},_t={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},HKe={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},aa={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},yT={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},eo={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},Lw={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},_T={ERRORS:0,WARNINGS:1,INFOS:5},VN={NONE:0,BINARY:1},as={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},XKe={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let wT=_T.WARNINGS;function WKe(e){Number.isInteger(e)&&(wT=e)}function kKe(){return wT}function xT(e){wT>=_T.INFOS&&console.log(`Info: ${e}`)}function Dt(e){wT>=_T.WARNINGS&&console.log(`Warning: ${e}`)}function Er(e){throw new Error(e)}function to(e,t){e||Er(t)}function GKe(e){switch(e==null?void 0:e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function YKe(e,t=null,r=null){if(!e)return null;try{if(r&&typeof e=="string"){if(r.addDefaultProtocol&&e.startsWith("www.")){const o=e.match(/\./g);(o==null?void 0:o.length)>=2&&(e=`http://${e}`)}if(r.tryConvertEncoding)try{e=e6e(e)}catch{}}const n=t?new URL(e,t):new URL(e);if(GKe(n))return n}catch{}return null}function ar(e,t,r,n=!1){return Object.defineProperty(e,t,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}const $u=function(){function t(r,n){this.constructor===t&&Er("Cannot initialize BaseException."),this.message=r,this.name=n}return t.prototype=new Error,t.constructor=t,t}();class KN extends $u{constructor(t,r){super(t,"PasswordException"),this.code=r}}class HN extends $u{constructor(t,r){super(t,"UnknownErrorException"),this.details=r}}class Pk extends $u{constructor(t){super(t,"InvalidPDFException")}}class xf extends $u{constructor(t){super(t,"MissingPDFException")}}class jT extends $u{constructor(t,r){super(t,"UnexpectedResponseException"),this.status=r}}class qKe extends $u{constructor(t){super(t,"FormatError")}}class jf extends $u{constructor(t){super(t,"AbortException")}}function Ek(e){(typeof e!="object"||(e==null?void 0:e.length)===void 0)&&Er("Invalid argument for bytesToString");const t=e.length,r=8192;if(t<r)return String.fromCharCode.apply(null,e);const n=[];for(let o=0;o<t;o+=r){const a=Math.min(o+r,t),i=e.subarray(o,a);n.push(String.fromCharCode.apply(null,i))}return n.join("")}function OT(e){typeof e!="string"&&Er("Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let n=0;n<t;++n)r[n]=e.charCodeAt(n)&255;return r}function JKe(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function XN(e){const t=Object.create(null);for(const[r,n]of e)t[r]=n;return t}function QKe(){const e=new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}function ZKe(){try{return new Function(""),!0}catch{return!1}}class Na{static get isLittleEndian(){return ar(this,"isLittleEndian",QKe())}static get isEvalSupported(){return ar(this,"isEvalSupported",ZKe())}static get isOffscreenCanvasSupported(){return ar(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?ar(this,"platform",{isMac:navigator.platform.includes("Mac")}):ar(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){var t,r;return ar(this,"isCSSRoundSupported",(r=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:r.call(t,"width: round(1.5px, 1px)"))}}const WN=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0"));class rt{static makeHexColor(t,r,n){return`#${WN[t]}${WN[r]}${WN[n]}`}static scaleMinMax(t,r){let n;t[0]?(t[0]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=t[0],r[2]*=t[0],t[3]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=t[3],r[3]*=t[3]):(n=r[0],r[0]=r[1],r[1]=n,n=r[2],r[2]=r[3],r[3]=n,t[1]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=t[1],r[3]*=t[1],t[2]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=t[2],r[2]*=t[2]),r[0]+=t[4],r[1]+=t[5],r[2]+=t[4],r[3]+=t[5]}static transform(t,r){return[t[0]*r[0]+t[2]*r[1],t[1]*r[0]+t[3]*r[1],t[0]*r[2]+t[2]*r[3],t[1]*r[2]+t[3]*r[3],t[0]*r[4]+t[2]*r[5]+t[4],t[1]*r[4]+t[3]*r[5]+t[5]]}static applyTransform(t,r){const n=t[0]*r[0]+t[1]*r[2]+r[4],o=t[0]*r[1]+t[1]*r[3]+r[5];return[n,o]}static applyInverseTransform(t,r){const n=r[0]*r[3]-r[1]*r[2],o=(t[0]*r[3]-t[1]*r[2]+r[2]*r[5]-r[4]*r[3])/n,a=(-t[0]*r[1]+t[1]*r[0]+r[4]*r[1]-r[5]*r[0])/n;return[o,a]}static getAxialAlignedBoundingBox(t,r){const n=this.applyTransform(t,r),o=this.applyTransform(t.slice(2,4),r),a=this.applyTransform([t[0],t[3]],r),i=this.applyTransform([t[2],t[1]],r);return[Math.min(n[0],o[0],a[0],i[0]),Math.min(n[1],o[1],a[1],i[1]),Math.max(n[0],o[0],a[0],i[0]),Math.max(n[1],o[1],a[1],i[1])]}static inverseTransform(t){const r=t[0]*t[3]-t[1]*t[2];return[t[3]/r,-t[1]/r,-t[2]/r,t[0]/r,(t[2]*t[5]-t[4]*t[3])/r,(t[4]*t[1]-t[5]*t[0])/r]}static singularValueDecompose2dScale(t){const r=[t[0],t[2],t[1],t[3]],n=t[0]*r[0]+t[1]*r[2],o=t[0]*r[1]+t[1]*r[3],a=t[2]*r[0]+t[3]*r[2],i=t[2]*r[1]+t[3]*r[3],s=(n+i)/2,c=Math.sqrt((n+i)**2-4*(n*i-a*o))/2,l=s+c||1,u=s-c||1;return[Math.sqrt(l),Math.sqrt(u)]}static normalizeRect(t){const r=t.slice(0);return t[0]>t[2]&&(r[0]=t[2],r[2]=t[0]),t[1]>t[3]&&(r[1]=t[3],r[3]=t[1]),r}static intersect(t,r){const n=Math.max(Math.min(t[0],t[2]),Math.min(r[0],r[2])),o=Math.min(Math.max(t[0],t[2]),Math.max(r[0],r[2]));if(n>o)return null;const a=Math.max(Math.min(t[1],t[3]),Math.min(r[1],r[3])),i=Math.min(Math.max(t[1],t[3]),Math.max(r[1],r[3]));return a>i?null:[n,a,o,i]}static bezierBoundingBox(t,r,n,o,a,i,s,c,l){return l?(l[0]=Math.min(l[0],t,s),l[1]=Math.min(l[1],r,c),l[2]=Math.max(l[2],t,s),l[3]=Math.max(l[3],r,c)):l=[Math.min(t,s),Math.min(r,c),Math.max(t,s),Math.max(r,c)],J(this,Jc,w$).call(this,t,n,a,s,r,o,i,c,3*(-t+3*(n-a)+s),6*(t-2*n+a),3*(n-t),l),J(this,Jc,w$).call(this,t,n,a,s,r,o,i,c,3*(-r+3*(o-i)+c),6*(r-2*o+i),3*(o-r),l),l}}Jc=new WeakSet,UA=function(t,r,n,o,a,i,s,c,l,u){if(l<=0||l>=1)return;const h=1-l,p=l*l,m=p*l,g=h*(h*(h*t+3*l*r)+3*p*n)+m*o,b=h*(h*(h*a+3*l*i)+3*p*s)+m*c;u[0]=Math.min(u[0],g),u[1]=Math.min(u[1],b),u[2]=Math.max(u[2],g),u[3]=Math.max(u[3],b)},w$=function(t,r,n,o,a,i,s,c,l,u,h,p){if(Math.abs(l)<1e-12){Math.abs(u)>=1e-12&&J(this,Jc,UA).call(this,t,r,n,o,a,i,s,c,-h/u,p);return}const m=u**2-4*h*l;if(m<0)return;const g=Math.sqrt(m),b=2*l;J(this,Jc,UA).call(this,t,r,n,o,a,i,s,c,(-u+g)/b,p),J(this,Jc,UA).call(this,t,r,n,o,a,i,s,c,(-u-g)/b,p)},ee(rt,Jc);function e6e(e){return decodeURIComponent(escape(e))}let kN=null,Tk=null;function t6e(e){return kN||(kN=/([\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,Tk=new Map([["ſt","ſt"]])),e.replaceAll(kN,(t,r,n)=>r?r.normalize("NFKC"):Tk.get(n))}function r6e(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const e=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(e);else for(let t=0;t<32;t++)e[t]=Math.floor(Math.random()*255);return Ek(e)}const Ak="pdfjs_internal_id_",Hc={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class MT{constructor(){this.constructor===MT&&Er("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,r){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,r,n,o,a){return"none"}destroy(t=!1){}}const g$=class g${constructor({enableHWA:t=!1}={}){ee(this,n0,!1);this.constructor===g$&&Er("Cannot initialize BaseCanvasFactory."),Y(this,n0,t)}create(t,r){if(t<=0||r<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(t,r);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!v(this,n0)})}}reset(t,r,n){if(!t.canvas)throw new Error("Canvas is not specified");if(r<=0||n<=0)throw new Error("Invalid canvas size");t.canvas.width=r,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,r){Er("Abstract method `_createCanvas` called.")}};n0=new WeakMap;let ST=g$;class PT{constructor({baseUrl:t=null,isCompressed:r=!0}){this.constructor===PT&&Er("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=r}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const r=this.baseUrl+t+(this.isCompressed?".bcmap":""),n=this.isCompressed?VN.BINARY:VN.NONE;return this._fetchData(r,n).catch(o=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${r}`)})}_fetchData(t,r){Er("Abstract method `_fetchData` called.")}}class ET{constructor({baseUrl:t=null}){this.constructor===ET&&Er("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const r=`${this.baseUrl}${t}`;return this._fetchData(r).catch(n=>{throw new Error(`Unable to load font data at: ${r}`)})}_fetchData(t){Er("Abstract method `_fetchData` called.")}}class GN{constructor(){this.constructor===GN&&Er("Cannot initialize BaseSVGFactory.")}create(t,r,n=!1){if(t<=0||r<=0)throw new Error("Invalid SVG dimensions");const o=this._createSVG("svg:svg");return o.setAttribute("version","1.1"),n||(o.setAttribute("width",`${t}px`),o.setAttribute("height",`${r}px`)),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("viewBox",`0 0 ${t} ${r}`),o}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Er("Abstract method `_createSVG` called.")}}const Xc="http://www.w3.org/2000/svg",If=class If{};Qe(If,"CSS",96),Qe(If,"PDF",72),Qe(If,"PDF_TO_CSS_UNITS",If.CSS/If.PDF);let Fu=If;class n6e extends MT{constructor({docId:r,ownerDocument:n=globalThis.document}={}){super();ee(this,Je);ee(this,zf);ee(this,rc);ee(this,Qc);ee(this,Ba);ee(this,pA);ee(this,Uf,0);Y(this,Qc,r),Y(this,Ba,n)}addFilter(r){if(!r)return"none";let n=v(this,Je,ua).get(r);if(n)return n;const[o,a,i]=J(this,Je,NA).call(this,r),s=r.length===1?o:`${o}${a}${i}`;if(n=v(this,Je,ua).get(s),n)return v(this,Je,ua).set(r,n),n;const c=`g_${v(this,Qc)}_transfer_map_${hi(this,Uf)._++}`,l=`url(#${c})`;v(this,Je,ua).set(r,l),v(this,Je,ua).set(s,l);const u=J(this,Je,eb).call(this,c);return J(this,Je,Rx).call(this,o,a,i,u),l}addHCMFilter(r,n){var g;const o=`${r}-${n}`,a="base";let i=v(this,Je,Qg).get(a);if((i==null?void 0:i.key)===o||(i?((g=i.filter)==null||g.remove(),i.key=o,i.url="none",i.filter=null):(i={key:o,url:"none",filter:null},v(this,Je,Qg).set(a,i)),!r||!n))return i.url;const s=J(this,Je,$x).call(this,r);r=rt.makeHexColor(...s);const c=J(this,Je,$x).call(this,n);if(n=rt.makeHexColor(...c),v(this,Je,Zg).style.color="",r==="#000000"&&n==="#ffffff"||r===n)return i.url;const l=new Array(256);for(let b=0;b<=255;b++){const _=b/255;l[b]=_<=.03928?_/12.92:((_+.055)/1.055)**2.4}const u=l.join(","),h=`g_${v(this,Qc)}_hcm_filter`,p=i.filter=J(this,Je,eb).call(this,h);J(this,Je,Rx).call(this,u,u,u,p),J(this,Je,x$).call(this,p);const m=(b,_)=>{const y=s[b]/255,x=c[b]/255,O=new Array(_+1);for(let S=0;S<=_;S++)O[S]=y+S/_*(x-y);return O.join(",")};return J(this,Je,Rx).call(this,m(0,5),m(1,5),m(2,5),p),i.url=`url(#${h})`,i.url}addAlphaFilter(r){let n=v(this,Je,ua).get(r);if(n)return n;const[o]=J(this,Je,NA).call(this,[r]),a=`alpha_${o}`;if(n=v(this,Je,ua).get(a),n)return v(this,Je,ua).set(r,n),n;const i=`g_${v(this,Qc)}_alpha_map_${hi(this,Uf)._++}`,s=`url(#${i})`;v(this,Je,ua).set(r,s),v(this,Je,ua).set(a,s);const c=J(this,Je,eb).call(this,i);return J(this,Je,j$).call(this,o,c),s}addLuminosityFilter(r){let n=v(this,Je,ua).get(r||"luminosity");if(n)return n;let o,a;if(r?([o]=J(this,Je,NA).call(this,[r]),a=`luminosity_${o}`):a="luminosity",n=v(this,Je,ua).get(a),n)return v(this,Je,ua).set(r,n),n;const i=`g_${v(this,Qc)}_luminosity_map_${hi(this,Uf)._++}`,s=`url(#${i})`;v(this,Je,ua).set(r,s),v(this,Je,ua).set(a,s);const c=J(this,Je,eb).call(this,i);return J(this,Je,aJ).call(this,c),r&&J(this,Je,j$).call(this,o,c),s}addHighlightHCMFilter(r,n,o,a,i){var x;const s=`${n}-${o}-${a}-${i}`;let c=v(this,Je,Qg).get(r);if((c==null?void 0:c.key)===s||(c?((x=c.filter)==null||x.remove(),c.key=s,c.url="none",c.filter=null):(c={key:s,url:"none",filter:null},v(this,Je,Qg).set(r,c)),!n||!o))return c.url;const[l,u]=[n,o].map(J(this,Je,$x).bind(this));let h=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),p=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),[m,g]=[a,i].map(J(this,Je,$x).bind(this));p<h&&([h,p,m,g]=[p,h,g,m]),v(this,Je,Zg).style.color="";const b=(O,S,j)=>{const P=new Array(256),I=(p-h)/j,M=O/255,E=(S-O)/(255*j);let D=0;for(let A=0;A<=j;A++){const z=Math.round(h+A*I),$=M+A*E;for(let L=D;L<=z;L++)P[L]=$;D=z+1}for(let A=D;A<256;A++)P[A]=P[D-1];return P.join(",")},_=`g_${v(this,Qc)}_hcm_${r}_filter`,y=c.filter=J(this,Je,eb).call(this,_);return J(this,Je,x$).call(this,y),J(this,Je,Rx).call(this,b(m[0],g[0],5),b(m[1],g[1],5),b(m[2],g[2],5),y),c.url=`url(#${_})`,c.url}destroy(r=!1){r&&v(this,Je,Qg).size!==0||(v(this,rc)&&(v(this,rc).parentNode.parentNode.remove(),Y(this,rc,null)),v(this,zf)&&(v(this,zf).clear(),Y(this,zf,null)),Y(this,Uf,0))}}zf=new WeakMap,rc=new WeakMap,Qc=new WeakMap,Ba=new WeakMap,pA=new WeakMap,Uf=new WeakMap,Je=new WeakSet,ua=function(){return v(this,zf)||Y(this,zf,new Map)},Qg=function(){return v(this,pA)||Y(this,pA,new Map)},Zg=function(){if(!v(this,rc)){const r=v(this,Ba).createElement("div"),{style:n}=r;n.visibility="hidden",n.contain="strict",n.width=n.height=0,n.position="absolute",n.top=n.left=0,n.zIndex=-1;const o=v(this,Ba).createElementNS(Xc,"svg");o.setAttribute("width",0),o.setAttribute("height",0),Y(this,rc,v(this,Ba).createElementNS(Xc,"defs")),r.append(o),o.append(v(this,rc)),v(this,Ba).body.append(r)}return v(this,rc)},NA=function(r){if(r.length===1){const l=r[0],u=new Array(256);for(let p=0;p<256;p++)u[p]=l[p]/255;const h=u.join(",");return[h,h,h]}const[n,o,a]=r,i=new Array(256),s=new Array(256),c=new Array(256);for(let l=0;l<256;l++)i[l]=n[l]/255,s[l]=o[l]/255,c[l]=a[l]/255;return[i.join(","),s.join(","),c.join(",")]},aJ=function(r){const n=v(this,Ba).createElementNS(Xc,"feColorMatrix");n.setAttribute("type","matrix"),n.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"),r.append(n)},x$=function(r){const n=v(this,Ba).createElementNS(Xc,"feColorMatrix");n.setAttribute("type","matrix"),n.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"),r.append(n)},eb=function(r){const n=v(this,Ba).createElementNS(Xc,"filter");return n.setAttribute("color-interpolation-filters","sRGB"),n.setAttribute("id",r),v(this,Je,Zg).append(n),n},Nx=function(r,n,o){const a=v(this,Ba).createElementNS(Xc,n);a.setAttribute("type","discrete"),a.setAttribute("tableValues",o),r.append(a)},Rx=function(r,n,o,a){const i=v(this,Ba).createElementNS(Xc,"feComponentTransfer");a.append(i),J(this,Je,Nx).call(this,i,"feFuncR",r),J(this,Je,Nx).call(this,i,"feFuncG",n),J(this,Je,Nx).call(this,i,"feFuncB",o)},j$=function(r,n){const o=v(this,Ba).createElementNS(Xc,"feComponentTransfer");n.append(o),J(this,Je,Nx).call(this,o,"feFuncA",r)},$x=function(r){return v(this,Je,Zg).style.color=r,ZN(getComputedStyle(v(this,Je,Zg)).getPropertyValue("color"))};class o6e extends ST{constructor({ownerDocument:t=globalThis.document,enableHWA:r=!1}={}){super({enableHWA:r}),this._document=t}_createCanvas(t,r){const n=this._document.createElement("canvas");return n.width=t,n.height=r,n}}async function TT(e,t="text"){if(Kw(e,document.baseURI)){const r=await fetch(e);if(!r.ok)throw new Error(r.statusText);switch(t){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise((r,n)=>{const o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType=t,o.onreadystatechange=()=>{if(o.readyState===XMLHttpRequest.DONE){if(o.status===200||o.status===0){switch(t){case"arraybuffer":case"blob":case"json":r(o.response);return}r(o.responseText);return}n(new Error(o.statusText))}},o.send(null)})}class Ck extends PT{_fetchData(t,r){return TT(t,this.isCompressed?"arraybuffer":"text").then(n=>({cMapData:n instanceof ArrayBuffer?new Uint8Array(n):OT(n),compressionType:r}))}}class Dk extends ET{_fetchData(t){return TT(t,"arraybuffer").then(r=>new Uint8Array(r))}}class YN extends GN{_createSVG(t){return document.createElementNS(Xc,t)}}class Vw{constructor({viewBox:t,scale:r,rotation:n,offsetX:o=0,offsetY:a=0,dontFlip:i=!1}){this.viewBox=t,this.scale=r,this.rotation=n,this.offsetX=o,this.offsetY=a;const s=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let l,u,h,p;switch(n%=360,n<0&&(n+=360),n){case 180:l=-1,u=0,h=0,p=1;break;case 90:l=0,u=1,h=1,p=0;break;case 270:l=0,u=-1,h=-1,p=0;break;case 0:l=1,u=0,h=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}i&&(h=-h,p=-p);let m,g,b,_;l===0?(m=Math.abs(c-t[1])*r+o,g=Math.abs(s-t[0])*r+a,b=(t[3]-t[1])*r,_=(t[2]-t[0])*r):(m=Math.abs(s-t[0])*r+o,g=Math.abs(c-t[1])*r+a,b=(t[2]-t[0])*r,_=(t[3]-t[1])*r),this.transform=[l*r,u*r,h*r,p*r,m-l*r*s-h*r*c,g-u*r*s-p*r*c],this.width=b,this.height=_}get rawDims(){const{viewBox:t}=this;return ar(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:r=this.rotation,offsetX:n=this.offsetX,offsetY:o=this.offsetY,dontFlip:a=!1}={}){return new Vw({viewBox:this.viewBox.slice(),scale:t,rotation:r,offsetX:n,offsetY:o,dontFlip:a})}convertToViewportPoint(t,r){return rt.applyTransform([t,r],this.transform)}convertToViewportRectangle(t){const r=rt.applyTransform([t[0],t[1]],this.transform),n=rt.applyTransform([t[2],t[3]],this.transform);return[r[0],r[1],n[0],n[1]]}convertToPdfPoint(t,r){return rt.applyInverseTransform([t,r],this.transform)}}class qN extends $u{constructor(t,r=0){super(t,"RenderingCancelledException"),this.extraDelay=r}}function JN(e){const t=e.length;let r=0;for(;r<t&&e[r].trim()==="";)r++;return e.substring(r,r+5).toLowerCase()==="data:"}function QN(e){return typeof e=="string"&&/\.pdf$/i.test(e)}function a6e(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function i6e(e,t="document.pdf"){if(typeof e!="string")return t;if(JN(e))return Dt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const r=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,o=r.exec(e);let a=n.exec(o[1])||n.exec(o[2])||n.exec(o[3]);if(a&&(a=a[0],a.includes("%")))try{a=n.exec(decodeURIComponent(a))[0]}catch{}return a||t}class Ik{constructor(){Qe(this,"started",Object.create(null));Qe(this,"times",[])}time(t){t in this.started&&Dt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Dt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let r=0;for(const{name:n}of this.times)r=Math.max(n.length,r);for(const{name:n,start:o,end:a}of this.times)t.push(`${n.padEnd(r)} ${a-o}ms
185
185
  `);return t.join("")}}function Kw(e,t){try{const{protocol:r}=t?new URL(e,t):new URL(e);return r==="http:"||r==="https:"}catch{return!1}}function Ra(e){e.preventDefault()}function zk(e){console.log("Deprecated API usage: "+e)}let Uk;class Nk{static toDateObject(t){if(!t||typeof t!="string")return null;Uk||(Uk=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const r=Uk.exec(t);if(!r)return null;const n=parseInt(r[1],10);let o=parseInt(r[2],10);o=o>=1&&o<=12?o-1:0;let a=parseInt(r[3],10);a=a>=1&&a<=31?a:1;let i=parseInt(r[4],10);i=i>=0&&i<=23?i:0;let s=parseInt(r[5],10);s=s>=0&&s<=59?s:0;let c=parseInt(r[6],10);c=c>=0&&c<=59?c:0;const l=r[7]||"Z";let u=parseInt(r[8],10);u=u>=0&&u<=23?u:0;let h=parseInt(r[9],10)||0;return h=h>=0&&h<=59?h:0,l==="-"?(i+=u,s+=h):l==="+"&&(i-=u,s-=h),new Date(Date.UTC(n,o,a,i,s,c))}}function s6e(e,{scale:t=1,rotation:r=0}){const{width:n,height:o}=e.attributes.style,a=[0,0,parseInt(n),parseInt(o)];return new Vw({viewBox:a,scale:t,rotation:r})}function ZN(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map(t=>parseInt(t)):e.startsWith("rgba(")?e.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Dt(`Not a valid color format: "${e}"`),[0,0,0])}function c6e(e){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const r of e.keys()){t.style.color=r;const n=window.getComputedStyle(t).color;e.set(r,ZN(n))}t.remove()}function ln(e){const{a:t,b:r,c:n,d:o,e:a,f:i}=e.getTransform();return[t,r,n,o,a,i]}function Wc(e){const{a:t,b:r,c:n,d:o,e:a,f:i}=e.getTransform().invertSelf();return[t,r,n,o,a,i]}function Of(e,t,r=!1,n=!0){if(t instanceof Vw){const{pageWidth:o,pageHeight:a}=t.rawDims,{style:i}=e,s=Na.isCSSRoundSupported,c=`var(--scale-factor) * ${o}px`,l=`var(--scale-factor) * ${a}px`,u=s?`round(${c}, 1px)`:`calc(${c})`,h=s?`round(${l}, 1px)`:`calc(${l})`;!r||t.rotation%180===0?(i.width=u,i.height=h):(i.width=h,i.height=u)}n&&e.setAttribute("data-main-rotation",t.rotation)}const gA=class gA{constructor(t){ee(this,ga);ee(this,Nf,null);ee(this,Rf,null);ee(this,ri);ee(this,$f,null);Y(this,ri,t)}render(){const t=Y(this,Nf,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const r=v(this,ri)._uiManager._signal;t.addEventListener("contextmenu",Ra,{signal:r}),t.addEventListener("pointerdown",J(gA,mA,iJ),{signal:r});const n=Y(this,$f,document.createElement("div"));n.className="buttons",t.append(n);const o=v(this,ri).toolbarPosition;if(o){const{style:a}=t,i=v(this,ri)._uiManager.direction==="ltr"?1-o[0]:o[0];a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*o[1]}% + var(--editor-toolbar-vert-offset))`}return J(this,ga,lJ).call(this),t}hide(){var t;v(this,Nf).classList.add("hidden"),(t=v(this,Rf))==null||t.hideDropdown()}show(){v(this,Nf).classList.remove("hidden")}addAltTextButton(t){J(this,ga,RA).call(this,t),v(this,$f).prepend(t,v(this,ga,O$))}addColorPicker(t){Y(this,Rf,t);const r=t.renderButton();J(this,ga,RA).call(this,r),v(this,$f).prepend(r,v(this,ga,O$))}remove(){var t;v(this,Nf).remove(),(t=v(this,Rf))==null||t.destroy(),Y(this,Rf,null)}};Nf=new WeakMap,Rf=new WeakMap,ri=new WeakMap,$f=new WeakMap,mA=new WeakSet,iJ=function(t){t.stopPropagation()},ga=new WeakSet,sJ=function(t){v(this,ri)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},cJ=function(t){v(this,ri)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},RA=function(t){const r=v(this,ri)._uiManager._signal;t.addEventListener("focusin",J(this,ga,sJ).bind(this),{capture:!0,signal:r}),t.addEventListener("focusout",J(this,ga,cJ).bind(this),{capture:!0,signal:r}),t.addEventListener("contextmenu",Ra,{signal:r})},lJ=function(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${v(this,ri).editorType}-button`),J(this,ga,RA).call(this,t),t.addEventListener("click",r=>{v(this,ri)._uiManager.delete()},{signal:v(this,ri)._uiManager._signal}),v(this,$f).append(t)},O$=function(){const t=document.createElement("div");return t.className="divider",t},ee(gA,mA);let eR=gA;class l6e{constructor(t){ee(this,Ku);ee(this,o0,null);ee(this,Ff,null);ee(this,Bf);Y(this,Bf,t)}show(t,r,n){const[o,a]=J(this,Ku,dJ).call(this,r,n),{style:i}=v(this,Ff)||Y(this,Ff,J(this,Ku,uJ).call(this));t.append(v(this,Ff)),i.insetInlineEnd=`${100*o}%`,i.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){v(this,Ff).remove()}}o0=new WeakMap,Ff=new WeakMap,Bf=new WeakMap,Ku=new WeakSet,uJ=function(){const t=Y(this,Ff,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ra,{signal:v(this,Bf)._signal});const r=Y(this,o0,document.createElement("div"));return r.className="buttons",t.append(r),J(this,Ku,fJ).call(this),t},dJ=function(t,r){let n=0,o=0;for(const a of t){const i=a.y+a.height;if(i<n)continue;const s=a.x+(r?a.width:0);if(i>n){o=s,n=i;continue}r?s>o&&(o=s):s<o&&(o=s)}return[r?1-o:o,n]},fJ=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const r=document.createElement("span");t.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=v(this,Bf)._signal;t.addEventListener("contextmenu",Ra,{signal:n}),t.addEventListener("click",()=>{v(this,Bf).highlightSelection("floating_button")},{signal:n}),v(this,o0).append(t)};function AT(e,t,r){for(const n of r)t.addEventListener(n,e[n].bind(e))}function u6e(e){return Math.round(Math.min(255,Math.max(1,255*e))).toString(16).padStart(2,"0")}class d6e{constructor(){ee(this,bA,0)}get id(){return`${KKe}${hi(this,bA)._++}`}}bA=new WeakMap;const b$=class b${constructor(){ee(this,i0);ee(this,a0,r6e());ee(this,vA,0);ee(this,Ri,null)}static get _isSVGFittingCanvas(){const 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}),o=new Image;o.src=t;const a=o.decode().then(()=>(n.drawImage(o,0,0,1,1,0,0,1,3),new Uint32Array(n.getImageData(0,0,1,1).data.buffer)[0]===0));return ar(this,"_isSVGFittingCanvas",a)}async getFromFile(t){const{lastModified:r,name:n,size:o,type:a}=t;return J(this,i0,M$).call(this,`${r}_${n}_${o}_${a}`,t)}async getFromUrl(t){return J(this,i0,M$).call(this,t,t)}async getFromId(t){v(this,Ri)||Y(this,Ri,new Map);const r=v(this,Ri).get(t);return r?r.bitmap?(r.refCounter+=1,r):r.file?this.getFromFile(r.file):this.getFromUrl(r.url):null}getSvgUrl(t){const r=v(this,Ri).get(t);return r!=null&&r.isSvg?r.svgUrl:null}deleteId(t){v(this,Ri)||Y(this,Ri,new Map);const r=v(this,Ri).get(t);r&&(r.refCounter-=1,r.refCounter===0&&(r.bitmap=null))}isValidId(t){return t.startsWith(`image_${v(this,a0)}_`)}};a0=new WeakMap,vA=new WeakMap,Ri=new WeakMap,i0=new WeakSet,M$=async function(t,r){v(this,Ri)||Y(this,Ri,new Map);let n=v(this,Ri).get(t);if(n===null)return null;if(n!=null&&n.bitmap)return n.refCounter+=1,n;try{n||(n={bitmap:null,id:`image_${v(this,a0)}_${hi(this,vA)._++}`,refCounter:0,isSvg:!1});let o;if(typeof r=="string"?(n.url=r,o=await TT(r,"blob")):o=n.file=r,o.type==="image/svg+xml"){const a=b$._isSVGFittingCanvas,i=new FileReader,s=new Image,c=new Promise((l,u)=>{s.onload=()=>{n.bitmap=s,n.isSvg=!0,l()},i.onload=async()=>{const h=n.svgUrl=i.result;s.src=await a?`${h}#svgView(preserveAspectRatio(none))`:h},s.onerror=i.onerror=u});i.readAsDataURL(o),await c}else n.bitmap=await createImageBitmap(o);n.refCounter=1}catch(o){console.error(o),n=null}return v(this,Ri).set(t,n),n&&v(this,Ri).set(n.id,n),n};let tR=b$;class f6e{constructor(t=128){ee(this,wo,[]);ee(this,Hu,!1);ee(this,s0);ee(this,xo,-1);Y(this,s0,t)}add({cmd:t,undo:r,post:n,mustExec:o,type:a=NaN,overwriteIfSameType:i=!1,keepUndo:s=!1}){if(o&&t(),v(this,Hu))return;const c={cmd:t,undo:r,post:n,type:a};if(v(this,xo)===-1){v(this,wo).length>0&&(v(this,wo).length=0),Y(this,xo,0),v(this,wo).push(c);return}if(i&&v(this,wo)[v(this,xo)].type===a){s&&(c.undo=v(this,wo)[v(this,xo)].undo),v(this,wo)[v(this,xo)]=c;return}const l=v(this,xo)+1;l===v(this,s0)?v(this,wo).splice(0,1):(Y(this,xo,l),l<v(this,wo).length&&v(this,wo).splice(l)),v(this,wo).push(c)}undo(){if(v(this,xo)===-1)return;Y(this,Hu,!0);const{undo:t,post:r}=v(this,wo)[v(this,xo)];t(),r==null||r(),Y(this,Hu,!1),Y(this,xo,v(this,xo)-1)}redo(){if(v(this,xo)<v(this,wo).length-1){Y(this,xo,v(this,xo)+1),Y(this,Hu,!0);const{cmd:t,post:r}=v(this,wo)[v(this,xo)];t(),r==null||r(),Y(this,Hu,!1)}}hasSomethingToUndo(){return v(this,xo)!==-1}hasSomethingToRedo(){return v(this,xo)<v(this,wo).length-1}destroy(){Y(this,wo,null)}}wo=new WeakMap,Hu=new WeakMap,s0=new WeakMap,xo=new WeakMap;class Hw{constructor(t){ee(this,yA);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:r}=Na.platform;for(const[n,o,a={}]of t)for(const i of n){const s=i.startsWith("mac+");r&&s?(this.callbacks.set(i.slice(4),{callback:o,options:a}),this.allKeys.add(i.split("+").at(-1))):!r&&!s&&(this.callbacks.set(i,{callback:o,options:a}),this.allKeys.add(i.split("+").at(-1)))}}exec(t,r){if(!this.allKeys.has(r.key))return;const n=this.callbacks.get(J(this,yA,hJ).call(this,r));if(!n)return;const{callback:o,options:{bubbles:a=!1,args:i=[],checker:s=null}}=n;s&&!s(t,r)||(o.bind(t,...i,r)(),a||(r.stopPropagation(),r.preventDefault()))}}yA=new WeakSet,hJ=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const r=this.buffer.join("+");return this.buffer.length=0,r};const _A=class _A{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return c6e(t),ar(this,"_colors",t)}convert(t){const r=ZN(t);if(!window.matchMedia("(forced-colors: active)").matches)return r;for(const[n,o]of this._colors)if(o.every((a,i)=>a===r[i]))return _A._colorsMapping.get(n);return r}getHexCode(t){const r=this._colors.get(t);return r?rt.makeHexColor(...r):t}};Qe(_A,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let rR=_A;const og=class og{constructor(t,r,n,o,a,i,s,c,l){ee(this,Xe);ee(this,Qm,new AbortController);ee(this,ni,null);ee(this,ro,new Map);ee(this,Io,new Map);ee(this,Zm,null);ee(this,Zc,null);ee(this,eg,null);ee(this,is,new f6e);ee(this,tg,0);ee(this,Lf,new Set);ee(this,nc,null);ee(this,ss,null);ee(this,Vf,new Set);ee(this,c0,!1);ee(this,l0,null);ee(this,oc,null);ee(this,rg,null);ee(this,Xu,!1);ee(this,ac,null);ee(this,wA,new d6e);ee(this,Wu,!1);ee(this,u0,!1);ee(this,Kf,null);ee(this,d0,null);ee(this,ng,null);ee(this,zo,Qt.NONE);ee(this,_r,new Set);ee(this,el,null);ee(this,Hf,null);ee(this,f0,null);ee(this,h0,this.blur.bind(this));ee(this,p0,this.focus.bind(this));ee(this,m0,this.copy.bind(this));ee(this,g0,this.cut.bind(this));ee(this,b0,this.paste.bind(this));ee(this,v0,this.keydown.bind(this));ee(this,y0,this.keyup.bind(this));ee(this,_0,this.onEditingAction.bind(this));ee(this,w0,this.onPageChanging.bind(this));ee(this,x0,this.onScaleChanging.bind(this));ee(this,j0,this.onRotationChanging.bind(this));ee(this,O0,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});ee(this,ku,[0,0]);ee(this,ic,null);ee(this,tl,null);ee(this,M0,null);this._signal=v(this,Qm).signal,Y(this,tl,t),Y(this,M0,r),Y(this,Zm,n),this._eventBus=o,this._eventBus._on("editingaction",v(this,_0)),this._eventBus._on("pagechanging",v(this,w0)),this._eventBus._on("scalechanging",v(this,x0)),this._eventBus._on("rotationchanging",v(this,j0)),J(this,Xe,gJ).call(this),J(this,Xe,_J).call(this),J(this,Xe,S$).call(this),Y(this,Zc,a.annotationStorage),Y(this,l0,a.filterFactory),Y(this,Hf,i),Y(this,rg,s||null),Y(this,c0,c),Y(this,ng,l||null),this.viewParameters={realScale:Fu.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=og.prototype,r=i=>v(i,tl).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&i.hasSomethingToControl(),n=(i,{target:s})=>{if(s instanceof HTMLInputElement){const{type:c}=s;return c!=="text"&&c!=="number"}return!0},o=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return ar(this,"_keyboardManager",new Hw([[["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:(i,{target:s})=>!(s instanceof HTMLButtonElement)&&v(i,tl).contains(s)&&!i.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(i,{target:s})=>!(s instanceof HTMLButtonElement)&&v(i,tl).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-o,0],checker:r}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:r}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[o,0],checker:r}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:r}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-o],checker:r}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:r}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,o],checker:r}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:r}]]))}destroy(){var t,r,n;(t=v(this,Qm))==null||t.abort(),Y(this,Qm,null),this._signal=null,this._eventBus._off("editingaction",v(this,_0)),this._eventBus._off("pagechanging",v(this,w0)),this._eventBus._off("scalechanging",v(this,x0)),this._eventBus._off("rotationchanging",v(this,j0));for(const o of v(this,Io).values())o.destroy();v(this,Io).clear(),v(this,ro).clear(),v(this,Vf).clear(),Y(this,ni,null),v(this,_r).clear(),v(this,is).destroy(),(r=v(this,Zm))==null||r.destroy(),(n=v(this,ac))==null||n.hide(),Y(this,ac,null),v(this,oc)&&(clearTimeout(v(this,oc)),Y(this,oc,null)),v(this,ic)&&(clearTimeout(v(this,ic)),Y(this,ic,null))}async mlGuess(t){var r;return((r=v(this,ng))==null?void 0:r.guess(t))||null}get hasMLManager(){return!!v(this,ng)}get hcmFilter(){return ar(this,"hcmFilter",v(this,Hf)?v(this,l0).addHCMFilter(v(this,Hf).foreground,v(this,Hf).background):"none")}get direction(){return ar(this,"direction",getComputedStyle(v(this,tl)).direction)}get highlightColors(){return ar(this,"highlightColors",v(this,rg)?new Map(v(this,rg).split(",").map(t=>t.split("=").map(r=>r.trim()))):null)}get highlightColorNames(){return ar(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){Y(this,d0,t)}editAltText(t){var r;(r=v(this,Zm))==null||r.editAltText(this,t)}onPageChanging({pageNumber:t}){Y(this,tg,t-1)}focusMainContainer(){v(this,tl).focus()}findParent(t,r){for(const n of v(this,Io).values()){const{x:o,y:a,width:i,height:s}=n.div.getBoundingClientRect();if(t>=o&&t<=o+i&&r>=a&&r<=a+s)return n}return null}disableUserSelect(t=!1){v(this,M0).classList.toggle("noUserSelect",t)}addShouldRescale(t){v(this,Vf).add(t)}removeShouldRescale(t){v(this,Vf).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Fu.PDF_TO_CSS_UNITS;for(const r of v(this,Vf))r.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const r=document.getSelection();if(!r||r.isCollapsed)return;const{anchorNode:n,anchorOffset:o,focusNode:a,focusOffset:i}=r,s=r.toString(),l=J(this,Xe,$A).call(this,r).closest(".textLayer"),u=this.getSelectionBoxes(l);if(u){r.empty(),v(this,zo)===Qt.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:Qt.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const h of v(this,Io).values())if(h.hasTextLayer(l)){h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:n,anchorOffset:o,focusNode:a,focusOffset:i,text:s});break}}}addToAnnotationStorage(t){!t.isEmpty()&&v(this,Zc)&&!v(this,Zc).has(t.id)&&v(this,Zc).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,v(this,Xu)&&(Y(this,Xu,!1),J(this,Xe,FA).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const r of v(this,_r))if(r.div.contains(t)){Y(this,Kf,[r,t]),r._focusEventsAllowed=!1;break}}focus(){if(!v(this,Kf))return;const[t,r]=v(this,Kf);Y(this,Kf,null),r.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),r.focus()}addEditListeners(){J(this,Xe,S$).call(this),J(this,Xe,P$).call(this)}removeEditListeners(){J(this,Xe,yJ).call(this),J(this,Xe,E$).call(this)}dragOver(t){for(const{type:r}of t.dataTransfer.items)for(const n of v(this,ss))if(n.isHandlingMimeForPasting(r)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const r of t.dataTransfer.items)for(const n of v(this,ss))if(n.isHandlingMimeForPasting(r.type)){n.paste(r,this.currentLayer),t.preventDefault();return}}copy(t){var n;if(t.preventDefault(),(n=v(this,ni))==null||n.commitOrRemove(),!this.hasSelection)return;const r=[];for(const o of v(this,_r)){const a=o.serialize(!0);a&&r.push(a)}r.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(r))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:r}=t;for(const a of r.items)for(const i of v(this,ss))if(i.isHandlingMimeForPasting(a.type)){i.paste(a,this.currentLayer);return}let n=r.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(a){Dt(`paste: "${a.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();const o=this.currentLayer;try{const a=[];for(const c of n){const l=o.deserialize(c);if(!l)return;a.push(l)}const i=()=>{for(const c of a)J(this,Xe,T$).call(this,c);J(this,Xe,A$).call(this,a)},s=()=>{for(const c of a)c.remove()};this.addCommands({cmd:i,undo:s,mustExec:!0})}catch(a){Dt(`paste: "${a.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),v(this,zo)!==Qt.NONE&&!this.isEditorHandlingKeyboard&&og._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,v(this,Xu)&&(Y(this,Xu,!1),J(this,Xe,FA).call(this,"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}}setEditingState(t){t?(J(this,Xe,bJ).call(this),J(this,Xe,P$).call(this),J(this,Xe,_a).call(this,{isEditing:v(this,zo)!==Qt.NONE,isEmpty:J(this,Xe,Fx).call(this),hasSomethingToUndo:v(this,is).hasSomethingToUndo(),hasSomethingToRedo:v(this,is).hasSomethingToRedo(),hasSelectedEditor:!1})):(J(this,Xe,vJ).call(this),J(this,Xe,E$).call(this),J(this,Xe,_a).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!v(this,ss)){Y(this,ss,t);for(const r of v(this,ss))J(this,Xe,hd).call(this,r.defaultPropertiesToUpdate)}}getId(){return v(this,wA).id}get currentLayer(){return v(this,Io).get(v(this,tg))}getLayer(t){return v(this,Io).get(t)}get currentPageIndex(){return v(this,tg)}addLayer(t){v(this,Io).set(t.pageIndex,t),v(this,Wu)?t.enable():t.disable()}removeLayer(t){v(this,Io).delete(t.pageIndex)}updateMode(t,r=null,n=!1){if(v(this,zo)!==t){if(Y(this,zo,t),t===Qt.NONE){this.setEditingState(!1),J(this,Xe,xJ).call(this);return}this.setEditingState(!0),J(this,Xe,wJ).call(this),this.unselectAll();for(const o of v(this,Io).values())o.updateMode(t);if(!r&&n){this.addNewEditorFromKeyboard();return}if(r){for(const o of v(this,ro).values())if(o.annotationElementId===r){this.setSelected(o),o.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==v(this,zo)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,r){var n;if(v(this,ss)){switch(t){case _t.CREATE:this.currentLayer.addNewEditor();return;case _t.HIGHLIGHT_DEFAULT_COLOR:(n=v(this,d0))==null||n.updateColor(r);break;case _t.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(v(this,f0)||Y(this,f0,new Map)).set(t,r),this.showAllEditors("highlight",r);break}for(const o of v(this,_r))o.updateParams(t,r);for(const o of v(this,ss))o.updateDefaultParams(t,r)}}showAllEditors(t,r,n=!1){var a;for(const i of v(this,ro).values())i.editorType===t&&i.show(r);(((a=v(this,f0))==null?void 0:a.get(_t.HIGHLIGHT_SHOW_ALL))??!0)!==r&&J(this,Xe,hd).call(this,[[_t.HIGHLIGHT_SHOW_ALL,r]])}enableWaiting(t=!1){if(v(this,u0)!==t){Y(this,u0,t);for(const r of v(this,Io).values())t?r.disableClick():r.enableClick(),r.div.classList.toggle("waiting",t)}}getEditors(t){const r=[];for(const n of v(this,ro).values())n.pageIndex===t&&r.push(n);return r}getEditor(t){return v(this,ro).get(t)}addEditor(t){v(this,ro).set(t.id,t)}removeEditor(t){var r;t.div.contains(document.activeElement)&&(v(this,oc)&&clearTimeout(v(this,oc)),Y(this,oc,setTimeout(()=>{this.focusMainContainer(),Y(this,oc,null)},0))),v(this,ro).delete(t.id),this.unselect(t),(!t.annotationElementId||!v(this,Lf).has(t.annotationElementId))&&((r=v(this,Zc))==null||r.remove(t.id))}addDeletedAnnotationElement(t){v(this,Lf).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return v(this,Lf).has(t)}removeDeletedAnnotationElement(t){v(this,Lf).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){v(this,ni)!==t&&(Y(this,ni,t),t&&J(this,Xe,hd).call(this,t.propertiesToUpdate))}updateUI(t){v(this,Xe,jJ)===t&&J(this,Xe,hd).call(this,t.propertiesToUpdate)}toggleSelected(t){if(v(this,_r).has(t)){v(this,_r).delete(t),t.unselect(),J(this,Xe,_a).call(this,{hasSelectedEditor:this.hasSelection});return}v(this,_r).add(t),t.select(),J(this,Xe,hd).call(this,t.propertiesToUpdate),J(this,Xe,_a).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const r of v(this,_r))r!==t&&r.unselect();v(this,_r).clear(),v(this,_r).add(t),t.select(),J(this,Xe,hd).call(this,t.propertiesToUpdate),J(this,Xe,_a).call(this,{hasSelectedEditor:!0})}isSelected(t){return v(this,_r).has(t)}get firstSelectedEditor(){return v(this,_r).values().next().value}unselect(t){t.unselect(),v(this,_r).delete(t),J(this,Xe,_a).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return v(this,_r).size!==0}get isEnterHandled(){return v(this,_r).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){v(this,is).undo(),J(this,Xe,_a).call(this,{hasSomethingToUndo:v(this,is).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:J(this,Xe,Fx).call(this)})}redo(){v(this,is).redo(),J(this,Xe,_a).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:v(this,is).hasSomethingToRedo(),isEmpty:J(this,Xe,Fx).call(this)})}addCommands(t){v(this,is).add(t),J(this,Xe,_a).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:J(this,Xe,Fx).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...v(this,_r)],r=()=>{for(const o of t)o.remove()},n=()=>{for(const o of t)J(this,Xe,T$).call(this,o)};this.addCommands({cmd:r,undo:n,mustExec:!0})}commitOrRemove(){var t;(t=v(this,ni))==null||t.commitOrRemove()}hasSomethingToControl(){return v(this,ni)||this.hasSelection}selectAll(){for(const t of v(this,_r))t.commit();J(this,Xe,A$).call(this,v(this,ro).values())}unselectAll(){if(!(v(this,ni)&&(v(this,ni).commitOrRemove(),v(this,zo)!==Qt.NONE))&&this.hasSelection){for(const t of v(this,_r))t.unselect();v(this,_r).clear(),J(this,Xe,_a).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,r,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;v(this,ku)[0]+=t,v(this,ku)[1]+=r;const[o,a]=v(this,ku),i=[...v(this,_r)],s=1e3;v(this,ic)&&clearTimeout(v(this,ic)),Y(this,ic,setTimeout(()=>{Y(this,ic,null),v(this,ku)[0]=v(this,ku)[1]=0,this.addCommands({cmd:()=>{for(const c of i)v(this,ro).has(c.id)&&c.translateInPage(o,a)},undo:()=>{for(const c of i)v(this,ro).has(c.id)&&c.translateInPage(-o,-a)},mustExec:!1})},s));for(const c of i)c.translateInPage(t,r)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),Y(this,nc,new Map);for(const t of v(this,_r))v(this,nc).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!v(this,nc))return!1;this.disableUserSelect(!1);const t=v(this,nc);Y(this,nc,null);let r=!1;for(const[{x:o,y:a,pageIndex:i},s]of t)s.newX=o,s.newY=a,s.newPageIndex=i,r||(r=o!==s.savedX||a!==s.savedY||i!==s.savedPageIndex);if(!r)return!1;const n=(o,a,i,s)=>{if(v(this,ro).has(o.id)){const c=v(this,Io).get(s);c?o._setParentAndPosition(c,a,i):(o.pageIndex=s,o.x=a,o.y=i)}};return this.addCommands({cmd:()=>{for(const[o,{newX:a,newY:i,newPageIndex:s}]of t)n(o,a,i,s)},undo:()=>{for(const[o,{savedX:a,savedY:i,savedPageIndex:s}]of t)n(o,a,i,s)},mustExec:!0}),!0}dragSelectedEditors(t,r){if(v(this,nc))for(const n of v(this,nc).keys())n.drag(t,r)}rebuild(t){if(t.parent===null){const r=this.getLayer(t.pageIndex);r?(r.changeParent(t),r.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||v(this,_r).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return v(this,ni)===t}getActive(){return v(this,ni)}getMode(){return v(this,zo)}get imageManager(){return ar(this,"imageManager",new tR)}getSelectionBoxes(t){if(!t)return null;const r=document.getSelection();for(let l=0,u=r.rangeCount;l<u;l++)if(!t.contains(r.getRangeAt(l).commonAncestorContainer))return null;const{x:n,y:o,width:a,height:i}=t.getBoundingClientRect();let s;switch(t.getAttribute("data-main-rotation")){case"90":s=(l,u,h,p)=>({x:(u-o)/i,y:1-(l+h-n)/a,width:p/i,height:h/a});break;case"180":s=(l,u,h,p)=>({x:1-(l+h-n)/a,y:1-(u+p-o)/i,width:h/a,height:p/i});break;case"270":s=(l,u,h,p)=>({x:1-(u+p-o)/i,y:(l-n)/a,width:p/i,height:h/a});break;default:s=(l,u,h,p)=>({x:(l-n)/a,y:(u-o)/i,width:h/a,height:p/i});break}const c=[];for(let l=0,u=r.rangeCount;l<u;l++){const h=r.getRangeAt(l);if(!h.collapsed)for(const{x:p,y:m,width:g,height:b}of h.getClientRects())g===0||b===0||c.push(s(p,m,g,b))}return c.length===0?null:c}addChangedExistingAnnotation({annotationElementId:t,id:r}){(v(this,eg)||Y(this,eg,new Map)).set(t,r)}removeChangedExistingAnnotation({annotationElementId:t}){var r;(r=v(this,eg))==null||r.delete(t)}renderAnnotationElement(t){var o;const r=(o=v(this,eg))==null?void 0:o.get(t.data.id);if(!r)return;const n=v(this,Zc).getRawValue(r);n&&(v(this,zo)===Qt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(t))}};Qm=new WeakMap,ni=new WeakMap,ro=new WeakMap,Io=new WeakMap,Zm=new WeakMap,Zc=new WeakMap,eg=new WeakMap,is=new WeakMap,tg=new WeakMap,Lf=new WeakMap,nc=new WeakMap,ss=new WeakMap,Vf=new WeakMap,c0=new WeakMap,l0=new WeakMap,oc=new WeakMap,rg=new WeakMap,Xu=new WeakMap,ac=new WeakMap,wA=new WeakMap,Wu=new WeakMap,u0=new WeakMap,Kf=new WeakMap,d0=new WeakMap,ng=new WeakMap,zo=new WeakMap,_r=new WeakMap,el=new WeakMap,Hf=new WeakMap,f0=new WeakMap,h0=new WeakMap,p0=new WeakMap,m0=new WeakMap,g0=new WeakMap,b0=new WeakMap,v0=new WeakMap,y0=new WeakMap,_0=new WeakMap,w0=new WeakMap,x0=new WeakMap,j0=new WeakMap,O0=new WeakMap,ku=new WeakMap,ic=new WeakMap,tl=new WeakMap,M0=new WeakMap,Xe=new WeakSet,$A=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},pJ=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const n=J(this,Xe,$A).call(this,t).closest(".textLayer"),o=this.getSelectionBoxes(n);o&&(v(this,ac)||Y(this,ac,new l6e(this)),v(this,ac).show(n,o,this.direction==="ltr"))},mJ=function(){var a,i,s;const t=document.getSelection();if(!t||t.isCollapsed){v(this,el)&&((a=v(this,ac))==null||a.hide(),Y(this,el,null),J(this,Xe,_a).call(this,{hasSelectedText:!1}));return}const{anchorNode:r}=t;if(r===v(this,el))return;if(!J(this,Xe,$A).call(this,t).closest(".textLayer")){v(this,el)&&((i=v(this,ac))==null||i.hide(),Y(this,el,null),J(this,Xe,_a).call(this,{hasSelectedText:!1}));return}if((s=v(this,ac))==null||s.hide(),Y(this,el,r),J(this,Xe,_a).call(this,{hasSelectedText:!0}),!(v(this,zo)!==Qt.HIGHLIGHT&&v(this,zo)!==Qt.NONE)&&(v(this,zo)===Qt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Y(this,Xu,this.isShiftKeyDown),!this.isShiftKeyDown)){const c=this._signal,l=u=>{u.type==="pointerup"&&u.button!==0||(window.removeEventListener("pointerup",l),window.removeEventListener("blur",l),u.type==="pointerup"&&J(this,Xe,FA).call(this,"main_toolbar"))};window.addEventListener("pointerup",l,{signal:c}),window.addEventListener("blur",l,{signal:c})}},FA=function(t=""){v(this,zo)===Qt.HIGHLIGHT?this.highlightSelection(t):v(this,c0)&&J(this,Xe,pJ).call(this)},gJ=function(){document.addEventListener("selectionchange",J(this,Xe,mJ).bind(this),{signal:this._signal})},bJ=function(){const t=this._signal;window.addEventListener("focus",v(this,p0),{signal:t}),window.addEventListener("blur",v(this,h0),{signal:t})},vJ=function(){window.removeEventListener("focus",v(this,p0)),window.removeEventListener("blur",v(this,h0))},S$=function(){const t=this._signal;window.addEventListener("keydown",v(this,v0),{signal:t}),window.addEventListener("keyup",v(this,y0),{signal:t})},yJ=function(){window.removeEventListener("keydown",v(this,v0)),window.removeEventListener("keyup",v(this,y0))},P$=function(){const t=this._signal;document.addEventListener("copy",v(this,m0),{signal:t}),document.addEventListener("cut",v(this,g0),{signal:t}),document.addEventListener("paste",v(this,b0),{signal:t})},E$=function(){document.removeEventListener("copy",v(this,m0)),document.removeEventListener("cut",v(this,g0)),document.removeEventListener("paste",v(this,b0))},_J=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},_a=function(t){Object.entries(t).some(([n,o])=>v(this,O0)[n]!==o)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(v(this,O0),t)}),v(this,zo)===Qt.HIGHLIGHT&&t.hasSelectedEditor===!1&&J(this,Xe,hd).call(this,[[_t.HIGHLIGHT_FREE,!0]]))},hd=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},wJ=function(){if(!v(this,Wu)){Y(this,Wu,!0);for(const t of v(this,Io).values())t.enable();for(const t of v(this,ro).values())t.enable()}},xJ=function(){if(this.unselectAll(),v(this,Wu)){Y(this,Wu,!1);for(const t of v(this,Io).values())t.disable();for(const t of v(this,ro).values())t.disable()}},T$=function(t){const r=v(this,Io).get(t.pageIndex);r?r.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},jJ=function(){let t=null;for(t of v(this,_r));return t},Fx=function(){if(v(this,ro).size===0)return!0;if(v(this,ro).size===1)for(const t of v(this,ro).values())return t.isEmpty();return!1},A$=function(t){for(const r of v(this,_r))r.unselect();v(this,_r).clear();for(const r of t)r.isEmpty()||(v(this,_r).add(r),r.select());J(this,Xe,_a).call(this,{hasSelectedEditor:this.hasSelection})},Qe(og,"TRANSLATE_SMALL",1),Qe(og,"TRANSLATE_BIG",10);let Mf=og;const al=class al{constructor(t){ee(this,S0);ee(this,rl,"");ee(this,nl,!1);ee(this,cs,null);ee(this,ol,null);ee(this,oi,null);ee(this,ag,!1);ee(this,ls,null);Y(this,ls,t)}static initialize(t){al._l10nPromise||(al._l10nPromise=t)}async render(){const t=Y(this,cs,document.createElement("button"));t.className="altText";const r=await al._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=r,t.setAttribute("aria-label",r),t.tabIndex="0";const n=v(this,ls)._uiManager._signal;t.addEventListener("contextmenu",Ra,{signal:n}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:n});const o=a=>{a.preventDefault(),v(this,ls)._uiManager.editAltText(v(this,ls))};return t.addEventListener("click",o,{capture:!0,signal:n}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(Y(this,ag,!0),o(a))},{signal:n}),await J(this,S0,C$).call(this),t}finish(){v(this,cs)&&(v(this,cs).focus({focusVisible:v(this,ag)}),Y(this,ag,!1))}isEmpty(){return!v(this,rl)&&!v(this,nl)}get data(){return{altText:v(this,rl),decorative:v(this,nl)}}set data({altText:t,decorative:r}){v(this,rl)===t&&v(this,nl)===r||(Y(this,rl,t),Y(this,nl,r),J(this,S0,C$).call(this))}toggle(t=!1){v(this,cs)&&(!t&&v(this,oi)&&(clearTimeout(v(this,oi)),Y(this,oi,null)),v(this,cs).disabled=!t)}destroy(){var t;(t=v(this,cs))==null||t.remove(),Y(this,cs,null),Y(this,ol,null)}};rl=new WeakMap,nl=new WeakMap,cs=new WeakMap,ol=new WeakMap,oi=new WeakMap,ag=new WeakMap,ls=new WeakMap,S0=new WeakSet,C$=async function(){var o;const t=v(this,cs);if(!t)return;if(!v(this,rl)&&!v(this,nl)){t.classList.remove("done"),(o=v(this,ol))==null||o.remove();return}t.classList.add("done"),al._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(a=>{t.setAttribute("aria-label",a)});let r=v(this,ol);if(!r){Y(this,ol,r=document.createElement("span")),r.className="tooltip",r.setAttribute("role","tooltip");const a=r.id=`alt-text-tooltip-${v(this,ls).id}`;t.setAttribute("aria-describedby",a);const i=100,s=v(this,ls)._uiManager._signal;s.addEventListener("abort",()=>{clearTimeout(v(this,oi)),Y(this,oi,null)},{once:!0}),t.addEventListener("mouseenter",()=>{Y(this,oi,setTimeout(()=>{Y(this,oi,null),v(this,ol).classList.add("show"),v(this,ls)._reportTelemetry({action:"alt_text_tooltip"})},i))},{signal:s}),t.addEventListener("mouseleave",()=>{var c;v(this,oi)&&(clearTimeout(v(this,oi)),Y(this,oi,null)),(c=v(this,ol))==null||c.classList.remove("show")},{signal:s})}r.innerText=v(this,nl)?await al._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):v(this,rl),r.parentNode||t.append(r);const n=v(this,ls).getImageForAltText();n==null||n.setAttribute("aria-describedby",r.id)},Qe(al,"_l10nPromise",null);let CT=al;const $r=class $r{constructor(t){ee(this,It);ee(this,Xf,null);ee(this,us,null);ee(this,sa,null);ee(this,ig,!1);ee(this,Wf,!1);ee(this,Uo,null);ee(this,kf,null);ee(this,sg,this.focusin.bind(this));ee(this,cg,this.focusout.bind(this));ee(this,ca,null);ee(this,P0,"");ee(this,Gf,!1);ee(this,Gu,null);ee(this,E0,!1);ee(this,Yf,!1);ee(this,il,!1);ee(this,sc,null);ee(this,lg,0);ee(this,ug,0);ee(this,$i,null);Qe(this,"_initialOptions",Object.create(null));Qe(this,"_isVisible",!0);Qe(this,"_uiManager",null);Qe(this,"_focusEventsAllowed",!0);Qe(this,"_l10nPromise",null);ee(this,T0,!1);ee(this,xA,$r._zIndex++);this.constructor===$r&&Er("Cannot initialize AnnotationEditor."),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:r,rawDims:{pageWidth:n,pageHeight:o,pageX:a,pageY:i}}=this.parent.viewport;this.rotation=r,this.pageRotation=(360+r-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,o],this.pageTranslation=[a,i];const[s,c]=this.parentDimensions;this.x=t.x/s,this.y=t.y/c,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=$r.prototype._resizeWithKeyboard,r=Mf.TRANSLATE_SMALL,n=Mf.TRANSLATE_BIG;return ar(this,"_resizerKeyboardManager",new Hw([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-r,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[r,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-r]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,r]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,n]}],[["Escape","mac+Escape"],$r.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return ar(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const r=new h6e({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});r.annotationElementId=t.annotationElementId,r.deleted=!0,r._uiManager.addToAnnotationStorage(r)}static initialize(t,r,n){if($r._l10nPromise||($r._l10nPromise=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(a=>[a,t.get(a.replaceAll(/([A-Z])/g,i=>`-${i.toLowerCase()}`))]))),n!=null&&n.strings)for(const a of n.strings)$r._l10nPromise.set(a,t.get(a));if($r._borderLineWidth!==-1)return;const o=getComputedStyle(document.documentElement);$r._borderLineWidth=parseFloat(o.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,r){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,r){Er("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return v(this,T0)}set _isDraggable(t){var r;Y(this,T0,t),(r=this.div)==null||r.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,r]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*r/(t*2),this.y+=this.width*t/(r*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*r/(t*2),this.y-=this.width*t/(r*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=v(this,xA)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):J(this,It,Bx).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(v(this,Gf)?Y(this,Gf,!1):this.parent.setSelected(this))}focusout(t){var n;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const r=t.relatedTarget;r!=null&&r.closest(`#${this.id}`)||(t.preventDefault(),(n=this.parent)!=null&&n.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,r,n,o){const[a,i]=this.parentDimensions;[n,o]=this.screenToPageTranslation(n,o),this.x=(t+n)/a,this.y=(r+o)/i,this.fixAndSetPosition()}translate(t,r){J(this,It,D$).call(this,this.parentDimensions,t,r)}translateInPage(t,r){v(this,Gu)||Y(this,Gu,[this.x,this.y]),J(this,It,D$).call(this,this.pageDimensions,t,r),this.div.scrollIntoView({block:"nearest"})}drag(t,r){v(this,Gu)||Y(this,Gu,[this.x,this.y]);const[n,o]=this.parentDimensions;if(this.x+=t/n,this.y+=r/o,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:l,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,l,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:i}=this;const[s,c]=this.getBaseTranslation();a+=s,i+=c,this.div.style.left=`${(100*a).toFixed(2)}%`,this.div.style.top=`${(100*i).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!v(this,Gu)&&(v(this,Gu)[0]!==this.x||v(this,Gu)[1]!==this.y)}getBaseTranslation(){const[t,r]=this.parentDimensions,{_borderLineWidth:n}=$r,o=n/t,a=n/r;switch(this.rotation){case 90:return[-o,a];case 180:return[o,a];case 270:return[o,-a];default:return[-o,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[r,n]=this.pageDimensions;let{x:o,y:a,width:i,height:s}=this;if(i*=r,s*=n,o*=r,a*=n,this._mustFixPosition)switch(t){case 0:o=Math.max(0,Math.min(r-i,o)),a=Math.max(0,Math.min(n-s,a));break;case 90:o=Math.max(0,Math.min(r-s,o)),a=Math.min(n,Math.max(i,a));break;case 180:o=Math.min(r,Math.max(i,o)),a=Math.min(n,Math.max(s,a));break;case 270:o=Math.min(r,Math.max(s,o)),a=Math.max(0,Math.min(n-i,a));break}this.x=o/=r,this.y=a/=n;const[c,l]=this.getBaseTranslation();o+=c,a+=l;const{style:u}=this.div;u.left=`${(100*o).toFixed(2)}%`,u.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,r){var n;return J(n=$r,A0,I$).call(n,t,r,this.parentRotation)}pageTranslationToScreen(t,r){var n;return J(n=$r,A0,I$).call(n,t,r,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[r,n]}=this,o=r*t,a=n*t;return Na.isCSSRoundSupported?[Math.round(o),Math.round(a)]:[o,a]}setDims(t,r){const[n,o]=this.parentDimensions;this.div.style.width=`${(100*t/n).toFixed(2)}%`,v(this,Wf)||(this.div.style.height=`${(100*r/o).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:r,width:n}=t,o=n.endsWith("%"),a=!v(this,Wf)&&r.endsWith("%");if(o&&a)return;const[i,s]=this.parentDimensions;o||(t.width=`${(100*parseFloat(n)/i).toFixed(2)}%`),!v(this,Wf)&&!a&&(t.height=`${(100*parseFloat(r)/s).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=v(this,sa))==null||t.finish()}async addEditToolbar(){return v(this,ca)||v(this,Yf)?v(this,ca):(Y(this,ca,new eR(this)),this.div.append(v(this,ca).render()),v(this,sa)&&v(this,ca).addAltTextButton(await v(this,sa).render()),v(this,ca))}removeEditToolbar(){var t;v(this,ca)&&(v(this,ca).remove(),Y(this,ca,null),(t=v(this,sa))==null||t.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){v(this,sa)||(CT.initialize($r._l10nPromise),Y(this,sa,new CT(this)),v(this,Xf)&&(v(this,sa).data=v(this,Xf),Y(this,Xf,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=v(this,sa))==null?void 0:t.data}set altTextData(t){v(this,sa)&&(v(this,sa).data=t)}hasAltText(){var t;return!((t=v(this,sa))!=null&&t.isEmpty())}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=v(this,ig)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",v(this,sg),{signal:t}),this.div.addEventListener("focusout",v(this,cg),{signal:t});const[r,n]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*n/r).toFixed(2)}%`,this.div.style.maxHeight=`${(100*r/n).toFixed(2)}%`);const[o,a]=this.getInitialTranslation();return this.translate(o,a),AT(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:r}=Na.platform;if(t.button!==0||t.ctrlKey&&r){t.preventDefault();return}if(Y(this,Gf,!0),this._isDraggable){J(this,It,SJ).call(this,t);return}J(this,It,R$).call(this,t)}moveInDOM(){v(this,sc)&&clearTimeout(v(this,sc)),Y(this,sc,setTimeout(()=>{var t;Y(this,sc,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,r,n){t.changeParent(this),this.x=r,this.y=n,this.fixAndSetPosition()}getRect(t,r,n=this.rotation){const o=this.parentScale,[a,i]=this.pageDimensions,[s,c]=this.pageTranslation,l=t/o,u=r/o,h=this.x*a,p=this.y*i,m=this.width*a,g=this.height*i;switch(n){case 0:return[h+l+s,i-p-u-g+c,h+l+m+s,i-p-u+c];case 90:return[h+u+s,i-p+l+c,h+u+g+s,i-p+l+m+c];case 180:return[h-l-m+s,i-p+u+c,h-l+s,i-p+u+g+c];case 270:return[h-u-g+s,i-p-l-m+c,h-u+s,i-p-l+c];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,r){const[n,o,a,i]=t,s=a-n,c=i-o;switch(this.rotation){case 0:return[n,r-i,s,c];case 90:return[n,r-o,c,s];case 180:return[a,r-o,s,c];case 270:return[a,r-i,c,s];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){Y(this,Yf,!0)}disableEditMode(){Y(this,Yf,!1)}isInEditMode(){return v(this,Yf)}shouldGetKeyboardEvents(){return v(this,il)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var r,n;const t=this._uiManager._signal;(r=this.div)==null||r.addEventListener("focusin",v(this,sg),{signal:t}),(n=this.div)==null||n.addEventListener("focusout",v(this,cg),{signal:t})}rotate(t){}serialize(t=!1,r=null){Er("An editor must be serializable")}static deserialize(t,r,n){const o=new this.prototype.constructor({parent:r,id:r.getNextId(),uiManager:n});o.rotation=t.rotation,Y(o,Xf,t.accessibilityData);const[a,i]=o.pageDimensions,[s,c,l,u]=o.getRectInCurrentCoords(t.rect,i);return o.x=s/a,o.y=c/i,o.width=l/a,o.height=u/i,o}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",v(this,sg)),this.div.removeEventListener("focusout",v(this,cg)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),v(this,sc)&&(clearTimeout(v(this,sc)),Y(this,sc,null)),J(this,It,Bx).call(this),this.removeEditToolbar(),v(this,$i)){for(const t of v(this,$i).values())clearTimeout(t);Y(this,$i,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(J(this,It,OJ).call(this),v(this,Uo).classList.remove("hidden"),AT(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),Y(this,kf,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const r=v(this,Uo).children;if(!v(this,us)){Y(this,us,Array.from(r));const i=J(this,It,PJ).bind(this),s=J(this,It,EJ).bind(this),c=this._uiManager._signal;for(const l of v(this,us)){const u=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",i,{signal:c}),l.addEventListener("blur",s,{signal:c}),l.addEventListener("focus",J(this,It,TJ).bind(this,u),{signal:c}),$r._l10nPromise.get(`pdfjs-editor-resizer-label-${u}`).then(h=>l.setAttribute("aria-label",h))}}const n=v(this,us)[0];let o=0;for(const i of r){if(i===n)break;o++}const a=(360-this.rotation+this.parentRotation)%360/90*(v(this,us).length/4);if(a!==o){if(a<o)for(let s=0;s<o-a;s++)v(this,Uo).append(v(this,Uo).firstChild);else if(a>o)for(let s=0;s<a-o;s++)v(this,Uo).firstChild.before(v(this,Uo).lastChild);let i=0;for(const s of r){const l=v(this,us)[i++].getAttribute("data-resizer-name");$r._l10nPromise.get(`pdfjs-editor-resizer-label-${l}`).then(u=>s.setAttribute("aria-label",u))}}J(this,It,$$).call(this,0),Y(this,il,!0),v(this,Uo).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,r){v(this,il)&&J(this,It,N$).call(this,v(this,P0),{movementX:t,movementY:r})}_stopResizingWithKeyboard(){J(this,It,Bx).call(this),this.div.focus()}select(){var t,r;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!v(this,ca)){this.addEditToolbar().then(()=>{var n,o;(n=this.div)!=null&&n.classList.contains("selectedEditor")&&((o=v(this,ca))==null||o.show())});return}(r=v(this,ca))==null||r.show()}unselect(){var t,r,n,o;(t=v(this,Uo))==null||t.classList.add("hidden"),(r=this.div)==null||r.classList.remove("selectedEditor"),(n=this.div)!=null&&n.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(o=v(this,ca))==null||o.hide()}updateParams(t,r){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return v(this,E0)}set isEditing(t){Y(this,E0,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,r){Y(this,Wf,!0);const n=t/r,{style:o}=this.div;o.aspectRatio=n,o.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,r=!1){if(r){v(this,$i)||Y(this,$i,new Map);const{action:n}=t;let o=v(this,$i).get(n);o&&clearTimeout(o),o=setTimeout(()=>{this._reportTelemetry(t),v(this,$i).delete(n),v(this,$i).size===0&&Y(this,$i,null)},$r._telemetryTimeout),v(this,$i).set(n,o);return}t.type||(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),Y(this,ig,!1)}disable(){this.div&&(this.div.tabIndex=-1),Y(this,ig,!0)}renderAnnotationElement(t){let r=t.container.querySelector(".annotationContent");if(!r)r=document.createElement("div"),r.classList.add("annotationContent",this.editorType),t.container.prepend(r);else if(r.nodeName==="CANVAS"){const n=r;r=document.createElement("div"),r.classList.add("annotationContent",this.editorType),n.before(r)}return r}resetAnnotationElement(t){const{firstChild:r}=t.container;r.nodeName==="DIV"&&r.classList.contains("annotationContent")&&r.remove()}};Xf=new WeakMap,us=new WeakMap,sa=new WeakMap,ig=new WeakMap,Wf=new WeakMap,Uo=new WeakMap,kf=new WeakMap,sg=new WeakMap,cg=new WeakMap,ca=new WeakMap,P0=new WeakMap,Gf=new WeakMap,Gu=new WeakMap,E0=new WeakMap,Yf=new WeakMap,il=new WeakMap,sc=new WeakMap,lg=new WeakMap,ug=new WeakMap,$i=new WeakMap,T0=new WeakMap,xA=new WeakMap,It=new WeakSet,D$=function([t,r],n,o){[n,o]=this.screenToPageTranslation(n,o),this.x+=n/t,this.y+=o/r,this.fixAndSetPosition()},A0=new WeakSet,I$=function(t,r,n){switch(n){case 90:return[r,-t];case 180:return[-t,-r];case 270:return[-r,t];default:return[t,r]}},z$=function(t){switch(t){case 90:{const[r,n]=this.pageDimensions;return[0,-r/n,n/r,0]}case 180:return[-1,0,0,-1];case 270:{const[r,n]=this.pageDimensions;return[0,r/n,-n/r,0]}default:return[1,0,0,1]}},OJ=function(){if(v(this,Uo))return;Y(this,Uo,document.createElement("div")),v(this,Uo).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],r=this._uiManager._signal;for(const n of t){const o=document.createElement("div");v(this,Uo).append(o),o.classList.add("resizer",n),o.setAttribute("data-resizer-name",n),o.addEventListener("pointerdown",J(this,It,MJ).bind(this,n),{signal:r}),o.addEventListener("contextmenu",Ra,{signal:r}),o.tabIndex=-1}this.div.prepend(v(this,Uo))},MJ=function(t,r){var b;r.preventDefault();const{isMac:n}=Na.platform;if(r.button!==0||r.ctrlKey&&n)return;(b=v(this,sa))==null||b.toggle(!1);const o=J(this,It,N$).bind(this,t),a=this._isDraggable;this._isDraggable=!1;const i=this._uiManager._signal,s={passive:!0,capture:!0,signal:i};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",o,s),window.addEventListener("contextmenu",Ra,{signal:i});const c=this.x,l=this.y,u=this.width,h=this.height,p=this.parent.div.style.cursor,m=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(r.target).cursor;const g=()=>{var _;this.parent.togglePointerEvents(!0),(_=v(this,sa))==null||_.toggle(!0),this._isDraggable=a,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",o,s),window.removeEventListener("contextmenu",Ra),this.parent.div.style.cursor=p,this.div.style.cursor=m,J(this,It,U$).call(this,c,l,u,h)};window.addEventListener("pointerup",g,{signal:i}),window.addEventListener("blur",g,{signal:i})},U$=function(t,r,n,o){const a=this.x,i=this.y,s=this.width,c=this.height;a===t&&i===r&&s===n&&c===o||this.addCommands({cmd:()=>{this.width=s,this.height=c,this.x=a,this.y=i;const[l,u]=this.parentDimensions;this.setDims(l*s,u*c),this.fixAndSetPosition()},undo:()=>{this.width=n,this.height=o,this.x=t,this.y=r;const[l,u]=this.parentDimensions;this.setDims(l*n,u*o),this.fixAndSetPosition()},mustExec:!0})},N$=function(t,r){const[n,o]=this.parentDimensions,a=this.x,i=this.y,s=this.width,c=this.height,l=$r.MIN_SIZE/n,u=$r.MIN_SIZE/o,h=K=>Math.round(K*1e4)/1e4,p=J(this,It,z$).call(this,this.rotation),m=(K,Q)=>[p[0]*K+p[2]*Q,p[1]*K+p[3]*Q],g=J(this,It,z$).call(this,360-this.rotation),b=(K,Q)=>[g[0]*K+g[2]*Q,g[1]*K+g[3]*Q];let _,y,x=!1,O=!1;switch(t){case"topLeft":x=!0,_=(K,Q)=>[0,0],y=(K,Q)=>[K,Q];break;case"topMiddle":_=(K,Q)=>[K/2,0],y=(K,Q)=>[K/2,Q];break;case"topRight":x=!0,_=(K,Q)=>[K,0],y=(K,Q)=>[0,Q];break;case"middleRight":O=!0,_=(K,Q)=>[K,Q/2],y=(K,Q)=>[0,Q/2];break;case"bottomRight":x=!0,_=(K,Q)=>[K,Q],y=(K,Q)=>[0,0];break;case"bottomMiddle":_=(K,Q)=>[K/2,Q],y=(K,Q)=>[K/2,0];break;case"bottomLeft":x=!0,_=(K,Q)=>[0,Q],y=(K,Q)=>[K,0];break;case"middleLeft":O=!0,_=(K,Q)=>[0,Q/2],y=(K,Q)=>[K,Q/2];break}const S=_(s,c),j=y(s,c);let P=m(...j);const I=h(a+P[0]),M=h(i+P[1]);let E=1,D=1,[A,z]=this.screenToPageTranslation(r.movementX,r.movementY);if([A,z]=b(A/n,z/o),x){const K=Math.hypot(s,c);E=D=Math.max(Math.min(Math.hypot(j[0]-S[0]-A,j[1]-S[1]-z)/K,1/s,1/c),l/s,u/c)}else O?E=Math.max(l,Math.min(1,Math.abs(j[0]-S[0]-A)))/s:D=Math.max(u,Math.min(1,Math.abs(j[1]-S[1]-z)))/c;const $=h(s*E),L=h(c*D);P=m(...y($,L));const B=I-P[0],W=M-P[1];this.width=$,this.height=L,this.x=B,this.y=W,this.setDims(n*$,o*L),this.fixAndSetPosition()},R$=function(t){const{isMac:r}=Na.platform;t.ctrlKey&&!r||t.shiftKey||t.metaKey&&r?this.parent.toggleSelected(this):this.parent.setSelected(this)},SJ=function(t){const r=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let n,o;const a=this._uiManager._signal;r&&(this.div.classList.add("moving"),n={passive:!0,capture:!0,signal:a},Y(this,lg,t.clientX),Y(this,ug,t.clientY),o=s=>{const{clientX:c,clientY:l}=s,[u,h]=this.screenToPageTranslation(c-v(this,lg),l-v(this,ug));Y(this,lg,c),Y(this,ug,l),this._uiManager.dragSelectedEditors(u,h)},window.addEventListener("pointermove",o,n));const i=()=>{window.removeEventListener("pointerup",i),window.removeEventListener("blur",i),r&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",o,n)),Y(this,Gf,!1),this._uiManager.endDragSession()||J(this,It,R$).call(this,t)};window.addEventListener("pointerup",i,{signal:a}),window.addEventListener("blur",i,{signal:a})},PJ=function(t){$r._resizerKeyboardManager.exec(this,t)},EJ=function(t){var r;v(this,il)&&((r=t.relatedTarget)==null?void 0:r.parentNode)!==v(this,Uo)&&J(this,It,Bx).call(this)},TJ=function(t){Y(this,P0,v(this,il)?t:"")},$$=function(t){if(v(this,us))for(const r of v(this,us))r.tabIndex=t},Bx=function(){if(Y(this,il,!1),J(this,It,$$).call(this,-1),v(this,kf)){const{savedX:t,savedY:r,savedWidth:n,savedHeight:o}=v(this,kf);J(this,It,U$).call(this,t,r,n,o),Y(this,kf,null)}},ee($r,A0),Qe($r,"_borderLineWidth",-1),Qe($r,"_colorManager",new rR),Qe($r,"_zIndex",1),Qe($r,"_telemetryTimeout",1e3);let yr=$r;class h6e extends yr{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const Rk=3285377520,Ui=4294901760,ec=65535;class $k{constructor(t){this.h1=t?t&4294967295:Rk,this.h2=t?t&4294967295:Rk}update(t){let r,n;if(typeof t=="string"){r=new Uint8Array(t.length*2),n=0;for(let b=0,_=t.length;b<_;b++){const y=t.charCodeAt(b);y<=255?r[n++]=y:(r[n++]=y>>>8,r[n++]=y&255)}}else if(ArrayBuffer.isView(t))r=t.slice(),n=r.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const o=n>>2,a=n-o*4,i=new Uint32Array(r.buffer,0,o);let s=0,c=0,l=this.h1,u=this.h2;const h=3432918353,p=461845907,m=h&ec,g=p&ec;for(let b=0;b<o;b++)b&1?(s=i[b],s=s*h&Ui|s*m&ec,s=s<<15|s>>>17,s=s*p&Ui|s*g&ec,l^=s,l=l<<13|l>>>19,l=l*5+3864292196):(c=i[b],c=c*h&Ui|c*m&ec,c=c<<15|c>>>17,c=c*p&Ui|c*g&ec,u^=c,u=u<<13|u>>>19,u=u*5+3864292196);switch(s=0,a){case 3:s^=r[o*4+2]<<16;case 2:s^=r[o*4+1]<<8;case 1:s^=r[o*4],s=s*h&Ui|s*m&ec,s=s<<15|s>>>17,s=s*p&Ui|s*g&ec,o&1?l^=s:u^=s}this.h1=l,this.h2=u}hexdigest(){let t=this.h1,r=this.h2;return t^=r>>>1,t=t*3981806797&Ui|t*36045&ec,r=r*4283543511&Ui|((r<<16|t>>>16)*2950163797&Ui)>>>16,t^=r>>>1,t=t*444984403&Ui|t*60499&ec,r=r*3301882366&Ui|((r<<16|t>>>16)*3120437893&Ui)>>>16,t^=r>>>1,(t>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")}}const nR=Object.freeze({map:null,hash:"",transfer:void 0});class oR{constructor(){ee(this,jA);ee(this,qf,!1);ee(this,No,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,r){const n=v(this,No).get(t);return n===void 0?r:Object.assign(r,n)}getRawValue(t){return v(this,No).get(t)}remove(t){if(v(this,No).delete(t),v(this,No).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const r of v(this,No).values())if(r instanceof yr)return;this.onAnnotationEditor(null)}}setValue(t,r){const n=v(this,No).get(t);let o=!1;if(n!==void 0)for(const[a,i]of Object.entries(r))n[a]!==i&&(o=!0,n[a]=i);else o=!0,v(this,No).set(t,r);o&&J(this,jA,AJ).call(this),r instanceof yr&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(r.constructor._type)}has(t){return v(this,No).has(t)}getAll(){return v(this,No).size>0?XN(v(this,No)):null}setAll(t){for(const[r,n]of Object.entries(t))this.setValue(r,n)}get size(){return v(this,No).size}resetModified(){v(this,qf)&&(Y(this,qf,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Fk(this)}get serializable(){if(v(this,No).size===0)return nR;const t=new Map,r=new $k,n=[],o=Object.create(null);let a=!1;for(const[i,s]of v(this,No)){const c=s instanceof yr?s.serialize(!1,o):s;c&&(t.set(i,c),r.update(`${i}:${JSON.stringify(c)}`),a||(a=!!c.bitmap))}if(a)for(const i of t.values())i.bitmap&&n.push(i.bitmap);return t.size>0?{map:t,hash:r.hexdigest(),transfer:n}:nR}get editorStats(){let t=null;const r=new Map;for(const n of v(this,No).values()){if(!(n instanceof yr))continue;const o=n.telemetryFinalData;if(!o)continue;const{type:a}=o;r.has(a)||r.set(a,Object.getPrototypeOf(n).constructor),t||(t=Object.create(null));const i=t[a]||(t[a]=new Map);for(const[s,c]of Object.entries(o)){if(s==="type")continue;let l=i.get(s);l||(l=new Map,i.set(s,l));const u=l.get(c)??0;l.set(c,u+1)}}for(const[n,o]of r)t[n]=o.computeTelemetryFinalData(t[n]);return t}}qf=new WeakMap,No=new WeakMap,jA=new WeakSet,AJ=function(){v(this,qf)||(Y(this,qf,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class Fk extends oR{constructor(r){super();ee(this,C0);const{map:n,hash:o,transfer:a}=r.serializable,i=structuredClone(n,a?{transfer:a}:null);Y(this,C0,{map:i,hash:o,transfer:a})}get print(){Er("Should not call PrintAnnotationStorage.print")}get serializable(){return v(this,C0)}}C0=new WeakMap;class p6e{constructor({ownerDocument:t=globalThis.document,styleElement:r=null}){ee(this,dg,new Set);this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const r=this.styleElement.sheet;r.insertRule(t,r.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),v(this,dg).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:r}){if(!(!t||v(this,dg).has(t.loadedName))){if(to(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:o,style:a}=t,i=new FontFace(n,o,a);this.addNativeFontFace(i);try{await i.load(),v(this,dg).add(n),r==null||r(t)}catch{Dt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(i)}return}Er("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){const n=t.createNativeFontFace();if(n){this.addNativeFontFace(n);try{await n.loaded}catch(o){throw Dt(`Failed to load font '${n.family}': '${o}'.`),t.disableFontFace=!0,o}}return}const r=t.createFontFaceRule();if(r){if(this.insertRule(r),this.isSyncFontLoadingSupported)return;await new Promise(n=>{const o=this._queueLoadingCallback(n);this._prepareFontLoadEvent(t,o)})}}get isFontLoadingAPISupported(){var r;const t=!!((r=this._document)!=null&&r.fonts);return ar(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(oa||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),ar(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function r(){for(to(!o.done,"completeRequest() cannot be called twice."),o.done=!0;n.length>0&&n[0].done;){const a=n.shift();setTimeout(a.callback,0)}}const{loadingRequests:n}=this,o={done:!1,complete:r,callback:t};return n.push(o),o}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return ar(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,r){function n(S,j){return S.charCodeAt(j)<<24|S.charCodeAt(j+1)<<16|S.charCodeAt(j+2)<<8|S.charCodeAt(j+3)&255}function o(S,j,P,I){const M=S.substring(0,j),E=S.substring(j+P);return M+I+E}let a,i;const s=this._document.createElement("canvas");s.width=1,s.height=1;const c=s.getContext("2d");let l=0;function u(S,j){if(++l>30){Dt("Load test font never loaded."),j();return}if(c.font="30px "+S,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){j();return}setTimeout(u.bind(null,S,j))}const h=`lt${Date.now()}${this.loadTestFontId++}`;let p=this._loadTestFont;p=o(p,976,h.length,h);const g=16,b=1482184792;let _=n(p,g);for(a=0,i=h.length-3;a<i;a+=4)_=_-b+n(h,a)|0;a<h.length&&(_=_-b+n(h+"XXX",a)|0),p=o(p,g,4,JKe(_));const y=`url(data:font/opentype;base64,${btoa(p)});`,x=`@font-face {font-family:"${h}";src:${y}}`;this.insertRule(x);const O=this._document.createElement("div");O.style.visibility="hidden",O.style.width=O.style.height="10px",O.style.position="absolute",O.style.top=O.style.left="0px";for(const S of[t.loadedName,h]){const j=this._document.createElement("span");j.textContent="Hi",j.style.fontFamily=S,O.append(j)}this._document.body.append(O),u(h,()=>{O.remove(),r.complete()})}}dg=new WeakMap;class m6e{constructor(t,{disableFontFace:r=!1,inspectFont:n=null}){this.compiledGlyphs=Object.create(null);for(const o in t)this[o]=t[o];this.disableFontFace=r===!0,this._inspectFont=n}createNativeFontFace(){var r;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const n={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(n.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,n)}return(r=this._inspectFont)==null||r.call(this,this),t}createFontFaceRule(){var o;if(!this.data||this.disableFontFace)return null;const t=Ek(this.data),r=`url(data:${this.mimetype};base64,${btoa(t)});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${r}}`;else{let a=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(a+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${a}src:${r}}`}return(o=this._inspectFont)==null||o.call(this,this,r),n}getPathGenerator(t,r){if(this.compiledGlyphs[r]!==void 0)return this.compiledGlyphs[r];let n;try{n=t.get(this.loadedName+"_path_"+r)}catch(a){Dt(`getPathGenerator - ignoring character: "${a}".`)}if(!Array.isArray(n)||n.length===0)return this.compiledGlyphs[r]=function(a,i){};const o=[];for(let a=0,i=n.length;a<i;)switch(n[a++]){case Hc.BEZIER_CURVE_TO:{const[s,c,l,u,h,p]=n.slice(a,a+6);o.push(m=>m.bezierCurveTo(s,c,l,u,h,p)),a+=6}break;case Hc.MOVE_TO:{const[s,c]=n.slice(a,a+2);o.push(l=>l.moveTo(s,c)),a+=2}break;case Hc.LINE_TO:{const[s,c]=n.slice(a,a+2);o.push(l=>l.lineTo(s,c)),a+=2}break;case Hc.QUADRATIC_CURVE_TO:{const[s,c,l,u]=n.slice(a,a+4);o.push(h=>h.quadraticCurveTo(s,c,l,u)),a+=4}break;case Hc.RESTORE:o.push(s=>s.restore());break;case Hc.SAVE:o.push(s=>s.save());break;case Hc.SCALE:to(o.length===2,"Scale command is only valid at the third position.");break;case Hc.TRANSFORM:{const[s,c,l,u,h,p]=n.slice(a,a+6);o.push(m=>m.transform(s,c,l,u,h,p)),a+=6}break;case Hc.TRANSLATE:{const[s,c]=n.slice(a,a+2);o.push(l=>l.translate(s,c)),a+=2}break}return this.compiledGlyphs[r]=function(i,s){o[0](i),o[1](i),i.scale(s,-s);for(let c=2,l=o.length;c<l;c++)o[c](i)}}}if(oa){var aR=Promise.withResolvers(),Xw=null;(async()=>{const t=await Promise.resolve().then(()=>X9e),r=await Promise.resolve().then(()=>$Xe),n=await Promise.resolve().then(()=>FXe),o=await Promise.resolve().then(()=>RXe);let a,i;return new Map(Object.entries({fs:t,http:r,https:n,url:o,canvas:a,path2d:i}))})().then(t=>{Xw=t,aR.resolve()},t=>{Dt(`loadPackages: ${t}`),Xw=new Map,aR.resolve()})}class tc{static get promise(){return aR.promise}static get(t){return Xw==null?void 0:Xw.get(t)}}const Bk=function(e){return tc.get("fs").promises.readFile(e).then(r=>new Uint8Array(r))};class g6e extends MT{}class b6e extends ST{_createCanvas(t,r){return tc.get("canvas").createCanvas(t,r)}}class v6e extends PT{_fetchData(t,r){return Bk(t).then(n=>({cMapData:n,compressionType:r}))}}class y6e extends ET{_fetchData(t){return Bk(t)}}const ma={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function iR(e,t){if(!t)return;const r=t[2]-t[0],n=t[3]-t[1],o=new Path2D;o.rect(t[0],t[1],r,n),e.clip(o)}class Ww{constructor(){this.constructor===Ww&&Er("Cannot initialize BaseShadingPattern.")}getPattern(){Er("Abstract method `getPattern` called.")}}class _6e extends Ww{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 r;this._type==="axial"?r=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(r=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const n of this._colorStops)r.addColorStop(n[0],n[1]);return r}getPattern(t,r,n,o){let a;if(o===ma.STROKE||o===ma.FILL){const i=r.current.getClippedPathBoundingBox(o,ln(t))||[0,0,0,0],s=Math.ceil(i[2]-i[0])||1,c=Math.ceil(i[3]-i[1])||1,l=r.cachedCanvases.getCanvas("pattern",s,c,!0),u=l.context;u.clearRect(0,0,u.canvas.width,u.canvas.height),u.beginPath(),u.rect(0,0,u.canvas.width,u.canvas.height),u.translate(-i[0],-i[1]),n=rt.transform(n,[1,0,0,1,i[0],i[1]]),u.transform(...r.baseTransform),this.matrix&&u.transform(...this.matrix),iR(u,this._bbox),u.fillStyle=this._createGradient(u),u.fill(),a=t.createPattern(l.canvas,"no-repeat");const h=new DOMMatrix(n);a.setTransform(h)}else iR(t,this._bbox),a=this._createGradient(t);return a}}function sR(e,t,r,n,o,a,i,s){const c=t.coords,l=t.colors,u=e.data,h=e.width*4;let p;c[r+1]>c[n+1]&&(p=r,r=n,n=p,p=a,a=i,i=p),c[n+1]>c[o+1]&&(p=n,n=o,o=p,p=i,i=s,s=p),c[r+1]>c[n+1]&&(p=r,r=n,n=p,p=a,a=i,i=p);const m=(c[r]+t.offsetX)*t.scaleX,g=(c[r+1]+t.offsetY)*t.scaleY,b=(c[n]+t.offsetX)*t.scaleX,_=(c[n+1]+t.offsetY)*t.scaleY,y=(c[o]+t.offsetX)*t.scaleX,x=(c[o+1]+t.offsetY)*t.scaleY;if(g>=x)return;const O=l[a],S=l[a+1],j=l[a+2],P=l[i],I=l[i+1],M=l[i+2],E=l[s],D=l[s+1],A=l[s+2],z=Math.round(g),$=Math.round(x);let L,B,W,K,Q,re,de,ge;for(let H=z;H<=$;H++){if(H<_){const N=H<g?0:(g-H)/(g-_);L=m-(m-b)*N,B=O-(O-P)*N,W=S-(S-I)*N,K=j-(j-M)*N}else{let N;H>x?N=1:_===x?N=0:N=(_-H)/(_-x),L=b-(b-y)*N,B=P-(P-E)*N,W=I-(I-D)*N,K=M-(M-A)*N}let R;H<g?R=0:H>x?R=1:R=(g-H)/(g-x),Q=m-(m-y)*R,re=O-(O-E)*R,de=S-(S-D)*R,ge=j-(j-A)*R;const Z=Math.round(Math.min(L,Q)),ae=Math.round(Math.max(L,Q));let k=h*H+Z*4;for(let N=Z;N<=ae;N++)R=(L-N)/(L-Q),R<0?R=0:R>1&&(R=1),u[k++]=B-(B-re)*R|0,u[k++]=W-(W-de)*R|0,u[k++]=K-(K-ge)*R|0,u[k++]=255}}function w6e(e,t,r){const n=t.coords,o=t.colors;let a,i;switch(t.type){case"lattice":const s=t.verticesPerRow,c=Math.floor(n.length/s)-1,l=s-1;for(a=0;a<c;a++){let u=a*s;for(let h=0;h<l;h++,u++)sR(e,r,n[u],n[u+1],n[u+s],o[u],o[u+1],o[u+s]),sR(e,r,n[u+s+1],n[u+1],n[u+s],o[u+s+1],o[u+1],o[u+s])}break;case"triangles":for(a=0,i=n.length;a<i;a+=3)sR(e,r,n[a],n[a+1],n[a+2],o[a],o[a+1],o[a+2]);break;default:throw new Error("illegal figure")}}class x6e extends Ww{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,r,n){const s=Math.floor(this._bounds[0]),c=Math.floor(this._bounds[1]),l=Math.ceil(this._bounds[2])-s,u=Math.ceil(this._bounds[3])-c,h=Math.min(Math.ceil(Math.abs(l*t[0]*1.1)),3e3),p=Math.min(Math.ceil(Math.abs(u*t[1]*1.1)),3e3),m=l/h,g=u/p,b={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-c,scaleX:1/m,scaleY:1/g},_=h+2*2,y=p+2*2,x=n.getCanvas("mesh",_,y,!1),O=x.context,S=O.createImageData(h,p);if(r){const P=S.data;for(let I=0,M=P.length;I<M;I+=4)P[I]=r[0],P[I+1]=r[1],P[I+2]=r[2],P[I+3]=255}for(const P of this._figures)w6e(S,P,b);return O.putImageData(S,2,2),{canvas:x.canvas,offsetX:s-2*m,offsetY:c-2*g,scaleX:m,scaleY:g}}getPattern(t,r,n,o){iR(t,this._bbox);let a;if(o===ma.SHADING)a=rt.singularValueDecompose2dScale(ln(t));else if(a=rt.singularValueDecompose2dScale(r.baseTransform),this.matrix){const s=rt.singularValueDecompose2dScale(this.matrix);a=[a[0]*s[0],a[1]*s[1]]}const i=this._createMeshCanvas(a,o===ma.SHADING?null:this._background,r.cachedCanvases);return o!==ma.SHADING&&(t.setTransform(...r.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(i.offsetX,i.offsetY),t.scale(i.scaleX,i.scaleY),t.createPattern(i.canvas,"no-repeat")}}class j6e extends Ww{getPattern(){return"hotpink"}}function O6e(e){switch(e[0]){case"RadialAxial":return new _6e(e);case"Mesh":return new x6e(e);case"Dummy":return new j6e}throw new Error(`Unknown IR type: ${e[0]}`)}const Lk={COLORED:1,UNCOLORED:2},OA=class OA{constructor(t,r,n,o,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=r,this.ctx=n,this.canvasGraphicsFactory=o,this.baseTransform=a}createPatternCanvas(t){const r=this.operatorList,n=this.bbox,o=this.xstep,a=this.ystep,i=this.paintType,s=this.tilingType,c=this.color,l=this.canvasGraphicsFactory;xT("TilingType: "+s);const u=n[0],h=n[1],p=n[2],m=n[3],g=rt.singularValueDecompose2dScale(this.matrix),b=rt.singularValueDecompose2dScale(this.baseTransform),_=[g[0]*b[0],g[1]*b[1]],y=this.getSizeAndScale(o,this.ctx.canvas.width,_[0]),x=this.getSizeAndScale(a,this.ctx.canvas.height,_[1]),O=t.cachedCanvases.getCanvas("pattern",y.size,x.size,!0),S=O.context,j=l.createCanvasGraphics(S);j.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(j,i,c);let P=u,I=h,M=p,E=m;return u<0&&(P=0,M+=Math.abs(u)),h<0&&(I=0,E+=Math.abs(h)),S.translate(-(y.scale*P),-(x.scale*I)),j.transform(y.scale,0,0,x.scale,0,0),S.save(),this.clipBbox(j,P,I,M,E),j.baseTransform=ln(j.ctx),j.executeOperatorList(r),j.endDrawing(),{canvas:O.canvas,scaleX:y.scale,scaleY:x.scale,offsetX:P,offsetY:I}}getSizeAndScale(t,r,n){t=Math.abs(t);const o=Math.max(OA.MAX_PATTERN_SIZE,r);let a=Math.ceil(t*n);return a>=o?a=o:n=a/t,{scale:n,size:a}}clipBbox(t,r,n,o,a){const i=o-r,s=a-n;t.ctx.rect(r,n,i,s),t.current.updateRectMinMax(ln(t.ctx),[r,n,o,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,r,n){const o=t.ctx,a=t.current;switch(r){case Lk.COLORED:const i=this.ctx;o.fillStyle=i.fillStyle,o.strokeStyle=i.strokeStyle,a.fillColor=i.fillStyle,a.strokeColor=i.strokeStyle;break;case Lk.UNCOLORED:const s=rt.makeHexColor(n[0],n[1],n[2]);o.fillStyle=s,o.strokeStyle=s,a.fillColor=s,a.strokeColor=s;break;default:throw new qKe(`Unsupported paint type: ${r}`)}}getPattern(t,r,n,o){let a=n;o!==ma.SHADING&&(a=rt.transform(a,r.baseTransform),this.matrix&&(a=rt.transform(a,this.matrix)));const i=this.createPatternCanvas(r);let s=new DOMMatrix(a);s=s.translate(i.offsetX,i.offsetY),s=s.scale(1/i.scaleX,1/i.scaleY);const c=t.createPattern(i.canvas,"repeat");return c.setTransform(s),c}};Qe(OA,"MAX_PATTERN_SIZE",3e3);let cR=OA;function M6e({src:e,srcPos:t=0,dest:r,width:n,height:o,nonBlackColor:a=4294967295,inverseDecode:i=!1}){const s=Na.isLittleEndian?4278190080:255,[c,l]=i?[a,s]:[s,a],u=n>>3,h=n&7,p=e.length;r=new Uint32Array(r.buffer);let m=0;for(let g=0;g<o;g++){for(const _=t+u;t<_;t++){const y=t<p?e[t]:255;r[m++]=y&128?l:c,r[m++]=y&64?l:c,r[m++]=y&32?l:c,r[m++]=y&16?l:c,r[m++]=y&8?l:c,r[m++]=y&4?l:c,r[m++]=y&2?l:c,r[m++]=y&1?l:c}if(h===0)continue;const b=t<p?e[t++]:255;for(let _=0;_<h;_++)r[m++]=b&1<<7-_?l:c}return{srcPos:t,destPos:m}}const Vk=16,Kk=100,S6e=15,Hk=10,Xk=1e3,$a=16;function P6e(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(n,o){t.translate(n,o),this.__originalTranslate(n,o)},e.scale=function(n,o){t.scale(n,o),this.__originalScale(n,o)},e.transform=function(n,o,a,i,s,c){t.transform(n,o,a,i,s,c),this.__originalTransform(n,o,a,i,s,c)},e.setTransform=function(n,o,a,i,s,c){t.setTransform(n,o,a,i,s,c),this.__originalSetTransform(n,o,a,i,s,c)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(n){t.rotate(n),this.__originalRotate(n)},e.clip=function(n){t.clip(n),this.__originalClip(n)},e.moveTo=function(r,n){t.moveTo(r,n),this.__originalMoveTo(r,n)},e.lineTo=function(r,n){t.lineTo(r,n),this.__originalLineTo(r,n)},e.bezierCurveTo=function(r,n,o,a,i,s){t.bezierCurveTo(r,n,o,a,i,s),this.__originalBezierCurveTo(r,n,o,a,i,s)},e.rect=function(r,n,o,a){t.rect(r,n,o,a),this.__originalRect(r,n,o,a)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class E6e{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,r,n){let o;return this.cache[t]!==void 0?(o=this.cache[t],this.canvasFactory.reset(o,r,n)):(o=this.canvasFactory.create(r,n),this.cache[t]=o),o}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const r=this.cache[t];this.canvasFactory.destroy(r),delete this.cache[t]}}}function DT(e,t,r,n,o,a,i,s,c,l){const[u,h,p,m,g,b]=ln(e);if(h===0&&p===0){const x=i*u+g,O=Math.round(x),S=s*m+b,j=Math.round(S),P=(i+c)*u+g,I=Math.abs(Math.round(P)-O)||1,M=(s+l)*m+b,E=Math.abs(Math.round(M)-j)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(m),O,j),e.drawImage(t,r,n,o,a,0,0,I,E),e.setTransform(u,h,p,m,g,b),[I,E]}if(u===0&&m===0){const x=s*p+g,O=Math.round(x),S=i*h+b,j=Math.round(S),P=(s+l)*p+g,I=Math.abs(Math.round(P)-O)||1,M=(i+c)*h+b,E=Math.abs(Math.round(M)-j)||1;return e.setTransform(0,Math.sign(h),Math.sign(p),0,O,j),e.drawImage(t,r,n,o,a,0,0,E,I),e.setTransform(u,h,p,m,g,b),[E,I]}e.drawImage(t,r,n,o,a,i,s,c,l);const _=Math.hypot(u,h),y=Math.hypot(p,m);return[_*c,y*l]}function T6e(e){const{width:t,height:r}=e;if(t>Xk||r>Xk)return null;const n=1e3,o=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1;let i=new Uint8Array(a*(r+1)),s,c,l;const u=t+7&-8;let h=new Uint8Array(u*r),p=0;for(const y of e.data){let x=128;for(;x>0;)h[p++]=y&x?0:255,x>>=1}let m=0;for(p=0,h[p]!==0&&(i[0]=1,++m),c=1;c<t;c++)h[p]!==h[p+1]&&(i[c]=h[p]?2:1,++m),p++;for(h[p]!==0&&(i[c]=2,++m),s=1;s<r;s++){p=s*u,l=s*a,h[p-u]!==h[p]&&(i[l]=h[p]?1:8,++m);let y=(h[p]?4:0)+(h[p-u]?8:0);for(c=1;c<t;c++)y=(y>>2)+(h[p+1]?4:0)+(h[p-u+1]?8:0),o[y]&&(i[l+c]=o[y],++m),p++;if(h[p-u]!==h[p]&&(i[l+c]=h[p]?2:4,++m),m>n)return null}for(p=u*(r-1),l=s*a,h[p]!==0&&(i[l]=8,++m),c=1;c<t;c++)h[p]!==h[p+1]&&(i[l+c]=h[p]?4:8,++m),p++;if(h[p]!==0&&(i[l+c]=4,++m),m>n)return null;const g=new Int32Array([0,a,-1,0,-a,0,0,0,1]),b=new Path2D;for(s=0;m&&s<=r;s++){let y=s*a;const x=y+t;for(;y<x&&!i[y];)y++;if(y===x)continue;b.moveTo(y%a,s);const O=y;let S=i[y];do{const j=g[S];do y+=j;while(!i[y]);const P=i[y];P!==5&&P!==10?(S=P,i[y]=0):(S=P&51*S>>4,i[y]&=S>>2|S<<2),b.lineTo(y%a,y/a|0),i[y]||--m}while(O!==y);--s}return h=null,i=null,function(y){y.save(),y.scale(1/t,-1/r),y.translate(0,-r),y.fill(b),y.beginPath(),y.restore()}}class Wk{constructor(t,r){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Sk,this.textMatrixScale=1,this.fontMatrix=BN,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=aa.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,r])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,r){this.x=t,this.y=r}updatePathMinMax(t,r,n){[r,n]=rt.applyTransform([r,n],t),this.minX=Math.min(this.minX,r),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,r),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(t,r){const n=rt.applyTransform(r,t),o=rt.applyTransform(r.slice(2),t),a=rt.applyTransform([r[0],r[3]],t),i=rt.applyTransform([r[2],r[1]],t);this.minX=Math.min(this.minX,n[0],o[0],a[0],i[0]),this.minY=Math.min(this.minY,n[1],o[1],a[1],i[1]),this.maxX=Math.max(this.maxX,n[0],o[0],a[0],i[0]),this.maxY=Math.max(this.maxY,n[1],o[1],a[1],i[1])}updateScalingPathMinMax(t,r){rt.scaleMinMax(t,r),this.minX=Math.min(this.minX,r[0]),this.minY=Math.min(this.minY,r[1]),this.maxX=Math.max(this.maxX,r[2]),this.maxY=Math.max(this.maxY,r[3])}updateCurvePathMinMax(t,r,n,o,a,i,s,c,l,u){const h=rt.bezierBoundingBox(r,n,o,a,i,s,c,l,u);u||this.updateRectMinMax(t,h)}getPathBoundingBox(t=ma.FILL,r=null){const n=[this.minX,this.minY,this.maxX,this.maxY];if(t===ma.STROKE){r||Er("Stroke bounding box must include transform.");const o=rt.singularValueDecompose2dScale(r),a=o[0]*this.lineWidth/2,i=o[1]*this.lineWidth/2;n[0]-=a,n[1]-=i,n[2]+=a,n[3]+=i}return n}updateClipFromPath(){const t=rt.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=ma.FILL,r=null){return rt.intersect(this.clipBox,this.getPathBoundingBox(t,r))}}function kk(e,t){if(typeof ImageData<"u"&&t instanceof ImageData){e.putImageData(t,0,0);return}const r=t.height,n=t.width,o=r%$a,a=(r-o)/$a,i=o===0?a:a+1,s=e.createImageData(n,$a);let c=0,l;const u=t.data,h=s.data;let p,m,g,b;if(t.kind===yT.GRAYSCALE_1BPP){const _=u.byteLength,y=new Uint32Array(h.buffer,0,h.byteLength>>2),x=y.length,O=n+7>>3,S=4294967295,j=Na.isLittleEndian?4278190080:255;for(p=0;p<i;p++){for(g=p<a?$a:o,l=0,m=0;m<g;m++){const P=_-c;let I=0;const M=P>O?n:P*8-7,E=M&-8;let D=0,A=0;for(;I<E;I+=8)A=u[c++],y[l++]=A&128?S:j,y[l++]=A&64?S:j,y[l++]=A&32?S:j,y[l++]=A&16?S:j,y[l++]=A&8?S:j,y[l++]=A&4?S:j,y[l++]=A&2?S:j,y[l++]=A&1?S:j;for(;I<M;I++)D===0&&(A=u[c++],D=128),y[l++]=A&D?S:j,D>>=1}for(;l<x;)y[l++]=0;e.putImageData(s,0,p*$a)}}else if(t.kind===yT.RGBA_32BPP){for(m=0,b=n*$a*4,p=0;p<a;p++)h.set(u.subarray(c,c+b)),c+=b,e.putImageData(s,0,m),m+=$a;p<i&&(b=n*o*4,h.set(u.subarray(c,c+b)),e.putImageData(s,0,m))}else if(t.kind===yT.RGB_24BPP)for(g=$a,b=n*g,p=0;p<i;p++){for(p>=a&&(g=o,b=n*g),l=0,m=b;m--;)h[l++]=u[c++],h[l++]=u[c++],h[l++]=u[c++],h[l++]=255;e.putImageData(s,0,p*$a)}else throw new Error(`bad image kind: ${t.kind}`)}function Gk(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}const r=t.height,n=t.width,o=r%$a,a=(r-o)/$a,i=o===0?a:a+1,s=e.createImageData(n,$a);let c=0;const l=t.data,u=s.data;for(let h=0;h<i;h++){const p=h<a?$a:o;({srcPos:c}=M6e({src:l,srcPos:c,dest:u,width:n,height:p,nonBlackColor:0})),e.putImageData(s,0,h*$a)}}function kw(e,t){const r=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of r)e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function IT(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",e.setLineDash!==void 0&&(e.setLineDash([]),e.lineDashOffset=0),!oa){const{filter:t}=e;t!=="none"&&t!==""&&(e.filter="none")}}function Yk(e,t){if(t)return!0;const r=rt.singularValueDecompose2dScale(e);r[0]=Math.fround(r[0]),r[1]=Math.fround(r[1]);const n=Math.fround((globalThis.devicePixelRatio||1)*Fu.PDF_TO_CSS_UNITS);return r[0]<=n&&r[1]<=n}const A6e=["butt","round","square"],C6e=["miter","round","bevel"],D6e={},qk={},v$=class v${constructor(t,r,n,o,a,{optionalContentConfig:i,markedContentStack:s=null},c,l){ee(this,Yu);this.ctx=t,this.current=new Wk(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=r,this.objs=n,this.canvasFactory=o,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=s||[],this.optionalContentConfig=i,this.cachedCanvases=new E6e(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=c,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,r=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):r}beginDrawing({transform:t,viewport:r,transparency:n=!1,background:o=null}){const a=this.ctx.canvas.width,i=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=o||"#ffffff",this.ctx.fillRect(0,0,a,i),this.ctx.fillStyle=s,n){const c=this.cachedCanvases.getCanvas("transparent",a,i);this.compositeCtx=this.ctx,this.transparentCanvas=c.canvas,this.ctx=c.context,this.ctx.save(),this.ctx.transform(...ln(this.compositeCtx))}this.ctx.save(),IT(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...r.transform),this.viewportScale=r.scale,this.baseTransform=ln(this.ctx)}executeOperatorList(t,r,n,o){const a=t.argsArray,i=t.fnArray;let s=r||0;const c=a.length;if(c===s)return s;const l=c-s>Hk&&typeof n=="function",u=l?Date.now()+S6e:0;let h=0;const p=this.commonObjs,m=this.objs;let g;for(;;){if(o!==void 0&&s===o.nextBreakPoint)return o.breakIt(s,n),s;if(g=i[s],g!==as.dependency)this[g].apply(this,a[s]);else for(const b of a[s]){const _=b.startsWith("g_")?p:m;if(!_.has(b))return _.get(b,n),s}if(s++,s===c)return s;if(l&&++h>Hk){if(Date.now()>u)return n(),s;h=0}}}endDrawing(){J(this,Yu,F$).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const r of t.values())typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement&&(r.width=r.height=0);t.clear()}this._cachedBitmapsMap.clear(),J(this,Yu,B$).call(this)}_scaleImage(t,r){const n=t.width,o=t.height;let a=Math.max(Math.hypot(r[0],r[1]),1),i=Math.max(Math.hypot(r[2],r[3]),1),s=n,c=o,l="prescale1",u,h;for(;a>2&&s>1||i>2&&c>1;){let p=s,m=c;a>2&&s>1&&(p=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),a/=s/p),i>2&&c>1&&(m=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,i/=c/m),u=this.cachedCanvases.getCanvas(l,p,m),h=u.context,h.clearRect(0,0,p,m),h.drawImage(t,0,0,s,c,0,0,p,m),t=u.canvas,s=p,c=m,l=l==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:s,paintHeight:c}}_createMaskCanvas(t){const r=this.ctx,{width:n,height:o}=t,a=this.current.fillColor,i=this.current.patternFill,s=ln(r);let c,l,u,h;if((t.bitmap||t.data)&&t.count>1){const M=t.bitmap||t.data.buffer;l=JSON.stringify(i?s:[s.slice(0,4),a]),c=this._cachedBitmapsMap.get(M),c||(c=new Map,this._cachedBitmapsMap.set(M,c));const E=c.get(l);if(E&&!i){const D=Math.round(Math.min(s[0],s[2])+s[4]),A=Math.round(Math.min(s[1],s[3])+s[5]);return{canvas:E,offsetX:D,offsetY:A}}u=E}u||(h=this.cachedCanvases.getCanvas("maskCanvas",n,o),Gk(h.context,t));let p=rt.transform(s,[1/n,0,0,-1/o,0,0]);p=rt.transform(p,[1,0,0,1,0,-o]);const[m,g,b,_]=rt.getAxialAlignedBoundingBox([0,0,n,o],p),y=Math.round(b-m)||1,x=Math.round(_-g)||1,O=this.cachedCanvases.getCanvas("fillCanvas",y,x),S=O.context,j=m,P=g;S.translate(-j,-P),S.transform(...p),u||(u=this._scaleImage(h.canvas,Wc(S)),u=u.img,c&&i&&c.set(l,u)),S.imageSmoothingEnabled=Yk(ln(S),t.interpolate),DT(S,u,0,0,u.width,u.height,0,0,n,o),S.globalCompositeOperation="source-in";const I=rt.transform(Wc(S),[1,0,0,1,-j,-P]);return S.fillStyle=i?a.getPattern(r,this,I,ma.FILL):a,S.fillRect(0,0,n,o),c&&!i&&(this.cachedCanvases.delete("fillCanvas"),c.set(l,O.canvas)),{canvas:O.canvas,offsetX:Math.round(j),offsetY:Math.round(P)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=A6e[t]}setLineJoin(t){this.ctx.lineJoin=C6e[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,r){const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(t),n.lineDashOffset=r)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[r,n]of t)switch(r){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(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,r=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,o=this.cachedCanvases.getCanvas(n,t,r);this.suspendedCtx=this.ctx,this.ctx=o.context;const a=this.ctx;a.setTransform(...ln(this.suspendedCtx)),kw(this.suspendedCtx,a),P6e(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(),kw(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const r=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,r,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,r,n,o){const a=o[0],i=o[1],s=o[2]-a,c=o[3]-i;s===0||c===0||(this.genericComposeSMask(r.context,n,s,c,r.subtype,r.backdrop,r.transferMap,a,i,r.offsetX,r.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,r,n,o,a,i,s,c,l,u,h){let p=t.canvas,m=c-u,g=l-h;if(i){if(m<0||g<0||m+n>p.width||g+o>p.height){const _=this.cachedCanvases.getCanvas("maskExtension",n,o),y=_.context;y.drawImage(p,-m,-g),i.some(x=>x!==0)&&(y.globalCompositeOperation="destination-atop",y.fillStyle=rt.makeHexColor(...i),y.fillRect(0,0,n,o),y.globalCompositeOperation="source-over"),p=_.canvas,m=g=0}else if(i.some(_=>_!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const _=new Path2D;_.rect(m,g,n,o),t.clip(_),t.globalCompositeOperation="destination-atop",t.fillStyle=rt.makeHexColor(...i),t.fillRect(m,g,n,o),t.restore()}}r.save(),r.globalAlpha=1,r.setTransform(1,0,0,1,0,0),a==="Alpha"&&s?r.filter=this.filterFactory.addAlphaFilter(s):a==="Luminosity"&&(r.filter=this.filterFactory.addLuminosityFilter(s));const b=new Path2D;b.rect(c,l,n,o),r.clip(b),r.globalCompositeOperation="destination-in",r.drawImage(p,m,g,n,o,c,l,n,o),r.restore()}save(){this.inSMaskMode?(kw(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const 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(),kw(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,r,n,o,a,i){this.ctx.transform(t,r,n,o,a,i),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,r,n){const o=this.ctx,a=this.current;let i=a.x,s=a.y,c,l;const u=ln(o),h=u[0]===0&&u[3]===0||u[1]===0&&u[2]===0,p=h?n.slice(0):null;for(let m=0,g=0,b=t.length;m<b;m++)switch(t[m]|0){case as.rectangle:i=r[g++],s=r[g++];const _=r[g++],y=r[g++],x=i+_,O=s+y;o.moveTo(i,s),_===0||y===0?o.lineTo(x,O):(o.lineTo(x,s),o.lineTo(x,O),o.lineTo(i,O)),h||a.updateRectMinMax(u,[i,s,x,O]),o.closePath();break;case as.moveTo:i=r[g++],s=r[g++],o.moveTo(i,s),h||a.updatePathMinMax(u,i,s);break;case as.lineTo:i=r[g++],s=r[g++],o.lineTo(i,s),h||a.updatePathMinMax(u,i,s);break;case as.curveTo:c=i,l=s,i=r[g+4],s=r[g+5],o.bezierCurveTo(r[g],r[g+1],r[g+2],r[g+3],i,s),a.updateCurvePathMinMax(u,c,l,r[g],r[g+1],r[g+2],r[g+3],i,s,p),g+=6;break;case as.curveTo2:c=i,l=s,o.bezierCurveTo(i,s,r[g],r[g+1],r[g+2],r[g+3]),a.updateCurvePathMinMax(u,c,l,i,s,r[g],r[g+1],r[g+2],r[g+3],p),i=r[g+2],s=r[g+3],g+=4;break;case as.curveTo3:c=i,l=s,i=r[g+2],s=r[g+3],o.bezierCurveTo(r[g],r[g+1],i,s,i,s),a.updateCurvePathMinMax(u,c,l,r[g],r[g+1],i,s,i,s,p),g+=4;break;case as.closePath:o.closePath();break}h&&a.updateScalingPathMinMax(u,p),a.setCurrentPoint(i,s)}closePath(){this.ctx.closePath()}stroke(t=!0){const r=this.ctx,n=this.current.strokeColor;r.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n=="object"&&(n!=null&&n.getPattern)?(r.save(),r.strokeStyle=n.getPattern(r,this,Wc(r),ma.STROKE),this.rescaleAndStroke(!1),r.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),r.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const r=this.ctx,n=this.current.fillColor,o=this.current.patternFill;let a=!1;o&&(r.save(),r.fillStyle=n.getPattern(r,this,Wc(r),ma.FILL),a=!0);const i=this.current.getClippedPathBoundingBox();this.contentVisible&&i!==null&&(this.pendingEOFill?(r.fill("evenodd"),this.pendingEOFill=!1):r.fill()),a&&r.restore(),t&&this.consumePath(i)}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=D6e}eoClip(){this.pendingClip=qk}beginText(){this.current.textMatrix=Sk,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,r=this.ctx;if(t===void 0){r.beginPath();return}r.save(),r.beginPath();for(const n of t)r.setTransform(...n.transform),r.translate(n.x,n.y),n.addToPath(r,n.fontSize);r.restore(),r.clip(),r.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,r){var u;const n=this.commonObjs.get(t),o=this.current;if(!n)throw new Error(`Can't find font for ${t}`);if(o.fontMatrix=n.fontMatrix||BN,(o.fontMatrix[0]===0||o.fontMatrix[3]===0)&&Dt("Invalid font matrix for font "+t),r<0?(r=-r,o.fontDirection=-1):o.fontDirection=1,this.current.font=n,this.current.fontSize=r,n.isType3Font)return;const a=n.loadedName||"sans-serif",i=((u=n.systemFontInfo)==null?void 0:u.css)||`"${a}", ${n.fallbackName}`;let s="normal";n.black?s="900":n.bold&&(s="bold");const c=n.italic?"italic":"normal";let l=r;r<Vk?l=Vk:r>Kk&&(l=Kk),this.current.fontSizeScale=r/l,this.ctx.font=`${c} ${s} ${l}px ${i}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,r){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=r}setLeadingMoveText(t,r){this.setLeading(-r),this.moveText(t,r)}setTextMatrix(t,r,n,o,a,i){this.current.textMatrix=[t,r,n,o,a,i],this.current.textMatrixScale=Math.hypot(t,r),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,r,n,o){const a=this.ctx,i=this.current,s=i.font,c=i.textRenderingMode,l=i.fontSize/i.fontSizeScale,u=c&aa.FILL_STROKE_MASK,h=!!(c&aa.ADD_TO_PATH_FLAG),p=i.patternFill&&!s.missingFile;let m;(s.disableFontFace||h||p)&&(m=s.getPathGenerator(this.commonObjs,t)),s.disableFontFace||p?(a.save(),a.translate(r,n),a.beginPath(),m(a,l),o&&a.setTransform(...o),(u===aa.FILL||u===aa.FILL_STROKE)&&a.fill(),(u===aa.STROKE||u===aa.FILL_STROKE)&&a.stroke(),a.restore()):((u===aa.FILL||u===aa.FILL_STROKE)&&a.fillText(t,r,n),(u===aa.STROKE||u===aa.FILL_STROKE)&&a.strokeText(t,r,n)),h&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:ln(a),x:r,y:n,fontSize:l,addToPath:m})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const r=t.getImageData(0,0,10,10).data;let n=!1;for(let o=3;o<r.length;o+=4)if(r[o]>0&&r[o]<255){n=!0;break}return ar(this,"isFontSubpixelAAEnabled",n)}showText(t){const r=this.current,n=r.font;if(n.isType3Font)return this.showType3Text(t);const o=r.fontSize;if(o===0)return;const a=this.ctx,i=r.fontSizeScale,s=r.charSpacing,c=r.wordSpacing,l=r.fontDirection,u=r.textHScale*l,h=t.length,p=n.vertical,m=p?1:-1,g=n.defaultVMetrics,b=o*r.fontMatrix[0],_=r.textRenderingMode===aa.FILL&&!n.disableFontFace&&!r.patternFill;a.save(),a.transform(...r.textMatrix),a.translate(r.x,r.y+r.textRise),l>0?a.scale(u,-1):a.scale(u,1);let y;if(r.patternFill){a.save();const P=r.fillColor.getPattern(a,this,Wc(a),ma.FILL);y=ln(a),a.restore(),a.fillStyle=P}let x=r.lineWidth;const O=r.textMatrixScale;if(O===0||x===0){const P=r.textRenderingMode&aa.FILL_STROKE_MASK;(P===aa.STROKE||P===aa.FILL_STROKE)&&(x=this.getSinglePixelWidth())}else x/=O;if(i!==1&&(a.scale(i,i),x/=i),a.lineWidth=x,n.isInvalidPDFjsFont){const P=[];let I=0;for(const M of t)P.push(M.unicode),I+=M.width;a.fillText(P.join(""),0,0),r.x+=I*b*u,a.restore(),this.compose();return}let S=0,j;for(j=0;j<h;++j){const P=t[j];if(typeof P=="number"){S+=m*P*o/1e3;continue}let I=!1;const M=(P.isSpace?c:0)+s,E=P.fontChar,D=P.accent;let A,z,$=P.width;if(p){const B=P.vmetric||g,W=-(P.vmetric?B[1]:$*.5)*b,K=B[2]*b;$=B?-B[0]:$,A=W/i,z=(S+K)/i}else A=S/i,z=0;if(n.remeasure&&$>0){const B=a.measureText(E).width*1e3/o*i;if($<B&&this.isFontSubpixelAAEnabled){const W=$/B;I=!0,a.save(),a.scale(W,1),A/=W}else $!==B&&(A+=($-B)/2e3*o/i)}if(this.contentVisible&&(P.isInFont||n.missingFile)){if(_&&!D)a.fillText(E,A,z);else if(this.paintChar(E,A,z,y),D){const B=A+o*D.offset.x/i,W=z-o*D.offset.y/i;this.paintChar(D.fontChar,B,W,y)}}const L=p?$*b-M*l:$*b+M*l;S+=L,I&&a.restore()}p?r.y-=S:r.x+=S*u,a.restore(),this.compose()}showType3Text(t){const r=this.ctx,n=this.current,o=n.font,a=n.fontSize,i=n.fontDirection,s=o.vertical?1:-1,c=n.charSpacing,l=n.wordSpacing,u=n.textHScale*i,h=n.fontMatrix||BN,p=t.length,m=n.textRenderingMode===aa.INVISIBLE;let g,b,_,y;if(!(m||a===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),r.transform(...n.textMatrix),r.translate(n.x,n.y),r.scale(u,i),g=0;g<p;++g){if(b=t[g],typeof b=="number"){y=s*b*a/1e3,this.ctx.translate(y,0),n.x+=y*u;continue}const x=(b.isSpace?l:0)+c,O=o.charProcOperatorList[b.operatorListId];if(!O){Dt(`Type3 character "${b.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=b,this.save(),r.scale(a,a),r.transform(...h),this.executeOperatorList(O),this.restore()),_=rt.applyTransform([b.width,0],h)[0]*a+x,r.translate(_,0),n.x+=_*u}r.restore(),this.processingType3=null}}setCharWidth(t,r){}setCharWidthAndBounds(t,r,n,o,a,i){this.ctx.rect(n,o,a-n,i-o),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let r;if(t[0]==="TilingPattern"){const n=t[1],o=this.baseTransform||ln(this.ctx),a={createCanvasGraphics:i=>new v$(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};r=new cR(t,n,this.ctx,a,o)}else r=this._getPattern(t[1],t[2]);return r}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,r,n){const o=rt.makeHexColor(t,r,n);this.ctx.strokeStyle=o,this.current.strokeColor=o}setFillRGBColor(t,r,n){const o=rt.makeHexColor(t,r,n);this.ctx.fillStyle=o,this.current.fillColor=o,this.current.patternFill=!1}_getPattern(t,r=null){let n;return this.cachedPatterns.has(t)?n=this.cachedPatterns.get(t):(n=O6e(this.getObject(t)),this.cachedPatterns.set(t,n)),r&&(n.matrix=r),n}shadingFill(t){if(!this.contentVisible)return;const r=this.ctx;this.save();const n=this._getPattern(t);r.fillStyle=n.getPattern(r,this,Wc(r),ma.SHADING);const o=Wc(r);if(o){const{width:a,height:i}=r.canvas,[s,c,l,u]=rt.getAxialAlignedBoundingBox([0,0,a,i],o);this.ctx.fillRect(s,c,l-s,u-c)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Er("Should not call beginInlineImage")}beginImageData(){Er("Should not call beginImageData")}paintFormXObjectBegin(t,r){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ln(this.ctx),r)){const n=r[2]-r[0],o=r[3]-r[1];this.ctx.rect(r[0],r[1],n,o),this.current.updateRectMinMax(ln(this.ctx),r),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const r=this.ctx;t.isolated||xT("TODO: Support non-isolated groups."),t.knockout&&Dt("Knockout groups not supported.");const n=ln(r);if(t.matrix&&r.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let o=rt.getAxialAlignedBoundingBox(t.bbox,ln(r));const a=[0,0,r.canvas.width,r.canvas.height];o=rt.intersect(o,a)||[0,0,0,0];const i=Math.floor(o[0]),s=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-i,1),l=Math.max(Math.ceil(o[3])-s,1);this.current.startNewPathAndClipBox([0,0,c,l]);let u="groupAt"+this.groupLevel;t.smask&&(u+="_smask_"+this.smaskCounter++%2);const h=this.cachedCanvases.getCanvas(u,c,l),p=h.context;p.translate(-i,-s),p.transform(...n),t.smask?this.smaskStack.push({canvas:h.canvas,context:p,offsetX:i,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(r.setTransform(1,0,0,1,0,0),r.translate(i,s),r.save()),kw(r,p),this.ctx=p,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(r),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const r=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();const o=ln(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...o);const a=rt.getAxialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],o);this.ctx.drawImage(r.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,r,n,o,a){if(J(this,Yu,F$).call(this),IT(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),r){const i=r[2]-r[0],s=r[3]-r[1];if(a&&this.annotationCanvasMap){n=n.slice(),n[4]-=r[0],n[5]-=r[1],r=r.slice(),r[0]=r[1]=0,r[2]=i,r[3]=s;const[c,l]=rt.singularValueDecompose2dScale(ln(this.ctx)),{viewportScale:u}=this,h=Math.ceil(i*this.outputScaleX*u),p=Math.ceil(s*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(h,p);const{canvas:m,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(t,m),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(c,0,0,-l,0,s*l),IT(this.ctx)}else IT(this.ctx),this.ctx.rect(r[0],r[1],i,s),this.ctx.clip(),this.endPath()}this.current=new Wk(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...o)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),J(this,Yu,B$).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const r=t.count;t=this.getObject(t.data,t),t.count=r;const n=this.ctx,o=this.processingType3;if(o&&(o.compiled===void 0&&(o.compiled=T6e(t)),o.compiled)){o.compiled(n);return}const a=this._createMaskCanvas(t),i=a.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(i,a.offsetX,a.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,r,n=0,o=0,a,i){if(!this.contentVisible)return;t=this.getObject(t.data,t);const s=this.ctx;s.save();const c=ln(s);s.transform(r,n,o,a,0,0);const l=this._createMaskCanvas(t);s.setTransform(1,0,0,1,l.offsetX-c[4],l.offsetY-c[5]);for(let u=0,h=i.length;u<h;u+=2){const p=rt.transform(c,[r,n,o,a,i[u],i[u+1]]),[m,g]=rt.applyTransform([0,0],p);s.drawImage(l.canvas,m,g)}s.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const r=this.ctx,n=this.current.fillColor,o=this.current.patternFill;for(const a of t){const{data:i,width:s,height:c,transform:l}=a,u=this.cachedCanvases.getCanvas("maskCanvas",s,c),h=u.context;h.save();const p=this.getObject(i,a);Gk(h,p),h.globalCompositeOperation="source-in",h.fillStyle=o?n.getPattern(h,this,Wc(r),ma.FILL):n,h.fillRect(0,0,s,c),h.restore(),r.save(),r.transform(...l),r.scale(1,-1),DT(r,u.canvas,0,0,s,c,0,-1,1,1),r.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const r=this.getObject(t);if(!r){Dt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(r)}paintImageXObjectRepeat(t,r,n,o){if(!this.contentVisible)return;const a=this.getObject(t);if(!a){Dt("Dependent image isn't ready yet");return}const i=a.width,s=a.height,c=[];for(let l=0,u=o.length;l<u;l+=2)c.push({transform:[r,0,0,n,o[l],o[l+1]],x:0,y:0,w:i,h:s});this.paintInlineImageXObjectGroup(a,c)}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;const{bitmap:r,width:n,height:o}=t,a=this.cachedCanvases.getCanvas("inlineImage",n,o),i=a.context;return i.filter=this.current.transferMaps,i.drawImage(r,0,0),i.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const r=t.width,n=t.height,o=this.ctx;if(this.save(),!oa){const{filter:s}=o;s!=="none"&&s!==""&&(o.filter="none")}o.scale(1/r,-1/n);let a;if(t.bitmap)a=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)a=t;else{const c=this.cachedCanvases.getCanvas("inlineImage",r,n).context;kk(c,t),a=this.applyTransferMapsToCanvas(c)}const i=this._scaleImage(a,Wc(o));o.imageSmoothingEnabled=Yk(ln(o),t.interpolate),DT(o,i.img,0,0,i.paintWidth,i.paintHeight,0,-n,r,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,r){if(!this.contentVisible)return;const n=this.ctx;let o;if(t.bitmap)o=t.bitmap;else{const a=t.width,i=t.height,c=this.cachedCanvases.getCanvas("inlineImage",a,i).context;kk(c,t),o=this.applyTransferMapsToCanvas(c)}for(const a of r)n.save(),n.transform(...a.transform),n.scale(1,-1),DT(n,o,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,r){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,r){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(r)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const n=this.ctx;this.pendingClip&&(r||(this.pendingClip===qk?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ln(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const r=Math.abs(t[0]*t[3]-t[2]*t[1]),n=Math.hypot(t[0],t[2]),o=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(n,o)/r}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:r,b:n,c:o,d:a}=this.ctx.getTransform();let i,s;if(n===0&&o===0){const c=Math.abs(r),l=Math.abs(a);if(c===l)if(t===0)i=s=1/c;else{const u=c*t;i=s=u<1?1/u:1}else if(t===0)i=1/c,s=1/l;else{const u=c*t,h=l*t;i=u<1?1/u:1,s=h<1?1/h:1}}else{const c=Math.abs(r*a-n*o),l=Math.hypot(r,n),u=Math.hypot(o,a);if(t===0)i=u/c,s=l/c;else{const h=t*c;i=u>h?u/h:1,s=l>h?l/h:1}}this._cachedScaleForStroking[0]=i,this._cachedScaleForStroking[1]=s}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:r}=this,{lineWidth:n}=this.current,[o,a]=this.getScaleForStroking();if(r.lineWidth=n||1,o===1&&a===1){r.stroke();return}const i=r.getLineDash();if(t&&r.save(),r.scale(o,a),i.length>0){const s=Math.max(o,a);r.setLineDash(i.map(c=>c/s)),r.lineDashOffset/=s}r.stroke(),t&&r.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Yu=new WeakSet,F$=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();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)},B$=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const r=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=r}}};let Hm=v$;for(const e in as)Hm.prototype[e]!==void 0&&(Hm.prototype[as[e]]=Hm.prototype[e]);class kc{static get workerPort(){return v(this,D0)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");Y(this,D0,t)}static get workerSrc(){return v(this,I0)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");Y(this,I0,t)}}D0=new WeakMap,I0=new WeakMap,ee(kc,D0,null),ee(kc,I0,"");const zT={UNKNOWN:0,DATA:1,ERROR:2},Xn={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function ti(e){switch(e instanceof Error||typeof e=="object"&&e!==null||Er('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new jf(e.message);case"MissingPDFException":return new xf(e.message);case"PasswordException":return new KN(e.message,e.code);case"UnexpectedResponseException":return new jT(e.message,e.status);case"UnknownErrorException":return new HN(e.message,e.details);default:return new HN(e.message,e.toString())}}class Gw{constructor(t,r,n){ee(this,cc);this.sourceName=t,this.targetName=r,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),this._onComObjOnMessage=o=>{const a=o.data;if(a.targetName!==this.sourceName)return;if(a.stream){J(this,cc,DJ).call(this,a);return}if(a.callback){const s=a.callbackId,c=this.callbackCapabilities[s];if(!c)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],a.callback===zT.DATA)c.resolve(a.data);else if(a.callback===zT.ERROR)c.reject(ti(a.reason));else throw new Error("Unexpected callback case");return}const i=this.actionHandler[a.action];if(!i)throw new Error(`Unknown action from worker: ${a.action}`);if(a.callbackId){const s=this.sourceName,c=a.sourceName;new Promise(function(l){l(i(a.data))}).then(function(l){n.postMessage({sourceName:s,targetName:c,callback:zT.DATA,callbackId:a.callbackId,data:l})},function(l){n.postMessage({sourceName:s,targetName:c,callback:zT.ERROR,callbackId:a.callbackId,reason:ti(l)})});return}if(a.streamId){J(this,cc,CJ).call(this,a);return}i(a.data)},n.addEventListener("message",this._onComObjOnMessage)}on(t,r){const n=this.actionHandler;if(n[t])throw new Error(`There is already an actionName called "${t}"`);n[t]=r}send(t,r,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:r},n)}sendWithPromise(t,r,n){const o=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[o]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:o,data:r},n)}catch(i){a.reject(i)}return a.promise}sendWithStream(t,r,n,o){const a=this.streamId++,i=this.sourceName,s=this.targetName,c=this.comObj;return new ReadableStream({start:l=>{const u=Promise.withResolvers();return this.streamControllers[a]={controller:l,startCall:u,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:i,targetName:s,action:t,streamId:a,data:r,desiredSize:l.desiredSize},o),u.promise},pull:l=>{const u=Promise.withResolvers();return this.streamControllers[a].pullCall=u,c.postMessage({sourceName:i,targetName:s,stream:Xn.PULL,streamId:a,desiredSize:l.desiredSize}),u.promise},cancel:l=>{to(l instanceof Error,"cancel must have a valid reason");const u=Promise.withResolvers();return this.streamControllers[a].cancelCall=u,this.streamControllers[a].isClosed=!0,c.postMessage({sourceName:i,targetName:s,stream:Xn.CANCEL,streamId:a,reason:ti(l)}),u.promise}},n)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}cc=new WeakSet,CJ=function(t){const r=t.streamId,n=this.sourceName,o=t.sourceName,a=this.comObj,i=this,s=this.actionHandler[t.action],c={enqueue(l,u=1,h){if(this.isCancelled)return;const p=this.desiredSize;this.desiredSize-=u,p>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:n,targetName:o,stream:Xn.ENQUEUE,streamId:r,chunk:l},h)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:o,stream:Xn.CLOSE,streamId:r}),delete i.streamSinks[r])},error(l){to(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:o,stream:Xn.ERROR,streamId:r,reason:ti(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[r]=c,new Promise(function(l){l(s(t.data,c))}).then(function(){a.postMessage({sourceName:n,targetName:o,stream:Xn.START_COMPLETE,streamId:r,success:!0})},function(l){a.postMessage({sourceName:n,targetName:o,stream:Xn.START_COMPLETE,streamId:r,reason:ti(l)})})},DJ=function(t){const r=t.streamId,n=this.sourceName,o=t.sourceName,a=this.comObj,i=this.streamControllers[r],s=this.streamSinks[r];switch(t.stream){case Xn.START_COMPLETE:t.success?i.startCall.resolve():i.startCall.reject(ti(t.reason));break;case Xn.PULL_COMPLETE:t.success?i.pullCall.resolve():i.pullCall.reject(ti(t.reason));break;case Xn.PULL:if(!s){a.postMessage({sourceName:n,targetName:o,stream:Xn.PULL_COMPLETE,streamId:r,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,new Promise(function(c){var l;c((l=s.onPull)==null?void 0:l.call(s))}).then(function(){a.postMessage({sourceName:n,targetName:o,stream:Xn.PULL_COMPLETE,streamId:r,success:!0})},function(c){a.postMessage({sourceName:n,targetName:o,stream:Xn.PULL_COMPLETE,streamId:r,reason:ti(c)})});break;case Xn.ENQUEUE:if(to(i,"enqueue should have stream controller"),i.isClosed)break;i.controller.enqueue(t.chunk);break;case Xn.CLOSE:if(to(i,"close should have stream controller"),i.isClosed)break;i.isClosed=!0,i.controller.close(),J(this,cc,BA).call(this,i,r);break;case Xn.ERROR:to(i,"error should have stream controller"),i.controller.error(ti(t.reason)),J(this,cc,BA).call(this,i,r);break;case Xn.CANCEL_COMPLETE:t.success?i.cancelCall.resolve():i.cancelCall.reject(ti(t.reason)),J(this,cc,BA).call(this,i,r);break;case Xn.CANCEL:if(!s)break;new Promise(function(c){var l;c((l=s.onCancel)==null?void 0:l.call(s,ti(t.reason)))}).then(function(){a.postMessage({sourceName:n,targetName:o,stream:Xn.CANCEL_COMPLETE,streamId:r,success:!0})},function(c){a.postMessage({sourceName:n,targetName:o,stream:Xn.CANCEL_COMPLETE,streamId:r,reason:ti(c)})}),s.sinkCapability.reject(ti(t.reason)),s.isCancelled=!0,delete this.streamSinks[r];break;default:throw new Error("Unexpected stream case")}},BA=async function(t,r){var n,o,a;await Promise.allSettled([(n=t.startCall)==null?void 0:n.promise,(o=t.pullCall)==null?void 0:o.promise,(a=t.cancelCall)==null?void 0:a.promise]),delete this.streamControllers[r]};class I6e{constructor({parsedData:t,rawData:r}){ee(this,Jf);ee(this,z0);Y(this,Jf,t),Y(this,z0,r)}getRaw(){return v(this,z0)}get(t){return v(this,Jf).get(t)??null}getAll(){return XN(v(this,Jf))}has(t){return v(this,Jf).has(t)}}Jf=new WeakMap,z0=new WeakMap;const Bu=Symbol("INTERNAL");class z6e{constructor(t,{name:r,intent:n,usage:o}){ee(this,U0,!1);ee(this,N0,!1);ee(this,R0,!1);ee(this,fg,!0);Y(this,U0,!!(t&zi.DISPLAY)),Y(this,N0,!!(t&zi.PRINT)),this.name=r,this.intent=n,this.usage=o}get visible(){if(v(this,R0))return v(this,fg);if(!v(this,fg))return!1;const{print:t,view:r}=this.usage;return v(this,U0)?(r==null?void 0:r.viewState)!=="OFF":v(this,N0)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,r,n=!1){t!==Bu&&Er("Internal method `_setVisible` called."),Y(this,R0,n),Y(this,fg,r)}}U0=new WeakMap,N0=new WeakMap,R0=new WeakMap,fg=new WeakMap;class U6e{constructor(t,r=zi.DISPLAY){ee(this,$0);ee(this,qu,null);ee(this,Ar,new Map);ee(this,hg,null);ee(this,pg,null);if(this.renderingIntent=r,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,Y(this,pg,t.order);for(const n of t.groups)v(this,Ar).set(n.id,new z6e(r,n));if(t.baseState==="OFF")for(const n of v(this,Ar).values())n._setVisible(Bu,!1);for(const n of t.on)v(this,Ar).get(n)._setVisible(Bu,!0);for(const n of t.off)v(this,Ar).get(n)._setVisible(Bu,!1);Y(this,hg,this.getHash())}}isVisible(t){if(v(this,Ar).size===0)return!0;if(!t)return xT("Optional content group not defined."),!0;if(t.type==="OCG")return v(this,Ar).has(t.id)?v(this,Ar).get(t.id).visible:(Dt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return J(this,$0,L$).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const r of t.ids){if(!v(this,Ar).has(r))return Dt(`Optional content group not found: ${r}`),!0;if(v(this,Ar).get(r).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const r of t.ids){if(!v(this,Ar).has(r))return Dt(`Optional content group not found: ${r}`),!0;if(!v(this,Ar).get(r).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const r of t.ids){if(!v(this,Ar).has(r))return Dt(`Optional content group not found: ${r}`),!0;if(!v(this,Ar).get(r).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const r of t.ids){if(!v(this,Ar).has(r))return Dt(`Optional content group not found: ${r}`),!0;if(v(this,Ar).get(r).visible)return!1}return!0}return Dt(`Unknown optional content policy ${t.policy}.`),!0}return Dt(`Unknown group type ${t.type}.`),!0}setVisibility(t,r=!0){const n=v(this,Ar).get(t);if(!n){Dt(`Optional content group not found: ${t}`);return}n._setVisible(Bu,!!r,!0),Y(this,qu,null)}setOCGState({state:t,preserveRB:r}){let n;for(const o of t){switch(o){case"ON":case"OFF":case"Toggle":n=o;continue}const a=v(this,Ar).get(o);if(a)switch(n){case"ON":a._setVisible(Bu,!0);break;case"OFF":a._setVisible(Bu,!1);break;case"Toggle":a._setVisible(Bu,!a.visible);break}}Y(this,qu,null)}get hasInitialVisibility(){return v(this,hg)===null||this.getHash()===v(this,hg)}getOrder(){return v(this,Ar).size?v(this,pg)?v(this,pg).slice():[...v(this,Ar).keys()]:null}getGroups(){return v(this,Ar).size>0?XN(v(this,Ar)):null}getGroup(t){return v(this,Ar).get(t)||null}getHash(){if(v(this,qu)!==null)return v(this,qu);const t=new $k;for(const[r,n]of v(this,Ar))t.update(`${r}:${n.visible}`);return Y(this,qu,t.hexdigest())}}qu=new WeakMap,Ar=new WeakMap,hg=new WeakMap,pg=new WeakMap,$0=new WeakSet,L$=function(t){const r=t.length;if(r<2)return!0;const n=t[0];for(let o=1;o<r;o++){const a=t[o];let i;if(Array.isArray(a))i=J(this,$0,L$).call(this,a);else if(v(this,Ar).has(a))i=v(this,Ar).get(a).visible;else return Dt(`Optional content group not found: ${a}`),!0;switch(n){case"And":if(!i)return!1;break;case"Or":if(i)return!0;break;case"Not":return!i;default:return!0}}return n==="And"};class N6e{constructor(t,{disableRange:r=!1,disableStream:n=!1}){to(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:o,initialData:a,progressiveDone:i,contentDispositionFilename:s}=t;if(this._queuedChunks=[],this._progressiveDone=i,this._contentDispositionFilename=s,(a==null?void 0:a.length)>0){const c=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(c)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!r,this._contentLength=o,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((c,l)=>{this._onReceiveData({begin:c,chunk:l})}),t.addProgressListener((c,l)=>{this._onProgress({loaded:c,total:l})}),t.addProgressiveReadListener(c=>{this._onReceiveData({chunk:c})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:r}){const n=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{const o=this._rangeReaders.some(function(a){return a._begin!==t?!1:(a._enqueue(n),!0)});to(o,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var r,n,o,a;t.total===void 0?(n=(r=this._rangeReaders[0])==null?void 0:r.onProgress)==null||n.call(r,{loaded:t.loaded}):(a=(o=this._fullRequestReader)==null?void 0:o.onProgress)==null||a.call(o,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const r=this._rangeReaders.indexOf(t);r>=0&&this._rangeReaders.splice(r,1)}getFullReader(){to(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new R6e(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,r){if(r<=this._progressiveDataLength)return null;const n=new $6e(this,t,r);return this._pdfDataRangeTransport.requestDataRange(t,r),this._rangeReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeReaders.slice(0))n.cancel(t);this._pdfDataRangeTransport.abort()}}class R6e{constructor(t,r,n=!1,o=null){this._stream=t,this._done=n||!1,this._filename=QN(o)?o:null,this._queuedChunks=r||[],this._loaded=0;for(const 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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class $6e{constructor(t,r,n){this._stream=t,this._begin=r,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(const 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){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function F6e(e){let t=!0,r=n("filename\\*","i").exec(e);if(r){r=r[1];let u=s(r);return u=unescape(u),u=c(u),u=l(u),a(u)}if(r=i(e),r){const u=l(r);return a(u)}if(r=n("filename","i").exec(e),r){r=r[1];let u=s(r);return u=l(u),a(u)}function n(u,h){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',h)}function o(u,h){if(u){if(!/^[\x00-\xFF]+$/.test(h))return h;try{const p=new TextDecoder(u,{fatal:!0}),m=OT(h);h=p.decode(m),t=!1}catch{}}return h}function a(u){return t&&/[\x80-\xff]/.test(u)&&(u=o("utf-8",u),t&&(u=o("iso-8859-1",u))),u}function i(u){const h=[];let p;const m=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(p=m.exec(u))!==null;){let[,b,_,y]=p;if(b=parseInt(b,10),b in h){if(b===0)break;continue}h[b]=[_,y]}const g=[];for(let b=0;b<h.length&&b in h;++b){let[_,y]=h[b];y=s(y),_&&(y=unescape(y),b===0&&(y=c(y))),g.push(y)}return g.join("")}function s(u){if(u.startsWith('"')){const h=u.slice(1).split('\\"');for(let p=0;p<h.length;++p){const m=h[p].indexOf('"');m!==-1&&(h[p]=h[p].slice(0,m),h.length=p+1),h[p]=h[p].replaceAll(/\\(.)/g,"$1")}u=h.join('"')}return u}function c(u){const h=u.indexOf("'");if(h===-1)return u;const p=u.slice(0,h),g=u.slice(h+1).replace(/^[^']*'/,"");return o(p,g)}function l(u){return!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u)?u:u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(h,p,m,g){if(m==="q"||m==="Q")return g=g.replaceAll("_"," "),g=g.replaceAll(/=([0-9a-fA-F]{2})/g,function(b,_){return String.fromCharCode(parseInt(_,16))}),o(p,g);try{g=atob(g)}catch{}return o(p,g)})}return""}function lR({getResponseHeader:e,isHttp:t,rangeChunkSize:r,disableRange:n}){const o={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e("Content-Length"),10);return!Number.isInteger(a)||(o.suggestedLength=a,a<=2*r)||n||!t||e("Accept-Ranges")!=="bytes"||(e("Content-Encoding")||"identity")!=="identity"||(o.allowRangeRequests=!0),o}function uR(e){const t=e("Content-Disposition");if(t){let r=F6e(t);if(r.includes("%"))try{r=decodeURIComponent(r)}catch{}if(QN(r))return r}return null}function UT(e,t){return e===404||e===0&&t.startsWith("file:")?new xf('Missing PDF "'+t+'".'):new jT(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function Jk(e){return e===200||e===206}function Qk(e,t,r){return{method:"GET",headers:e,signal:r.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Zk(e){const t=new Headers;for(const r in e){const n=e[r];n!==void 0&&t.append(r,n)}return t}function eG(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(Dt(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}class tG{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return to(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new B6e(this),this._fullRequestReader}getRangeReader(t,r){if(r<=this._progressiveDataLength)return null;const n=new L6e(this,t,r);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class B6e{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const r=t.source;this._withCredentials=r.withCredentials||!1,this._contentLength=r.length,this._headersCapability=Promise.withResolvers(),this._disableRange=r.disableRange||!1,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!r.disableStream,this._isRangeSupported=!r.disableRange,this._headers=Zk(this._stream.httpHeaders);const n=r.url;fetch(n,Qk(this._headers,this._withCredentials,this._abortController)).then(o=>{if(!Jk(o.status))throw UT(o.status,n);this._reader=o.body.getReader(),this._headersCapability.resolve();const a=c=>o.headers.get(c),{allowRangeRequests:i,suggestedLength:s}=lR({getResponseHeader:a,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=s||this._contentLength,this._filename=uR(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new jf("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(){var n;await this._headersCapability.promise;const{value:t,done:r}=await this._reader.read();return r?{value:t,done:r}:(this._loaded+=t.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded,total:this._contentLength}),{value:eG(t),done:!1})}cancel(t){var r;(r=this._reader)==null||r.cancel(t),this._abortController.abort()}}class L6e{constructor(t,r,n){this._stream=t,this._reader=null,this._loaded=0;const o=t.source;this._withCredentials=o.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!o.disableStream,this._abortController=new AbortController,this._headers=Zk(this._stream.httpHeaders),this._headers.append("Range",`bytes=${r}-${n-1}`);const a=o.url;fetch(a,Qk(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Jk(i.status))throw UT(i.status,a);this._readCapability.resolve(),this._reader=i.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;await this._readCapability.promise;const{value:t,done:r}=await this._reader.read();return r?{value:t,done:r}:(this._loaded+=t.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded}),{value:eG(t),done:!1})}cancel(t){var r;(r=this._reader)==null||r.cancel(t),this._abortController.abort()}}const dR=200,fR=206;function V6e(e){const t=e.response;return typeof t!="string"?t:OT(t).buffer}class K6e{constructor(t,r={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&r.httpHeaders||Object.create(null),this.withCredentials=r.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,r,n){const o={begin:t,end:r};for(const a in n)o[a]=n[a];return this.request(o)}requestFull(t){return this.request(t)}request(t){const r=new XMLHttpRequest,n=this.currXhrId++,o=this.pendingRequests[n]={xhr:r};r.open("GET",this.url),r.withCredentials=this.withCredentials;for(const a in this.httpHeaders){const i=this.httpHeaders[a];i!==void 0&&r.setRequestHeader(a,i)}return this.isHttp&&"begin"in t&&"end"in t?(r.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),o.expectedStatus=fR):o.expectedStatus=dR,r.responseType="arraybuffer",t.onError&&(r.onerror=function(a){t.onError(r.status)}),r.onreadystatechange=this.onStateChange.bind(this,n),r.onprogress=this.onProgress.bind(this,n),o.onHeadersReceived=t.onHeadersReceived,o.onDone=t.onDone,o.onError=t.onError,o.onProgress=t.onProgress,r.send(null),n}onProgress(t,r){var o;const n=this.pendingRequests[t];n&&((o=n.onProgress)==null||o.call(n,r))}onStateChange(t,r){var c,l,u;const n=this.pendingRequests[t];if(!n)return;const o=n.xhr;if(o.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),o.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],o.status===0&&this.isHttp){(c=n.onError)==null||c.call(n,o.status);return}const a=o.status||dR;if(!(a===dR&&n.expectedStatus===fR)&&a!==n.expectedStatus){(l=n.onError)==null||l.call(n,o.status);return}const s=V6e(o);if(a===fR){const h=o.getResponseHeader("Content-Range"),p=/bytes (\d+)-(\d+)\/(\d+)/.exec(h);n.onDone({begin:parseInt(p[1],10),chunk:s})}else s?n.onDone({begin:0,chunk:s}):(u=n.onError)==null||u.call(n,o.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const r=this.pendingRequests[t].xhr;delete this.pendingRequests[t],r.abort()}}class H6e{constructor(t){this._source=t,this._manager=new K6e(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const r=this._rangeRequestReaders.indexOf(t);r>=0&&this._rangeRequestReaders.splice(r,1)}getFullReader(){return to(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new X6e(this._manager,this._source),this._fullRequestReader}getRangeReader(t,r){const n=new W6e(this._manager,t,r);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class X6e{constructor(t,r){this._manager=t;const n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=r.url,this._fullRequestId=t.requestFull(n),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=r.disableRange||!1,this._contentLength=r.length,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,r=this._manager.getRequestXhr(t),n=i=>r.getResponseHeader(i),{allowRangeRequests:o,suggestedLength:a}=lR({getResponseHeader:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});o&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=uR(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=UT(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var r;(r=this.onProgress)==null||r.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.reject(t);for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class W6e{constructor(t,r,n){this._manager=t;const o={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(r,n,o),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const r=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:r,done:!1}):this._queuedChunk=r,this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=UT(t,this._url);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var r;this.isStreamingSupported||(r=this.onProgress)==null||r.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const rG=/^file:\/\/\/[a-zA-Z]:\//;function k6e(e){const t=tc.get("url"),r=t.parse(e);return r.protocol==="file:"||r.host?r:/^[a-z]:[/\\]/i.test(e)?t.parse(`file:///${e}`):(r.host||(r.protocol="file:"),r)}class G6e{constructor(t){this.source=t,this.url=k6e(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return to(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new J6e(this):new Y6e(this),this._fullRequestReader}getRangeReader(t,r){if(r<=this._progressiveDataLength)return null;const n=this.isFsUrl?new Q6e(this,t,r):new q6e(this,t,r);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class nG{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const r=t.source;this._contentLength=r.length,this._loaded=0,this._filename=null,this._disableRange=r.disableRange||!1,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!r.disableStream,this._isRangeSupported=!r.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(n=this.onProgress)==null||n.call(this,{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",r=>{this._error(r)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new jf("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class oG{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=t.source;this._isStreamingSupported=!r.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(n=this.onProgress)==null||n.call(this,{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",r=>{this._error(r)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function NT(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class Y6e extends nG{constructor(t){super(t);const r=n=>{if(n.statusCode===404){const s=new xf(`Missing PDF "${this._url}".`);this._storedError=s,this._headersCapability.reject(s);return}this._headersCapability.resolve(),this._setReadableStream(n);const o=s=>this._readableStream.headers[s.toLowerCase()],{allowRangeRequests:a,suggestedLength:i}=lR({getResponseHeader:o,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=i||this._contentLength,this._filename=uR(o)};if(this._request=null,this._url.protocol==="http:"){const n=tc.get("http");this._request=n.request(NT(this._url,t.httpHeaders),r)}else{const n=tc.get("https");this._request=n.request(NT(this._url,t.httpHeaders),r)}this._request.on("error",n=>{this._storedError=n,this._headersCapability.reject(n)}),this._request.end()}}class q6e extends oG{constructor(t,r,n){super(t),this._httpHeaders={};for(const a in t.httpHeaders){const i=t.httpHeaders[a];i!==void 0&&(this._httpHeaders[a]=i)}this._httpHeaders.Range=`bytes=${r}-${n-1}`;const o=a=>{if(a.statusCode===404){const i=new xf(`Missing PDF "${this._url}".`);this._storedError=i;return}this._setReadableStream(a)};if(this._request=null,this._url.protocol==="http:"){const a=tc.get("http");this._request=a.request(NT(this._url,this._httpHeaders),o)}else{const a=tc.get("https");this._request=a.request(NT(this._url,this._httpHeaders),o)}this._request.on("error",a=>{this._storedError=a}),this._request.end()}}class J6e extends nG{constructor(t){super(t);let r=decodeURIComponent(this._url.path);rG.test(this._url.href)&&(r=r.replace(/^\//,""));const n=tc.get("fs");n.promises.lstat(r).then(o=>{this._contentLength=o.size,this._setReadableStream(n.createReadStream(r)),this._headersCapability.resolve()},o=>{o.code==="ENOENT"&&(o=new xf(`Missing PDF "${r}".`)),this._storedError=o,this._headersCapability.reject(o)})}}class Q6e extends oG{constructor(t,r,n){super(t);let o=decodeURIComponent(this._url.path);rG.test(this._url.href)&&(o=o.replace(/^\//,""));const a=tc.get("fs");this._setReadableStream(a.createReadStream(o,{start:r,end:n-1}))}}const Z6e=1e5,Fa=30,e8e=.8;let RT=(no=class{constructor({textContentSource:t,container:r,viewport:n}){ee(this,cl);ee(this,Ju,Promise.withResolvers());ee(this,La,null);ee(this,F0,!1);ee(this,B0,!!((jq=globalThis.FontInspector)!=null&&jq.enabled));ee(this,Qf,null);ee(this,sl,null);ee(this,L0,0);ee(this,V0,0);ee(this,Zf,null);ee(this,mg,null);ee(this,gg,0);ee(this,Qu,0);ee(this,bg,Object.create(null));ee(this,K0,[]);ee(this,vg,null);ee(this,eh,[]);ee(this,H0,new WeakMap);ee(this,X0,null);var c;if(t instanceof ReadableStream)Y(this,vg,t);else if(typeof t=="object")Y(this,vg,new ReadableStream({start(l){l.enqueue(t),l.close()}}));else throw new Error('No "textContentSource" parameter specified.');Y(this,La,Y(this,mg,r)),Y(this,Qu,n.scale*(globalThis.devicePixelRatio||1)),Y(this,gg,n.rotation),Y(this,sl,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:o,pageHeight:a,pageX:i,pageY:s}=n.rawDims;Y(this,X0,[1,0,0,-1,-i,s+a]),Y(this,V0,o),Y(this,L0,a),J(c=no,lc,UJ).call(c),Of(r,n),v(this,Ju).promise.catch(()=>{}).then(()=>{v(no,yg).delete(this),Y(this,sl,null),Y(this,bg,null)})}render(){const t=()=>{v(this,Zf).read().then(({value:r,done:n})=>{if(n){v(this,Ju).resolve();return}v(this,Qf)??Y(this,Qf,r.lang),Object.assign(v(this,bg),r.styles),J(this,cl,IJ).call(this,r.items),t()},v(this,Ju).reject)};return Y(this,Zf,v(this,vg).getReader()),v(no,yg).add(this),t(),v(this,Ju).promise}update({viewport:t,onBefore:r=null}){var a;const n=t.scale*(globalThis.devicePixelRatio||1),o=t.rotation;if(o!==v(this,gg)&&(r==null||r(),Y(this,gg,o),Of(v(this,mg),{rotation:o})),n!==v(this,Qu)){r==null||r(),Y(this,Qu,n);const i={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:J(a=no,lc,LA).call(a,v(this,Qf))};for(const s of v(this,eh))i.properties=v(this,H0).get(s),i.div=s,J(this,cl,V$).call(this,i)}}cancel(){var r;const t=new jf("TextLayer task cancelled.");(r=v(this,Zf))==null||r.cancel(t).catch(()=>{}),Y(this,Zf,null),v(this,Ju).reject(t)}get textDivs(){return v(this,eh)}get textContentItemsStr(){return v(this,K0)}static cleanup(){if(!(v(this,yg).size>0)){v(this,th).clear();for(const{canvas:t}of v(this,rh).values())t.remove();v(this,rh).clear()}}},Ju=new WeakMap,La=new WeakMap,F0=new WeakMap,B0=new WeakMap,Qf=new WeakMap,sl=new WeakMap,L0=new WeakMap,V0=new WeakMap,Zf=new WeakMap,mg=new WeakMap,gg=new WeakMap,Qu=new WeakMap,bg=new WeakMap,K0=new WeakMap,vg=new WeakMap,eh=new WeakMap,H0=new WeakMap,X0=new WeakMap,th=new WeakMap,rh=new WeakMap,Zu=new WeakMap,yg=new WeakMap,cl=new WeakSet,IJ=function(t){var o,a;if(v(this,F0))return;(a=v(this,sl)).ctx??(a.ctx=J(o=no,lc,LA).call(o,v(this,Qf)));const r=v(this,eh),n=v(this,K0);for(const i of t){if(r.length>Z6e){Dt("Ignoring additional textDivs for performance reasons."),Y(this,F0,!0);return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const s=v(this,La);Y(this,La,document.createElement("span")),v(this,La).classList.add("markedContent"),i.id!==null&&v(this,La).setAttribute("id",`${i.id}`),s.append(v(this,La))}else i.type==="endMarkedContent"&&Y(this,La,v(this,La).parentNode);continue}n.push(i.str),J(this,cl,zJ).call(this,i)}},zJ=function(t){var b;const r=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};v(this,eh).push(r);const o=rt.transform(v(this,X0),t.transform);let a=Math.atan2(o[1],o[0]);const i=v(this,bg)[t.fontName];i.vertical&&(a+=Math.PI/2);const s=v(this,B0)&&i.fontSubstitution||i.fontFamily,c=Math.hypot(o[2],o[3]),l=c*J(b=no,lc,NJ).call(b,s,v(this,Qf));let u,h;a===0?(u=o[4],h=o[5]-l):(u=o[4]+l*Math.sin(a),h=o[5]-l*Math.cos(a));const p="calc(var(--scale-factor)*",m=r.style;v(this,La)===v(this,mg)?(m.left=`${(100*u/v(this,V0)).toFixed(2)}%`,m.top=`${(100*h/v(this,L0)).toFixed(2)}%`):(m.left=`${p}${u.toFixed(2)}px)`,m.top=`${p}${h.toFixed(2)}px)`),m.fontSize=`${p}${(v(no,Zu)*c).toFixed(2)}px)`,m.fontFamily=s,n.fontSize=c,r.setAttribute("role","presentation"),r.textContent=t.str,r.dir=t.dir,v(this,B0)&&(r.dataset.fontName=i.fontSubstitutionLoadedName||t.fontName),a!==0&&(n.angle=a*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const _=Math.abs(t.transform[0]),y=Math.abs(t.transform[3]);_!==y&&Math.max(_,y)/Math.min(_,y)>1.5&&(g=!0)}if(g&&(n.canvasWidth=i.vertical?t.height:t.width),v(this,H0).set(r,n),v(this,sl).div=r,v(this,sl).properties=n,J(this,cl,V$).call(this,v(this,sl)),n.hasText&&v(this,La).append(r),n.hasEOL){const _=document.createElement("br");_.setAttribute("role","presentation"),v(this,La).append(_)}},V$=function(t){const{div:r,properties:n,ctx:o,prevFontSize:a,prevFontFamily:i}=t,{style:s}=r;let c="";if(v(no,Zu)>1&&(c=`scale(${1/v(no,Zu)})`),n.canvasWidth!==0&&n.hasText){const{fontFamily:l}=s,{canvasWidth:u,fontSize:h}=n;(a!==h||i!==l)&&(o.font=`${h*v(this,Qu)}px ${l}`,t.prevFontSize=h,t.prevFontFamily=l);const{width:p}=o.measureText(r.textContent);p>0&&(c=`scaleX(${u*v(this,Qu)/p}) ${c}`)}n.angle!==0&&(c=`rotate(${n.angle}deg) ${c}`),c.length>0&&(s.transform=c)},lc=new WeakSet,LA=function(t=null){let r=v(this,rh).get(t||(t=""));if(!r){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),r=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),v(this,rh).set(t,r)}return r},UJ=function(){if(v(this,Zu)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),Y(this,Zu,t.getBoundingClientRect().height),t.remove()},NJ=function(t,r){const n=v(this,th).get(t);if(n)return n;const o=J(this,lc,LA).call(this,r),a=o.font;o.canvas.width=o.canvas.height=Fa,o.font=`${Fa}px ${t}`;const i=o.measureText("");let s=i.fontBoundingBoxAscent,c=Math.abs(i.fontBoundingBoxDescent);if(s){const h=s/(s+c);return v(this,th).set(t,h),o.canvas.width=o.canvas.height=0,o.font=a,h}o.strokeStyle="red",o.clearRect(0,0,Fa,Fa),o.strokeText("g",0,0);let l=o.getImageData(0,0,Fa,Fa).data;c=0;for(let h=l.length-1-3;h>=0;h-=4)if(l[h]>0){c=Math.ceil(h/4/Fa);break}o.clearRect(0,0,Fa,Fa),o.strokeText("A",0,Fa),l=o.getImageData(0,0,Fa,Fa).data,s=0;for(let h=0,p=l.length;h<p;h+=4)if(l[h]>0){s=Fa-Math.floor(h/4/Fa);break}o.canvas.width=o.canvas.height=0,o.font=a;const u=s?s/(s+c):e8e;return v(this,th).set(t,u),u},ee(no,lc),ee(no,th,new Map),ee(no,rh,new Map),ee(no,Zu,null),ee(no,yg,new Set),no);function t8e(){zk("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:e,container:t,viewport:r,...n}=arguments[0],o=Object.keys(n);o.length>0&&Dt("Ignoring `renderTextLayer` parameters: "+o.join(", "));const a=new RT({textContentSource:e,container:t,viewport:r}),{textDivs:i,textContentItemsStr:s}=a;return{promise:a.render(),textDivs:i,textContentItemsStr:s}}function r8e(){zk("`updateTextLayer`, please use `TextLayer` instead.")}class Yw{static textContent(t){const r=[],n={items:r,styles:Object.create(null)};function o(a){var c;if(!a)return;let i=null;const s=a.name;if(s==="#text")i=a.value;else if(Yw.shouldBuildText(s))(c=a==null?void 0:a.attributes)!=null&&c.textContent?i=a.attributes.textContent:a.value&&(i=a.value);else return;if(i!==null&&r.push({str:i}),!!a.children)for(const l of a.children)o(l)}return o(t),n}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const n8e=65536,o8e=100,a8e=5e3,i8e=oa?b6e:o6e,s8e=oa?v6e:Ck,c8e=oa?g6e:n6e,l8e=oa?y6e:Dk;function u8e(e={}){typeof e=="string"||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t=new hR,{docId:r}=t,n=e.url?d8e(e.url):null,o=e.data?f8e(e.data):null,a=e.httpHeaders||null,i=e.withCredentials===!0,s=e.password??null,c=e.range instanceof iG?e.range:null,l=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:n8e;let u=e.worker instanceof Xm?e.worker:null;const h=e.verbosity,p=typeof e.docBaseUrl=="string"&&!JN(e.docBaseUrl)?e.docBaseUrl:null,m=typeof e.cMapUrl=="string"?e.cMapUrl:null,g=e.cMapPacked!==!1,b=e.CMapReaderFactory||s8e,_=typeof e.standardFontDataUrl=="string"?e.standardFontDataUrl:null,y=e.StandardFontDataFactory||l8e,x=e.stopAtErrors!==!0,O=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,S=e.isEvalSupported!==!1,j=typeof e.isOffscreenCanvasSupported=="boolean"?e.isOffscreenCanvasSupported:!oa,P=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,I=typeof e.disableFontFace=="boolean"?e.disableFontFace:oa,M=e.fontExtraProperties===!0,E=e.enableXfa===!0,D=e.ownerDocument||globalThis.document,A=e.disableRange===!0,z=e.disableStream===!0,$=e.disableAutoFetch===!0,L=e.pdfBug===!0,B=e.enableHWA===!0,W=c?c.length:e.length??NaN,K=typeof e.useSystemFonts=="boolean"?e.useSystemFonts:!oa&&!I,Q=typeof e.useWorkerFetch=="boolean"?e.useWorkerFetch:b===Ck&&y===Dk&&m&&_&&Kw(m,document.baseURI)&&Kw(_,document.baseURI),re=e.canvasFactory||new i8e({ownerDocument:D,enableHWA:B}),de=e.filterFactory||new c8e({docId:r,ownerDocument:D}),ge=null;WKe(h);const H={canvasFactory:re,filterFactory:de};if(Q||(H.cMapReaderFactory=new b({baseUrl:m,isCompressed:g}),H.standardFontDataFactory=new y({baseUrl:_})),!u){const ae={verbosity:h,port:kc.workerPort};u=ae.port?Xm.fromPort(ae):new Xm(ae),t._worker=u}const R={docId:r,apiVersion:"4.4.168",data:o,password:s,disableAutoFetch:$,rangeChunkSize:l,length:W,docBaseUrl:p,enableXfa:E,evaluatorOptions:{maxImageSize:O,disableFontFace:I,ignoreErrors:x,isEvalSupported:S,isOffscreenCanvasSupported:j,canvasMaxAreaInBytes:P,fontExtraProperties:M,useSystemFonts:K,cMapUrl:Q?m:null,standardFontDataUrl:Q?_:null}},Z={disableFontFace:I,fontExtraProperties:M,ownerDocument:D,pdfBug:L,styleElement:ge,loadingParams:{disableAutoFetch:$,enableXfa:E}};return u.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const ae=u.messageHandler.sendWithPromise("GetDocRequest",R,o?[o.buffer]:null);let k;if(c)k=new N6e(c,{disableRange:A,disableStream:z});else if(!o){if(!n)throw new Error("getDocument - no `url` parameter provided.");k=(q=>oa?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&Kw(q.url)?new tG(q):new G6e(q):Kw(q.url)?new tG(q):new H6e(q))({url:n,length:W,httpHeaders:a,withCredentials:i,rangeChunkSize:l,disableRange:A,disableStream:z})}return ae.then(N=>{if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const q=new Gw(r,N,u.port),ie=new g8e(q,t,k,Z,H);t._transport=ie,q.send("Ready",null)})}).catch(t._capability.reject),t}function d8e(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(oa&&typeof e=="string")return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function f8e(e){if(oa&&typeof uo<"u"&&e instanceof uo)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e=="string")return OT(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e=="object"&&!isNaN(e==null?void 0:e.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function aG(e){return typeof e=="object"&&Number.isInteger(e==null?void 0:e.num)&&e.num>=0&&Number.isInteger(e==null?void 0:e.gen)&&e.gen>=0}const SA=class SA{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${hi(SA,MA)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,r,n;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((r=this._transport)==null?void 0:r.destroy())}catch(o){throw(n=this._worker)!=null&&n.port&&delete this._worker._pendingDestroy,o}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};MA=new WeakMap,ee(SA,MA,0);let hR=SA,iG=class{constructor(t,r,n=!1,o=null){this.length=t,this.initialData=r,this.progressiveDone=n,this.contentDispositionFilename=o,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,r){for(const n of this._rangeListeners)n(t,r)}onDataProgress(t,r){this._readyCapability.promise.then(()=>{for(const n of this._progressListeners)n(t,r)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const r of this._progressiveReadListeners)r(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,r){Er("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class h8e{constructor(t,r){this._pdfInfo=t,this._transport=r}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return ar(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:r}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(r)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class p8e{constructor(t,r,n,o=!1){ee(this,Fi);ee(this,ed,null);ee(this,ll,!1);this._pageIndex=t,this._pageInfo=r,this._transport=n,this._stats=o?new Ik:null,this._pdfBug=o,this.commonObjs=n.commonObjs,this.objs=new sG,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:r=this.rotate,offsetX:n=0,offsetY:o=0,dontFlip:a=!1}={}){return new Vw({viewBox:this.view,scale:t,rotation:r,offsetX:n,offsetY:o,dontFlip:a})}getAnnotations({intent:t="display"}={}){const{renderingIntent:r}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,r)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ar(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:r,intent:n="display",annotationMode:o=Ru.ENABLE,transform:a=null,background:i=null,optionalContentConfigPromise:s=null,annotationCanvasMap:c=null,pageColors:l=null,printAnnotationStorage:u=null}){var O,S;(O=this._stats)==null||O.time("Overall");const h=this._transport.getRenderingIntent(n,o,u),{renderingIntent:p,cacheKey:m}=h;Y(this,ll,!1),J(this,Fi,VA).call(this),s||(s=this._transport.getOptionalContentConfig(p));let g=this._intentStates.get(m);g||(g=Object.create(null),this._intentStates.set(m,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const b=!!(p&zi.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(S=this._stats)==null||S.time("Page Request"),this._pumpOperatorList(h));const _=j=>{var P;g.renderTasks.delete(y),(this._maybeCleanupAfterRender||b)&&Y(this,ll,!0),J(this,Fi,tb).call(this,!b),j?(y.capability.reject(j),this._abortOperatorList({intentState:g,reason:j instanceof Error?j:new Error(j)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(P=globalThis.Stats)!=null&&P.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new pR({callback:_,params:{canvasContext:t,viewport:r,transform:a,background:i},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||(g.renderTasks=new Set)).add(y);const x=y.task;return Promise.all([g.displayReadyCapability.promise,s]).then(([j,P])=>{var I;if(this.destroyed){_();return}if((I=this._stats)==null||I.time("Rendering"),!(P.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:j,optionalContentConfig:P}),y.operatorListChanged()}).catch(_),x}getOperatorList({intent:t="display",annotationMode:r=Ru.ENABLE,printAnnotationStorage:n=null}={}){var c;function o(){i.operatorList.lastChunk&&(i.opListReadCapability.resolve(i.operatorList),i.renderTasks.delete(s))}const a=this._transport.getRenderingIntent(t,r,n,!0);let i=this._intentStates.get(a.cacheKey);i||(i=Object.create(null),this._intentStates.set(a.cacheKey,i));let s;return i.opListReadCapability||(s=Object.create(null),s.operatorListChanged=o,i.opListReadCapability=Promise.withResolvers(),(i.renderTasks||(i.renderTasks=new Set)).add(s),i.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(a)),i.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:r=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:r===!0},{highWaterMark:100,size(o){return o.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>Yw.textContent(n));const r=this.streamTextContent(t);return new Promise(function(n,o){function a(){i.read().then(function({value:c,done:l}){if(l){n(s);return}s.lang??(s.lang=c.lang),Object.assign(s.styles,c.styles),s.items.push(...c.items),a()},o)}const i=r.getReader(),s={items:[],styles:Object.create(null),lang:null};a()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const r of this._intentStates.values())if(this._abortOperatorList({intentState:r,reason:new Error("Page was destroyed."),force:!0}),!r.opListReadCapability)for(const n of r.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),Y(this,ll,!1),J(this,Fi,VA).call(this),Promise.all(t)}cleanup(t=!1){Y(this,ll,!0);const r=J(this,Fi,tb).call(this,!1);return t&&r&&this._stats&&(this._stats=new Ik),r}_startRenderPage(t,r){var o,a;const n=this._intentStates.get(r);n&&((o=this._stats)==null||o.timeEnd("Page Request"),(a=n.displayReadyCapability)==null||a.resolve(t))}_renderPageChunk(t,r){for(let n=0,o=t.length;n<o;n++)r.operatorList.fnArray.push(t.fnArray[n]),r.operatorList.argsArray.push(t.argsArray[n]);r.operatorList.lastChunk=t.lastChunk,r.operatorList.separateAnnots=t.separateAnnots;for(const n of r.renderTasks)n.operatorListChanged();t.lastChunk&&J(this,Fi,tb).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:r,annotationStorageSerializable:n}){const{map:o,transfer:a}=n,s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:r,annotationStorage:o},a).getReader(),c=this._intentStates.get(r);c.streamReader=s;const l=()=>{s.read().then(({value:u,done:h})=>{if(h){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,c),l())},u=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const h of c.renderTasks)h.operatorListChanged();J(this,Fi,tb).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(u);else if(c.opListReadCapability)c.opListReadCapability.reject(u);else throw u}})};l()}_abortOperatorList({intentState:t,reason:r,force:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(r instanceof qN){let o=o8e;r.extraDelay>0&&r.extraDelay<1e3&&(o+=r.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:r,force:!0})},o);return}}if(t.streamReader.cancel(new jf(r.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[o,a]of this._intentStates)if(a===t){this._intentStates.delete(o);break}this.cleanup()}}}get stats(){return this._stats}}ed=new WeakMap,ll=new WeakMap,Fi=new WeakSet,tb=function(t=!1){if(J(this,Fi,VA).call(this),!v(this,ll)||this.destroyed)return!1;if(t)return Y(this,ed,setTimeout(()=>{Y(this,ed,null),J(this,Fi,tb).call(this,!1)},a8e)),!1;for(const{renderTasks:r,operatorList:n}of this._intentStates.values())if(r.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Y(this,ll,!1),!0},VA=function(){v(this,ed)&&(clearTimeout(v(this,ed)),Y(this,ed,null))};class m8e{constructor(){ee(this,nh,new Set);ee(this,PA,Promise.resolve())}postMessage(t,r){const n={data:structuredClone(t,r?{transfer:r}:null)};v(this,PA).then(()=>{for(const o of v(this,nh))o.call(this,n)})}addEventListener(t,r){v(this,nh).add(r)}removeEventListener(t,r){v(this,nh).delete(r)}terminate(){v(this,nh).clear()}}nh=new WeakMap,PA=new WeakMap;const Gc={isWorkerDisabled:!1,fakeWorkerId:0};oa&&(Gc.isWorkerDisabled=!0,kc.workerSrc||(kc.workerSrc="./pdf.worker.mjs")),Gc.isSameOrigin=function(e,t){let r;try{if(r=new URL(e),!r.origin||r.origin==="null")return!1}catch{return!1}const n=new URL(t,r);return r.origin===n.origin},Gc.createCDNWrapper=function(e){const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};const ai=class ai{constructor({name:t=null,port:r=null,verbosity:n=kKe()}={}){ee(this,_g);var o;if(this.name=t,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,r){if((o=v(ai,oh))!=null&&o.has(r))throw new Error("Cannot use more than one PDFWorker per port.");(v(ai,oh)||Y(ai,oh,new WeakMap)).set(r,this),this._initializeFromPort(r);return}this._initialize()}get promise(){return oa?Promise.all([tc.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Gw("main","worker",t),this._messageHandler.on("ready",function(){}),J(this,_g,KA).call(this)}_initialize(){if(Gc.isWorkerDisabled||v(ai,wg,HA)){this._setupFakeWorker();return}let{workerSrc:t}=ai;try{Gc.isSameOrigin(window.location.href,t)||(t=Gc.createCDNWrapper(new URL(t,window.location).href));const r=new Worker(t,{type:"module"}),n=new Gw("main","worker",r),o=()=>{a.abort(),n.destroy(),r.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;r.addEventListener("error",()=>{this._webWorker||o()},{signal:a.signal}),n.on("test",s=>{if(a.abort(),this.destroyed||!s){o();return}this._messageHandler=n,this._port=r,this._webWorker=r,J(this,_g,KA).call(this)}),n.on("ready",s=>{if(a.abort(),this.destroyed){o();return}try{i()}catch{this._setupFakeWorker()}});const i=()=>{const s=new Uint8Array;n.send("test",s,[s.buffer])};i();return}catch{xT("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Gc.isWorkerDisabled||(Dt("Setting up fake worker."),Gc.isWorkerDisabled=!0),ai._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const r=new m8e;this._port=r;const n=`fake${Gc.fakeWorkerId++}`,o=new Gw(n+"_worker",n,r);t.setup(o,r),this._messageHandler=new Gw(n,n+"_worker",r),J(this,_g,KA).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(t=v(ai,oh))==null||t.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){var n;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const r=(n=v(this,oh))==null?void 0:n.get(t.port);if(r){if(r._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return r}return new ai(t)}static get workerSrc(){if(kc.workerSrc)return kc.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ar(this,"_setupFakeWorkerGlobal",(async()=>v(this,wg,HA)?v(this,wg,HA):(await import(this.workerSrc)).WorkerMessageHandler)())}};oh=new WeakMap,_g=new WeakSet,KA=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},wg=new WeakSet,HA=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},ee(ai,wg),ee(ai,oh);let Xm=ai;class g8e{constructor(t,r,n,o,a){ee(this,ah);ee(this,ul,new Map);ee(this,uc,new Map);ee(this,xg,new Map);ee(this,jg,new Map);ee(this,dc,null);this.messageHandler=t,this.loadingTask=r,this.commonObjs=new sG,this.fontLoader=new p6e({ownerDocument:o.ownerDocument,styleElement:o.styleElement}),this.loadingParams=o.loadingParams,this._params=o,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()}get annotationStorage(){return ar(this,"annotationStorage",new oR)}getRenderingIntent(t,r=Ru.ENABLE,n=null,o=!1){let a=zi.DISPLAY,i=nR;switch(t){case"any":a=zi.ANY;break;case"display":break;case"print":a=zi.PRINT;break;default:Dt(`getRenderingIntent - invalid intent: ${t}`)}switch(r){case Ru.DISABLE:a+=zi.ANNOTATIONS_DISABLE;break;case Ru.ENABLE:break;case Ru.ENABLE_FORMS:a+=zi.ANNOTATIONS_FORMS;break;case Ru.ENABLE_STORAGE:a+=zi.ANNOTATIONS_STORAGE,i=(a&zi.PRINT&&n instanceof Fk?n:this.annotationStorage).serializable;break;default:Dt(`getRenderingIntent - invalid annotationMode: ${r}`)}return o&&(a+=zi.OPLIST),{renderingIntent:a,cacheKey:`${a}_${i.hash}`,annotationStorageSerializable:i}}destroy(){var n;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(n=v(this,dc))==null||n.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const o of v(this,uc).values())t.push(o._destroy());v(this,uc).clear(),v(this,xg).clear(),v(this,jg).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const r=this.messageHandler.sendWithPromise("Terminate",null);return t.push(r),Promise.all(t).then(()=>{var o;this.commonObjs.clear(),this.fontLoader.clear(),v(this,ul).clear(),this.filterFactory.destroy(),RT.cleanup(),(o=this._networkStream)==null||o.cancelAllRequests(new jf("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:r}=this;t.on("GetReader",(n,o)=>{to(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},o.onPull=()=>{this._fullReader.read().then(function({value:a,done:i}){if(i){o.close();return}to(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),o.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{o.error(a)})},o.onCancel=a=>{this._fullReader.cancel(a),o.ready.catch(i=>{if(!this.destroyed)throw i})}}),t.on("ReaderHeadersReady",n=>{const o=Promise.withResolvers(),a=this._fullReader;return a.headersReady.then(()=>{var i;(!a.isStreamingSupported||!a.isRangeSupported)&&(this._lastProgress&&((i=r.onProgress)==null||i.call(r,this._lastProgress)),a.onProgress=s=>{var c;(c=r.onProgress)==null||c.call(r,{loaded:s.loaded,total:s.total})}),o.resolve({isStreamingSupported:a.isStreamingSupported,isRangeSupported:a.isRangeSupported,contentLength:a.contentLength})},o.reject),o.promise}),t.on("GetRangeReader",(n,o)=>{to(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const a=this._networkStream.getRangeReader(n.begin,n.end);if(!a){o.close();return}o.onPull=()=>{a.read().then(function({value:i,done:s}){if(s){o.close();return}to(i instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),o.enqueue(new Uint8Array(i),1,[i])}).catch(i=>{o.error(i)})},o.onCancel=i=>{a.cancel(i),o.ready.catch(s=>{if(!this.destroyed)throw s})}}),t.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,r._capability.resolve(new h8e(n,this))}),t.on("DocException",function(n){let o;switch(n.name){case"PasswordException":o=new KN(n.message,n.code);break;case"InvalidPDFException":o=new Pk(n.message);break;case"MissingPDFException":o=new xf(n.message);break;case"UnexpectedResponseException":o=new jT(n.message,n.status);break;case"UnknownErrorException":o=new HN(n.message,n.details);break;default:Er("DocException - expected a valid Error.")}r._capability.reject(o)}),t.on("PasswordRequest",n=>{if(Y(this,dc,Promise.withResolvers()),r.onPassword){const o=a=>{a instanceof Error?v(this,dc).reject(a):v(this,dc).resolve({password:a})};try{r.onPassword(o,n.code)}catch(a){v(this,dc).reject(a)}}else v(this,dc).reject(new KN(n.message,n.code));return v(this,dc).promise}),t.on("DataLoaded",n=>{var o;(o=r.onProgress)==null||o.call(r,{loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),t.on("StartRenderPage",n=>{if(this.destroyed)return;v(this,uc).get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),t.on("commonobj",([n,o,a])=>{var i;if(this.destroyed||this.commonObjs.has(n))return null;switch(o){case"Font":const{disableFontFace:s,fontExtraProperties:c,pdfBug:l}=this._params;if("error"in a){const m=a.error;Dt(`Error during font loading: ${m}`),this.commonObjs.resolve(n,m);break}const u=l&&((i=globalThis.FontInspector)!=null&&i.enabled)?(m,g)=>globalThis.FontInspector.fontAdded(m,g):null,h=new m6e(a,{disableFontFace:s,inspectFont:u});this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:n})).finally(()=>{!c&&h.data&&(h.data=null),this.commonObjs.resolve(n,h)});break;case"CopyLocalImage":const{imageRef:p}=a;to(p,"The imageRef must be defined.");for(const m of v(this,uc).values())for(const[,g]of m.objs)if((g==null?void 0:g.ref)===p)return g.dataLen?(this.commonObjs.resolve(n,structuredClone(g)),g.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error(`Got unknown common object type ${o}`)}return null}),t.on("obj",([n,o,a,i])=>{var c;if(this.destroyed)return;const s=v(this,uc).get(o);if(!s.objs.has(n)){if(s._intentStates.size===0){(c=i==null?void 0:i.bitmap)==null||c.close();return}switch(a){case"Image":s.objs.resolve(n,i),(i==null?void 0:i.dataLen)>VKe&&(s._maybeCleanupAfterRender=!0);break;case"Pattern":s.objs.resolve(n,i);break;default:throw new Error(`Got unknown object type ${a}`)}}}),t.on("DocProgress",n=>{var o;this.destroyed||(o=r.onProgress)==null||o.call(r,{loaded:n.loaded,total:n.total})}),t.on("FetchBuiltInCMap",n=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(n):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",n=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(n):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var n;this.annotationStorage.size<=0&&Dt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:r}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((n=this._fullReader)==null?void 0:n.filename)??null},r).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const r=t-1,n=v(this,xg).get(r);if(n)return n;const o=this.messageHandler.sendWithPromise("GetPage",{pageIndex:r}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&v(this,jg).set(a.refStr,t);const i=new p8e(r,a,this,this._params.pdfBug);return v(this,uc).set(r,i),i});return v(this,xg).set(r,o),o}getPageIndex(t){return aG(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,r){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:r})}getFieldObjects(){return J(this,ah,Lx).call(this,"GetFieldObjects")}hasJSActions(){return J(this,ah,Lx).call(this,"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 J(this,ah,Lx).call(this,"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 J(this,ah,Lx).call(this,"GetOptionalContentConfig").then(r=>new U6e(r,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",r=v(this,ul).get(t);if(r)return r;const n=this.messageHandler.sendWithPromise(t,null).then(o=>{var a,i;return{info:o[0],metadata:o[1]?new I6e(o[1]):null,contentDispositionFilename:((a=this._fullReader)==null?void 0:a.filename)??null,contentLength:((i=this._fullReader)==null?void 0:i.contentLength)??null}});return v(this,ul).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(const r of v(this,uc).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),v(this,ul).clear(),this.filterFactory.destroy(!0),RT.cleanup()}}cachedPageNumber(t){if(!aG(t))return null;const r=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return v(this,jg).get(r)??null}}ul=new WeakMap,uc=new WeakMap,xg=new WeakMap,jg=new WeakMap,dc=new WeakMap,ah=new WeakSet,Lx=function(t,r=null){const n=v(this,ul).get(t);if(n)return n;const o=this.messageHandler.sendWithPromise(t,r);return v(this,ul).set(t,o),o};const $T=Symbol("INITIAL_DATA");class sG{constructor(){ee(this,W0);ee(this,ds,Object.create(null))}get(t,r=null){if(r){const o=J(this,W0,K$).call(this,t);return o.promise.then(()=>r(o.data)),null}const n=v(this,ds)[t];if(!n||n.data===$T)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){const r=v(this,ds)[t];return!!r&&r.data!==$T}resolve(t,r=null){const n=J(this,W0,K$).call(this,t);n.data=r,n.resolve()}clear(){var t;for(const r in v(this,ds)){const{data:n}=v(this,ds)[r];(t=n==null?void 0:n.bitmap)==null||t.close()}Y(this,ds,Object.create(null))}*[Symbol.iterator](){for(const t in v(this,ds)){const{data:r}=v(this,ds)[t];r!==$T&&(yield[t,r])}}}ds=new WeakMap,W0=new WeakSet,K$=function(t){var r;return(r=v(this,ds))[t]||(r[t]={...Promise.withResolvers(),data:$T})};class b8e{constructor(t){ee(this,td,null);Y(this,td,t),this.onContinue=null}get promise(){return v(this,td).capability.promise}cancel(t=0){v(this,td).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=v(this,td).operatorList;if(!t)return!1;const{annotationCanvasMap:r}=v(this,td);return t.form||t.canvas&&(r==null?void 0:r.size)>0}}td=new WeakMap;const sh=class sh{constructor({callback:t,params:r,objs:n,commonObjs:o,annotationCanvasMap:a,operatorList:i,pageIndex:s,canvasFactory:c,filterFactory:l,useRequestAnimationFrame:u=!1,pdfBug:h=!1,pageColors:p=null}){ee(this,rd,null);this.callback=t,this.params=r,this.objs=n,this.commonObjs=o,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=i,this._pageIndex=s,this.canvasFactory=c,this.filterFactory=l,this._pdfBug=h,this.pageColors=p,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=u===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new b8e(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=r.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:r}){var s,c;if(this.cancelled)return;if(this._canvas){if(v(sh,ih).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.");v(sh,ih).add(this._canvas)}this._pdfBug&&((s=globalThis.StepperManager)!=null&&s.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:o,transform:a,background:i}=this.params;this.gfx=new Hm(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:r},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:o,transparency:t,background:i}),this.operatorListIdx=0,this.graphicsReady=!0,(c=this.graphicsReadyCallback)==null||c.call(this)}cancel(t=null,r=0){var n;this.running=!1,this.cancelled=!0,(n=this.gfx)==null||n.endDrawing(),v(this,rd)&&(window.cancelAnimationFrame(v(this,rd)),Y(this,rd,null)),v(sh,ih).delete(this._canvas),this.callback(t||new qN(`Rendering cancelled, page ${this._pageIndex+1}`,r))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.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?Y(this,rd,window.requestAnimationFrame(()=>{Y(this,rd,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(),v(sh,ih).delete(this._canvas),this.callback())))}};rd=new WeakMap,ih=new WeakMap,ee(sh,ih,new WeakSet);let pR=sh;const v8e="4.4.168",y8e="19fbc8998";function cG(e){return Math.floor(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,"0")}function qw(e){return Math.max(0,Math.min(255,255*e))}class lG{static CMYK_G([t,r,n,o]){return["G",1-Math.min(1,.3*t+.59*n+.11*r+o)]}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=qw(t),[t,t,t]}static G_HTML([t]){const r=cG(t);return`#${r}${r}${r}`}static RGB_G([t,r,n]){return["G",.3*t+.59*r+.11*n]}static RGB_rgb(t){return t.map(qw)}static RGB_HTML(t){return`#${t.map(cG).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,r,n,o]){return["RGB",1-Math.min(1,t+o),1-Math.min(1,n+o),1-Math.min(1,r+o)]}static CMYK_rgb([t,r,n,o]){return[qw(1-Math.min(1,t+o)),qw(1-Math.min(1,n+o)),qw(1-Math.min(1,r+o))]}static CMYK_HTML(t){const r=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(r)}static RGB_CMYK([t,r,n]){const o=1-t,a=1-r,i=1-n,s=Math.min(o,a,i);return["CMYK",o,a,i,s]}}class uG{static setupStorage(t,r,n,o,a){const i=o.getValue(r,{value:null});switch(n.name){case"textarea":if(i.value!==null&&(t.textContent=i.value),a==="print")break;t.addEventListener("input",s=>{o.setValue(r,{value:s.target.value})});break;case"input":if(n.attributes.type==="radio"||n.attributes.type==="checkbox"){if(i.value===n.attributes.xfaOn?t.setAttribute("checked",!0):i.value===n.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",s=>{o.setValue(r,{value:s.target.checked?s.target.getAttribute("xfaOn"):s.target.getAttribute("xfaOff")})})}else{if(i.value!==null&&t.setAttribute("value",i.value),a==="print")break;t.addEventListener("input",s=>{o.setValue(r,{value:s.target.value})})}break;case"select":if(i.value!==null){t.setAttribute("value",i.value);for(const s of n.children)s.attributes.value===i.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected}t.addEventListener("input",s=>{const c=s.target.options,l=c.selectedIndex===-1?"":c[c.selectedIndex].value;o.setValue(r,{value:l})});break}}static setAttributes({html:t,element:r,storage:n=null,intent:o,linkService:a}){const{attributes:i}=r,s=t instanceof HTMLAnchorElement;i.type==="radio"&&(i.name=`${i.name}-${o}`);for(const[c,l]of Object.entries(i))if(l!=null)switch(c){case"class":l.length&&t.setAttribute(c,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!s||c!=="href"&&c!=="newWindow")&&t.setAttribute(c,l)}s&&a.addLinkAttributes(t,i.href,i.newWindow),n&&i.dataId&&this.setupStorage(t,i.dataId,r,n)}static render(t){var h,p;const r=t.annotationStorage,n=t.linkService,o=t.xfaHtml,a=t.intent||"display",i=document.createElement(o.name);o.attributes&&this.setAttributes({html:i,element:o,intent:a,linkService:n});const s=a!=="richText",c=t.div;if(c.append(i),t.viewport){const m=`matrix(${t.viewport.transform.join(",")})`;c.style.transform=m}s&&c.setAttribute("class","xfaLayer xfaFont");const l=[];if(o.children.length===0){if(o.value){const m=document.createTextNode(o.value);i.append(m),s&&Yw.shouldBuildText(o.name)&&l.push(m)}return{textDivs:l}}const u=[[o,-1,i]];for(;u.length>0;){const[m,g,b]=u.at(-1);if(g+1===m.children.length){u.pop();continue}const _=m.children[++u.at(-1)[1]];if(_===null)continue;const{name:y}=_;if(y==="#text"){const O=document.createTextNode(_.value);l.push(O),b.append(O);continue}const x=(h=_==null?void 0:_.attributes)!=null&&h.xmlns?document.createElementNS(_.attributes.xmlns,y):document.createElement(y);if(b.append(x),_.attributes&&this.setAttributes({html:x,element:_,storage:r,intent:a,linkService:n}),((p=_.children)==null?void 0:p.length)>0)u.push([_,-1,x]);else if(_.value){const O=document.createTextNode(_.value);s&&Yw.shouldBuildText(y)&&l.push(O),x.append(O)}}for(const m of c.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))m.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const r=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=r,t.div.hidden=!1}}const Jw=1e3,_8e=9,Sf=new WeakSet;function Yc(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class w8e{static create(t){switch(t.data.annotationType){case eo.LINK:return new dG(t);case eo.TEXT:return new x8e(t);case eo.WIDGET:switch(t.data.fieldType){case"Tx":return new j8e(t);case"Btn":return t.data.radioButton?new fG(t):t.data.checkBox?new M8e(t):new S8e(t);case"Ch":return new P8e(t);case"Sig":return new O8e(t)}return new Pf(t);case eo.POPUP:return new mR(t);case eo.FREETEXT:return new hG(t);case eo.LINE:return new T8e(t);case eo.SQUARE:return new A8e(t);case eo.CIRCLE:return new C8e(t);case eo.POLYLINE:return new pG(t);case eo.CARET:return new I8e(t);case eo.INK:return new mG(t);case eo.POLYGON:return new D8e(t);case eo.HIGHLIGHT:return new z8e(t);case eo.UNDERLINE:return new U8e(t);case eo.SQUIGGLY:return new N8e(t);case eo.STRIKEOUT:return new R8e(t);case eo.STAMP:return new gG(t);case eo.FILEATTACHMENT:return new $8e(t);default:return new zn(t)}}}const y$=class y${constructor(t,{isRenderable:r=!1,ignoreBorder:n=!1,createQuadrilaterals:o=!1}={}){ee(this,k0);ee(this,ch,null);ee(this,Og,!1);ee(this,Mg,null);this.isRenderable=r,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,r&&(this.container=this._createContainer(n)),o&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:r,richText:n}){return!!(t!=null&&t.str||r!=null&&r.str||n!=null&&n.str)}get hasPopupData(){return y$._hasPopupData(this.data)}updateEdited(t){var n;if(!this.container)return;v(this,ch)||Y(this,ch,{rect:this.data.rect.slice(0)});const{rect:r}=t;r&&J(this,k0,H$).call(this,r),(n=v(this,Mg))==null||n.popup.updateEdited(t)}resetEdited(){var t;v(this,ch)&&(J(this,k0,H$).call(this,v(this,ch).rect),(t=v(this,Mg))==null||t.popup.resetEdited(),Y(this,ch,null))}_createContainer(t){const{data:r,parent:{page:n,viewport:o}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",r.id),this instanceof Pf||(a.tabIndex=Jw);const{style:i}=a;if(i.zIndex=this.parent.zIndex++,r.popupRef&&a.setAttribute("aria-haspopup","dialog"),r.alternativeText&&(a.title=r.alternativeText),r.noRotate&&a.classList.add("norotate"),!r.rect||this instanceof mR){const{rotation:b}=r;return!r.hasOwnCanvas&&b!==0&&this.setRotation(b,a),a}const{width:s,height:c}=Yc(r.rect);if(!t&&r.borderStyle.width>0){i.borderWidth=`${r.borderStyle.width}px`;const b=r.borderStyle.horizontalCornerRadius,_=r.borderStyle.verticalCornerRadius;if(b>0||_>0){const x=`calc(${b}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`;i.borderRadius=x}else if(this instanceof fG){const x=`calc(${s}px * var(--scale-factor)) / calc(${c}px * var(--scale-factor))`;i.borderRadius=x}switch(r.borderStyle.style){case Lw.SOLID:i.borderStyle="solid";break;case Lw.DASHED:i.borderStyle="dashed";break;case Lw.BEVELED:Dt("Unimplemented border style: beveled");break;case Lw.INSET:Dt("Unimplemented border style: inset");break;case Lw.UNDERLINE:i.borderBottomStyle="solid";break}const y=r.borderColor||null;y?(Y(this,Og,!0),i.borderColor=rt.makeHexColor(y[0]|0,y[1]|0,y[2]|0)):i.borderWidth=0}const l=rt.normalizeRect([r.rect[0],n.view[3]-r.rect[1]+n.view[1],r.rect[2],n.view[3]-r.rect[3]+n.view[1]]),{pageWidth:u,pageHeight:h,pageX:p,pageY:m}=o.rawDims;i.left=`${100*(l[0]-p)/u}%`,i.top=`${100*(l[1]-m)/h}%`;const{rotation:g}=r;return r.hasOwnCanvas||g===0?(i.width=`${100*s/u}%`,i.height=`${100*c/h}%`):this.setRotation(g,a),a}setRotation(t,r=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:o}=this.parent.viewport.rawDims,{width:a,height:i}=Yc(this.data.rect);let s,c;t%180===0?(s=100*a/n,c=100*i/o):(s=100*i/n,c=100*a/o),r.style.width=`${s}%`,r.style.height=`${c}%`,r.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(r,n,o)=>{const a=o.detail[r],i=a[0],s=a.slice(1);o.target.style[n]=lG[`${i}_HTML`](s),this.annotationStorage.setValue(this.data.id,{[n]:lG[`${i}_rgb`](s)})};return ar(this,"_commonActions",{display:r=>{const{display:n}=r.detail,o=n%2===1;this.container.style.visibility=o?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:o,noPrint:n===1||n===2})},print:r=>{this.annotationStorage.setValue(this.data.id,{noPrint:!r.detail.print})},hidden:r=>{const{hidden:n}=r.detail;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:n,noView:n})},focus:r=>{setTimeout(()=>r.target.focus({preventScroll:!1}),0)},userName:r=>{r.target.title=r.detail.userName},readonly:r=>{r.target.disabled=r.detail.readonly},required:r=>{this._setRequired(r.target,r.detail.required)},bgColor:r=>{t("bgColor","backgroundColor",r)},fillColor:r=>{t("fillColor","backgroundColor",r)},fgColor:r=>{t("fgColor","color",r)},textColor:r=>{t("textColor","color",r)},borderColor:r=>{t("borderColor","borderColor",r)},strokeColor:r=>{t("strokeColor","borderColor",r)},rotation:r=>{const n=r.detail.rotation;this.setRotation(n),this.annotationStorage.setValue(this.data.id,{rotation:n})}})}_dispatchEventFromSandbox(t,r){const n=this._commonActions;for(const o of Object.keys(r.detail)){const a=t[o]||n[o];a==null||a(r)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const r=this.annotationStorage.getRawValue(this.data.id);if(!r)return;const n=this._commonActions;for(const[o,a]of Object.entries(r)){const i=n[o];if(i){const s={detail:{[o]:a},target:t};i(s),delete r[o]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[r,n,o,a]=this.data.rect.map(b=>Math.fround(b));if(t.length===8){const[b,_,y,x]=t.subarray(2,6);if(o===b&&a===_&&r===y&&n===x)return}const{style:i}=this.container;let s;if(v(this,Og)){const{borderColor:b,borderWidth:_}=i;i.borderWidth=0,s=["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="${b}" stroke-width="${_}">`],this.container.classList.add("hasBorder")}const c=o-r,l=a-n,{svgFactory:u}=this,h=u.createElement("svg");h.classList.add("quadrilateralsContainer"),h.setAttribute("width",0),h.setAttribute("height",0);const p=u.createElement("defs");h.append(p);const m=u.createElement("clipPath"),g=`clippath_${this.data.id}`;m.setAttribute("id",g),m.setAttribute("clipPathUnits","objectBoundingBox"),p.append(m);for(let b=2,_=t.length;b<_;b+=8){const y=t[b],x=t[b+1],O=t[b+2],S=t[b+3],j=u.createElement("rect"),P=(O-r)/c,I=(a-x)/l,M=(y-O)/c,E=(x-S)/l;j.setAttribute("x",P),j.setAttribute("y",I),j.setAttribute("width",M),j.setAttribute("height",E),m.append(j),s==null||s.push(`<rect vector-effect="non-scaling-stroke" x="${P}" y="${I}" width="${M}" height="${E}"/>`)}v(this,Og)&&(s.push("</g></svg>')"),i.backgroundImage=s.join("")),this.container.append(h),this.container.style.clipPath=`url(#${g})`}_createPopup(){const{container:t,data:r}=this;t.setAttribute("aria-haspopup","dialog");const n=Y(this,Mg,new mR({data:{color:r.color,titleObj:r.titleObj,modificationDate:r.modificationDate,contentsObj:r.contentsObj,richText:r.richText,parentRect:r.rect,borderStyle:0,id:`popup_${r.id}`,rotation:r.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(n.render())}render(){Er("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,r=null){const n=[];if(this._fieldObjects){const o=this._fieldObjects[t];if(o)for(const{page:a,id:i,exportValues:s}of o){if(a===-1||i===r)continue;const c=typeof s=="string"?s:null,l=document.querySelector(`[data-element-id="${i}"]`);if(l&&!Sf.has(l)){Dt(`_getElementsByName - element not allowed: ${i}`);continue}n.push({id:i,exportValue:c,domElement:l})}return n}for(const o of document.getElementsByName(t)){const{exportValue:a}=o,i=o.getAttribute("data-element-id");i!==r&&Sf.has(o)&&n.push({id:i,exportValue:a,domElement:o})}return n}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const r of t)r.classList.add("highlightArea");else t.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:r}}=this;this.container.addEventListener("dblclick",()=>{var n;(n=this.linkService.eventBus)==null||n.dispatch("switchannotationeditormode",{source:this,mode:t,editId:r})})}};ch=new WeakMap,Og=new WeakMap,Mg=new WeakMap,k0=new WeakSet,H$=function(t){const{container:{style:r},data:{rect:n,rotation:o},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:i,pageX:s,pageY:c}}}}=this;n==null||n.splice(0,4,...t);const{width:l,height:u}=Yc(t);r.left=`${100*(t[0]-s)/a}%`,r.top=`${100*(i-t[3]+c)/i}%`,o===0?(r.width=`${100*l/a}%`,r.height=`${100*u/i}%`):this.setRotation(o)};let zn=y$;class dG extends zn{constructor(r,n=null){super(r,{isRenderable:!0,ignoreBorder:!!(n!=null&&n.ignoreBorder),createQuadrilaterals:!0});ee(this,ii);this.isTooltipOnly=r.data.isTooltipOnly}render(){const{data:r,linkService:n}=this,o=document.createElement("a");o.setAttribute("data-element-id",r.id);let a=!1;return r.url?(n.addLinkAttributes(o,r.url,r.newWindow),a=!0):r.action?(this._bindNamedAction(o,r.action),a=!0):r.attachment?(J(this,ii,RJ).call(this,o,r.attachment,r.attachmentDest),a=!0):r.setOCGState?(J(this,ii,$J).call(this,o,r.setOCGState),a=!0):r.dest?(this._bindLink(o,r.dest),a=!0):(r.actions&&(r.actions.Action||r.actions["Mouse Up"]||r.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(o,r),a=!0),r.resetForm?(this._bindResetFormAction(o,r.resetForm),a=!0):this.isTooltipOnly&&!a&&(this._bindLink(o,""),a=!0)),this.container.classList.add("linkAnnotation"),a&&this.container.append(o),this.container}_bindLink(r,n){r.href=this.linkService.getDestinationHash(n),r.onclick=()=>(n&&this.linkService.goToDestination(n),!1),(n||n==="")&&J(this,ii,Uh).call(this)}_bindNamedAction(r,n){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(n),!1),J(this,ii,Uh).call(this)}_bindJSAction(r,n){r.href=this.linkService.getAnchorUrl("");const o=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of Object.keys(n.actions)){const i=o.get(a);i&&(r[i]=()=>{var s;return(s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n.id,name:a}}),!1})}r.onclick||(r.onclick=()=>!1),J(this,ii,Uh).call(this)}_bindResetFormAction(r,n){const o=r.onclick;if(o||(r.href=this.linkService.getAnchorUrl("")),J(this,ii,Uh).call(this),!this._fieldObjects){Dt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),o||(r.onclick=()=>!1);return}r.onclick=()=>{var h;o==null||o();const{fields:a,refs:i,include:s}=n,c=[];if(a.length!==0||i.length!==0){const p=new Set(i);for(const m of a){const g=this._fieldObjects[m]||[];for(const{id:b}of g)p.add(b)}for(const m of Object.values(this._fieldObjects))for(const g of m)p.has(g.id)===s&&c.push(g)}else for(const p of Object.values(this._fieldObjects))c.push(...p);const l=this.annotationStorage,u=[];for(const p of c){const{id:m}=p;switch(u.push(m),p.type){case"text":{const b=p.defaultValue||"";l.setValue(m,{value:b});break}case"checkbox":case"radiobutton":{const b=p.defaultValue===p.exportValues;l.setValue(m,{value:b});break}case"combobox":case"listbox":{const b=p.defaultValue||"";l.setValue(m,{value:b});break}default:continue}const g=document.querySelector(`[data-element-id="${m}"]`);if(g){if(!Sf.has(g)){Dt(`_bindResetFormAction - element not allowed: ${m}`);continue}}else continue;g.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((h=this.linkService.eventBus)==null||h.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:u,name:"ResetForm"}})),!1}}}ii=new WeakSet,Uh=function(){this.container.setAttribute("data-internal-link","")},RJ=function(r,n,o=null){r.href=this.linkService.getAnchorUrl(""),n.description&&(r.title=n.description),r.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(n.content,n.filename,o),!1},J(this,ii,Uh).call(this)},$J=function(r,n){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(n),!1),J(this,ii,Uh).call(this)};class x8e extends zn{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Pf extends zn{render(){return this.container}showElementAndHideCanvas(t){var r;this.data.hasOwnCanvas&&(((r=t.previousSibling)==null?void 0:r.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Na.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,r,n,o,a){n.includes("mouse")?t.addEventListener(n,i=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:o,value:a(i),shift:i.shiftKey,modifier:this._getKeyModifier(i)}})}):t.addEventListener(n,i=>{var s;if(n==="blur"){if(!r.focused||!i.relatedTarget)return;r.focused=!1}else if(n==="focus"){if(r.focused)return;r.focused=!0}a&&((s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:o,value:a(i)}}))})}_setEventListeners(t,r,n,o){var a,i,s;for(const[c,l]of n)(l==="Action"||(a=this.data.actions)!=null&&a[l])&&((l==="Focus"||l==="Blur")&&(r||(r={focused:!1})),this._setEventListener(t,r,c,l,o),l==="Focus"&&!((i=this.data.actions)!=null&&i.Blur)?this._setEventListener(t,r,"blur","Blur",null):l==="Blur"&&!((s=this.data.actions)!=null&&s.Focus)&&this._setEventListener(t,r,"focus","Focus",null))}_setBackgroundColor(t){const r=this.data.backgroundColor||null;t.style.backgroundColor=r===null?"transparent":rt.makeHexColor(r[0],r[1],r[2])}_setTextStyle(t){const r=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,o=this.data.defaultAppearanceData.fontSize||_8e,a=t.style;let i;const s=2,c=l=>Math.round(10*l)/10;if(this.data.multiLine){const l=Math.abs(this.data.rect[3]-this.data.rect[1]-s),u=Math.round(l/(LN*o))||1,h=l/u;i=Math.min(o,c(h/LN))}else{const l=Math.abs(this.data.rect[3]-this.data.rect[1]-s);i=Math.min(o,c(l/LN))}a.fontSize=`calc(${i}px * var(--scale-factor))`,a.color=rt.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(a.textAlign=r[this.data.textAlignment])}_setRequired(t,r){r?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",r)}}class j8e extends Pf{constructor(t){const r=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:r})}setPropertyOnSiblings(t,r,n,o){const a=this.annotationStorage;for(const i of this._getElementsByName(t.name,t.id))i.domElement&&(i.domElement[r]=n),a.setValue(i.id,{[o]:n})}render(){var o,a;const t=this.annotationStorage,r=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const i=t.getValue(r,{value:this.data.fieldValue});let s=i.value||"";const c=t.getValue(r,{charLimit:this.data.maxLen}).charLimit;c&&s.length>c&&(s=s.slice(0,c));let l=i.formattedValue||((o=this.data.textContent)==null?void 0:o.join(`