@pksep/yui 0.1.165 → 0.1.166

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.
@@ -1323,7 +1323,7 @@ function print() { __p += __j.call(arguments, '') }
1323
1323
  `),position:p,pageIndex:Y-1,rect:a.slice(0),rotation:d,annotationElementId:m,id:m,deleted:!1,popupRef:u,comment:(Z==null?void 0:Z.str)||null,richText:b,creationDate:w,modificationDate:G}}const A=await super.deserialize(I,e,t);return V(A,ni,I.fontSize),A.color=wg.makeHexColor(...I.color),V(A,Ai,f(n=PI,Hl,JR).call(n,I.value)),A._initialData=i,I.comment&&A.setCommentData(I),A}serialize(I=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=xI._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),t=Object.assign(super.serialize(I),{color:e,fontSize:c(this,ni),value:f(this,JC,mT).call(this)});return this.addComment(t),I?(t.isCopy=!0,t):this.annotationElementId&&!f(this,JC,uT).call(this,t)?null:(t.id=this.annotationElementId,t)}renderAnnotationElement(I){const e=super.renderAnnotationElement(I);if(!e)return null;const{style:t}=e;t.fontSize=`calc(${c(this,ni)}px * var(--total-scale-factor))`,t.color=this.color,e.replaceChildren();for(const i of c(this,Ai).split(`
1324
1324
  `)){const A=document.createElement("div");A.append(i?document.createTextNode(i):document.createElement("br")),e.append(A)}return I.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:c(this,Ai)}}),e}resetAnnotationElement(I){super.resetAnnotationElement(I),I.resetEdited()}};Ai=new WeakMap,xb=new WeakMap,Ld=new WeakMap,ni=new WeakMap,JC=new WeakSet,dT=function(I){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-c(this,ni))*this.parentScale),V(this,ni,i),f(this,JC,Op).call(this)},t=c(this,ni);this.addCommands({cmd:e.bind(this,I),undo:e.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:oI.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},cT=function(I){const e=i=>{this.color=i,this.onUpdatedColor()},t=this.color;this.addCommands({cmd:e.bind(this,I),undo:e.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:oI.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},rT=function(){var t;const I=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)(e==null?void 0:e.nodeType)===Node.TEXT_NODE&&i.nodeName==="BR"||(I.push(f(t=PI,Hl,Qp).call(t,i)),e=i);return I.join(`
1325
1325
  `)},Op=function(){const[I,e]=this.parentDimensions;let t;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{const{currentLayer:i,div:A}=this,n=A.style.display,l=A.classList.contains("hidden");A.classList.remove("hidden"),A.style.display="hidden",i.div.append(this.div),t=A.getBoundingClientRect(),A.remove(),A.style.display=n,A.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=t.width/I,this.height=t.height/e):(this.width=t.height/I,this.height=t.width/e),this.fixAndSetPosition()},Hl=new WeakSet,Qp=function(I){return(I.nodeType===Node.TEXT_NODE?I.nodeValue:I.innerText).replaceAll(yw,"")},Up=function(){if(this.editorDiv.replaceChildren(),!!c(this,Ai))for(const I of c(this,Ai).split(`
1326
- `)){const e=document.createElement("div");e.append(I?document.createTextNode(I):document.createElement("br")),this.editorDiv.append(e)}},mT=function(){return c(this,Ai).replaceAll(" "," ")},JR=function(I){return I.replaceAll(" "," ")},uT=function(I){const{value:e,fontSize:t,color:i,pageIndex:A}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||I.value!==e||I.fontSize!==t||I.color.some((n,l)=>n!==i[l])||I.pageIndex!==A},X(PI,Hl),sg(PI,"_freeTextDefaultContent",""),sg(PI,"_internalPadding",0),sg(PI,"_defaultColor",null),sg(PI,"_defaultFontSize",10),sg(PI,"_type","freetext"),sg(PI,"_editorType",Tg.FREETEXT);let PY=PI;class Zg{toSVGPath(){kI("Abstract method `toSVGPath` must be implemented.")}get box(){kI("Abstract getter `box` must be implemented.")}serialize(g,I){kI("Abstract method `serialize` must be implemented.")}static _rescale(g,I,e,t,i,A){A||(A=new Float32Array(g.length));for(let n=0,l=g.length;n<l;n+=2)A[n]=I+g[n]*t,A[n+1]=e+g[n+1]*i;return A}static _rescaleAndSwap(g,I,e,t,i,A){A||(A=new Float32Array(g.length));for(let n=0,l=g.length;n<l;n+=2)A[n]=I+g[n+1]*t,A[n+1]=e+g[n]*i;return A}static _translate(g,I,e,t){t||(t=new Float32Array(g.length));for(let i=0,A=g.length;i<A;i+=2)t[i]=I+g[i],t[i+1]=e+g[i+1];return t}static svgRound(g){return Math.round(g*1e4)}static _normalizePoint(g,I,e,t,i){switch(i){case 90:return[1-I/e,g/t];case 180:return[1-g/e,1-I/t];case 270:return[I/e,1-g/t];default:return[g/e,I/t]}}static _normalizePagePoint(g,I,e){switch(e){case 90:return[1-I,g];case 180:return[1-g,1-I];case 270:return[I,1-g];default:return[g,I]}}static createBezierPoints(g,I,e,t,i,A){return[(g+5*e)/6,(I+5*t)/6,(5*e+i)/6,(5*t+A)/6,(e+i)/2,(t+A)/2]}}sg(Zg,"PRECISION",1e-4);const fl=class fl{constructor({x:g,y:I},e,t,i,A,n=0){X(this,OC);X(this,li);X(this,MA,[]);X(this,Hm);X(this,fm);X(this,Yn,[]);X(this,CI,new Float32Array(18));X(this,Td);X(this,vd);X(this,Ob);X(this,Qb);X(this,Dm);X(this,Sm);X(this,Bo,[]);V(this,li,e),V(this,Sm,i*t),V(this,fm,A),c(this,CI).set([NaN,NaN,NaN,NaN,g,I],6),V(this,Hm,n),V(this,Qb,c(fl,Ub)*t),V(this,Ob,c(fl,fB)*t),V(this,Dm,t),c(this,Bo).push(g,I)}isEmpty(){return isNaN(c(this,CI)[8])}add({x:g,y:I}){var J;V(this,Td,g),V(this,vd,I);const[e,t,i,A]=c(this,li);let[n,l,s,a]=c(this,CI).subarray(8,12);const d=g-s,m=I-a,u=Math.hypot(d,m);if(u<c(this,Ob))return!1;const b=u-c(this,Qb),Z=b/u,w=Z*d,G=Z*m;let B=n,p=l;n=s,l=a,s+=w,a+=G,(J=c(this,Bo))==null||J.push(g,I);const Y=-G/b,y=w/b,R=Y*c(this,Sm),M=y*c(this,Sm);return c(this,CI).set(c(this,CI).subarray(2,8),0),c(this,CI).set([s+R,a+M],4),c(this,CI).set(c(this,CI).subarray(14,18),12),c(this,CI).set([s-R,a-M],16),isNaN(c(this,CI)[6])?(c(this,Yn).length===0&&(c(this,CI).set([n+R,l+M],2),c(this,Yn).push(NaN,NaN,NaN,NaN,(n+R-e)/i,(l+M-t)/A),c(this,CI).set([n-R,l-M],14),c(this,MA).push(NaN,NaN,NaN,NaN,(n-R-e)/i,(l-M-t)/A)),c(this,CI).set([B,p,n,l,s,a],6),!this.isEmpty()):(c(this,CI).set([B,p,n,l,s,a],6),Math.abs(Math.atan2(p-l,B-n)-Math.atan2(G,w))<Math.PI/2?([n,l,s,a]=c(this,CI).subarray(2,6),c(this,Yn).push(NaN,NaN,NaN,NaN,((n+s)/2-e)/i,((l+a)/2-t)/A),[n,l,B,p]=c(this,CI).subarray(14,18),c(this,MA).push(NaN,NaN,NaN,NaN,((B+n)/2-e)/i,((p+l)/2-t)/A),!0):([B,p,n,l,s,a]=c(this,CI).subarray(0,6),c(this,Yn).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+s)/6-e)/i,((5*l+a)/6-t)/A,((n+s)/2-e)/i,((l+a)/2-t)/A),[s,a,n,l,B,p]=c(this,CI).subarray(12,18),c(this,MA).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+s)/6-e)/i,((5*l+a)/6-t)/A,((n+s)/2-e)/i,((l+a)/2-t)/A),!0))}toSVGPath(){if(this.isEmpty())return"";const g=c(this,Yn),I=c(this,MA);if(isNaN(c(this,CI)[6])&&!this.isEmpty())return f(this,OC,hT).call(this);const e=[];e.push(`M${g[4]} ${g[5]}`);for(let t=6;t<g.length;t+=6)isNaN(g[t])?e.push(`L${g[t+4]} ${g[t+5]}`):e.push(`C${g[t]} ${g[t+1]} ${g[t+2]} ${g[t+3]} ${g[t+4]} ${g[t+5]}`);f(this,OC,ZT).call(this,e);for(let t=I.length-6;t>=6;t-=6)isNaN(I[t])?e.push(`L${I[t+4]} ${I[t+5]}`):e.push(`C${I[t]} ${I[t+1]} ${I[t+2]} ${I[t+3]} ${I[t+4]} ${I[t+5]}`);return f(this,OC,bT).call(this,e),e.join(" ")}newFreeDrawOutline(g,I,e,t,i,A){return new PS(g,I,e,t,i,A)}getOutlines(){var d;const g=c(this,Yn),I=c(this,MA),e=c(this,CI),[t,i,A,n]=c(this,li),l=new Float32Array((((d=c(this,Bo))==null?void 0:d.length)??0)+2);for(let m=0,u=l.length-2;m<u;m+=2)l[m]=(c(this,Bo)[m]-t)/A,l[m+1]=(c(this,Bo)[m+1]-i)/n;if(l[l.length-2]=(c(this,Td)-t)/A,l[l.length-1]=(c(this,vd)-i)/n,isNaN(e[6])&&!this.isEmpty())return f(this,OC,GT).call(this,l);const s=new Float32Array(c(this,Yn).length+24+c(this,MA).length);let a=g.length;for(let m=0;m<a;m+=2){if(isNaN(g[m])){s[m]=s[m+1]=NaN;continue}s[m]=g[m],s[m+1]=g[m+1]}a=f(this,OC,WT).call(this,s,a);for(let m=I.length-6;m>=6;m-=6)for(let u=0;u<6;u+=2){if(isNaN(I[m+u])){s[a]=s[a+1]=NaN,a+=2;continue}s[a]=I[m+u],s[a+1]=I[m+u+1],a+=2}return f(this,OC,wT).call(this,s,a),this.newFreeDrawOutline(s,l,c(this,li),c(this,Dm),c(this,Hm),c(this,fm))}};li=new WeakMap,MA=new WeakMap,Hm=new WeakMap,fm=new WeakMap,Yn=new WeakMap,CI=new WeakMap,Td=new WeakMap,vd=new WeakMap,Ob=new WeakMap,Qb=new WeakMap,Dm=new WeakMap,Sm=new WeakMap,Bo=new WeakMap,Ub=new WeakMap,HB=new WeakMap,fB=new WeakMap,OC=new WeakSet,FZ=function(){const g=c(this,CI).subarray(4,6),I=c(this,CI).subarray(16,18),[e,t,i,A]=c(this,li);return[(c(this,Td)+(g[0]-I[0])/2-e)/i,(c(this,vd)+(g[1]-I[1])/2-t)/A,(c(this,Td)+(I[0]-g[0])/2-e)/i,(c(this,vd)+(I[1]-g[1])/2-t)/A]},hT=function(){const[g,I,e,t]=c(this,li),[i,A,n,l]=f(this,OC,FZ).call(this);return`M${(c(this,CI)[2]-g)/e} ${(c(this,CI)[3]-I)/t} L${(c(this,CI)[4]-g)/e} ${(c(this,CI)[5]-I)/t} L${i} ${A} L${n} ${l} L${(c(this,CI)[16]-g)/e} ${(c(this,CI)[17]-I)/t} L${(c(this,CI)[14]-g)/e} ${(c(this,CI)[15]-I)/t} Z`},bT=function(g){const I=c(this,MA);g.push(`L${I[4]} ${I[5]} Z`)},ZT=function(g){const[I,e,t,i]=c(this,li),A=c(this,CI).subarray(4,6),n=c(this,CI).subarray(16,18),[l,s,a,d]=f(this,OC,FZ).call(this);g.push(`L${(A[0]-I)/t} ${(A[1]-e)/i} L${l} ${s} L${a} ${d} L${(n[0]-I)/t} ${(n[1]-e)/i}`)},GT=function(g){const I=c(this,CI),[e,t,i,A]=c(this,li),[n,l,s,a]=f(this,OC,FZ).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(I[2]-e)/i,(I[3]-t)/A,NaN,NaN,NaN,NaN,(I[4]-e)/i,(I[5]-t)/A,NaN,NaN,NaN,NaN,n,l,NaN,NaN,NaN,NaN,s,a,NaN,NaN,NaN,NaN,(I[16]-e)/i,(I[17]-t)/A,NaN,NaN,NaN,NaN,(I[14]-e)/i,(I[15]-t)/A],0),this.newFreeDrawOutline(d,g,c(this,li),c(this,Dm),c(this,Hm),c(this,fm))},wT=function(g,I){const e=c(this,MA);return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],I),I+=6},WT=function(g,I){const e=c(this,CI).subarray(4,6),t=c(this,CI).subarray(16,18),[i,A,n,l]=c(this,li),[s,a,d,m]=f(this,OC,FZ).call(this);return g.set([NaN,NaN,NaN,NaN,(e[0]-i)/n,(e[1]-A)/l,NaN,NaN,NaN,NaN,s,a,NaN,NaN,NaN,NaN,d,m,NaN,NaN,NaN,NaN,(t[0]-i)/n,(t[1]-A)/l],I),I+=24},X(fl,Ub,8),X(fl,HB,2),X(fl,fB,c(fl,Ub)+c(fl,HB));let Yw=fl;class PS extends Zg{constructor(I,e,t,i,A,n){super();X(this,DB);X(this,Km);X(this,jd,new Float32Array(4));X(this,Dl);X(this,Eb);X(this,si);X(this,Pb);X(this,NC);V(this,NC,I),V(this,si,e),V(this,Km,t),V(this,Pb,i),V(this,Dl,A),V(this,Eb,n),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],f(this,DB,BT).call(this,n);const[l,s,a,d]=c(this,jd);for(let m=0,u=I.length;m<u;m+=2)I[m]=(I[m]-l)/a,I[m+1]=(I[m+1]-s)/d;for(let m=0,u=e.length;m<u;m+=2)e[m]=(e[m]-l)/a,e[m+1]=(e[m+1]-s)/d}toSVGPath(){const I=[`M${c(this,NC)[4]} ${c(this,NC)[5]}`];for(let e=6,t=c(this,NC).length;e<t;e+=6){if(isNaN(c(this,NC)[e])){I.push(`L${c(this,NC)[e+4]} ${c(this,NC)[e+5]}`);continue}I.push(`C${c(this,NC)[e]} ${c(this,NC)[e+1]} ${c(this,NC)[e+2]} ${c(this,NC)[e+3]} ${c(this,NC)[e+4]} ${c(this,NC)[e+5]}`)}return I.push("Z"),I.join(" ")}serialize([I,e,t,i],A){const n=t-I,l=i-e;let s,a;switch(A){case 0:s=Zg._rescale(c(this,NC),I,i,n,-l),a=Zg._rescale(c(this,si),I,i,n,-l);break;case 90:s=Zg._rescaleAndSwap(c(this,NC),I,e,n,l),a=Zg._rescaleAndSwap(c(this,si),I,e,n,l);break;case 180:s=Zg._rescale(c(this,NC),t,e,-n,l),a=Zg._rescale(c(this,si),t,e,-n,l);break;case 270:s=Zg._rescaleAndSwap(c(this,NC),t,i,-n,-l),a=Zg._rescaleAndSwap(c(this,si),t,i,-n,-l);break}return{outline:Array.from(s),points:[Array.from(a)]}}get box(){return c(this,jd)}newOutliner(I,e,t,i,A,n=0){return new Yw(I,e,t,i,A,n)}getNewOutline(I,e){const[t,i,A,n]=c(this,jd),[l,s,a,d]=c(this,Km),m=A*a,u=n*d,b=t*a+l,Z=i*d+s,w=this.newOutliner({x:c(this,si)[0]*m+b,y:c(this,si)[1]*u+Z},c(this,Km),c(this,Pb),I,c(this,Eb),e??c(this,Dl));for(let G=2;G<c(this,si).length;G+=2)w.add({x:c(this,si)[G]*m+b,y:c(this,si)[G+1]*u+Z});return w.getOutlines()}}Km=new WeakMap,jd=new WeakMap,Dl=new WeakMap,Eb=new WeakMap,si=new WeakMap,Pb=new WeakMap,NC=new WeakMap,DB=new WeakSet,BT=function(I){const e=c(this,NC);let t=e[4],i=e[5];const A=[t,i,t,i];let n=t,l=i,s=t,a=i;const d=I?Math.max:Math.min,m=new Float32Array(4);for(let b=6,Z=e.length;b<Z;b+=6){const w=e[b+4],G=e[b+5];isNaN(e[b])?(wg.pointBoundingBox(w,G,A),l>G?(n=w,l=G):l===G&&(n=d(n,w)),a<G?(s=w,a=G):a===G&&(s=d(s,w))):(m[0]=m[1]=1/0,m[2]=m[3]=-1/0,wg.bezierBoundingBox(t,i,...e.slice(b,b+6),m),wg.rectBoundingBox(m[0],m[1],m[2],m[3],A),l>m[1]?(n=m[0],l=m[1]):l===m[1]&&(n=d(n,m[0])),a<m[3]?(s=m[2],a=m[3]):a===m[3]&&(s=d(s,m[2]))),t=w,i=G}const u=c(this,jd);u[0]=A[0]-c(this,Dl),u[1]=A[1]-c(this,Dl),u[2]=A[2]-A[0]+2*c(this,Dl),u[3]=A[3]-A[1]+2*c(this,Dl),this.firstPoint=[n,l],this.lastPoint=[s,a]};class _Y{constructor(g,I=0,e=0,t=!0){X(this,lt);X(this,_b);X(this,$b);X(this,qb);X(this,po,[]);X(this,RA,[]);const i=[1/0,1/0,-1/0,-1/0],n=10**-4;for(const{x:w,y:G,width:B,height:p}of g){const Y=Math.floor((w-I)/n)*n,y=Math.ceil((w+B+I)/n)*n,R=Math.floor((G-I)/n)*n,M=Math.ceil((G+p+I)/n)*n,D=[Y,R,M,!0],J=[y,R,M,!1];c(this,po).push(D,J),wg.rectBoundingBox(Y,R,y,M,i)}const l=i[2]-i[0]+2*e,s=i[3]-i[1]+2*e,a=i[0]-e,d=i[1]-e;let m=t?-1/0:1/0,u=1/0;const b=c(this,po).at(t?-1:-2),Z=[b[0],b[2]];for(const w of c(this,po)){const[G,B,p,Y]=w;!Y&&t?B<u?(u=B,m=G):B===u&&(m=Math.max(m,G)):Y&&!t&&(B<u?(u=B,m=G):B===u&&(m=Math.min(m,G))),w[0]=(G-a)/l,w[1]=(B-d)/s,w[2]=(p-d)/s}V(this,_b,new Float32Array([a,d,l,s])),V(this,$b,[m,u]),V(this,qb,Z)}getOutlines(){c(this,po).sort((I,e)=>I[0]-e[0]||I[1]-e[1]||I[2]-e[2]);const g=[];for(const I of c(this,po))I[3]?(g.push(...f(this,lt,LR).call(this,I)),f(this,lt,yT).call(this,I)):(f(this,lt,YT).call(this,I),g.push(...f(this,lt,LR).call(this,I)));return f(this,lt,pT).call(this,g)}}_b=new WeakMap,$b=new WeakMap,qb=new WeakMap,po=new WeakMap,RA=new WeakMap,lt=new WeakSet,pT=function(g){const I=[],e=new Set;for(const A of g){const[n,l,s]=A;I.push([n,l,A],[n,s,A])}I.sort((A,n)=>A[1]-n[1]||A[0]-n[0]);for(let A=0,n=I.length;A<n;A+=2){const l=I[A][2],s=I[A+1][2];l.push(s),s.push(l),e.add(l),e.add(s)}const t=[];let i;for(;e.size>0;){const A=e.values().next().value;let[n,l,s,a,d]=A;e.delete(A);let m=n,u=l;for(i=[n,s],t.push(i);;){let b;if(e.has(a))b=a;else if(e.has(d))b=d;else break;e.delete(b),[n,l,s,a,d]=b,m!==n&&(i.push(m,u,n,u===l?l:s),m=n),u=u===l?s:l}i.push(m,u)}return new bjg(t,c(this,_b),c(this,$b),c(this,qb))},Ep=function(g){const I=c(this,RA);let e=0,t=I.length-1;for(;e<=t;){const i=e+t>>1,A=I[i][0];if(A===g)return i;A<g?e=i+1:t=i-1}return t+1},yT=function([,g,I]){const e=f(this,lt,Ep).call(this,g);c(this,RA).splice(e,0,[g,I])},YT=function([,g,I]){const e=f(this,lt,Ep).call(this,g);for(let t=e;t<c(this,RA).length;t++){const[i,A]=c(this,RA)[t];if(i!==g)break;if(i===g&&A===I){c(this,RA).splice(t,1);return}}for(let t=e-1;t>=0;t--){const[i,A]=c(this,RA)[t];if(i!==g)break;if(i===g&&A===I){c(this,RA).splice(t,1);return}}},LR=function(g){const[I,e,t]=g,i=[[I,e,t]],A=f(this,lt,Ep).call(this,t);for(let n=0;n<A;n++){const[l,s]=c(this,RA)[n];for(let a=0,d=i.length;a<d;a++){const[,m,u]=i[a];if(!(s<=m||u<=l)){if(m>=l){if(u>s)i[a][1]=s;else{if(d===1)return[];i.splice(a,1),a--,d--}continue}i[a][2]=l,u>s&&i.push([I,s,u])}}}return i};class bjg extends Zg{constructor(I,e,t,i){super();X(this,gZ);X(this,km);V(this,km,I),V(this,gZ,e),this.firstPoint=t,this.lastPoint=i}toSVGPath(){const I=[];for(const e of c(this,km)){let[t,i]=e;I.push(`M${t} ${i}`);for(let A=2;A<e.length;A+=2){const n=e[A],l=e[A+1];n===t?(I.push(`V${l}`),i=l):l===i&&(I.push(`H${n}`),t=n)}I.push("Z")}return I.join(" ")}serialize([I,e,t,i],A){const n=[],l=t-I,s=i-e;for(const a of c(this,km)){const d=new Array(a.length);for(let m=0;m<a.length;m+=2)d[m]=I+a[m]*l,d[m+1]=i-a[m+1]*s;n.push(d)}return n}get box(){return c(this,gZ)}get classNamesForOutlining(){return["highlightOutline"]}}gZ=new WeakMap,km=new WeakMap;class $Y extends Yw{newFreeDrawOutline(g,I,e,t,i,A){return new Zjg(g,I,e,t,i,A)}}class Zjg extends PS{newOutliner(g,I,e,t,i,A=0){return new $Y(g,I,e,t,i,A)}}const uI=class uI extends xI{constructor(I){super({...I,name:"highlightEditor"});X(this,Eg);X(this,zm,null);X(this,IZ,0);X(this,Sl);X(this,xd,null);X(this,CZ,null);X(this,St,null);X(this,eZ,null);X(this,tZ,0);X(this,Od,null);X(this,oi,null);X(this,ai,null);X(this,we,!1);X(this,Fm,null);X(this,Jm,null);X(this,ze,null);X(this,Lm,"");X(this,Ei);X(this,iZ,"");this.color=I.color||uI._defaultColor,V(this,Ei,I.thickness||uI._defaultThickness),this.opacity=I.opacity||uI._defaultOpacity,V(this,Sl,I.boxes||null),V(this,iZ,I.methodOfCreation||""),V(this,Lm,I.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",I.highlightId>-1?(V(this,we,!0),f(this,Eg,Pp).call(this,I),f(this,Eg,Zc).call(this)):c(this,Sl)&&(V(this,zm,I.anchorNode),V(this,IZ,I.anchorOffset),V(this,eZ,I.focusNode),V(this,tZ,I.focusOffset),f(this,Eg,TR).call(this),f(this,Eg,Zc).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const I=uI.prototype;return Jg(this,"_keyboardManager",new mh([[["ArrowLeft","mac+ArrowLeft"],I._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],I._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],I._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],I._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:c(this,we)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:c(this,Ei),methodOfCreation:c(this,iZ)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(I){return{numberOfColors:I.get("color").size}}static initialize(I,e){var t;xI.initialize(I,e),uI._defaultColor||(uI._defaultColor=((t=e.highlightColors)==null?void 0:t.values().next().value)||"#fff066")}static updateDefaultParams(I,e){switch(I){case oI.HIGHLIGHT_COLOR:uI._defaultColor=e;break;case oI.HIGHLIGHT_THICKNESS:uI._defaultThickness=e;break}}translateInPage(I,e){}get toolbarPosition(){return c(this,Jm)}get commentButtonPosition(){return c(this,Fm)}updateParams(I,e){switch(I){case oI.HIGHLIGHT_COLOR:f(this,Eg,VT).call(this,e);break;case oI.HIGHLIGHT_THICKNESS:f(this,Eg,NT).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[oI.HIGHLIGHT_COLOR,uI._defaultColor],[oI.HIGHLIGHT_THICKNESS,uI._defaultThickness]]}get propertiesToUpdate(){return[[oI.HIGHLIGHT_COLOR,this.color||uI._defaultColor],[oI.HIGHLIGHT_THICKNESS,c(this,Ei)||uI._defaultThickness],[oI.HIGHLIGHT_FREE,c(this,we)]]}onUpdatedColor(){var I,e;(I=this.parent)==null||I.drawLayer.updateProperties(c(this,ai),{root:{fill:this.color,"fill-opacity":this.opacity}}),(e=c(this,CZ))==null||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",V(this,CZ,new Ww({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(f(this,Eg,$p).call(this))}getBaseTranslation(){return[0,0]}getRect(I,e){return super.getRect(I,e,f(this,Eg,$p).call(this))}onceAdded(I){this.annotationElementId||this.parent.addUndoableEditor(this),I&&this.div.focus()}remove(){f(this,Eg,vR).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,Eg,Zc).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?f(this,Eg,vR).call(this):I&&(f(this,Eg,Zc).call(this,I),e=!this.parent&&((t=this.div)==null?void 0:t.classList.contains("selectedEditor"))),super.setParent(I),this.show(this._isVisible),e&&this.select()}rotate(I){var i,A,n;const{drawLayer:e}=this.parent;let t;c(this,we)?(I=(I-this.rotation+360)%360,t=f(i=uI,Pi,bu).call(i,c(this,oi).box,I)):t=f(A=uI,Pi,bu).call(A,[this.x,this.y,this.width,this.height],I),e.updateProperties(c(this,ai),{bbox:t,root:{"data-main-rotation":I}}),e.updateProperties(c(this,ze),{bbox:f(n=uI,Pi,bu).call(n,c(this,St).box,I),root:{"data-main-rotation":I}})}render(){if(this.div)return this.div;const I=super.render();c(this,Lm)&&(I.setAttribute("aria-label",c(this,Lm)),I.setAttribute("role","mark")),c(this,we)?I.classList.add("free"):this.div.addEventListener("keydown",f(this,Eg,RT).bind(this),{signal:this._uiManager._signal});const e=V(this,Od,document.createElement("div"));return I.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=c(this,xd),this.setDims(),oS(this,c(this,Od),["pointerover","pointerleave"]),this.enableEditing(),I}pointerover(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{hovered:!0}})}pointerleave(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{hovered:!1}})}_moveCaret(I){switch(this.parent.unselect(this),I){case 0:case 2:f(this,Eg,_p).call(this,!0);break;case 1:case 3:f(this,Eg,_p).call(this,!1);break}}select(){var I;super.select(),c(this,ze)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var I;super.unselect(),c(this,ze)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{selected:!1}}),c(this,we)||f(this,Eg,_p).call(this,!1))}get _mustFixPosition(){return!c(this,we)}show(I=this._isVisible){super.show(I),this.parent&&(this.parent.drawLayer.updateProperties(c(this,ai),{rootClass:{hidden:!I}}),this.parent.drawLayer.updateProperties(c(this,ze),{rootClass:{hidden:!I}}))}static startHighlighting(I,e,{target:t,x:i,y:A}){const{x:n,y:l,width:s,height:a}=t.getBoundingClientRect(),d=new AbortController,m=I.combinedSignal(d),u=b=>{d.abort(),f(this,Pi,DT).call(this,I,b)};window.addEventListener("blur",u,{signal:m}),window.addEventListener("pointerup",u,{signal:m}),window.addEventListener("pointerdown",mC,{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",yi,{signal:m}),t.addEventListener("pointermove",f(this,Pi,fT).bind(this,I),{signal:m}),this._freeHighlight=new $Y({x:i,y:A},[n,l,s,a],I.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=I.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(I,e,t){var Z,w,G,B;let i=null;if(I instanceof US){const{data:{quadPoints:p,rect:Y,rotation:y,id:R,color:M,opacity:D,popupRef:J,richText:H,contentsObj:z,creationDate:T,modificationDate:P},parent:{page:{pageNumber:Ig}}}=I;i=I={annotationType:Tg.HIGHLIGHT,color:Array.from(M),opacity:D,quadPoints:p,boxes:null,pageIndex:Ig-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(z==null?void 0:z.str)||null,creationDate:T,modificationDate:P}}else if(I instanceof UY){const{data:{inkLists:p,rect:Y,rotation:y,id:R,color:M,borderStyle:{rawWidth:D},popupRef:J,richText:H,contentsObj:z,creationDate:T,modificationDate:P},parent:{page:{pageNumber:Ig}}}=I;i=I={annotationType:Tg.HIGHLIGHT,color:Array.from(M),thickness:D,inkLists:p,boxes:null,pageIndex:Ig-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(z==null?void 0:z.str)||null,creationDate:T,modificationDate:P}}const{color:A,quadPoints:n,inkLists:l,opacity:s}=I,a=await super.deserialize(I,e,t);a.color=wg.makeHexColor(...A),a.opacity=s||1,l&&V(a,Ei,I.thickness),a._initialData=i,I.comment&&a.setCommentData(I);const[d,m]=a.pageDimensions,[u,b]=a.pageTranslation;if(n){const p=V(a,Sl,[]);for(let Y=0;Y<n.length;Y+=8)p.push({x:(n[Y]-u)/d,y:1-(n[Y+1]-b)/m,width:(n[Y+2]-n[Y])/d,height:(n[Y+1]-n[Y+5])/m});f(Z=a,Eg,TR).call(Z),f(w=a,Eg,Zc).call(w),a.rotate(a.rotation)}else if(l){V(a,we,!0);const p=l[0],Y={x:p[0]-u,y:m-(p[1]-b)},y=new $Y(Y,[0,0,d,m],1,c(a,Ei)/2,!0,.001);for(let D=0,J=p.length;D<J;D+=2)Y.x=p[D]-u,Y.y=m-(p[D+1]-b),y.add(Y);const{id:R,clipPathId:M}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:a.color,"fill-opacity":a._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:y.toSVGPath()}},!0,!0);f(G=a,Eg,Pp).call(G,{highlightOutlines:y.getOutlines(),highlightId:R,clipPathId:M}),f(B=a,Eg,Zc).call(B),a.rotate(a.parentRotation)}return a}serialize(I=!1){if(this.isEmpty()||I)return null;if(this.deleted)return this.serializeDeleted();const e=xI._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),t=super.serialize(I);return Object.assign(t,{color:e,opacity:this.opacity,thickness:c(this,Ei),quadPoints:f(this,Eg,XT).call(this),outlines:f(this,Eg,HT).call(this,t.rect)}),this.addComment(t),this.annotationElementId&&!f(this,Eg,ST).call(this,t)?null:(t.id=this.annotationElementId,t)}renderAnnotationElement(I){return this.deleted?(I.hide(),null):(I.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};zm=new WeakMap,IZ=new WeakMap,Sl=new WeakMap,xd=new WeakMap,CZ=new WeakMap,St=new WeakMap,eZ=new WeakMap,tZ=new WeakMap,Od=new WeakMap,oi=new WeakMap,ai=new WeakMap,we=new WeakMap,Fm=new WeakMap,Jm=new WeakMap,ze=new WeakMap,Lm=new WeakMap,Ei=new WeakMap,iZ=new WeakMap,Eg=new WeakSet,TR=function(){const I=new _Y(c(this,Sl),.001);V(this,oi,I.getOutlines()),[this.x,this.y,this.width,this.height]=c(this,oi).box;const e=new _Y(c(this,Sl),.0025,.001,this._uiManager.direction==="ltr");V(this,St,e.getOutlines());const{firstPoint:t}=c(this,oi);V(this,Fm,[(t[0]-this.x)/this.width,(t[1]-this.y)/this.height]);const{lastPoint:i}=c(this,St);V(this,Jm,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Pp=function({highlightOutlines:I,highlightId:e,clipPathId:t}){var m,u;if(V(this,oi,I),V(this,St,I.getNewOutline(c(this,Ei)/2+1.5,.0025)),e>=0)V(this,ai,e),V(this,xd,t),this.parent.drawLayer.finalizeDraw(e,{bbox:I.box,path:{d:I.toSVGPath()}}),V(this,ze,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:c(this,St).box,path:{d:c(this,St).toSVGPath()}},!0));else if(this.parent){const b=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(c(this,ai),{bbox:f(m=uI,Pi,bu).call(m,c(this,oi).box,(b-this.rotation+360)%360),path:{d:I.toSVGPath()}}),this.parent.drawLayer.updateProperties(c(this,ze),{bbox:f(u=uI,Pi,bu).call(u,c(this,St).box,b),path:{d:c(this,St).toSVGPath()}})}const[A,n,l,s]=I.box;switch(this.rotation){case 0:this.x=A,this.y=n,this.width=l,this.height=s;break;case 90:{const[b,Z]=this.parentDimensions;this.x=n,this.y=1-A,this.width=l*Z/b,this.height=s*b/Z;break}case 180:this.x=1-A,this.y=1-n,this.width=l,this.height=s;break;case 270:{const[b,Z]=this.parentDimensions;this.x=1-n,this.y=A,this.width=l*Z/b,this.height=s*b/Z;break}}const{firstPoint:a}=I;V(this,Fm,[(a[0]-A)/l,(a[1]-n)/s]);const{lastPoint:d}=c(this,St);V(this,Jm,[(d[0]-A)/l,(d[1]-n)/s])},VT=function(I){const e=(A,n)=>{this.color=A,this.opacity=n,this.onUpdatedColor()},t=this.color,i=this.opacity;this.addCommands({cmd:e.bind(this,I,uI._defaultOpacity),undo:e.bind(this,t,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:oI.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(I)},!0)},NT=function(I){const e=c(this,Ei),t=i=>{V(this,Ei,i),f(this,Eg,MT).call(this,i)};this.addCommands({cmd:t.bind(this,I),undo:t.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:oI.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:I},!0)},MT=function(I){c(this,we)&&(f(this,Eg,Pp).call(this,{highlightOutlines:c(this,oi).getNewOutline(I/2)}),this.fixAndSetPosition(),this.setDims())},vR=function(){c(this,ai)===null||!this.parent||(this.parent.drawLayer.remove(c(this,ai)),V(this,ai,null),this.parent.drawLayer.remove(c(this,ze)),V(this,ze,null))},Zc=function(I=this.parent){c(this,ai)===null&&({id:PC(this,ai)._,clipPathId:PC(this,xd)._}=I.drawLayer.draw({bbox:c(this,oi).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:c(this,we)},path:{d:c(this,oi).toSVGPath()}},!1,!0),V(this,ze,I.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:c(this,we)},bbox:c(this,St).box,path:{d:c(this,St).toSVGPath()}},c(this,we))),c(this,Od)&&(c(this,Od).style.clipPath=c(this,xd)))},Pi=new WeakSet,bu=function([I,e,t,i],A){switch(A){case 90:return[1-e-i,I,i,t];case 180:return[1-I-t,1-e-i,t,i];case 270:return[e,1-I-t,i,t]}return[I,e,t,i]},RT=function(I){uI._keyboardManager.exec(this,I)},_p=function(I){if(!c(this,zm))return;const e=window.getSelection();I?e.setPosition(c(this,zm),c(this,IZ)):e.setPosition(c(this,eZ),c(this,tZ))},$p=function(){return c(this,we)?this.rotation:0},XT=function(){if(c(this,we))return null;const[I,e]=this.pageDimensions,[t,i]=this.pageTranslation,A=c(this,Sl),n=new Float32Array(A.length*8);let l=0;for(const{x:s,y:a,width:d,height:m}of A){const u=s*I+t,b=(1-a)*e+i;n[l]=n[l+4]=u,n[l+1]=n[l+3]=b,n[l+2]=n[l+6]=u+d*I,n[l+5]=n[l+7]=b-m*e,l+=8}return n},HT=function(I){return c(this,oi).serialize(I,f(this,Eg,$p).call(this))},fT=function(I,e){this._freeHighlight.add(e)&&I.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},DT=function(I,e){this._freeHighlight.isEmpty()?I.drawLayer.remove(this._freeHighlightId):I.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},ST=function(I){const{color:e}=this._initialData;return this.hasEditedComment||I.color.some((t,i)=>t!==e[i])},X(uI,Pi),sg(uI,"_defaultColor",null),sg(uI,"_defaultOpacity",1),sg(uI,"_defaultThickness",12),sg(uI,"_type","highlight"),sg(uI,"_editorType",Tg.HIGHLIGHT),sg(uI,"_freeHighlightId",-1),sg(uI,"_freeHighlight",null),sg(uI,"_freeHighlightClipId","");let Vw=uI;class _S{constructor(){X(this,Qd,Object.create(null))}updateProperty(g,I){this[g]=I,this.updateSVGProperty(g,I)}updateProperties(g){if(g)for(const[I,e]of Object.entries(g))I.startsWith("_")||this.updateProperty(I,e)}updateSVGProperty(g,I){c(this,Qd)[g]=I}toSVGProperties(){const g=c(this,Qd);return V(this,Qd,Object.create(null)),{root:g}}reset(){V(this,Qd,Object.create(null))}updateAll(g=this){this.updateProperties(g)}clone(){kI("Not implemented")}}Qd=new WeakMap;const iI=class iI extends xI{constructor(I){super(I);X(this,rI);X(this,di,null);X(this,Tm);sg(this,"_colorPicker",null);sg(this,"_drawId",null);V(this,Tm,I.mustBeCommitted||!1),this._addOutlines(I)}onUpdatedColor(){var I;(I=this._colorPicker)==null||I.update(this.color),super.onUpdatedColor()}_addOutlines(I){I.drawOutlines&&(f(this,rI,jR).call(this,I),f(this,rI,JZ).call(this))}static _mergeSVGProperties(I,e){const t=new Set(Object.keys(I));for(const[i,A]of Object.entries(e))t.has(i)?Object.assign(I[i],A):I[i]=A;return I}static getDefaultDrawingOptions(I){kI("Not implemented")}static get typesMap(){kI("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(I,e){const t=this.typesMap.get(I);t&&this._defaultDrawingOptions.updateProperty(t,e),this._currentParent&&(c(iI,ie).updateProperty(t,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(I,e){const t=this.constructor.typesMap.get(I);t&&this._updateProperty(I,t,e)}static get defaultPropertiesToUpdate(){const I=[],e=this._defaultDrawingOptions;for(const[t,i]of this.typesMap)I.push([t,e[i]]);return I}get propertiesToUpdate(){const I=[],{_drawingOptions:e}=this;for(const[t,i]of this.constructor.typesMap)I.push([t,e[i]]);return I}_updateProperty(I,e,t){const i=this._drawingOptions,A=i[e],n=l=>{var a;i.updateProperty(e,l);const s=c(this,di).updateProperty(e,l);s&&f(this,rI,LZ).call(this,s),(a=this.parent)==null||a.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),I===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:I,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties(c(this,di).getPathResizingSVGProperties(f(this,rI,qp).call(this)),{bbox:f(this,rI,Zu).call(this)}))}_onResized(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties(c(this,di).getPathResizedSVGProperties(f(this,rI,qp).call(this)),{bbox:f(this,rI,Zu).call(this)}))}_onTranslating(I,e){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{bbox:f(this,rI,Zu).call(this)})}_onTranslated(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties(c(this,di).getPathTranslatedSVGProperties(f(this,rI,qp).call(this),this.parentDimensions),{bbox:f(this,rI,Zu).call(this)}))}_onStartDragging(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(I){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,c(this,Tm)&&(V(this,Tm,!1),this.commit(),this.parent.setSelected(this),I&&this.isOnScreen&&this.div.focus())}remove(){f(this,rI,OR).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,rI,JZ).call(this),f(this,rI,LZ).call(this,c(this,di).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?(this._uiManager.removeShouldRescale(this),f(this,rI,OR).call(this)):I&&(this._uiManager.addShouldRescale(this),f(this,rI,JZ).call(this,I),e=!this.parent&&((t=this.div)==null?void 0:t.classList.contains("selectedEditor"))),super.setParent(I),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties({bbox:f(this,rI,Zu).call(this)},c(this,di).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&f(this,rI,LZ).call(this,c(this,di).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let I,e;this._isCopy&&(I=this.x,e=this.y);const t=super.render();t.classList.add("draw");const i=document.createElement("div");return t.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(I,e),t}static createDrawerInstance(I,e,t,i,A){kI("Not implemented")}static startDrawing(I,e,t,i){var w;const{target:A,offsetX:n,offsetY:l,pointerId:s,pointerType:a}=i;if(Re.isInitializedAndDifferentPointerType(a))return;const{viewport:{rotation:d}}=I,{width:m,height:u}=A.getBoundingClientRect(),b=V(iI,Ud,new AbortController),Z=I.combinedSignal(b);if(Re.setPointer(a,s),window.addEventListener("pointerup",G=>{Re.isSamePointerIdOrRemove(G.pointerId)&&this._endDraw(G)},{signal:Z}),window.addEventListener("pointercancel",G=>{Re.isSamePointerIdOrRemove(G.pointerId)&&this._currentParent.endDrawingSession()},{signal:Z}),window.addEventListener("pointerdown",G=>{Re.isSamePointerType(G.pointerType)&&(Re.initializeAndAddPointerId(G.pointerId),c(iI,ie).isCancellable()&&(c(iI,ie).removeLastElement(),c(iI,ie).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:Z}),window.addEventListener("contextmenu",yi,{signal:Z}),A.addEventListener("pointermove",this._drawMove.bind(this),{signal:Z}),A.addEventListener("touchmove",G=>{Re.isSameTimeStamp(G.timeStamp)&&mC(G)},{signal:Z}),I.toggleDrawing(),(w=e._editorUndoBar)==null||w.hide(),c(iI,ie)){I.drawLayer.updateProperties(this._currentDrawId,c(iI,ie).startNew(n,l,m,u,d));return}e.updateUIForDefaultProperties(this),V(iI,ie,this.createDrawerInstance(n,l,m,u,d)),V(iI,Ed,this.getDefaultDrawingOptions()),this._currentParent=I,{id:this._currentDrawId}=I.drawLayer.draw(this._mergeSVGProperties(c(iI,Ed).toSVGProperties(),c(iI,ie).defaultSVGProperties),!0,!1)}static _drawMove(I){if(Re.isSameTimeStamp(I.timeStamp),!c(iI,ie))return;const{offsetX:e,offsetY:t,pointerId:i}=I;if(Re.isSamePointerId(i)){if(Re.isUsingMultiplePointers()){this._endDraw(I);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,c(iI,ie).add(e,t)),Re.setTimeStamp(I.timeStamp),mC(I)}}static _cleanup(I){I&&(this._currentDrawId=-1,this._currentParent=null,V(iI,ie,null),V(iI,Ed,null),Re.clearPointerType(),Re.clearTimeStamp()),c(iI,Ud)&&(c(iI,Ud).abort(),V(iI,Ud,null),Re.clearPointerIds())}static _endDraw(I){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),(I==null?void 0:I.target)===e.div&&e.drawLayer.updateProperties(this._currentDrawId,c(iI,ie).end(I.offsetX,I.offsetY)),this.supportMultipleDrawings){const t=c(iI,ie),i=this._currentDrawId,A=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(A))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:oI.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(I){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(oI.DRAW_STEP),!c(iI,ie).isEmpty()){const{pageDimensions:[t,i],scale:A}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:c(iI,ie).getOutlines(t*A,i*A,A,this._INNER_MARGIN),drawingOptions:c(iI,Ed),mustBeCommitted:!I});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(I){}static deserializeDraw(I,e,t,i,A,n){kI("Not implemented")}static async deserialize(I,e,t){var d,m;const{rawDims:{pageWidth:i,pageHeight:A,pageX:n,pageY:l}}=e.viewport,s=this.deserializeDraw(n,l,i,A,this._INNER_MARGIN,I),a=await super.deserialize(I,e,t);return a.createDrawingOptions(I),f(d=a,rI,jR).call(d,{drawOutlines:s}),f(m=a,rI,JZ).call(m),a.onScaleChanging(),a.rotate(),a}serializeDraw(I){const[e,t]=this.pageTranslation,[i,A]=this.pageDimensions;return c(this,di).serialize([e,t,i,A],I)}renderAnnotationElement(I){return I.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};di=new WeakMap,Tm=new WeakMap,ie=new WeakMap,Ud=new WeakMap,Ed=new WeakMap,rI=new WeakSet,jR=function({drawOutlines:I,drawId:e,drawingOptions:t}){V(this,di,I),this._drawingOptions||(this._drawingOptions=t),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,I.defaultProperties)):this._drawId=f(this,rI,xR).call(this,I,this.parent),f(this,rI,LZ).call(this,I.box)},xR=function(I,e){const{id:t}=e.drawLayer.draw(iI._mergeSVGProperties(this._drawingOptions.toSVGProperties(),I.defaultSVGProperties),!1,!1);return t},OR=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},JZ=function(I=this.parent){if(!(this._drawId!==null&&this.parent===I)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,I.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=f(this,rI,xR).call(this,c(this,di),I)}},KT=function([I,e,t,i]){const{parentDimensions:[A,n],rotation:l}=this;switch(l){case 90:return[e,1-I,t*(n/A),i*(A/n)];case 180:return[1-I,1-e,t,i];case 270:return[1-e,I,t*(n/A),i*(A/n)];default:return[I,e,t,i]}},qp=function(){const{x:I,y:e,width:t,height:i,parentDimensions:[A,n],rotation:l}=this;switch(l){case 90:return[1-e,I,t*(A/n),i*(n/A)];case 180:return[1-I,1-e,t,i];case 270:return[e,1-I,t*(A/n),i*(n/A)];default:return[I,e,t,i]}},LZ=function(I){[this.x,this.y,this.width,this.height]=f(this,rI,KT).call(this,I),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Zu=function(){const{x:I,y:e,width:t,height:i,rotation:A,parentRotation:n,parentDimensions:[l,s]}=this;switch((A*4+n)/90){case 1:return[1-e-i,I,i,t];case 2:return[1-I-t,1-e-i,t,i];case 3:return[e,1-I-t,i,t];case 4:return[I,e-t*(l/s),i*(s/l),t*(l/s)];case 5:return[1-e,I,t*(l/s),i*(s/l)];case 6:return[1-I-i*(s/l),1-e,i*(s/l),t*(l/s)];case 7:return[e-t*(l/s),1-I-i*(s/l),t*(l/s),i*(s/l)];case 8:return[I-t,e-i,t,i];case 9:return[1-e,I-t,i,t];case 10:return[1-I,1-e,t,i];case 11:return[e-i,1-I,i,t];case 12:return[I-i*(s/l),e,i*(s/l),t*(l/s)];case 13:return[1-e-t*(l/s),I-i*(s/l),t*(l/s),i*(s/l)];case 14:return[1-I,1-e-t*(l/s),i*(s/l),t*(l/s)];case 15:return[e,1-I,t*(l/s),i*(s/l)];default:return[I,e,t,i]}},sg(iI,"_currentDrawId",-1),sg(iI,"_currentParent",null),X(iI,ie,null),X(iI,Ud,null),X(iI,Ed,null),sg(iI,"_INNER_MARGIN",3);let Nw=iI;class Gjg{constructor(g,I,e,t,i,A){X(this,jm);X(this,Vn,new Float64Array(6));X(this,Ae);X(this,ne);X(this,Pd);X(this,vm);X(this,st);X(this,We,"");X(this,_i,0);X(this,_d,new Bh);X(this,$d);X(this,qd);V(this,$d,e),V(this,qd,t),V(this,Pd,i),V(this,vm,A),[g,I]=f(this,jm,gy).call(this,g,I);const n=V(this,Ae,[NaN,NaN,NaN,NaN,g,I]);V(this,st,[g,I]),V(this,ne,[{line:n,points:c(this,st)}]),c(this,Vn).set(n,0)}updateProperty(g,I){g==="stroke-width"&&V(this,vm,I)}isEmpty(){return!c(this,ne)||c(this,ne).length===0}isCancellable(){return c(this,st).length<=10}add(g,I){[g,I]=f(this,jm,gy).call(this,g,I);const[e,t,i,A]=c(this,Vn).subarray(2,6),n=g-i,l=I-A;return Math.hypot(c(this,$d)*n,c(this,qd)*l)<=2?null:(c(this,st).push(g,I),isNaN(e)?(c(this,Vn).set([i,A,g,I],2),c(this,Ae).push(NaN,NaN,NaN,NaN,g,I),{path:{d:this.toSVGPath()}}):(isNaN(c(this,Vn)[0])&&c(this,Ae).splice(6,6),c(this,Vn).set([e,t,i,A,g,I],0),c(this,Ae).push(...Zg.createBezierPoints(e,t,i,A,g,I)),{path:{d:this.toSVGPath()}}))}end(g,I){const e=this.add(g,I);return e||(c(this,st).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(g,I,e,t,i){V(this,$d,e),V(this,qd,t),V(this,Pd,i),[g,I]=f(this,jm,gy).call(this,g,I);const A=V(this,Ae,[NaN,NaN,NaN,NaN,g,I]);V(this,st,[g,I]);const n=c(this,ne).at(-1);return n&&(n.line=new Float32Array(n.line),n.points=new Float32Array(n.points)),c(this,ne).push({line:A,points:c(this,st)}),c(this,Vn).set(A,0),V(this,_i,0),this.toSVGPath(),null}getLastElement(){return c(this,ne).at(-1)}setLastElement(g){return c(this,ne)?(c(this,ne).push(g),V(this,Ae,g.line),V(this,st,g.points),V(this,_i,0),{path:{d:this.toSVGPath()}}):c(this,_d).setLastElement(g)}removeLastElement(){if(!c(this,ne))return c(this,_d).removeLastElement();c(this,ne).pop(),V(this,We,"");for(let g=0,I=c(this,ne).length;g<I;g++){const{line:e,points:t}=c(this,ne)[g];V(this,Ae,e),V(this,st,t),V(this,_i,0),this.toSVGPath()}return{path:{d:c(this,We)}}}toSVGPath(){const g=Zg.svgRound(c(this,Ae)[4]),I=Zg.svgRound(c(this,Ae)[5]);if(c(this,st).length===2)return V(this,We,`${c(this,We)} M ${g} ${I} Z`),c(this,We);if(c(this,st).length<=6){const t=c(this,We).lastIndexOf("M");V(this,We,`${c(this,We).slice(0,t)} M ${g} ${I}`),V(this,_i,6)}if(c(this,st).length===4){const t=Zg.svgRound(c(this,Ae)[10]),i=Zg.svgRound(c(this,Ae)[11]);return V(this,We,`${c(this,We)} L ${t} ${i}`),V(this,_i,12),c(this,We)}const e=[];c(this,_i)===0&&(e.push(`M ${g} ${I}`),V(this,_i,6));for(let t=c(this,_i),i=c(this,Ae).length;t<i;t+=6){const[A,n,l,s,a,d]=c(this,Ae).slice(t,t+6).map(Zg.svgRound);e.push(`C${A} ${n} ${l} ${s} ${a} ${d}`)}return V(this,We,c(this,We)+e.join(" ")),V(this,_i,c(this,Ae).length),c(this,We)}getOutlines(g,I,e,t){const i=c(this,ne).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),c(this,_d).build(c(this,ne),g,I,e,c(this,Pd),c(this,vm),t),V(this,Vn,null),V(this,Ae,null),V(this,ne,null),V(this,We,null),c(this,_d)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Vn=new WeakMap,Ae=new WeakMap,ne=new WeakMap,Pd=new WeakMap,vm=new WeakMap,st=new WeakMap,We=new WeakMap,_i=new WeakMap,_d=new WeakMap,$d=new WeakMap,qd=new WeakMap,jm=new WeakSet,gy=function(g,I){return Zg._normalizePoint(g,I,c(this,$d),c(this,qd),c(this,Pd))};class Bh extends Zg{constructor(){super(...arguments);X(this,Be);X(this,ot);X(this,AZ,0);X(this,nZ);X(this,ci);X(this,Nn);X(this,Mn);X(this,xm);X(this,Om);X(this,gc)}build(I,e,t,i,A,n,l){V(this,Nn,e),V(this,Mn,t),V(this,xm,i),V(this,Om,A),V(this,gc,n),V(this,nZ,l??0),V(this,ci,I),f(this,Be,zT).call(this)}get thickness(){return c(this,gc)}setLastElement(I){return c(this,ci).push(I),{path:{d:this.toSVGPath()}}}removeLastElement(){return c(this,ci).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const I=[];for(const{line:e}of c(this,ci)){if(I.push(`M${Zg.svgRound(e[4])} ${Zg.svgRound(e[5])}`),e.length===6){I.push("Z");continue}if(e.length===12&&isNaN(e[6])){I.push(`L${Zg.svgRound(e[10])} ${Zg.svgRound(e[11])}`);continue}for(let t=6,i=e.length;t<i;t+=6){const[A,n,l,s,a,d]=e.subarray(t,t+6).map(Zg.svgRound);I.push(`C${A} ${n} ${l} ${s} ${a} ${d}`)}}return I.join("")}serialize([I,e,t,i],A){const n=[],l=[],[s,a,d,m]=f(this,Be,kT).call(this);let u,b,Z,w,G,B,p,Y,y;switch(c(this,Om)){case 0:y=Zg._rescale,u=I,b=e+i,Z=t,w=-i,G=I+s*t,B=e+(1-a-m)*i,p=I+(s+d)*t,Y=e+(1-a)*i;break;case 90:y=Zg._rescaleAndSwap,u=I,b=e,Z=t,w=i,G=I+a*t,B=e+s*i,p=I+(a+m)*t,Y=e+(s+d)*i;break;case 180:y=Zg._rescale,u=I+t,b=e,Z=-t,w=i,G=I+(1-s-d)*t,B=e+a*i,p=I+(1-s)*t,Y=e+(a+m)*i;break;case 270:y=Zg._rescaleAndSwap,u=I+t,b=e+i,Z=-t,w=-i,G=I+(1-a-m)*t,B=e+(1-s-d)*i,p=I+(1-a)*t,Y=e+(1-s)*i;break}for(const{line:R,points:M}of c(this,ci))n.push(y(R,u,b,Z,w,A?new Array(R.length):null)),l.push(y(M,u,b,Z,w,A?new Array(M.length):null));return{lines:n,points:l,rect:[G,B,p,Y]}}static deserialize(I,e,t,i,A,{paths:{lines:n,points:l},rotation:s,thickness:a}){const d=[];let m,u,b,Z,w;switch(s){case 0:w=Zg._rescale,m=-I/t,u=e/i+1,b=1/t,Z=-1/i;break;case 90:w=Zg._rescaleAndSwap,m=-e/i,u=-I/t,b=1/i,Z=1/t;break;case 180:w=Zg._rescale,m=I/t+1,u=-e/i,b=-1/t,Z=1/i;break;case 270:w=Zg._rescaleAndSwap,m=e/i+1,u=I/t+1,b=-1/i,Z=-1/t;break}if(!n){n=[];for(const B of l){const p=B.length;if(p===2){n.push(new Float32Array([NaN,NaN,NaN,NaN,B[0],B[1]]));continue}if(p===4){n.push(new Float32Array([NaN,NaN,NaN,NaN,B[0],B[1],NaN,NaN,NaN,NaN,B[2],B[3]]));continue}const Y=new Float32Array(3*(p-2));n.push(Y);let[y,R,M,D]=B.subarray(0,4);Y.set([NaN,NaN,NaN,NaN,y,R],0);for(let J=4;J<p;J+=2){const H=B[J],z=B[J+1];Y.set(Zg.createBezierPoints(y,R,M,D,H,z),(J-2)*3),[y,R,M,D]=[M,D,H,z]}}}for(let B=0,p=n.length;B<p;B++)d.push({line:w(n[B].map(Y=>Y??NaN),m,u,b,Z),points:w(l[B].map(Y=>Y??NaN),m,u,b,Z)});const G=new this.prototype.constructor;return G.build(d,t,i,1,s,a,A),G}get box(){return c(this,ot)}updateProperty(I,e){return I==="stroke-width"?f(this,Be,FT).call(this,e):null}updateParentDimensions([I,e],t){const[i,A]=f(this,Be,$l).call(this);V(this,Nn,I),V(this,Mn,e),V(this,xm,t);const[n,l]=f(this,Be,$l).call(this),s=n-i,a=l-A,d=c(this,ot);return d[0]-=s,d[1]-=a,d[2]+=2*s,d[3]+=2*a,d}updateRotation(I){return V(this,AZ,I),{path:{transform:this.rotationTransform}}}get viewBox(){return c(this,ot).map(Zg.svgRound).join(" ")}get defaultProperties(){const[I,e]=c(this,ot);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`}}}get rotationTransform(){const[,,I,e]=c(this,ot);let t=0,i=0,A=0,n=0,l=0,s=0;switch(c(this,AZ)){case 90:i=e/I,A=-I/e,l=I;break;case 180:t=-1,n=-1,l=I,s=e;break;case 270:i=-e/I,A=I/e,s=e;break;default:return""}return`matrix(${t} ${i} ${A} ${n} ${Zg.svgRound(l)} ${Zg.svgRound(s)})`}getPathResizingSVGProperties([I,e,t,i]){const[A,n]=f(this,Be,$l).call(this),[l,s,a,d]=c(this,ot);if(Math.abs(a-A)<=Zg.PRECISION||Math.abs(d-n)<=Zg.PRECISION){const w=I+t/2-(l+a/2),G=e+i/2-(s+d/2);return{path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`,transform:`${this.rotationTransform} translate(${w} ${G})`}}}const m=(t-2*A)/(a-2*A),u=(i-2*n)/(d-2*n),b=a/t,Z=d/i;return{path:{"transform-origin":`${Zg.svgRound(l)} ${Zg.svgRound(s)}`,transform:`${this.rotationTransform} scale(${b} ${Z}) translate(${Zg.svgRound(A)} ${Zg.svgRound(n)}) scale(${m} ${u}) translate(${Zg.svgRound(-A)} ${Zg.svgRound(-n)})`}}}getPathResizedSVGProperties([I,e,t,i]){const[A,n]=f(this,Be,$l).call(this),l=c(this,ot),[s,a,d,m]=l;if(l[0]=I,l[1]=e,l[2]=t,l[3]=i,Math.abs(d-A)<=Zg.PRECISION||Math.abs(m-n)<=Zg.PRECISION){const G=I+t/2-(s+d/2),B=e+i/2-(a+m/2);for(const{line:p,points:Y}of c(this,ci))Zg._translate(p,G,B,p),Zg._translate(Y,G,B,Y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(t-2*A)/(d-2*A),b=(i-2*n)/(m-2*n),Z=-u*(s+A)+I+A,w=-b*(a+n)+e+n;if(u!==1||b!==1||Z!==0||w!==0)for(const{line:G,points:B}of c(this,ci))Zg._rescale(G,Z,w,u,b,G),Zg._rescale(B,Z,w,u,b,B);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([I,e],t){const[i,A]=t,n=c(this,ot),l=I-n[0],s=e-n[1];if(c(this,Nn)===i&&c(this,Mn)===A)for(const{line:a,points:d}of c(this,ci))Zg._translate(a,l,s,a),Zg._translate(d,l,s,d);else{const a=c(this,Nn)/i,d=c(this,Mn)/A;V(this,Nn,i),V(this,Mn,A);for(const{line:m,points:u}of c(this,ci))Zg._rescale(m,l,s,a,d,m),Zg._rescale(u,l,s,a,d,u);n[2]*=a,n[3]*=d}return n[0]=I,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`}}}get defaultSVGProperties(){const I=c(this,ot);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Zg.svgRound(I[0])} ${Zg.svgRound(I[1])}`,transform:this.rotationTransform||null},bbox:I}}}ot=new WeakMap,AZ=new WeakMap,nZ=new WeakMap,ci=new WeakMap,Nn=new WeakMap,Mn=new WeakMap,xm=new WeakMap,Om=new WeakMap,gc=new WeakMap,Be=new WeakSet,$l=function(I=c(this,gc)){const e=c(this,nZ)+I/2*c(this,xm);return c(this,Om)%180===0?[e/c(this,Nn),e/c(this,Mn)]:[e/c(this,Mn),e/c(this,Nn)]},kT=function(){const[I,e,t,i]=c(this,ot),[A,n]=f(this,Be,$l).call(this,0);return[I+A,e+n,t-2*A,i-2*n]},zT=function(){const I=V(this,ot,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of c(this,ci)){if(i.length<=12){for(let l=4,s=i.length;l<s;l+=6)wg.pointBoundingBox(i[l],i[l+1],I);continue}let A=i[4],n=i[5];for(let l=6,s=i.length;l<s;l+=6){const[a,d,m,u,b,Z]=i.subarray(l,l+6);wg.bezierBoundingBox(A,n,a,d,m,u,b,Z,I),A=b,n=Z}}const[e,t]=f(this,Be,$l).call(this);I[0]=gt(I[0]-e,0,1),I[1]=gt(I[1]-t,0,1),I[2]=gt(I[2]+e,0,1),I[3]=gt(I[3]+t,0,1),I[2]-=I[0],I[3]-=I[1]},FT=function(I){const[e,t]=f(this,Be,$l).call(this);V(this,gc,I);const[i,A]=f(this,Be,$l).call(this),[n,l]=[i-e,A-t],s=c(this,ot);return s[0]-=n,s[1]-=l,s[2]+=2*n,s[3]+=2*l,s};class Mw extends _S{constructor(g){super(),this._viewParameters=g,super.updateProperties({fill:"none",stroke:xI._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(g,I){g==="stroke-width"&&(I??(I=this["stroke-width"]),I*=this._viewParameters.realScale),super.updateSVGProperty(g,I)}clone(){const g=new Mw(this._viewParameters);return g.updateAll(this),g}}const Qm=class Qm extends Nw{constructor(I){super({...I,name:"inkEditor"});X(this,SB);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(I,e){xI.initialize(I,e),this._defaultDrawingOptions=new Mw(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Jg(this,"typesMap",new Map([[oI.INK_THICKNESS,"stroke-width"],[oI.INK_COLOR,"stroke"],[oI.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(I,e,t,i,A){return new Gjg(I,e,t,i,A,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(I,e,t,i,A,n){return Bh.deserialize(I,e,t,i,A,n)}static async deserialize(I,e,t){let i=null;if(I instanceof UY){const{data:{inkLists:n,rect:l,rotation:s,id:a,color:d,opacity:m,borderStyle:{rawWidth:u},popupRef:b,richText:Z,contentsObj:w,creationDate:G,modificationDate:B},parent:{page:{pageNumber:p}}}=I;i=I={annotationType:Tg.INK,color:Array.from(d),thickness:u,opacity:m,paths:{points:n},boxes:null,pageIndex:p-1,rect:l.slice(0),rotation:s,annotationElementId:a,id:a,deleted:!1,popupRef:b,richText:Z,comment:(w==null?void 0:w.str)||null,creationDate:G,modificationDate:B}}const A=await super.deserialize(I,e,t);return A._initialData=i,I.comment&&A.setCommentData(I),A}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Bw(this)),[["colorPicker",this._colorPicker]]}get colorType(){return oI.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:I,_drawingOptions:e,parent:t}=this;e.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(I,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const I=this._currentParent;I&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),I.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:I,thickness:e,opacity:t}){this._drawingOptions=Qm.getDefaultDrawingOptions({stroke:wg.makeHexColor(...I),"stroke-width":e,"stroke-opacity":t})}serialize(I=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:t}=this.serializeDraw(I),{_drawingOptions:{stroke:i,"stroke-opacity":A,"stroke-width":n}}=this,l=Object.assign(super.serialize(I),{color:xI._colorManager.convert(i),opacity:A,thickness:n,paths:{lines:e,points:t}});return this.addComment(l),I?(l.isCopy=!0,l):this.annotationElementId&&!f(this,SB,JT).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(I){if(this.deleted)return I.hide(),null;const{points:e,rect:t}=this.serializeDraw(!1);return I.updateEdited({rect:t,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}};SB=new WeakSet,JT=function(I){const{color:e,thickness:t,opacity:i,pageIndex:A}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||I.color.some((n,l)=>n!==e[l])||I.thickness!==t||I.opacity!==i||I.pageIndex!==A},sg(Qm,"_type","ink"),sg(Qm,"_editorType",Tg.INK),sg(Qm,"_defaultDrawingOptions",null);let qY=Qm;class gV extends Bh{toSVGPath(){let g=super.toSVGPath();return g.endsWith("Z")||(g+="Z"),g}}const Rw=8,ph=3;class jn{static extractContoursFromText(g,{fontFamily:I,fontStyle:e,fontWeight:t},i,A,n,l){let s=new OffscreenCanvas(1,1),a=s.getContext("2d",{alpha:!1});const d=200,m=a.font=`${e} ${t} ${d}px ${I}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:b,actualBoundingBoxAscent:Z,actualBoundingBoxDescent:w,fontBoundingBoxAscent:G,fontBoundingBoxDescent:B,width:p}=a.measureText(g),Y=1.5,y=Math.ceil(Math.max(Math.abs(u)+Math.abs(b)||0,p)*Y),R=Math.ceil(Math.max(Math.abs(Z)+Math.abs(w)||d,Math.abs(G)+Math.abs(B)||d)*Y);s=new OffscreenCanvas(y,R),a=s.getContext("2d",{alpha:!0,willReadFrequently:!0}),a.font=m,a.filter="grayscale(1)",a.fillStyle="white",a.fillRect(0,0,y,R),a.fillStyle="black",a.fillText(g,y*(Y-1)/2,R*(3-Y)/2);const M=f(this,bI,ER).call(this,a.getImageData(0,0,y,R).data),D=f(this,bI,xT).call(this,M),J=f(this,bI,PR).call(this,D),H=f(this,bI,UR).call(this,M,y,R,J);return this.processDrawnLines({lines:{curves:H,width:y,height:R},pageWidth:i,pageHeight:A,rotation:n,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(g,I,e,t,i){const[A,n,l]=f(this,bI,OT).call(this,g),[s,a]=f(this,bI,jT).call(this,A,n,l,Math.hypot(n,l)*c(this,Ic).sigmaSFactor,c(this,Ic).sigmaR,c(this,Ic).kernelSize),d=f(this,bI,PR).call(this,a),m=f(this,bI,UR).call(this,s,n,l,d);return this.processDrawnLines({lines:{curves:m,width:n,height:l},pageWidth:I,pageHeight:e,rotation:t,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:g,pageWidth:I,pageHeight:e,rotation:t,innerMargin:i,mustSmooth:A,areContours:n}){t%180!==0&&([I,e]=[e,I]);const{curves:l,width:s,height:a}=g,d=g.thickness??0,m=[],u=Math.min(I/s,e/a),b=u/I,Z=u/e,w=[];for(const{points:B}of l){const p=A?f(this,bI,vT).call(this,B):B;if(!p)continue;w.push(p);const Y=p.length,y=new Float32Array(Y),R=new Float32Array(3*(Y===2?2:Y-2));if(m.push({line:R,points:y}),Y===2){y[0]=p[0]*b,y[1]=p[1]*Z,R.set([NaN,NaN,NaN,NaN,y[0],y[1]],0);continue}let[M,D,J,H]=p;M*=b,D*=Z,J*=b,H*=Z,y.set([M,D,J,H],0),R.set([NaN,NaN,NaN,NaN,M,D],0);for(let z=4;z<Y;z+=2){const T=y[z]=p[z]*b,P=y[z+1]=p[z+1]*Z;R.set(Zg.createBezierPoints(M,D,J,H,T,P),(z-2)*3),[M,D,J,H]=[J,H,T,P]}}if(m.length===0)return null;const G=n?new gV:new Bh;return G.build(m,I,e,1,t,n?0:d,i),{outline:G,newCurves:w,areContours:n,thickness:d,width:s,height:a}}static async compressSignature({outlines:g,areContours:I,thickness:e,width:t,height:i}){let A=1/0,n=-1/0,l=0;for(const p of g){l+=p.length;for(let Y=2,y=p.length;Y<y;Y++){const R=p[Y]-p[Y-2];A=Math.min(A,R),n=Math.max(n,R)}}let s;A>=-128&&n<=127?s=Int8Array:A>=-32768&&n<=32767?s=Int16Array:s=Int32Array;const a=g.length,d=Rw+ph*a,m=new Uint32Array(d);let u=0;m[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*a)*s.BYTES_PER_ELEMENT,m[u++]=0,m[u++]=t,m[u++]=i,m[u++]=I?0:1,m[u++]=Math.max(0,Math.floor(e??0)),m[u++]=a,m[u++]=s.BYTES_PER_ELEMENT;for(const p of g)m[u++]=p.length-2,m[u++]=p[0],m[u++]=p[1];const b=new CompressionStream("deflate-raw"),Z=b.writable.getWriter();await Z.ready,Z.write(m);const w=s.prototype.constructor;for(const p of g){const Y=new w(p.length-2);for(let y=2,R=p.length;y<R;y++)Y[y-2]=p[y]-p[y-2];Z.write(Y)}Z.close();const G=await new Response(b.readable).arrayBuffer(),B=new Uint8Array(G);return IS(B)}static async decompressSignature(g){try{const I=KTg(g),{readable:e,writable:t}=new DecompressionStream("deflate-raw"),i=t.getWriter();await i.ready,i.write(I).then(async()=>{await i.ready,await i.close()}).catch(()=>{});let A=null,n=0;for await(const p of e)A||(A=new Uint8Array(new Uint32Array(p.buffer,0,4)[0])),A.set(p,n),n+=p.length;const l=new Uint32Array(A.buffer,0,A.length>>2),s=l[1];if(s!==0)throw new Error(`Invalid version: ${s}`);const a=l[2],d=l[3],m=l[4]===0,u=l[5],b=l[6],Z=l[7],w=[],G=(Rw+ph*b)*Uint32Array.BYTES_PER_ELEMENT;let B;switch(Z){case Int8Array.BYTES_PER_ELEMENT:B=new Int8Array(A.buffer,G);break;case Int16Array.BYTES_PER_ELEMENT:B=new Int16Array(A.buffer,G);break;case Int32Array.BYTES_PER_ELEMENT:B=new Int32Array(A.buffer,G);break}n=0;for(let p=0;p<b;p++){const Y=l[ph*p+Rw],y=new Float32Array(Y+2);w.push(y);for(let R=0;R<ph-1;R++)y[R]=l[ph*p+Rw+R+1];for(let R=0;R<Y;R++)y[R+2]=y[R]+B[n++]}return{areContours:m,thickness:u,outlines:w,width:a,height:d}}catch(I){return Fg(`decompressSignature: ${I}`),null}}}Ic=new WeakMap,bI=new WeakSet,QR=function(g,I,e,t){return e-=g,t-=I,e===0?t>0?0:4:e===1?t+6:2-t},XA=new WeakMap,LT=function(g,I,e,t,i,A,n){const l=f(this,bI,QR).call(this,e,t,i,A);for(let s=0;s<8;s++){const a=(-s+l-n+16)%8,d=c(this,XA)[2*a],m=c(this,XA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},TT=function(g,I,e,t,i,A,n){const l=f(this,bI,QR).call(this,e,t,i,A);for(let s=0;s<8;s++){const a=(s+l+n+16)%8,d=c(this,XA)[2*a],m=c(this,XA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},UR=function(g,I,e,t){const i=g.length,A=new Int32Array(i);for(let a=0;a<i;a++)A[a]=g[a]<=t?1:0;for(let a=1;a<e-1;a++)A[a*I]=A[a*I+I-1]=0;for(let a=0;a<I;a++)A[a]=A[I*e-1-a]=0;let n=1,l;const s=[];for(let a=1;a<e-1;a++){l=1;for(let d=1;d<I-1;d++){const m=a*I+d,u=A[m];if(u===0)continue;let b=a,Z=d;if(u===1&&A[m-1]===0)n+=1,Z-=1;else if(u>=1&&A[m+1]===0)n+=1,Z+=1,u>1&&(l=u);else{u!==1&&(l=Math.abs(u));continue}const w=[d,a],G=Z===d+1,B={isHole:G,points:w,id:n,parent:0};s.push(B);let p;for(const z of s)if(z.id===l){p=z;break}p?p.isHole?B.parent=G?p.parent:l:B.parent=G?l:p.parent:B.parent=G?l:0;const Y=f(this,bI,LT).call(this,A,I,a,d,b,Z,0);if(Y===-1){A[m]=-n,A[m]!==1&&(l=Math.abs(A[m]));continue}let y=c(this,XA)[2*Y],R=c(this,XA)[2*Y+1];const M=a+y,D=d+R;b=M,Z=D;let J=a,H=d;for(;;){const z=f(this,bI,TT).call(this,A,I,J,H,b,Z,1);y=c(this,XA)[2*z],R=c(this,XA)[2*z+1];const T=J+y,P=H+R;w.push(P,T);const Ig=J*I+H;if(A[Ig+1]===0?A[Ig]=-n:A[Ig]===1&&(A[Ig]=n),T===a&&P===d&&J===M&&H===D){A[m]!==1&&(l=Math.abs(A[m]));break}else b=J,Z=H,J=T,H=P}}}return s},Iy=function(g,I,e,t){if(e-I<=4){for(let M=I;M<e-2;M+=2)t.push(g[M],g[M+1]);return}const i=g[I],A=g[I+1],n=g[e-4]-i,l=g[e-3]-A,s=Math.hypot(n,l),a=n/s,d=l/s,m=a*A-d*i,u=l/n,b=1/s,Z=Math.atan(u),w=Math.cos(Z),G=Math.sin(Z),B=b*(Math.abs(w)+Math.abs(G)),p=b*(1-B+B**2),Y=Math.max(Math.atan(Math.abs(G+w)*p),Math.atan(Math.abs(G-w)*p));let y=0,R=I;for(let M=I+2;M<e-2;M+=2){const D=Math.abs(m-a*g[M+1]+d*g[M]);D>y&&(R=M,y=D)}y>(s*Y)**2?(f(this,bI,Iy).call(this,g,I,R+2,t),f(this,bI,Iy).call(this,g,R,e,t)):t.push(i,A)},vT=function(g){const I=[],e=g.length;return f(this,bI,Iy).call(this,g,0,e,I),I.push(g[e-2],g[e-1]),I.length<=4?null:I},jT=function(g,I,e,t,i,A){const n=new Float32Array(A**2),l=-2*t**2,s=A>>1;for(let Z=0;Z<A;Z++){const w=(Z-s)**2;for(let G=0;G<A;G++)n[Z*A+G]=Math.exp((w+(G-s)**2)/l)}const a=new Float32Array(256),d=-2*i**2;for(let Z=0;Z<256;Z++)a[Z]=Math.exp(Z**2/d);const m=g.length,u=new Uint8Array(m),b=new Uint32Array(256);for(let Z=0;Z<e;Z++)for(let w=0;w<I;w++){const G=Z*I+w,B=g[G];let p=0,Y=0;for(let R=0;R<A;R++){const M=Z+R-s;if(!(M<0||M>=e))for(let D=0;D<A;D++){const J=w+D-s;if(J<0||J>=I)continue;const H=g[M*I+J],z=n[R*A+D]*a[Math.abs(H-B)];p+=H*z,Y+=z}}const y=u[G]=Math.round(p/Y);b[y]++}return[u,b]},xT=function(g){const I=new Uint32Array(256);for(const e of g)I[e]++;return I},ER=function(g){const I=g.length,e=new Uint8ClampedArray(I>>2);let t=-1/0,i=1/0;for(let n=0,l=e.length;n<l;n++){const s=e[n]=g[n<<2];t=Math.max(t,s),i=Math.min(i,s)}const A=255/(t-i);for(let n=0,l=e.length;n<l;n++)e[n]=(e[n]-i)*A;return e},PR=function(g){let I,e=-1/0,t=-1/0;const i=g.findIndex(l=>l!==0);let A=i,n=i;for(I=i;I<256;I++){const l=g[I];l>e&&(I-A>t&&(t=I-A,n=I-1),e=l,A=I)}for(I=n-1;I>=0&&!(g[I]>g[I+1]);I--);return I},OT=function(g){const I=g,{width:e,height:t}=g,{maxDim:i}=c(this,Ic);let A=e,n=t;if(e>i||t>i){let m=e,u=t,b=Math.log2(Math.max(e,t)/i);const Z=Math.floor(b);b=b===Z?Z-1:Z;for(let G=0;G<b;G++){A=Math.ceil(m/2),n=Math.ceil(u/2);const B=new OffscreenCanvas(A,n);B.getContext("2d").drawImage(g,0,0,m,u,0,0,A,n),m=A,u=n,g!==I&&g.close(),g=B.transferToImageBitmap()}const w=Math.min(i/A,i/n);A=Math.round(A*w),n=Math.round(n*w)}const s=new OffscreenCanvas(A,n).getContext("2d",{willReadFrequently:!0});s.fillStyle="white",s.fillRect(0,0,A,n),s.filter="grayscale(1)",s.drawImage(g,0,0,g.width,g.height,0,0,A,n);const a=s.getImageData(0,0,A,n).data;return[f(this,bI,ER).call(this,a),A,n]},X(jn,bI),X(jn,Ic,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),X(jn,XA,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class IV extends _S{constructor(){super(),super.updateProperties({fill:xI._defaultLineColor,"stroke-width":0})}clone(){const g=new IV;return g.updateAll(this),g}}class CV extends Mw{constructor(g){super(g),super.updateProperties({stroke:xI._defaultLineColor,"stroke-width":1})}clone(){const g=new CV(this._viewParameters);return g.updateAll(this),g}}const ri=class ri extends Nw{constructor(I){super({...I,mustBeCommitted:!0,name:"signatureEditor"});X(this,yo,!1);X(this,Rn,null);X(this,Yo,null);X(this,Cc,null);this._willKeepAspectRatio=!0,V(this,Yo,I.signatureData||null),V(this,Rn,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(I,e){xI.initialize(I,e),this._defaultDrawingOptions=new IV,this._defaultDrawnSignatureOptions=new CV(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Jg(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!c(this,Rn)}}static computeTelemetryFinalData(I){const e=I.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let I,e;const{_isCopy:t}=this;if(t&&(this._isCopy=!1,I=this.x,e=this.y),super.render(),this._drawId===null)if(c(this,Yo)){const{lines:i,mustSmooth:A,areContours:n,description:l,uuid:s,heightInPage:a}=c(this,Yo),{rawDims:{pageWidth:d,pageHeight:m},rotation:u}=this.parent.viewport,b=jn.processDrawnLines({lines:i,pageWidth:d,pageHeight:m,rotation:u,innerMargin:ri._INNER_MARGIN,mustSmooth:A,areContours:n});this.addSignature(b,a,l,s)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:c(this,Rn)||""}));return t&&(this._isCopy=!0,this._moveAfterPaste(I,e)),this.div}setUuid(I){V(this,Cc,I),this.addEditToolbar()}getUuid(){return c(this,Cc)}get description(){return c(this,Rn)}set description(I){V(this,Rn,I),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:I})),super.addEditToolbar().then(e=>{e==null||e.updateEditSignatureButton(I)}))}getSignaturePreview(){const{newCurves:I,areContours:e,thickness:t,width:i,height:A}=c(this,Yo),n=Math.max(i,A),l=jn.processDrawnLines({lines:{curves:I.map(s=>({points:s})),thickness:t,width:i,height:A},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(I,e,t,i){const{x:A,y:n}=this,{outline:l}=V(this,Yo,I);V(this,yo,l instanceof gV),this.description=t;let s;c(this,yo)?s=ri.getDefaultDrawingOptions():(s=ri._defaultDrawnSignatureOptions.clone(),s.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:s});const[,a]=this.pageDimensions;let d=e/a;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=A,this.y=n,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!t}}),this.div.hidden=!1}getFromImage(I){const{rawDims:{pageWidth:e,pageHeight:t},rotation:i}=this.parent.viewport;return jn.process(I,e,t,i,ri._INNER_MARGIN)}getFromText(I,e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:A}=this.parent.viewport;return jn.extractContoursFromText(I,e,t,i,A,ri._INNER_MARGIN)}getDrawnSignature(I){const{rawDims:{pageWidth:e,pageHeight:t},rotation:i}=this.parent.viewport;return jn.processDrawnLines({lines:I,pageWidth:e,pageHeight:t,rotation:i,innerMargin:ri._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:I,thickness:e}){I?this._drawingOptions=ri.getDefaultDrawingOptions():(this._drawingOptions=ri._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(I=!1){if(this.isEmpty())return null;const{lines:e,points:t}=this.serializeDraw(I),{_drawingOptions:{"stroke-width":i}}=this,A=Object.assign(super.serialize(I),{isSignature:!0,areContours:c(this,yo),color:[0,0,0],thickness:c(this,yo)?0:i});return this.addComment(A),I?(A.paths={lines:e,points:t},A.uuid=c(this,Cc),A.isCopy=!0):A.lines=e,c(this,Rn)&&(A.accessibilityData={type:"Figure",alt:c(this,Rn)}),A}static deserializeDraw(I,e,t,i,A,n){return n.areContours?gV.deserialize(I,e,t,i,A,n):Bh.deserialize(I,e,t,i,A,n)}static async deserialize(I,e,t){var A;const i=await super.deserialize(I,e,t);return V(i,yo,I.areContours),i.description=((A=I.accessibilityData)==null?void 0:A.alt)||"",V(i,Cc,I.uuid),i}};yo=new WeakMap,Rn=new WeakMap,Yo=new WeakMap,Cc=new WeakMap,sg(ri,"_type","signature"),sg(ri,"_editorType",Tg.SIGNATURE),sg(ri,"_defaultDrawingOptions",null);let eV=ri;class tV extends xI{constructor(I){super({...I,name:"stampEditor"});X(this,mI);X(this,CC,null);X(this,le,null);X(this,Vo,null);X(this,Kl,null);X(this,No,null);X(this,Um,"");X(this,kl,null);X(this,ec,!1);X(this,Xn,null);X(this,mi,!1);X(this,Em,!1);V(this,Kl,I.bitmapUrl),V(this,No,I.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(I,e){xI.initialize(I,e)}static isHandlingMimeForPasting(I){return BY.includes(I)}static paste(I,e){e.pasteEditor({mode:Tg.STAMP},{bitmapFile:I.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var I;return{type:"stamp",hasAltText:!!((I=this.altTextData)!=null&&I.altText)}}static computeTelemetryFinalData(I){const e=I.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(I=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:t}=this._uiManager;if(!t)throw new Error("No ML.");if(!await t.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:A,height:n}=I||this.copyCanvas(null,null,!0).imageData,l=await t.guess({name:"altText",request:{data:i,width:A,height:n,channels:i.length/(A*n)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const s=l.output;return await this.setGuessedAltText(s),e&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1}),s}remove(){var I;c(this,le)&&(V(this,CC,null),this._uiManager.imageManager.deleteId(c(this,le)),(I=c(this,kl))==null||I.remove(),V(this,kl,null),c(this,Xn)&&(clearTimeout(c(this,Xn)),V(this,Xn,null))),super.remove()}rebuild(){if(!this.parent){c(this,le)&&f(this,mI,Cy).call(this);return}super.rebuild(),this.div!==null&&(c(this,le)&&c(this,kl)===null&&f(this,mI,Cy).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(I){this._isDraggable=!0,I&&this.div.focus()}isEmpty(){return!(c(this,Vo)||c(this,CC)||c(this,Kl)||c(this,No)||c(this,le)||c(this,ec))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let I,e;return this._isCopy&&(I=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),c(this,ec)||(c(this,CC)?f(this,mI,ey).call(this):f(this,mI,Cy).call(this)),this._isCopy&&this._moveAfterPaste(I,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(I,e){const{id:t,bitmap:i}=this._uiManager.imageManager.getFromCanvas(I,e);e.remove(),t&&this._uiManager.imageManager.isValidId(t)&&(V(this,le,t),i&&V(this,CC,i),V(this,ec,!1),f(this,mI,ey).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;c(this,Xn)!==null&&clearTimeout(c(this,Xn)),V(this,Xn,setTimeout(()=>{V(this,Xn,null),f(this,mI,_R).call(this)},200))}copyCanvas(I,e,t=!1){I||(I=224);const{width:i,height:A}=c(this,CC),n=new _A;let l=c(this,CC),s=i,a=A,d=null;if(e){if(i>e||A>e){const M=Math.min(e/i,e/A);s=Math.floor(i*M),a=Math.floor(A*M)}d=document.createElement("canvas");const u=d.width=Math.ceil(s*n.sx),b=d.height=Math.ceil(a*n.sy);c(this,mi)||(l=f(this,mI,ty).call(this,u,b));const Z=d.getContext("2d");Z.filter=this._uiManager.hcmFilter;let w="white",G="#cfcfd8";this._uiManager.hcmFilter!=="none"?G="black":TTg.isDarkMode&&(w="#8f8f9d",G="#42414d");const B=15,p=B*n.sx,Y=B*n.sy,y=new OffscreenCanvas(p*2,Y*2),R=y.getContext("2d");R.fillStyle=w,R.fillRect(0,0,p*2,Y*2),R.fillStyle=G,R.fillRect(0,0,p,Y),R.fillRect(p,Y,p,Y),Z.fillStyle=Z.createPattern(y,"repeat"),Z.fillRect(0,0,u,b),Z.drawImage(l,0,0,l.width,l.height,0,0,u,b)}let m=null;if(t){let u,b;if(n.symmetric&&l.width<I&&l.height<I)u=l.width,b=l.height;else if(l=c(this,CC),i>I||A>I){const G=Math.min(I/i,I/A);u=Math.floor(i*G),b=Math.floor(A*G),c(this,mi)||(l=f(this,mI,ty).call(this,u,b))}const w=new OffscreenCanvas(u,b).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,u,b),m={width:u,height:b,data:w.getImageData(0,0,u,b).data}}return{canvas:d,width:s,height:a,imageData:m}}static async deserialize(I,e,t){var w;let i=null,A=!1;if(I instanceof ES){const{data:{rect:G,rotation:B,id:p,structParent:Y,popupRef:y,richText:R,contentsObj:M,creationDate:D,modificationDate:J},container:H,parent:{page:{pageNumber:z}},canvas:T}=I;let P,Ig;T?(delete I.canvas,{id:P,bitmap:Ig}=t.imageManager.getFromCanvas(H.id,T),T.remove()):(A=!0,I._hasNoCanvas=!0);const gg=((w=await e._structTree.getAriaAttributes(`${Qc}${p}`))==null?void 0:w.get("aria-label"))||"";i=I={annotationType:Tg.STAMP,bitmapId:P,bitmap:Ig,pageIndex:z-1,rect:G.slice(0),rotation:B,annotationElementId:p,id:p,deleted:!1,accessibilityData:{decorative:!1,altText:gg},isSvg:!1,structParent:Y,popupRef:y,richText:R,comment:(M==null?void 0:M.str)||null,creationDate:D,modificationDate:J}}const n=await super.deserialize(I,e,t),{rect:l,bitmap:s,bitmapUrl:a,bitmapId:d,isSvg:m,accessibilityData:u}=I;A?(t.addMissingCanvas(I.id,n),V(n,ec,!0)):d&&t.imageManager.isValidId(d)?(V(n,le,d),s&&V(n,CC,s)):V(n,Kl,a),V(n,mi,m);const[b,Z]=n.pageDimensions;return n.width=(l[2]-l[0])/b,n.height=(l[3]-l[1])/Z,u&&(n.altTextData=u),n._initialData=i,I.comment&&n.setCommentData(I),V(n,Em,!!i),n}serialize(I=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const t=Object.assign(super.serialize(I),{bitmapId:c(this,le),isSvg:c(this,mi)});if(this.addComment(t),I)return t.bitmapUrl=f(this,mI,iy).call(this,!0),t.accessibilityData=this.serializeAltText(!0),t.isCopy=!0,t;const{decorative:i,altText:A}=this.serializeAltText(!1);if(!i&&A&&(t.accessibilityData={type:"Figure",alt:A}),this.annotationElementId){const l=f(this,mI,QT).call(this,t);return l.isSame?null:(l.isSameAltText?delete t.accessibilityData:t.accessibilityData.structParent=this._initialData.structParent??-1,t.id=this.annotationElementId,delete t.bitmapId,t)}if(e===null)return t;e.stamps||(e.stamps=new Map);const n=c(this,mi)?(t.rect[2]-t.rect[0])*(t.rect[3]-t.rect[1]):null;if(!e.stamps.has(c(this,le)))e.stamps.set(c(this,le),{area:n,serialized:t}),t.bitmap=f(this,mI,iy).call(this,!1);else if(c(this,mi)){const l=e.stamps.get(c(this,le));n>l.area&&(l.area=n,l.serialized.bitmap.close(),l.serialized.bitmap=f(this,mI,iy).call(this,!1))}return t}renderAnnotationElement(I){return this.deleted?(I.hide(),null):(I.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}CC=new WeakMap,le=new WeakMap,Vo=new WeakMap,Kl=new WeakMap,No=new WeakMap,Um=new WeakMap,kl=new WeakMap,ec=new WeakMap,Xn=new WeakMap,mi=new WeakMap,Em=new WeakMap,mI=new WeakSet,TZ=function(I,e=!1){if(!I){this.remove();return}V(this,CC,I.bitmap),e||(V(this,le,I.id),V(this,mi,I.isSvg)),I.file&&V(this,Um,I.file.name),f(this,mI,ey).call(this)},vZ=function(){if(V(this,Vo,null),this._uiManager.enableWaiting(!1),!!c(this,kl)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,CC)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,CC)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Cy=function(){if(c(this,le)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,le)).then(t=>f(this,mI,TZ).call(this,t,!0)).finally(()=>f(this,mI,vZ).call(this));return}if(c(this,Kl)){const t=c(this,Kl);V(this,Kl,null),this._uiManager.enableWaiting(!0),V(this,Vo,this._uiManager.imageManager.getFromUrl(t).then(i=>f(this,mI,TZ).call(this,i)).finally(()=>f(this,mI,vZ).call(this)));return}if(c(this,No)){const t=c(this,No);V(this,No,null),this._uiManager.enableWaiting(!0),V(this,Vo,this._uiManager.imageManager.getFromFile(t).then(i=>f(this,mI,TZ).call(this,i)).finally(()=>f(this,mI,vZ).call(this)));return}const I=document.createElement("input");I.type="file",I.accept=BY.join(",");const e=this._uiManager._signal;V(this,Vo,new Promise(t=>{I.addEventListener("change",async()=>{if(!I.files||I.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(I.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),f(this,mI,TZ).call(this,i)}t()},{signal:e}),I.addEventListener("cancel",()=>{this.remove(),t()},{signal:e})}).finally(()=>f(this,mI,vZ).call(this))),I.click()},ey=function(){var s;const{div:I}=this;let{width:e,height:t}=c(this,CC);const[i,A]=this.pageDimensions,n=.75;if(this.width)e=this.width*i,t=this.height*A;else if(e>n*i||t>n*A){const a=Math.min(n*i/e,n*A/t);e*=a,t*=a}this._uiManager.enableWaiting(!1);const l=V(this,kl,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=e/i,this.height=t/A,this.setDims(),(s=this._initialOptions)!=null&&s.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(I.hidden=!1),f(this,mI,_R).call(this),c(this,Em)||(this.parent.addUndoableEditor(this),V(this,Em,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,Um)&&this.div.setAttribute("aria-description",c(this,Um)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},ty=function(I,e){const{width:t,height:i}=c(this,CC);let A=t,n=i,l=c(this,CC);for(;A>2*I||n>2*e;){const s=A,a=n;A>2*I&&(A=A>=16384?Math.floor(A/2)-1:Math.ceil(A/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));const d=new OffscreenCanvas(A,n);d.getContext("2d").drawImage(l,0,0,s,a,0,0,A,n),l=d.transferToImageBitmap()}return l},_R=function(){const[I,e]=this.parentDimensions,{width:t,height:i}=this,A=new _A,n=Math.ceil(t*I*A.sx),l=Math.ceil(i*e*A.sy),s=c(this,kl);if(!s||s.width===n&&s.height===l)return;s.width=n,s.height=l;const a=c(this,mi)?c(this,CC):f(this,mI,ty).call(this,n,l),d=s.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(a,0,0,a.width,a.height,0,0,n,l)},iy=function(I){if(I){if(c(this,mi)){const i=this._uiManager.imageManager.getSvgUrl(c(this,le));if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=c(this,CC),e.getContext("2d").drawImage(c(this,CC),0,0),e.toDataURL()}if(c(this,mi)){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*hs.PDF_TO_CSS_UNITS),A=Math.round(this.height*t*hs.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,A);return n.getContext("2d").drawImage(c(this,CC),0,0,c(this,CC).width,c(this,CC).height,0,0,i,A),n.transferToImageBitmap()}return structuredClone(c(this,CC))},QT=function(I){var n;const{pageIndex:e,accessibilityData:{altText:t}}=this._initialData,i=I.pageIndex===e,A=(((n=I.accessibilityData)==null?void 0:n.alt)||"")===t;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&A,isSameAltText:A}},sg(tV,"_type","stamp"),sg(tV,"_editorType",Tg.STAMP);const fA=class fA{constructor({uiManager:g,pageIndex:I,div:e,structTreeLayer:t,accessibilityManager:i,annotationLayer:A,drawLayer:n,textLayer:l,viewport:s,l10n:a}){X(this,LI);X(this,tc);X(this,Pm,!1);X(this,Mo,null);X(this,Ro,null);X(this,zl,null);X(this,Kt,new Map);X(this,Xo,!1);X(this,_m,!1);X(this,$m,!1);X(this,HA,null);X(this,Fl,null);X(this,se,null);X(this,Jl,null);X(this,Ho,null);X(this,qm,-1);X(this,Wg);const d=[...c(fA,fo).values()];if(!fA._initialized){fA._initialized=!0;for(const m of d)m.initialize(a,g)}g.registerEditorTypes(d),V(this,Wg,g),this.pageIndex=I,this.div=e,V(this,tc,i),V(this,Mo,A),this.viewport=s,V(this,se,l),this.drawLayer=n,this._structTree=t,c(this,Wg).addLayer(this)}get isEmpty(){return c(this,Kt).size===0}get isInvisible(){return this.isEmpty&&c(this,Wg).getMode()===Tg.NONE}updateToolbar(g){c(this,Wg).updateToolbar(g)}updateMode(g=c(this,Wg).getMode()){switch(f(this,LI,Ay).call(this),g){case Tg.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Tg.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Tg.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:I}=this.div;if(I.toggle("nonEditing",!1),g===Tg.POPUP)I.toggle("commentEditing",!0);else{I.toggle("commentEditing",!1);for(const e of c(fA,fo).values())I.toggle(`${e._type}Editing`,g===e._editorType)}this.div.hidden=!1}hasTextLayer(g){var I;return g===((I=c(this,se))==null?void 0:I.div)}setEditingState(g){c(this,Wg).setEditingState(g)}addCommands(g){c(this,Wg).addCommands(g)}cleanUndoStack(g){c(this,Wg).cleanUndoStack(g)}toggleDrawing(g=!1){this.div.classList.toggle("drawing",!g)}togglePointerEvents(g=!1){this.div.classList.toggle("disabled",!g)}toggleAnnotationLayerPointerEvents(g=!1){var I;(I=c(this,Mo))==null||I.togglePointerEvents(g)}async enable(){var e;V(this,$m,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(e=c(this,Ho))==null||e.abort(),V(this,Ho,null);const g=new Set;for(const t of c(this,LI,$R))t.enableEditing(),t.show(!0),t.annotationElementId&&(c(this,Wg).removeChangedExistingAnnotation(t),g.add(t.annotationElementId));const I=c(this,Mo);if(I)for(const t of I.getEditableAnnotations()){if(t.hide(),c(this,Wg).isDeletedAnnotationElement(t.data.id)||g.has(t.data.id))continue;const i=await this.deserialize(t);i&&(this.addOrRebuild(i),i.enableEditing())}V(this,$m,!1),c(this,Wg)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var t;if(V(this,_m,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),c(this,se)&&!c(this,Ho)){V(this,Ho,new AbortController);const i=c(this,Wg).combinedSignal(c(this,Ho));c(this,se).div.addEventListener("pointerdown",A=>{const{clientX:l,clientY:s,timeStamp:a}=A,d=c(this,qm);if(a-d>500){V(this,qm,a);return}V(this,qm,-1);const{classList:m}=this.div;m.toggle("getElements",!0);const u=document.elementsFromPoint(l,s);if(m.toggle("getElements",!1),!this.div.contains(u[0]))return;let b;const Z=new RegExp(`^${Ah}[0-9]+$`);for(const G of u)if(Z.test(G.id)){b=G.id;break}if(!b)return;const w=c(this,Kt).get(b);(w==null?void 0:w.annotationElementId)===null&&(A.stopPropagation(),A.preventDefault(),w.dblclick(A))},{signal:i,capture:!0})}const g=c(this,Mo),I=[];if(g){const i=new Map,A=new Map;for(const l of c(this,LI,$R)){if(l.disableEditing(),!l.annotationElementId){I.push(l);continue}if(l.serialize()!==null){i.set(l.annotationElementId,l);continue}else A.set(l.annotationElementId,l);(t=this.getEditableAnnotation(l.annotationElementId))==null||t.show(),l.remove()}const n=g.getEditableAnnotations();for(const l of n){const{id:s}=l.data;if(c(this,Wg).isDeletedAnnotationElement(s)){l.updateEdited({deleted:!0});continue}let a=A.get(s);if(a){a.resetAnnotationElement(l),a.show(!1),l.show();continue}a=i.get(s),a&&(c(this,Wg).addChangedExistingAnnotation(a),a.renderAnnotationElement(l)&&a.show(!1)),l.show()}}f(this,LI,Ay).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const i of c(fA,fo).values())e.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),g==null||g.updateFakeAnnotations(I),V(this,_m,!1)}getEditableAnnotation(g){var I;return((I=c(this,Mo))==null?void 0:I.getEditableAnnotation(g))||null}setActiveEditor(g){c(this,Wg).getActive()!==g&&c(this,Wg).setActiveEditor(g)}enableTextSelection(){var g;if(this.div.tabIndex=-1,(g=c(this,se))!=null&&g.div&&!c(this,Jl)){V(this,Jl,new AbortController);const I=c(this,Wg).combinedSignal(c(this,Jl));c(this,se).div.addEventListener("pointerdown",f(this,LI,UT).bind(this),{signal:I}),c(this,se).div.classList.add("highlighting")}}disableTextSelection(){var g;this.div.tabIndex=0,(g=c(this,se))!=null&&g.div&&c(this,Jl)&&(c(this,Jl).abort(),V(this,Jl,null),c(this,se).div.classList.remove("highlighting"))}enableClick(){if(c(this,Ro))return;V(this,Ro,new AbortController);const g=c(this,Wg).combinedSignal(c(this,Ro));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:g});const I=this.pointerup.bind(this);this.div.addEventListener("pointerup",I,{signal:g}),this.div.addEventListener("pointercancel",I,{signal:g})}disableClick(){var g;(g=c(this,Ro))==null||g.abort(),V(this,Ro,null)}attach(g){c(this,Kt).set(g.id,g);const{annotationElementId:I}=g;I&&c(this,Wg).isDeletedAnnotationElement(I)&&c(this,Wg).removeDeletedAnnotationElement(g)}detach(g){var I;c(this,Kt).delete(g.id),(I=c(this,tc))==null||I.removePointerInTextLayer(g.contentDiv),!c(this,_m)&&g.annotationElementId&&c(this,Wg).addDeletedAnnotationElement(g)}remove(g){this.detach(g),c(this,Wg).removeEditor(g),g.div.remove(),g.isAttachedToDOM=!1}changeParent(g){var I;g.parent!==this&&(g.parent&&g.annotationElementId&&(c(this,Wg).addDeletedAnnotationElement(g),xI.deleteAnnotationElement(g),g.annotationElementId=null),this.attach(g),(I=g.parent)==null||I.detach(g),g.setParent(this),g.div&&g.isAttachedToDOM&&(g.div.remove(),this.div.append(g.div)))}add(g){if(!(g.parent===this&&g.isAttachedToDOM)){if(this.changeParent(g),c(this,Wg).addEditor(g),this.attach(g),!g.isAttachedToDOM){const I=g.render();this.div.append(I),g.isAttachedToDOM=!0}g.fixAndSetPosition(),g.onceAdded(!c(this,$m)),c(this,Wg).addToAnnotationStorage(g),g._reportTelemetry(g.telemetryInitialData)}}moveEditorInDOM(g){var e;if(!g.isAttachedToDOM)return;const{activeElement:I}=document;g.div.contains(I)&&!c(this,zl)&&(g._focusEventsAllowed=!1,V(this,zl,setTimeout(()=>{V(this,zl,null),g.div.contains(document.activeElement)?g._focusEventsAllowed=!0:(g.div.addEventListener("focusin",()=>{g._focusEventsAllowed=!0},{once:!0,signal:c(this,Wg)._signal}),I.focus())},0))),g._structTreeParentId=(e=c(this,tc))==null?void 0:e.moveElementInDOM(this.div,g.div,g.contentDiv,!0)}addOrRebuild(g){g.needsToBeRebuilt()?(g.parent||(g.parent=this),g.rebuild(),g.show()):this.add(g)}addUndoableEditor(g){const I=()=>g._uiManager.rebuild(g),e=()=>{g.remove()};this.addCommands({cmd:I,undo:e,mustExec:!1})}getEditorByUID(g){for(const I of c(this,Kt).values())if(I.uid===g)return I;return null}getNextId(){return c(this,Wg).getId()}combinedSignal(g){return c(this,Wg).combinedSignal(g)}canCreateNewEmptyEditor(){var g;return(g=c(this,LI,kn))==null?void 0:g.canCreateNewEmptyEditor()}async pasteEditor(g,I){this.updateToolbar(g),await c(this,Wg).updateMode(g.mode);const{offsetX:e,offsetY:t}=f(this,LI,gX).call(this),i=this.getNextId(),A=f(this,LI,qR).call(this,{parent:this,id:i,x:e,y:t,uiManager:c(this,Wg),isCentered:!0,...I});A&&this.add(A)}async deserialize(g){var I;return await((I=c(fA,fo).get(g.annotationType??g.annotationEditorType))==null?void 0:I.deserialize(g,this,c(this,Wg)))||null}createAndAddNewEditor(g,I,e={}){const t=this.getNextId(),i=f(this,LI,qR).call(this,{parent:this,id:t,x:g.offsetX,y:g.offsetY,uiManager:c(this,Wg),isCentered:I,...e});return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(g={}){this.createAndAddNewEditor(f(this,LI,gX).call(this),!0,g)}setSelected(g){c(this,Wg).setSelected(g)}toggleSelected(g){c(this,Wg).toggleSelected(g)}unselect(g){c(this,Wg).unselect(g)}pointerup(g){var t;const{isMac:I}=de.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div||!c(this,Xo)||(V(this,Xo,!1),(t=c(this,LI,kn))!=null&&t.isDrawer&&c(this,LI,kn).supportMultipleDrawings))return;if(!c(this,Pm)){V(this,Pm,!0);return}const e=c(this,Wg).getMode();if(e===Tg.STAMP||e===Tg.SIGNATURE){c(this,Wg).unselectAll();return}this.createAndAddNewEditor(g,!1)}pointerdown(g){var t;if(c(this,Wg).getMode()===Tg.HIGHLIGHT&&this.enableTextSelection(),c(this,Xo)){V(this,Xo,!1);return}const{isMac:I}=de.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div)return;if(V(this,Xo,!0),(t=c(this,LI,kn))!=null&&t.isDrawer){this.startDrawingSession(g);return}const e=c(this,Wg).getActive();V(this,Pm,!e||e.isEmpty())}startDrawingSession(g){if(this.div.focus({preventScroll:!0}),c(this,HA)){c(this,LI,kn).startDrawing(this,c(this,Wg),!1,g);return}c(this,Wg).setCurrentDrawingSession(this),V(this,HA,new AbortController);const I=c(this,Wg).combinedSignal(c(this,HA));this.div.addEventListener("blur",({relatedTarget:e})=>{e&&!this.div.contains(e)&&(V(this,Fl,null),this.commitOrRemove())},{signal:I}),c(this,LI,kn).startDrawing(this,c(this,Wg),!1,g)}pause(g){if(g){const{activeElement:I}=document;this.div.contains(I)&&V(this,Fl,I);return}c(this,Fl)&&setTimeout(()=>{var I;(I=c(this,Fl))==null||I.focus(),V(this,Fl,null)},0)}endDrawingSession(g=!1){return c(this,HA)?(c(this,Wg).setCurrentDrawingSession(null),c(this,HA).abort(),V(this,HA,null),V(this,Fl,null),c(this,LI,kn).endDrawing(g)):null}findNewParent(g,I,e){const t=c(this,Wg).findParent(I,e);return t===null||t===this?!1:(t.changeParent(g),!0)}commitOrRemove(){return c(this,HA)?(this.endDrawingSession(),!0):!1}onScaleChanging(){c(this,HA)&&c(this,LI,kn).onScaleChangingWhenDrawing(this)}destroy(){var g,I;this.commitOrRemove(),((g=c(this,Wg).getActive())==null?void 0:g.parent)===this&&(c(this,Wg).commitOrRemove(),c(this,Wg).setActiveEditor(null)),c(this,zl)&&(clearTimeout(c(this,zl)),V(this,zl,null));for(const e of c(this,Kt).values())(I=c(this,tc))==null||I.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,c(this,Kt).clear(),c(this,Wg).removeLayer(this)}render({viewport:g}){this.viewport=g,ha(this.div,g);for(const I of c(this,Wg).getEditors(this.pageIndex))this.add(I),I.rebuild();this.updateMode()}update({viewport:g}){c(this,Wg).commitOrRemove(),f(this,LI,Ay).call(this);const I=this.viewport.rotation,e=g.rotation;if(this.viewport=g,ha(this.div,{rotation:e}),I!==e)for(const t of c(this,Kt).values())t.rotate(e)}get pageDimensions(){const{pageWidth:g,pageHeight:I}=this.viewport.rawDims;return[g,I]}get scale(){return c(this,Wg).viewParameters.realScale}};tc=new WeakMap,Pm=new WeakMap,Mo=new WeakMap,Ro=new WeakMap,zl=new WeakMap,Kt=new WeakMap,Xo=new WeakMap,_m=new WeakMap,$m=new WeakMap,HA=new WeakMap,Fl=new WeakMap,se=new WeakMap,Jl=new WeakMap,Ho=new WeakMap,qm=new WeakMap,Wg=new WeakMap,fo=new WeakMap,LI=new WeakSet,$R=function(){return c(this,Kt).size!==0?c(this,Kt).values():c(this,Wg).getEditors(this.pageIndex)},UT=function(g){c(this,Wg).unselectAll();const{target:I}=g;if(I===c(this,se).div||(I.getAttribute("role")==="img"||I.classList.contains("endOfContent"))&&c(this,se).div.contains(I)){const{isMac:e}=de.platform;if(g.button!==0||g.ctrlKey&&e)return;c(this,Wg).showAllEditors("highlight",!0,!0),c(this,se).div.classList.add("free"),this.toggleDrawing(),Vw.startHighlighting(this,c(this,Wg).direction==="ltr",{target:c(this,se).div,x:g.x,y:g.y}),c(this,se).div.addEventListener("pointerup",()=>{c(this,se).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,Wg)._signal}),g.preventDefault()}},kn=function(){return c(fA,fo).get(c(this,Wg).getMode())},qR=function(g){const I=c(this,LI,kn);return I?new I.prototype.constructor(g):null},gX=function(){const{x:g,y:I,width:e,height:t}=this.boundingClientRect,i=Math.max(0,g),A=Math.max(0,I),n=Math.min(window.innerWidth,g+e),l=Math.min(window.innerHeight,I+t),s=(i+n)/2-g,a=(A+l)/2-I,[d,m]=this.viewport.rotation%180===0?[s,a]:[a,s];return{offsetX:d,offsetY:m}},Ay=function(){for(const g of c(this,Kt).values())g.isEmpty()&&g.remove()},sg(fA,"_initialized",!1),X(fA,fo,new Map([PY,qY,tV,Vw,eV].map(g=>[g._editorType,g])));let iV=fA;const QC=class QC{constructor({pageIndex:g}){X(this,Hn);X(this,DA,null);X(this,at,new Map);X(this,ic,new Map);this.pageIndex=g}setParent(g){if(!c(this,DA)){V(this,DA,g);return}if(c(this,DA)!==g){if(c(this,at).size>0)for(const I of c(this,at).values())I.remove(),g.append(I);V(this,DA,g)}}static get _svgFactory(){return Jg(this,"_svgFactory",new pw)}draw(g,I=!1,e=!1){const t=PC(QC,lZ)._++,i=f(this,Hn,IX).call(this),A=QC._svgFactory.createElement("defs");i.append(A);const n=QC._svgFactory.createElement("path");A.append(n);const l=`path_p${this.pageIndex}_${t}`;n.setAttribute("id",l),n.setAttribute("vector-effect","non-scaling-stroke"),I&&c(this,ic).set(t,n);const s=e?f(this,Hn,PT).call(this,A,l):null,a=QC._svgFactory.createElement("use");return i.append(a),a.setAttribute("href",`#${l}`),this.updateProperties(i,g),c(this,at).set(t,i),{id:t,clipPathId:`url(#${s})`}}drawOutline(g,I){const e=PC(QC,lZ)._++,t=f(this,Hn,IX).call(this),i=QC._svgFactory.createElement("defs");t.append(i);const A=QC._svgFactory.createElement("path");i.append(A);const n=`path_p${this.pageIndex}_${e}`;A.setAttribute("id",n),A.setAttribute("vector-effect","non-scaling-stroke");let l;if(I){const d=QC._svgFactory.createElement("mask");i.append(d),l=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const m=QC._svgFactory.createElement("rect");d.append(m),m.setAttribute("width","1"),m.setAttribute("height","1"),m.setAttribute("fill","white");const u=QC._svgFactory.createElement("use");d.append(u),u.setAttribute("href",`#${n}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}const s=QC._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${n}`),l&&s.setAttribute("mask",`url(#${l})`);const a=s.cloneNode();return t.append(a),s.classList.add("mainOutline"),a.classList.add("secondaryOutline"),this.updateProperties(t,g),c(this,at).set(e,t),e}finalizeDraw(g,I){c(this,ic).delete(g),this.updateProperties(g,I)}updateProperties(g,I){var l;if(!I)return;const{root:e,bbox:t,rootClass:i,path:A}=I,n=typeof g=="number"?c(this,at).get(g):g;if(n){if(e&&f(this,Hn,CX).call(this,n,e),t&&f(l=QC,KB,ET).call(l,n,t),i){const{classList:s}=n;for(const[a,d]of Object.entries(i))s.toggle(a,d)}if(A){const a=n.firstElementChild.firstElementChild;f(this,Hn,CX).call(this,a,A)}}}updateParent(g,I){if(I===this)return;const e=c(this,at).get(g);e&&(c(I,DA).append(e),c(this,at).delete(g),c(I,at).set(g,e))}remove(g){c(this,ic).delete(g),c(this,DA)!==null&&(c(this,at).get(g).remove(),c(this,at).delete(g))}destroy(){V(this,DA,null);for(const g of c(this,at).values())g.remove();c(this,at).clear(),c(this,ic).clear()}};DA=new WeakMap,at=new WeakMap,ic=new WeakMap,lZ=new WeakMap,KB=new WeakSet,ET=function(g,[I,e,t,i]){const{style:A}=g;A.top=`${100*e}%`,A.left=`${100*I}%`,A.width=`${100*t}%`,A.height=`${100*i}%`},Hn=new WeakSet,IX=function(){const g=QC._svgFactory.create(1,1,!0);return c(this,DA).append(g),g.setAttribute("aria-hidden",!0),g},PT=function(g,I){const e=QC._svgFactory.createElement("clipPath");g.append(e);const t=`clip_${I}`;e.setAttribute("id",t),e.setAttribute("clipPathUnits","objectBoundingBox");const i=QC._svgFactory.createElement("use");return e.append(i),i.setAttribute("href",`#${I}`),i.classList.add("clip"),t},CX=function(g,I){for(const[e,t]of Object.entries(I))t===null?g.removeAttribute(e):g.setAttribute(e,t)},X(QC,KB),X(QC,lZ,0);let AV=QC;globalThis._pdfjsTestingUtils={HighlightOutliner:_Y},globalThis.pdfjsLib={AbortException:us,AnnotationEditorLayer:iV,AnnotationEditorParamsType:oI,AnnotationEditorType:Tg,AnnotationEditorUIManager:ba,AnnotationLayer:EY,AnnotationMode:ms,AnnotationType:fC,applyOpacity:jTg,build:_vg,ColorPicker:Ww,createValidAbsoluteUrl:ED,CSSConstants:vTg,DOMSVGFactory:pw,DrawLayer:AV,FeatureTest:de,fetchData:ah,findContrastColor:xTg,getDocument:TY,getFilenameFromUrl:kTg,getPdfFilenameFromUrl:zTg,getRGB:rh,getUuid:gS,getXfaPageViewport:JTg,GlobalWorkerOptions:qA,ImageKind:Iw,InvalidPDFException:ZY,isDataScheme:Aw,isPdfFile:nw,isValidExplicitDest:Ivg,MathClamp:gt,noContextMenu:yi,normalizeUnicode:DTg,OPS:nh,OutputScale:_A,PasswordResponses:yTg,PDFDataRangeTransport:TS,PDFDateString:lw,PDFWorker:wh,PermissionFlag:pTg,PixelsPerInch:hs,RenderingCancelledException:WY,renderRichText:lS,ResponseException:iw,setLayerDimensions:ha,shadow:Jg,SignatureExtractor:jn,stopEvent:mC,SupportedImageMimeTypes:BY,TextLayer:Gh,TouchManager:aw,updateUrlHash:PD,Util:wg,VerbosityLevel:Cw,version:Pvg,XfaLayer:CS};class wjg{constructor(){sg(this,"cache",{});sg(this,"cachePage",{})}setCache(g,I){this.cache[g]=I}getCache(g){return this.cache[g]}setPageCache(g,I){this.cachePage[g]=I}getPageCache(g){return this.cachePage[g]}}const wa=new wjg,Wjg=["src"],Wa=o.defineComponent({name:"PdfPreview",__name:"PdfPreview",props:{src:{},page:{}},setup(C,{expose:g}){qA.workerSrc=BTg;const I=C,e=o.reactive({isError:!1,rotate:0}),t=o.ref(null);let i,A=null;o.watch([()=>I.src,()=>I.page],()=>{i==null||i.disconnect(),a(),e.isError=!1,o.nextTick(()=>{s()})}),o.watch(()=>I.src,()=>{e.rotate=0});const n=async()=>{try{if(!t.value||!I.src)throw new Error("Canvas not found");A&&(A==null||A.cancel(),A=null);let d;const m=wa.getCache(I.src);if(m?d=m:(d=await TY(I.src).promise,wa.setCache(I.src,d)),!d)throw new Error("Pdf not found");const u=I.page??1,b=`${I.src}-${u}`,Z=wa.getPageCache(b);let w;Z?w=Z:(w=await d.getPage(u),wa.setPageCache(b,w));const G=t.value.getBoundingClientRect(),B=w.getViewport({scale:1}),p=G.width/B.width,Y=G.height/B.height,y=Math.min(p,Y),R=w.getViewport({scale:y,rotation:e.rotate}),M=t.value.getContext("2d");if(M===null)throw new Error("Context not found");t.value.width=R.width,t.value.height=R.height;const D=w.render({canvas:t.value,canvasContext:M,viewport:R});A=D,await D.promise}catch(d){if(d&&typeof d=="object"&&"name"in d&&(d==null?void 0:d.name)==="RenderingCancelledException")return;console.error(d),e.isError=!0}},l=async d=>{try{if(!t.value)return;const m=wa.getPageCache(`${I.src}-${I.page}`);if(!m)return;const u=t.value.getContext("2d");if(!u)return;const b=Math.round(d/90)*90;e.rotate+=b;const{width:Z,height:w}=t.value;u.clearRect(0,0,Z,w);const G=m.getViewport({scale:1,rotation:e.rotate});t.value.width=G.width,t.value.height=G.height;const B=m.render({canvas:t.value,canvasContext:u,viewport:G});A=B,await B.promise}catch(m){if(m&&typeof m=="object"&&"name"in m&&(m==null?void 0:m.name)==="RenderingCancelledException")return;console.error(m),e.isError=!0}},s=()=>{i=new IntersectionObserver((d,m)=>{d.forEach(u=>{u.isIntersecting&&(n(),m.unobserve(u.target))},{rootMargin:"50px"})}),t.value&&i.observe(t.value)},a=()=>{if(!t.value)return;const d=t.value.getContext("2d");d&&d.clearRect(0,0,t.value.width,t.value.height)};return g({clearCanvas:a,rotatePdf:l}),o.onMounted(()=>{s()}),(d,m)=>e.isError?(o.openBlock(),o.createElementBlock("img",{key:1,src:o.unref(Tn)},null,8,Wjg)):(o.openBlock(),o.createElementBlock("canvas",{key:0,ref_key:"canvas",ref:t},null,512))}});var nV=(C=>(C.slideTop="slide-top",C.slideLeft="slide-left",C.fadeAndScale="fade-and-scale",C.fade="fade",C))(nV||{});function AC(C,g=document.documentElement){for(const[I,e]of Object.entries(C))g.style.setProperty(I,String(e))}const Bjg=()=>{const C=o.ref(0),g=o.ref([]),I=o.ref(null),e=l=>{g.value.push(l),i(l),A()},t=()=>{g.value.pop(),n(),g.value.length?i(g.value[g.value.length-1]):I.value=null},i=l=>{I.value=l},A=()=>{C.value+=1},n=()=>{C.value>0&&(C.value-=1)};return{countOpenedModal:C,openedModals:g,lastOpenedModal:I,addOpenedModal:e,reduceOpenedModal:t,setLastOpenedModal:i,incrementCountModal:A,decrementCountModal:n}},pjg=["data-testid"],yjg=["data-testid"],Yjg=yg(o.defineComponent({__name:"Modal",props:{open:{type:Boolean},position:{default:"right"},width:{},height:{},dataTestid:{default:"Modal"}},emits:["close","unmounted"],setup(C,{expose:g,emit:I}){const{lastOpenedModal:e,addOpenedModal:t,reduceOpenedModal:i}=Bjg(),A=C,n=o.ref(null),l=o.useAttrs(),s=o.ref(!1),a=o.computed(()=>({width:A.width,height:A.height})),d=I;let m=0;const u=()=>{m=Date.now(),n.value&&(A.open?(n.value.showModal(),t(n.value)):b())},b=()=>{Date.now()-m<300||(i(),d("close"))},Z=()=>{var Y;(Y=n.value)==null||Y.close(),document.documentElement.focus(),B()},w=Y=>{Y.key==="Escape"&&e.value===n.value&&b()},G=()=>{if(document.querySelectorAll(".modal-yui-kit").length===1)return window.innerWidth-document.documentElement.clientWidth;{const y=document.body.style.paddingRight;return Number(y.replace(/\D/g,""))||0}},B=()=>{document.querySelectorAll(".modal-yui-kit").length===0&&AC({overflow:"","padding-right":""},document.body)},p=Y=>{Y.target===n.value&&b()};return g({closeDialog:Z}),o.onMounted(()=>{o.watchEffect(()=>{A.open!==s.value&&(u(),s.value=A.open)}),n.value&&n.value.addEventListener("cancel",y=>{y.preventDefault()});const Y=G();AC({overflow:"hidden","padding-right":`${Y}px`},document.body),document.addEventListener("keydown",w)}),o.onUnmounted(()=>{B(),document.removeEventListener("keydown",w),d("unmounted")}),(Y,y)=>(o.openBlock(),o.createElementBlock("dialog",o.mergeProps({ref_key:"dialog",ref:n},o.unref(l),{class:["modal-yui-kit",`modal-yui-kit_${A.position}`],"data-testid":A.dataTestid,onClick:o.withModifiers(p,["self","left"])}),[o.createElementVNode("div",{class:"modal-yui-kit__modal-content",style:o.normalizeStyle(a.value),"data-testid":`${A.dataTestid}-ModalContent`},[o.renderSlot(Y.$slots,"default",{},void 0,!0)],12,yjg)],16,pjg))}}),[["__scopeId","data-v-58136e08"]]),yh=yg(o.defineComponent({__name:"ModalAnimated",props:{animateType:{},open:{type:Boolean},position:{default:"right"},width:{},height:{},dataTestid:{default:"Modal"}},emits:["close","unmounted","end-animation"],setup(C,{emit:g}){const I=C,e=g,t=o.computed(()=>I.animateType===nV.fade?"fade":I.position==="bottom"?"slide-bottom":I.position==="right"?"slide-left":"fade-and-scale"),i=o.ref(null),A=o.reactive({function:()=>{}}),n=()=>{d()},l=()=>{e("unmounted")},s=()=>{d()},a=()=>{A.function(),e("end-animation")},d=()=>{var u;i.value&&(A.function=(u=i.value)==null?void 0:u.closeDialog)},m=()=>{d(),e("close")};return(u,b)=>(o.openBlock(),o.createBlock(o.Transition,{name:t.value,onAfterLeave:a,onBeforeLeave:s,onAfterEnter:n},{default:o.withCtx(()=>[I.open?(o.openBlock(),o.createBlock(Yjg,{key:0,ref_key:"modalRef",ref:i,open:I.open,position:I.position,width:I.width,height:I.height,"data-testid":I.dataTestid,onClose:m,onUnmounted:l},{default:o.withCtx(()=>[o.renderSlot(u.$slots,"default",{},void 0,!0)]),_:3},8,["open","position","width","height","data-testid"])):o.createCommentVNode("",!0)]),_:3},8,["name"]))}}),[["__scopeId","data-v-6c0d942a"]]),$S=(C,g=window)=>{const I=C.getBoundingClientRect();if(g instanceof Window){const e=window.innerWidth,t=window.innerHeight;return I.top<t&&I.bottom>0&&I.left<e&&I.right>0}else{const e=g.getBoundingClientRect();return I.top<e.bottom&&I.bottom>e.top&&I.left<e.right&&I.right>e.left}},lV=(C,g=null)=>{if(!C)return;(g?$S(C,g):$S(C))||C.scrollIntoView({behavior:"smooth",block:"nearest"})},Vjg=o.defineComponent({name:"BaseSlider",__name:"BaseSlider",props:{activeIndex:{default:0}},setup(C,{expose:g}){const I=C,e=o.reactive({children:null,activeIndex:I.activeIndex}),t=o.ref(null),i=o.ref(null);o.watch(()=>I.activeIndex,()=>{A(I.activeIndex)});const A=a=>{if(!t.value||!i.value)return;const d=[...t.value.children];a>d.length-1||a<0||(lV(d[a],i.value),e.activeIndex=a)},n=()=>{o.nextTick(()=>{!e.children||!i.value||lV(e.children[e.activeIndex],i.value)})},l=()=>(A(e.activeIndex+1),e.activeIndex),s=()=>(A(e.activeIndex-1),e.activeIndex);return o.onMounted(()=>{!t.value||!i.value||(e.children=[...t.value.children])}),g({shiftPosition:A,nextSlide:l,prevSlide:s,initScroll:n}),(a,d)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"sliderRef",ref:i,class:"base-slider"},[o.createElementVNode("div",{ref_key:"contentRef",ref:t,class:"base-slider__content"},[o.renderSlot(a.$slots,"default")],512)],512))}}),Njg={class:"base-slide__content"},Mjg=o.defineComponent({name:"BaseSlide",__name:"BaseSlide",props:{isActive:{type:Boolean}},setup(C){const g=C,I=o.computed(()=>[{"base-slide_active":g.isActive}]);return(e,t)=>(o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["base-slide",I.value])},[o.createElementVNode("div",Njg,[o.renderSlot(e.$slots,"default")])],2))}}),qS=C=>{if(!C)return null;const g=C.split("?")[0],I=/\.\w+$/,e=g.match(I);return e?e[0].replace(".",""):null},sV=C=>{if(!C)return!1;if(C.startsWith("data:image/"))return!0;const g=qS(C);return g?Object.values(th).includes(g.toLowerCase()):!1},Rjg=async(C,g="file")=>{const e=await(await fetch(C)).blob(),t=window.URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download=g,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(t)};var g9={exports:{}};(function(C,g){(function(e,t){C.exports=t()})(window,function(){return function(I){var e={};function t(i){if(e[i])return e[i].exports;var A=e[i]={i,l:!1,exports:{}};return I[i].call(A.exports,A,A.exports,t),A.l=!0,A.exports}return t.m=I,t.c=e,t.d=function(i,A,n){t.o(i,A)||Object.defineProperty(i,A,{enumerable:!0,get:n})},t.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},t.t=function(i,A){if(A&1&&(i=t(i)),A&8||A&4&&typeof i=="object"&&i&&i.__esModule)return i;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:i}),A&2&&typeof i!="string")for(var l in i)t.d(n,l,(function(s){return i[s]}).bind(null,l));return n},t.n=function(i){var A=i&&i.__esModule?function(){return i.default}:function(){return i};return t.d(A,"a",A),A},t.o=function(i,A){return Object.prototype.hasOwnProperty.call(i,A)},t.p="",t(t.s=0)}({"./src/index.js":function(I,e,t){t.r(e),t("./src/sass/index.scss");var i=t("./src/js/init.js"),A=i.default.init;typeof window<"u"&&(window.printJS=A),e.default=A},"./src/js/browser.js":function(I,e,t){t.r(e);var i={isFirefox:function(){return typeof InstallTrigger<"u"},isIE:function(){return navigator.userAgent.indexOf("MSIE")!==-1||!!document.documentMode},isEdge:function(){return!i.isIE()&&!!window.StyleMedia},isChrome:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window;return!!n.chrome},isSafari:function(){return Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0||navigator.userAgent.toLowerCase().indexOf("safari")!==-1},isIOSChrome:function(){return navigator.userAgent.toLowerCase().indexOf("crios")!==-1}};e.default=i},"./src/js/functions.js":function(I,e,t){t.r(e),t.d(e,"addWrapper",function(){return l}),t.d(e,"capitalizePrint",function(){return s}),t.d(e,"collectStyles",function(){return a}),t.d(e,"addHeader",function(){return m}),t.d(e,"cleanUp",function(){return u}),t.d(e,"isRawHTML",function(){return b});var i=t("./src/js/modal.js"),A=t("./src/js/browser.js");function n(Z){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?n=function(G){return typeof G}:n=function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},n(Z)}function l(Z,w){var G="font-family:"+w.font+" !important; font-size: "+w.font_size+" !important; width:100%;";return'<div style="'+G+'">'+Z+"</div>"}function s(Z){return Z.charAt(0).toUpperCase()+Z.slice(1)}function a(Z,w){for(var G=document.defaultView||window,B="",p=G.getComputedStyle(Z,""),Y=0;Y<p.length;Y++)(w.targetStyles.indexOf("*")!==-1||w.targetStyle.indexOf(p[Y])!==-1||d(w.targetStyles,p[Y]))&&p.getPropertyValue(p[Y])&&(B+=p[Y]+":"+p.getPropertyValue(p[Y])+";");return B+="max-width: "+w.maxWidth+"px !important; font-size: "+w.font_size+" !important;",B}function d(Z,w){for(var G=0;G<Z.length;G++)if(n(w)==="object"&&w.indexOf(Z[G])!==-1)return!0;return!1}function m(Z,w){var G=document.createElement("div");if(b(w.header))G.innerHTML=w.header;else{var B=document.createElement("h1"),p=document.createTextNode(w.header);B.appendChild(p),B.setAttribute("style",w.headerStyle),G.appendChild(B)}Z.insertBefore(G,Z.childNodes[0])}function u(Z){Z.showModal&&i.default.close(),Z.onLoadingEnd&&Z.onLoadingEnd(),(Z.showModal||Z.onLoadingStart)&&window.URL.revokeObjectURL(Z.printable);var w="mouseover";(A.default.isChrome()||A.default.isFirefox())&&(w="focus");var G=function B(){window.removeEventListener(w,B),Z.onPrintDialogClose();var p=document.getElementById(Z.frameId);p&&p.remove()};window.addEventListener(w,G)}function b(Z){var w=new RegExp("<([A-Za-z][A-Za-z0-9]*)\\b[^>]*>(.*?)</\\1>");return w.test(Z)}},"./src/js/html.js":function(I,e,t){t.r(e);var i=t("./src/js/functions.js"),A=t("./src/js/print.js");function n(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?n=function(m){return typeof m}:n=function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},n(a)}e.default={print:function(d,m){var u=s(d.printable)?d.printable:document.getElementById(d.printable);if(!u){window.console.error("Invalid HTML element id: "+d.printable);return}d.printableElement=l(u,d),d.header&&Object(i.addHeader)(d.printableElement,d),A.default.send(d,m)}};function l(a,d){for(var m=a.cloneNode(),u=Array.prototype.slice.call(a.childNodes),b=0;b<u.length;b++)if(d.ignoreElements.indexOf(u[b].id)===-1){var Z=l(u[b],d);m.appendChild(Z)}switch(d.scanStyles&&a.nodeType===1&&m.setAttribute("style",Object(i.collectStyles)(a,d)),a.tagName){case"SELECT":m.value=a.value;break;case"CANVAS":m.getContext("2d").drawImage(a,0,0);break}return m}function s(a){return n(a)==="object"&&a&&(a instanceof HTMLElement||a.nodeType===1)}},"./src/js/image.js":function(I,e,t){t.r(e);var i=t("./src/js/functions.js"),A=t("./src/js/print.js"),n=t("./src/js/browser.js");e.default={print:function(s,a){s.printable.constructor!==Array&&(s.printable=[s.printable]),s.printableElement=document.createElement("div"),s.printable.forEach(function(d){var m=document.createElement("img");if(m.setAttribute("style",s.imageStyle),m.src=d,n.default.isFirefox()){var u=m.src;m.src=u}var b=document.createElement("div");b.appendChild(m),s.printableElement.appendChild(b)}),s.header&&Object(i.addHeader)(s.printableElement,s),A.default.send(s,a)}}},"./src/js/init.js":function(I,e,t){t.r(e);var i=t("./src/js/browser.js"),A=t("./src/js/modal.js"),n=t("./src/js/pdf.js"),l=t("./src/js/html.js"),s=t("./src/js/raw-html.js"),a=t("./src/js/image.js"),d=t("./src/js/json.js");function m(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?m=function(w){return typeof w}:m=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},m(b)}var u=["pdf","html","image","json","raw-html"];e.default={init:function(){var Z={printable:null,fallbackPrintable:null,type:"pdf",header:null,headerStyle:"font-weight: 300;",maxWidth:800,properties:null,gridHeaderStyle:"font-weight: bold; padding: 5px; border: 1px solid #dddddd;",gridStyle:"border: 1px solid lightgray; margin-bottom: -1px;",showModal:!1,onError:function(R){throw R},onLoadingStart:null,onLoadingEnd:null,onPrintDialogClose:function(){},onIncompatibleBrowser:function(){},modalMessage:"Retrieving Document...",frameId:"printJS",printableElement:null,documentTitle:"Document",targetStyle:["clear","display","width","min-width","height","min-height","max-height"],targetStyles:["border","box","break","text-decoration"],ignoreElements:[],repeatTableHeader:!0,css:null,style:null,scanStyles:!0,base64:!1,onPdfOpen:null,font:"TimesNewRoman",font_size:"12pt",honorMarginPadding:!0,honorColor:!1,imageStyle:"max-width: 100%;"},w=arguments[0];if(w===void 0)throw new Error("printJS expects at least 1 attribute.");switch(m(w)){case"string":Z.printable=encodeURI(w),Z.fallbackPrintable=Z.printable,Z.type=arguments[1]||Z.type;break;case"object":Z.printable=w.printable,Z.fallbackPrintable=typeof w.fallbackPrintable<"u"?w.fallbackPrintable:Z.printable,Z.fallbackPrintable=Z.base64?"data:application/pdf;base64,".concat(Z.fallbackPrintable):Z.fallbackPrintable;for(var G in Z)G==="printable"||G==="fallbackPrintable"||(Z[G]=typeof w[G]<"u"?w[G]:Z[G]);break;default:throw new Error('Unexpected argument type! Expected "string" or "object", got '+m(w))}if(!Z.printable)throw new Error("Missing printable information.");if(!Z.type||typeof Z.type!="string"||u.indexOf(Z.type.toLowerCase())===-1)throw new Error("Invalid print type. Available types are: pdf, html, image and json.");Z.showModal&&A.default.show(Z),Z.onLoadingStart&&Z.onLoadingStart();var B=document.getElementById(Z.frameId);B&&B.parentNode.removeChild(B);var p=document.createElement("iframe");switch(i.default.isFirefox()?p.setAttribute("style","width: 1px; height: 100px; position: fixed; left: 0; top: 0; opacity: 0; border-width: 0; margin: 0; padding: 0"):p.setAttribute("style","visibility: hidden; height: 0; width: 0; position: absolute; border: 0"),p.setAttribute("id",Z.frameId),Z.type!=="pdf"&&(p.srcdoc="<html><head><title>"+Z.documentTitle+"</title>",Z.css&&(Array.isArray(Z.css)||(Z.css=[Z.css]),Z.css.forEach(function(y){p.srcdoc+='<link rel="stylesheet" href="'+y+'">'})),p.srcdoc+="</head><body></body></html>"),Z.type){case"pdf":if(i.default.isIE())try{console.info("Print.js doesn't support PDF printing in Internet Explorer.");var Y=window.open(Z.fallbackPrintable,"_blank");Y.focus(),Z.onIncompatibleBrowser()}catch(y){Z.onError(y)}finally{Z.showModal&&A.default.close(),Z.onLoadingEnd&&Z.onLoadingEnd()}else n.default.print(Z,p);break;case"image":a.default.print(Z,p);break;case"html":l.default.print(Z,p);break;case"raw-html":s.default.print(Z,p);break;case"json":d.default.print(Z,p);break}}}},"./src/js/json.js":function(I,e,t){t.r(e);var i=t("./src/js/functions.js"),A=t("./src/js/print.js");function n(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?n=function(d){return typeof d}:n=function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},n(s)}e.default={print:function(a,d){if(n(a.printable)!=="object")throw new Error("Invalid javascript data object (JSON).");if(typeof a.repeatTableHeader!="boolean")throw new Error("Invalid value for repeatTableHeader attribute (JSON).");if(!a.properties||!Array.isArray(a.properties))throw new Error("Invalid properties array for your JSON data.");a.properties=a.properties.map(function(m){return{field:n(m)==="object"?m.field:m,displayName:n(m)==="object"?m.displayName:m,columnSize:n(m)==="object"&&m.columnSize?m.columnSize+";":100/a.properties.length+"%;"}}),a.printableElement=document.createElement("div"),a.header&&Object(i.addHeader)(a.printableElement,a),a.printableElement.innerHTML+=l(a),A.default.send(a,d)}};function l(s){var a=s.printable,d=s.properties,m='<table style="border-collapse: collapse; width: 100%;">';s.repeatTableHeader&&(m+="<thead>"),m+="<tr>";for(var u=0;u<d.length;u++)m+='<th style="width:'+d[u].columnSize+";"+s.gridHeaderStyle+'">'+Object(i.capitalizePrint)(d[u].displayName)+"</th>";m+="</tr>",s.repeatTableHeader&&(m+="</thead>"),m+="<tbody>";for(var b=0;b<a.length;b++){m+="<tr>";for(var Z=0;Z<d.length;Z++){var w=a[b],G=d[Z].field.split(".");if(G.length>1)for(var B=0;B<G.length;B++)w=w[G[B]];else w=w[d[Z].field];m+='<td style="width:'+d[Z].columnSize+s.gridStyle+'">'+w+"</td>"}m+="</tr>"}return m+="</tbody></table>",m}},"./src/js/modal.js":function(I,e,t){t.r(e);var i={show:function(n){var l="font-family:sans-serif; display:table; text-align:center; font-weight:300; font-size:30px; left:0; top:0;position:fixed; z-index: 9990;color: #0460B5; width: 100%; height: 100%; background-color:rgba(255,255,255,.9);transition: opacity .3s ease;",s=document.createElement("div");s.setAttribute("style",l),s.setAttribute("id","printJS-Modal");var a=document.createElement("div");a.setAttribute("style","display:table-cell; vertical-align:middle; padding-bottom:100px;");var d=document.createElement("div");d.setAttribute("class","printClose"),d.setAttribute("id","printClose"),a.appendChild(d);var m=document.createElement("span");m.setAttribute("class","printSpinner"),a.appendChild(m);var u=document.createTextNode(n.modalMessage);a.appendChild(u),s.appendChild(a),document.getElementsByTagName("body")[0].appendChild(s),document.getElementById("printClose").addEventListener("click",function(){i.close()})},close:function(){var n=document.getElementById("printJS-Modal");n&&n.parentNode.removeChild(n)}};e.default=i},"./src/js/pdf.js":function(I,e,t){t.r(e);var i=t("./src/js/print.js"),A=t("./src/js/functions.js");e.default={print:function(s,a){if(s.base64){var d=Uint8Array.from(atob(s.printable),function(u){return u.charCodeAt(0)});n(s,a,d);return}s.printable=/^(blob|http|\/\/)/i.test(s.printable)?s.printable:window.location.origin+(s.printable.charAt(0)!=="/"?"/"+s.printable:s.printable);var m=new window.XMLHttpRequest;m.responseType="arraybuffer",m.addEventListener("error",function(){Object(A.cleanUp)(s),s.onError(m.statusText,m)}),m.addEventListener("load",function(){if([200,201].indexOf(m.status)===-1){Object(A.cleanUp)(s),s.onError(m.statusText,m);return}n(s,a,m.response)}),m.open("GET",s.printable,!0),m.send()}};function n(l,s,a){var d=new window.Blob([a],{type:"application/pdf"});d=window.URL.createObjectURL(d),s.setAttribute("src",d),i.default.send(l,s)}},"./src/js/print.js":function(I,e,t){t.r(e);var i=t("./src/js/browser.js"),A=t("./src/js/functions.js"),n={send:function(m,u){document.getElementsByTagName("body")[0].appendChild(u);var b=document.getElementById(m.frameId);b.onload=function(){if(m.type==="pdf"){i.default.isFirefox()?setTimeout(function(){return l(b,m)},1e3):l(b,m);return}var Z=b.contentWindow||b.contentDocument;if(Z.document&&(Z=Z.document),Z.body.appendChild(m.printableElement),m.type!=="pdf"&&m.style){var w=document.createElement("style");w.innerHTML=m.style,Z.head.appendChild(w)}var G=Z.getElementsByTagName("img");G.length>0?s(Array.from(G)).then(function(){return l(b,m)}):l(b,m)}}};function l(d,m){try{if(d.focus(),i.default.isEdge()||i.default.isIE())try{d.contentWindow.document.execCommand("print",!1,null)}catch{d.contentWindow.print()}else d.contentWindow.print()}catch(u){m.onError(u)}finally{i.default.isFirefox()&&(d.style.visibility="hidden",d.style.left="-1px"),Object(A.cleanUp)(m)}}function s(d){var m=d.map(function(u){if(u.src&&u.src!==window.location.href)return a(u)});return Promise.all(m)}function a(d){return new Promise(function(m){var u=function b(){!d||typeof d.naturalWidth>"u"||d.naturalWidth===0||!d.complete?setTimeout(b,500):m()};u()})}e.default=n},"./src/js/raw-html.js":function(I,e,t){t.r(e);var i=t("./src/js/print.js");e.default={print:function(n,l){n.printableElement=document.createElement("div"),n.printableElement.setAttribute("style","width:100%"),n.printableElement.innerHTML=n.printable,i.default.send(n,l)}}},"./src/sass/index.scss":function(I,e,t){},0:function(I,e,t){I.exports=t("./src/index.js")}}).default})})(g9);var Xjg=g9.exports;const Hjg=jLg(Xjg),Yh=C=>{if(!C)return!1;const g=qS(C);return g?Object.values(ih).includes(g):!1},fjg=["src"],Vh=o.defineComponent({name:"VideoPreview",__name:"VideoPreview",props:{src:{}},emits:["error"],setup(C,{emit:g}){const I=C,e=g,t=o.reactive({isError:!1});o.watch(()=>I.src,()=>{t.isError=!1,o.nextTick(()=>{A()})});const i=o.ref(null),A=async()=>{var n;try{if(!i.value||!I.src)return;const l=document.createElement("video");l.muted=!0,l.preload="metadata";const s=await fetch(I.src);if(!s.ok)throw new Error("Failed to fetch video");const a=new Blob([await s.arrayBuffer()]);l.src=URL.createObjectURL(a);const d=(n=i==null?void 0:i.value)==null?void 0:n.getContext("2d");if(!d)return;l.addEventListener("loadeddata",()=>{l.currentTime=0}),l.addEventListener("seeked",()=>{var m,u;i.value&&d.drawImage(l,0,0,(m=i.value)==null?void 0:m.width,(u=i.value)==null?void 0:u.height)}),l.addEventListener("error",m=>{t.isError=!0,e("error",m)})}catch{e("error",new Event("error")),t.isError=!0}};return o.onMounted(()=>{o.nextTick(()=>{A()})}),(n,l)=>t.isError?(o.openBlock(),o.createElementBlock("img",{key:1,src:o.unref(Tn)},null,8,fjg)):(o.openBlock(),o.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:i,class:"video-preview"},null,512))}}),Djg=["src"],Xw=o.defineComponent({name:"ImagePreview",__name:"ImagePreview",props:{src:{}},emits:["error"],setup(C,{expose:g,emit:I}){const e=C,t=I,i=o.reactive({isError:!1,rotate:0});o.watch(()=>e.src,()=>{i.isError=!1,i.rotate=0,o.nextTick(()=>{n()})});const A=o.ref(null),n=async()=>{try{if(!A.value||!e.src)return;const s=new Image;s.src=e.src,s.addEventListener("load",()=>{var Z;if(!A.value)return;const a=(Z=A.value)==null?void 0:Z.getContext("2d");if(!a)return;const d=s.width,m=s.height;let u=d,b=m;i.rotate%180!==0&&(u=m,b=d),A.value.width=u,A.value.height=b,a.save(),a.clearRect(0,0,u,b),a.translate(u/2,b/2),a.rotate(i.rotate*Math.PI/180),a.drawImage(s,-d/2,-m/2,d,m),a.restore()}),s.addEventListener("error",a=>{i.isError=!0,t("error",a)})}catch{t("error",new Event("error")),i.isError=!0}},l=async s=>{const a=Math.round(s/90)*90;i.rotate+=a,o.nextTick(()=>{n()})};return o.onMounted(()=>{o.nextTick(()=>{n()})}),g({rotateImage:l}),(s,a)=>i.isError?(o.openBlock(),o.createElementBlock("img",{key:1,src:o.unref(Tn)},null,8,Djg)):(o.openBlock(),o.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:A,class:"image-preview"},null,512))}}),bs=C=>C?C instanceof File?C.type==="application/pdf":nw(C):!1,Sjg={ref:"contentRef",class:"slider-modal__content"},Kjg=["onClick"],kjg={class:"slider-modal__side-bar-count"},zjg=["data-testid"],Fjg=["src"],Jjg=["src"],Ljg={class:"slider-modal__bottom"},Tjg={class:"slider-modal__nav-block"},vjg=["disabled"],jjg=["src","alt"],xjg=["src"],Ojg=["disabled"],Qjg={class:"slider-modal__nav-block"},Ujg={class:"slider-modal__sub-nav"},Ejg=["disabled"],Pjg=["disabled"],_jg=["disabled"],$jg={class:"slider-modal__sub-nav"},qjg=["disabled"],gxg=["disabled"],Hw=yg(o.defineComponent({name:"SliderModal",__name:"SliderModal",props:{dataTestid:{default:"SliderModal"},animateType:{},open:{type:Boolean},position:{},width:{},height:{},items:{},defaultIndex:{default:0}},emits:["close","unmounted","end-animation"],setup(C){const g=C,I=o.reactive({defaultIndex:g.defaultIndex,file:g.items[g.defaultIndex],sideBarItems:[],sideBarIndex:0,sideBarLength:0,isErrorFile:!1,zoomValue:1}),e=o.ref(null),t=o.ref(null),i=o.ref(null),A=o.ref(null),n=o.ref(null),l=o.computed(()=>I.defaultIndex===0),s=o.computed(()=>I.defaultIndex===g.items.length-1),a=o.computed(()=>{var q;let x=!I.file||I.isErrorFile;return x=Yh((q=I.file)==null?void 0:q.path)||x,x}),d=o.computed(()=>{var q;let x=!I.file||I.isErrorFile;return x=Yh((q=I.file)==null?void 0:q.path)||x,x}),m=o.computed(()=>!I.file||I.isErrorFile),u=o.computed(()=>{var q;let x=!I.file||I.isErrorFile;return x=Yh((q=I.file)==null?void 0:q.path)||x,x});o.watch([()=>g.items,()=>g.defaultIndex],()=>{I.file=g.items[g.defaultIndex??0],I.defaultIndex=g.defaultIndex??0}),o.watch([()=>I.file,()=>g.open],()=>{if(!g.open){Q(),I.file=null;return}I.zoomValue=1,I.file||(I.file=g.items[g.defaultIndex??0]),I.isErrorFile=!1,T()}),o.watch(()=>g.open,()=>{g.open&&(o.nextTick(()=>{A.value&&A.value.initScroll()}),I.defaultIndex=g.defaultIndex??0)}),o.watch(()=>I.sideBarIndex,()=>{P()});const b=x=>{H(x)},Z=x=>{I.sideBarIndex=x},w=x=>{z(x.deltaY)},G=()=>{J(!0)},B=()=>{J(!1)},p=()=>{i.value&&i.value.rotatePdf(-90),n.value&&n.value.rotateImage(-90)},Y=()=>{var Dg,AI,Hg;if(!((Dg=I.file)!=null&&Dg.path))return;let x="pdf",q="",cg="";sV((AI=I.file)==null?void 0:AI.path)&&(x="image",q=`
1326
+ `)){const e=document.createElement("div");e.append(I?document.createTextNode(I):document.createElement("br")),this.editorDiv.append(e)}},mT=function(){return c(this,Ai).replaceAll(" "," ")},JR=function(I){return I.replaceAll(" "," ")},uT=function(I){const{value:e,fontSize:t,color:i,pageIndex:A}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||I.value!==e||I.fontSize!==t||I.color.some((n,l)=>n!==i[l])||I.pageIndex!==A},X(PI,Hl),sg(PI,"_freeTextDefaultContent",""),sg(PI,"_internalPadding",0),sg(PI,"_defaultColor",null),sg(PI,"_defaultFontSize",10),sg(PI,"_type","freetext"),sg(PI,"_editorType",Tg.FREETEXT);let PY=PI;class Zg{toSVGPath(){kI("Abstract method `toSVGPath` must be implemented.")}get box(){kI("Abstract getter `box` must be implemented.")}serialize(g,I){kI("Abstract method `serialize` must be implemented.")}static _rescale(g,I,e,t,i,A){A||(A=new Float32Array(g.length));for(let n=0,l=g.length;n<l;n+=2)A[n]=I+g[n]*t,A[n+1]=e+g[n+1]*i;return A}static _rescaleAndSwap(g,I,e,t,i,A){A||(A=new Float32Array(g.length));for(let n=0,l=g.length;n<l;n+=2)A[n]=I+g[n+1]*t,A[n+1]=e+g[n]*i;return A}static _translate(g,I,e,t){t||(t=new Float32Array(g.length));for(let i=0,A=g.length;i<A;i+=2)t[i]=I+g[i],t[i+1]=e+g[i+1];return t}static svgRound(g){return Math.round(g*1e4)}static _normalizePoint(g,I,e,t,i){switch(i){case 90:return[1-I/e,g/t];case 180:return[1-g/e,1-I/t];case 270:return[I/e,1-g/t];default:return[g/e,I/t]}}static _normalizePagePoint(g,I,e){switch(e){case 90:return[1-I,g];case 180:return[1-g,1-I];case 270:return[I,1-g];default:return[g,I]}}static createBezierPoints(g,I,e,t,i,A){return[(g+5*e)/6,(I+5*t)/6,(5*e+i)/6,(5*t+A)/6,(e+i)/2,(t+A)/2]}}sg(Zg,"PRECISION",1e-4);const fl=class fl{constructor({x:g,y:I},e,t,i,A,n=0){X(this,OC);X(this,li);X(this,MA,[]);X(this,Hm);X(this,fm);X(this,Yn,[]);X(this,CI,new Float32Array(18));X(this,Td);X(this,vd);X(this,Ob);X(this,Qb);X(this,Dm);X(this,Sm);X(this,Bo,[]);V(this,li,e),V(this,Sm,i*t),V(this,fm,A),c(this,CI).set([NaN,NaN,NaN,NaN,g,I],6),V(this,Hm,n),V(this,Qb,c(fl,Ub)*t),V(this,Ob,c(fl,fB)*t),V(this,Dm,t),c(this,Bo).push(g,I)}isEmpty(){return isNaN(c(this,CI)[8])}add({x:g,y:I}){var J;V(this,Td,g),V(this,vd,I);const[e,t,i,A]=c(this,li);let[n,l,s,a]=c(this,CI).subarray(8,12);const d=g-s,m=I-a,u=Math.hypot(d,m);if(u<c(this,Ob))return!1;const b=u-c(this,Qb),Z=b/u,w=Z*d,G=Z*m;let B=n,p=l;n=s,l=a,s+=w,a+=G,(J=c(this,Bo))==null||J.push(g,I);const Y=-G/b,y=w/b,R=Y*c(this,Sm),M=y*c(this,Sm);return c(this,CI).set(c(this,CI).subarray(2,8),0),c(this,CI).set([s+R,a+M],4),c(this,CI).set(c(this,CI).subarray(14,18),12),c(this,CI).set([s-R,a-M],16),isNaN(c(this,CI)[6])?(c(this,Yn).length===0&&(c(this,CI).set([n+R,l+M],2),c(this,Yn).push(NaN,NaN,NaN,NaN,(n+R-e)/i,(l+M-t)/A),c(this,CI).set([n-R,l-M],14),c(this,MA).push(NaN,NaN,NaN,NaN,(n-R-e)/i,(l-M-t)/A)),c(this,CI).set([B,p,n,l,s,a],6),!this.isEmpty()):(c(this,CI).set([B,p,n,l,s,a],6),Math.abs(Math.atan2(p-l,B-n)-Math.atan2(G,w))<Math.PI/2?([n,l,s,a]=c(this,CI).subarray(2,6),c(this,Yn).push(NaN,NaN,NaN,NaN,((n+s)/2-e)/i,((l+a)/2-t)/A),[n,l,B,p]=c(this,CI).subarray(14,18),c(this,MA).push(NaN,NaN,NaN,NaN,((B+n)/2-e)/i,((p+l)/2-t)/A),!0):([B,p,n,l,s,a]=c(this,CI).subarray(0,6),c(this,Yn).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+s)/6-e)/i,((5*l+a)/6-t)/A,((n+s)/2-e)/i,((l+a)/2-t)/A),[s,a,n,l,B,p]=c(this,CI).subarray(12,18),c(this,MA).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+s)/6-e)/i,((5*l+a)/6-t)/A,((n+s)/2-e)/i,((l+a)/2-t)/A),!0))}toSVGPath(){if(this.isEmpty())return"";const g=c(this,Yn),I=c(this,MA);if(isNaN(c(this,CI)[6])&&!this.isEmpty())return f(this,OC,hT).call(this);const e=[];e.push(`M${g[4]} ${g[5]}`);for(let t=6;t<g.length;t+=6)isNaN(g[t])?e.push(`L${g[t+4]} ${g[t+5]}`):e.push(`C${g[t]} ${g[t+1]} ${g[t+2]} ${g[t+3]} ${g[t+4]} ${g[t+5]}`);f(this,OC,ZT).call(this,e);for(let t=I.length-6;t>=6;t-=6)isNaN(I[t])?e.push(`L${I[t+4]} ${I[t+5]}`):e.push(`C${I[t]} ${I[t+1]} ${I[t+2]} ${I[t+3]} ${I[t+4]} ${I[t+5]}`);return f(this,OC,bT).call(this,e),e.join(" ")}newFreeDrawOutline(g,I,e,t,i,A){return new PS(g,I,e,t,i,A)}getOutlines(){var d;const g=c(this,Yn),I=c(this,MA),e=c(this,CI),[t,i,A,n]=c(this,li),l=new Float32Array((((d=c(this,Bo))==null?void 0:d.length)??0)+2);for(let m=0,u=l.length-2;m<u;m+=2)l[m]=(c(this,Bo)[m]-t)/A,l[m+1]=(c(this,Bo)[m+1]-i)/n;if(l[l.length-2]=(c(this,Td)-t)/A,l[l.length-1]=(c(this,vd)-i)/n,isNaN(e[6])&&!this.isEmpty())return f(this,OC,GT).call(this,l);const s=new Float32Array(c(this,Yn).length+24+c(this,MA).length);let a=g.length;for(let m=0;m<a;m+=2){if(isNaN(g[m])){s[m]=s[m+1]=NaN;continue}s[m]=g[m],s[m+1]=g[m+1]}a=f(this,OC,WT).call(this,s,a);for(let m=I.length-6;m>=6;m-=6)for(let u=0;u<6;u+=2){if(isNaN(I[m+u])){s[a]=s[a+1]=NaN,a+=2;continue}s[a]=I[m+u],s[a+1]=I[m+u+1],a+=2}return f(this,OC,wT).call(this,s,a),this.newFreeDrawOutline(s,l,c(this,li),c(this,Dm),c(this,Hm),c(this,fm))}};li=new WeakMap,MA=new WeakMap,Hm=new WeakMap,fm=new WeakMap,Yn=new WeakMap,CI=new WeakMap,Td=new WeakMap,vd=new WeakMap,Ob=new WeakMap,Qb=new WeakMap,Dm=new WeakMap,Sm=new WeakMap,Bo=new WeakMap,Ub=new WeakMap,HB=new WeakMap,fB=new WeakMap,OC=new WeakSet,FZ=function(){const g=c(this,CI).subarray(4,6),I=c(this,CI).subarray(16,18),[e,t,i,A]=c(this,li);return[(c(this,Td)+(g[0]-I[0])/2-e)/i,(c(this,vd)+(g[1]-I[1])/2-t)/A,(c(this,Td)+(I[0]-g[0])/2-e)/i,(c(this,vd)+(I[1]-g[1])/2-t)/A]},hT=function(){const[g,I,e,t]=c(this,li),[i,A,n,l]=f(this,OC,FZ).call(this);return`M${(c(this,CI)[2]-g)/e} ${(c(this,CI)[3]-I)/t} L${(c(this,CI)[4]-g)/e} ${(c(this,CI)[5]-I)/t} L${i} ${A} L${n} ${l} L${(c(this,CI)[16]-g)/e} ${(c(this,CI)[17]-I)/t} L${(c(this,CI)[14]-g)/e} ${(c(this,CI)[15]-I)/t} Z`},bT=function(g){const I=c(this,MA);g.push(`L${I[4]} ${I[5]} Z`)},ZT=function(g){const[I,e,t,i]=c(this,li),A=c(this,CI).subarray(4,6),n=c(this,CI).subarray(16,18),[l,s,a,d]=f(this,OC,FZ).call(this);g.push(`L${(A[0]-I)/t} ${(A[1]-e)/i} L${l} ${s} L${a} ${d} L${(n[0]-I)/t} ${(n[1]-e)/i}`)},GT=function(g){const I=c(this,CI),[e,t,i,A]=c(this,li),[n,l,s,a]=f(this,OC,FZ).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(I[2]-e)/i,(I[3]-t)/A,NaN,NaN,NaN,NaN,(I[4]-e)/i,(I[5]-t)/A,NaN,NaN,NaN,NaN,n,l,NaN,NaN,NaN,NaN,s,a,NaN,NaN,NaN,NaN,(I[16]-e)/i,(I[17]-t)/A,NaN,NaN,NaN,NaN,(I[14]-e)/i,(I[15]-t)/A],0),this.newFreeDrawOutline(d,g,c(this,li),c(this,Dm),c(this,Hm),c(this,fm))},wT=function(g,I){const e=c(this,MA);return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],I),I+=6},WT=function(g,I){const e=c(this,CI).subarray(4,6),t=c(this,CI).subarray(16,18),[i,A,n,l]=c(this,li),[s,a,d,m]=f(this,OC,FZ).call(this);return g.set([NaN,NaN,NaN,NaN,(e[0]-i)/n,(e[1]-A)/l,NaN,NaN,NaN,NaN,s,a,NaN,NaN,NaN,NaN,d,m,NaN,NaN,NaN,NaN,(t[0]-i)/n,(t[1]-A)/l],I),I+=24},X(fl,Ub,8),X(fl,HB,2),X(fl,fB,c(fl,Ub)+c(fl,HB));let Yw=fl;class PS extends Zg{constructor(I,e,t,i,A,n){super();X(this,DB);X(this,Km);X(this,jd,new Float32Array(4));X(this,Dl);X(this,Eb);X(this,si);X(this,Pb);X(this,NC);V(this,NC,I),V(this,si,e),V(this,Km,t),V(this,Pb,i),V(this,Dl,A),V(this,Eb,n),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],f(this,DB,BT).call(this,n);const[l,s,a,d]=c(this,jd);for(let m=0,u=I.length;m<u;m+=2)I[m]=(I[m]-l)/a,I[m+1]=(I[m+1]-s)/d;for(let m=0,u=e.length;m<u;m+=2)e[m]=(e[m]-l)/a,e[m+1]=(e[m+1]-s)/d}toSVGPath(){const I=[`M${c(this,NC)[4]} ${c(this,NC)[5]}`];for(let e=6,t=c(this,NC).length;e<t;e+=6){if(isNaN(c(this,NC)[e])){I.push(`L${c(this,NC)[e+4]} ${c(this,NC)[e+5]}`);continue}I.push(`C${c(this,NC)[e]} ${c(this,NC)[e+1]} ${c(this,NC)[e+2]} ${c(this,NC)[e+3]} ${c(this,NC)[e+4]} ${c(this,NC)[e+5]}`)}return I.push("Z"),I.join(" ")}serialize([I,e,t,i],A){const n=t-I,l=i-e;let s,a;switch(A){case 0:s=Zg._rescale(c(this,NC),I,i,n,-l),a=Zg._rescale(c(this,si),I,i,n,-l);break;case 90:s=Zg._rescaleAndSwap(c(this,NC),I,e,n,l),a=Zg._rescaleAndSwap(c(this,si),I,e,n,l);break;case 180:s=Zg._rescale(c(this,NC),t,e,-n,l),a=Zg._rescale(c(this,si),t,e,-n,l);break;case 270:s=Zg._rescaleAndSwap(c(this,NC),t,i,-n,-l),a=Zg._rescaleAndSwap(c(this,si),t,i,-n,-l);break}return{outline:Array.from(s),points:[Array.from(a)]}}get box(){return c(this,jd)}newOutliner(I,e,t,i,A,n=0){return new Yw(I,e,t,i,A,n)}getNewOutline(I,e){const[t,i,A,n]=c(this,jd),[l,s,a,d]=c(this,Km),m=A*a,u=n*d,b=t*a+l,Z=i*d+s,w=this.newOutliner({x:c(this,si)[0]*m+b,y:c(this,si)[1]*u+Z},c(this,Km),c(this,Pb),I,c(this,Eb),e??c(this,Dl));for(let G=2;G<c(this,si).length;G+=2)w.add({x:c(this,si)[G]*m+b,y:c(this,si)[G+1]*u+Z});return w.getOutlines()}}Km=new WeakMap,jd=new WeakMap,Dl=new WeakMap,Eb=new WeakMap,si=new WeakMap,Pb=new WeakMap,NC=new WeakMap,DB=new WeakSet,BT=function(I){const e=c(this,NC);let t=e[4],i=e[5];const A=[t,i,t,i];let n=t,l=i,s=t,a=i;const d=I?Math.max:Math.min,m=new Float32Array(4);for(let b=6,Z=e.length;b<Z;b+=6){const w=e[b+4],G=e[b+5];isNaN(e[b])?(wg.pointBoundingBox(w,G,A),l>G?(n=w,l=G):l===G&&(n=d(n,w)),a<G?(s=w,a=G):a===G&&(s=d(s,w))):(m[0]=m[1]=1/0,m[2]=m[3]=-1/0,wg.bezierBoundingBox(t,i,...e.slice(b,b+6),m),wg.rectBoundingBox(m[0],m[1],m[2],m[3],A),l>m[1]?(n=m[0],l=m[1]):l===m[1]&&(n=d(n,m[0])),a<m[3]?(s=m[2],a=m[3]):a===m[3]&&(s=d(s,m[2]))),t=w,i=G}const u=c(this,jd);u[0]=A[0]-c(this,Dl),u[1]=A[1]-c(this,Dl),u[2]=A[2]-A[0]+2*c(this,Dl),u[3]=A[3]-A[1]+2*c(this,Dl),this.firstPoint=[n,l],this.lastPoint=[s,a]};class _Y{constructor(g,I=0,e=0,t=!0){X(this,lt);X(this,_b);X(this,$b);X(this,qb);X(this,po,[]);X(this,RA,[]);const i=[1/0,1/0,-1/0,-1/0],n=10**-4;for(const{x:w,y:G,width:B,height:p}of g){const Y=Math.floor((w-I)/n)*n,y=Math.ceil((w+B+I)/n)*n,R=Math.floor((G-I)/n)*n,M=Math.ceil((G+p+I)/n)*n,D=[Y,R,M,!0],J=[y,R,M,!1];c(this,po).push(D,J),wg.rectBoundingBox(Y,R,y,M,i)}const l=i[2]-i[0]+2*e,s=i[3]-i[1]+2*e,a=i[0]-e,d=i[1]-e;let m=t?-1/0:1/0,u=1/0;const b=c(this,po).at(t?-1:-2),Z=[b[0],b[2]];for(const w of c(this,po)){const[G,B,p,Y]=w;!Y&&t?B<u?(u=B,m=G):B===u&&(m=Math.max(m,G)):Y&&!t&&(B<u?(u=B,m=G):B===u&&(m=Math.min(m,G))),w[0]=(G-a)/l,w[1]=(B-d)/s,w[2]=(p-d)/s}V(this,_b,new Float32Array([a,d,l,s])),V(this,$b,[m,u]),V(this,qb,Z)}getOutlines(){c(this,po).sort((I,e)=>I[0]-e[0]||I[1]-e[1]||I[2]-e[2]);const g=[];for(const I of c(this,po))I[3]?(g.push(...f(this,lt,LR).call(this,I)),f(this,lt,yT).call(this,I)):(f(this,lt,YT).call(this,I),g.push(...f(this,lt,LR).call(this,I)));return f(this,lt,pT).call(this,g)}}_b=new WeakMap,$b=new WeakMap,qb=new WeakMap,po=new WeakMap,RA=new WeakMap,lt=new WeakSet,pT=function(g){const I=[],e=new Set;for(const A of g){const[n,l,s]=A;I.push([n,l,A],[n,s,A])}I.sort((A,n)=>A[1]-n[1]||A[0]-n[0]);for(let A=0,n=I.length;A<n;A+=2){const l=I[A][2],s=I[A+1][2];l.push(s),s.push(l),e.add(l),e.add(s)}const t=[];let i;for(;e.size>0;){const A=e.values().next().value;let[n,l,s,a,d]=A;e.delete(A);let m=n,u=l;for(i=[n,s],t.push(i);;){let b;if(e.has(a))b=a;else if(e.has(d))b=d;else break;e.delete(b),[n,l,s,a,d]=b,m!==n&&(i.push(m,u,n,u===l?l:s),m=n),u=u===l?s:l}i.push(m,u)}return new bjg(t,c(this,_b),c(this,$b),c(this,qb))},Ep=function(g){const I=c(this,RA);let e=0,t=I.length-1;for(;e<=t;){const i=e+t>>1,A=I[i][0];if(A===g)return i;A<g?e=i+1:t=i-1}return t+1},yT=function([,g,I]){const e=f(this,lt,Ep).call(this,g);c(this,RA).splice(e,0,[g,I])},YT=function([,g,I]){const e=f(this,lt,Ep).call(this,g);for(let t=e;t<c(this,RA).length;t++){const[i,A]=c(this,RA)[t];if(i!==g)break;if(i===g&&A===I){c(this,RA).splice(t,1);return}}for(let t=e-1;t>=0;t--){const[i,A]=c(this,RA)[t];if(i!==g)break;if(i===g&&A===I){c(this,RA).splice(t,1);return}}},LR=function(g){const[I,e,t]=g,i=[[I,e,t]],A=f(this,lt,Ep).call(this,t);for(let n=0;n<A;n++){const[l,s]=c(this,RA)[n];for(let a=0,d=i.length;a<d;a++){const[,m,u]=i[a];if(!(s<=m||u<=l)){if(m>=l){if(u>s)i[a][1]=s;else{if(d===1)return[];i.splice(a,1),a--,d--}continue}i[a][2]=l,u>s&&i.push([I,s,u])}}}return i};class bjg extends Zg{constructor(I,e,t,i){super();X(this,gZ);X(this,km);V(this,km,I),V(this,gZ,e),this.firstPoint=t,this.lastPoint=i}toSVGPath(){const I=[];for(const e of c(this,km)){let[t,i]=e;I.push(`M${t} ${i}`);for(let A=2;A<e.length;A+=2){const n=e[A],l=e[A+1];n===t?(I.push(`V${l}`),i=l):l===i&&(I.push(`H${n}`),t=n)}I.push("Z")}return I.join(" ")}serialize([I,e,t,i],A){const n=[],l=t-I,s=i-e;for(const a of c(this,km)){const d=new Array(a.length);for(let m=0;m<a.length;m+=2)d[m]=I+a[m]*l,d[m+1]=i-a[m+1]*s;n.push(d)}return n}get box(){return c(this,gZ)}get classNamesForOutlining(){return["highlightOutline"]}}gZ=new WeakMap,km=new WeakMap;class $Y extends Yw{newFreeDrawOutline(g,I,e,t,i,A){return new Zjg(g,I,e,t,i,A)}}class Zjg extends PS{newOutliner(g,I,e,t,i,A=0){return new $Y(g,I,e,t,i,A)}}const uI=class uI extends xI{constructor(I){super({...I,name:"highlightEditor"});X(this,Eg);X(this,zm,null);X(this,IZ,0);X(this,Sl);X(this,xd,null);X(this,CZ,null);X(this,St,null);X(this,eZ,null);X(this,tZ,0);X(this,Od,null);X(this,oi,null);X(this,ai,null);X(this,we,!1);X(this,Fm,null);X(this,Jm,null);X(this,ze,null);X(this,Lm,"");X(this,Ei);X(this,iZ,"");this.color=I.color||uI._defaultColor,V(this,Ei,I.thickness||uI._defaultThickness),this.opacity=I.opacity||uI._defaultOpacity,V(this,Sl,I.boxes||null),V(this,iZ,I.methodOfCreation||""),V(this,Lm,I.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",I.highlightId>-1?(V(this,we,!0),f(this,Eg,Pp).call(this,I),f(this,Eg,Zc).call(this)):c(this,Sl)&&(V(this,zm,I.anchorNode),V(this,IZ,I.anchorOffset),V(this,eZ,I.focusNode),V(this,tZ,I.focusOffset),f(this,Eg,TR).call(this),f(this,Eg,Zc).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const I=uI.prototype;return Jg(this,"_keyboardManager",new mh([[["ArrowLeft","mac+ArrowLeft"],I._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],I._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],I._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],I._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:c(this,we)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:c(this,Ei),methodOfCreation:c(this,iZ)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(I){return{numberOfColors:I.get("color").size}}static initialize(I,e){var t;xI.initialize(I,e),uI._defaultColor||(uI._defaultColor=((t=e.highlightColors)==null?void 0:t.values().next().value)||"#fff066")}static updateDefaultParams(I,e){switch(I){case oI.HIGHLIGHT_COLOR:uI._defaultColor=e;break;case oI.HIGHLIGHT_THICKNESS:uI._defaultThickness=e;break}}translateInPage(I,e){}get toolbarPosition(){return c(this,Jm)}get commentButtonPosition(){return c(this,Fm)}updateParams(I,e){switch(I){case oI.HIGHLIGHT_COLOR:f(this,Eg,VT).call(this,e);break;case oI.HIGHLIGHT_THICKNESS:f(this,Eg,NT).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[oI.HIGHLIGHT_COLOR,uI._defaultColor],[oI.HIGHLIGHT_THICKNESS,uI._defaultThickness]]}get propertiesToUpdate(){return[[oI.HIGHLIGHT_COLOR,this.color||uI._defaultColor],[oI.HIGHLIGHT_THICKNESS,c(this,Ei)||uI._defaultThickness],[oI.HIGHLIGHT_FREE,c(this,we)]]}onUpdatedColor(){var I,e;(I=this.parent)==null||I.drawLayer.updateProperties(c(this,ai),{root:{fill:this.color,"fill-opacity":this.opacity}}),(e=c(this,CZ))==null||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",V(this,CZ,new Ww({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(f(this,Eg,$p).call(this))}getBaseTranslation(){return[0,0]}getRect(I,e){return super.getRect(I,e,f(this,Eg,$p).call(this))}onceAdded(I){this.annotationElementId||this.parent.addUndoableEditor(this),I&&this.div.focus()}remove(){f(this,Eg,vR).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,Eg,Zc).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?f(this,Eg,vR).call(this):I&&(f(this,Eg,Zc).call(this,I),e=!this.parent&&((t=this.div)==null?void 0:t.classList.contains("selectedEditor"))),super.setParent(I),this.show(this._isVisible),e&&this.select()}rotate(I){var i,A,n;const{drawLayer:e}=this.parent;let t;c(this,we)?(I=(I-this.rotation+360)%360,t=f(i=uI,Pi,bu).call(i,c(this,oi).box,I)):t=f(A=uI,Pi,bu).call(A,[this.x,this.y,this.width,this.height],I),e.updateProperties(c(this,ai),{bbox:t,root:{"data-main-rotation":I}}),e.updateProperties(c(this,ze),{bbox:f(n=uI,Pi,bu).call(n,c(this,St).box,I),root:{"data-main-rotation":I}})}render(){if(this.div)return this.div;const I=super.render();c(this,Lm)&&(I.setAttribute("aria-label",c(this,Lm)),I.setAttribute("role","mark")),c(this,we)?I.classList.add("free"):this.div.addEventListener("keydown",f(this,Eg,RT).bind(this),{signal:this._uiManager._signal});const e=V(this,Od,document.createElement("div"));return I.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=c(this,xd),this.setDims(),oS(this,c(this,Od),["pointerover","pointerleave"]),this.enableEditing(),I}pointerover(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{hovered:!0}})}pointerleave(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{hovered:!1}})}_moveCaret(I){switch(this.parent.unselect(this),I){case 0:case 2:f(this,Eg,_p).call(this,!0);break;case 1:case 3:f(this,Eg,_p).call(this,!1);break}}select(){var I;super.select(),c(this,ze)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var I;super.unselect(),c(this,ze)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,ze),{rootClass:{selected:!1}}),c(this,we)||f(this,Eg,_p).call(this,!1))}get _mustFixPosition(){return!c(this,we)}show(I=this._isVisible){super.show(I),this.parent&&(this.parent.drawLayer.updateProperties(c(this,ai),{rootClass:{hidden:!I}}),this.parent.drawLayer.updateProperties(c(this,ze),{rootClass:{hidden:!I}}))}static startHighlighting(I,e,{target:t,x:i,y:A}){const{x:n,y:l,width:s,height:a}=t.getBoundingClientRect(),d=new AbortController,m=I.combinedSignal(d),u=b=>{d.abort(),f(this,Pi,DT).call(this,I,b)};window.addEventListener("blur",u,{signal:m}),window.addEventListener("pointerup",u,{signal:m}),window.addEventListener("pointerdown",mC,{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",yi,{signal:m}),t.addEventListener("pointermove",f(this,Pi,fT).bind(this,I),{signal:m}),this._freeHighlight=new $Y({x:i,y:A},[n,l,s,a],I.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=I.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(I,e,t){var Z,w,G,B;let i=null;if(I instanceof US){const{data:{quadPoints:p,rect:Y,rotation:y,id:R,color:M,opacity:D,popupRef:J,richText:H,contentsObj:z,creationDate:T,modificationDate:P},parent:{page:{pageNumber:Ig}}}=I;i=I={annotationType:Tg.HIGHLIGHT,color:Array.from(M),opacity:D,quadPoints:p,boxes:null,pageIndex:Ig-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(z==null?void 0:z.str)||null,creationDate:T,modificationDate:P}}else if(I instanceof UY){const{data:{inkLists:p,rect:Y,rotation:y,id:R,color:M,borderStyle:{rawWidth:D},popupRef:J,richText:H,contentsObj:z,creationDate:T,modificationDate:P},parent:{page:{pageNumber:Ig}}}=I;i=I={annotationType:Tg.HIGHLIGHT,color:Array.from(M),thickness:D,inkLists:p,boxes:null,pageIndex:Ig-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(z==null?void 0:z.str)||null,creationDate:T,modificationDate:P}}const{color:A,quadPoints:n,inkLists:l,opacity:s}=I,a=await super.deserialize(I,e,t);a.color=wg.makeHexColor(...A),a.opacity=s||1,l&&V(a,Ei,I.thickness),a._initialData=i,I.comment&&a.setCommentData(I);const[d,m]=a.pageDimensions,[u,b]=a.pageTranslation;if(n){const p=V(a,Sl,[]);for(let Y=0;Y<n.length;Y+=8)p.push({x:(n[Y]-u)/d,y:1-(n[Y+1]-b)/m,width:(n[Y+2]-n[Y])/d,height:(n[Y+1]-n[Y+5])/m});f(Z=a,Eg,TR).call(Z),f(w=a,Eg,Zc).call(w),a.rotate(a.rotation)}else if(l){V(a,we,!0);const p=l[0],Y={x:p[0]-u,y:m-(p[1]-b)},y=new $Y(Y,[0,0,d,m],1,c(a,Ei)/2,!0,.001);for(let D=0,J=p.length;D<J;D+=2)Y.x=p[D]-u,Y.y=m-(p[D+1]-b),y.add(Y);const{id:R,clipPathId:M}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:a.color,"fill-opacity":a._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:y.toSVGPath()}},!0,!0);f(G=a,Eg,Pp).call(G,{highlightOutlines:y.getOutlines(),highlightId:R,clipPathId:M}),f(B=a,Eg,Zc).call(B),a.rotate(a.parentRotation)}return a}serialize(I=!1){if(this.isEmpty()||I)return null;if(this.deleted)return this.serializeDeleted();const e=xI._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),t=super.serialize(I);return Object.assign(t,{color:e,opacity:this.opacity,thickness:c(this,Ei),quadPoints:f(this,Eg,XT).call(this),outlines:f(this,Eg,HT).call(this,t.rect)}),this.addComment(t),this.annotationElementId&&!f(this,Eg,ST).call(this,t)?null:(t.id=this.annotationElementId,t)}renderAnnotationElement(I){return this.deleted?(I.hide(),null):(I.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};zm=new WeakMap,IZ=new WeakMap,Sl=new WeakMap,xd=new WeakMap,CZ=new WeakMap,St=new WeakMap,eZ=new WeakMap,tZ=new WeakMap,Od=new WeakMap,oi=new WeakMap,ai=new WeakMap,we=new WeakMap,Fm=new WeakMap,Jm=new WeakMap,ze=new WeakMap,Lm=new WeakMap,Ei=new WeakMap,iZ=new WeakMap,Eg=new WeakSet,TR=function(){const I=new _Y(c(this,Sl),.001);V(this,oi,I.getOutlines()),[this.x,this.y,this.width,this.height]=c(this,oi).box;const e=new _Y(c(this,Sl),.0025,.001,this._uiManager.direction==="ltr");V(this,St,e.getOutlines());const{firstPoint:t}=c(this,oi);V(this,Fm,[(t[0]-this.x)/this.width,(t[1]-this.y)/this.height]);const{lastPoint:i}=c(this,St);V(this,Jm,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Pp=function({highlightOutlines:I,highlightId:e,clipPathId:t}){var m,u;if(V(this,oi,I),V(this,St,I.getNewOutline(c(this,Ei)/2+1.5,.0025)),e>=0)V(this,ai,e),V(this,xd,t),this.parent.drawLayer.finalizeDraw(e,{bbox:I.box,path:{d:I.toSVGPath()}}),V(this,ze,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:c(this,St).box,path:{d:c(this,St).toSVGPath()}},!0));else if(this.parent){const b=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(c(this,ai),{bbox:f(m=uI,Pi,bu).call(m,c(this,oi).box,(b-this.rotation+360)%360),path:{d:I.toSVGPath()}}),this.parent.drawLayer.updateProperties(c(this,ze),{bbox:f(u=uI,Pi,bu).call(u,c(this,St).box,b),path:{d:c(this,St).toSVGPath()}})}const[A,n,l,s]=I.box;switch(this.rotation){case 0:this.x=A,this.y=n,this.width=l,this.height=s;break;case 90:{const[b,Z]=this.parentDimensions;this.x=n,this.y=1-A,this.width=l*Z/b,this.height=s*b/Z;break}case 180:this.x=1-A,this.y=1-n,this.width=l,this.height=s;break;case 270:{const[b,Z]=this.parentDimensions;this.x=1-n,this.y=A,this.width=l*Z/b,this.height=s*b/Z;break}}const{firstPoint:a}=I;V(this,Fm,[(a[0]-A)/l,(a[1]-n)/s]);const{lastPoint:d}=c(this,St);V(this,Jm,[(d[0]-A)/l,(d[1]-n)/s])},VT=function(I){const e=(A,n)=>{this.color=A,this.opacity=n,this.onUpdatedColor()},t=this.color,i=this.opacity;this.addCommands({cmd:e.bind(this,I,uI._defaultOpacity),undo:e.bind(this,t,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:oI.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(I)},!0)},NT=function(I){const e=c(this,Ei),t=i=>{V(this,Ei,i),f(this,Eg,MT).call(this,i)};this.addCommands({cmd:t.bind(this,I),undo:t.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:oI.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:I},!0)},MT=function(I){c(this,we)&&(f(this,Eg,Pp).call(this,{highlightOutlines:c(this,oi).getNewOutline(I/2)}),this.fixAndSetPosition(),this.setDims())},vR=function(){c(this,ai)===null||!this.parent||(this.parent.drawLayer.remove(c(this,ai)),V(this,ai,null),this.parent.drawLayer.remove(c(this,ze)),V(this,ze,null))},Zc=function(I=this.parent){c(this,ai)===null&&({id:PC(this,ai)._,clipPathId:PC(this,xd)._}=I.drawLayer.draw({bbox:c(this,oi).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:c(this,we)},path:{d:c(this,oi).toSVGPath()}},!1,!0),V(this,ze,I.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:c(this,we)},bbox:c(this,St).box,path:{d:c(this,St).toSVGPath()}},c(this,we))),c(this,Od)&&(c(this,Od).style.clipPath=c(this,xd)))},Pi=new WeakSet,bu=function([I,e,t,i],A){switch(A){case 90:return[1-e-i,I,i,t];case 180:return[1-I-t,1-e-i,t,i];case 270:return[e,1-I-t,i,t]}return[I,e,t,i]},RT=function(I){uI._keyboardManager.exec(this,I)},_p=function(I){if(!c(this,zm))return;const e=window.getSelection();I?e.setPosition(c(this,zm),c(this,IZ)):e.setPosition(c(this,eZ),c(this,tZ))},$p=function(){return c(this,we)?this.rotation:0},XT=function(){if(c(this,we))return null;const[I,e]=this.pageDimensions,[t,i]=this.pageTranslation,A=c(this,Sl),n=new Float32Array(A.length*8);let l=0;for(const{x:s,y:a,width:d,height:m}of A){const u=s*I+t,b=(1-a)*e+i;n[l]=n[l+4]=u,n[l+1]=n[l+3]=b,n[l+2]=n[l+6]=u+d*I,n[l+5]=n[l+7]=b-m*e,l+=8}return n},HT=function(I){return c(this,oi).serialize(I,f(this,Eg,$p).call(this))},fT=function(I,e){this._freeHighlight.add(e)&&I.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},DT=function(I,e){this._freeHighlight.isEmpty()?I.drawLayer.remove(this._freeHighlightId):I.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},ST=function(I){const{color:e}=this._initialData;return this.hasEditedComment||I.color.some((t,i)=>t!==e[i])},X(uI,Pi),sg(uI,"_defaultColor",null),sg(uI,"_defaultOpacity",1),sg(uI,"_defaultThickness",12),sg(uI,"_type","highlight"),sg(uI,"_editorType",Tg.HIGHLIGHT),sg(uI,"_freeHighlightId",-1),sg(uI,"_freeHighlight",null),sg(uI,"_freeHighlightClipId","");let Vw=uI;class _S{constructor(){X(this,Qd,Object.create(null))}updateProperty(g,I){this[g]=I,this.updateSVGProperty(g,I)}updateProperties(g){if(g)for(const[I,e]of Object.entries(g))I.startsWith("_")||this.updateProperty(I,e)}updateSVGProperty(g,I){c(this,Qd)[g]=I}toSVGProperties(){const g=c(this,Qd);return V(this,Qd,Object.create(null)),{root:g}}reset(){V(this,Qd,Object.create(null))}updateAll(g=this){this.updateProperties(g)}clone(){kI("Not implemented")}}Qd=new WeakMap;const iI=class iI extends xI{constructor(I){super(I);X(this,rI);X(this,di,null);X(this,Tm);sg(this,"_colorPicker",null);sg(this,"_drawId",null);V(this,Tm,I.mustBeCommitted||!1),this._addOutlines(I)}onUpdatedColor(){var I;(I=this._colorPicker)==null||I.update(this.color),super.onUpdatedColor()}_addOutlines(I){I.drawOutlines&&(f(this,rI,jR).call(this,I),f(this,rI,JZ).call(this))}static _mergeSVGProperties(I,e){const t=new Set(Object.keys(I));for(const[i,A]of Object.entries(e))t.has(i)?Object.assign(I[i],A):I[i]=A;return I}static getDefaultDrawingOptions(I){kI("Not implemented")}static get typesMap(){kI("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(I,e){const t=this.typesMap.get(I);t&&this._defaultDrawingOptions.updateProperty(t,e),this._currentParent&&(c(iI,ie).updateProperty(t,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(I,e){const t=this.constructor.typesMap.get(I);t&&this._updateProperty(I,t,e)}static get defaultPropertiesToUpdate(){const I=[],e=this._defaultDrawingOptions;for(const[t,i]of this.typesMap)I.push([t,e[i]]);return I}get propertiesToUpdate(){const I=[],{_drawingOptions:e}=this;for(const[t,i]of this.constructor.typesMap)I.push([t,e[i]]);return I}_updateProperty(I,e,t){const i=this._drawingOptions,A=i[e],n=l=>{var a;i.updateProperty(e,l);const s=c(this,di).updateProperty(e,l);s&&f(this,rI,LZ).call(this,s),(a=this.parent)==null||a.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),I===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:I,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties(c(this,di).getPathResizingSVGProperties(f(this,rI,qp).call(this)),{bbox:f(this,rI,Zu).call(this)}))}_onResized(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties(c(this,di).getPathResizedSVGProperties(f(this,rI,qp).call(this)),{bbox:f(this,rI,Zu).call(this)}))}_onTranslating(I,e){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{bbox:f(this,rI,Zu).call(this)})}_onTranslated(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties(c(this,di).getPathTranslatedSVGProperties(f(this,rI,qp).call(this),this.parentDimensions),{bbox:f(this,rI,Zu).call(this)}))}_onStartDragging(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(I){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,c(this,Tm)&&(V(this,Tm,!1),this.commit(),this.parent.setSelected(this),I&&this.isOnScreen&&this.div.focus())}remove(){f(this,rI,OR).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,rI,JZ).call(this),f(this,rI,LZ).call(this,c(this,di).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?(this._uiManager.removeShouldRescale(this),f(this,rI,OR).call(this)):I&&(this._uiManager.addShouldRescale(this),f(this,rI,JZ).call(this,I),e=!this.parent&&((t=this.div)==null?void 0:t.classList.contains("selectedEditor"))),super.setParent(I),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,iI._mergeSVGProperties({bbox:f(this,rI,Zu).call(this)},c(this,di).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&f(this,rI,LZ).call(this,c(this,di).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let I,e;this._isCopy&&(I=this.x,e=this.y);const t=super.render();t.classList.add("draw");const i=document.createElement("div");return t.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(I,e),t}static createDrawerInstance(I,e,t,i,A){kI("Not implemented")}static startDrawing(I,e,t,i){var w;const{target:A,offsetX:n,offsetY:l,pointerId:s,pointerType:a}=i;if(Re.isInitializedAndDifferentPointerType(a))return;const{viewport:{rotation:d}}=I,{width:m,height:u}=A.getBoundingClientRect(),b=V(iI,Ud,new AbortController),Z=I.combinedSignal(b);if(Re.setPointer(a,s),window.addEventListener("pointerup",G=>{Re.isSamePointerIdOrRemove(G.pointerId)&&this._endDraw(G)},{signal:Z}),window.addEventListener("pointercancel",G=>{Re.isSamePointerIdOrRemove(G.pointerId)&&this._currentParent.endDrawingSession()},{signal:Z}),window.addEventListener("pointerdown",G=>{Re.isSamePointerType(G.pointerType)&&(Re.initializeAndAddPointerId(G.pointerId),c(iI,ie).isCancellable()&&(c(iI,ie).removeLastElement(),c(iI,ie).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:Z}),window.addEventListener("contextmenu",yi,{signal:Z}),A.addEventListener("pointermove",this._drawMove.bind(this),{signal:Z}),A.addEventListener("touchmove",G=>{Re.isSameTimeStamp(G.timeStamp)&&mC(G)},{signal:Z}),I.toggleDrawing(),(w=e._editorUndoBar)==null||w.hide(),c(iI,ie)){I.drawLayer.updateProperties(this._currentDrawId,c(iI,ie).startNew(n,l,m,u,d));return}e.updateUIForDefaultProperties(this),V(iI,ie,this.createDrawerInstance(n,l,m,u,d)),V(iI,Ed,this.getDefaultDrawingOptions()),this._currentParent=I,{id:this._currentDrawId}=I.drawLayer.draw(this._mergeSVGProperties(c(iI,Ed).toSVGProperties(),c(iI,ie).defaultSVGProperties),!0,!1)}static _drawMove(I){if(Re.isSameTimeStamp(I.timeStamp),!c(iI,ie))return;const{offsetX:e,offsetY:t,pointerId:i}=I;if(Re.isSamePointerId(i)){if(Re.isUsingMultiplePointers()){this._endDraw(I);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,c(iI,ie).add(e,t)),Re.setTimeStamp(I.timeStamp),mC(I)}}static _cleanup(I){I&&(this._currentDrawId=-1,this._currentParent=null,V(iI,ie,null),V(iI,Ed,null),Re.clearPointerType(),Re.clearTimeStamp()),c(iI,Ud)&&(c(iI,Ud).abort(),V(iI,Ud,null),Re.clearPointerIds())}static _endDraw(I){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),(I==null?void 0:I.target)===e.div&&e.drawLayer.updateProperties(this._currentDrawId,c(iI,ie).end(I.offsetX,I.offsetY)),this.supportMultipleDrawings){const t=c(iI,ie),i=this._currentDrawId,A=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(A))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:oI.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(I){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(oI.DRAW_STEP),!c(iI,ie).isEmpty()){const{pageDimensions:[t,i],scale:A}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:c(iI,ie).getOutlines(t*A,i*A,A,this._INNER_MARGIN),drawingOptions:c(iI,Ed),mustBeCommitted:!I});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(I){}static deserializeDraw(I,e,t,i,A,n){kI("Not implemented")}static async deserialize(I,e,t){var d,m;const{rawDims:{pageWidth:i,pageHeight:A,pageX:n,pageY:l}}=e.viewport,s=this.deserializeDraw(n,l,i,A,this._INNER_MARGIN,I),a=await super.deserialize(I,e,t);return a.createDrawingOptions(I),f(d=a,rI,jR).call(d,{drawOutlines:s}),f(m=a,rI,JZ).call(m),a.onScaleChanging(),a.rotate(),a}serializeDraw(I){const[e,t]=this.pageTranslation,[i,A]=this.pageDimensions;return c(this,di).serialize([e,t,i,A],I)}renderAnnotationElement(I){return I.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};di=new WeakMap,Tm=new WeakMap,ie=new WeakMap,Ud=new WeakMap,Ed=new WeakMap,rI=new WeakSet,jR=function({drawOutlines:I,drawId:e,drawingOptions:t}){V(this,di,I),this._drawingOptions||(this._drawingOptions=t),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,I.defaultProperties)):this._drawId=f(this,rI,xR).call(this,I,this.parent),f(this,rI,LZ).call(this,I.box)},xR=function(I,e){const{id:t}=e.drawLayer.draw(iI._mergeSVGProperties(this._drawingOptions.toSVGProperties(),I.defaultSVGProperties),!1,!1);return t},OR=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},JZ=function(I=this.parent){if(!(this._drawId!==null&&this.parent===I)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,I.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=f(this,rI,xR).call(this,c(this,di),I)}},KT=function([I,e,t,i]){const{parentDimensions:[A,n],rotation:l}=this;switch(l){case 90:return[e,1-I,t*(n/A),i*(A/n)];case 180:return[1-I,1-e,t,i];case 270:return[1-e,I,t*(n/A),i*(A/n)];default:return[I,e,t,i]}},qp=function(){const{x:I,y:e,width:t,height:i,parentDimensions:[A,n],rotation:l}=this;switch(l){case 90:return[1-e,I,t*(A/n),i*(n/A)];case 180:return[1-I,1-e,t,i];case 270:return[e,1-I,t*(A/n),i*(n/A)];default:return[I,e,t,i]}},LZ=function(I){[this.x,this.y,this.width,this.height]=f(this,rI,KT).call(this,I),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Zu=function(){const{x:I,y:e,width:t,height:i,rotation:A,parentRotation:n,parentDimensions:[l,s]}=this;switch((A*4+n)/90){case 1:return[1-e-i,I,i,t];case 2:return[1-I-t,1-e-i,t,i];case 3:return[e,1-I-t,i,t];case 4:return[I,e-t*(l/s),i*(s/l),t*(l/s)];case 5:return[1-e,I,t*(l/s),i*(s/l)];case 6:return[1-I-i*(s/l),1-e,i*(s/l),t*(l/s)];case 7:return[e-t*(l/s),1-I-i*(s/l),t*(l/s),i*(s/l)];case 8:return[I-t,e-i,t,i];case 9:return[1-e,I-t,i,t];case 10:return[1-I,1-e,t,i];case 11:return[e-i,1-I,i,t];case 12:return[I-i*(s/l),e,i*(s/l),t*(l/s)];case 13:return[1-e-t*(l/s),I-i*(s/l),t*(l/s),i*(s/l)];case 14:return[1-I,1-e-t*(l/s),i*(s/l),t*(l/s)];case 15:return[e,1-I,t*(l/s),i*(s/l)];default:return[I,e,t,i]}},sg(iI,"_currentDrawId",-1),sg(iI,"_currentParent",null),X(iI,ie,null),X(iI,Ud,null),X(iI,Ed,null),sg(iI,"_INNER_MARGIN",3);let Nw=iI;class Gjg{constructor(g,I,e,t,i,A){X(this,jm);X(this,Vn,new Float64Array(6));X(this,Ae);X(this,ne);X(this,Pd);X(this,vm);X(this,st);X(this,We,"");X(this,_i,0);X(this,_d,new Bh);X(this,$d);X(this,qd);V(this,$d,e),V(this,qd,t),V(this,Pd,i),V(this,vm,A),[g,I]=f(this,jm,gy).call(this,g,I);const n=V(this,Ae,[NaN,NaN,NaN,NaN,g,I]);V(this,st,[g,I]),V(this,ne,[{line:n,points:c(this,st)}]),c(this,Vn).set(n,0)}updateProperty(g,I){g==="stroke-width"&&V(this,vm,I)}isEmpty(){return!c(this,ne)||c(this,ne).length===0}isCancellable(){return c(this,st).length<=10}add(g,I){[g,I]=f(this,jm,gy).call(this,g,I);const[e,t,i,A]=c(this,Vn).subarray(2,6),n=g-i,l=I-A;return Math.hypot(c(this,$d)*n,c(this,qd)*l)<=2?null:(c(this,st).push(g,I),isNaN(e)?(c(this,Vn).set([i,A,g,I],2),c(this,Ae).push(NaN,NaN,NaN,NaN,g,I),{path:{d:this.toSVGPath()}}):(isNaN(c(this,Vn)[0])&&c(this,Ae).splice(6,6),c(this,Vn).set([e,t,i,A,g,I],0),c(this,Ae).push(...Zg.createBezierPoints(e,t,i,A,g,I)),{path:{d:this.toSVGPath()}}))}end(g,I){const e=this.add(g,I);return e||(c(this,st).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(g,I,e,t,i){V(this,$d,e),V(this,qd,t),V(this,Pd,i),[g,I]=f(this,jm,gy).call(this,g,I);const A=V(this,Ae,[NaN,NaN,NaN,NaN,g,I]);V(this,st,[g,I]);const n=c(this,ne).at(-1);return n&&(n.line=new Float32Array(n.line),n.points=new Float32Array(n.points)),c(this,ne).push({line:A,points:c(this,st)}),c(this,Vn).set(A,0),V(this,_i,0),this.toSVGPath(),null}getLastElement(){return c(this,ne).at(-1)}setLastElement(g){return c(this,ne)?(c(this,ne).push(g),V(this,Ae,g.line),V(this,st,g.points),V(this,_i,0),{path:{d:this.toSVGPath()}}):c(this,_d).setLastElement(g)}removeLastElement(){if(!c(this,ne))return c(this,_d).removeLastElement();c(this,ne).pop(),V(this,We,"");for(let g=0,I=c(this,ne).length;g<I;g++){const{line:e,points:t}=c(this,ne)[g];V(this,Ae,e),V(this,st,t),V(this,_i,0),this.toSVGPath()}return{path:{d:c(this,We)}}}toSVGPath(){const g=Zg.svgRound(c(this,Ae)[4]),I=Zg.svgRound(c(this,Ae)[5]);if(c(this,st).length===2)return V(this,We,`${c(this,We)} M ${g} ${I} Z`),c(this,We);if(c(this,st).length<=6){const t=c(this,We).lastIndexOf("M");V(this,We,`${c(this,We).slice(0,t)} M ${g} ${I}`),V(this,_i,6)}if(c(this,st).length===4){const t=Zg.svgRound(c(this,Ae)[10]),i=Zg.svgRound(c(this,Ae)[11]);return V(this,We,`${c(this,We)} L ${t} ${i}`),V(this,_i,12),c(this,We)}const e=[];c(this,_i)===0&&(e.push(`M ${g} ${I}`),V(this,_i,6));for(let t=c(this,_i),i=c(this,Ae).length;t<i;t+=6){const[A,n,l,s,a,d]=c(this,Ae).slice(t,t+6).map(Zg.svgRound);e.push(`C${A} ${n} ${l} ${s} ${a} ${d}`)}return V(this,We,c(this,We)+e.join(" ")),V(this,_i,c(this,Ae).length),c(this,We)}getOutlines(g,I,e,t){const i=c(this,ne).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),c(this,_d).build(c(this,ne),g,I,e,c(this,Pd),c(this,vm),t),V(this,Vn,null),V(this,Ae,null),V(this,ne,null),V(this,We,null),c(this,_d)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Vn=new WeakMap,Ae=new WeakMap,ne=new WeakMap,Pd=new WeakMap,vm=new WeakMap,st=new WeakMap,We=new WeakMap,_i=new WeakMap,_d=new WeakMap,$d=new WeakMap,qd=new WeakMap,jm=new WeakSet,gy=function(g,I){return Zg._normalizePoint(g,I,c(this,$d),c(this,qd),c(this,Pd))};class Bh extends Zg{constructor(){super(...arguments);X(this,Be);X(this,ot);X(this,AZ,0);X(this,nZ);X(this,ci);X(this,Nn);X(this,Mn);X(this,xm);X(this,Om);X(this,gc)}build(I,e,t,i,A,n,l){V(this,Nn,e),V(this,Mn,t),V(this,xm,i),V(this,Om,A),V(this,gc,n),V(this,nZ,l??0),V(this,ci,I),f(this,Be,zT).call(this)}get thickness(){return c(this,gc)}setLastElement(I){return c(this,ci).push(I),{path:{d:this.toSVGPath()}}}removeLastElement(){return c(this,ci).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const I=[];for(const{line:e}of c(this,ci)){if(I.push(`M${Zg.svgRound(e[4])} ${Zg.svgRound(e[5])}`),e.length===6){I.push("Z");continue}if(e.length===12&&isNaN(e[6])){I.push(`L${Zg.svgRound(e[10])} ${Zg.svgRound(e[11])}`);continue}for(let t=6,i=e.length;t<i;t+=6){const[A,n,l,s,a,d]=e.subarray(t,t+6).map(Zg.svgRound);I.push(`C${A} ${n} ${l} ${s} ${a} ${d}`)}}return I.join("")}serialize([I,e,t,i],A){const n=[],l=[],[s,a,d,m]=f(this,Be,kT).call(this);let u,b,Z,w,G,B,p,Y,y;switch(c(this,Om)){case 0:y=Zg._rescale,u=I,b=e+i,Z=t,w=-i,G=I+s*t,B=e+(1-a-m)*i,p=I+(s+d)*t,Y=e+(1-a)*i;break;case 90:y=Zg._rescaleAndSwap,u=I,b=e,Z=t,w=i,G=I+a*t,B=e+s*i,p=I+(a+m)*t,Y=e+(s+d)*i;break;case 180:y=Zg._rescale,u=I+t,b=e,Z=-t,w=i,G=I+(1-s-d)*t,B=e+a*i,p=I+(1-s)*t,Y=e+(a+m)*i;break;case 270:y=Zg._rescaleAndSwap,u=I+t,b=e+i,Z=-t,w=-i,G=I+(1-a-m)*t,B=e+(1-s-d)*i,p=I+(1-a)*t,Y=e+(1-s)*i;break}for(const{line:R,points:M}of c(this,ci))n.push(y(R,u,b,Z,w,A?new Array(R.length):null)),l.push(y(M,u,b,Z,w,A?new Array(M.length):null));return{lines:n,points:l,rect:[G,B,p,Y]}}static deserialize(I,e,t,i,A,{paths:{lines:n,points:l},rotation:s,thickness:a}){const d=[];let m,u,b,Z,w;switch(s){case 0:w=Zg._rescale,m=-I/t,u=e/i+1,b=1/t,Z=-1/i;break;case 90:w=Zg._rescaleAndSwap,m=-e/i,u=-I/t,b=1/i,Z=1/t;break;case 180:w=Zg._rescale,m=I/t+1,u=-e/i,b=-1/t,Z=1/i;break;case 270:w=Zg._rescaleAndSwap,m=e/i+1,u=I/t+1,b=-1/i,Z=-1/t;break}if(!n){n=[];for(const B of l){const p=B.length;if(p===2){n.push(new Float32Array([NaN,NaN,NaN,NaN,B[0],B[1]]));continue}if(p===4){n.push(new Float32Array([NaN,NaN,NaN,NaN,B[0],B[1],NaN,NaN,NaN,NaN,B[2],B[3]]));continue}const Y=new Float32Array(3*(p-2));n.push(Y);let[y,R,M,D]=B.subarray(0,4);Y.set([NaN,NaN,NaN,NaN,y,R],0);for(let J=4;J<p;J+=2){const H=B[J],z=B[J+1];Y.set(Zg.createBezierPoints(y,R,M,D,H,z),(J-2)*3),[y,R,M,D]=[M,D,H,z]}}}for(let B=0,p=n.length;B<p;B++)d.push({line:w(n[B].map(Y=>Y??NaN),m,u,b,Z),points:w(l[B].map(Y=>Y??NaN),m,u,b,Z)});const G=new this.prototype.constructor;return G.build(d,t,i,1,s,a,A),G}get box(){return c(this,ot)}updateProperty(I,e){return I==="stroke-width"?f(this,Be,FT).call(this,e):null}updateParentDimensions([I,e],t){const[i,A]=f(this,Be,$l).call(this);V(this,Nn,I),V(this,Mn,e),V(this,xm,t);const[n,l]=f(this,Be,$l).call(this),s=n-i,a=l-A,d=c(this,ot);return d[0]-=s,d[1]-=a,d[2]+=2*s,d[3]+=2*a,d}updateRotation(I){return V(this,AZ,I),{path:{transform:this.rotationTransform}}}get viewBox(){return c(this,ot).map(Zg.svgRound).join(" ")}get defaultProperties(){const[I,e]=c(this,ot);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`}}}get rotationTransform(){const[,,I,e]=c(this,ot);let t=0,i=0,A=0,n=0,l=0,s=0;switch(c(this,AZ)){case 90:i=e/I,A=-I/e,l=I;break;case 180:t=-1,n=-1,l=I,s=e;break;case 270:i=-e/I,A=I/e,s=e;break;default:return""}return`matrix(${t} ${i} ${A} ${n} ${Zg.svgRound(l)} ${Zg.svgRound(s)})`}getPathResizingSVGProperties([I,e,t,i]){const[A,n]=f(this,Be,$l).call(this),[l,s,a,d]=c(this,ot);if(Math.abs(a-A)<=Zg.PRECISION||Math.abs(d-n)<=Zg.PRECISION){const w=I+t/2-(l+a/2),G=e+i/2-(s+d/2);return{path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`,transform:`${this.rotationTransform} translate(${w} ${G})`}}}const m=(t-2*A)/(a-2*A),u=(i-2*n)/(d-2*n),b=a/t,Z=d/i;return{path:{"transform-origin":`${Zg.svgRound(l)} ${Zg.svgRound(s)}`,transform:`${this.rotationTransform} scale(${b} ${Z}) translate(${Zg.svgRound(A)} ${Zg.svgRound(n)}) scale(${m} ${u}) translate(${Zg.svgRound(-A)} ${Zg.svgRound(-n)})`}}}getPathResizedSVGProperties([I,e,t,i]){const[A,n]=f(this,Be,$l).call(this),l=c(this,ot),[s,a,d,m]=l;if(l[0]=I,l[1]=e,l[2]=t,l[3]=i,Math.abs(d-A)<=Zg.PRECISION||Math.abs(m-n)<=Zg.PRECISION){const G=I+t/2-(s+d/2),B=e+i/2-(a+m/2);for(const{line:p,points:Y}of c(this,ci))Zg._translate(p,G,B,p),Zg._translate(Y,G,B,Y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(t-2*A)/(d-2*A),b=(i-2*n)/(m-2*n),Z=-u*(s+A)+I+A,w=-b*(a+n)+e+n;if(u!==1||b!==1||Z!==0||w!==0)for(const{line:G,points:B}of c(this,ci))Zg._rescale(G,Z,w,u,b,G),Zg._rescale(B,Z,w,u,b,B);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([I,e],t){const[i,A]=t,n=c(this,ot),l=I-n[0],s=e-n[1];if(c(this,Nn)===i&&c(this,Mn)===A)for(const{line:a,points:d}of c(this,ci))Zg._translate(a,l,s,a),Zg._translate(d,l,s,d);else{const a=c(this,Nn)/i,d=c(this,Mn)/A;V(this,Nn,i),V(this,Mn,A);for(const{line:m,points:u}of c(this,ci))Zg._rescale(m,l,s,a,d,m),Zg._rescale(u,l,s,a,d,u);n[2]*=a,n[3]*=d}return n[0]=I,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Zg.svgRound(I)} ${Zg.svgRound(e)}`}}}get defaultSVGProperties(){const I=c(this,ot);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Zg.svgRound(I[0])} ${Zg.svgRound(I[1])}`,transform:this.rotationTransform||null},bbox:I}}}ot=new WeakMap,AZ=new WeakMap,nZ=new WeakMap,ci=new WeakMap,Nn=new WeakMap,Mn=new WeakMap,xm=new WeakMap,Om=new WeakMap,gc=new WeakMap,Be=new WeakSet,$l=function(I=c(this,gc)){const e=c(this,nZ)+I/2*c(this,xm);return c(this,Om)%180===0?[e/c(this,Nn),e/c(this,Mn)]:[e/c(this,Mn),e/c(this,Nn)]},kT=function(){const[I,e,t,i]=c(this,ot),[A,n]=f(this,Be,$l).call(this,0);return[I+A,e+n,t-2*A,i-2*n]},zT=function(){const I=V(this,ot,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of c(this,ci)){if(i.length<=12){for(let l=4,s=i.length;l<s;l+=6)wg.pointBoundingBox(i[l],i[l+1],I);continue}let A=i[4],n=i[5];for(let l=6,s=i.length;l<s;l+=6){const[a,d,m,u,b,Z]=i.subarray(l,l+6);wg.bezierBoundingBox(A,n,a,d,m,u,b,Z,I),A=b,n=Z}}const[e,t]=f(this,Be,$l).call(this);I[0]=gt(I[0]-e,0,1),I[1]=gt(I[1]-t,0,1),I[2]=gt(I[2]+e,0,1),I[3]=gt(I[3]+t,0,1),I[2]-=I[0],I[3]-=I[1]},FT=function(I){const[e,t]=f(this,Be,$l).call(this);V(this,gc,I);const[i,A]=f(this,Be,$l).call(this),[n,l]=[i-e,A-t],s=c(this,ot);return s[0]-=n,s[1]-=l,s[2]+=2*n,s[3]+=2*l,s};class Mw extends _S{constructor(g){super(),this._viewParameters=g,super.updateProperties({fill:"none",stroke:xI._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(g,I){g==="stroke-width"&&(I??(I=this["stroke-width"]),I*=this._viewParameters.realScale),super.updateSVGProperty(g,I)}clone(){const g=new Mw(this._viewParameters);return g.updateAll(this),g}}const Qm=class Qm extends Nw{constructor(I){super({...I,name:"inkEditor"});X(this,SB);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(I,e){xI.initialize(I,e),this._defaultDrawingOptions=new Mw(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Jg(this,"typesMap",new Map([[oI.INK_THICKNESS,"stroke-width"],[oI.INK_COLOR,"stroke"],[oI.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(I,e,t,i,A){return new Gjg(I,e,t,i,A,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(I,e,t,i,A,n){return Bh.deserialize(I,e,t,i,A,n)}static async deserialize(I,e,t){let i=null;if(I instanceof UY){const{data:{inkLists:n,rect:l,rotation:s,id:a,color:d,opacity:m,borderStyle:{rawWidth:u},popupRef:b,richText:Z,contentsObj:w,creationDate:G,modificationDate:B},parent:{page:{pageNumber:p}}}=I;i=I={annotationType:Tg.INK,color:Array.from(d),thickness:u,opacity:m,paths:{points:n},boxes:null,pageIndex:p-1,rect:l.slice(0),rotation:s,annotationElementId:a,id:a,deleted:!1,popupRef:b,richText:Z,comment:(w==null?void 0:w.str)||null,creationDate:G,modificationDate:B}}const A=await super.deserialize(I,e,t);return A._initialData=i,I.comment&&A.setCommentData(I),A}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Bw(this)),[["colorPicker",this._colorPicker]]}get colorType(){return oI.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:I,_drawingOptions:e,parent:t}=this;e.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(I,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const I=this._currentParent;I&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),I.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:I,thickness:e,opacity:t}){this._drawingOptions=Qm.getDefaultDrawingOptions({stroke:wg.makeHexColor(...I),"stroke-width":e,"stroke-opacity":t})}serialize(I=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:t}=this.serializeDraw(I),{_drawingOptions:{stroke:i,"stroke-opacity":A,"stroke-width":n}}=this,l=Object.assign(super.serialize(I),{color:xI._colorManager.convert(i),opacity:A,thickness:n,paths:{lines:e,points:t}});return this.addComment(l),I?(l.isCopy=!0,l):this.annotationElementId&&!f(this,SB,JT).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(I){if(this.deleted)return I.hide(),null;const{points:e,rect:t}=this.serializeDraw(!1);return I.updateEdited({rect:t,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}};SB=new WeakSet,JT=function(I){const{color:e,thickness:t,opacity:i,pageIndex:A}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||I.color.some((n,l)=>n!==e[l])||I.thickness!==t||I.opacity!==i||I.pageIndex!==A},sg(Qm,"_type","ink"),sg(Qm,"_editorType",Tg.INK),sg(Qm,"_defaultDrawingOptions",null);let qY=Qm;class gV extends Bh{toSVGPath(){let g=super.toSVGPath();return g.endsWith("Z")||(g+="Z"),g}}const Rw=8,ph=3;class jn{static extractContoursFromText(g,{fontFamily:I,fontStyle:e,fontWeight:t},i,A,n,l){let s=new OffscreenCanvas(1,1),a=s.getContext("2d",{alpha:!1});const d=200,m=a.font=`${e} ${t} ${d}px ${I}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:b,actualBoundingBoxAscent:Z,actualBoundingBoxDescent:w,fontBoundingBoxAscent:G,fontBoundingBoxDescent:B,width:p}=a.measureText(g),Y=1.5,y=Math.ceil(Math.max(Math.abs(u)+Math.abs(b)||0,p)*Y),R=Math.ceil(Math.max(Math.abs(Z)+Math.abs(w)||d,Math.abs(G)+Math.abs(B)||d)*Y);s=new OffscreenCanvas(y,R),a=s.getContext("2d",{alpha:!0,willReadFrequently:!0}),a.font=m,a.filter="grayscale(1)",a.fillStyle="white",a.fillRect(0,0,y,R),a.fillStyle="black",a.fillText(g,y*(Y-1)/2,R*(3-Y)/2);const M=f(this,bI,ER).call(this,a.getImageData(0,0,y,R).data),D=f(this,bI,xT).call(this,M),J=f(this,bI,PR).call(this,D),H=f(this,bI,UR).call(this,M,y,R,J);return this.processDrawnLines({lines:{curves:H,width:y,height:R},pageWidth:i,pageHeight:A,rotation:n,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(g,I,e,t,i){const[A,n,l]=f(this,bI,OT).call(this,g),[s,a]=f(this,bI,jT).call(this,A,n,l,Math.hypot(n,l)*c(this,Ic).sigmaSFactor,c(this,Ic).sigmaR,c(this,Ic).kernelSize),d=f(this,bI,PR).call(this,a),m=f(this,bI,UR).call(this,s,n,l,d);return this.processDrawnLines({lines:{curves:m,width:n,height:l},pageWidth:I,pageHeight:e,rotation:t,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:g,pageWidth:I,pageHeight:e,rotation:t,innerMargin:i,mustSmooth:A,areContours:n}){t%180!==0&&([I,e]=[e,I]);const{curves:l,width:s,height:a}=g,d=g.thickness??0,m=[],u=Math.min(I/s,e/a),b=u/I,Z=u/e,w=[];for(const{points:B}of l){const p=A?f(this,bI,vT).call(this,B):B;if(!p)continue;w.push(p);const Y=p.length,y=new Float32Array(Y),R=new Float32Array(3*(Y===2?2:Y-2));if(m.push({line:R,points:y}),Y===2){y[0]=p[0]*b,y[1]=p[1]*Z,R.set([NaN,NaN,NaN,NaN,y[0],y[1]],0);continue}let[M,D,J,H]=p;M*=b,D*=Z,J*=b,H*=Z,y.set([M,D,J,H],0),R.set([NaN,NaN,NaN,NaN,M,D],0);for(let z=4;z<Y;z+=2){const T=y[z]=p[z]*b,P=y[z+1]=p[z+1]*Z;R.set(Zg.createBezierPoints(M,D,J,H,T,P),(z-2)*3),[M,D,J,H]=[J,H,T,P]}}if(m.length===0)return null;const G=n?new gV:new Bh;return G.build(m,I,e,1,t,n?0:d,i),{outline:G,newCurves:w,areContours:n,thickness:d,width:s,height:a}}static async compressSignature({outlines:g,areContours:I,thickness:e,width:t,height:i}){let A=1/0,n=-1/0,l=0;for(const p of g){l+=p.length;for(let Y=2,y=p.length;Y<y;Y++){const R=p[Y]-p[Y-2];A=Math.min(A,R),n=Math.max(n,R)}}let s;A>=-128&&n<=127?s=Int8Array:A>=-32768&&n<=32767?s=Int16Array:s=Int32Array;const a=g.length,d=Rw+ph*a,m=new Uint32Array(d);let u=0;m[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*a)*s.BYTES_PER_ELEMENT,m[u++]=0,m[u++]=t,m[u++]=i,m[u++]=I?0:1,m[u++]=Math.max(0,Math.floor(e??0)),m[u++]=a,m[u++]=s.BYTES_PER_ELEMENT;for(const p of g)m[u++]=p.length-2,m[u++]=p[0],m[u++]=p[1];const b=new CompressionStream("deflate-raw"),Z=b.writable.getWriter();await Z.ready,Z.write(m);const w=s.prototype.constructor;for(const p of g){const Y=new w(p.length-2);for(let y=2,R=p.length;y<R;y++)Y[y-2]=p[y]-p[y-2];Z.write(Y)}Z.close();const G=await new Response(b.readable).arrayBuffer(),B=new Uint8Array(G);return IS(B)}static async decompressSignature(g){try{const I=KTg(g),{readable:e,writable:t}=new DecompressionStream("deflate-raw"),i=t.getWriter();await i.ready,i.write(I).then(async()=>{await i.ready,await i.close()}).catch(()=>{});let A=null,n=0;for await(const p of e)A||(A=new Uint8Array(new Uint32Array(p.buffer,0,4)[0])),A.set(p,n),n+=p.length;const l=new Uint32Array(A.buffer,0,A.length>>2),s=l[1];if(s!==0)throw new Error(`Invalid version: ${s}`);const a=l[2],d=l[3],m=l[4]===0,u=l[5],b=l[6],Z=l[7],w=[],G=(Rw+ph*b)*Uint32Array.BYTES_PER_ELEMENT;let B;switch(Z){case Int8Array.BYTES_PER_ELEMENT:B=new Int8Array(A.buffer,G);break;case Int16Array.BYTES_PER_ELEMENT:B=new Int16Array(A.buffer,G);break;case Int32Array.BYTES_PER_ELEMENT:B=new Int32Array(A.buffer,G);break}n=0;for(let p=0;p<b;p++){const Y=l[ph*p+Rw],y=new Float32Array(Y+2);w.push(y);for(let R=0;R<ph-1;R++)y[R]=l[ph*p+Rw+R+1];for(let R=0;R<Y;R++)y[R+2]=y[R]+B[n++]}return{areContours:m,thickness:u,outlines:w,width:a,height:d}}catch(I){return Fg(`decompressSignature: ${I}`),null}}}Ic=new WeakMap,bI=new WeakSet,QR=function(g,I,e,t){return e-=g,t-=I,e===0?t>0?0:4:e===1?t+6:2-t},XA=new WeakMap,LT=function(g,I,e,t,i,A,n){const l=f(this,bI,QR).call(this,e,t,i,A);for(let s=0;s<8;s++){const a=(-s+l-n+16)%8,d=c(this,XA)[2*a],m=c(this,XA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},TT=function(g,I,e,t,i,A,n){const l=f(this,bI,QR).call(this,e,t,i,A);for(let s=0;s<8;s++){const a=(s+l+n+16)%8,d=c(this,XA)[2*a],m=c(this,XA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},UR=function(g,I,e,t){const i=g.length,A=new Int32Array(i);for(let a=0;a<i;a++)A[a]=g[a]<=t?1:0;for(let a=1;a<e-1;a++)A[a*I]=A[a*I+I-1]=0;for(let a=0;a<I;a++)A[a]=A[I*e-1-a]=0;let n=1,l;const s=[];for(let a=1;a<e-1;a++){l=1;for(let d=1;d<I-1;d++){const m=a*I+d,u=A[m];if(u===0)continue;let b=a,Z=d;if(u===1&&A[m-1]===0)n+=1,Z-=1;else if(u>=1&&A[m+1]===0)n+=1,Z+=1,u>1&&(l=u);else{u!==1&&(l=Math.abs(u));continue}const w=[d,a],G=Z===d+1,B={isHole:G,points:w,id:n,parent:0};s.push(B);let p;for(const z of s)if(z.id===l){p=z;break}p?p.isHole?B.parent=G?p.parent:l:B.parent=G?l:p.parent:B.parent=G?l:0;const Y=f(this,bI,LT).call(this,A,I,a,d,b,Z,0);if(Y===-1){A[m]=-n,A[m]!==1&&(l=Math.abs(A[m]));continue}let y=c(this,XA)[2*Y],R=c(this,XA)[2*Y+1];const M=a+y,D=d+R;b=M,Z=D;let J=a,H=d;for(;;){const z=f(this,bI,TT).call(this,A,I,J,H,b,Z,1);y=c(this,XA)[2*z],R=c(this,XA)[2*z+1];const T=J+y,P=H+R;w.push(P,T);const Ig=J*I+H;if(A[Ig+1]===0?A[Ig]=-n:A[Ig]===1&&(A[Ig]=n),T===a&&P===d&&J===M&&H===D){A[m]!==1&&(l=Math.abs(A[m]));break}else b=J,Z=H,J=T,H=P}}}return s},Iy=function(g,I,e,t){if(e-I<=4){for(let M=I;M<e-2;M+=2)t.push(g[M],g[M+1]);return}const i=g[I],A=g[I+1],n=g[e-4]-i,l=g[e-3]-A,s=Math.hypot(n,l),a=n/s,d=l/s,m=a*A-d*i,u=l/n,b=1/s,Z=Math.atan(u),w=Math.cos(Z),G=Math.sin(Z),B=b*(Math.abs(w)+Math.abs(G)),p=b*(1-B+B**2),Y=Math.max(Math.atan(Math.abs(G+w)*p),Math.atan(Math.abs(G-w)*p));let y=0,R=I;for(let M=I+2;M<e-2;M+=2){const D=Math.abs(m-a*g[M+1]+d*g[M]);D>y&&(R=M,y=D)}y>(s*Y)**2?(f(this,bI,Iy).call(this,g,I,R+2,t),f(this,bI,Iy).call(this,g,R,e,t)):t.push(i,A)},vT=function(g){const I=[],e=g.length;return f(this,bI,Iy).call(this,g,0,e,I),I.push(g[e-2],g[e-1]),I.length<=4?null:I},jT=function(g,I,e,t,i,A){const n=new Float32Array(A**2),l=-2*t**2,s=A>>1;for(let Z=0;Z<A;Z++){const w=(Z-s)**2;for(let G=0;G<A;G++)n[Z*A+G]=Math.exp((w+(G-s)**2)/l)}const a=new Float32Array(256),d=-2*i**2;for(let Z=0;Z<256;Z++)a[Z]=Math.exp(Z**2/d);const m=g.length,u=new Uint8Array(m),b=new Uint32Array(256);for(let Z=0;Z<e;Z++)for(let w=0;w<I;w++){const G=Z*I+w,B=g[G];let p=0,Y=0;for(let R=0;R<A;R++){const M=Z+R-s;if(!(M<0||M>=e))for(let D=0;D<A;D++){const J=w+D-s;if(J<0||J>=I)continue;const H=g[M*I+J],z=n[R*A+D]*a[Math.abs(H-B)];p+=H*z,Y+=z}}const y=u[G]=Math.round(p/Y);b[y]++}return[u,b]},xT=function(g){const I=new Uint32Array(256);for(const e of g)I[e]++;return I},ER=function(g){const I=g.length,e=new Uint8ClampedArray(I>>2);let t=-1/0,i=1/0;for(let n=0,l=e.length;n<l;n++){const s=e[n]=g[n<<2];t=Math.max(t,s),i=Math.min(i,s)}const A=255/(t-i);for(let n=0,l=e.length;n<l;n++)e[n]=(e[n]-i)*A;return e},PR=function(g){let I,e=-1/0,t=-1/0;const i=g.findIndex(l=>l!==0);let A=i,n=i;for(I=i;I<256;I++){const l=g[I];l>e&&(I-A>t&&(t=I-A,n=I-1),e=l,A=I)}for(I=n-1;I>=0&&!(g[I]>g[I+1]);I--);return I},OT=function(g){const I=g,{width:e,height:t}=g,{maxDim:i}=c(this,Ic);let A=e,n=t;if(e>i||t>i){let m=e,u=t,b=Math.log2(Math.max(e,t)/i);const Z=Math.floor(b);b=b===Z?Z-1:Z;for(let G=0;G<b;G++){A=Math.ceil(m/2),n=Math.ceil(u/2);const B=new OffscreenCanvas(A,n);B.getContext("2d").drawImage(g,0,0,m,u,0,0,A,n),m=A,u=n,g!==I&&g.close(),g=B.transferToImageBitmap()}const w=Math.min(i/A,i/n);A=Math.round(A*w),n=Math.round(n*w)}const s=new OffscreenCanvas(A,n).getContext("2d",{willReadFrequently:!0});s.fillStyle="white",s.fillRect(0,0,A,n),s.filter="grayscale(1)",s.drawImage(g,0,0,g.width,g.height,0,0,A,n);const a=s.getImageData(0,0,A,n).data;return[f(this,bI,ER).call(this,a),A,n]},X(jn,bI),X(jn,Ic,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),X(jn,XA,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class IV extends _S{constructor(){super(),super.updateProperties({fill:xI._defaultLineColor,"stroke-width":0})}clone(){const g=new IV;return g.updateAll(this),g}}class CV extends Mw{constructor(g){super(g),super.updateProperties({stroke:xI._defaultLineColor,"stroke-width":1})}clone(){const g=new CV(this._viewParameters);return g.updateAll(this),g}}const ri=class ri extends Nw{constructor(I){super({...I,mustBeCommitted:!0,name:"signatureEditor"});X(this,yo,!1);X(this,Rn,null);X(this,Yo,null);X(this,Cc,null);this._willKeepAspectRatio=!0,V(this,Yo,I.signatureData||null),V(this,Rn,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(I,e){xI.initialize(I,e),this._defaultDrawingOptions=new IV,this._defaultDrawnSignatureOptions=new CV(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Jg(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!c(this,Rn)}}static computeTelemetryFinalData(I){const e=I.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let I,e;const{_isCopy:t}=this;if(t&&(this._isCopy=!1,I=this.x,e=this.y),super.render(),this._drawId===null)if(c(this,Yo)){const{lines:i,mustSmooth:A,areContours:n,description:l,uuid:s,heightInPage:a}=c(this,Yo),{rawDims:{pageWidth:d,pageHeight:m},rotation:u}=this.parent.viewport,b=jn.processDrawnLines({lines:i,pageWidth:d,pageHeight:m,rotation:u,innerMargin:ri._INNER_MARGIN,mustSmooth:A,areContours:n});this.addSignature(b,a,l,s)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:c(this,Rn)||""}));return t&&(this._isCopy=!0,this._moveAfterPaste(I,e)),this.div}setUuid(I){V(this,Cc,I),this.addEditToolbar()}getUuid(){return c(this,Cc)}get description(){return c(this,Rn)}set description(I){V(this,Rn,I),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:I})),super.addEditToolbar().then(e=>{e==null||e.updateEditSignatureButton(I)}))}getSignaturePreview(){const{newCurves:I,areContours:e,thickness:t,width:i,height:A}=c(this,Yo),n=Math.max(i,A),l=jn.processDrawnLines({lines:{curves:I.map(s=>({points:s})),thickness:t,width:i,height:A},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(I,e,t,i){const{x:A,y:n}=this,{outline:l}=V(this,Yo,I);V(this,yo,l instanceof gV),this.description=t;let s;c(this,yo)?s=ri.getDefaultDrawingOptions():(s=ri._defaultDrawnSignatureOptions.clone(),s.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:s});const[,a]=this.pageDimensions;let d=e/a;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=A,this.y=n,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!t}}),this.div.hidden=!1}getFromImage(I){const{rawDims:{pageWidth:e,pageHeight:t},rotation:i}=this.parent.viewport;return jn.process(I,e,t,i,ri._INNER_MARGIN)}getFromText(I,e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:A}=this.parent.viewport;return jn.extractContoursFromText(I,e,t,i,A,ri._INNER_MARGIN)}getDrawnSignature(I){const{rawDims:{pageWidth:e,pageHeight:t},rotation:i}=this.parent.viewport;return jn.processDrawnLines({lines:I,pageWidth:e,pageHeight:t,rotation:i,innerMargin:ri._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:I,thickness:e}){I?this._drawingOptions=ri.getDefaultDrawingOptions():(this._drawingOptions=ri._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(I=!1){if(this.isEmpty())return null;const{lines:e,points:t}=this.serializeDraw(I),{_drawingOptions:{"stroke-width":i}}=this,A=Object.assign(super.serialize(I),{isSignature:!0,areContours:c(this,yo),color:[0,0,0],thickness:c(this,yo)?0:i});return this.addComment(A),I?(A.paths={lines:e,points:t},A.uuid=c(this,Cc),A.isCopy=!0):A.lines=e,c(this,Rn)&&(A.accessibilityData={type:"Figure",alt:c(this,Rn)}),A}static deserializeDraw(I,e,t,i,A,n){return n.areContours?gV.deserialize(I,e,t,i,A,n):Bh.deserialize(I,e,t,i,A,n)}static async deserialize(I,e,t){var A;const i=await super.deserialize(I,e,t);return V(i,yo,I.areContours),i.description=((A=I.accessibilityData)==null?void 0:A.alt)||"",V(i,Cc,I.uuid),i}};yo=new WeakMap,Rn=new WeakMap,Yo=new WeakMap,Cc=new WeakMap,sg(ri,"_type","signature"),sg(ri,"_editorType",Tg.SIGNATURE),sg(ri,"_defaultDrawingOptions",null);let eV=ri;class tV extends xI{constructor(I){super({...I,name:"stampEditor"});X(this,mI);X(this,CC,null);X(this,le,null);X(this,Vo,null);X(this,Kl,null);X(this,No,null);X(this,Um,"");X(this,kl,null);X(this,ec,!1);X(this,Xn,null);X(this,mi,!1);X(this,Em,!1);V(this,Kl,I.bitmapUrl),V(this,No,I.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(I,e){xI.initialize(I,e)}static isHandlingMimeForPasting(I){return BY.includes(I)}static paste(I,e){e.pasteEditor({mode:Tg.STAMP},{bitmapFile:I.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var I;return{type:"stamp",hasAltText:!!((I=this.altTextData)!=null&&I.altText)}}static computeTelemetryFinalData(I){const e=I.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(I=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:t}=this._uiManager;if(!t)throw new Error("No ML.");if(!await t.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:A,height:n}=I||this.copyCanvas(null,null,!0).imageData,l=await t.guess({name:"altText",request:{data:i,width:A,height:n,channels:i.length/(A*n)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const s=l.output;return await this.setGuessedAltText(s),e&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1}),s}remove(){var I;c(this,le)&&(V(this,CC,null),this._uiManager.imageManager.deleteId(c(this,le)),(I=c(this,kl))==null||I.remove(),V(this,kl,null),c(this,Xn)&&(clearTimeout(c(this,Xn)),V(this,Xn,null))),super.remove()}rebuild(){if(!this.parent){c(this,le)&&f(this,mI,Cy).call(this);return}super.rebuild(),this.div!==null&&(c(this,le)&&c(this,kl)===null&&f(this,mI,Cy).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(I){this._isDraggable=!0,I&&this.div.focus()}isEmpty(){return!(c(this,Vo)||c(this,CC)||c(this,Kl)||c(this,No)||c(this,le)||c(this,ec))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let I,e;return this._isCopy&&(I=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),c(this,ec)||(c(this,CC)?f(this,mI,ey).call(this):f(this,mI,Cy).call(this)),this._isCopy&&this._moveAfterPaste(I,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(I,e){const{id:t,bitmap:i}=this._uiManager.imageManager.getFromCanvas(I,e);e.remove(),t&&this._uiManager.imageManager.isValidId(t)&&(V(this,le,t),i&&V(this,CC,i),V(this,ec,!1),f(this,mI,ey).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;c(this,Xn)!==null&&clearTimeout(c(this,Xn)),V(this,Xn,setTimeout(()=>{V(this,Xn,null),f(this,mI,_R).call(this)},200))}copyCanvas(I,e,t=!1){I||(I=224);const{width:i,height:A}=c(this,CC),n=new _A;let l=c(this,CC),s=i,a=A,d=null;if(e){if(i>e||A>e){const M=Math.min(e/i,e/A);s=Math.floor(i*M),a=Math.floor(A*M)}d=document.createElement("canvas");const u=d.width=Math.ceil(s*n.sx),b=d.height=Math.ceil(a*n.sy);c(this,mi)||(l=f(this,mI,ty).call(this,u,b));const Z=d.getContext("2d");Z.filter=this._uiManager.hcmFilter;let w="white",G="#cfcfd8";this._uiManager.hcmFilter!=="none"?G="black":TTg.isDarkMode&&(w="#8f8f9d",G="#42414d");const B=15,p=B*n.sx,Y=B*n.sy,y=new OffscreenCanvas(p*2,Y*2),R=y.getContext("2d");R.fillStyle=w,R.fillRect(0,0,p*2,Y*2),R.fillStyle=G,R.fillRect(0,0,p,Y),R.fillRect(p,Y,p,Y),Z.fillStyle=Z.createPattern(y,"repeat"),Z.fillRect(0,0,u,b),Z.drawImage(l,0,0,l.width,l.height,0,0,u,b)}let m=null;if(t){let u,b;if(n.symmetric&&l.width<I&&l.height<I)u=l.width,b=l.height;else if(l=c(this,CC),i>I||A>I){const G=Math.min(I/i,I/A);u=Math.floor(i*G),b=Math.floor(A*G),c(this,mi)||(l=f(this,mI,ty).call(this,u,b))}const w=new OffscreenCanvas(u,b).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,u,b),m={width:u,height:b,data:w.getImageData(0,0,u,b).data}}return{canvas:d,width:s,height:a,imageData:m}}static async deserialize(I,e,t){var w;let i=null,A=!1;if(I instanceof ES){const{data:{rect:G,rotation:B,id:p,structParent:Y,popupRef:y,richText:R,contentsObj:M,creationDate:D,modificationDate:J},container:H,parent:{page:{pageNumber:z}},canvas:T}=I;let P,Ig;T?(delete I.canvas,{id:P,bitmap:Ig}=t.imageManager.getFromCanvas(H.id,T),T.remove()):(A=!0,I._hasNoCanvas=!0);const gg=((w=await e._structTree.getAriaAttributes(`${Qc}${p}`))==null?void 0:w.get("aria-label"))||"";i=I={annotationType:Tg.STAMP,bitmapId:P,bitmap:Ig,pageIndex:z-1,rect:G.slice(0),rotation:B,annotationElementId:p,id:p,deleted:!1,accessibilityData:{decorative:!1,altText:gg},isSvg:!1,structParent:Y,popupRef:y,richText:R,comment:(M==null?void 0:M.str)||null,creationDate:D,modificationDate:J}}const n=await super.deserialize(I,e,t),{rect:l,bitmap:s,bitmapUrl:a,bitmapId:d,isSvg:m,accessibilityData:u}=I;A?(t.addMissingCanvas(I.id,n),V(n,ec,!0)):d&&t.imageManager.isValidId(d)?(V(n,le,d),s&&V(n,CC,s)):V(n,Kl,a),V(n,mi,m);const[b,Z]=n.pageDimensions;return n.width=(l[2]-l[0])/b,n.height=(l[3]-l[1])/Z,u&&(n.altTextData=u),n._initialData=i,I.comment&&n.setCommentData(I),V(n,Em,!!i),n}serialize(I=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const t=Object.assign(super.serialize(I),{bitmapId:c(this,le),isSvg:c(this,mi)});if(this.addComment(t),I)return t.bitmapUrl=f(this,mI,iy).call(this,!0),t.accessibilityData=this.serializeAltText(!0),t.isCopy=!0,t;const{decorative:i,altText:A}=this.serializeAltText(!1);if(!i&&A&&(t.accessibilityData={type:"Figure",alt:A}),this.annotationElementId){const l=f(this,mI,QT).call(this,t);return l.isSame?null:(l.isSameAltText?delete t.accessibilityData:t.accessibilityData.structParent=this._initialData.structParent??-1,t.id=this.annotationElementId,delete t.bitmapId,t)}if(e===null)return t;e.stamps||(e.stamps=new Map);const n=c(this,mi)?(t.rect[2]-t.rect[0])*(t.rect[3]-t.rect[1]):null;if(!e.stamps.has(c(this,le)))e.stamps.set(c(this,le),{area:n,serialized:t}),t.bitmap=f(this,mI,iy).call(this,!1);else if(c(this,mi)){const l=e.stamps.get(c(this,le));n>l.area&&(l.area=n,l.serialized.bitmap.close(),l.serialized.bitmap=f(this,mI,iy).call(this,!1))}return t}renderAnnotationElement(I){return this.deleted?(I.hide(),null):(I.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}CC=new WeakMap,le=new WeakMap,Vo=new WeakMap,Kl=new WeakMap,No=new WeakMap,Um=new WeakMap,kl=new WeakMap,ec=new WeakMap,Xn=new WeakMap,mi=new WeakMap,Em=new WeakMap,mI=new WeakSet,TZ=function(I,e=!1){if(!I){this.remove();return}V(this,CC,I.bitmap),e||(V(this,le,I.id),V(this,mi,I.isSvg)),I.file&&V(this,Um,I.file.name),f(this,mI,ey).call(this)},vZ=function(){if(V(this,Vo,null),this._uiManager.enableWaiting(!1),!!c(this,kl)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,CC)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,CC)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Cy=function(){if(c(this,le)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,le)).then(t=>f(this,mI,TZ).call(this,t,!0)).finally(()=>f(this,mI,vZ).call(this));return}if(c(this,Kl)){const t=c(this,Kl);V(this,Kl,null),this._uiManager.enableWaiting(!0),V(this,Vo,this._uiManager.imageManager.getFromUrl(t).then(i=>f(this,mI,TZ).call(this,i)).finally(()=>f(this,mI,vZ).call(this)));return}if(c(this,No)){const t=c(this,No);V(this,No,null),this._uiManager.enableWaiting(!0),V(this,Vo,this._uiManager.imageManager.getFromFile(t).then(i=>f(this,mI,TZ).call(this,i)).finally(()=>f(this,mI,vZ).call(this)));return}const I=document.createElement("input");I.type="file",I.accept=BY.join(",");const e=this._uiManager._signal;V(this,Vo,new Promise(t=>{I.addEventListener("change",async()=>{if(!I.files||I.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(I.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),f(this,mI,TZ).call(this,i)}t()},{signal:e}),I.addEventListener("cancel",()=>{this.remove(),t()},{signal:e})}).finally(()=>f(this,mI,vZ).call(this))),I.click()},ey=function(){var s;const{div:I}=this;let{width:e,height:t}=c(this,CC);const[i,A]=this.pageDimensions,n=.75;if(this.width)e=this.width*i,t=this.height*A;else if(e>n*i||t>n*A){const a=Math.min(n*i/e,n*A/t);e*=a,t*=a}this._uiManager.enableWaiting(!1);const l=V(this,kl,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=e/i,this.height=t/A,this.setDims(),(s=this._initialOptions)!=null&&s.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(I.hidden=!1),f(this,mI,_R).call(this),c(this,Em)||(this.parent.addUndoableEditor(this),V(this,Em,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,Um)&&this.div.setAttribute("aria-description",c(this,Um)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},ty=function(I,e){const{width:t,height:i}=c(this,CC);let A=t,n=i,l=c(this,CC);for(;A>2*I||n>2*e;){const s=A,a=n;A>2*I&&(A=A>=16384?Math.floor(A/2)-1:Math.ceil(A/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));const d=new OffscreenCanvas(A,n);d.getContext("2d").drawImage(l,0,0,s,a,0,0,A,n),l=d.transferToImageBitmap()}return l},_R=function(){const[I,e]=this.parentDimensions,{width:t,height:i}=this,A=new _A,n=Math.ceil(t*I*A.sx),l=Math.ceil(i*e*A.sy),s=c(this,kl);if(!s||s.width===n&&s.height===l)return;s.width=n,s.height=l;const a=c(this,mi)?c(this,CC):f(this,mI,ty).call(this,n,l),d=s.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(a,0,0,a.width,a.height,0,0,n,l)},iy=function(I){if(I){if(c(this,mi)){const i=this._uiManager.imageManager.getSvgUrl(c(this,le));if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=c(this,CC),e.getContext("2d").drawImage(c(this,CC),0,0),e.toDataURL()}if(c(this,mi)){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*hs.PDF_TO_CSS_UNITS),A=Math.round(this.height*t*hs.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,A);return n.getContext("2d").drawImage(c(this,CC),0,0,c(this,CC).width,c(this,CC).height,0,0,i,A),n.transferToImageBitmap()}return structuredClone(c(this,CC))},QT=function(I){var n;const{pageIndex:e,accessibilityData:{altText:t}}=this._initialData,i=I.pageIndex===e,A=(((n=I.accessibilityData)==null?void 0:n.alt)||"")===t;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&A,isSameAltText:A}},sg(tV,"_type","stamp"),sg(tV,"_editorType",Tg.STAMP);const fA=class fA{constructor({uiManager:g,pageIndex:I,div:e,structTreeLayer:t,accessibilityManager:i,annotationLayer:A,drawLayer:n,textLayer:l,viewport:s,l10n:a}){X(this,LI);X(this,tc);X(this,Pm,!1);X(this,Mo,null);X(this,Ro,null);X(this,zl,null);X(this,Kt,new Map);X(this,Xo,!1);X(this,_m,!1);X(this,$m,!1);X(this,HA,null);X(this,Fl,null);X(this,se,null);X(this,Jl,null);X(this,Ho,null);X(this,qm,-1);X(this,Wg);const d=[...c(fA,fo).values()];if(!fA._initialized){fA._initialized=!0;for(const m of d)m.initialize(a,g)}g.registerEditorTypes(d),V(this,Wg,g),this.pageIndex=I,this.div=e,V(this,tc,i),V(this,Mo,A),this.viewport=s,V(this,se,l),this.drawLayer=n,this._structTree=t,c(this,Wg).addLayer(this)}get isEmpty(){return c(this,Kt).size===0}get isInvisible(){return this.isEmpty&&c(this,Wg).getMode()===Tg.NONE}updateToolbar(g){c(this,Wg).updateToolbar(g)}updateMode(g=c(this,Wg).getMode()){switch(f(this,LI,Ay).call(this),g){case Tg.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Tg.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Tg.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:I}=this.div;if(I.toggle("nonEditing",!1),g===Tg.POPUP)I.toggle("commentEditing",!0);else{I.toggle("commentEditing",!1);for(const e of c(fA,fo).values())I.toggle(`${e._type}Editing`,g===e._editorType)}this.div.hidden=!1}hasTextLayer(g){var I;return g===((I=c(this,se))==null?void 0:I.div)}setEditingState(g){c(this,Wg).setEditingState(g)}addCommands(g){c(this,Wg).addCommands(g)}cleanUndoStack(g){c(this,Wg).cleanUndoStack(g)}toggleDrawing(g=!1){this.div.classList.toggle("drawing",!g)}togglePointerEvents(g=!1){this.div.classList.toggle("disabled",!g)}toggleAnnotationLayerPointerEvents(g=!1){var I;(I=c(this,Mo))==null||I.togglePointerEvents(g)}async enable(){var e;V(this,$m,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(e=c(this,Ho))==null||e.abort(),V(this,Ho,null);const g=new Set;for(const t of c(this,LI,$R))t.enableEditing(),t.show(!0),t.annotationElementId&&(c(this,Wg).removeChangedExistingAnnotation(t),g.add(t.annotationElementId));const I=c(this,Mo);if(I)for(const t of I.getEditableAnnotations()){if(t.hide(),c(this,Wg).isDeletedAnnotationElement(t.data.id)||g.has(t.data.id))continue;const i=await this.deserialize(t);i&&(this.addOrRebuild(i),i.enableEditing())}V(this,$m,!1),c(this,Wg)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var t;if(V(this,_m,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),c(this,se)&&!c(this,Ho)){V(this,Ho,new AbortController);const i=c(this,Wg).combinedSignal(c(this,Ho));c(this,se).div.addEventListener("pointerdown",A=>{const{clientX:l,clientY:s,timeStamp:a}=A,d=c(this,qm);if(a-d>500){V(this,qm,a);return}V(this,qm,-1);const{classList:m}=this.div;m.toggle("getElements",!0);const u=document.elementsFromPoint(l,s);if(m.toggle("getElements",!1),!this.div.contains(u[0]))return;let b;const Z=new RegExp(`^${Ah}[0-9]+$`);for(const G of u)if(Z.test(G.id)){b=G.id;break}if(!b)return;const w=c(this,Kt).get(b);(w==null?void 0:w.annotationElementId)===null&&(A.stopPropagation(),A.preventDefault(),w.dblclick(A))},{signal:i,capture:!0})}const g=c(this,Mo),I=[];if(g){const i=new Map,A=new Map;for(const l of c(this,LI,$R)){if(l.disableEditing(),!l.annotationElementId){I.push(l);continue}if(l.serialize()!==null){i.set(l.annotationElementId,l);continue}else A.set(l.annotationElementId,l);(t=this.getEditableAnnotation(l.annotationElementId))==null||t.show(),l.remove()}const n=g.getEditableAnnotations();for(const l of n){const{id:s}=l.data;if(c(this,Wg).isDeletedAnnotationElement(s)){l.updateEdited({deleted:!0});continue}let a=A.get(s);if(a){a.resetAnnotationElement(l),a.show(!1),l.show();continue}a=i.get(s),a&&(c(this,Wg).addChangedExistingAnnotation(a),a.renderAnnotationElement(l)&&a.show(!1)),l.show()}}f(this,LI,Ay).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const i of c(fA,fo).values())e.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),g==null||g.updateFakeAnnotations(I),V(this,_m,!1)}getEditableAnnotation(g){var I;return((I=c(this,Mo))==null?void 0:I.getEditableAnnotation(g))||null}setActiveEditor(g){c(this,Wg).getActive()!==g&&c(this,Wg).setActiveEditor(g)}enableTextSelection(){var g;if(this.div.tabIndex=-1,(g=c(this,se))!=null&&g.div&&!c(this,Jl)){V(this,Jl,new AbortController);const I=c(this,Wg).combinedSignal(c(this,Jl));c(this,se).div.addEventListener("pointerdown",f(this,LI,UT).bind(this),{signal:I}),c(this,se).div.classList.add("highlighting")}}disableTextSelection(){var g;this.div.tabIndex=0,(g=c(this,se))!=null&&g.div&&c(this,Jl)&&(c(this,Jl).abort(),V(this,Jl,null),c(this,se).div.classList.remove("highlighting"))}enableClick(){if(c(this,Ro))return;V(this,Ro,new AbortController);const g=c(this,Wg).combinedSignal(c(this,Ro));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:g});const I=this.pointerup.bind(this);this.div.addEventListener("pointerup",I,{signal:g}),this.div.addEventListener("pointercancel",I,{signal:g})}disableClick(){var g;(g=c(this,Ro))==null||g.abort(),V(this,Ro,null)}attach(g){c(this,Kt).set(g.id,g);const{annotationElementId:I}=g;I&&c(this,Wg).isDeletedAnnotationElement(I)&&c(this,Wg).removeDeletedAnnotationElement(g)}detach(g){var I;c(this,Kt).delete(g.id),(I=c(this,tc))==null||I.removePointerInTextLayer(g.contentDiv),!c(this,_m)&&g.annotationElementId&&c(this,Wg).addDeletedAnnotationElement(g)}remove(g){this.detach(g),c(this,Wg).removeEditor(g),g.div.remove(),g.isAttachedToDOM=!1}changeParent(g){var I;g.parent!==this&&(g.parent&&g.annotationElementId&&(c(this,Wg).addDeletedAnnotationElement(g),xI.deleteAnnotationElement(g),g.annotationElementId=null),this.attach(g),(I=g.parent)==null||I.detach(g),g.setParent(this),g.div&&g.isAttachedToDOM&&(g.div.remove(),this.div.append(g.div)))}add(g){if(!(g.parent===this&&g.isAttachedToDOM)){if(this.changeParent(g),c(this,Wg).addEditor(g),this.attach(g),!g.isAttachedToDOM){const I=g.render();this.div.append(I),g.isAttachedToDOM=!0}g.fixAndSetPosition(),g.onceAdded(!c(this,$m)),c(this,Wg).addToAnnotationStorage(g),g._reportTelemetry(g.telemetryInitialData)}}moveEditorInDOM(g){var e;if(!g.isAttachedToDOM)return;const{activeElement:I}=document;g.div.contains(I)&&!c(this,zl)&&(g._focusEventsAllowed=!1,V(this,zl,setTimeout(()=>{V(this,zl,null),g.div.contains(document.activeElement)?g._focusEventsAllowed=!0:(g.div.addEventListener("focusin",()=>{g._focusEventsAllowed=!0},{once:!0,signal:c(this,Wg)._signal}),I.focus())},0))),g._structTreeParentId=(e=c(this,tc))==null?void 0:e.moveElementInDOM(this.div,g.div,g.contentDiv,!0)}addOrRebuild(g){g.needsToBeRebuilt()?(g.parent||(g.parent=this),g.rebuild(),g.show()):this.add(g)}addUndoableEditor(g){const I=()=>g._uiManager.rebuild(g),e=()=>{g.remove()};this.addCommands({cmd:I,undo:e,mustExec:!1})}getEditorByUID(g){for(const I of c(this,Kt).values())if(I.uid===g)return I;return null}getNextId(){return c(this,Wg).getId()}combinedSignal(g){return c(this,Wg).combinedSignal(g)}canCreateNewEmptyEditor(){var g;return(g=c(this,LI,kn))==null?void 0:g.canCreateNewEmptyEditor()}async pasteEditor(g,I){this.updateToolbar(g),await c(this,Wg).updateMode(g.mode);const{offsetX:e,offsetY:t}=f(this,LI,gX).call(this),i=this.getNextId(),A=f(this,LI,qR).call(this,{parent:this,id:i,x:e,y:t,uiManager:c(this,Wg),isCentered:!0,...I});A&&this.add(A)}async deserialize(g){var I;return await((I=c(fA,fo).get(g.annotationType??g.annotationEditorType))==null?void 0:I.deserialize(g,this,c(this,Wg)))||null}createAndAddNewEditor(g,I,e={}){const t=this.getNextId(),i=f(this,LI,qR).call(this,{parent:this,id:t,x:g.offsetX,y:g.offsetY,uiManager:c(this,Wg),isCentered:I,...e});return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(g={}){this.createAndAddNewEditor(f(this,LI,gX).call(this),!0,g)}setSelected(g){c(this,Wg).setSelected(g)}toggleSelected(g){c(this,Wg).toggleSelected(g)}unselect(g){c(this,Wg).unselect(g)}pointerup(g){var t;const{isMac:I}=de.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div||!c(this,Xo)||(V(this,Xo,!1),(t=c(this,LI,kn))!=null&&t.isDrawer&&c(this,LI,kn).supportMultipleDrawings))return;if(!c(this,Pm)){V(this,Pm,!0);return}const e=c(this,Wg).getMode();if(e===Tg.STAMP||e===Tg.SIGNATURE){c(this,Wg).unselectAll();return}this.createAndAddNewEditor(g,!1)}pointerdown(g){var t;if(c(this,Wg).getMode()===Tg.HIGHLIGHT&&this.enableTextSelection(),c(this,Xo)){V(this,Xo,!1);return}const{isMac:I}=de.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div)return;if(V(this,Xo,!0),(t=c(this,LI,kn))!=null&&t.isDrawer){this.startDrawingSession(g);return}const e=c(this,Wg).getActive();V(this,Pm,!e||e.isEmpty())}startDrawingSession(g){if(this.div.focus({preventScroll:!0}),c(this,HA)){c(this,LI,kn).startDrawing(this,c(this,Wg),!1,g);return}c(this,Wg).setCurrentDrawingSession(this),V(this,HA,new AbortController);const I=c(this,Wg).combinedSignal(c(this,HA));this.div.addEventListener("blur",({relatedTarget:e})=>{e&&!this.div.contains(e)&&(V(this,Fl,null),this.commitOrRemove())},{signal:I}),c(this,LI,kn).startDrawing(this,c(this,Wg),!1,g)}pause(g){if(g){const{activeElement:I}=document;this.div.contains(I)&&V(this,Fl,I);return}c(this,Fl)&&setTimeout(()=>{var I;(I=c(this,Fl))==null||I.focus(),V(this,Fl,null)},0)}endDrawingSession(g=!1){return c(this,HA)?(c(this,Wg).setCurrentDrawingSession(null),c(this,HA).abort(),V(this,HA,null),V(this,Fl,null),c(this,LI,kn).endDrawing(g)):null}findNewParent(g,I,e){const t=c(this,Wg).findParent(I,e);return t===null||t===this?!1:(t.changeParent(g),!0)}commitOrRemove(){return c(this,HA)?(this.endDrawingSession(),!0):!1}onScaleChanging(){c(this,HA)&&c(this,LI,kn).onScaleChangingWhenDrawing(this)}destroy(){var g,I;this.commitOrRemove(),((g=c(this,Wg).getActive())==null?void 0:g.parent)===this&&(c(this,Wg).commitOrRemove(),c(this,Wg).setActiveEditor(null)),c(this,zl)&&(clearTimeout(c(this,zl)),V(this,zl,null));for(const e of c(this,Kt).values())(I=c(this,tc))==null||I.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,c(this,Kt).clear(),c(this,Wg).removeLayer(this)}render({viewport:g}){this.viewport=g,ha(this.div,g);for(const I of c(this,Wg).getEditors(this.pageIndex))this.add(I),I.rebuild();this.updateMode()}update({viewport:g}){c(this,Wg).commitOrRemove(),f(this,LI,Ay).call(this);const I=this.viewport.rotation,e=g.rotation;if(this.viewport=g,ha(this.div,{rotation:e}),I!==e)for(const t of c(this,Kt).values())t.rotate(e)}get pageDimensions(){const{pageWidth:g,pageHeight:I}=this.viewport.rawDims;return[g,I]}get scale(){return c(this,Wg).viewParameters.realScale}};tc=new WeakMap,Pm=new WeakMap,Mo=new WeakMap,Ro=new WeakMap,zl=new WeakMap,Kt=new WeakMap,Xo=new WeakMap,_m=new WeakMap,$m=new WeakMap,HA=new WeakMap,Fl=new WeakMap,se=new WeakMap,Jl=new WeakMap,Ho=new WeakMap,qm=new WeakMap,Wg=new WeakMap,fo=new WeakMap,LI=new WeakSet,$R=function(){return c(this,Kt).size!==0?c(this,Kt).values():c(this,Wg).getEditors(this.pageIndex)},UT=function(g){c(this,Wg).unselectAll();const{target:I}=g;if(I===c(this,se).div||(I.getAttribute("role")==="img"||I.classList.contains("endOfContent"))&&c(this,se).div.contains(I)){const{isMac:e}=de.platform;if(g.button!==0||g.ctrlKey&&e)return;c(this,Wg).showAllEditors("highlight",!0,!0),c(this,se).div.classList.add("free"),this.toggleDrawing(),Vw.startHighlighting(this,c(this,Wg).direction==="ltr",{target:c(this,se).div,x:g.x,y:g.y}),c(this,se).div.addEventListener("pointerup",()=>{c(this,se).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,Wg)._signal}),g.preventDefault()}},kn=function(){return c(fA,fo).get(c(this,Wg).getMode())},qR=function(g){const I=c(this,LI,kn);return I?new I.prototype.constructor(g):null},gX=function(){const{x:g,y:I,width:e,height:t}=this.boundingClientRect,i=Math.max(0,g),A=Math.max(0,I),n=Math.min(window.innerWidth,g+e),l=Math.min(window.innerHeight,I+t),s=(i+n)/2-g,a=(A+l)/2-I,[d,m]=this.viewport.rotation%180===0?[s,a]:[a,s];return{offsetX:d,offsetY:m}},Ay=function(){for(const g of c(this,Kt).values())g.isEmpty()&&g.remove()},sg(fA,"_initialized",!1),X(fA,fo,new Map([PY,qY,tV,Vw,eV].map(g=>[g._editorType,g])));let iV=fA;const QC=class QC{constructor({pageIndex:g}){X(this,Hn);X(this,DA,null);X(this,at,new Map);X(this,ic,new Map);this.pageIndex=g}setParent(g){if(!c(this,DA)){V(this,DA,g);return}if(c(this,DA)!==g){if(c(this,at).size>0)for(const I of c(this,at).values())I.remove(),g.append(I);V(this,DA,g)}}static get _svgFactory(){return Jg(this,"_svgFactory",new pw)}draw(g,I=!1,e=!1){const t=PC(QC,lZ)._++,i=f(this,Hn,IX).call(this),A=QC._svgFactory.createElement("defs");i.append(A);const n=QC._svgFactory.createElement("path");A.append(n);const l=`path_p${this.pageIndex}_${t}`;n.setAttribute("id",l),n.setAttribute("vector-effect","non-scaling-stroke"),I&&c(this,ic).set(t,n);const s=e?f(this,Hn,PT).call(this,A,l):null,a=QC._svgFactory.createElement("use");return i.append(a),a.setAttribute("href",`#${l}`),this.updateProperties(i,g),c(this,at).set(t,i),{id:t,clipPathId:`url(#${s})`}}drawOutline(g,I){const e=PC(QC,lZ)._++,t=f(this,Hn,IX).call(this),i=QC._svgFactory.createElement("defs");t.append(i);const A=QC._svgFactory.createElement("path");i.append(A);const n=`path_p${this.pageIndex}_${e}`;A.setAttribute("id",n),A.setAttribute("vector-effect","non-scaling-stroke");let l;if(I){const d=QC._svgFactory.createElement("mask");i.append(d),l=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const m=QC._svgFactory.createElement("rect");d.append(m),m.setAttribute("width","1"),m.setAttribute("height","1"),m.setAttribute("fill","white");const u=QC._svgFactory.createElement("use");d.append(u),u.setAttribute("href",`#${n}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}const s=QC._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${n}`),l&&s.setAttribute("mask",`url(#${l})`);const a=s.cloneNode();return t.append(a),s.classList.add("mainOutline"),a.classList.add("secondaryOutline"),this.updateProperties(t,g),c(this,at).set(e,t),e}finalizeDraw(g,I){c(this,ic).delete(g),this.updateProperties(g,I)}updateProperties(g,I){var l;if(!I)return;const{root:e,bbox:t,rootClass:i,path:A}=I,n=typeof g=="number"?c(this,at).get(g):g;if(n){if(e&&f(this,Hn,CX).call(this,n,e),t&&f(l=QC,KB,ET).call(l,n,t),i){const{classList:s}=n;for(const[a,d]of Object.entries(i))s.toggle(a,d)}if(A){const a=n.firstElementChild.firstElementChild;f(this,Hn,CX).call(this,a,A)}}}updateParent(g,I){if(I===this)return;const e=c(this,at).get(g);e&&(c(I,DA).append(e),c(this,at).delete(g),c(I,at).set(g,e))}remove(g){c(this,ic).delete(g),c(this,DA)!==null&&(c(this,at).get(g).remove(),c(this,at).delete(g))}destroy(){V(this,DA,null);for(const g of c(this,at).values())g.remove();c(this,at).clear(),c(this,ic).clear()}};DA=new WeakMap,at=new WeakMap,ic=new WeakMap,lZ=new WeakMap,KB=new WeakSet,ET=function(g,[I,e,t,i]){const{style:A}=g;A.top=`${100*e}%`,A.left=`${100*I}%`,A.width=`${100*t}%`,A.height=`${100*i}%`},Hn=new WeakSet,IX=function(){const g=QC._svgFactory.create(1,1,!0);return c(this,DA).append(g),g.setAttribute("aria-hidden",!0),g},PT=function(g,I){const e=QC._svgFactory.createElement("clipPath");g.append(e);const t=`clip_${I}`;e.setAttribute("id",t),e.setAttribute("clipPathUnits","objectBoundingBox");const i=QC._svgFactory.createElement("use");return e.append(i),i.setAttribute("href",`#${I}`),i.classList.add("clip"),t},CX=function(g,I){for(const[e,t]of Object.entries(I))t===null?g.removeAttribute(e):g.setAttribute(e,t)},X(QC,KB),X(QC,lZ,0);let AV=QC;globalThis._pdfjsTestingUtils={HighlightOutliner:_Y},globalThis.pdfjsLib={AbortException:us,AnnotationEditorLayer:iV,AnnotationEditorParamsType:oI,AnnotationEditorType:Tg,AnnotationEditorUIManager:ba,AnnotationLayer:EY,AnnotationMode:ms,AnnotationType:fC,applyOpacity:jTg,build:_vg,ColorPicker:Ww,createValidAbsoluteUrl:ED,CSSConstants:vTg,DOMSVGFactory:pw,DrawLayer:AV,FeatureTest:de,fetchData:ah,findContrastColor:xTg,getDocument:TY,getFilenameFromUrl:kTg,getPdfFilenameFromUrl:zTg,getRGB:rh,getUuid:gS,getXfaPageViewport:JTg,GlobalWorkerOptions:qA,ImageKind:Iw,InvalidPDFException:ZY,isDataScheme:Aw,isPdfFile:nw,isValidExplicitDest:Ivg,MathClamp:gt,noContextMenu:yi,normalizeUnicode:DTg,OPS:nh,OutputScale:_A,PasswordResponses:yTg,PDFDataRangeTransport:TS,PDFDateString:lw,PDFWorker:wh,PermissionFlag:pTg,PixelsPerInch:hs,RenderingCancelledException:WY,renderRichText:lS,ResponseException:iw,setLayerDimensions:ha,shadow:Jg,SignatureExtractor:jn,stopEvent:mC,SupportedImageMimeTypes:BY,TextLayer:Gh,TouchManager:aw,updateUrlHash:PD,Util:wg,VerbosityLevel:Cw,version:Pvg,XfaLayer:CS};class wjg{constructor(){sg(this,"cache",{});sg(this,"cachePage",{})}setCache(g,I){this.cache[g]=I}getCache(g){return this.cache[g]}setPageCache(g,I){this.cachePage[g]=I}getPageCache(g){return this.cachePage[g]}}const wa=new wjg,Wjg=["src"],Wa=o.defineComponent({name:"PdfPreview",__name:"PdfPreview",props:{src:{},page:{}},setup(C,{expose:g}){qA.workerSrc=BTg;const I=C,e=o.reactive({isError:!1,rotate:0}),t=o.ref(null);let i,A=null;o.watch([()=>I.src,()=>I.page],()=>{i==null||i.disconnect(),a(),e.isError=!1,o.nextTick(()=>{s()})}),o.watch(()=>I.src,()=>{e.rotate=0});const n=async()=>{try{if(!t.value||!I.src)throw new Error("Canvas not found");A&&(A==null||A.cancel(),A=null);let d;const m=wa.getCache(I.src);if(m?d=m:(d=await TY(I.src).promise,wa.setCache(I.src,d)),!d)throw new Error("Pdf not found");const u=I.page??1,b=`${I.src}-${u}`,Z=wa.getPageCache(b);let w;Z?w=Z:(w=await d.getPage(u),wa.setPageCache(b,w));const G=t.value.getBoundingClientRect(),B=w.getViewport({scale:1}),p=G.width/B.width,Y=G.height/B.height,y=Math.min(p,Y),R=w.getViewport({scale:y,rotation:e.rotate}),M=t.value.getContext("2d");if(M===null)throw new Error("Context not found");t.value.width=R.width,t.value.height=R.height;const D=w.render({canvas:t.value,canvasContext:M,viewport:R});A=D,await D.promise}catch(d){if(d&&typeof d=="object"&&"name"in d&&(d==null?void 0:d.name)==="RenderingCancelledException")return;console.error(d),e.isError=!0}},l=async d=>{try{if(!t.value)return;const m=wa.getPageCache(`${I.src}-${I.page}`);if(!m)return;const u=t.value.getContext("2d");if(!u)return;const b=Math.round(d/90)*90;e.rotate+=b;const{width:Z,height:w}=t.value;u.clearRect(0,0,Z,w);const G=m.getViewport({scale:1,rotation:e.rotate});t.value.width=G.width,t.value.height=G.height;const B=m.render({canvas:t.value,canvasContext:u,viewport:G});A=B,await B.promise}catch(m){if(m&&typeof m=="object"&&"name"in m&&(m==null?void 0:m.name)==="RenderingCancelledException")return;console.error(m),e.isError=!0}},s=()=>{i=new IntersectionObserver((d,m)=>{d.forEach(u=>{u.isIntersecting&&(n(),m.unobserve(u.target))},{rootMargin:"50px"})}),t.value&&i.observe(t.value)},a=()=>{if(!t.value)return;const d=t.value.getContext("2d");d&&d.clearRect(0,0,t.value.width,t.value.height)};return g({clearCanvas:a,rotatePdf:l}),o.onMounted(()=>{s()}),(d,m)=>e.isError?(o.openBlock(),o.createElementBlock("img",{key:1,src:o.unref(Tn)},null,8,Wjg)):(o.openBlock(),o.createElementBlock("canvas",{key:0,ref_key:"canvas",ref:t},null,512))}});var nV=(C=>(C.slideTop="slide-top",C.slideLeft="slide-left",C.fadeAndScale="fade-and-scale",C.fade="fade",C))(nV||{});function AC(C,g=document.documentElement){for(const[I,e]of Object.entries(C))g.style.setProperty(I,String(e))}const Bjg=()=>{const C=o.ref(0),g=o.ref([]),I=o.ref(null),e=l=>{g.value.push(l),i(l),A()},t=()=>{g.value.pop(),n(),g.value.length?i(g.value[g.value.length-1]):I.value=null},i=l=>{I.value=l},A=()=>{C.value+=1},n=()=>{C.value>0&&(C.value-=1)};return{countOpenedModal:C,openedModals:g,lastOpenedModal:I,addOpenedModal:e,reduceOpenedModal:t,setLastOpenedModal:i,incrementCountModal:A,decrementCountModal:n}},pjg=["data-testid"],yjg=["data-testid"],Yjg=yg(o.defineComponent({__name:"Modal",props:{open:{type:Boolean},position:{default:"right"},width:{},height:{},dataTestid:{default:"Modal"}},emits:["close","unmounted"],setup(C,{expose:g,emit:I}){const{lastOpenedModal:e,addOpenedModal:t,reduceOpenedModal:i}=Bjg(),A=C,n=o.ref(null),l=o.useAttrs(),s=o.ref(!1),a=o.computed(()=>({width:A.width,height:A.height})),d=I;let m=0;const u=()=>{m=Date.now(),n.value&&(A.open?(n.value.showModal(),t(n.value)):b())},b=()=>{Date.now()-m<300||(i(),d("close"))},Z=()=>{var Y;(Y=n.value)==null||Y.close(),document.documentElement.focus(),B()},w=Y=>{Y.key==="Escape"&&e.value===n.value&&b()},G=()=>{if(document.querySelectorAll(".modal-yui-kit").length===1)return window.innerWidth-document.documentElement.clientWidth;{const y=document.body.style.paddingRight;return Number(y.replace(/\D/g,""))||0}},B=()=>{document.querySelectorAll(".modal-yui-kit").length===0&&AC({overflow:"","padding-right":""},document.body)},p=Y=>{Y.target===n.value&&b()};return g({closeDialog:Z}),o.onMounted(()=>{o.watchEffect(()=>{A.open!==s.value&&(u(),s.value=A.open,n.value&&n.value.focus())}),n.value&&n.value.addEventListener("cancel",y=>{y.preventDefault()});const Y=G();AC({overflow:"hidden","padding-right":`${Y}px`},document.body),document.addEventListener("keydown",w)}),o.onUnmounted(()=>{B(),document.removeEventListener("keydown",w),d("unmounted")}),(Y,y)=>(o.openBlock(),o.createElementBlock("dialog",o.mergeProps({ref_key:"dialog",ref:n},o.unref(l),{class:["modal-yui-kit",`modal-yui-kit_${A.position}`],"data-testid":A.dataTestid,onClick:o.withModifiers(p,["self","left"])}),[o.createElementVNode("div",{class:"modal-yui-kit__modal-content",style:o.normalizeStyle(a.value),"data-testid":`${A.dataTestid}-ModalContent`},[o.renderSlot(Y.$slots,"default",{},void 0,!0)],12,yjg)],16,pjg))}}),[["__scopeId","data-v-3fe43f14"]]),yh=yg(o.defineComponent({__name:"ModalAnimated",props:{animateType:{},open:{type:Boolean},position:{default:"right"},width:{},height:{},dataTestid:{default:"Modal"}},emits:["close","unmounted","end-animation"],setup(C,{emit:g}){const I=C,e=g,t=o.computed(()=>I.animateType===nV.fade?"fade":I.position==="bottom"?"slide-bottom":I.position==="right"?"slide-left":"fade-and-scale"),i=o.ref(null),A=o.reactive({function:()=>{}}),n=()=>{d()},l=()=>{e("unmounted")},s=()=>{d()},a=()=>{A.function(),e("end-animation")},d=()=>{var u;i.value&&(A.function=(u=i.value)==null?void 0:u.closeDialog)},m=()=>{d(),e("close")};return(u,b)=>(o.openBlock(),o.createBlock(o.Transition,{name:t.value,onAfterLeave:a,onBeforeLeave:s,onAfterEnter:n},{default:o.withCtx(()=>[I.open?(o.openBlock(),o.createBlock(Yjg,{key:0,ref_key:"modalRef",ref:i,open:I.open,position:I.position,width:I.width,height:I.height,"data-testid":I.dataTestid,onClose:m,onUnmounted:l},{default:o.withCtx(()=>[o.renderSlot(u.$slots,"default",{},void 0,!0)]),_:3},8,["open","position","width","height","data-testid"])):o.createCommentVNode("",!0)]),_:3},8,["name"]))}}),[["__scopeId","data-v-6c0d942a"]]),$S=(C,g=window)=>{const I=C.getBoundingClientRect();if(g instanceof Window){const e=window.innerWidth,t=window.innerHeight;return I.top<t&&I.bottom>0&&I.left<e&&I.right>0}else{const e=g.getBoundingClientRect();return I.top<e.bottom&&I.bottom>e.top&&I.left<e.right&&I.right>e.left}},lV=(C,g=null)=>{if(!C)return;(g?$S(C,g):$S(C))||C.scrollIntoView({behavior:"smooth",block:"nearest"})},Vjg=o.defineComponent({name:"BaseSlider",__name:"BaseSlider",props:{activeIndex:{default:0}},setup(C,{expose:g}){const I=C,e=o.reactive({children:null,activeIndex:I.activeIndex}),t=o.ref(null),i=o.ref(null);o.watch(()=>I.activeIndex,()=>{A(I.activeIndex)});const A=a=>{if(!t.value||!i.value)return;const d=[...t.value.children];a>d.length-1||a<0||(lV(d[a],i.value),e.activeIndex=a)},n=()=>{o.nextTick(()=>{!e.children||!i.value||lV(e.children[e.activeIndex],i.value)})},l=()=>(A(e.activeIndex+1),e.activeIndex),s=()=>(A(e.activeIndex-1),e.activeIndex);return o.onMounted(()=>{!t.value||!i.value||(e.children=[...t.value.children])}),g({shiftPosition:A,nextSlide:l,prevSlide:s,initScroll:n}),(a,d)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"sliderRef",ref:i,class:"base-slider"},[o.createElementVNode("div",{ref_key:"contentRef",ref:t,class:"base-slider__content"},[o.renderSlot(a.$slots,"default")],512)],512))}}),Njg={class:"base-slide__content"},Mjg=o.defineComponent({name:"BaseSlide",__name:"BaseSlide",props:{isActive:{type:Boolean}},setup(C){const g=C,I=o.computed(()=>[{"base-slide_active":g.isActive}]);return(e,t)=>(o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["base-slide",I.value])},[o.createElementVNode("div",Njg,[o.renderSlot(e.$slots,"default")])],2))}}),qS=C=>{if(!C)return null;const g=C.split("?")[0],I=/\.\w+$/,e=g.match(I);return e?e[0].replace(".",""):null},sV=C=>{if(!C)return!1;if(C.startsWith("data:image/"))return!0;const g=qS(C);return g?Object.values(th).includes(g.toLowerCase()):!1},Rjg=async(C,g="file")=>{const e=await(await fetch(C)).blob(),t=window.URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download=g,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(t)};var g9={exports:{}};(function(C,g){(function(e,t){C.exports=t()})(window,function(){return function(I){var e={};function t(i){if(e[i])return e[i].exports;var A=e[i]={i,l:!1,exports:{}};return I[i].call(A.exports,A,A.exports,t),A.l=!0,A.exports}return t.m=I,t.c=e,t.d=function(i,A,n){t.o(i,A)||Object.defineProperty(i,A,{enumerable:!0,get:n})},t.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},t.t=function(i,A){if(A&1&&(i=t(i)),A&8||A&4&&typeof i=="object"&&i&&i.__esModule)return i;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:i}),A&2&&typeof i!="string")for(var l in i)t.d(n,l,(function(s){return i[s]}).bind(null,l));return n},t.n=function(i){var A=i&&i.__esModule?function(){return i.default}:function(){return i};return t.d(A,"a",A),A},t.o=function(i,A){return Object.prototype.hasOwnProperty.call(i,A)},t.p="",t(t.s=0)}({"./src/index.js":function(I,e,t){t.r(e),t("./src/sass/index.scss");var i=t("./src/js/init.js"),A=i.default.init;typeof window<"u"&&(window.printJS=A),e.default=A},"./src/js/browser.js":function(I,e,t){t.r(e);var i={isFirefox:function(){return typeof InstallTrigger<"u"},isIE:function(){return navigator.userAgent.indexOf("MSIE")!==-1||!!document.documentMode},isEdge:function(){return!i.isIE()&&!!window.StyleMedia},isChrome:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window;return!!n.chrome},isSafari:function(){return Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0||navigator.userAgent.toLowerCase().indexOf("safari")!==-1},isIOSChrome:function(){return navigator.userAgent.toLowerCase().indexOf("crios")!==-1}};e.default=i},"./src/js/functions.js":function(I,e,t){t.r(e),t.d(e,"addWrapper",function(){return l}),t.d(e,"capitalizePrint",function(){return s}),t.d(e,"collectStyles",function(){return a}),t.d(e,"addHeader",function(){return m}),t.d(e,"cleanUp",function(){return u}),t.d(e,"isRawHTML",function(){return b});var i=t("./src/js/modal.js"),A=t("./src/js/browser.js");function n(Z){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?n=function(G){return typeof G}:n=function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},n(Z)}function l(Z,w){var G="font-family:"+w.font+" !important; font-size: "+w.font_size+" !important; width:100%;";return'<div style="'+G+'">'+Z+"</div>"}function s(Z){return Z.charAt(0).toUpperCase()+Z.slice(1)}function a(Z,w){for(var G=document.defaultView||window,B="",p=G.getComputedStyle(Z,""),Y=0;Y<p.length;Y++)(w.targetStyles.indexOf("*")!==-1||w.targetStyle.indexOf(p[Y])!==-1||d(w.targetStyles,p[Y]))&&p.getPropertyValue(p[Y])&&(B+=p[Y]+":"+p.getPropertyValue(p[Y])+";");return B+="max-width: "+w.maxWidth+"px !important; font-size: "+w.font_size+" !important;",B}function d(Z,w){for(var G=0;G<Z.length;G++)if(n(w)==="object"&&w.indexOf(Z[G])!==-1)return!0;return!1}function m(Z,w){var G=document.createElement("div");if(b(w.header))G.innerHTML=w.header;else{var B=document.createElement("h1"),p=document.createTextNode(w.header);B.appendChild(p),B.setAttribute("style",w.headerStyle),G.appendChild(B)}Z.insertBefore(G,Z.childNodes[0])}function u(Z){Z.showModal&&i.default.close(),Z.onLoadingEnd&&Z.onLoadingEnd(),(Z.showModal||Z.onLoadingStart)&&window.URL.revokeObjectURL(Z.printable);var w="mouseover";(A.default.isChrome()||A.default.isFirefox())&&(w="focus");var G=function B(){window.removeEventListener(w,B),Z.onPrintDialogClose();var p=document.getElementById(Z.frameId);p&&p.remove()};window.addEventListener(w,G)}function b(Z){var w=new RegExp("<([A-Za-z][A-Za-z0-9]*)\\b[^>]*>(.*?)</\\1>");return w.test(Z)}},"./src/js/html.js":function(I,e,t){t.r(e);var i=t("./src/js/functions.js"),A=t("./src/js/print.js");function n(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?n=function(m){return typeof m}:n=function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},n(a)}e.default={print:function(d,m){var u=s(d.printable)?d.printable:document.getElementById(d.printable);if(!u){window.console.error("Invalid HTML element id: "+d.printable);return}d.printableElement=l(u,d),d.header&&Object(i.addHeader)(d.printableElement,d),A.default.send(d,m)}};function l(a,d){for(var m=a.cloneNode(),u=Array.prototype.slice.call(a.childNodes),b=0;b<u.length;b++)if(d.ignoreElements.indexOf(u[b].id)===-1){var Z=l(u[b],d);m.appendChild(Z)}switch(d.scanStyles&&a.nodeType===1&&m.setAttribute("style",Object(i.collectStyles)(a,d)),a.tagName){case"SELECT":m.value=a.value;break;case"CANVAS":m.getContext("2d").drawImage(a,0,0);break}return m}function s(a){return n(a)==="object"&&a&&(a instanceof HTMLElement||a.nodeType===1)}},"./src/js/image.js":function(I,e,t){t.r(e);var i=t("./src/js/functions.js"),A=t("./src/js/print.js"),n=t("./src/js/browser.js");e.default={print:function(s,a){s.printable.constructor!==Array&&(s.printable=[s.printable]),s.printableElement=document.createElement("div"),s.printable.forEach(function(d){var m=document.createElement("img");if(m.setAttribute("style",s.imageStyle),m.src=d,n.default.isFirefox()){var u=m.src;m.src=u}var b=document.createElement("div");b.appendChild(m),s.printableElement.appendChild(b)}),s.header&&Object(i.addHeader)(s.printableElement,s),A.default.send(s,a)}}},"./src/js/init.js":function(I,e,t){t.r(e);var i=t("./src/js/browser.js"),A=t("./src/js/modal.js"),n=t("./src/js/pdf.js"),l=t("./src/js/html.js"),s=t("./src/js/raw-html.js"),a=t("./src/js/image.js"),d=t("./src/js/json.js");function m(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?m=function(w){return typeof w}:m=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},m(b)}var u=["pdf","html","image","json","raw-html"];e.default={init:function(){var Z={printable:null,fallbackPrintable:null,type:"pdf",header:null,headerStyle:"font-weight: 300;",maxWidth:800,properties:null,gridHeaderStyle:"font-weight: bold; padding: 5px; border: 1px solid #dddddd;",gridStyle:"border: 1px solid lightgray; margin-bottom: -1px;",showModal:!1,onError:function(R){throw R},onLoadingStart:null,onLoadingEnd:null,onPrintDialogClose:function(){},onIncompatibleBrowser:function(){},modalMessage:"Retrieving Document...",frameId:"printJS",printableElement:null,documentTitle:"Document",targetStyle:["clear","display","width","min-width","height","min-height","max-height"],targetStyles:["border","box","break","text-decoration"],ignoreElements:[],repeatTableHeader:!0,css:null,style:null,scanStyles:!0,base64:!1,onPdfOpen:null,font:"TimesNewRoman",font_size:"12pt",honorMarginPadding:!0,honorColor:!1,imageStyle:"max-width: 100%;"},w=arguments[0];if(w===void 0)throw new Error("printJS expects at least 1 attribute.");switch(m(w)){case"string":Z.printable=encodeURI(w),Z.fallbackPrintable=Z.printable,Z.type=arguments[1]||Z.type;break;case"object":Z.printable=w.printable,Z.fallbackPrintable=typeof w.fallbackPrintable<"u"?w.fallbackPrintable:Z.printable,Z.fallbackPrintable=Z.base64?"data:application/pdf;base64,".concat(Z.fallbackPrintable):Z.fallbackPrintable;for(var G in Z)G==="printable"||G==="fallbackPrintable"||(Z[G]=typeof w[G]<"u"?w[G]:Z[G]);break;default:throw new Error('Unexpected argument type! Expected "string" or "object", got '+m(w))}if(!Z.printable)throw new Error("Missing printable information.");if(!Z.type||typeof Z.type!="string"||u.indexOf(Z.type.toLowerCase())===-1)throw new Error("Invalid print type. Available types are: pdf, html, image and json.");Z.showModal&&A.default.show(Z),Z.onLoadingStart&&Z.onLoadingStart();var B=document.getElementById(Z.frameId);B&&B.parentNode.removeChild(B);var p=document.createElement("iframe");switch(i.default.isFirefox()?p.setAttribute("style","width: 1px; height: 100px; position: fixed; left: 0; top: 0; opacity: 0; border-width: 0; margin: 0; padding: 0"):p.setAttribute("style","visibility: hidden; height: 0; width: 0; position: absolute; border: 0"),p.setAttribute("id",Z.frameId),Z.type!=="pdf"&&(p.srcdoc="<html><head><title>"+Z.documentTitle+"</title>",Z.css&&(Array.isArray(Z.css)||(Z.css=[Z.css]),Z.css.forEach(function(y){p.srcdoc+='<link rel="stylesheet" href="'+y+'">'})),p.srcdoc+="</head><body></body></html>"),Z.type){case"pdf":if(i.default.isIE())try{console.info("Print.js doesn't support PDF printing in Internet Explorer.");var Y=window.open(Z.fallbackPrintable,"_blank");Y.focus(),Z.onIncompatibleBrowser()}catch(y){Z.onError(y)}finally{Z.showModal&&A.default.close(),Z.onLoadingEnd&&Z.onLoadingEnd()}else n.default.print(Z,p);break;case"image":a.default.print(Z,p);break;case"html":l.default.print(Z,p);break;case"raw-html":s.default.print(Z,p);break;case"json":d.default.print(Z,p);break}}}},"./src/js/json.js":function(I,e,t){t.r(e);var i=t("./src/js/functions.js"),A=t("./src/js/print.js");function n(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?n=function(d){return typeof d}:n=function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},n(s)}e.default={print:function(a,d){if(n(a.printable)!=="object")throw new Error("Invalid javascript data object (JSON).");if(typeof a.repeatTableHeader!="boolean")throw new Error("Invalid value for repeatTableHeader attribute (JSON).");if(!a.properties||!Array.isArray(a.properties))throw new Error("Invalid properties array for your JSON data.");a.properties=a.properties.map(function(m){return{field:n(m)==="object"?m.field:m,displayName:n(m)==="object"?m.displayName:m,columnSize:n(m)==="object"&&m.columnSize?m.columnSize+";":100/a.properties.length+"%;"}}),a.printableElement=document.createElement("div"),a.header&&Object(i.addHeader)(a.printableElement,a),a.printableElement.innerHTML+=l(a),A.default.send(a,d)}};function l(s){var a=s.printable,d=s.properties,m='<table style="border-collapse: collapse; width: 100%;">';s.repeatTableHeader&&(m+="<thead>"),m+="<tr>";for(var u=0;u<d.length;u++)m+='<th style="width:'+d[u].columnSize+";"+s.gridHeaderStyle+'">'+Object(i.capitalizePrint)(d[u].displayName)+"</th>";m+="</tr>",s.repeatTableHeader&&(m+="</thead>"),m+="<tbody>";for(var b=0;b<a.length;b++){m+="<tr>";for(var Z=0;Z<d.length;Z++){var w=a[b],G=d[Z].field.split(".");if(G.length>1)for(var B=0;B<G.length;B++)w=w[G[B]];else w=w[d[Z].field];m+='<td style="width:'+d[Z].columnSize+s.gridStyle+'">'+w+"</td>"}m+="</tr>"}return m+="</tbody></table>",m}},"./src/js/modal.js":function(I,e,t){t.r(e);var i={show:function(n){var l="font-family:sans-serif; display:table; text-align:center; font-weight:300; font-size:30px; left:0; top:0;position:fixed; z-index: 9990;color: #0460B5; width: 100%; height: 100%; background-color:rgba(255,255,255,.9);transition: opacity .3s ease;",s=document.createElement("div");s.setAttribute("style",l),s.setAttribute("id","printJS-Modal");var a=document.createElement("div");a.setAttribute("style","display:table-cell; vertical-align:middle; padding-bottom:100px;");var d=document.createElement("div");d.setAttribute("class","printClose"),d.setAttribute("id","printClose"),a.appendChild(d);var m=document.createElement("span");m.setAttribute("class","printSpinner"),a.appendChild(m);var u=document.createTextNode(n.modalMessage);a.appendChild(u),s.appendChild(a),document.getElementsByTagName("body")[0].appendChild(s),document.getElementById("printClose").addEventListener("click",function(){i.close()})},close:function(){var n=document.getElementById("printJS-Modal");n&&n.parentNode.removeChild(n)}};e.default=i},"./src/js/pdf.js":function(I,e,t){t.r(e);var i=t("./src/js/print.js"),A=t("./src/js/functions.js");e.default={print:function(s,a){if(s.base64){var d=Uint8Array.from(atob(s.printable),function(u){return u.charCodeAt(0)});n(s,a,d);return}s.printable=/^(blob|http|\/\/)/i.test(s.printable)?s.printable:window.location.origin+(s.printable.charAt(0)!=="/"?"/"+s.printable:s.printable);var m=new window.XMLHttpRequest;m.responseType="arraybuffer",m.addEventListener("error",function(){Object(A.cleanUp)(s),s.onError(m.statusText,m)}),m.addEventListener("load",function(){if([200,201].indexOf(m.status)===-1){Object(A.cleanUp)(s),s.onError(m.statusText,m);return}n(s,a,m.response)}),m.open("GET",s.printable,!0),m.send()}};function n(l,s,a){var d=new window.Blob([a],{type:"application/pdf"});d=window.URL.createObjectURL(d),s.setAttribute("src",d),i.default.send(l,s)}},"./src/js/print.js":function(I,e,t){t.r(e);var i=t("./src/js/browser.js"),A=t("./src/js/functions.js"),n={send:function(m,u){document.getElementsByTagName("body")[0].appendChild(u);var b=document.getElementById(m.frameId);b.onload=function(){if(m.type==="pdf"){i.default.isFirefox()?setTimeout(function(){return l(b,m)},1e3):l(b,m);return}var Z=b.contentWindow||b.contentDocument;if(Z.document&&(Z=Z.document),Z.body.appendChild(m.printableElement),m.type!=="pdf"&&m.style){var w=document.createElement("style");w.innerHTML=m.style,Z.head.appendChild(w)}var G=Z.getElementsByTagName("img");G.length>0?s(Array.from(G)).then(function(){return l(b,m)}):l(b,m)}}};function l(d,m){try{if(d.focus(),i.default.isEdge()||i.default.isIE())try{d.contentWindow.document.execCommand("print",!1,null)}catch{d.contentWindow.print()}else d.contentWindow.print()}catch(u){m.onError(u)}finally{i.default.isFirefox()&&(d.style.visibility="hidden",d.style.left="-1px"),Object(A.cleanUp)(m)}}function s(d){var m=d.map(function(u){if(u.src&&u.src!==window.location.href)return a(u)});return Promise.all(m)}function a(d){return new Promise(function(m){var u=function b(){!d||typeof d.naturalWidth>"u"||d.naturalWidth===0||!d.complete?setTimeout(b,500):m()};u()})}e.default=n},"./src/js/raw-html.js":function(I,e,t){t.r(e);var i=t("./src/js/print.js");e.default={print:function(n,l){n.printableElement=document.createElement("div"),n.printableElement.setAttribute("style","width:100%"),n.printableElement.innerHTML=n.printable,i.default.send(n,l)}}},"./src/sass/index.scss":function(I,e,t){},0:function(I,e,t){I.exports=t("./src/index.js")}}).default})})(g9);var Xjg=g9.exports;const Hjg=jLg(Xjg),Yh=C=>{if(!C)return!1;const g=qS(C);return g?Object.values(ih).includes(g):!1},fjg=["src"],Vh=o.defineComponent({name:"VideoPreview",__name:"VideoPreview",props:{src:{}},emits:["error"],setup(C,{emit:g}){const I=C,e=g,t=o.reactive({isError:!1});o.watch(()=>I.src,()=>{t.isError=!1,o.nextTick(()=>{A()})});const i=o.ref(null),A=async()=>{var n;try{if(!i.value||!I.src)return;const l=document.createElement("video");l.muted=!0,l.preload="metadata";const s=await fetch(I.src);if(!s.ok)throw new Error("Failed to fetch video");const a=new Blob([await s.arrayBuffer()]);l.src=URL.createObjectURL(a);const d=(n=i==null?void 0:i.value)==null?void 0:n.getContext("2d");if(!d)return;l.addEventListener("loadeddata",()=>{l.currentTime=0}),l.addEventListener("seeked",()=>{var m,u;i.value&&d.drawImage(l,0,0,(m=i.value)==null?void 0:m.width,(u=i.value)==null?void 0:u.height)}),l.addEventListener("error",m=>{t.isError=!0,e("error",m)})}catch{e("error",new Event("error")),t.isError=!0}};return o.onMounted(()=>{o.nextTick(()=>{A()})}),(n,l)=>t.isError?(o.openBlock(),o.createElementBlock("img",{key:1,src:o.unref(Tn)},null,8,fjg)):(o.openBlock(),o.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:i,class:"video-preview"},null,512))}}),Djg=["src"],Xw=o.defineComponent({name:"ImagePreview",__name:"ImagePreview",props:{src:{}},emits:["error"],setup(C,{expose:g,emit:I}){const e=C,t=I,i=o.reactive({isError:!1,rotate:0});o.watch(()=>e.src,()=>{i.isError=!1,i.rotate=0,o.nextTick(()=>{n()})});const A=o.ref(null),n=async()=>{try{if(!A.value||!e.src)return;const s=new Image;s.src=e.src,s.addEventListener("load",()=>{var Z;if(!A.value)return;const a=(Z=A.value)==null?void 0:Z.getContext("2d");if(!a)return;const d=s.width,m=s.height;let u=d,b=m;i.rotate%180!==0&&(u=m,b=d),A.value.width=u,A.value.height=b,a.save(),a.clearRect(0,0,u,b),a.translate(u/2,b/2),a.rotate(i.rotate*Math.PI/180),a.drawImage(s,-d/2,-m/2,d,m),a.restore()}),s.addEventListener("error",a=>{i.isError=!0,t("error",a)})}catch{t("error",new Event("error")),i.isError=!0}},l=async s=>{const a=Math.round(s/90)*90;i.rotate+=a,o.nextTick(()=>{n()})};return o.onMounted(()=>{o.nextTick(()=>{n()})}),g({rotateImage:l}),(s,a)=>i.isError?(o.openBlock(),o.createElementBlock("img",{key:1,src:o.unref(Tn)},null,8,Djg)):(o.openBlock(),o.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:A,class:"image-preview"},null,512))}}),bs=C=>C?C instanceof File?C.type==="application/pdf":nw(C):!1,Sjg={ref:"contentRef",class:"slider-modal__content"},Kjg=["onClick"],kjg={class:"slider-modal__side-bar-count"},zjg=["data-testid"],Fjg=["src"],Jjg=["src"],Ljg={class:"slider-modal__bottom"},Tjg={class:"slider-modal__nav-block"},vjg=["disabled"],jjg=["src","alt"],xjg=["src"],Ojg=["disabled"],Qjg={class:"slider-modal__nav-block"},Ujg={class:"slider-modal__sub-nav"},Ejg=["disabled"],Pjg=["disabled"],_jg=["disabled"],$jg={class:"slider-modal__sub-nav"},qjg=["disabled"],gxg=["disabled"],Hw=yg(o.defineComponent({name:"SliderModal",__name:"SliderModal",props:{dataTestid:{default:"SliderModal"},animateType:{},open:{type:Boolean},position:{},width:{},height:{},items:{},defaultIndex:{default:0}},emits:["close","unmounted","end-animation"],setup(C){const g=C,I=o.reactive({defaultIndex:g.defaultIndex,file:g.items[g.defaultIndex],sideBarItems:[],sideBarIndex:0,sideBarLength:0,isErrorFile:!1,zoomValue:1}),e=o.ref(null),t=o.ref(null),i=o.ref(null),A=o.ref(null),n=o.ref(null),l=o.computed(()=>I.defaultIndex===0),s=o.computed(()=>I.defaultIndex===g.items.length-1),a=o.computed(()=>{var q;let x=!I.file||I.isErrorFile;return x=Yh((q=I.file)==null?void 0:q.path)||x,x}),d=o.computed(()=>{var q;let x=!I.file||I.isErrorFile;return x=Yh((q=I.file)==null?void 0:q.path)||x,x}),m=o.computed(()=>!I.file||I.isErrorFile),u=o.computed(()=>{var q;let x=!I.file||I.isErrorFile;return x=Yh((q=I.file)==null?void 0:q.path)||x,x});o.watch([()=>g.items,()=>g.defaultIndex],()=>{I.file=g.items[g.defaultIndex??0],I.defaultIndex=g.defaultIndex??0}),o.watch([()=>I.file,()=>g.open],()=>{if(!g.open){Q(),I.file=null;return}I.zoomValue=1,I.file||(I.file=g.items[g.defaultIndex??0]),I.isErrorFile=!1,T()}),o.watch(()=>g.open,()=>{g.open&&(o.nextTick(()=>{A.value&&A.value.initScroll()}),I.defaultIndex=g.defaultIndex??0)}),o.watch(()=>I.sideBarIndex,()=>{P()});const b=x=>{H(x)},Z=x=>{I.sideBarIndex=x},w=x=>{z(x.deltaY)},G=()=>{J(!0)},B=()=>{J(!1)},p=()=>{i.value&&i.value.rotatePdf(-90),n.value&&n.value.rotateImage(-90)},Y=()=>{var Dg,AI,Hg;if(!((Dg=I.file)!=null&&Dg.path))return;let x="pdf",q="",cg="";sV((AI=I.file)==null?void 0:AI.path)&&(x="image",q=`
1327
1327
  @page {
1328
1328
  size: A4 portrait;
1329
1329
  margin: 10mm;