@pksep/yui 0.1.171 → 0.1.173

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.
@@ -1325,7 +1325,7 @@ function print() { __p += __j.call(arguments, '') }
1325
1325
  `),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,bi,I.fontSize),A.color=Wg.makeHexColor(...I.color),V(A,hi,f(n=IC,Ol,LR).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=EI._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),t=Object.assign(super.serialize(I),{color:e,fontSize:c(this,bi),value:f(this,jC,hT).call(this)});return this.addComment(t),I?(t.isCopy=!0,t):this.annotationElementId&&!f(this,jC,bT).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,bi)}px * var(--total-scale-factor))`,t.color=this.color,e.replaceChildren();for(const i of c(this,hi).split(`
1326
1326
  `)){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,hi)}}),e}resetAnnotationElement(I){super.resetAnnotationElement(I),I.resetEdited()}};hi=new WeakMap,iZ=new WeakMap,Ed=new WeakMap,bi=new WeakMap,jC=new WeakSet,rT=function(I){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-c(this,bi))*this.parentScale),V(this,bi,i),f(this,jC,Cy).call(this)},t=c(this,bi);this.addCommands({cmd:e.bind(this,I),undo:e.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:aI.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},mT=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:aI.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},uT=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=IC,Ol,ey).call(t,i)),e=i);return I.join(`
1327
1327
  `)},Cy=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()},Ol=new WeakSet,ey=function(I){return(I.nodeType===Node.TEXT_NODE?I.nodeValue:I.innerText).replaceAll(Fw,"")},ty=function(){if(this.editorDiv.replaceChildren(),!!c(this,hi))for(const I of c(this,hi).split(`
1328
- `)){const e=document.createElement("div");e.append(I?document.createTextNode(I):document.createElement("br")),this.editorDiv.append(e)}},hT=function(){return c(this,hi).replaceAll(" "," ")},LR=function(I){return I.replaceAll(" "," ")},bT=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(IC,Ol),sg(IC,"_freeTextDefaultContent",""),sg(IC,"_internalPadding",0),sg(IC,"_defaultColor",null),sg(IC,"_defaultFontSize",10),sg(IC,"_type","freetext"),sg(IC,"_editorType",jg.FREETEXT);let AV=IC;class Gg{toSVGPath(){JI("Abstract method `toSVGPath` must be implemented.")}get box(){JI("Abstract getter `box` must be implemented.")}serialize(g,I){JI("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(Gg,"PRECISION",1e-4);const Ql=class Ql{constructor({x:g,y:I},e,t,i,A,n=0){X(this,ge);X(this,Zi);X(this,LA,[]);X(this,Fm);X(this,zm);X(this,zn,[]);X(this,tI,new Float32Array(18));X(this,Pd);X(this,_d);X(this,AZ);X(this,nZ);X(this,Jm);X(this,Lm);X(this,So,[]);V(this,Zi,e),V(this,Lm,i*t),V(this,zm,A),c(this,tI).set([NaN,NaN,NaN,NaN,g,I],6),V(this,Fm,n),V(this,nZ,c(Ql,lZ)*t),V(this,AZ,c(Ql,OB)*t),V(this,Jm,t),c(this,So).push(g,I)}isEmpty(){return isNaN(c(this,tI)[8])}add({x:g,y:I}){var J;V(this,Pd,g),V(this,_d,I);const[e,t,i,A]=c(this,Zi);let[n,l,o,a]=c(this,tI).subarray(8,12);const d=g-o,m=I-a,u=Math.hypot(d,m);if(u<c(this,AZ))return!1;const b=u-c(this,nZ),Z=b/u,w=Z*d,G=Z*m;let B=n,p=l;n=o,l=a,o+=w,a+=G,(J=c(this,So))==null||J.push(g,I);const Y=-G/b,y=w/b,R=Y*c(this,Lm),M=y*c(this,Lm);return c(this,tI).set(c(this,tI).subarray(2,8),0),c(this,tI).set([o+R,a+M],4),c(this,tI).set(c(this,tI).subarray(14,18),12),c(this,tI).set([o-R,a-M],16),isNaN(c(this,tI)[6])?(c(this,zn).length===0&&(c(this,tI).set([n+R,l+M],2),c(this,zn).push(NaN,NaN,NaN,NaN,(n+R-e)/i,(l+M-t)/A),c(this,tI).set([n-R,l-M],14),c(this,LA).push(NaN,NaN,NaN,NaN,(n-R-e)/i,(l-M-t)/A)),c(this,tI).set([B,p,n,l,o,a],6),!this.isEmpty()):(c(this,tI).set([B,p,n,l,o,a],6),Math.abs(Math.atan2(p-l,B-n)-Math.atan2(G,w))<Math.PI/2?([n,l,o,a]=c(this,tI).subarray(2,6),c(this,zn).push(NaN,NaN,NaN,NaN,((n+o)/2-e)/i,((l+a)/2-t)/A),[n,l,B,p]=c(this,tI).subarray(14,18),c(this,LA).push(NaN,NaN,NaN,NaN,((B+n)/2-e)/i,((p+l)/2-t)/A),!0):([B,p,n,l,o,a]=c(this,tI).subarray(0,6),c(this,zn).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+o)/6-e)/i,((5*l+a)/6-t)/A,((n+o)/2-e)/i,((l+a)/2-t)/A),[o,a,n,l,B,p]=c(this,tI).subarray(12,18),c(this,LA).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+o)/6-e)/i,((5*l+a)/6-t)/A,((n+o)/2-e)/i,((l+a)/2-t)/A),!0))}toSVGPath(){if(this.isEmpty())return"";const g=c(this,zn),I=c(this,LA);if(isNaN(c(this,tI)[6])&&!this.isEmpty())return f(this,ge,ZT).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,ge,wT).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,ge,GT).call(this,e),e.join(" ")}newFreeDrawOutline(g,I,e,t,i,A){return new _S(g,I,e,t,i,A)}getOutlines(){var d;const g=c(this,zn),I=c(this,LA),e=c(this,tI),[t,i,A,n]=c(this,Zi),l=new Float32Array((((d=c(this,So))==null?void 0:d.length)??0)+2);for(let m=0,u=l.length-2;m<u;m+=2)l[m]=(c(this,So)[m]-t)/A,l[m+1]=(c(this,So)[m+1]-i)/n;if(l[l.length-2]=(c(this,Pd)-t)/A,l[l.length-1]=(c(this,_d)-i)/n,isNaN(e[6])&&!this.isEmpty())return f(this,ge,WT).call(this,l);const o=new Float32Array(c(this,zn).length+24+c(this,LA).length);let a=g.length;for(let m=0;m<a;m+=2){if(isNaN(g[m])){o[m]=o[m+1]=NaN;continue}o[m]=g[m],o[m+1]=g[m+1]}a=f(this,ge,pT).call(this,o,a);for(let m=I.length-6;m>=6;m-=6)for(let u=0;u<6;u+=2){if(isNaN(I[m+u])){o[a]=o[a+1]=NaN,a+=2;continue}o[a]=I[m+u],o[a+1]=I[m+u+1],a+=2}return f(this,ge,BT).call(this,o,a),this.newFreeDrawOutline(o,l,c(this,Zi),c(this,Jm),c(this,Fm),c(this,zm))}};Zi=new WeakMap,LA=new WeakMap,Fm=new WeakMap,zm=new WeakMap,zn=new WeakMap,tI=new WeakMap,Pd=new WeakMap,_d=new WeakMap,AZ=new WeakMap,nZ=new WeakMap,Jm=new WeakMap,Lm=new WeakMap,So=new WeakMap,lZ=new WeakMap,xB=new WeakMap,OB=new WeakMap,ge=new WeakSet,qZ=function(){const g=c(this,tI).subarray(4,6),I=c(this,tI).subarray(16,18),[e,t,i,A]=c(this,Zi);return[(c(this,Pd)+(g[0]-I[0])/2-e)/i,(c(this,_d)+(g[1]-I[1])/2-t)/A,(c(this,Pd)+(I[0]-g[0])/2-e)/i,(c(this,_d)+(I[1]-g[1])/2-t)/A]},ZT=function(){const[g,I,e,t]=c(this,Zi),[i,A,n,l]=f(this,ge,qZ).call(this);return`M${(c(this,tI)[2]-g)/e} ${(c(this,tI)[3]-I)/t} L${(c(this,tI)[4]-g)/e} ${(c(this,tI)[5]-I)/t} L${i} ${A} L${n} ${l} L${(c(this,tI)[16]-g)/e} ${(c(this,tI)[17]-I)/t} L${(c(this,tI)[14]-g)/e} ${(c(this,tI)[15]-I)/t} Z`},GT=function(g){const I=c(this,LA);g.push(`L${I[4]} ${I[5]} Z`)},wT=function(g){const[I,e,t,i]=c(this,Zi),A=c(this,tI).subarray(4,6),n=c(this,tI).subarray(16,18),[l,o,a,d]=f(this,ge,qZ).call(this);g.push(`L${(A[0]-I)/t} ${(A[1]-e)/i} L${l} ${o} L${a} ${d} L${(n[0]-I)/t} ${(n[1]-e)/i}`)},WT=function(g){const I=c(this,tI),[e,t,i,A]=c(this,Zi),[n,l,o,a]=f(this,ge,qZ).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,o,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,Zi),c(this,Jm),c(this,Fm),c(this,zm))},BT=function(g,I){const e=c(this,LA);return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],I),I+=6},pT=function(g,I){const e=c(this,tI).subarray(4,6),t=c(this,tI).subarray(16,18),[i,A,n,l]=c(this,Zi),[o,a,d,m]=f(this,ge,qZ).call(this);return g.set([NaN,NaN,NaN,NaN,(e[0]-i)/n,(e[1]-A)/l,NaN,NaN,NaN,NaN,o,a,NaN,NaN,NaN,NaN,d,m,NaN,NaN,NaN,NaN,(t[0]-i)/n,(t[1]-A)/l],I),I+=24},X(Ql,lZ,8),X(Ql,xB,2),X(Ql,OB,c(Ql,lZ)+c(Ql,xB));let zw=Ql;class _S extends Gg{constructor(I,e,t,i,A,n){super();X(this,QB);X(this,Tm);X(this,$d,new Float32Array(4));X(this,Ul);X(this,sZ);X(this,Gi);X(this,oZ);X(this,HC);V(this,HC,I),V(this,Gi,e),V(this,Tm,t),V(this,oZ,i),V(this,Ul,A),V(this,sZ,n),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],f(this,QB,yT).call(this,n);const[l,o,a,d]=c(this,$d);for(let m=0,u=I.length;m<u;m+=2)I[m]=(I[m]-l)/a,I[m+1]=(I[m+1]-o)/d;for(let m=0,u=e.length;m<u;m+=2)e[m]=(e[m]-l)/a,e[m+1]=(e[m+1]-o)/d}toSVGPath(){const I=[`M${c(this,HC)[4]} ${c(this,HC)[5]}`];for(let e=6,t=c(this,HC).length;e<t;e+=6){if(isNaN(c(this,HC)[e])){I.push(`L${c(this,HC)[e+4]} ${c(this,HC)[e+5]}`);continue}I.push(`C${c(this,HC)[e]} ${c(this,HC)[e+1]} ${c(this,HC)[e+2]} ${c(this,HC)[e+3]} ${c(this,HC)[e+4]} ${c(this,HC)[e+5]}`)}return I.push("Z"),I.join(" ")}serialize([I,e,t,i],A){const n=t-I,l=i-e;let o,a;switch(A){case 0:o=Gg._rescale(c(this,HC),I,i,n,-l),a=Gg._rescale(c(this,Gi),I,i,n,-l);break;case 90:o=Gg._rescaleAndSwap(c(this,HC),I,e,n,l),a=Gg._rescaleAndSwap(c(this,Gi),I,e,n,l);break;case 180:o=Gg._rescale(c(this,HC),t,e,-n,l),a=Gg._rescale(c(this,Gi),t,e,-n,l);break;case 270:o=Gg._rescaleAndSwap(c(this,HC),t,i,-n,-l),a=Gg._rescaleAndSwap(c(this,Gi),t,i,-n,-l);break}return{outline:Array.from(o),points:[Array.from(a)]}}get box(){return c(this,$d)}newOutliner(I,e,t,i,A,n=0){return new zw(I,e,t,i,A,n)}getNewOutline(I,e){const[t,i,A,n]=c(this,$d),[l,o,a,d]=c(this,Tm),m=A*a,u=n*d,b=t*a+l,Z=i*d+o,w=this.newOutliner({x:c(this,Gi)[0]*m+b,y:c(this,Gi)[1]*u+Z},c(this,Tm),c(this,oZ),I,c(this,sZ),e??c(this,Ul));for(let G=2;G<c(this,Gi).length;G+=2)w.add({x:c(this,Gi)[G]*m+b,y:c(this,Gi)[G+1]*u+Z});return w.getOutlines()}}Tm=new WeakMap,$d=new WeakMap,Ul=new WeakMap,sZ=new WeakMap,Gi=new WeakMap,oZ=new WeakMap,HC=new WeakMap,QB=new WeakSet,yT=function(I){const e=c(this,HC);let t=e[4],i=e[5];const A=[t,i,t,i];let n=t,l=i,o=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?(o=w,a=G):a===G&&(o=d(o,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]?(o=m[2],a=m[3]):a===m[3]&&(o=d(o,m[2]))),t=w,i=G}const u=c(this,$d);u[0]=A[0]-c(this,Ul),u[1]=A[1]-c(this,Ul),u[2]=A[2]-A[0]+2*c(this,Ul),u[3]=A[3]-A[1]+2*c(this,Ul),this.firstPoint=[n,l],this.lastPoint=[o,a]};class nV{constructor(g,I=0,e=0,t=!0){X(this,ut);X(this,aZ);X(this,dZ);X(this,cZ);X(this,Ko,[]);X(this,TA,[]);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,Ko).push(D,J),Wg.rectBoundingBox(Y,R,y,M,i)}const l=i[2]-i[0]+2*e,o=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,Ko).at(t?-1:-2),Z=[b[0],b[2]];for(const w of c(this,Ko)){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)/o,w[2]=(p-d)/o}V(this,aZ,new Float32Array([a,d,l,o])),V(this,dZ,[m,u]),V(this,cZ,Z)}getOutlines(){c(this,Ko).sort((I,e)=>I[0]-e[0]||I[1]-e[1]||I[2]-e[2]);const g=[];for(const I of c(this,Ko))I[3]?(g.push(...f(this,ut,TR).call(this,I)),f(this,ut,VT).call(this,I)):(f(this,ut,NT).call(this,I),g.push(...f(this,ut,TR).call(this,I)));return f(this,ut,YT).call(this,g)}}aZ=new WeakMap,dZ=new WeakMap,cZ=new WeakMap,Ko=new WeakMap,TA=new WeakMap,ut=new WeakSet,YT=function(g){const I=[],e=new Set;for(const A of g){const[n,l,o]=A;I.push([n,l,A],[n,o,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],o=I[A+1][2];l.push(o),o.push(l),e.add(l),e.add(o)}const t=[];let i;for(;e.size>0;){const A=e.values().next().value;let[n,l,o,a,d]=A;e.delete(A);let m=n,u=l;for(i=[n,o],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,o,a,d]=b,m!==n&&(i.push(m,u,n,u===l?l:o),m=n),u=u===l?o:l}i.push(m,u)}return new wjg(t,c(this,aZ),c(this,dZ),c(this,cZ))},iy=function(g){const I=c(this,TA);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},VT=function([,g,I]){const e=f(this,ut,iy).call(this,g);c(this,TA).splice(e,0,[g,I])},NT=function([,g,I]){const e=f(this,ut,iy).call(this,g);for(let t=e;t<c(this,TA).length;t++){const[i,A]=c(this,TA)[t];if(i!==g)break;if(i===g&&A===I){c(this,TA).splice(t,1);return}}for(let t=e-1;t>=0;t--){const[i,A]=c(this,TA)[t];if(i!==g)break;if(i===g&&A===I){c(this,TA).splice(t,1);return}}},TR=function(g){const[I,e,t]=g,i=[[I,e,t]],A=f(this,ut,iy).call(this,t);for(let n=0;n<A;n++){const[l,o]=c(this,TA)[n];for(let a=0,d=i.length;a<d;a++){const[,m,u]=i[a];if(!(o<=m||u<=l)){if(m>=l){if(u>o)i[a][1]=o;else{if(d===1)return[];i.splice(a,1),a--,d--}continue}i[a][2]=l,u>o&&i.push([I,o,u])}}}return i};class wjg extends Gg{constructor(I,e,t,i){super();X(this,rZ);X(this,vm);V(this,vm,I),V(this,rZ,e),this.firstPoint=t,this.lastPoint=i}toSVGPath(){const I=[];for(const e of c(this,vm)){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,o=i-e;for(const a of c(this,vm)){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]*o;n.push(d)}return n}get box(){return c(this,rZ)}get classNamesForOutlining(){return["highlightOutline"]}}rZ=new WeakMap,vm=new WeakMap;class lV extends zw{newFreeDrawOutline(g,I,e,t,i,A){return new Wjg(g,I,e,t,i,A)}}class Wjg extends _S{newOutliner(g,I,e,t,i,A=0){return new lV(g,I,e,t,i,A)}}const ZI=class ZI extends EI{constructor(I){super({...I,name:"highlightEditor"});X(this,_g);X(this,jm,null);X(this,mZ,0);X(this,El);X(this,qd,null);X(this,uZ,null);X(this,xt,null);X(this,hZ,null);X(this,bZ,0);X(this,gc,null);X(this,wi,null);X(this,Wi,null);X(this,Re,!1);X(this,xm,null);X(this,Om,null);X(this,Ue,null);X(this,Qm,"");X(this,iA);X(this,ZZ,"");this.color=I.color||ZI._defaultColor,V(this,iA,I.thickness||ZI._defaultThickness),this.opacity=I.opacity||ZI._defaultOpacity,V(this,El,I.boxes||null),V(this,ZZ,I.methodOfCreation||""),V(this,Qm,I.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",I.highlightId>-1?(V(this,Re,!0),f(this,_g,Ay).call(this,I),f(this,_g,yc).call(this)):c(this,El)&&(V(this,jm,I.anchorNode),V(this,mZ,I.anchorOffset),V(this,hZ,I.focusNode),V(this,bZ,I.focusOffset),f(this,_g,vR).call(this),f(this,_g,yc).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const I=ZI.prototype;return Tg(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,Re)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:c(this,iA),methodOfCreation:c(this,ZZ)}}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;EI.initialize(I,e),ZI._defaultColor||(ZI._defaultColor=((t=e.highlightColors)==null?void 0:t.values().next().value)||"#fff066")}static updateDefaultParams(I,e){switch(I){case aI.HIGHLIGHT_COLOR:ZI._defaultColor=e;break;case aI.HIGHLIGHT_THICKNESS:ZI._defaultThickness=e;break}}translateInPage(I,e){}get toolbarPosition(){return c(this,Om)}get commentButtonPosition(){return c(this,xm)}updateParams(I,e){switch(I){case aI.HIGHLIGHT_COLOR:f(this,_g,MT).call(this,e);break;case aI.HIGHLIGHT_THICKNESS:f(this,_g,RT).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[aI.HIGHLIGHT_COLOR,ZI._defaultColor],[aI.HIGHLIGHT_THICKNESS,ZI._defaultThickness]]}get propertiesToUpdate(){return[[aI.HIGHLIGHT_COLOR,this.color||ZI._defaultColor],[aI.HIGHLIGHT_THICKNESS,c(this,iA)||ZI._defaultThickness],[aI.HIGHLIGHT_FREE,c(this,Re)]]}onUpdatedColor(){var I,e;(I=this.parent)==null||I.drawLayer.updateProperties(c(this,Wi),{root:{fill:this.color,"fill-opacity":this.opacity}}),(e=c(this,uZ))==null||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",V(this,uZ,new Sw({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,_g,ly).call(this))}getBaseTranslation(){return[0,0]}getRect(I,e){return super.getRect(I,e,f(this,_g,ly).call(this))}onceAdded(I){this.annotationElementId||this.parent.addUndoableEditor(this),I&&this.div.focus()}remove(){f(this,_g,jR).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,_g,yc).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?f(this,_g,jR).call(this):I&&(f(this,_g,yc).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,Re)?(I=(I-this.rotation+360)%360,t=f(i=ZI,AA,Xu).call(i,c(this,wi).box,I)):t=f(A=ZI,AA,Xu).call(A,[this.x,this.y,this.width,this.height],I),e.updateProperties(c(this,Wi),{bbox:t,root:{"data-main-rotation":I}}),e.updateProperties(c(this,Ue),{bbox:f(n=ZI,AA,Xu).call(n,c(this,xt).box,I),root:{"data-main-rotation":I}})}render(){if(this.div)return this.div;const I=super.render();c(this,Qm)&&(I.setAttribute("aria-label",c(this,Qm)),I.setAttribute("role","mark")),c(this,Re)?I.classList.add("free"):this.div.addEventListener("keydown",f(this,_g,HT).bind(this),{signal:this._uiManager._signal});const e=V(this,gc,document.createElement("div"));return I.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=c(this,qd),this.setDims(),aS(this,c(this,gc),["pointerover","pointerleave"]),this.enableEditing(),I}pointerover(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{hovered:!0}})}pointerleave(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{hovered:!1}})}_moveCaret(I){switch(this.parent.unselect(this),I){case 0:case 2:f(this,_g,ny).call(this,!0);break;case 1:case 3:f(this,_g,ny).call(this,!1);break}}select(){var I;super.select(),c(this,Ue)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var I;super.unselect(),c(this,Ue)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{selected:!1}}),c(this,Re)||f(this,_g,ny).call(this,!1))}get _mustFixPosition(){return!c(this,Re)}show(I=this._isVisible){super.show(I),this.parent&&(this.parent.drawLayer.updateProperties(c(this,Wi),{rootClass:{hidden:!I}}),this.parent.drawLayer.updateProperties(c(this,Ue),{rootClass:{hidden:!I}}))}static startHighlighting(I,e,{target:t,x:i,y:A}){const{x:n,y:l,width:o,height:a}=t.getBoundingClientRect(),d=new AbortController,m=I.combinedSignal(d),u=b=>{d.abort(),f(this,AA,KT).call(this,I,b)};window.addEventListener("blur",u,{signal:m}),window.addEventListener("pointerup",u,{signal:m}),window.addEventListener("pointerdown",bC,{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",Si,{signal:m}),t.addEventListener("pointermove",f(this,AA,ST).bind(this,I),{signal:m}),this._freeHighlight=new lV({x:i,y:A},[n,l,o,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 ES){const{data:{quadPoints:p,rect:Y,rotation:y,id:R,color:M,opacity:D,popupRef:J,richText:H,contentsObj:F,creationDate:T,modificationDate:E},parent:{page:{pageNumber:q}}}=I;i=I={annotationType:jg.HIGHLIGHT,color:Array.from(M),opacity:D,quadPoints:p,boxes:null,pageIndex:q-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(F==null?void 0:F.str)||null,creationDate:T,modificationDate:E}}else if(I instanceof tV){const{data:{inkLists:p,rect:Y,rotation:y,id:R,color:M,borderStyle:{rawWidth:D},popupRef:J,richText:H,contentsObj:F,creationDate:T,modificationDate:E},parent:{page:{pageNumber:q}}}=I;i=I={annotationType:jg.HIGHLIGHT,color:Array.from(M),thickness:D,inkLists:p,boxes:null,pageIndex:q-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(F==null?void 0:F.str)||null,creationDate:T,modificationDate:E}}const{color:A,quadPoints:n,inkLists:l,opacity:o}=I,a=await super.deserialize(I,e,t);a.color=Wg.makeHexColor(...A),a.opacity=o||1,l&&V(a,iA,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,El,[]);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,_g,vR).call(Z),f(w=a,_g,yc).call(w),a.rotate(a.rotation)}else if(l){V(a,Re,!0);const p=l[0],Y={x:p[0]-u,y:m-(p[1]-b)},y=new lV(Y,[0,0,d,m],1,c(a,iA)/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,_g,Ay).call(G,{highlightOutlines:y.getOutlines(),highlightId:R,clipPathId:M}),f(B=a,_g,yc).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=EI._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),t=super.serialize(I);return Object.assign(t,{color:e,opacity:this.opacity,thickness:c(this,iA),quadPoints:f(this,_g,fT).call(this),outlines:f(this,_g,DT).call(this,t.rect)}),this.addComment(t),this.annotationElementId&&!f(this,_g,kT).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}};jm=new WeakMap,mZ=new WeakMap,El=new WeakMap,qd=new WeakMap,uZ=new WeakMap,xt=new WeakMap,hZ=new WeakMap,bZ=new WeakMap,gc=new WeakMap,wi=new WeakMap,Wi=new WeakMap,Re=new WeakMap,xm=new WeakMap,Om=new WeakMap,Ue=new WeakMap,Qm=new WeakMap,iA=new WeakMap,ZZ=new WeakMap,_g=new WeakSet,vR=function(){const I=new nV(c(this,El),.001);V(this,wi,I.getOutlines()),[this.x,this.y,this.width,this.height]=c(this,wi).box;const e=new nV(c(this,El),.0025,.001,this._uiManager.direction==="ltr");V(this,xt,e.getOutlines());const{firstPoint:t}=c(this,wi);V(this,xm,[(t[0]-this.x)/this.width,(t[1]-this.y)/this.height]);const{lastPoint:i}=c(this,xt);V(this,Om,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Ay=function({highlightOutlines:I,highlightId:e,clipPathId:t}){var m,u;if(V(this,wi,I),V(this,xt,I.getNewOutline(c(this,iA)/2+1.5,.0025)),e>=0)V(this,Wi,e),V(this,qd,t),this.parent.drawLayer.finalizeDraw(e,{bbox:I.box,path:{d:I.toSVGPath()}}),V(this,Ue,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:c(this,xt).box,path:{d:c(this,xt).toSVGPath()}},!0));else if(this.parent){const b=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(c(this,Wi),{bbox:f(m=ZI,AA,Xu).call(m,c(this,wi).box,(b-this.rotation+360)%360),path:{d:I.toSVGPath()}}),this.parent.drawLayer.updateProperties(c(this,Ue),{bbox:f(u=ZI,AA,Xu).call(u,c(this,xt).box,b),path:{d:c(this,xt).toSVGPath()}})}const[A,n,l,o]=I.box;switch(this.rotation){case 0:this.x=A,this.y=n,this.width=l,this.height=o;break;case 90:{const[b,Z]=this.parentDimensions;this.x=n,this.y=1-A,this.width=l*Z/b,this.height=o*b/Z;break}case 180:this.x=1-A,this.y=1-n,this.width=l,this.height=o;break;case 270:{const[b,Z]=this.parentDimensions;this.x=1-n,this.y=A,this.width=l*Z/b,this.height=o*b/Z;break}}const{firstPoint:a}=I;V(this,xm,[(a[0]-A)/l,(a[1]-n)/o]);const{lastPoint:d}=c(this,xt);V(this,Om,[(d[0]-A)/l,(d[1]-n)/o])},MT=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,ZI._defaultOpacity),undo:e.bind(this,t,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:aI.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(I)},!0)},RT=function(I){const e=c(this,iA),t=i=>{V(this,iA,i),f(this,_g,XT).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:aI.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:I},!0)},XT=function(I){c(this,Re)&&(f(this,_g,Ay).call(this,{highlightOutlines:c(this,wi).getNewOutline(I/2)}),this.fixAndSetPosition(),this.setDims())},jR=function(){c(this,Wi)===null||!this.parent||(this.parent.drawLayer.remove(c(this,Wi)),V(this,Wi,null),this.parent.drawLayer.remove(c(this,Ue)),V(this,Ue,null))},yc=function(I=this.parent){c(this,Wi)===null&&({id:te(this,Wi)._,clipPathId:te(this,qd)._}=I.drawLayer.draw({bbox:c(this,wi).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:c(this,Re)},path:{d:c(this,wi).toSVGPath()}},!1,!0),V(this,Ue,I.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:c(this,Re)},bbox:c(this,xt).box,path:{d:c(this,xt).toSVGPath()}},c(this,Re))),c(this,gc)&&(c(this,gc).style.clipPath=c(this,qd)))},AA=new WeakSet,Xu=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]},HT=function(I){ZI._keyboardManager.exec(this,I)},ny=function(I){if(!c(this,jm))return;const e=window.getSelection();I?e.setPosition(c(this,jm),c(this,mZ)):e.setPosition(c(this,hZ),c(this,bZ))},ly=function(){return c(this,Re)?this.rotation:0},fT=function(){if(c(this,Re))return null;const[I,e]=this.pageDimensions,[t,i]=this.pageTranslation,A=c(this,El),n=new Float32Array(A.length*8);let l=0;for(const{x:o,y:a,width:d,height:m}of A){const u=o*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},DT=function(I){return c(this,wi).serialize(I,f(this,_g,ly).call(this))},ST=function(I,e){this._freeHighlight.add(e)&&I.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},KT=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=""},kT=function(I){const{color:e}=this._initialData;return this.hasEditedComment||I.color.some((t,i)=>t!==e[i])},X(ZI,AA),sg(ZI,"_defaultColor",null),sg(ZI,"_defaultOpacity",1),sg(ZI,"_defaultThickness",12),sg(ZI,"_type","highlight"),sg(ZI,"_editorType",jg.HIGHLIGHT),sg(ZI,"_freeHighlightId",-1),sg(ZI,"_freeHighlight",null),sg(ZI,"_freeHighlightClipId","");let Jw=ZI;class $S{constructor(){X(this,Ic,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,Ic)[g]=I}toSVGProperties(){const g=c(this,Ic);return V(this,Ic,Object.create(null)),{root:g}}reset(){V(this,Ic,Object.create(null))}updateAll(g=this){this.updateProperties(g)}clone(){JI("Not implemented")}}Ic=new WeakMap;const lI=class lI extends EI{constructor(I){super(I);X(this,hI);X(this,Bi,null);X(this,Um);sg(this,"_colorPicker",null);sg(this,"_drawId",null);V(this,Um,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,hI,xR).call(this,I),f(this,hI,gG).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){JI("Not implemented")}static get typesMap(){JI("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(lI,ce).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 o=c(this,Bi).updateProperty(e,l);o&&f(this,hI,IG).call(this,o),(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,lI._mergeSVGProperties(c(this,Bi).getPathResizingSVGProperties(f(this,hI,sy).call(this)),{bbox:f(this,hI,Hu).call(this)}))}_onResized(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,lI._mergeSVGProperties(c(this,Bi).getPathResizedSVGProperties(f(this,hI,sy).call(this)),{bbox:f(this,hI,Hu).call(this)}))}_onTranslating(I,e){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{bbox:f(this,hI,Hu).call(this)})}_onTranslated(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,lI._mergeSVGProperties(c(this,Bi).getPathTranslatedSVGProperties(f(this,hI,sy).call(this),this.parentDimensions),{bbox:f(this,hI,Hu).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,Um)&&(V(this,Um,!1),this.commit(),this.parent.setSelected(this),I&&this.isOnScreen&&this.div.focus())}remove(){f(this,hI,QR).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,hI,gG).call(this),f(this,hI,IG).call(this,c(this,Bi).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?(this._uiManager.removeShouldRescale(this),f(this,hI,QR).call(this)):I&&(this._uiManager.addShouldRescale(this),f(this,hI,gG).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,lI._mergeSVGProperties({bbox:f(this,hI,Hu).call(this)},c(this,Bi).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&f(this,hI,IG).call(this,c(this,Bi).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){JI("Not implemented")}static startDrawing(I,e,t,i){var w;const{target:A,offsetX:n,offsetY:l,pointerId:o,pointerType:a}=i;if(Je.isInitializedAndDifferentPointerType(a))return;const{viewport:{rotation:d}}=I,{width:m,height:u}=A.getBoundingClientRect(),b=V(lI,Cc,new AbortController),Z=I.combinedSignal(b);if(Je.setPointer(a,o),window.addEventListener("pointerup",G=>{Je.isSamePointerIdOrRemove(G.pointerId)&&this._endDraw(G)},{signal:Z}),window.addEventListener("pointercancel",G=>{Je.isSamePointerIdOrRemove(G.pointerId)&&this._currentParent.endDrawingSession()},{signal:Z}),window.addEventListener("pointerdown",G=>{Je.isSamePointerType(G.pointerType)&&(Je.initializeAndAddPointerId(G.pointerId),c(lI,ce).isCancellable()&&(c(lI,ce).removeLastElement(),c(lI,ce).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:Z}),window.addEventListener("contextmenu",Si,{signal:Z}),A.addEventListener("pointermove",this._drawMove.bind(this),{signal:Z}),A.addEventListener("touchmove",G=>{Je.isSameTimeStamp(G.timeStamp)&&bC(G)},{signal:Z}),I.toggleDrawing(),(w=e._editorUndoBar)==null||w.hide(),c(lI,ce)){I.drawLayer.updateProperties(this._currentDrawId,c(lI,ce).startNew(n,l,m,u,d));return}e.updateUIForDefaultProperties(this),V(lI,ce,this.createDrawerInstance(n,l,m,u,d)),V(lI,ec,this.getDefaultDrawingOptions()),this._currentParent=I,{id:this._currentDrawId}=I.drawLayer.draw(this._mergeSVGProperties(c(lI,ec).toSVGProperties(),c(lI,ce).defaultSVGProperties),!0,!1)}static _drawMove(I){if(Je.isSameTimeStamp(I.timeStamp),!c(lI,ce))return;const{offsetX:e,offsetY:t,pointerId:i}=I;if(Je.isSamePointerId(i)){if(Je.isUsingMultiplePointers()){this._endDraw(I);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,c(lI,ce).add(e,t)),Je.setTimeStamp(I.timeStamp),bC(I)}}static _cleanup(I){I&&(this._currentDrawId=-1,this._currentParent=null,V(lI,ce,null),V(lI,ec,null),Je.clearPointerType(),Je.clearTimeStamp()),c(lI,Cc)&&(c(lI,Cc).abort(),V(lI,Cc,null),Je.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(lI,ce).end(I.offsetX,I.offsetY)),this.supportMultipleDrawings){const t=c(lI,ce),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:aI.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(I){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(aI.DRAW_STEP),!c(lI,ce).isEmpty()){const{pageDimensions:[t,i],scale:A}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:c(lI,ce).getOutlines(t*A,i*A,A,this._INNER_MARGIN),drawingOptions:c(lI,ec),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){JI("Not implemented")}static async deserialize(I,e,t){var d,m;const{rawDims:{pageWidth:i,pageHeight:A,pageX:n,pageY:l}}=e.viewport,o=this.deserializeDraw(n,l,i,A,this._INNER_MARGIN,I),a=await super.deserialize(I,e,t);return a.createDrawingOptions(I),f(d=a,hI,xR).call(d,{drawOutlines:o}),f(m=a,hI,gG).call(m),a.onScaleChanging(),a.rotate(),a}serializeDraw(I){const[e,t]=this.pageTranslation,[i,A]=this.pageDimensions;return c(this,Bi).serialize([e,t,i,A],I)}renderAnnotationElement(I){return I.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Bi=new WeakMap,Um=new WeakMap,ce=new WeakMap,Cc=new WeakMap,ec=new WeakMap,hI=new WeakSet,xR=function({drawOutlines:I,drawId:e,drawingOptions:t}){V(this,Bi,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,hI,OR).call(this,I,this.parent),f(this,hI,IG).call(this,I.box)},OR=function(I,e){const{id:t}=e.drawLayer.draw(lI._mergeSVGProperties(this._drawingOptions.toSVGProperties(),I.defaultSVGProperties),!1,!1);return t},QR=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},gG=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,hI,OR).call(this,c(this,Bi),I)}},FT=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]}},sy=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]}},IG=function(I){[this.x,this.y,this.width,this.height]=f(this,hI,FT).call(this,I),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Hu=function(){const{x:I,y:e,width:t,height:i,rotation:A,parentRotation:n,parentDimensions:[l,o]}=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/o),i*(o/l),t*(l/o)];case 5:return[1-e,I,t*(l/o),i*(o/l)];case 6:return[1-I-i*(o/l),1-e,i*(o/l),t*(l/o)];case 7:return[e-t*(l/o),1-I-i*(o/l),t*(l/o),i*(o/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*(o/l),e,i*(o/l),t*(l/o)];case 13:return[1-e-t*(l/o),I-i*(o/l),t*(l/o),i*(o/l)];case 14:return[1-I,1-e-t*(l/o),i*(o/l),t*(l/o)];case 15:return[e,1-I,t*(l/o),i*(o/l)];default:return[I,e,t,i]}},sg(lI,"_currentDrawId",-1),sg(lI,"_currentParent",null),X(lI,ce,null),X(lI,Cc,null),X(lI,ec,null),sg(lI,"_INNER_MARGIN",3);let Lw=lI;class Bjg{constructor(g,I,e,t,i,A){X(this,Pm);X(this,Jn,new Float64Array(6));X(this,re);X(this,me);X(this,tc);X(this,Em);X(this,ht);X(this,Xe,"");X(this,nA,0);X(this,ic,new kh);X(this,Ac);X(this,nc);V(this,Ac,e),V(this,nc,t),V(this,tc,i),V(this,Em,A),[g,I]=f(this,Pm,oy).call(this,g,I);const n=V(this,re,[NaN,NaN,NaN,NaN,g,I]);V(this,ht,[g,I]),V(this,me,[{line:n,points:c(this,ht)}]),c(this,Jn).set(n,0)}updateProperty(g,I){g==="stroke-width"&&V(this,Em,I)}isEmpty(){return!c(this,me)||c(this,me).length===0}isCancellable(){return c(this,ht).length<=10}add(g,I){[g,I]=f(this,Pm,oy).call(this,g,I);const[e,t,i,A]=c(this,Jn).subarray(2,6),n=g-i,l=I-A;return Math.hypot(c(this,Ac)*n,c(this,nc)*l)<=2?null:(c(this,ht).push(g,I),isNaN(e)?(c(this,Jn).set([i,A,g,I],2),c(this,re).push(NaN,NaN,NaN,NaN,g,I),{path:{d:this.toSVGPath()}}):(isNaN(c(this,Jn)[0])&&c(this,re).splice(6,6),c(this,Jn).set([e,t,i,A,g,I],0),c(this,re).push(...Gg.createBezierPoints(e,t,i,A,g,I)),{path:{d:this.toSVGPath()}}))}end(g,I){const e=this.add(g,I);return e||(c(this,ht).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(g,I,e,t,i){V(this,Ac,e),V(this,nc,t),V(this,tc,i),[g,I]=f(this,Pm,oy).call(this,g,I);const A=V(this,re,[NaN,NaN,NaN,NaN,g,I]);V(this,ht,[g,I]);const n=c(this,me).at(-1);return n&&(n.line=new Float32Array(n.line),n.points=new Float32Array(n.points)),c(this,me).push({line:A,points:c(this,ht)}),c(this,Jn).set(A,0),V(this,nA,0),this.toSVGPath(),null}getLastElement(){return c(this,me).at(-1)}setLastElement(g){return c(this,me)?(c(this,me).push(g),V(this,re,g.line),V(this,ht,g.points),V(this,nA,0),{path:{d:this.toSVGPath()}}):c(this,ic).setLastElement(g)}removeLastElement(){if(!c(this,me))return c(this,ic).removeLastElement();c(this,me).pop(),V(this,Xe,"");for(let g=0,I=c(this,me).length;g<I;g++){const{line:e,points:t}=c(this,me)[g];V(this,re,e),V(this,ht,t),V(this,nA,0),this.toSVGPath()}return{path:{d:c(this,Xe)}}}toSVGPath(){const g=Gg.svgRound(c(this,re)[4]),I=Gg.svgRound(c(this,re)[5]);if(c(this,ht).length===2)return V(this,Xe,`${c(this,Xe)} M ${g} ${I} Z`),c(this,Xe);if(c(this,ht).length<=6){const t=c(this,Xe).lastIndexOf("M");V(this,Xe,`${c(this,Xe).slice(0,t)} M ${g} ${I}`),V(this,nA,6)}if(c(this,ht).length===4){const t=Gg.svgRound(c(this,re)[10]),i=Gg.svgRound(c(this,re)[11]);return V(this,Xe,`${c(this,Xe)} L ${t} ${i}`),V(this,nA,12),c(this,Xe)}const e=[];c(this,nA)===0&&(e.push(`M ${g} ${I}`),V(this,nA,6));for(let t=c(this,nA),i=c(this,re).length;t<i;t+=6){const[A,n,l,o,a,d]=c(this,re).slice(t,t+6).map(Gg.svgRound);e.push(`C${A} ${n} ${l} ${o} ${a} ${d}`)}return V(this,Xe,c(this,Xe)+e.join(" ")),V(this,nA,c(this,re).length),c(this,Xe)}getOutlines(g,I,e,t){const i=c(this,me).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),c(this,ic).build(c(this,me),g,I,e,c(this,tc),c(this,Em),t),V(this,Jn,null),V(this,re,null),V(this,me,null),V(this,Xe,null),c(this,ic)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Jn=new WeakMap,re=new WeakMap,me=new WeakMap,tc=new WeakMap,Em=new WeakMap,ht=new WeakMap,Xe=new WeakMap,nA=new WeakMap,ic=new WeakMap,Ac=new WeakMap,nc=new WeakMap,Pm=new WeakSet,oy=function(g,I){return Gg._normalizePoint(g,I,c(this,Ac),c(this,nc),c(this,tc))};class kh extends Gg{constructor(){super(...arguments);X(this,He);X(this,bt);X(this,GZ,0);X(this,wZ);X(this,pi);X(this,Ln);X(this,Tn);X(this,_m);X(this,$m);X(this,lc)}build(I,e,t,i,A,n,l){V(this,Ln,e),V(this,Tn,t),V(this,_m,i),V(this,$m,A),V(this,lc,n),V(this,wZ,l??0),V(this,pi,I),f(this,He,JT).call(this)}get thickness(){return c(this,lc)}setLastElement(I){return c(this,pi).push(I),{path:{d:this.toSVGPath()}}}removeLastElement(){return c(this,pi).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const I=[];for(const{line:e}of c(this,pi)){if(I.push(`M${Gg.svgRound(e[4])} ${Gg.svgRound(e[5])}`),e.length===6){I.push("Z");continue}if(e.length===12&&isNaN(e[6])){I.push(`L${Gg.svgRound(e[10])} ${Gg.svgRound(e[11])}`);continue}for(let t=6,i=e.length;t<i;t+=6){const[A,n,l,o,a,d]=e.subarray(t,t+6).map(Gg.svgRound);I.push(`C${A} ${n} ${l} ${o} ${a} ${d}`)}}return I.join("")}serialize([I,e,t,i],A){const n=[],l=[],[o,a,d,m]=f(this,He,zT).call(this);let u,b,Z,w,G,B,p,Y,y;switch(c(this,$m)){case 0:y=Gg._rescale,u=I,b=e+i,Z=t,w=-i,G=I+o*t,B=e+(1-a-m)*i,p=I+(o+d)*t,Y=e+(1-a)*i;break;case 90:y=Gg._rescaleAndSwap,u=I,b=e,Z=t,w=i,G=I+a*t,B=e+o*i,p=I+(a+m)*t,Y=e+(o+d)*i;break;case 180:y=Gg._rescale,u=I+t,b=e,Z=-t,w=i,G=I+(1-o-d)*t,B=e+a*i,p=I+(1-o)*t,Y=e+(a+m)*i;break;case 270:y=Gg._rescaleAndSwap,u=I+t,b=e+i,Z=-t,w=-i,G=I+(1-a-m)*t,B=e+(1-o-d)*i,p=I+(1-a)*t,Y=e+(1-o)*i;break}for(const{line:R,points:M}of c(this,pi))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:o,thickness:a}){const d=[];let m,u,b,Z,w;switch(o){case 0:w=Gg._rescale,m=-I/t,u=e/i+1,b=1/t,Z=-1/i;break;case 90:w=Gg._rescaleAndSwap,m=-e/i,u=-I/t,b=1/i,Z=1/t;break;case 180:w=Gg._rescale,m=I/t+1,u=-e/i,b=-1/t,Z=1/i;break;case 270:w=Gg._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],F=B[J+1];Y.set(Gg.createBezierPoints(y,R,M,D,H,F),(J-2)*3),[y,R,M,D]=[M,D,H,F]}}}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,o,a,A),G}get box(){return c(this,bt)}updateProperty(I,e){return I==="stroke-width"?f(this,He,LT).call(this,e):null}updateParentDimensions([I,e],t){const[i,A]=f(this,He,ds).call(this);V(this,Ln,I),V(this,Tn,e),V(this,_m,t);const[n,l]=f(this,He,ds).call(this),o=n-i,a=l-A,d=c(this,bt);return d[0]-=o,d[1]-=a,d[2]+=2*o,d[3]+=2*a,d}updateRotation(I){return V(this,GZ,I),{path:{transform:this.rotationTransform}}}get viewBox(){return c(this,bt).map(Gg.svgRound).join(" ")}get defaultProperties(){const[I,e]=c(this,bt);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.svgRound(e)}`}}}get rotationTransform(){const[,,I,e]=c(this,bt);let t=0,i=0,A=0,n=0,l=0,o=0;switch(c(this,GZ)){case 90:i=e/I,A=-I/e,l=I;break;case 180:t=-1,n=-1,l=I,o=e;break;case 270:i=-e/I,A=I/e,o=e;break;default:return""}return`matrix(${t} ${i} ${A} ${n} ${Gg.svgRound(l)} ${Gg.svgRound(o)})`}getPathResizingSVGProperties([I,e,t,i]){const[A,n]=f(this,He,ds).call(this),[l,o,a,d]=c(this,bt);if(Math.abs(a-A)<=Gg.PRECISION||Math.abs(d-n)<=Gg.PRECISION){const w=I+t/2-(l+a/2),G=e+i/2-(o+d/2);return{path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.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":`${Gg.svgRound(l)} ${Gg.svgRound(o)}`,transform:`${this.rotationTransform} scale(${b} ${Z}) translate(${Gg.svgRound(A)} ${Gg.svgRound(n)}) scale(${m} ${u}) translate(${Gg.svgRound(-A)} ${Gg.svgRound(-n)})`}}}getPathResizedSVGProperties([I,e,t,i]){const[A,n]=f(this,He,ds).call(this),l=c(this,bt),[o,a,d,m]=l;if(l[0]=I,l[1]=e,l[2]=t,l[3]=i,Math.abs(d-A)<=Gg.PRECISION||Math.abs(m-n)<=Gg.PRECISION){const G=I+t/2-(o+d/2),B=e+i/2-(a+m/2);for(const{line:p,points:Y}of c(this,pi))Gg._translate(p,G,B,p),Gg._translate(Y,G,B,Y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.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*(o+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,pi))Gg._rescale(G,Z,w,u,b,G),Gg._rescale(B,Z,w,u,b,B);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([I,e],t){const[i,A]=t,n=c(this,bt),l=I-n[0],o=e-n[1];if(c(this,Ln)===i&&c(this,Tn)===A)for(const{line:a,points:d}of c(this,pi))Gg._translate(a,l,o,a),Gg._translate(d,l,o,d);else{const a=c(this,Ln)/i,d=c(this,Tn)/A;V(this,Ln,i),V(this,Tn,A);for(const{line:m,points:u}of c(this,pi))Gg._rescale(m,l,o,a,d,m),Gg._rescale(u,l,o,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":`${Gg.svgRound(I)} ${Gg.svgRound(e)}`}}}get defaultSVGProperties(){const I=c(this,bt);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Gg.svgRound(I[0])} ${Gg.svgRound(I[1])}`,transform:this.rotationTransform||null},bbox:I}}}bt=new WeakMap,GZ=new WeakMap,wZ=new WeakMap,pi=new WeakMap,Ln=new WeakMap,Tn=new WeakMap,_m=new WeakMap,$m=new WeakMap,lc=new WeakMap,He=new WeakSet,ds=function(I=c(this,lc)){const e=c(this,wZ)+I/2*c(this,_m);return c(this,$m)%180===0?[e/c(this,Ln),e/c(this,Tn)]:[e/c(this,Tn),e/c(this,Ln)]},zT=function(){const[I,e,t,i]=c(this,bt),[A,n]=f(this,He,ds).call(this,0);return[I+A,e+n,t-2*A,i-2*n]},JT=function(){const I=V(this,bt,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of c(this,pi)){if(i.length<=12){for(let l=4,o=i.length;l<o;l+=6)Wg.pointBoundingBox(i[l],i[l+1],I);continue}let A=i[4],n=i[5];for(let l=6,o=i.length;l<o;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,He,ds).call(this);I[0]=lt(I[0]-e,0,1),I[1]=lt(I[1]-t,0,1),I[2]=lt(I[2]+e,0,1),I[3]=lt(I[3]+t,0,1),I[2]-=I[0],I[3]-=I[1]},LT=function(I){const[e,t]=f(this,He,ds).call(this);V(this,lc,I);const[i,A]=f(this,He,ds).call(this),[n,l]=[i-e,A-t],o=c(this,bt);return o[0]-=n,o[1]-=l,o[2]+=2*n,o[3]+=2*l,o};class Tw extends $S{constructor(g){super(),this._viewParameters=g,super.updateProperties({fill:"none",stroke:EI._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 Tw(this._viewParameters);return g.updateAll(this),g}}const qm=class qm extends Lw{constructor(I){super({...I,name:"inkEditor"});X(this,UB);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(I,e){EI.initialize(I,e),this._defaultDrawingOptions=new Tw(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Tg(this,"typesMap",new Map([[aI.INK_THICKNESS,"stroke-width"],[aI.INK_COLOR,"stroke"],[aI.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(I,e,t,i,A){return new Bjg(I,e,t,i,A,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(I,e,t,i,A,n){return kh.deserialize(I,e,t,i,A,n)}static async deserialize(I,e,t){let i=null;if(I instanceof tV){const{data:{inkLists:n,rect:l,rotation:o,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:jg.INK,color:Array.from(d),thickness:u,opacity:m,paths:{points:n},boxes:null,pageIndex:p-1,rect:l.slice(0),rotation:o,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 Kw(this)),[["colorPicker",this._colorPicker]]}get colorType(){return aI.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:EI._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,UB,TT).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}};UB=new WeakSet,TT=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",jg.INK),sg(qm,"_defaultDrawingOptions",null);let sV=qm;class oV extends kh{toSVGPath(){let g=super.toSVGPath();return g.endsWith("Z")||(g+="Z"),g}}const vw=8,Fh=3;class Cl{static extractContoursFromText(g,{fontFamily:I,fontStyle:e,fontWeight:t},i,A,n,l){let o=new OffscreenCanvas(1,1),a=o.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);o=new OffscreenCanvas(y,R),a=o.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,wI,PR).call(this,a.getImageData(0,0,y,R).data),D=f(this,wI,QT).call(this,M),J=f(this,wI,_R).call(this,D),H=f(this,wI,ER).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,wI,UT).call(this,g),[o,a]=f(this,wI,OT).call(this,A,n,l,Math.hypot(n,l)*c(this,sc).sigmaSFactor,c(this,sc).sigmaR,c(this,sc).kernelSize),d=f(this,wI,_R).call(this,a),m=f(this,wI,ER).call(this,o,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:o,height:a}=g,d=g.thickness??0,m=[],u=Math.min(I/o,e/a),b=u/I,Z=u/e,w=[];for(const{points:B}of l){const p=A?f(this,wI,xT).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 F=4;F<Y;F+=2){const T=y[F]=p[F]*b,E=y[F+1]=p[F+1]*Z;R.set(Gg.createBezierPoints(M,D,J,H,T,E),(F-2)*3),[M,D,J,H]=[J,H,T,E]}}if(m.length===0)return null;const G=n?new oV:new kh;return G.build(m,I,e,1,t,n?0:d,i),{outline:G,newCurves:w,areContours:n,thickness:d,width:o,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 o;A>=-128&&n<=127?o=Int8Array:A>=-32768&&n<=32767?o=Int16Array:o=Int32Array;const a=g.length,d=vw+Fh*a,m=new Uint32Array(d);let u=0;m[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*a)*o.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++]=o.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=o.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 CS(B)}static async decompressSignature(g){try{const I=zTg(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),o=l[1];if(o!==0)throw new Error(`Invalid version: ${o}`);const a=l[2],d=l[3],m=l[4]===0,u=l[5],b=l[6],Z=l[7],w=[],G=(vw+Fh*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[Fh*p+vw],y=new Float32Array(Y+2);w.push(y);for(let R=0;R<Fh-1;R++)y[R]=l[Fh*p+vw+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 Lg(`decompressSignature: ${I}`),null}}}sc=new WeakMap,wI=new WeakSet,UR=function(g,I,e,t){return e-=g,t-=I,e===0?t>0?0:4:e===1?t+6:2-t},vA=new WeakMap,vT=function(g,I,e,t,i,A,n){const l=f(this,wI,UR).call(this,e,t,i,A);for(let o=0;o<8;o++){const a=(-o+l-n+16)%8,d=c(this,vA)[2*a],m=c(this,vA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},jT=function(g,I,e,t,i,A,n){const l=f(this,wI,UR).call(this,e,t,i,A);for(let o=0;o<8;o++){const a=(o+l+n+16)%8,d=c(this,vA)[2*a],m=c(this,vA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},ER=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 o=[];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};o.push(B);let p;for(const F of o)if(F.id===l){p=F;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,wI,vT).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,vA)[2*Y],R=c(this,vA)[2*Y+1];const M=a+y,D=d+R;b=M,Z=D;let J=a,H=d;for(;;){const F=f(this,wI,jT).call(this,A,I,J,H,b,Z,1);y=c(this,vA)[2*F],R=c(this,vA)[2*F+1];const T=J+y,E=H+R;w.push(E,T);const q=J*I+H;if(A[q+1]===0?A[q]=-n:A[q]===1&&(A[q]=n),T===a&&E===d&&J===M&&H===D){A[m]!==1&&(l=Math.abs(A[m]));break}else b=J,Z=H,J=T,H=E}}}return o},ay=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,o=Math.hypot(n,l),a=n/o,d=l/o,m=a*A-d*i,u=l/n,b=1/o,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>(o*Y)**2?(f(this,wI,ay).call(this,g,I,R+2,t),f(this,wI,ay).call(this,g,R,e,t)):t.push(i,A)},xT=function(g){const I=[],e=g.length;return f(this,wI,ay).call(this,g,0,e,I),I.push(g[e-2],g[e-1]),I.length<=4?null:I},OT=function(g,I,e,t,i,A){const n=new Float32Array(A**2),l=-2*t**2,o=A>>1;for(let Z=0;Z<A;Z++){const w=(Z-o)**2;for(let G=0;G<A;G++)n[Z*A+G]=Math.exp((w+(G-o)**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-o;if(!(M<0||M>=e))for(let D=0;D<A;D++){const J=w+D-o;if(J<0||J>=I)continue;const H=g[M*I+J],F=n[R*A+D]*a[Math.abs(H-B)];p+=H*F,Y+=F}}const y=u[G]=Math.round(p/Y);b[y]++}return[u,b]},QT=function(g){const I=new Uint32Array(256);for(const e of g)I[e]++;return I},PR=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 o=e[n]=g[n<<2];t=Math.max(t,o),i=Math.min(i,o)}const A=255/(t-i);for(let n=0,l=e.length;n<l;n++)e[n]=(e[n]-i)*A;return e},_R=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},UT=function(g){const I=g,{width:e,height:t}=g,{maxDim:i}=c(this,sc);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 o=new OffscreenCanvas(A,n).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,A,n),o.filter="grayscale(1)",o.drawImage(g,0,0,g.width,g.height,0,0,A,n);const a=o.getImageData(0,0,A,n).data;return[f(this,wI,PR).call(this,a),A,n]},X(Cl,wI),X(Cl,sc,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),X(Cl,vA,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class aV extends $S{constructor(){super(),super.updateProperties({fill:EI._defaultLineColor,"stroke-width":0})}clone(){const g=new aV;return g.updateAll(this),g}}class dV extends Tw{constructor(g){super(g),super.updateProperties({stroke:EI._defaultLineColor,"stroke-width":1})}clone(){const g=new dV(this._viewParameters);return g.updateAll(this),g}}const yi=class yi extends Lw{constructor(I){super({...I,mustBeCommitted:!0,name:"signatureEditor"});X(this,ko,!1);X(this,vn,null);X(this,Fo,null);X(this,oc,null);this._willKeepAspectRatio=!0,V(this,Fo,I.signatureData||null),V(this,vn,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(I,e){EI.initialize(I,e),this._defaultDrawingOptions=new aV,this._defaultDrawnSignatureOptions=new dV(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Tg(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!c(this,vn)}}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,Fo)){const{lines:i,mustSmooth:A,areContours:n,description:l,uuid:o,heightInPage:a}=c(this,Fo),{rawDims:{pageWidth:d,pageHeight:m},rotation:u}=this.parent.viewport,b=Cl.processDrawnLines({lines:i,pageWidth:d,pageHeight:m,rotation:u,innerMargin:yi._INNER_MARGIN,mustSmooth:A,areContours:n});this.addSignature(b,a,l,o)}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,vn)||""}));return t&&(this._isCopy=!0,this._moveAfterPaste(I,e)),this.div}setUuid(I){V(this,oc,I),this.addEditToolbar()}getUuid(){return c(this,oc)}get description(){return c(this,vn)}set description(I){V(this,vn,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,Fo),n=Math.max(i,A),l=Cl.processDrawnLines({lines:{curves:I.map(o=>({points:o})),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,Fo,I);V(this,ko,l instanceof oV),this.description=t;let o;c(this,ko)?o=yi.getDefaultDrawingOptions():(o=yi._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:o});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 Cl.process(I,e,t,i,yi._INNER_MARGIN)}getFromText(I,e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:A}=this.parent.viewport;return Cl.extractContoursFromText(I,e,t,i,A,yi._INNER_MARGIN)}getDrawnSignature(I){const{rawDims:{pageWidth:e,pageHeight:t},rotation:i}=this.parent.viewport;return Cl.processDrawnLines({lines:I,pageWidth:e,pageHeight:t,rotation:i,innerMargin:yi._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:I,thickness:e}){I?this._drawingOptions=yi.getDefaultDrawingOptions():(this._drawingOptions=yi._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,ko),color:[0,0,0],thickness:c(this,ko)?0:i});return this.addComment(A),I?(A.paths={lines:e,points:t},A.uuid=c(this,oc),A.isCopy=!0):A.lines=e,c(this,vn)&&(A.accessibilityData={type:"Figure",alt:c(this,vn)}),A}static deserializeDraw(I,e,t,i,A,n){return n.areContours?oV.deserialize(I,e,t,i,A,n):kh.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,ko,I.areContours),i.description=((A=I.accessibilityData)==null?void 0:A.alt)||"",V(i,oc,I.uuid),i}};ko=new WeakMap,vn=new WeakMap,Fo=new WeakMap,oc=new WeakMap,sg(yi,"_type","signature"),sg(yi,"_editorType",jg.SIGNATURE),sg(yi,"_defaultDrawingOptions",null);let cV=yi;class rV extends EI{constructor(I){super({...I,name:"stampEditor"});X(this,bI);X(this,nC,null);X(this,ue,null);X(this,zo,null);X(this,Pl,null);X(this,Jo,null);X(this,gu,"");X(this,_l,null);X(this,ac,!1);X(this,jn,null);X(this,Yi,!1);X(this,Iu,!1);V(this,Pl,I.bitmapUrl),V(this,Jo,I.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(I,e){EI.initialize(I,e)}static isHandlingMimeForPasting(I){return fY.includes(I)}static paste(I,e){e.pasteEditor({mode:jg.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 o=l.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){var I;c(this,ue)&&(V(this,nC,null),this._uiManager.imageManager.deleteId(c(this,ue)),(I=c(this,_l))==null||I.remove(),V(this,_l,null),c(this,jn)&&(clearTimeout(c(this,jn)),V(this,jn,null))),super.remove()}rebuild(){if(!this.parent){c(this,ue)&&f(this,bI,dy).call(this);return}super.rebuild(),this.div!==null&&(c(this,ue)&&c(this,_l)===null&&f(this,bI,dy).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(I){this._isDraggable=!0,I&&this.div.focus()}isEmpty(){return!(c(this,zo)||c(this,nC)||c(this,Pl)||c(this,Jo)||c(this,ue)||c(this,ac))}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,ac)||(c(this,nC)?f(this,bI,cy).call(this):f(this,bI,dy).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,ue,t),i&&V(this,nC,i),V(this,ac,!1),f(this,bI,cy).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;c(this,jn)!==null&&clearTimeout(c(this,jn)),V(this,jn,setTimeout(()=>{V(this,jn,null),f(this,bI,$R).call(this)},200))}copyCanvas(I,e,t=!1){I||(I=224);const{width:i,height:A}=c(this,nC),n=new an;let l=c(this,nC),o=i,a=A,d=null;if(e){if(i>e||A>e){const M=Math.min(e/i,e/A);o=Math.floor(i*M),a=Math.floor(A*M)}d=document.createElement("canvas");const u=d.width=Math.ceil(o*n.sx),b=d.height=Math.ceil(a*n.sy);c(this,Yi)||(l=f(this,bI,ry).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":xTg.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,nC),i>I||A>I){const G=Math.min(I/i,I/A);u=Math.floor(i*G),b=Math.floor(A*G),c(this,Yi)||(l=f(this,bI,ry).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:o,height:a,imageData:m}}static async deserialize(I,e,t){var w;let i=null,A=!1;if(I instanceof PS){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:F}},canvas:T}=I;let E,q;T?(delete I.canvas,{id:E,bitmap:q}=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:jg.STAMP,bitmapId:E,bitmap:q,pageIndex:F-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:o,bitmapUrl:a,bitmapId:d,isSvg:m,accessibilityData:u}=I;A?(t.addMissingCanvas(I.id,n),V(n,ac,!0)):d&&t.imageManager.isValidId(d)?(V(n,ue,d),o&&V(n,nC,o)):V(n,Pl,a),V(n,Yi,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,Iu,!!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,ue),isSvg:c(this,Yi)});if(this.addComment(t),I)return t.bitmapUrl=f(this,bI,my).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,bI,ET).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,Yi)?(t.rect[2]-t.rect[0])*(t.rect[3]-t.rect[1]):null;if(!e.stamps.has(c(this,ue)))e.stamps.set(c(this,ue),{area:n,serialized:t}),t.bitmap=f(this,bI,my).call(this,!1);else if(c(this,Yi)){const l=e.stamps.get(c(this,ue));n>l.area&&(l.area=n,l.serialized.bitmap.close(),l.serialized.bitmap=f(this,bI,my).call(this,!1))}return t}renderAnnotationElement(I){return this.deleted?(I.hide(),null):(I.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}nC=new WeakMap,ue=new WeakMap,zo=new WeakMap,Pl=new WeakMap,Jo=new WeakMap,gu=new WeakMap,_l=new WeakMap,ac=new WeakMap,jn=new WeakMap,Yi=new WeakMap,Iu=new WeakMap,bI=new WeakSet,CG=function(I,e=!1){if(!I){this.remove();return}V(this,nC,I.bitmap),e||(V(this,ue,I.id),V(this,Yi,I.isSvg)),I.file&&V(this,gu,I.file.name),f(this,bI,cy).call(this)},eG=function(){if(V(this,zo,null),this._uiManager.enableWaiting(!1),!!c(this,_l)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,nC)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,nC)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},dy=function(){if(c(this,ue)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,ue)).then(t=>f(this,bI,CG).call(this,t,!0)).finally(()=>f(this,bI,eG).call(this));return}if(c(this,Pl)){const t=c(this,Pl);V(this,Pl,null),this._uiManager.enableWaiting(!0),V(this,zo,this._uiManager.imageManager.getFromUrl(t).then(i=>f(this,bI,CG).call(this,i)).finally(()=>f(this,bI,eG).call(this)));return}if(c(this,Jo)){const t=c(this,Jo);V(this,Jo,null),this._uiManager.enableWaiting(!0),V(this,zo,this._uiManager.imageManager.getFromFile(t).then(i=>f(this,bI,CG).call(this,i)).finally(()=>f(this,bI,eG).call(this)));return}const I=document.createElement("input");I.type="file",I.accept=fY.join(",");const e=this._uiManager._signal;V(this,zo,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,bI,CG).call(this,i)}t()},{signal:e}),I.addEventListener("cancel",()=>{this.remove(),t()},{signal:e})}).finally(()=>f(this,bI,eG).call(this))),I.click()},cy=function(){var o;const{div:I}=this;let{width:e,height:t}=c(this,nC);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,_l,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=e/i,this.height=t/A,this.setDims(),(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(I.hidden=!1),f(this,bI,$R).call(this),c(this,Iu)||(this.parent.addUndoableEditor(this),V(this,Iu,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,gu)&&this.div.setAttribute("aria-description",c(this,gu)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},ry=function(I,e){const{width:t,height:i}=c(this,nC);let A=t,n=i,l=c(this,nC);for(;A>2*I||n>2*e;){const o=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,o,a,0,0,A,n),l=d.transferToImageBitmap()}return l},$R=function(){const[I,e]=this.parentDimensions,{width:t,height:i}=this,A=new an,n=Math.ceil(t*I*A.sx),l=Math.ceil(i*e*A.sy),o=c(this,_l);if(!o||o.width===n&&o.height===l)return;o.width=n,o.height=l;const a=c(this,Yi)?c(this,nC):f(this,bI,ry).call(this,n,l),d=o.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(a,0,0,a.width,a.height,0,0,n,l)},my=function(I){if(I){if(c(this,Yi)){const i=this._uiManager.imageManager.getSvgUrl(c(this,ue));if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=c(this,nC),e.getContext("2d").drawImage(c(this,nC),0,0),e.toDataURL()}if(c(this,Yi)){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*Rs.PDF_TO_CSS_UNITS),A=Math.round(this.height*t*Rs.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,A);return n.getContext("2d").drawImage(c(this,nC),0,0,c(this,nC).width,c(this,nC).height,0,0,i,A),n.transferToImageBitmap()}return structuredClone(c(this,nC))},ET=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(rV,"_type","stamp"),sg(rV,"_editorType",jg.STAMP);const xA=class xA{constructor({uiManager:g,pageIndex:I,div:e,structTreeLayer:t,accessibilityManager:i,annotationLayer:A,drawLayer:n,textLayer:l,viewport:o,l10n:a}){X(this,jI);X(this,dc);X(this,Cu,!1);X(this,Lo,null);X(this,To,null);X(this,$l,null);X(this,Ot,new Map);X(this,vo,!1);X(this,eu,!1);X(this,tu,!1);X(this,jA,null);X(this,ql,null);X(this,he,null);X(this,gs,null);X(this,jo,null);X(this,iu,-1);X(this,pg);const d=[...c(xA,xo).values()];if(!xA._initialized){xA._initialized=!0;for(const m of d)m.initialize(a,g)}g.registerEditorTypes(d),V(this,pg,g),this.pageIndex=I,this.div=e,V(this,dc,i),V(this,Lo,A),this.viewport=o,V(this,he,l),this.drawLayer=n,this._structTree=t,c(this,pg).addLayer(this)}get isEmpty(){return c(this,Ot).size===0}get isInvisible(){return this.isEmpty&&c(this,pg).getMode()===jg.NONE}updateToolbar(g){c(this,pg).updateToolbar(g)}updateMode(g=c(this,pg).getMode()){switch(f(this,jI,uy).call(this),g){case jg.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case jg.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case jg.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===jg.POPUP)I.toggle("commentEditing",!0);else{I.toggle("commentEditing",!1);for(const e of c(xA,xo).values())I.toggle(`${e._type}Editing`,g===e._editorType)}this.div.hidden=!1}hasTextLayer(g){var I;return g===((I=c(this,he))==null?void 0:I.div)}setEditingState(g){c(this,pg).setEditingState(g)}addCommands(g){c(this,pg).addCommands(g)}cleanUndoStack(g){c(this,pg).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,Lo))==null||I.togglePointerEvents(g)}async enable(){var e;V(this,tu,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(e=c(this,jo))==null||e.abort(),V(this,jo,null);const g=new Set;for(const t of c(this,jI,qR))t.enableEditing(),t.show(!0),t.annotationElementId&&(c(this,pg).removeChangedExistingAnnotation(t),g.add(t.annotationElementId));const I=c(this,Lo);if(I)for(const t of I.getEditableAnnotations()){if(t.hide(),c(this,pg).isDeletedAnnotationElement(t.data.id)||g.has(t.data.id))continue;const i=await this.deserialize(t);i&&(this.addOrRebuild(i),i.enableEditing())}V(this,tu,!1),c(this,pg)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var t;if(V(this,eu,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),c(this,he)&&!c(this,jo)){V(this,jo,new AbortController);const i=c(this,pg).combinedSignal(c(this,jo));c(this,he).div.addEventListener("pointerdown",A=>{const{clientX:l,clientY:o,timeStamp:a}=A,d=c(this,iu);if(a-d>500){V(this,iu,a);return}V(this,iu,-1);const{classList:m}=this.div;m.toggle("getElements",!0);const u=document.elementsFromPoint(l,o);if(m.toggle("getElements",!1),!this.div.contains(u[0]))return;let b;const Z=new RegExp(`^${Zh}[0-9]+$`);for(const G of u)if(Z.test(G.id)){b=G.id;break}if(!b)return;const w=c(this,Ot).get(b);(w==null?void 0:w.annotationElementId)===null&&(A.stopPropagation(),A.preventDefault(),w.dblclick(A))},{signal:i,capture:!0})}const g=c(this,Lo),I=[];if(g){const i=new Map,A=new Map;for(const l of c(this,jI,qR)){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:o}=l.data;if(c(this,pg).isDeletedAnnotationElement(o)){l.updateEdited({deleted:!0});continue}let a=A.get(o);if(a){a.resetAnnotationElement(l),a.show(!1),l.show();continue}a=i.get(o),a&&(c(this,pg).addChangedExistingAnnotation(a),a.renderAnnotationElement(l)&&a.show(!1)),l.show()}}f(this,jI,uy).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const i of c(xA,xo).values())e.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),g==null||g.updateFakeAnnotations(I),V(this,eu,!1)}getEditableAnnotation(g){var I;return((I=c(this,Lo))==null?void 0:I.getEditableAnnotation(g))||null}setActiveEditor(g){c(this,pg).getActive()!==g&&c(this,pg).setActiveEditor(g)}enableTextSelection(){var g;if(this.div.tabIndex=-1,(g=c(this,he))!=null&&g.div&&!c(this,gs)){V(this,gs,new AbortController);const I=c(this,pg).combinedSignal(c(this,gs));c(this,he).div.addEventListener("pointerdown",f(this,jI,PT).bind(this),{signal:I}),c(this,he).div.classList.add("highlighting")}}disableTextSelection(){var g;this.div.tabIndex=0,(g=c(this,he))!=null&&g.div&&c(this,gs)&&(c(this,gs).abort(),V(this,gs,null),c(this,he).div.classList.remove("highlighting"))}enableClick(){if(c(this,To))return;V(this,To,new AbortController);const g=c(this,pg).combinedSignal(c(this,To));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,To))==null||g.abort(),V(this,To,null)}attach(g){c(this,Ot).set(g.id,g);const{annotationElementId:I}=g;I&&c(this,pg).isDeletedAnnotationElement(I)&&c(this,pg).removeDeletedAnnotationElement(g)}detach(g){var I;c(this,Ot).delete(g.id),(I=c(this,dc))==null||I.removePointerInTextLayer(g.contentDiv),!c(this,eu)&&g.annotationElementId&&c(this,pg).addDeletedAnnotationElement(g)}remove(g){this.detach(g),c(this,pg).removeEditor(g),g.div.remove(),g.isAttachedToDOM=!1}changeParent(g){var I;g.parent!==this&&(g.parent&&g.annotationElementId&&(c(this,pg).addDeletedAnnotationElement(g),EI.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,pg).addEditor(g),this.attach(g),!g.isAttachedToDOM){const I=g.render();this.div.append(I),g.isAttachedToDOM=!0}g.fixAndSetPosition(),g.onceAdded(!c(this,tu)),c(this,pg).addToAnnotationStorage(g),g._reportTelemetry(g.telemetryInitialData)}}moveEditorInDOM(g){var e;if(!g.isAttachedToDOM)return;const{activeElement:I}=document;g.div.contains(I)&&!c(this,$l)&&(g._focusEventsAllowed=!1,V(this,$l,setTimeout(()=>{V(this,$l,null),g.div.contains(document.activeElement)?g._focusEventsAllowed=!0:(g.div.addEventListener("focusin",()=>{g._focusEventsAllowed=!0},{once:!0,signal:c(this,pg)._signal}),I.focus())},0))),g._structTreeParentId=(e=c(this,dc))==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,Ot).values())if(I.uid===g)return I;return null}getNextId(){return c(this,pg).getId()}combinedSignal(g){return c(this,pg).combinedSignal(g)}canCreateNewEmptyEditor(){var g;return(g=c(this,jI,En))==null?void 0:g.canCreateNewEmptyEditor()}async pasteEditor(g,I){this.updateToolbar(g),await c(this,pg).updateMode(g.mode);const{offsetX:e,offsetY:t}=f(this,jI,IX).call(this),i=this.getNextId(),A=f(this,jI,gX).call(this,{parent:this,id:i,x:e,y:t,uiManager:c(this,pg),isCentered:!0,...I});A&&this.add(A)}async deserialize(g){var I;return await((I=c(xA,xo).get(g.annotationType??g.annotationEditorType))==null?void 0:I.deserialize(g,this,c(this,pg)))||null}createAndAddNewEditor(g,I,e={}){const t=this.getNextId(),i=f(this,jI,gX).call(this,{parent:this,id:t,x:g.offsetX,y:g.offsetY,uiManager:c(this,pg),isCentered:I,...e});return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(g={}){this.createAndAddNewEditor(f(this,jI,IX).call(this),!0,g)}setSelected(g){c(this,pg).setSelected(g)}toggleSelected(g){c(this,pg).toggleSelected(g)}unselect(g){c(this,pg).unselect(g)}pointerup(g){var t;const{isMac:I}=we.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div||!c(this,vo)||(V(this,vo,!1),(t=c(this,jI,En))!=null&&t.isDrawer&&c(this,jI,En).supportMultipleDrawings))return;if(!c(this,Cu)){V(this,Cu,!0);return}const e=c(this,pg).getMode();if(e===jg.STAMP||e===jg.SIGNATURE){c(this,pg).unselectAll();return}this.createAndAddNewEditor(g,!1)}pointerdown(g){var t;if(c(this,pg).getMode()===jg.HIGHLIGHT&&this.enableTextSelection(),c(this,vo)){V(this,vo,!1);return}const{isMac:I}=we.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div)return;if(V(this,vo,!0),(t=c(this,jI,En))!=null&&t.isDrawer){this.startDrawingSession(g);return}const e=c(this,pg).getActive();V(this,Cu,!e||e.isEmpty())}startDrawingSession(g){if(this.div.focus({preventScroll:!0}),c(this,jA)){c(this,jI,En).startDrawing(this,c(this,pg),!1,g);return}c(this,pg).setCurrentDrawingSession(this),V(this,jA,new AbortController);const I=c(this,pg).combinedSignal(c(this,jA));this.div.addEventListener("blur",({relatedTarget:e})=>{e&&!this.div.contains(e)&&(V(this,ql,null),this.commitOrRemove())},{signal:I}),c(this,jI,En).startDrawing(this,c(this,pg),!1,g)}pause(g){if(g){const{activeElement:I}=document;this.div.contains(I)&&V(this,ql,I);return}c(this,ql)&&setTimeout(()=>{var I;(I=c(this,ql))==null||I.focus(),V(this,ql,null)},0)}endDrawingSession(g=!1){return c(this,jA)?(c(this,pg).setCurrentDrawingSession(null),c(this,jA).abort(),V(this,jA,null),V(this,ql,null),c(this,jI,En).endDrawing(g)):null}findNewParent(g,I,e){const t=c(this,pg).findParent(I,e);return t===null||t===this?!1:(t.changeParent(g),!0)}commitOrRemove(){return c(this,jA)?(this.endDrawingSession(),!0):!1}onScaleChanging(){c(this,jA)&&c(this,jI,En).onScaleChangingWhenDrawing(this)}destroy(){var g,I;this.commitOrRemove(),((g=c(this,pg).getActive())==null?void 0:g.parent)===this&&(c(this,pg).commitOrRemove(),c(this,pg).setActiveEditor(null)),c(this,$l)&&(clearTimeout(c(this,$l)),V(this,$l,null));for(const e of c(this,Ot).values())(I=c(this,dc))==null||I.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,c(this,Ot).clear(),c(this,pg).removeLayer(this)}render({viewport:g}){this.viewport=g,Ya(this.div,g);for(const I of c(this,pg).getEditors(this.pageIndex))this.add(I),I.rebuild();this.updateMode()}update({viewport:g}){c(this,pg).commitOrRemove(),f(this,jI,uy).call(this);const I=this.viewport.rotation,e=g.rotation;if(this.viewport=g,Ya(this.div,{rotation:e}),I!==e)for(const t of c(this,Ot).values())t.rotate(e)}get pageDimensions(){const{pageWidth:g,pageHeight:I}=this.viewport.rawDims;return[g,I]}get scale(){return c(this,pg).viewParameters.realScale}};dc=new WeakMap,Cu=new WeakMap,Lo=new WeakMap,To=new WeakMap,$l=new WeakMap,Ot=new WeakMap,vo=new WeakMap,eu=new WeakMap,tu=new WeakMap,jA=new WeakMap,ql=new WeakMap,he=new WeakMap,gs=new WeakMap,jo=new WeakMap,iu=new WeakMap,pg=new WeakMap,xo=new WeakMap,jI=new WeakSet,qR=function(){return c(this,Ot).size!==0?c(this,Ot).values():c(this,pg).getEditors(this.pageIndex)},PT=function(g){c(this,pg).unselectAll();const{target:I}=g;if(I===c(this,he).div||(I.getAttribute("role")==="img"||I.classList.contains("endOfContent"))&&c(this,he).div.contains(I)){const{isMac:e}=we.platform;if(g.button!==0||g.ctrlKey&&e)return;c(this,pg).showAllEditors("highlight",!0,!0),c(this,he).div.classList.add("free"),this.toggleDrawing(),Jw.startHighlighting(this,c(this,pg).direction==="ltr",{target:c(this,he).div,x:g.x,y:g.y}),c(this,he).div.addEventListener("pointerup",()=>{c(this,he).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,pg)._signal}),g.preventDefault()}},En=function(){return c(xA,xo).get(c(this,pg).getMode())},gX=function(g){const I=c(this,jI,En);return I?new I.prototype.constructor(g):null},IX=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),o=(i+n)/2-g,a=(A+l)/2-I,[d,m]=this.viewport.rotation%180===0?[o,a]:[a,o];return{offsetX:d,offsetY:m}},uy=function(){for(const g of c(this,Ot).values())g.isEmpty()&&g.remove()},sg(xA,"_initialized",!1),X(xA,xo,new Map([AV,sV,rV,Jw,cV].map(g=>[g._editorType,g])));let mV=xA;const Ie=class Ie{constructor({pageIndex:g}){X(this,xn);X(this,OA,null);X(this,Zt,new Map);X(this,cc,new Map);this.pageIndex=g}setParent(g){if(!c(this,OA)){V(this,OA,g);return}if(c(this,OA)!==g){if(c(this,Zt).size>0)for(const I of c(this,Zt).values())I.remove(),g.append(I);V(this,OA,g)}}static get _svgFactory(){return Tg(this,"_svgFactory",new kw)}draw(g,I=!1,e=!1){const t=te(Ie,WZ)._++,i=f(this,xn,CX).call(this),A=Ie._svgFactory.createElement("defs");i.append(A);const n=Ie._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,cc).set(t,n);const o=e?f(this,xn,$T).call(this,A,l):null,a=Ie._svgFactory.createElement("use");return i.append(a),a.setAttribute("href",`#${l}`),this.updateProperties(i,g),c(this,Zt).set(t,i),{id:t,clipPathId:`url(#${o})`}}drawOutline(g,I){const e=te(Ie,WZ)._++,t=f(this,xn,CX).call(this),i=Ie._svgFactory.createElement("defs");t.append(i);const A=Ie._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=Ie._svgFactory.createElement("mask");i.append(d),l=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const m=Ie._svgFactory.createElement("rect");d.append(m),m.setAttribute("width","1"),m.setAttribute("height","1"),m.setAttribute("fill","white");const u=Ie._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 o=Ie._svgFactory.createElement("use");t.append(o),o.setAttribute("href",`#${n}`),l&&o.setAttribute("mask",`url(#${l})`);const a=o.cloneNode();return t.append(a),o.classList.add("mainOutline"),a.classList.add("secondaryOutline"),this.updateProperties(t,g),c(this,Zt).set(e,t),e}finalizeDraw(g,I){c(this,cc).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,Zt).get(g):g;if(n){if(e&&f(this,xn,eX).call(this,n,e),t&&f(l=Ie,EB,_T).call(l,n,t),i){const{classList:o}=n;for(const[a,d]of Object.entries(i))o.toggle(a,d)}if(A){const a=n.firstElementChild.firstElementChild;f(this,xn,eX).call(this,a,A)}}}updateParent(g,I){if(I===this)return;const e=c(this,Zt).get(g);e&&(c(I,OA).append(e),c(this,Zt).delete(g),c(I,Zt).set(g,e))}remove(g){c(this,cc).delete(g),c(this,OA)!==null&&(c(this,Zt).get(g).remove(),c(this,Zt).delete(g))}destroy(){V(this,OA,null);for(const g of c(this,Zt).values())g.remove();c(this,Zt).clear(),c(this,cc).clear()}};OA=new WeakMap,Zt=new WeakMap,cc=new WeakMap,WZ=new WeakMap,EB=new WeakSet,_T=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}%`},xn=new WeakSet,CX=function(){const g=Ie._svgFactory.create(1,1,!0);return c(this,OA).append(g),g.setAttribute("aria-hidden",!0),g},$T=function(g,I){const e=Ie._svgFactory.createElement("clipPath");g.append(e);const t=`clip_${I}`;e.setAttribute("id",t),e.setAttribute("clipPathUnits","objectBoundingBox");const i=Ie._svgFactory.createElement("use");return e.append(i),i.setAttribute("href",`#${I}`),i.classList.add("clip"),t},eX=function(g,I){for(const[e,t]of Object.entries(I))t===null?g.removeAttribute(e):g.setAttribute(e,t)},X(Ie,EB),X(Ie,WZ,0);let uV=Ie;globalThis._pdfjsTestingUtils={HighlightOutliner:nV},globalThis.pdfjsLib={AbortException:Ms,AnnotationEditorLayer:mV,AnnotationEditorParamsType:aI,AnnotationEditorType:jg,AnnotationEditorUIManager:Va,AnnotationLayer:iV,AnnotationMode:Ns,AnnotationType:kC,applyOpacity:QTg,build:gjg,ColorPicker:Sw,createValidAbsoluteUrl:PD,CSSConstants:OTg,DOMSVGFactory:kw,DrawLayer:uV,FeatureTest:we,fetchData:ph,findContrastColor:UTg,getDocument:$Y,getFilenameFromUrl:JTg,getPdfFilenameFromUrl:LTg,getRGB:Nh,getUuid:IS,getXfaPageViewport:vTg,GlobalWorkerOptions:cn,ImageKind:mw,InvalidPDFException:MY,isDataScheme:Gw,isPdfFile:Yh,isValidExplicitDest:tvg,MathClamp:lt,noContextMenu:Si,normalizeUnicode:kTg,OPS:Gh,OutputScale:an,PasswordResponses:NTg,PDFDataRangeTransport:vS,PDFDateString:ww,PDFWorker:Sh,PermissionFlag:VTg,PixelsPerInch:Rs,RenderingCancelledException:HY,renderRichText:sS,ResponseException:Zw,setLayerDimensions:Ya,shadow:Tg,SignatureExtractor:Cl,stopEvent:bC,SupportedImageMimeTypes:fY,TextLayer:Dh,TouchManager:pw,updateUrlHash:_D,Util:Wg,VerbosityLevel:uw,version:qvg,XfaLayer:eS};class pjg{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 Ra=new pjg,yjg=["src"],el=s.defineComponent({name:"PdfPreview",__name:"PdfPreview",props:{src:{},page:{}},setup(C,{expose:g}){cn.workerSrc=YTg;const I=C,e=s.reactive({isError:!1,rotate:0}),t=s.ref(null);let i,A=null;s.watch([()=>I.src,()=>I.page],()=>{i==null||i.disconnect(),a(),e.isError=!1,s.nextTick(()=>{o()})}),s.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=Ra.getCache(I.src);if(m?d=m:(d=await $Y(I.src).promise,Ra.setCache(I.src,d)),!d)throw new Error("Pdf not found");const u=I.page??1,b=`${I.src}-${u}`,Z=Ra.getPageCache(b);let w;Z?w=Z:(w=await d.getPage(u),Ra.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=window.devicePixelRatio||1,M=w.getViewport({scale:y*R,rotation:e.rotate}),D=t.value.getContext("2d");if(D===null)throw new Error("Context not found");t.value.width=M.width,t.value.height=M.height;const J=w.render({canvas:t.value,canvasContext:D,viewport:M});A=J,await J.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}finally{A=null}},l=async d=>{try{if(!t.value)return;const m=Ra.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}finally{A=null}},o=()=>{t.value&&(i=new IntersectionObserver((d,m)=>{d.forEach(u=>{u.isIntersecting&&(n(),m.unobserve(u.target))},{rootMargin:"50px"})}),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}),s.onMounted(()=>{o()}),(d,m)=>e.isError?(s.openBlock(),s.createElementBlock("img",{key:1,src:s.unref(gl)},null,8,yjg)):(s.openBlock(),s.createElementBlock("canvas",{key:0,ref_key:"canvas",ref:t},null,512))}});var hV=(C=>(C.slideTop="slide-top",C.slideLeft="slide-left",C.fadeAndScale="fade-and-scale",C.fade="fade",C))(hV||{});function qI(C,g=document.documentElement){for(const[I,e]of Object.entries(C))g.style.setProperty(I,String(e))}const Yjg=()=>{const C=s.ref(0),g=s.ref([]),I=s.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}},Vjg=["data-testid"],Njg=["data-testid"],Mjg=Vg(s.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}=Yjg(),A=C,n=s.ref(null),l=s.useAttrs(),o=s.ref(!1),a=s.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&&qI({overflow:"","padding-right":""},document.body)},p=Y=>{Y.target===n.value&&b()};return g({closeDialog:Z}),s.onMounted(()=>{s.watchEffect(()=>{A.open!==o.value&&(u(),o.value=A.open,n.value&&n.value.focus())}),n.value&&n.value.addEventListener("cancel",y=>{y.preventDefault()});const Y=G();qI({overflow:"hidden","padding-right":`${Y}px`},document.body),document.addEventListener("keydown",w)}),s.onUnmounted(()=>{B(),document.removeEventListener("keydown",w),d("unmounted")}),(Y,y)=>(s.openBlock(),s.createElementBlock("dialog",s.mergeProps({ref_key:"dialog",ref:n},s.unref(l),{class:["modal-yui-kit",`modal-yui-kit_${A.position}`],"data-testid":A.dataTestid,onClick:s.withModifiers(p,["self","left"])}),[s.createElementVNode("div",{class:"modal-yui-kit__modal-content",style:s.normalizeStyle(a.value),"data-testid":`${A.dataTestid}-ModalContent`},[s.renderSlot(Y.$slots,"default",{},void 0,!0)],12,Njg)],16,Vjg))}}),[["__scopeId","data-v-b4b136aa"]]),zh=Vg(s.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=s.computed(()=>I.animateType===hV.fade?"fade":I.position==="bottom"?"slide-bottom":I.position==="right"?"slide-left":"fade-and-scale"),i=s.ref(null),A=s.reactive({function:()=>{}}),n=()=>{d()},l=()=>{e("unmounted")},o=()=>{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)=>(s.openBlock(),s.createBlock(s.Transition,{name:t.value,onAfterLeave:a,onBeforeLeave:o,onAfterEnter:n},{default:s.withCtx(()=>[I.open?(s.openBlock(),s.createBlock(Mjg,{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:s.withCtx(()=>[s.renderSlot(u.$slots,"default",{},void 0,!0)]),_:3},8,["open","position","width","height","data-testid"])):s.createCommentVNode("",!0)]),_:3},8,["name"]))}}),[["__scopeId","data-v-6c0d942a"]]),qS=(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}},bV=(C,g=null)=>{if(!C)return;(g?qS(C,g):qS(C))||C.scrollIntoView({behavior:"smooth",block:"nearest"})},Rjg=s.defineComponent({name:"BaseSlider",__name:"BaseSlider",props:{activeIndex:{default:0}},setup(C,{expose:g}){const I=C,e=s.reactive({children:null,activeIndex:I.activeIndex}),t=s.ref(null),i=s.ref(null);s.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||(bV(d[a],i.value),e.activeIndex=a)},n=()=>{s.nextTick(()=>{!e.children||!i.value||bV(e.children[e.activeIndex],i.value)})},l=()=>(A(e.activeIndex+1),e.activeIndex),o=()=>(A(e.activeIndex-1),e.activeIndex);return s.onMounted(()=>{!t.value||!i.value||(e.children=[...t.value.children])}),g({shiftPosition:A,nextSlide:l,prevSlide:o,initScroll:n}),(a,d)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"sliderRef",ref:i,class:"base-slider"},[s.createElementVNode("div",{ref_key:"contentRef",ref:t,class:"base-slider__content"},[s.renderSlot(a.$slots,"default")],512)],512))}}),Xjg={class:"base-slide__content"},Hjg=s.defineComponent({name:"BaseSlide",__name:"BaseSlide",props:{isActive:{type:Boolean}},setup(C){const g=C,I=s.computed(()=>[{"base-slide_active":g.isActive}]);return(e,t)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["base-slide",I.value])},[s.createElementVNode("div",Xjg,[s.renderSlot(e.$slots,"default")])],2))}}),g9=C=>{if(!C)return null;const g=C.split("?")[0],I=/\.\w+$/,e=g.match(I);return e?e[0].replace(".",""):null},ZV=C=>{if(!C)return!1;if(C.startsWith("data:image/"))return!0;const g=g9(C);return g?Object.values(hh).includes(g.toLowerCase()):!1},fjg=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 I9={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(o){return i[o]}).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 o}),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 o(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=o(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 o(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(o,a){o.printable.constructor!==Array&&(o.printable=[o.printable]),o.printableElement=document.createElement("div"),o.printable.forEach(function(d){var m=document.createElement("img");if(m.setAttribute("style",o.imageStyle),m.src=d,n.default.isFirefox()){var u=m.src;m.src=u}var b=document.createElement("div");b.appendChild(m),o.printableElement.appendChild(b)}),o.header&&Object(i.addHeader)(o.printableElement,o),A.default.send(o,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"),o=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":o.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(o){"@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(o)}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(o){var a=o.printable,d=o.properties,m='<table style="border-collapse: collapse; width: 100%;">';o.repeatTableHeader&&(m+="<thead>"),m+="<tr>";for(var u=0;u<d.length;u++)m+='<th style="width:'+d[u].columnSize+";"+o.gridHeaderStyle+'">'+Object(i.capitalizePrint)(d[u].displayName)+"</th>";m+="</tr>",o.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+o.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;",o=document.createElement("div");o.setAttribute("style",l),o.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),o.appendChild(a),document.getElementsByTagName("body")[0].appendChild(o),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(o,a){if(o.base64){var d=Uint8Array.from(atob(o.printable),function(u){return u.charCodeAt(0)});n(o,a,d);return}o.printable=/^(blob|http|\/\/)/i.test(o.printable)?o.printable:window.location.origin+(o.printable.charAt(0)!=="/"?"/"+o.printable:o.printable);var m=new window.XMLHttpRequest;m.responseType="arraybuffer",m.addEventListener("error",function(){Object(A.cleanUp)(o),o.onError(m.statusText,m)}),m.addEventListener("load",function(){if([200,201].indexOf(m.status)===-1){Object(A.cleanUp)(o),o.onError(m.statusText,m);return}n(o,a,m.response)}),m.open("GET",o.printable,!0),m.send()}};function n(l,o,a){var d=new window.Blob([a],{type:"application/pdf"});d=window.URL.createObjectURL(d),o.setAttribute("src",d),i.default.send(l,o)}},"./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?o(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 o(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})})(I9);var Djg=I9.exports;const Sjg=QLg(Djg),Jh=C=>{if(!C)return!1;const g=g9(C);return g?Object.values(bh).includes(g):!1},Kjg=["src"],Lh=s.defineComponent({name:"VideoPreview",__name:"VideoPreview",props:{src:{}},emits:["error"],setup(C,{emit:g}){const I=C,e=g,t=s.reactive({isError:!1});s.watch(()=>I.src,()=>{t.isError=!1,s.nextTick(()=>{A()})});const i=s.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 o=await fetch(I.src);if(!o.ok)throw new Error("Failed to fetch video");const a=new Blob([await o.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 s.onMounted(()=>{s.nextTick(()=>{A()})}),(n,l)=>t.isError?(s.openBlock(),s.createElementBlock("img",{key:1,src:s.unref(gl)},null,8,Kjg)):(s.openBlock(),s.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:i,class:"video-preview"},null,512))}}),kjg=["src"],jw=s.defineComponent({name:"ImagePreview",__name:"ImagePreview",props:{src:{}},emits:["error"],setup(C,{expose:g,emit:I}){const e=C,t=I,i=s.reactive({isError:!1,rotate:0});s.watch(()=>e.src,()=>{i.isError=!1,i.rotate=0,s.nextTick(()=>{n()})});const A=s.ref(null),n=async()=>{try{if(!A.value||!e.src)return;const o=new Image;o.src=e.src,o.addEventListener("load",()=>{var Z;if(!A.value)return;const a=(Z=A.value)==null?void 0:Z.getContext("2d");if(!a)return;const d=o.width,m=o.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(o,-d/2,-m/2,d,m),a.restore()}),o.addEventListener("error",a=>{i.isError=!0,t("error",a)})}catch{t("error",new Event("error")),i.isError=!0}},l=async o=>{const a=Math.round(o/90)*90;i.rotate+=a,s.nextTick(()=>{n()})};return s.onMounted(()=>{s.nextTick(()=>{n()})}),g({rotateImage:l}),(o,a)=>i.isError?(s.openBlock(),s.createElementBlock("img",{key:1,src:s.unref(gl)},null,8,kjg)):(s.openBlock(),s.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:A,class:"image-preview"},null,512))}}),tl=C=>C?C instanceof File?C.type==="application/pdf":Yh(C):!1,Fjg={ref:"contentRef",class:"slider-modal__content"},zjg=["onClick"],Jjg={class:"slider-modal__side-bar-count"},Ljg={class:"slider-modal__mobile-header"},Tjg={class:"slider-modal__mobile-header-block"},vjg={class:"slider-modal__mobile-header-block"},jjg={key:0,class:"slider-modal__counter"},xjg=["data-testid"],Ojg=["src"],Qjg=["src"],Ujg={class:"slider-modal__bottom"},Ejg={class:"slider-modal__nav-block"},Pjg=["disabled"],_jg=["src","alt"],$jg=["src"],qjg=["disabled"],gxg={class:"slider-modal__nav-block"},Ixg={class:"slider-modal__sub-nav"},Cxg=["disabled"],exg=["disabled"],txg=["disabled"],ixg={class:"slider-modal__sub-nav"},Axg=["disabled"],nxg=["disabled"],GV=80,C9=20,lxg=80,sxg=20,xw=Vg(s.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,{emit:g}){const I=C,e=g,t=window.matchMedia("(max-width: 768px)"),i=s.reactive({defaultIndex:I.defaultIndex,file:I.items[I.defaultIndex],sideBarItems:[],sideBarIndex:0,sideBarLength:0,isErrorFile:!1,isClickOnExit:!1,isDragging:!1,isMobile:!1,isPointerActive:!1,isExistSwipe:!1,isChangeItemSwipe:!1,isSwipeNextSlide:!1,isSwipePrevSlide:!1,isExitScrollActive:!1,zoomValue:1,offsetX:0,offsetY:0,startX:0,startY:0,startXForMobile:0,startYForMobile:0,endXForMobile:0,endYForMobile:0,overscrollDelta:0,startScrollTop:0}),A=s.ref(null),n=s.ref(null),l=s.ref(null),o=s.ref(null),a=s.ref(null),d=s.ref(null),m=s.ref(null),u=s.ref(null),b=s.computed(()=>i.defaultIndex===0),Z=s.computed(()=>i.defaultIndex===I.items.length-1),w=s.computed(()=>{var rg,Jg;let og=!i.file||i.isErrorFile;return og=Jh((rg=i.file)==null?void 0:rg.path)||og,og=i.isMobile&&tl((Jg=i.file)==null?void 0:Jg.path)||og,og}),G=s.computed(()=>{var rg;let og=!i.file||i.isErrorFile;return og=Jh((rg=i.file)==null?void 0:rg.path)||og,og}),B=s.computed(()=>!i.file||i.isErrorFile),p=s.computed(()=>{var rg;let og=!i.file||i.isErrorFile;return og=Jh((rg=i.file)==null?void 0:rg.path)||og,og}),Y=s.computed(()=>({transform:`
1328
+ `)){const e=document.createElement("div");e.append(I?document.createTextNode(I):document.createElement("br")),this.editorDiv.append(e)}},hT=function(){return c(this,hi).replaceAll(" "," ")},LR=function(I){return I.replaceAll(" "," ")},bT=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(IC,Ol),sg(IC,"_freeTextDefaultContent",""),sg(IC,"_internalPadding",0),sg(IC,"_defaultColor",null),sg(IC,"_defaultFontSize",10),sg(IC,"_type","freetext"),sg(IC,"_editorType",jg.FREETEXT);let AV=IC;class Gg{toSVGPath(){JI("Abstract method `toSVGPath` must be implemented.")}get box(){JI("Abstract getter `box` must be implemented.")}serialize(g,I){JI("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(Gg,"PRECISION",1e-4);const Ql=class Ql{constructor({x:g,y:I},e,t,i,A,n=0){X(this,ge);X(this,Zi);X(this,LA,[]);X(this,Fm);X(this,zm);X(this,zn,[]);X(this,tI,new Float32Array(18));X(this,Pd);X(this,_d);X(this,AZ);X(this,nZ);X(this,Jm);X(this,Lm);X(this,So,[]);V(this,Zi,e),V(this,Lm,i*t),V(this,zm,A),c(this,tI).set([NaN,NaN,NaN,NaN,g,I],6),V(this,Fm,n),V(this,nZ,c(Ql,lZ)*t),V(this,AZ,c(Ql,OB)*t),V(this,Jm,t),c(this,So).push(g,I)}isEmpty(){return isNaN(c(this,tI)[8])}add({x:g,y:I}){var J;V(this,Pd,g),V(this,_d,I);const[e,t,i,A]=c(this,Zi);let[n,l,o,a]=c(this,tI).subarray(8,12);const d=g-o,m=I-a,u=Math.hypot(d,m);if(u<c(this,AZ))return!1;const b=u-c(this,nZ),Z=b/u,w=Z*d,G=Z*m;let B=n,p=l;n=o,l=a,o+=w,a+=G,(J=c(this,So))==null||J.push(g,I);const Y=-G/b,y=w/b,R=Y*c(this,Lm),M=y*c(this,Lm);return c(this,tI).set(c(this,tI).subarray(2,8),0),c(this,tI).set([o+R,a+M],4),c(this,tI).set(c(this,tI).subarray(14,18),12),c(this,tI).set([o-R,a-M],16),isNaN(c(this,tI)[6])?(c(this,zn).length===0&&(c(this,tI).set([n+R,l+M],2),c(this,zn).push(NaN,NaN,NaN,NaN,(n+R-e)/i,(l+M-t)/A),c(this,tI).set([n-R,l-M],14),c(this,LA).push(NaN,NaN,NaN,NaN,(n-R-e)/i,(l-M-t)/A)),c(this,tI).set([B,p,n,l,o,a],6),!this.isEmpty()):(c(this,tI).set([B,p,n,l,o,a],6),Math.abs(Math.atan2(p-l,B-n)-Math.atan2(G,w))<Math.PI/2?([n,l,o,a]=c(this,tI).subarray(2,6),c(this,zn).push(NaN,NaN,NaN,NaN,((n+o)/2-e)/i,((l+a)/2-t)/A),[n,l,B,p]=c(this,tI).subarray(14,18),c(this,LA).push(NaN,NaN,NaN,NaN,((B+n)/2-e)/i,((p+l)/2-t)/A),!0):([B,p,n,l,o,a]=c(this,tI).subarray(0,6),c(this,zn).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+o)/6-e)/i,((5*l+a)/6-t)/A,((n+o)/2-e)/i,((l+a)/2-t)/A),[o,a,n,l,B,p]=c(this,tI).subarray(12,18),c(this,LA).push(((B+5*n)/6-e)/i,((p+5*l)/6-t)/A,((5*n+o)/6-e)/i,((5*l+a)/6-t)/A,((n+o)/2-e)/i,((l+a)/2-t)/A),!0))}toSVGPath(){if(this.isEmpty())return"";const g=c(this,zn),I=c(this,LA);if(isNaN(c(this,tI)[6])&&!this.isEmpty())return f(this,ge,ZT).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,ge,wT).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,ge,GT).call(this,e),e.join(" ")}newFreeDrawOutline(g,I,e,t,i,A){return new _S(g,I,e,t,i,A)}getOutlines(){var d;const g=c(this,zn),I=c(this,LA),e=c(this,tI),[t,i,A,n]=c(this,Zi),l=new Float32Array((((d=c(this,So))==null?void 0:d.length)??0)+2);for(let m=0,u=l.length-2;m<u;m+=2)l[m]=(c(this,So)[m]-t)/A,l[m+1]=(c(this,So)[m+1]-i)/n;if(l[l.length-2]=(c(this,Pd)-t)/A,l[l.length-1]=(c(this,_d)-i)/n,isNaN(e[6])&&!this.isEmpty())return f(this,ge,WT).call(this,l);const o=new Float32Array(c(this,zn).length+24+c(this,LA).length);let a=g.length;for(let m=0;m<a;m+=2){if(isNaN(g[m])){o[m]=o[m+1]=NaN;continue}o[m]=g[m],o[m+1]=g[m+1]}a=f(this,ge,pT).call(this,o,a);for(let m=I.length-6;m>=6;m-=6)for(let u=0;u<6;u+=2){if(isNaN(I[m+u])){o[a]=o[a+1]=NaN,a+=2;continue}o[a]=I[m+u],o[a+1]=I[m+u+1],a+=2}return f(this,ge,BT).call(this,o,a),this.newFreeDrawOutline(o,l,c(this,Zi),c(this,Jm),c(this,Fm),c(this,zm))}};Zi=new WeakMap,LA=new WeakMap,Fm=new WeakMap,zm=new WeakMap,zn=new WeakMap,tI=new WeakMap,Pd=new WeakMap,_d=new WeakMap,AZ=new WeakMap,nZ=new WeakMap,Jm=new WeakMap,Lm=new WeakMap,So=new WeakMap,lZ=new WeakMap,xB=new WeakMap,OB=new WeakMap,ge=new WeakSet,qZ=function(){const g=c(this,tI).subarray(4,6),I=c(this,tI).subarray(16,18),[e,t,i,A]=c(this,Zi);return[(c(this,Pd)+(g[0]-I[0])/2-e)/i,(c(this,_d)+(g[1]-I[1])/2-t)/A,(c(this,Pd)+(I[0]-g[0])/2-e)/i,(c(this,_d)+(I[1]-g[1])/2-t)/A]},ZT=function(){const[g,I,e,t]=c(this,Zi),[i,A,n,l]=f(this,ge,qZ).call(this);return`M${(c(this,tI)[2]-g)/e} ${(c(this,tI)[3]-I)/t} L${(c(this,tI)[4]-g)/e} ${(c(this,tI)[5]-I)/t} L${i} ${A} L${n} ${l} L${(c(this,tI)[16]-g)/e} ${(c(this,tI)[17]-I)/t} L${(c(this,tI)[14]-g)/e} ${(c(this,tI)[15]-I)/t} Z`},GT=function(g){const I=c(this,LA);g.push(`L${I[4]} ${I[5]} Z`)},wT=function(g){const[I,e,t,i]=c(this,Zi),A=c(this,tI).subarray(4,6),n=c(this,tI).subarray(16,18),[l,o,a,d]=f(this,ge,qZ).call(this);g.push(`L${(A[0]-I)/t} ${(A[1]-e)/i} L${l} ${o} L${a} ${d} L${(n[0]-I)/t} ${(n[1]-e)/i}`)},WT=function(g){const I=c(this,tI),[e,t,i,A]=c(this,Zi),[n,l,o,a]=f(this,ge,qZ).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,o,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,Zi),c(this,Jm),c(this,Fm),c(this,zm))},BT=function(g,I){const e=c(this,LA);return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],I),I+=6},pT=function(g,I){const e=c(this,tI).subarray(4,6),t=c(this,tI).subarray(16,18),[i,A,n,l]=c(this,Zi),[o,a,d,m]=f(this,ge,qZ).call(this);return g.set([NaN,NaN,NaN,NaN,(e[0]-i)/n,(e[1]-A)/l,NaN,NaN,NaN,NaN,o,a,NaN,NaN,NaN,NaN,d,m,NaN,NaN,NaN,NaN,(t[0]-i)/n,(t[1]-A)/l],I),I+=24},X(Ql,lZ,8),X(Ql,xB,2),X(Ql,OB,c(Ql,lZ)+c(Ql,xB));let zw=Ql;class _S extends Gg{constructor(I,e,t,i,A,n){super();X(this,QB);X(this,Tm);X(this,$d,new Float32Array(4));X(this,Ul);X(this,sZ);X(this,Gi);X(this,oZ);X(this,HC);V(this,HC,I),V(this,Gi,e),V(this,Tm,t),V(this,oZ,i),V(this,Ul,A),V(this,sZ,n),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],f(this,QB,yT).call(this,n);const[l,o,a,d]=c(this,$d);for(let m=0,u=I.length;m<u;m+=2)I[m]=(I[m]-l)/a,I[m+1]=(I[m+1]-o)/d;for(let m=0,u=e.length;m<u;m+=2)e[m]=(e[m]-l)/a,e[m+1]=(e[m+1]-o)/d}toSVGPath(){const I=[`M${c(this,HC)[4]} ${c(this,HC)[5]}`];for(let e=6,t=c(this,HC).length;e<t;e+=6){if(isNaN(c(this,HC)[e])){I.push(`L${c(this,HC)[e+4]} ${c(this,HC)[e+5]}`);continue}I.push(`C${c(this,HC)[e]} ${c(this,HC)[e+1]} ${c(this,HC)[e+2]} ${c(this,HC)[e+3]} ${c(this,HC)[e+4]} ${c(this,HC)[e+5]}`)}return I.push("Z"),I.join(" ")}serialize([I,e,t,i],A){const n=t-I,l=i-e;let o,a;switch(A){case 0:o=Gg._rescale(c(this,HC),I,i,n,-l),a=Gg._rescale(c(this,Gi),I,i,n,-l);break;case 90:o=Gg._rescaleAndSwap(c(this,HC),I,e,n,l),a=Gg._rescaleAndSwap(c(this,Gi),I,e,n,l);break;case 180:o=Gg._rescale(c(this,HC),t,e,-n,l),a=Gg._rescale(c(this,Gi),t,e,-n,l);break;case 270:o=Gg._rescaleAndSwap(c(this,HC),t,i,-n,-l),a=Gg._rescaleAndSwap(c(this,Gi),t,i,-n,-l);break}return{outline:Array.from(o),points:[Array.from(a)]}}get box(){return c(this,$d)}newOutliner(I,e,t,i,A,n=0){return new zw(I,e,t,i,A,n)}getNewOutline(I,e){const[t,i,A,n]=c(this,$d),[l,o,a,d]=c(this,Tm),m=A*a,u=n*d,b=t*a+l,Z=i*d+o,w=this.newOutliner({x:c(this,Gi)[0]*m+b,y:c(this,Gi)[1]*u+Z},c(this,Tm),c(this,oZ),I,c(this,sZ),e??c(this,Ul));for(let G=2;G<c(this,Gi).length;G+=2)w.add({x:c(this,Gi)[G]*m+b,y:c(this,Gi)[G+1]*u+Z});return w.getOutlines()}}Tm=new WeakMap,$d=new WeakMap,Ul=new WeakMap,sZ=new WeakMap,Gi=new WeakMap,oZ=new WeakMap,HC=new WeakMap,QB=new WeakSet,yT=function(I){const e=c(this,HC);let t=e[4],i=e[5];const A=[t,i,t,i];let n=t,l=i,o=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?(o=w,a=G):a===G&&(o=d(o,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]?(o=m[2],a=m[3]):a===m[3]&&(o=d(o,m[2]))),t=w,i=G}const u=c(this,$d);u[0]=A[0]-c(this,Ul),u[1]=A[1]-c(this,Ul),u[2]=A[2]-A[0]+2*c(this,Ul),u[3]=A[3]-A[1]+2*c(this,Ul),this.firstPoint=[n,l],this.lastPoint=[o,a]};class nV{constructor(g,I=0,e=0,t=!0){X(this,ut);X(this,aZ);X(this,dZ);X(this,cZ);X(this,Ko,[]);X(this,TA,[]);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,Ko).push(D,J),Wg.rectBoundingBox(Y,R,y,M,i)}const l=i[2]-i[0]+2*e,o=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,Ko).at(t?-1:-2),Z=[b[0],b[2]];for(const w of c(this,Ko)){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)/o,w[2]=(p-d)/o}V(this,aZ,new Float32Array([a,d,l,o])),V(this,dZ,[m,u]),V(this,cZ,Z)}getOutlines(){c(this,Ko).sort((I,e)=>I[0]-e[0]||I[1]-e[1]||I[2]-e[2]);const g=[];for(const I of c(this,Ko))I[3]?(g.push(...f(this,ut,TR).call(this,I)),f(this,ut,VT).call(this,I)):(f(this,ut,NT).call(this,I),g.push(...f(this,ut,TR).call(this,I)));return f(this,ut,YT).call(this,g)}}aZ=new WeakMap,dZ=new WeakMap,cZ=new WeakMap,Ko=new WeakMap,TA=new WeakMap,ut=new WeakSet,YT=function(g){const I=[],e=new Set;for(const A of g){const[n,l,o]=A;I.push([n,l,A],[n,o,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],o=I[A+1][2];l.push(o),o.push(l),e.add(l),e.add(o)}const t=[];let i;for(;e.size>0;){const A=e.values().next().value;let[n,l,o,a,d]=A;e.delete(A);let m=n,u=l;for(i=[n,o],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,o,a,d]=b,m!==n&&(i.push(m,u,n,u===l?l:o),m=n),u=u===l?o:l}i.push(m,u)}return new wjg(t,c(this,aZ),c(this,dZ),c(this,cZ))},iy=function(g){const I=c(this,TA);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},VT=function([,g,I]){const e=f(this,ut,iy).call(this,g);c(this,TA).splice(e,0,[g,I])},NT=function([,g,I]){const e=f(this,ut,iy).call(this,g);for(let t=e;t<c(this,TA).length;t++){const[i,A]=c(this,TA)[t];if(i!==g)break;if(i===g&&A===I){c(this,TA).splice(t,1);return}}for(let t=e-1;t>=0;t--){const[i,A]=c(this,TA)[t];if(i!==g)break;if(i===g&&A===I){c(this,TA).splice(t,1);return}}},TR=function(g){const[I,e,t]=g,i=[[I,e,t]],A=f(this,ut,iy).call(this,t);for(let n=0;n<A;n++){const[l,o]=c(this,TA)[n];for(let a=0,d=i.length;a<d;a++){const[,m,u]=i[a];if(!(o<=m||u<=l)){if(m>=l){if(u>o)i[a][1]=o;else{if(d===1)return[];i.splice(a,1),a--,d--}continue}i[a][2]=l,u>o&&i.push([I,o,u])}}}return i};class wjg extends Gg{constructor(I,e,t,i){super();X(this,rZ);X(this,vm);V(this,vm,I),V(this,rZ,e),this.firstPoint=t,this.lastPoint=i}toSVGPath(){const I=[];for(const e of c(this,vm)){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,o=i-e;for(const a of c(this,vm)){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]*o;n.push(d)}return n}get box(){return c(this,rZ)}get classNamesForOutlining(){return["highlightOutline"]}}rZ=new WeakMap,vm=new WeakMap;class lV extends zw{newFreeDrawOutline(g,I,e,t,i,A){return new Wjg(g,I,e,t,i,A)}}class Wjg extends _S{newOutliner(g,I,e,t,i,A=0){return new lV(g,I,e,t,i,A)}}const ZI=class ZI extends EI{constructor(I){super({...I,name:"highlightEditor"});X(this,_g);X(this,jm,null);X(this,mZ,0);X(this,El);X(this,qd,null);X(this,uZ,null);X(this,xt,null);X(this,hZ,null);X(this,bZ,0);X(this,gc,null);X(this,wi,null);X(this,Wi,null);X(this,Re,!1);X(this,xm,null);X(this,Om,null);X(this,Ue,null);X(this,Qm,"");X(this,iA);X(this,ZZ,"");this.color=I.color||ZI._defaultColor,V(this,iA,I.thickness||ZI._defaultThickness),this.opacity=I.opacity||ZI._defaultOpacity,V(this,El,I.boxes||null),V(this,ZZ,I.methodOfCreation||""),V(this,Qm,I.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",I.highlightId>-1?(V(this,Re,!0),f(this,_g,Ay).call(this,I),f(this,_g,yc).call(this)):c(this,El)&&(V(this,jm,I.anchorNode),V(this,mZ,I.anchorOffset),V(this,hZ,I.focusNode),V(this,bZ,I.focusOffset),f(this,_g,vR).call(this),f(this,_g,yc).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const I=ZI.prototype;return Tg(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,Re)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:c(this,iA),methodOfCreation:c(this,ZZ)}}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;EI.initialize(I,e),ZI._defaultColor||(ZI._defaultColor=((t=e.highlightColors)==null?void 0:t.values().next().value)||"#fff066")}static updateDefaultParams(I,e){switch(I){case aI.HIGHLIGHT_COLOR:ZI._defaultColor=e;break;case aI.HIGHLIGHT_THICKNESS:ZI._defaultThickness=e;break}}translateInPage(I,e){}get toolbarPosition(){return c(this,Om)}get commentButtonPosition(){return c(this,xm)}updateParams(I,e){switch(I){case aI.HIGHLIGHT_COLOR:f(this,_g,MT).call(this,e);break;case aI.HIGHLIGHT_THICKNESS:f(this,_g,RT).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[aI.HIGHLIGHT_COLOR,ZI._defaultColor],[aI.HIGHLIGHT_THICKNESS,ZI._defaultThickness]]}get propertiesToUpdate(){return[[aI.HIGHLIGHT_COLOR,this.color||ZI._defaultColor],[aI.HIGHLIGHT_THICKNESS,c(this,iA)||ZI._defaultThickness],[aI.HIGHLIGHT_FREE,c(this,Re)]]}onUpdatedColor(){var I,e;(I=this.parent)==null||I.drawLayer.updateProperties(c(this,Wi),{root:{fill:this.color,"fill-opacity":this.opacity}}),(e=c(this,uZ))==null||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",V(this,uZ,new Sw({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,_g,ly).call(this))}getBaseTranslation(){return[0,0]}getRect(I,e){return super.getRect(I,e,f(this,_g,ly).call(this))}onceAdded(I){this.annotationElementId||this.parent.addUndoableEditor(this),I&&this.div.focus()}remove(){f(this,_g,jR).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,_g,yc).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?f(this,_g,jR).call(this):I&&(f(this,_g,yc).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,Re)?(I=(I-this.rotation+360)%360,t=f(i=ZI,AA,Xu).call(i,c(this,wi).box,I)):t=f(A=ZI,AA,Xu).call(A,[this.x,this.y,this.width,this.height],I),e.updateProperties(c(this,Wi),{bbox:t,root:{"data-main-rotation":I}}),e.updateProperties(c(this,Ue),{bbox:f(n=ZI,AA,Xu).call(n,c(this,xt).box,I),root:{"data-main-rotation":I}})}render(){if(this.div)return this.div;const I=super.render();c(this,Qm)&&(I.setAttribute("aria-label",c(this,Qm)),I.setAttribute("role","mark")),c(this,Re)?I.classList.add("free"):this.div.addEventListener("keydown",f(this,_g,HT).bind(this),{signal:this._uiManager._signal});const e=V(this,gc,document.createElement("div"));return I.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=c(this,qd),this.setDims(),aS(this,c(this,gc),["pointerover","pointerleave"]),this.enableEditing(),I}pointerover(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{hovered:!0}})}pointerleave(){var I;this.isSelected||(I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{hovered:!1}})}_moveCaret(I){switch(this.parent.unselect(this),I){case 0:case 2:f(this,_g,ny).call(this,!0);break;case 1:case 3:f(this,_g,ny).call(this,!1);break}}select(){var I;super.select(),c(this,Ue)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var I;super.unselect(),c(this,Ue)&&((I=this.parent)==null||I.drawLayer.updateProperties(c(this,Ue),{rootClass:{selected:!1}}),c(this,Re)||f(this,_g,ny).call(this,!1))}get _mustFixPosition(){return!c(this,Re)}show(I=this._isVisible){super.show(I),this.parent&&(this.parent.drawLayer.updateProperties(c(this,Wi),{rootClass:{hidden:!I}}),this.parent.drawLayer.updateProperties(c(this,Ue),{rootClass:{hidden:!I}}))}static startHighlighting(I,e,{target:t,x:i,y:A}){const{x:n,y:l,width:o,height:a}=t.getBoundingClientRect(),d=new AbortController,m=I.combinedSignal(d),u=b=>{d.abort(),f(this,AA,KT).call(this,I,b)};window.addEventListener("blur",u,{signal:m}),window.addEventListener("pointerup",u,{signal:m}),window.addEventListener("pointerdown",bC,{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",Si,{signal:m}),t.addEventListener("pointermove",f(this,AA,ST).bind(this,I),{signal:m}),this._freeHighlight=new lV({x:i,y:A},[n,l,o,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 ES){const{data:{quadPoints:p,rect:Y,rotation:y,id:R,color:M,opacity:D,popupRef:J,richText:H,contentsObj:F,creationDate:T,modificationDate:E},parent:{page:{pageNumber:q}}}=I;i=I={annotationType:jg.HIGHLIGHT,color:Array.from(M),opacity:D,quadPoints:p,boxes:null,pageIndex:q-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(F==null?void 0:F.str)||null,creationDate:T,modificationDate:E}}else if(I instanceof tV){const{data:{inkLists:p,rect:Y,rotation:y,id:R,color:M,borderStyle:{rawWidth:D},popupRef:J,richText:H,contentsObj:F,creationDate:T,modificationDate:E},parent:{page:{pageNumber:q}}}=I;i=I={annotationType:jg.HIGHLIGHT,color:Array.from(M),thickness:D,inkLists:p,boxes:null,pageIndex:q-1,rect:Y.slice(0),rotation:y,annotationElementId:R,id:R,deleted:!1,popupRef:J,richText:H,comment:(F==null?void 0:F.str)||null,creationDate:T,modificationDate:E}}const{color:A,quadPoints:n,inkLists:l,opacity:o}=I,a=await super.deserialize(I,e,t);a.color=Wg.makeHexColor(...A),a.opacity=o||1,l&&V(a,iA,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,El,[]);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,_g,vR).call(Z),f(w=a,_g,yc).call(w),a.rotate(a.rotation)}else if(l){V(a,Re,!0);const p=l[0],Y={x:p[0]-u,y:m-(p[1]-b)},y=new lV(Y,[0,0,d,m],1,c(a,iA)/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,_g,Ay).call(G,{highlightOutlines:y.getOutlines(),highlightId:R,clipPathId:M}),f(B=a,_g,yc).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=EI._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),t=super.serialize(I);return Object.assign(t,{color:e,opacity:this.opacity,thickness:c(this,iA),quadPoints:f(this,_g,fT).call(this),outlines:f(this,_g,DT).call(this,t.rect)}),this.addComment(t),this.annotationElementId&&!f(this,_g,kT).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}};jm=new WeakMap,mZ=new WeakMap,El=new WeakMap,qd=new WeakMap,uZ=new WeakMap,xt=new WeakMap,hZ=new WeakMap,bZ=new WeakMap,gc=new WeakMap,wi=new WeakMap,Wi=new WeakMap,Re=new WeakMap,xm=new WeakMap,Om=new WeakMap,Ue=new WeakMap,Qm=new WeakMap,iA=new WeakMap,ZZ=new WeakMap,_g=new WeakSet,vR=function(){const I=new nV(c(this,El),.001);V(this,wi,I.getOutlines()),[this.x,this.y,this.width,this.height]=c(this,wi).box;const e=new nV(c(this,El),.0025,.001,this._uiManager.direction==="ltr");V(this,xt,e.getOutlines());const{firstPoint:t}=c(this,wi);V(this,xm,[(t[0]-this.x)/this.width,(t[1]-this.y)/this.height]);const{lastPoint:i}=c(this,xt);V(this,Om,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Ay=function({highlightOutlines:I,highlightId:e,clipPathId:t}){var m,u;if(V(this,wi,I),V(this,xt,I.getNewOutline(c(this,iA)/2+1.5,.0025)),e>=0)V(this,Wi,e),V(this,qd,t),this.parent.drawLayer.finalizeDraw(e,{bbox:I.box,path:{d:I.toSVGPath()}}),V(this,Ue,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:c(this,xt).box,path:{d:c(this,xt).toSVGPath()}},!0));else if(this.parent){const b=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(c(this,Wi),{bbox:f(m=ZI,AA,Xu).call(m,c(this,wi).box,(b-this.rotation+360)%360),path:{d:I.toSVGPath()}}),this.parent.drawLayer.updateProperties(c(this,Ue),{bbox:f(u=ZI,AA,Xu).call(u,c(this,xt).box,b),path:{d:c(this,xt).toSVGPath()}})}const[A,n,l,o]=I.box;switch(this.rotation){case 0:this.x=A,this.y=n,this.width=l,this.height=o;break;case 90:{const[b,Z]=this.parentDimensions;this.x=n,this.y=1-A,this.width=l*Z/b,this.height=o*b/Z;break}case 180:this.x=1-A,this.y=1-n,this.width=l,this.height=o;break;case 270:{const[b,Z]=this.parentDimensions;this.x=1-n,this.y=A,this.width=l*Z/b,this.height=o*b/Z;break}}const{firstPoint:a}=I;V(this,xm,[(a[0]-A)/l,(a[1]-n)/o]);const{lastPoint:d}=c(this,xt);V(this,Om,[(d[0]-A)/l,(d[1]-n)/o])},MT=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,ZI._defaultOpacity),undo:e.bind(this,t,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:aI.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(I)},!0)},RT=function(I){const e=c(this,iA),t=i=>{V(this,iA,i),f(this,_g,XT).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:aI.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:I},!0)},XT=function(I){c(this,Re)&&(f(this,_g,Ay).call(this,{highlightOutlines:c(this,wi).getNewOutline(I/2)}),this.fixAndSetPosition(),this.setDims())},jR=function(){c(this,Wi)===null||!this.parent||(this.parent.drawLayer.remove(c(this,Wi)),V(this,Wi,null),this.parent.drawLayer.remove(c(this,Ue)),V(this,Ue,null))},yc=function(I=this.parent){c(this,Wi)===null&&({id:te(this,Wi)._,clipPathId:te(this,qd)._}=I.drawLayer.draw({bbox:c(this,wi).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:c(this,Re)},path:{d:c(this,wi).toSVGPath()}},!1,!0),V(this,Ue,I.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:c(this,Re)},bbox:c(this,xt).box,path:{d:c(this,xt).toSVGPath()}},c(this,Re))),c(this,gc)&&(c(this,gc).style.clipPath=c(this,qd)))},AA=new WeakSet,Xu=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]},HT=function(I){ZI._keyboardManager.exec(this,I)},ny=function(I){if(!c(this,jm))return;const e=window.getSelection();I?e.setPosition(c(this,jm),c(this,mZ)):e.setPosition(c(this,hZ),c(this,bZ))},ly=function(){return c(this,Re)?this.rotation:0},fT=function(){if(c(this,Re))return null;const[I,e]=this.pageDimensions,[t,i]=this.pageTranslation,A=c(this,El),n=new Float32Array(A.length*8);let l=0;for(const{x:o,y:a,width:d,height:m}of A){const u=o*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},DT=function(I){return c(this,wi).serialize(I,f(this,_g,ly).call(this))},ST=function(I,e){this._freeHighlight.add(e)&&I.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},KT=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=""},kT=function(I){const{color:e}=this._initialData;return this.hasEditedComment||I.color.some((t,i)=>t!==e[i])},X(ZI,AA),sg(ZI,"_defaultColor",null),sg(ZI,"_defaultOpacity",1),sg(ZI,"_defaultThickness",12),sg(ZI,"_type","highlight"),sg(ZI,"_editorType",jg.HIGHLIGHT),sg(ZI,"_freeHighlightId",-1),sg(ZI,"_freeHighlight",null),sg(ZI,"_freeHighlightClipId","");let Jw=ZI;class $S{constructor(){X(this,Ic,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,Ic)[g]=I}toSVGProperties(){const g=c(this,Ic);return V(this,Ic,Object.create(null)),{root:g}}reset(){V(this,Ic,Object.create(null))}updateAll(g=this){this.updateProperties(g)}clone(){JI("Not implemented")}}Ic=new WeakMap;const lI=class lI extends EI{constructor(I){super(I);X(this,hI);X(this,Bi,null);X(this,Um);sg(this,"_colorPicker",null);sg(this,"_drawId",null);V(this,Um,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,hI,xR).call(this,I),f(this,hI,gG).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){JI("Not implemented")}static get typesMap(){JI("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(lI,ce).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 o=c(this,Bi).updateProperty(e,l);o&&f(this,hI,IG).call(this,o),(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,lI._mergeSVGProperties(c(this,Bi).getPathResizingSVGProperties(f(this,hI,sy).call(this)),{bbox:f(this,hI,Hu).call(this)}))}_onResized(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,lI._mergeSVGProperties(c(this,Bi).getPathResizedSVGProperties(f(this,hI,sy).call(this)),{bbox:f(this,hI,Hu).call(this)}))}_onTranslating(I,e){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{bbox:f(this,hI,Hu).call(this)})}_onTranslated(){var I;(I=this.parent)==null||I.drawLayer.updateProperties(this._drawId,lI._mergeSVGProperties(c(this,Bi).getPathTranslatedSVGProperties(f(this,hI,sy).call(this),this.parentDimensions),{bbox:f(this,hI,Hu).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,Um)&&(V(this,Um,!1),this.commit(),this.parent.setSelected(this),I&&this.isOnScreen&&this.div.focus())}remove(){f(this,hI,QR).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(this,hI,gG).call(this),f(this,hI,IG).call(this,c(this,Bi).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(I){var t;let e=!1;this.parent&&!I?(this._uiManager.removeShouldRescale(this),f(this,hI,QR).call(this)):I&&(this._uiManager.addShouldRescale(this),f(this,hI,gG).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,lI._mergeSVGProperties({bbox:f(this,hI,Hu).call(this)},c(this,Bi).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&f(this,hI,IG).call(this,c(this,Bi).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){JI("Not implemented")}static startDrawing(I,e,t,i){var w;const{target:A,offsetX:n,offsetY:l,pointerId:o,pointerType:a}=i;if(Je.isInitializedAndDifferentPointerType(a))return;const{viewport:{rotation:d}}=I,{width:m,height:u}=A.getBoundingClientRect(),b=V(lI,Cc,new AbortController),Z=I.combinedSignal(b);if(Je.setPointer(a,o),window.addEventListener("pointerup",G=>{Je.isSamePointerIdOrRemove(G.pointerId)&&this._endDraw(G)},{signal:Z}),window.addEventListener("pointercancel",G=>{Je.isSamePointerIdOrRemove(G.pointerId)&&this._currentParent.endDrawingSession()},{signal:Z}),window.addEventListener("pointerdown",G=>{Je.isSamePointerType(G.pointerType)&&(Je.initializeAndAddPointerId(G.pointerId),c(lI,ce).isCancellable()&&(c(lI,ce).removeLastElement(),c(lI,ce).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:Z}),window.addEventListener("contextmenu",Si,{signal:Z}),A.addEventListener("pointermove",this._drawMove.bind(this),{signal:Z}),A.addEventListener("touchmove",G=>{Je.isSameTimeStamp(G.timeStamp)&&bC(G)},{signal:Z}),I.toggleDrawing(),(w=e._editorUndoBar)==null||w.hide(),c(lI,ce)){I.drawLayer.updateProperties(this._currentDrawId,c(lI,ce).startNew(n,l,m,u,d));return}e.updateUIForDefaultProperties(this),V(lI,ce,this.createDrawerInstance(n,l,m,u,d)),V(lI,ec,this.getDefaultDrawingOptions()),this._currentParent=I,{id:this._currentDrawId}=I.drawLayer.draw(this._mergeSVGProperties(c(lI,ec).toSVGProperties(),c(lI,ce).defaultSVGProperties),!0,!1)}static _drawMove(I){if(Je.isSameTimeStamp(I.timeStamp),!c(lI,ce))return;const{offsetX:e,offsetY:t,pointerId:i}=I;if(Je.isSamePointerId(i)){if(Je.isUsingMultiplePointers()){this._endDraw(I);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,c(lI,ce).add(e,t)),Je.setTimeStamp(I.timeStamp),bC(I)}}static _cleanup(I){I&&(this._currentDrawId=-1,this._currentParent=null,V(lI,ce,null),V(lI,ec,null),Je.clearPointerType(),Je.clearTimeStamp()),c(lI,Cc)&&(c(lI,Cc).abort(),V(lI,Cc,null),Je.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(lI,ce).end(I.offsetX,I.offsetY)),this.supportMultipleDrawings){const t=c(lI,ce),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:aI.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(I){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(aI.DRAW_STEP),!c(lI,ce).isEmpty()){const{pageDimensions:[t,i],scale:A}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:c(lI,ce).getOutlines(t*A,i*A,A,this._INNER_MARGIN),drawingOptions:c(lI,ec),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){JI("Not implemented")}static async deserialize(I,e,t){var d,m;const{rawDims:{pageWidth:i,pageHeight:A,pageX:n,pageY:l}}=e.viewport,o=this.deserializeDraw(n,l,i,A,this._INNER_MARGIN,I),a=await super.deserialize(I,e,t);return a.createDrawingOptions(I),f(d=a,hI,xR).call(d,{drawOutlines:o}),f(m=a,hI,gG).call(m),a.onScaleChanging(),a.rotate(),a}serializeDraw(I){const[e,t]=this.pageTranslation,[i,A]=this.pageDimensions;return c(this,Bi).serialize([e,t,i,A],I)}renderAnnotationElement(I){return I.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Bi=new WeakMap,Um=new WeakMap,ce=new WeakMap,Cc=new WeakMap,ec=new WeakMap,hI=new WeakSet,xR=function({drawOutlines:I,drawId:e,drawingOptions:t}){V(this,Bi,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,hI,OR).call(this,I,this.parent),f(this,hI,IG).call(this,I.box)},OR=function(I,e){const{id:t}=e.drawLayer.draw(lI._mergeSVGProperties(this._drawingOptions.toSVGProperties(),I.defaultSVGProperties),!1,!1);return t},QR=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},gG=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,hI,OR).call(this,c(this,Bi),I)}},FT=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]}},sy=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]}},IG=function(I){[this.x,this.y,this.width,this.height]=f(this,hI,FT).call(this,I),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Hu=function(){const{x:I,y:e,width:t,height:i,rotation:A,parentRotation:n,parentDimensions:[l,o]}=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/o),i*(o/l),t*(l/o)];case 5:return[1-e,I,t*(l/o),i*(o/l)];case 6:return[1-I-i*(o/l),1-e,i*(o/l),t*(l/o)];case 7:return[e-t*(l/o),1-I-i*(o/l),t*(l/o),i*(o/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*(o/l),e,i*(o/l),t*(l/o)];case 13:return[1-e-t*(l/o),I-i*(o/l),t*(l/o),i*(o/l)];case 14:return[1-I,1-e-t*(l/o),i*(o/l),t*(l/o)];case 15:return[e,1-I,t*(l/o),i*(o/l)];default:return[I,e,t,i]}},sg(lI,"_currentDrawId",-1),sg(lI,"_currentParent",null),X(lI,ce,null),X(lI,Cc,null),X(lI,ec,null),sg(lI,"_INNER_MARGIN",3);let Lw=lI;class Bjg{constructor(g,I,e,t,i,A){X(this,Pm);X(this,Jn,new Float64Array(6));X(this,re);X(this,me);X(this,tc);X(this,Em);X(this,ht);X(this,Xe,"");X(this,nA,0);X(this,ic,new kh);X(this,Ac);X(this,nc);V(this,Ac,e),V(this,nc,t),V(this,tc,i),V(this,Em,A),[g,I]=f(this,Pm,oy).call(this,g,I);const n=V(this,re,[NaN,NaN,NaN,NaN,g,I]);V(this,ht,[g,I]),V(this,me,[{line:n,points:c(this,ht)}]),c(this,Jn).set(n,0)}updateProperty(g,I){g==="stroke-width"&&V(this,Em,I)}isEmpty(){return!c(this,me)||c(this,me).length===0}isCancellable(){return c(this,ht).length<=10}add(g,I){[g,I]=f(this,Pm,oy).call(this,g,I);const[e,t,i,A]=c(this,Jn).subarray(2,6),n=g-i,l=I-A;return Math.hypot(c(this,Ac)*n,c(this,nc)*l)<=2?null:(c(this,ht).push(g,I),isNaN(e)?(c(this,Jn).set([i,A,g,I],2),c(this,re).push(NaN,NaN,NaN,NaN,g,I),{path:{d:this.toSVGPath()}}):(isNaN(c(this,Jn)[0])&&c(this,re).splice(6,6),c(this,Jn).set([e,t,i,A,g,I],0),c(this,re).push(...Gg.createBezierPoints(e,t,i,A,g,I)),{path:{d:this.toSVGPath()}}))}end(g,I){const e=this.add(g,I);return e||(c(this,ht).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(g,I,e,t,i){V(this,Ac,e),V(this,nc,t),V(this,tc,i),[g,I]=f(this,Pm,oy).call(this,g,I);const A=V(this,re,[NaN,NaN,NaN,NaN,g,I]);V(this,ht,[g,I]);const n=c(this,me).at(-1);return n&&(n.line=new Float32Array(n.line),n.points=new Float32Array(n.points)),c(this,me).push({line:A,points:c(this,ht)}),c(this,Jn).set(A,0),V(this,nA,0),this.toSVGPath(),null}getLastElement(){return c(this,me).at(-1)}setLastElement(g){return c(this,me)?(c(this,me).push(g),V(this,re,g.line),V(this,ht,g.points),V(this,nA,0),{path:{d:this.toSVGPath()}}):c(this,ic).setLastElement(g)}removeLastElement(){if(!c(this,me))return c(this,ic).removeLastElement();c(this,me).pop(),V(this,Xe,"");for(let g=0,I=c(this,me).length;g<I;g++){const{line:e,points:t}=c(this,me)[g];V(this,re,e),V(this,ht,t),V(this,nA,0),this.toSVGPath()}return{path:{d:c(this,Xe)}}}toSVGPath(){const g=Gg.svgRound(c(this,re)[4]),I=Gg.svgRound(c(this,re)[5]);if(c(this,ht).length===2)return V(this,Xe,`${c(this,Xe)} M ${g} ${I} Z`),c(this,Xe);if(c(this,ht).length<=6){const t=c(this,Xe).lastIndexOf("M");V(this,Xe,`${c(this,Xe).slice(0,t)} M ${g} ${I}`),V(this,nA,6)}if(c(this,ht).length===4){const t=Gg.svgRound(c(this,re)[10]),i=Gg.svgRound(c(this,re)[11]);return V(this,Xe,`${c(this,Xe)} L ${t} ${i}`),V(this,nA,12),c(this,Xe)}const e=[];c(this,nA)===0&&(e.push(`M ${g} ${I}`),V(this,nA,6));for(let t=c(this,nA),i=c(this,re).length;t<i;t+=6){const[A,n,l,o,a,d]=c(this,re).slice(t,t+6).map(Gg.svgRound);e.push(`C${A} ${n} ${l} ${o} ${a} ${d}`)}return V(this,Xe,c(this,Xe)+e.join(" ")),V(this,nA,c(this,re).length),c(this,Xe)}getOutlines(g,I,e,t){const i=c(this,me).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),c(this,ic).build(c(this,me),g,I,e,c(this,tc),c(this,Em),t),V(this,Jn,null),V(this,re,null),V(this,me,null),V(this,Xe,null),c(this,ic)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Jn=new WeakMap,re=new WeakMap,me=new WeakMap,tc=new WeakMap,Em=new WeakMap,ht=new WeakMap,Xe=new WeakMap,nA=new WeakMap,ic=new WeakMap,Ac=new WeakMap,nc=new WeakMap,Pm=new WeakSet,oy=function(g,I){return Gg._normalizePoint(g,I,c(this,Ac),c(this,nc),c(this,tc))};class kh extends Gg{constructor(){super(...arguments);X(this,He);X(this,bt);X(this,GZ,0);X(this,wZ);X(this,pi);X(this,Ln);X(this,Tn);X(this,_m);X(this,$m);X(this,lc)}build(I,e,t,i,A,n,l){V(this,Ln,e),V(this,Tn,t),V(this,_m,i),V(this,$m,A),V(this,lc,n),V(this,wZ,l??0),V(this,pi,I),f(this,He,JT).call(this)}get thickness(){return c(this,lc)}setLastElement(I){return c(this,pi).push(I),{path:{d:this.toSVGPath()}}}removeLastElement(){return c(this,pi).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const I=[];for(const{line:e}of c(this,pi)){if(I.push(`M${Gg.svgRound(e[4])} ${Gg.svgRound(e[5])}`),e.length===6){I.push("Z");continue}if(e.length===12&&isNaN(e[6])){I.push(`L${Gg.svgRound(e[10])} ${Gg.svgRound(e[11])}`);continue}for(let t=6,i=e.length;t<i;t+=6){const[A,n,l,o,a,d]=e.subarray(t,t+6).map(Gg.svgRound);I.push(`C${A} ${n} ${l} ${o} ${a} ${d}`)}}return I.join("")}serialize([I,e,t,i],A){const n=[],l=[],[o,a,d,m]=f(this,He,zT).call(this);let u,b,Z,w,G,B,p,Y,y;switch(c(this,$m)){case 0:y=Gg._rescale,u=I,b=e+i,Z=t,w=-i,G=I+o*t,B=e+(1-a-m)*i,p=I+(o+d)*t,Y=e+(1-a)*i;break;case 90:y=Gg._rescaleAndSwap,u=I,b=e,Z=t,w=i,G=I+a*t,B=e+o*i,p=I+(a+m)*t,Y=e+(o+d)*i;break;case 180:y=Gg._rescale,u=I+t,b=e,Z=-t,w=i,G=I+(1-o-d)*t,B=e+a*i,p=I+(1-o)*t,Y=e+(a+m)*i;break;case 270:y=Gg._rescaleAndSwap,u=I+t,b=e+i,Z=-t,w=-i,G=I+(1-a-m)*t,B=e+(1-o-d)*i,p=I+(1-a)*t,Y=e+(1-o)*i;break}for(const{line:R,points:M}of c(this,pi))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:o,thickness:a}){const d=[];let m,u,b,Z,w;switch(o){case 0:w=Gg._rescale,m=-I/t,u=e/i+1,b=1/t,Z=-1/i;break;case 90:w=Gg._rescaleAndSwap,m=-e/i,u=-I/t,b=1/i,Z=1/t;break;case 180:w=Gg._rescale,m=I/t+1,u=-e/i,b=-1/t,Z=1/i;break;case 270:w=Gg._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],F=B[J+1];Y.set(Gg.createBezierPoints(y,R,M,D,H,F),(J-2)*3),[y,R,M,D]=[M,D,H,F]}}}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,o,a,A),G}get box(){return c(this,bt)}updateProperty(I,e){return I==="stroke-width"?f(this,He,LT).call(this,e):null}updateParentDimensions([I,e],t){const[i,A]=f(this,He,ds).call(this);V(this,Ln,I),V(this,Tn,e),V(this,_m,t);const[n,l]=f(this,He,ds).call(this),o=n-i,a=l-A,d=c(this,bt);return d[0]-=o,d[1]-=a,d[2]+=2*o,d[3]+=2*a,d}updateRotation(I){return V(this,GZ,I),{path:{transform:this.rotationTransform}}}get viewBox(){return c(this,bt).map(Gg.svgRound).join(" ")}get defaultProperties(){const[I,e]=c(this,bt);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.svgRound(e)}`}}}get rotationTransform(){const[,,I,e]=c(this,bt);let t=0,i=0,A=0,n=0,l=0,o=0;switch(c(this,GZ)){case 90:i=e/I,A=-I/e,l=I;break;case 180:t=-1,n=-1,l=I,o=e;break;case 270:i=-e/I,A=I/e,o=e;break;default:return""}return`matrix(${t} ${i} ${A} ${n} ${Gg.svgRound(l)} ${Gg.svgRound(o)})`}getPathResizingSVGProperties([I,e,t,i]){const[A,n]=f(this,He,ds).call(this),[l,o,a,d]=c(this,bt);if(Math.abs(a-A)<=Gg.PRECISION||Math.abs(d-n)<=Gg.PRECISION){const w=I+t/2-(l+a/2),G=e+i/2-(o+d/2);return{path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.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":`${Gg.svgRound(l)} ${Gg.svgRound(o)}`,transform:`${this.rotationTransform} scale(${b} ${Z}) translate(${Gg.svgRound(A)} ${Gg.svgRound(n)}) scale(${m} ${u}) translate(${Gg.svgRound(-A)} ${Gg.svgRound(-n)})`}}}getPathResizedSVGProperties([I,e,t,i]){const[A,n]=f(this,He,ds).call(this),l=c(this,bt),[o,a,d,m]=l;if(l[0]=I,l[1]=e,l[2]=t,l[3]=i,Math.abs(d-A)<=Gg.PRECISION||Math.abs(m-n)<=Gg.PRECISION){const G=I+t/2-(o+d/2),B=e+i/2-(a+m/2);for(const{line:p,points:Y}of c(this,pi))Gg._translate(p,G,B,p),Gg._translate(Y,G,B,Y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.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*(o+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,pi))Gg._rescale(G,Z,w,u,b,G),Gg._rescale(B,Z,w,u,b,B);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gg.svgRound(I)} ${Gg.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([I,e],t){const[i,A]=t,n=c(this,bt),l=I-n[0],o=e-n[1];if(c(this,Ln)===i&&c(this,Tn)===A)for(const{line:a,points:d}of c(this,pi))Gg._translate(a,l,o,a),Gg._translate(d,l,o,d);else{const a=c(this,Ln)/i,d=c(this,Tn)/A;V(this,Ln,i),V(this,Tn,A);for(const{line:m,points:u}of c(this,pi))Gg._rescale(m,l,o,a,d,m),Gg._rescale(u,l,o,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":`${Gg.svgRound(I)} ${Gg.svgRound(e)}`}}}get defaultSVGProperties(){const I=c(this,bt);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Gg.svgRound(I[0])} ${Gg.svgRound(I[1])}`,transform:this.rotationTransform||null},bbox:I}}}bt=new WeakMap,GZ=new WeakMap,wZ=new WeakMap,pi=new WeakMap,Ln=new WeakMap,Tn=new WeakMap,_m=new WeakMap,$m=new WeakMap,lc=new WeakMap,He=new WeakSet,ds=function(I=c(this,lc)){const e=c(this,wZ)+I/2*c(this,_m);return c(this,$m)%180===0?[e/c(this,Ln),e/c(this,Tn)]:[e/c(this,Tn),e/c(this,Ln)]},zT=function(){const[I,e,t,i]=c(this,bt),[A,n]=f(this,He,ds).call(this,0);return[I+A,e+n,t-2*A,i-2*n]},JT=function(){const I=V(this,bt,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of c(this,pi)){if(i.length<=12){for(let l=4,o=i.length;l<o;l+=6)Wg.pointBoundingBox(i[l],i[l+1],I);continue}let A=i[4],n=i[5];for(let l=6,o=i.length;l<o;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,He,ds).call(this);I[0]=lt(I[0]-e,0,1),I[1]=lt(I[1]-t,0,1),I[2]=lt(I[2]+e,0,1),I[3]=lt(I[3]+t,0,1),I[2]-=I[0],I[3]-=I[1]},LT=function(I){const[e,t]=f(this,He,ds).call(this);V(this,lc,I);const[i,A]=f(this,He,ds).call(this),[n,l]=[i-e,A-t],o=c(this,bt);return o[0]-=n,o[1]-=l,o[2]+=2*n,o[3]+=2*l,o};class Tw extends $S{constructor(g){super(),this._viewParameters=g,super.updateProperties({fill:"none",stroke:EI._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 Tw(this._viewParameters);return g.updateAll(this),g}}const qm=class qm extends Lw{constructor(I){super({...I,name:"inkEditor"});X(this,UB);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(I,e){EI.initialize(I,e),this._defaultDrawingOptions=new Tw(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Tg(this,"typesMap",new Map([[aI.INK_THICKNESS,"stroke-width"],[aI.INK_COLOR,"stroke"],[aI.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(I,e,t,i,A){return new Bjg(I,e,t,i,A,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(I,e,t,i,A,n){return kh.deserialize(I,e,t,i,A,n)}static async deserialize(I,e,t){let i=null;if(I instanceof tV){const{data:{inkLists:n,rect:l,rotation:o,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:jg.INK,color:Array.from(d),thickness:u,opacity:m,paths:{points:n},boxes:null,pageIndex:p-1,rect:l.slice(0),rotation:o,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 Kw(this)),[["colorPicker",this._colorPicker]]}get colorType(){return aI.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:EI._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,UB,TT).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}};UB=new WeakSet,TT=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",jg.INK),sg(qm,"_defaultDrawingOptions",null);let sV=qm;class oV extends kh{toSVGPath(){let g=super.toSVGPath();return g.endsWith("Z")||(g+="Z"),g}}const vw=8,Fh=3;class Cl{static extractContoursFromText(g,{fontFamily:I,fontStyle:e,fontWeight:t},i,A,n,l){let o=new OffscreenCanvas(1,1),a=o.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);o=new OffscreenCanvas(y,R),a=o.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,wI,PR).call(this,a.getImageData(0,0,y,R).data),D=f(this,wI,QT).call(this,M),J=f(this,wI,_R).call(this,D),H=f(this,wI,ER).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,wI,UT).call(this,g),[o,a]=f(this,wI,OT).call(this,A,n,l,Math.hypot(n,l)*c(this,sc).sigmaSFactor,c(this,sc).sigmaR,c(this,sc).kernelSize),d=f(this,wI,_R).call(this,a),m=f(this,wI,ER).call(this,o,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:o,height:a}=g,d=g.thickness??0,m=[],u=Math.min(I/o,e/a),b=u/I,Z=u/e,w=[];for(const{points:B}of l){const p=A?f(this,wI,xT).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 F=4;F<Y;F+=2){const T=y[F]=p[F]*b,E=y[F+1]=p[F+1]*Z;R.set(Gg.createBezierPoints(M,D,J,H,T,E),(F-2)*3),[M,D,J,H]=[J,H,T,E]}}if(m.length===0)return null;const G=n?new oV:new kh;return G.build(m,I,e,1,t,n?0:d,i),{outline:G,newCurves:w,areContours:n,thickness:d,width:o,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 o;A>=-128&&n<=127?o=Int8Array:A>=-32768&&n<=32767?o=Int16Array:o=Int32Array;const a=g.length,d=vw+Fh*a,m=new Uint32Array(d);let u=0;m[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*a)*o.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++]=o.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=o.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 CS(B)}static async decompressSignature(g){try{const I=zTg(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),o=l[1];if(o!==0)throw new Error(`Invalid version: ${o}`);const a=l[2],d=l[3],m=l[4]===0,u=l[5],b=l[6],Z=l[7],w=[],G=(vw+Fh*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[Fh*p+vw],y=new Float32Array(Y+2);w.push(y);for(let R=0;R<Fh-1;R++)y[R]=l[Fh*p+vw+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 Lg(`decompressSignature: ${I}`),null}}}sc=new WeakMap,wI=new WeakSet,UR=function(g,I,e,t){return e-=g,t-=I,e===0?t>0?0:4:e===1?t+6:2-t},vA=new WeakMap,vT=function(g,I,e,t,i,A,n){const l=f(this,wI,UR).call(this,e,t,i,A);for(let o=0;o<8;o++){const a=(-o+l-n+16)%8,d=c(this,vA)[2*a],m=c(this,vA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},jT=function(g,I,e,t,i,A,n){const l=f(this,wI,UR).call(this,e,t,i,A);for(let o=0;o<8;o++){const a=(o+l+n+16)%8,d=c(this,vA)[2*a],m=c(this,vA)[2*a+1];if(g[(e+d)*I+(t+m)]!==0)return a}return-1},ER=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 o=[];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};o.push(B);let p;for(const F of o)if(F.id===l){p=F;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,wI,vT).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,vA)[2*Y],R=c(this,vA)[2*Y+1];const M=a+y,D=d+R;b=M,Z=D;let J=a,H=d;for(;;){const F=f(this,wI,jT).call(this,A,I,J,H,b,Z,1);y=c(this,vA)[2*F],R=c(this,vA)[2*F+1];const T=J+y,E=H+R;w.push(E,T);const q=J*I+H;if(A[q+1]===0?A[q]=-n:A[q]===1&&(A[q]=n),T===a&&E===d&&J===M&&H===D){A[m]!==1&&(l=Math.abs(A[m]));break}else b=J,Z=H,J=T,H=E}}}return o},ay=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,o=Math.hypot(n,l),a=n/o,d=l/o,m=a*A-d*i,u=l/n,b=1/o,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>(o*Y)**2?(f(this,wI,ay).call(this,g,I,R+2,t),f(this,wI,ay).call(this,g,R,e,t)):t.push(i,A)},xT=function(g){const I=[],e=g.length;return f(this,wI,ay).call(this,g,0,e,I),I.push(g[e-2],g[e-1]),I.length<=4?null:I},OT=function(g,I,e,t,i,A){const n=new Float32Array(A**2),l=-2*t**2,o=A>>1;for(let Z=0;Z<A;Z++){const w=(Z-o)**2;for(let G=0;G<A;G++)n[Z*A+G]=Math.exp((w+(G-o)**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-o;if(!(M<0||M>=e))for(let D=0;D<A;D++){const J=w+D-o;if(J<0||J>=I)continue;const H=g[M*I+J],F=n[R*A+D]*a[Math.abs(H-B)];p+=H*F,Y+=F}}const y=u[G]=Math.round(p/Y);b[y]++}return[u,b]},QT=function(g){const I=new Uint32Array(256);for(const e of g)I[e]++;return I},PR=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 o=e[n]=g[n<<2];t=Math.max(t,o),i=Math.min(i,o)}const A=255/(t-i);for(let n=0,l=e.length;n<l;n++)e[n]=(e[n]-i)*A;return e},_R=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},UT=function(g){const I=g,{width:e,height:t}=g,{maxDim:i}=c(this,sc);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 o=new OffscreenCanvas(A,n).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,A,n),o.filter="grayscale(1)",o.drawImage(g,0,0,g.width,g.height,0,0,A,n);const a=o.getImageData(0,0,A,n).data;return[f(this,wI,PR).call(this,a),A,n]},X(Cl,wI),X(Cl,sc,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),X(Cl,vA,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class aV extends $S{constructor(){super(),super.updateProperties({fill:EI._defaultLineColor,"stroke-width":0})}clone(){const g=new aV;return g.updateAll(this),g}}class dV extends Tw{constructor(g){super(g),super.updateProperties({stroke:EI._defaultLineColor,"stroke-width":1})}clone(){const g=new dV(this._viewParameters);return g.updateAll(this),g}}const yi=class yi extends Lw{constructor(I){super({...I,mustBeCommitted:!0,name:"signatureEditor"});X(this,ko,!1);X(this,vn,null);X(this,Fo,null);X(this,oc,null);this._willKeepAspectRatio=!0,V(this,Fo,I.signatureData||null),V(this,vn,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(I,e){EI.initialize(I,e),this._defaultDrawingOptions=new aV,this._defaultDrawnSignatureOptions=new dV(e.viewParameters)}static getDefaultDrawingOptions(I){const e=this._defaultDrawingOptions.clone();return e.updateProperties(I),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Tg(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!c(this,vn)}}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,Fo)){const{lines:i,mustSmooth:A,areContours:n,description:l,uuid:o,heightInPage:a}=c(this,Fo),{rawDims:{pageWidth:d,pageHeight:m},rotation:u}=this.parent.viewport,b=Cl.processDrawnLines({lines:i,pageWidth:d,pageHeight:m,rotation:u,innerMargin:yi._INNER_MARGIN,mustSmooth:A,areContours:n});this.addSignature(b,a,l,o)}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,vn)||""}));return t&&(this._isCopy=!0,this._moveAfterPaste(I,e)),this.div}setUuid(I){V(this,oc,I),this.addEditToolbar()}getUuid(){return c(this,oc)}get description(){return c(this,vn)}set description(I){V(this,vn,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,Fo),n=Math.max(i,A),l=Cl.processDrawnLines({lines:{curves:I.map(o=>({points:o})),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,Fo,I);V(this,ko,l instanceof oV),this.description=t;let o;c(this,ko)?o=yi.getDefaultDrawingOptions():(o=yi._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:o});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 Cl.process(I,e,t,i,yi._INNER_MARGIN)}getFromText(I,e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:A}=this.parent.viewport;return Cl.extractContoursFromText(I,e,t,i,A,yi._INNER_MARGIN)}getDrawnSignature(I){const{rawDims:{pageWidth:e,pageHeight:t},rotation:i}=this.parent.viewport;return Cl.processDrawnLines({lines:I,pageWidth:e,pageHeight:t,rotation:i,innerMargin:yi._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:I,thickness:e}){I?this._drawingOptions=yi.getDefaultDrawingOptions():(this._drawingOptions=yi._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,ko),color:[0,0,0],thickness:c(this,ko)?0:i});return this.addComment(A),I?(A.paths={lines:e,points:t},A.uuid=c(this,oc),A.isCopy=!0):A.lines=e,c(this,vn)&&(A.accessibilityData={type:"Figure",alt:c(this,vn)}),A}static deserializeDraw(I,e,t,i,A,n){return n.areContours?oV.deserialize(I,e,t,i,A,n):kh.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,ko,I.areContours),i.description=((A=I.accessibilityData)==null?void 0:A.alt)||"",V(i,oc,I.uuid),i}};ko=new WeakMap,vn=new WeakMap,Fo=new WeakMap,oc=new WeakMap,sg(yi,"_type","signature"),sg(yi,"_editorType",jg.SIGNATURE),sg(yi,"_defaultDrawingOptions",null);let cV=yi;class rV extends EI{constructor(I){super({...I,name:"stampEditor"});X(this,bI);X(this,nC,null);X(this,ue,null);X(this,zo,null);X(this,Pl,null);X(this,Jo,null);X(this,gu,"");X(this,_l,null);X(this,ac,!1);X(this,jn,null);X(this,Yi,!1);X(this,Iu,!1);V(this,Pl,I.bitmapUrl),V(this,Jo,I.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(I,e){EI.initialize(I,e)}static isHandlingMimeForPasting(I){return fY.includes(I)}static paste(I,e){e.pasteEditor({mode:jg.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 o=l.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){var I;c(this,ue)&&(V(this,nC,null),this._uiManager.imageManager.deleteId(c(this,ue)),(I=c(this,_l))==null||I.remove(),V(this,_l,null),c(this,jn)&&(clearTimeout(c(this,jn)),V(this,jn,null))),super.remove()}rebuild(){if(!this.parent){c(this,ue)&&f(this,bI,dy).call(this);return}super.rebuild(),this.div!==null&&(c(this,ue)&&c(this,_l)===null&&f(this,bI,dy).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(I){this._isDraggable=!0,I&&this.div.focus()}isEmpty(){return!(c(this,zo)||c(this,nC)||c(this,Pl)||c(this,Jo)||c(this,ue)||c(this,ac))}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,ac)||(c(this,nC)?f(this,bI,cy).call(this):f(this,bI,dy).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,ue,t),i&&V(this,nC,i),V(this,ac,!1),f(this,bI,cy).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;c(this,jn)!==null&&clearTimeout(c(this,jn)),V(this,jn,setTimeout(()=>{V(this,jn,null),f(this,bI,$R).call(this)},200))}copyCanvas(I,e,t=!1){I||(I=224);const{width:i,height:A}=c(this,nC),n=new an;let l=c(this,nC),o=i,a=A,d=null;if(e){if(i>e||A>e){const M=Math.min(e/i,e/A);o=Math.floor(i*M),a=Math.floor(A*M)}d=document.createElement("canvas");const u=d.width=Math.ceil(o*n.sx),b=d.height=Math.ceil(a*n.sy);c(this,Yi)||(l=f(this,bI,ry).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":xTg.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,nC),i>I||A>I){const G=Math.min(I/i,I/A);u=Math.floor(i*G),b=Math.floor(A*G),c(this,Yi)||(l=f(this,bI,ry).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:o,height:a,imageData:m}}static async deserialize(I,e,t){var w;let i=null,A=!1;if(I instanceof PS){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:F}},canvas:T}=I;let E,q;T?(delete I.canvas,{id:E,bitmap:q}=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:jg.STAMP,bitmapId:E,bitmap:q,pageIndex:F-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:o,bitmapUrl:a,bitmapId:d,isSvg:m,accessibilityData:u}=I;A?(t.addMissingCanvas(I.id,n),V(n,ac,!0)):d&&t.imageManager.isValidId(d)?(V(n,ue,d),o&&V(n,nC,o)):V(n,Pl,a),V(n,Yi,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,Iu,!!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,ue),isSvg:c(this,Yi)});if(this.addComment(t),I)return t.bitmapUrl=f(this,bI,my).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,bI,ET).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,Yi)?(t.rect[2]-t.rect[0])*(t.rect[3]-t.rect[1]):null;if(!e.stamps.has(c(this,ue)))e.stamps.set(c(this,ue),{area:n,serialized:t}),t.bitmap=f(this,bI,my).call(this,!1);else if(c(this,Yi)){const l=e.stamps.get(c(this,ue));n>l.area&&(l.area=n,l.serialized.bitmap.close(),l.serialized.bitmap=f(this,bI,my).call(this,!1))}return t}renderAnnotationElement(I){return this.deleted?(I.hide(),null):(I.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}nC=new WeakMap,ue=new WeakMap,zo=new WeakMap,Pl=new WeakMap,Jo=new WeakMap,gu=new WeakMap,_l=new WeakMap,ac=new WeakMap,jn=new WeakMap,Yi=new WeakMap,Iu=new WeakMap,bI=new WeakSet,CG=function(I,e=!1){if(!I){this.remove();return}V(this,nC,I.bitmap),e||(V(this,ue,I.id),V(this,Yi,I.isSvg)),I.file&&V(this,gu,I.file.name),f(this,bI,cy).call(this)},eG=function(){if(V(this,zo,null),this._uiManager.enableWaiting(!1),!!c(this,_l)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,nC)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,nC)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},dy=function(){if(c(this,ue)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,ue)).then(t=>f(this,bI,CG).call(this,t,!0)).finally(()=>f(this,bI,eG).call(this));return}if(c(this,Pl)){const t=c(this,Pl);V(this,Pl,null),this._uiManager.enableWaiting(!0),V(this,zo,this._uiManager.imageManager.getFromUrl(t).then(i=>f(this,bI,CG).call(this,i)).finally(()=>f(this,bI,eG).call(this)));return}if(c(this,Jo)){const t=c(this,Jo);V(this,Jo,null),this._uiManager.enableWaiting(!0),V(this,zo,this._uiManager.imageManager.getFromFile(t).then(i=>f(this,bI,CG).call(this,i)).finally(()=>f(this,bI,eG).call(this)));return}const I=document.createElement("input");I.type="file",I.accept=fY.join(",");const e=this._uiManager._signal;V(this,zo,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,bI,CG).call(this,i)}t()},{signal:e}),I.addEventListener("cancel",()=>{this.remove(),t()},{signal:e})}).finally(()=>f(this,bI,eG).call(this))),I.click()},cy=function(){var o;const{div:I}=this;let{width:e,height:t}=c(this,nC);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,_l,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=e/i,this.height=t/A,this.setDims(),(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(I.hidden=!1),f(this,bI,$R).call(this),c(this,Iu)||(this.parent.addUndoableEditor(this),V(this,Iu,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,gu)&&this.div.setAttribute("aria-description",c(this,gu)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},ry=function(I,e){const{width:t,height:i}=c(this,nC);let A=t,n=i,l=c(this,nC);for(;A>2*I||n>2*e;){const o=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,o,a,0,0,A,n),l=d.transferToImageBitmap()}return l},$R=function(){const[I,e]=this.parentDimensions,{width:t,height:i}=this,A=new an,n=Math.ceil(t*I*A.sx),l=Math.ceil(i*e*A.sy),o=c(this,_l);if(!o||o.width===n&&o.height===l)return;o.width=n,o.height=l;const a=c(this,Yi)?c(this,nC):f(this,bI,ry).call(this,n,l),d=o.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(a,0,0,a.width,a.height,0,0,n,l)},my=function(I){if(I){if(c(this,Yi)){const i=this._uiManager.imageManager.getSvgUrl(c(this,ue));if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=c(this,nC),e.getContext("2d").drawImage(c(this,nC),0,0),e.toDataURL()}if(c(this,Yi)){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*Rs.PDF_TO_CSS_UNITS),A=Math.round(this.height*t*Rs.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,A);return n.getContext("2d").drawImage(c(this,nC),0,0,c(this,nC).width,c(this,nC).height,0,0,i,A),n.transferToImageBitmap()}return structuredClone(c(this,nC))},ET=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(rV,"_type","stamp"),sg(rV,"_editorType",jg.STAMP);const xA=class xA{constructor({uiManager:g,pageIndex:I,div:e,structTreeLayer:t,accessibilityManager:i,annotationLayer:A,drawLayer:n,textLayer:l,viewport:o,l10n:a}){X(this,jI);X(this,dc);X(this,Cu,!1);X(this,Lo,null);X(this,To,null);X(this,$l,null);X(this,Ot,new Map);X(this,vo,!1);X(this,eu,!1);X(this,tu,!1);X(this,jA,null);X(this,ql,null);X(this,he,null);X(this,gs,null);X(this,jo,null);X(this,iu,-1);X(this,pg);const d=[...c(xA,xo).values()];if(!xA._initialized){xA._initialized=!0;for(const m of d)m.initialize(a,g)}g.registerEditorTypes(d),V(this,pg,g),this.pageIndex=I,this.div=e,V(this,dc,i),V(this,Lo,A),this.viewport=o,V(this,he,l),this.drawLayer=n,this._structTree=t,c(this,pg).addLayer(this)}get isEmpty(){return c(this,Ot).size===0}get isInvisible(){return this.isEmpty&&c(this,pg).getMode()===jg.NONE}updateToolbar(g){c(this,pg).updateToolbar(g)}updateMode(g=c(this,pg).getMode()){switch(f(this,jI,uy).call(this),g){case jg.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case jg.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case jg.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===jg.POPUP)I.toggle("commentEditing",!0);else{I.toggle("commentEditing",!1);for(const e of c(xA,xo).values())I.toggle(`${e._type}Editing`,g===e._editorType)}this.div.hidden=!1}hasTextLayer(g){var I;return g===((I=c(this,he))==null?void 0:I.div)}setEditingState(g){c(this,pg).setEditingState(g)}addCommands(g){c(this,pg).addCommands(g)}cleanUndoStack(g){c(this,pg).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,Lo))==null||I.togglePointerEvents(g)}async enable(){var e;V(this,tu,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(e=c(this,jo))==null||e.abort(),V(this,jo,null);const g=new Set;for(const t of c(this,jI,qR))t.enableEditing(),t.show(!0),t.annotationElementId&&(c(this,pg).removeChangedExistingAnnotation(t),g.add(t.annotationElementId));const I=c(this,Lo);if(I)for(const t of I.getEditableAnnotations()){if(t.hide(),c(this,pg).isDeletedAnnotationElement(t.data.id)||g.has(t.data.id))continue;const i=await this.deserialize(t);i&&(this.addOrRebuild(i),i.enableEditing())}V(this,tu,!1),c(this,pg)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var t;if(V(this,eu,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),c(this,he)&&!c(this,jo)){V(this,jo,new AbortController);const i=c(this,pg).combinedSignal(c(this,jo));c(this,he).div.addEventListener("pointerdown",A=>{const{clientX:l,clientY:o,timeStamp:a}=A,d=c(this,iu);if(a-d>500){V(this,iu,a);return}V(this,iu,-1);const{classList:m}=this.div;m.toggle("getElements",!0);const u=document.elementsFromPoint(l,o);if(m.toggle("getElements",!1),!this.div.contains(u[0]))return;let b;const Z=new RegExp(`^${Zh}[0-9]+$`);for(const G of u)if(Z.test(G.id)){b=G.id;break}if(!b)return;const w=c(this,Ot).get(b);(w==null?void 0:w.annotationElementId)===null&&(A.stopPropagation(),A.preventDefault(),w.dblclick(A))},{signal:i,capture:!0})}const g=c(this,Lo),I=[];if(g){const i=new Map,A=new Map;for(const l of c(this,jI,qR)){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:o}=l.data;if(c(this,pg).isDeletedAnnotationElement(o)){l.updateEdited({deleted:!0});continue}let a=A.get(o);if(a){a.resetAnnotationElement(l),a.show(!1),l.show();continue}a=i.get(o),a&&(c(this,pg).addChangedExistingAnnotation(a),a.renderAnnotationElement(l)&&a.show(!1)),l.show()}}f(this,jI,uy).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const i of c(xA,xo).values())e.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),g==null||g.updateFakeAnnotations(I),V(this,eu,!1)}getEditableAnnotation(g){var I;return((I=c(this,Lo))==null?void 0:I.getEditableAnnotation(g))||null}setActiveEditor(g){c(this,pg).getActive()!==g&&c(this,pg).setActiveEditor(g)}enableTextSelection(){var g;if(this.div.tabIndex=-1,(g=c(this,he))!=null&&g.div&&!c(this,gs)){V(this,gs,new AbortController);const I=c(this,pg).combinedSignal(c(this,gs));c(this,he).div.addEventListener("pointerdown",f(this,jI,PT).bind(this),{signal:I}),c(this,he).div.classList.add("highlighting")}}disableTextSelection(){var g;this.div.tabIndex=0,(g=c(this,he))!=null&&g.div&&c(this,gs)&&(c(this,gs).abort(),V(this,gs,null),c(this,he).div.classList.remove("highlighting"))}enableClick(){if(c(this,To))return;V(this,To,new AbortController);const g=c(this,pg).combinedSignal(c(this,To));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,To))==null||g.abort(),V(this,To,null)}attach(g){c(this,Ot).set(g.id,g);const{annotationElementId:I}=g;I&&c(this,pg).isDeletedAnnotationElement(I)&&c(this,pg).removeDeletedAnnotationElement(g)}detach(g){var I;c(this,Ot).delete(g.id),(I=c(this,dc))==null||I.removePointerInTextLayer(g.contentDiv),!c(this,eu)&&g.annotationElementId&&c(this,pg).addDeletedAnnotationElement(g)}remove(g){this.detach(g),c(this,pg).removeEditor(g),g.div.remove(),g.isAttachedToDOM=!1}changeParent(g){var I;g.parent!==this&&(g.parent&&g.annotationElementId&&(c(this,pg).addDeletedAnnotationElement(g),EI.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,pg).addEditor(g),this.attach(g),!g.isAttachedToDOM){const I=g.render();this.div.append(I),g.isAttachedToDOM=!0}g.fixAndSetPosition(),g.onceAdded(!c(this,tu)),c(this,pg).addToAnnotationStorage(g),g._reportTelemetry(g.telemetryInitialData)}}moveEditorInDOM(g){var e;if(!g.isAttachedToDOM)return;const{activeElement:I}=document;g.div.contains(I)&&!c(this,$l)&&(g._focusEventsAllowed=!1,V(this,$l,setTimeout(()=>{V(this,$l,null),g.div.contains(document.activeElement)?g._focusEventsAllowed=!0:(g.div.addEventListener("focusin",()=>{g._focusEventsAllowed=!0},{once:!0,signal:c(this,pg)._signal}),I.focus())},0))),g._structTreeParentId=(e=c(this,dc))==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,Ot).values())if(I.uid===g)return I;return null}getNextId(){return c(this,pg).getId()}combinedSignal(g){return c(this,pg).combinedSignal(g)}canCreateNewEmptyEditor(){var g;return(g=c(this,jI,En))==null?void 0:g.canCreateNewEmptyEditor()}async pasteEditor(g,I){this.updateToolbar(g),await c(this,pg).updateMode(g.mode);const{offsetX:e,offsetY:t}=f(this,jI,IX).call(this),i=this.getNextId(),A=f(this,jI,gX).call(this,{parent:this,id:i,x:e,y:t,uiManager:c(this,pg),isCentered:!0,...I});A&&this.add(A)}async deserialize(g){var I;return await((I=c(xA,xo).get(g.annotationType??g.annotationEditorType))==null?void 0:I.deserialize(g,this,c(this,pg)))||null}createAndAddNewEditor(g,I,e={}){const t=this.getNextId(),i=f(this,jI,gX).call(this,{parent:this,id:t,x:g.offsetX,y:g.offsetY,uiManager:c(this,pg),isCentered:I,...e});return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(g={}){this.createAndAddNewEditor(f(this,jI,IX).call(this),!0,g)}setSelected(g){c(this,pg).setSelected(g)}toggleSelected(g){c(this,pg).toggleSelected(g)}unselect(g){c(this,pg).unselect(g)}pointerup(g){var t;const{isMac:I}=we.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div||!c(this,vo)||(V(this,vo,!1),(t=c(this,jI,En))!=null&&t.isDrawer&&c(this,jI,En).supportMultipleDrawings))return;if(!c(this,Cu)){V(this,Cu,!0);return}const e=c(this,pg).getMode();if(e===jg.STAMP||e===jg.SIGNATURE){c(this,pg).unselectAll();return}this.createAndAddNewEditor(g,!1)}pointerdown(g){var t;if(c(this,pg).getMode()===jg.HIGHLIGHT&&this.enableTextSelection(),c(this,vo)){V(this,vo,!1);return}const{isMac:I}=we.platform;if(g.button!==0||g.ctrlKey&&I||g.target!==this.div)return;if(V(this,vo,!0),(t=c(this,jI,En))!=null&&t.isDrawer){this.startDrawingSession(g);return}const e=c(this,pg).getActive();V(this,Cu,!e||e.isEmpty())}startDrawingSession(g){if(this.div.focus({preventScroll:!0}),c(this,jA)){c(this,jI,En).startDrawing(this,c(this,pg),!1,g);return}c(this,pg).setCurrentDrawingSession(this),V(this,jA,new AbortController);const I=c(this,pg).combinedSignal(c(this,jA));this.div.addEventListener("blur",({relatedTarget:e})=>{e&&!this.div.contains(e)&&(V(this,ql,null),this.commitOrRemove())},{signal:I}),c(this,jI,En).startDrawing(this,c(this,pg),!1,g)}pause(g){if(g){const{activeElement:I}=document;this.div.contains(I)&&V(this,ql,I);return}c(this,ql)&&setTimeout(()=>{var I;(I=c(this,ql))==null||I.focus(),V(this,ql,null)},0)}endDrawingSession(g=!1){return c(this,jA)?(c(this,pg).setCurrentDrawingSession(null),c(this,jA).abort(),V(this,jA,null),V(this,ql,null),c(this,jI,En).endDrawing(g)):null}findNewParent(g,I,e){const t=c(this,pg).findParent(I,e);return t===null||t===this?!1:(t.changeParent(g),!0)}commitOrRemove(){return c(this,jA)?(this.endDrawingSession(),!0):!1}onScaleChanging(){c(this,jA)&&c(this,jI,En).onScaleChangingWhenDrawing(this)}destroy(){var g,I;this.commitOrRemove(),((g=c(this,pg).getActive())==null?void 0:g.parent)===this&&(c(this,pg).commitOrRemove(),c(this,pg).setActiveEditor(null)),c(this,$l)&&(clearTimeout(c(this,$l)),V(this,$l,null));for(const e of c(this,Ot).values())(I=c(this,dc))==null||I.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,c(this,Ot).clear(),c(this,pg).removeLayer(this)}render({viewport:g}){this.viewport=g,Ya(this.div,g);for(const I of c(this,pg).getEditors(this.pageIndex))this.add(I),I.rebuild();this.updateMode()}update({viewport:g}){c(this,pg).commitOrRemove(),f(this,jI,uy).call(this);const I=this.viewport.rotation,e=g.rotation;if(this.viewport=g,Ya(this.div,{rotation:e}),I!==e)for(const t of c(this,Ot).values())t.rotate(e)}get pageDimensions(){const{pageWidth:g,pageHeight:I}=this.viewport.rawDims;return[g,I]}get scale(){return c(this,pg).viewParameters.realScale}};dc=new WeakMap,Cu=new WeakMap,Lo=new WeakMap,To=new WeakMap,$l=new WeakMap,Ot=new WeakMap,vo=new WeakMap,eu=new WeakMap,tu=new WeakMap,jA=new WeakMap,ql=new WeakMap,he=new WeakMap,gs=new WeakMap,jo=new WeakMap,iu=new WeakMap,pg=new WeakMap,xo=new WeakMap,jI=new WeakSet,qR=function(){return c(this,Ot).size!==0?c(this,Ot).values():c(this,pg).getEditors(this.pageIndex)},PT=function(g){c(this,pg).unselectAll();const{target:I}=g;if(I===c(this,he).div||(I.getAttribute("role")==="img"||I.classList.contains("endOfContent"))&&c(this,he).div.contains(I)){const{isMac:e}=we.platform;if(g.button!==0||g.ctrlKey&&e)return;c(this,pg).showAllEditors("highlight",!0,!0),c(this,he).div.classList.add("free"),this.toggleDrawing(),Jw.startHighlighting(this,c(this,pg).direction==="ltr",{target:c(this,he).div,x:g.x,y:g.y}),c(this,he).div.addEventListener("pointerup",()=>{c(this,he).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,pg)._signal}),g.preventDefault()}},En=function(){return c(xA,xo).get(c(this,pg).getMode())},gX=function(g){const I=c(this,jI,En);return I?new I.prototype.constructor(g):null},IX=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),o=(i+n)/2-g,a=(A+l)/2-I,[d,m]=this.viewport.rotation%180===0?[o,a]:[a,o];return{offsetX:d,offsetY:m}},uy=function(){for(const g of c(this,Ot).values())g.isEmpty()&&g.remove()},sg(xA,"_initialized",!1),X(xA,xo,new Map([AV,sV,rV,Jw,cV].map(g=>[g._editorType,g])));let mV=xA;const Ie=class Ie{constructor({pageIndex:g}){X(this,xn);X(this,OA,null);X(this,Zt,new Map);X(this,cc,new Map);this.pageIndex=g}setParent(g){if(!c(this,OA)){V(this,OA,g);return}if(c(this,OA)!==g){if(c(this,Zt).size>0)for(const I of c(this,Zt).values())I.remove(),g.append(I);V(this,OA,g)}}static get _svgFactory(){return Tg(this,"_svgFactory",new kw)}draw(g,I=!1,e=!1){const t=te(Ie,WZ)._++,i=f(this,xn,CX).call(this),A=Ie._svgFactory.createElement("defs");i.append(A);const n=Ie._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,cc).set(t,n);const o=e?f(this,xn,$T).call(this,A,l):null,a=Ie._svgFactory.createElement("use");return i.append(a),a.setAttribute("href",`#${l}`),this.updateProperties(i,g),c(this,Zt).set(t,i),{id:t,clipPathId:`url(#${o})`}}drawOutline(g,I){const e=te(Ie,WZ)._++,t=f(this,xn,CX).call(this),i=Ie._svgFactory.createElement("defs");t.append(i);const A=Ie._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=Ie._svgFactory.createElement("mask");i.append(d),l=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const m=Ie._svgFactory.createElement("rect");d.append(m),m.setAttribute("width","1"),m.setAttribute("height","1"),m.setAttribute("fill","white");const u=Ie._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 o=Ie._svgFactory.createElement("use");t.append(o),o.setAttribute("href",`#${n}`),l&&o.setAttribute("mask",`url(#${l})`);const a=o.cloneNode();return t.append(a),o.classList.add("mainOutline"),a.classList.add("secondaryOutline"),this.updateProperties(t,g),c(this,Zt).set(e,t),e}finalizeDraw(g,I){c(this,cc).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,Zt).get(g):g;if(n){if(e&&f(this,xn,eX).call(this,n,e),t&&f(l=Ie,EB,_T).call(l,n,t),i){const{classList:o}=n;for(const[a,d]of Object.entries(i))o.toggle(a,d)}if(A){const a=n.firstElementChild.firstElementChild;f(this,xn,eX).call(this,a,A)}}}updateParent(g,I){if(I===this)return;const e=c(this,Zt).get(g);e&&(c(I,OA).append(e),c(this,Zt).delete(g),c(I,Zt).set(g,e))}remove(g){c(this,cc).delete(g),c(this,OA)!==null&&(c(this,Zt).get(g).remove(),c(this,Zt).delete(g))}destroy(){V(this,OA,null);for(const g of c(this,Zt).values())g.remove();c(this,Zt).clear(),c(this,cc).clear()}};OA=new WeakMap,Zt=new WeakMap,cc=new WeakMap,WZ=new WeakMap,EB=new WeakSet,_T=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}%`},xn=new WeakSet,CX=function(){const g=Ie._svgFactory.create(1,1,!0);return c(this,OA).append(g),g.setAttribute("aria-hidden",!0),g},$T=function(g,I){const e=Ie._svgFactory.createElement("clipPath");g.append(e);const t=`clip_${I}`;e.setAttribute("id",t),e.setAttribute("clipPathUnits","objectBoundingBox");const i=Ie._svgFactory.createElement("use");return e.append(i),i.setAttribute("href",`#${I}`),i.classList.add("clip"),t},eX=function(g,I){for(const[e,t]of Object.entries(I))t===null?g.removeAttribute(e):g.setAttribute(e,t)},X(Ie,EB),X(Ie,WZ,0);let uV=Ie;globalThis._pdfjsTestingUtils={HighlightOutliner:nV},globalThis.pdfjsLib={AbortException:Ms,AnnotationEditorLayer:mV,AnnotationEditorParamsType:aI,AnnotationEditorType:jg,AnnotationEditorUIManager:Va,AnnotationLayer:iV,AnnotationMode:Ns,AnnotationType:kC,applyOpacity:QTg,build:gjg,ColorPicker:Sw,createValidAbsoluteUrl:PD,CSSConstants:OTg,DOMSVGFactory:kw,DrawLayer:uV,FeatureTest:we,fetchData:ph,findContrastColor:UTg,getDocument:$Y,getFilenameFromUrl:JTg,getPdfFilenameFromUrl:LTg,getRGB:Nh,getUuid:IS,getXfaPageViewport:vTg,GlobalWorkerOptions:cn,ImageKind:mw,InvalidPDFException:MY,isDataScheme:Gw,isPdfFile:Yh,isValidExplicitDest:tvg,MathClamp:lt,noContextMenu:Si,normalizeUnicode:kTg,OPS:Gh,OutputScale:an,PasswordResponses:NTg,PDFDataRangeTransport:vS,PDFDateString:ww,PDFWorker:Sh,PermissionFlag:VTg,PixelsPerInch:Rs,RenderingCancelledException:HY,renderRichText:sS,ResponseException:Zw,setLayerDimensions:Ya,shadow:Tg,SignatureExtractor:Cl,stopEvent:bC,SupportedImageMimeTypes:fY,TextLayer:Dh,TouchManager:pw,updateUrlHash:_D,Util:Wg,VerbosityLevel:uw,version:qvg,XfaLayer:eS};class pjg{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 Ra=new pjg,yjg=["src"],el=s.defineComponent({name:"PdfPreview",__name:"PdfPreview",props:{src:{},page:{}},setup(C,{expose:g}){cn.workerSrc=YTg;const I=C,e=s.reactive({isError:!1,rotate:0}),t=s.ref(null);let i,A=null;s.watch([()=>I.src,()=>I.page],()=>{i==null||i.disconnect(),a(),e.isError=!1,s.nextTick(()=>{o()})}),s.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=Ra.getCache(I.src);if(m?d=m:(d=await $Y(I.src).promise,Ra.setCache(I.src,d)),!d)throw new Error("Pdf not found");const u=I.page??1,b=`${I.src}-${u}`,Z=Ra.getPageCache(b);let w;Z?w=Z:(w=await d.getPage(u),Ra.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=window.devicePixelRatio||1,M=w.getViewport({scale:y*R,rotation:e.rotate}),D=t.value.getContext("2d");if(D===null)throw new Error("Context not found");t.value.width=M.width,t.value.height=M.height;const J=w.render({canvas:t.value,canvasContext:D,viewport:M});A=J,await J.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}finally{A=null}},l=async d=>{try{if(!t.value)return;const m=Ra.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}finally{A=null}},o=()=>{t.value&&(i=new IntersectionObserver((d,m)=>{d.forEach(u=>{u.isIntersecting&&(n(),m.unobserve(u.target))},{rootMargin:"50px"})}),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}),s.onMounted(()=>{o()}),(d,m)=>e.isError?(s.openBlock(),s.createElementBlock("img",{key:1,src:s.unref(gl)},null,8,yjg)):(s.openBlock(),s.createElementBlock("canvas",{key:0,ref_key:"canvas",ref:t},null,512))}});var hV=(C=>(C.slideTop="slide-top",C.slideLeft="slide-left",C.fadeAndScale="fade-and-scale",C.fade="fade",C))(hV||{});function qI(C,g=document.documentElement){for(const[I,e]of Object.entries(C))g.style.setProperty(I,String(e))}const Yjg=()=>{const C=s.ref(0),g=s.ref([]),I=s.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}},Vjg=["data-testid"],Njg=["data-testid"],Mjg=Vg(s.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}=Yjg(),A=C,n=s.ref(null),l=s.useAttrs(),o=s.ref(!1),a=s.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&&qI({overflow:"","padding-right":""},document.body)},p=Y=>{Y.target===n.value&&b()};return g({closeDialog:Z}),s.onMounted(()=>{s.watchEffect(()=>{A.open!==o.value&&(u(),o.value=A.open,n.value&&n.value.focus())}),n.value&&n.value.addEventListener("cancel",y=>{y.preventDefault()});const Y=G();qI({overflow:"hidden","padding-right":`${Y}px`},document.body),document.addEventListener("keydown",w)}),s.onUnmounted(()=>{B(),document.removeEventListener("keydown",w),d("unmounted")}),(Y,y)=>(s.openBlock(),s.createElementBlock("dialog",s.mergeProps({ref_key:"dialog",ref:n},s.unref(l),{class:["modal-yui-kit",`modal-yui-kit_${A.position}`],"data-testid":A.dataTestid,onClick:s.withModifiers(p,["self","left"])}),[s.createElementVNode("div",{class:"modal-yui-kit__modal-content",style:s.normalizeStyle(a.value),"data-testid":`${A.dataTestid}-ModalContent`},[s.renderSlot(Y.$slots,"default",{},void 0,!0)],12,Njg)],16,Vjg))}}),[["__scopeId","data-v-b4b136aa"]]),zh=Vg(s.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=s.computed(()=>I.animateType===hV.fade?"fade":I.position==="bottom"?"slide-bottom":I.position==="right"?"slide-left":"fade-and-scale"),i=s.ref(null),A=s.reactive({function:()=>{}}),n=()=>{d()},l=()=>{e("unmounted")},o=()=>{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)=>(s.openBlock(),s.createBlock(s.Transition,{name:t.value,onAfterLeave:a,onBeforeLeave:o,onAfterEnter:n},{default:s.withCtx(()=>[I.open?(s.openBlock(),s.createBlock(Mjg,{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:s.withCtx(()=>[s.renderSlot(u.$slots,"default",{},void 0,!0)]),_:3},8,["open","position","width","height","data-testid"])):s.createCommentVNode("",!0)]),_:3},8,["name"]))}}),[["__scopeId","data-v-6c0d942a"]]),qS=(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}},bV=(C,g=null)=>{if(!C)return;(g?qS(C,g):qS(C))||C.scrollIntoView({behavior:"smooth",block:"nearest"})},Rjg=s.defineComponent({name:"BaseSlider",__name:"BaseSlider",props:{activeIndex:{default:0}},setup(C,{expose:g}){const I=C,e=s.reactive({children:null,activeIndex:I.activeIndex}),t=s.ref(null),i=s.ref(null);s.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||(bV(d[a],i.value),e.activeIndex=a)},n=()=>{s.nextTick(()=>{!e.children||!i.value||bV(e.children[e.activeIndex],i.value)})},l=()=>(A(e.activeIndex+1),e.activeIndex),o=()=>(A(e.activeIndex-1),e.activeIndex);return s.onMounted(()=>{!t.value||!i.value||(e.children=[...t.value.children])}),g({shiftPosition:A,nextSlide:l,prevSlide:o,initScroll:n}),(a,d)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"sliderRef",ref:i,class:"base-slider"},[s.createElementVNode("div",{ref_key:"contentRef",ref:t,class:"base-slider__content"},[s.renderSlot(a.$slots,"default")],512)],512))}}),Xjg={class:"base-slide__content"},Hjg=s.defineComponent({name:"BaseSlide",__name:"BaseSlide",props:{isActive:{type:Boolean}},setup(C){const g=C,I=s.computed(()=>[{"base-slide_active":g.isActive}]);return(e,t)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["base-slide",I.value])},[s.createElementVNode("div",Xjg,[s.renderSlot(e.$slots,"default")])],2))}}),g9=C=>{if(!C)return null;const g=C.split("?")[0],I=/\.\w+$/,e=g.match(I);return e?e[0].replace(".",""):null},ZV=C=>{if(!C)return!1;if(C.startsWith("data:image/"))return!0;const g=g9(C);return g?Object.values(hh).includes(g.toLowerCase()):!1},fjg=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 I9={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(o){return i[o]}).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 o}),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 o(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=o(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 o(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(o,a){o.printable.constructor!==Array&&(o.printable=[o.printable]),o.printableElement=document.createElement("div"),o.printable.forEach(function(d){var m=document.createElement("img");if(m.setAttribute("style",o.imageStyle),m.src=d,n.default.isFirefox()){var u=m.src;m.src=u}var b=document.createElement("div");b.appendChild(m),o.printableElement.appendChild(b)}),o.header&&Object(i.addHeader)(o.printableElement,o),A.default.send(o,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"),o=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":o.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(o){"@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(o)}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(o){var a=o.printable,d=o.properties,m='<table style="border-collapse: collapse; width: 100%;">';o.repeatTableHeader&&(m+="<thead>"),m+="<tr>";for(var u=0;u<d.length;u++)m+='<th style="width:'+d[u].columnSize+";"+o.gridHeaderStyle+'">'+Object(i.capitalizePrint)(d[u].displayName)+"</th>";m+="</tr>",o.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+o.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;",o=document.createElement("div");o.setAttribute("style",l),o.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),o.appendChild(a),document.getElementsByTagName("body")[0].appendChild(o),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(o,a){if(o.base64){var d=Uint8Array.from(atob(o.printable),function(u){return u.charCodeAt(0)});n(o,a,d);return}o.printable=/^(blob|http|\/\/)/i.test(o.printable)?o.printable:window.location.origin+(o.printable.charAt(0)!=="/"?"/"+o.printable:o.printable);var m=new window.XMLHttpRequest;m.responseType="arraybuffer",m.addEventListener("error",function(){Object(A.cleanUp)(o),o.onError(m.statusText,m)}),m.addEventListener("load",function(){if([200,201].indexOf(m.status)===-1){Object(A.cleanUp)(o),o.onError(m.statusText,m);return}n(o,a,m.response)}),m.open("GET",o.printable,!0),m.send()}};function n(l,o,a){var d=new window.Blob([a],{type:"application/pdf"});d=window.URL.createObjectURL(d),o.setAttribute("src",d),i.default.send(l,o)}},"./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?o(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 o(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})})(I9);var Djg=I9.exports;const Sjg=QLg(Djg),Jh=C=>{if(!C)return!1;const g=g9(C);return g?Object.values(bh).includes(g):!1},Kjg=["src"],Lh=s.defineComponent({name:"VideoPreview",__name:"VideoPreview",props:{src:{}},emits:["error"],setup(C,{emit:g}){const I=C,e=g,t=s.reactive({isError:!1});s.watch(()=>I.src,()=>{t.isError=!1,s.nextTick(()=>{A()})});const i=s.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 o=await fetch(I.src);if(!o.ok)throw new Error("Failed to fetch video");const a=new Blob([await o.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 s.onMounted(()=>{s.nextTick(()=>{A()})}),(n,l)=>t.isError?(s.openBlock(),s.createElementBlock("img",{key:1,src:s.unref(gl)},null,8,Kjg)):(s.openBlock(),s.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:i,class:"video-preview"},null,512))}}),kjg=["src"],jw=s.defineComponent({name:"ImagePreview",__name:"ImagePreview",props:{src:{}},emits:["error"],setup(C,{expose:g,emit:I}){const e=C,t=I,i=s.reactive({isError:!1,rotate:0});s.watch(()=>e.src,()=>{i.isError=!1,i.rotate=0,s.nextTick(()=>{n()})});const A=s.ref(null),n=async()=>{try{if(!A.value||!e.src)return;const o=new Image;o.src=e.src,o.addEventListener("load",()=>{var Z;if(!A.value)return;const a=(Z=A.value)==null?void 0:Z.getContext("2d");if(!a)return;const d=o.width,m=o.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(o,-d/2,-m/2,d,m),a.restore()}),o.addEventListener("error",a=>{i.isError=!0,t("error",a)})}catch{t("error",new Event("error")),i.isError=!0}},l=async o=>{const a=Math.round(o/90)*90;i.rotate+=a,s.nextTick(()=>{n()})};return s.onMounted(()=>{s.nextTick(()=>{n()})}),g({rotateImage:l}),(o,a)=>i.isError?(s.openBlock(),s.createElementBlock("img",{key:1,src:s.unref(gl)},null,8,kjg)):(s.openBlock(),s.createElementBlock("canvas",{key:0,ref_key:"canvasRef",ref:A,class:"image-preview"},null,512))}}),tl=C=>C?C instanceof File?C.type==="application/pdf":Yh(C):!1,Fjg={ref:"contentRef",class:"slider-modal__content"},zjg=["onClick"],Jjg={class:"slider-modal__side-bar-count"},Ljg={key:0,class:"slider-modal__mobile-header"},Tjg={class:"slider-modal__mobile-header-block"},vjg={class:"slider-modal__mobile-header-block"},jjg={class:"slider-modal__counter"},xjg=["data-testid"],Ojg=["src"],Qjg=["src"],Ujg={class:"slider-modal__bottom"},Ejg={class:"slider-modal__nav-block"},Pjg=["disabled"],_jg=["src","alt"],$jg=["src"],qjg=["disabled"],gxg={class:"slider-modal__nav-block"},Ixg={class:"slider-modal__sub-nav"},Cxg=["disabled"],exg=["disabled"],txg=["disabled"],ixg={class:"slider-modal__sub-nav"},Axg=["disabled"],nxg=["disabled"],GV=80,C9=20,lxg=80,sxg=20,xw=Vg(s.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,{emit:g}){const I=C,e=g,t=window.matchMedia("(max-width: 768px)"),i=s.reactive({defaultIndex:I.defaultIndex,file:I.items[I.defaultIndex],sideBarItems:[],sideBarIndex:0,sideBarLength:0,isErrorFile:!1,isClickOnExit:!1,isDragging:!1,isMobile:!1,isPointerActive:!1,isExistSwipe:!1,isChangeItemSwipe:!1,isSwipeNextSlide:!1,isSwipePrevSlide:!1,isExitScrollActive:!1,zoomValue:1,offsetX:0,offsetY:0,startX:0,startY:0,startXForMobile:0,startYForMobile:0,endXForMobile:0,endYForMobile:0,overscrollDelta:0,startScrollTop:0}),A=s.ref(null),n=s.ref(null),l=s.ref(null),o=s.ref(null),a=s.ref(null),d=s.ref(null),m=s.ref(null),u=s.ref(null),b=s.computed(()=>i.defaultIndex===0),Z=s.computed(()=>i.defaultIndex===I.items.length-1),w=s.computed(()=>{var rg,Jg;let og=!i.file||i.isErrorFile;return og=Jh((rg=i.file)==null?void 0:rg.path)||og,og=i.isMobile&&tl((Jg=i.file)==null?void 0:Jg.path)||og,og}),G=s.computed(()=>{var rg;let og=!i.file||i.isErrorFile;return og=Jh((rg=i.file)==null?void 0:rg.path)||og,og}),B=s.computed(()=>!i.file||i.isErrorFile),p=s.computed(()=>{var rg;let og=!i.file||i.isErrorFile;return og=Jh((rg=i.file)==null?void 0:rg.path)||og,og}),Y=s.computed(()=>({transform:`
1329
1329
  translate(${i.offsetX}px, ${i.offsetY}px)
1330
1330
  scale(${i.zoomValue})
1331
1331
  `}));s.watch([()=>I.items,()=>I.defaultIndex],()=>{i.file=I.items[I.defaultIndex??0],i.defaultIndex=I.defaultIndex??0}),s.watch([()=>i.file,()=>I.open],()=>{if(!I.open){QC(),i.file=null;return}i.zoomValue=1,i.file||(i.file=I.items[I.defaultIndex??0]),i.isErrorFile=!1,Ut()}),s.watch(()=>I.open,()=>{I.open&&(s.nextTick(()=>{m.value&&m.value.initScroll()}),i.defaultIndex=I.defaultIndex??0)}),s.watch(()=>i.sideBarIndex,()=>{nu()});const y=()=>{i.isClickOnExit&&e("close")},R=og=>{wt(og)},M=og=>{i.sideBarIndex=og},D=og=>{i.isMobile||Au(og.deltaY)},J=()=>{be(!0)},H=()=>{be(!1)},F=()=>{d.value&&d.value.rotatePdf(-90),u.value&&u.value.rotateImage(-90)},T=()=>{var uI,xI,lC;if(!((uI=i.file)!=null&&uI.path))return;let og="pdf",rg="",Jg="";ZV((xI=i.file)==null?void 0:xI.path)&&(og="image",rg=`
@@ -1333,7 +1333,7 @@ function print() { __p += __j.call(arguments, '') }
1333
1333
  size: A4 portrait;
1334
1334
  margin: 10mm;
1335
1335
  }
1336
- `,Jg="max-height: 95vh; margin-bottom: 10px; max-width: 100%"),Sjg({printable:(lC=i.file)==null?void 0:lC.path,type:og,style:rg,imageStyle:Jg})},E=()=>{var og,rg,Jg;(og=i.file)!=null&&og.path&&fjg((rg=i.file)==null?void 0:rg.path,(Jg=i.file)==null?void 0:Jg.name)},q=(og,rg=!1)=>{const Jg=og.target;Jg&&(Jg.src=gl),rg&&(i.isErrorFile=!0)},gg=()=>{m.value&&wt(m.value.nextSlide())},Q=()=>{m.value&&wt(m.value.prevSlide())},$=og=>{if(i.isMobile)return;const rg=og.target;(rg===a.value||rg===l.value)&&(i.isClickOnExit=!0)},lg=og=>{const rg=og.target;(rg===a.value||rg===l.value)&&y(),i.isClickOnExit=!1},Bg=og=>{i.isDragging=!0,i.startX=og.clientX-i.offsetX,i.startY=og.clientY-i.offsetY},II=og=>{i.isDragging&&(i.offsetX=og.clientX-i.startX,i.offsetY=og.clientY-i.startY,QA(),requestAnimationFrame(()=>{o.value&&qI(Y.value,o.value)}))},cI=()=>{i.isDragging=!1},Fg=og=>{i.isMobile&&(i.startXForMobile=og.clientX,i.startYForMobile=og.clientY,i.isPointerActive=!0)},kg=og=>{i.isMobile&&(i.startXForMobile=og.touches[0].clientX,i.startYForMobile=og.touches[0].clientY,i.isPointerActive=!0)},Ug=()=>{i.isMobile&&(Qt(),OC())},iI=og=>{var lC,oA;if(!i.isMobile)return;const rg=og.clientX,Jg=og.clientY,uI=Math.abs(rg-i.startXForMobile),xI=Jg-i.startYForMobile;i.isExistSwipe&&xI>GV&&xI>uI&&e("close"),i.isChangeItemSwipe&&m.value&&(i.isSwipeNextSlide&&wt((lC=m.value)==null?void 0:lC.nextSlide()),i.isSwipePrevSlide&&wt((oA=m.value)==null?void 0:oA.prevSlide())),Qt(),s.nextTick(()=>{OC()})},NC=og=>{var lC,oA;if(!i.isMobile)return;const rg=og.changedTouches[0].clientX,Jg=og.changedTouches[0].clientY,uI=Math.abs(rg-i.startXForMobile),xI=Jg-i.startYForMobile;i.isExistSwipe&&xI>GV&&xI>uI&&e("close"),i.isChangeItemSwipe&&m.value&&(i.isSwipeNextSlide&&wt((lC=m.value)==null?void 0:lC.nextSlide()),i.isSwipePrevSlide&&wt((oA=m.value)==null?void 0:oA.prevSlide())),Qt(),s.nextTick(()=>{OC()})},WI=og=>{if(!i.isMobile||!i.isPointerActive)return;const rg=og.clientY-i.startYForMobile,Jg=og.clientX-i.startXForMobile;lA(Jg,rg)},xC=og=>{if(!i.isMobile)return;const rg=og.touches[0].clientX,Jg=og.touches[0].clientY,uI=rg-i.startXForMobile,xI=Jg-i.startYForMobile;lA(uI,xI)},Gt=og=>{const rg=og.target;!i.isMobile||!rg||rg.scrollHeight<=rg.clientHeight||!i.isExitScrollActive&&rg.scrollTop===0&&og.preventDefault()},lA=(og,rg)=>{const Jg=Math.abs(og);if(Jg<rg&&rg>C9&&!i.isChangeItemSwipe&&l.value&&l.value.scrollTop===0&&(i.isExistSwipe=!0),Jg>rg&&Jg>sxg&&!i.isExistSwipe&&(i.isChangeItemSwipe=!0),i.isExistSwipe){const uI=Math.max(0,1-(rg-C9)/GV);requestAnimationFrame(()=>{a.value&&qI({opacity:uI},a.value)})}if(i.isChangeItemSwipe&&Jg>lxg){const uI=i.defaultIndex===I.items.length-1,xI=i.defaultIndex===0;if(og>0){if(xI)return;i.isSwipePrevSlide=!0}if(og<0){if(uI)return;i.isSwipeNextSlide=!0}}},OC=()=>{requestAnimationFrame(()=>{a.value&&qI({opacity:1},a.value)})},Qt=()=>{i.isPointerActive=!1,i.isExistSwipe=!1,i.isSwipeNextSlide=!1,i.isSwipePrevSlide=!1,i.isChangeItemSwipe=!1},QA=()=>{if(!l.value||!o.value)return;const og=l.value.clientWidth,rg=l.value.clientHeight,Jg=o.value.offsetWidth*i.zoomValue,uI=o.value.offsetHeight*i.zoomValue,xI=Math.max(0,(Jg-og)/2);i.offsetX=Math.min(xI,Math.max(-xI,i.offsetX));const lC=Math.max(0,(uI-rg)/2);i.offsetY=Math.min(lC,Math.max(-lC,i.offsetY))},be=og=>{const rg=i.zoomValue;i.zoomValue+=og?1:-1,i.zoomValue=Math.min(Math.max(1,i.zoomValue),3);const Jg=i.zoomValue;if(rg===Jg)return;const uI=Jg/rg;i.offsetX*=uI,i.offsetY*=uI,QA(),o.value&&(u.value||d.value)&&qI(Y.value,o.value)},wt=og=>{I.items[og]&&(i.defaultIndex=og,QC(),i.file=I.items[og])},Au=og=>{let rg=i.sideBarIndex;og>0?(rg=i.sideBarIndex+1,rg=Math.min(i.sideBarLength-1,rg)):(rg=i.sideBarIndex-1,rg=Math.max(0,rg)),i.sideBarIndex=rg},Ut=()=>{s.nextTick(()=>{var og,rg;i.file&&(tl((og=i.file)==null?void 0:og.path)||tl((rg=i.file)==null?void 0:rg.file))&&(i.isErrorFile=!0,BZ())})},nu=()=>{s.nextTick(()=>{if(!A.value||!n.value)return;const og=A.value[i.sideBarIndex];bV(og,n.value)})},BZ=async()=>{var og,rg;try{if(!i.file)return;const Jg=Ra.getCache(i.file.path);let uI;if(Jg?uI=Jg:uI=await $Y((og=i.file)==null?void 0:og.path).promise,!uI){i.isErrorFile=!0;return}i.sideBarLength=uI.numPages,i.sideBarItems=new Array(uI.numPages).fill(((rg=i.file)==null?void 0:rg.path)??""),Ra.setCache(i.file.path,uI),Wt(0),i.isErrorFile=!1}catch(Jg){console.error(Jg),i.isErrorFile=!0}},Wt=async(og=0)=>{i.sideBarIndex=og},QC=()=>{i.sideBarItems=[],i.sideBarIndex=0,i.sideBarLength=0},sA=()=>{i.isMobile=t.matches};return s.onMounted(()=>{sA(),t.addEventListener("change",sA)}),s.onUnmounted(()=>{QC(),t.removeEventListener("change",sA)}),(og,rg)=>{const Jg=s.resolveComponent("YIcon");return s.openBlock(),s.createBlock(zh,{position:"center",class:"slider-modal",ref:"modalRef",open:C.open,height:C.height,width:C.width,"animate-type":s.unref(hV).fade,onClose:y,onEndAnimation:rg[3]||(rg[3]=uI=>og.$emit("end-animation")),onUnmounted:rg[4]||(rg[4]=uI=>og.$emit("unmounted")),onPointerup:iI,onPointerleave:Ug,onTouchend:NC},{default:s.withCtx(()=>{var uI,xI,lC,oA,lu,su,ou,au,du;return[s.createElementVNode("div",Fjg,[s.createElementVNode("div",{ref_key:"sideBarRef",ref:n,class:s.normalizeClass(["slider-modal__side-bar",[{"slider-modal__side-bar_active":s.unref(tl)((uI=i.file)==null?void 0:uI.path)||s.unref(tl)((xI=i.file)==null?void 0:xI.file)}]])},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.sideBarItems,(UC,fe)=>(s.openBlock(),s.createElementBlock("div",{ref_for:!0,ref_key:"miniItemsRef",ref:A,class:s.normalizeClass(["slider-modal__side-bar-item",{"slider-modal__side-bar-item_active":fe===i.sideBarIndex}]),key:fe},[s.createElementVNode("div",{class:"slider-modal__mini-prewiew-wrapper",onClick:Oo=>M(fe)},[s.createVNode(el,{ref_for:!0,ref:"miniPreviewsRef",class:"slider-modal__mini-preview",src:UC,page:fe+1},null,8,["src","page"])],8,zjg),s.createElementVNode("div",Jjg,s.toDisplayString(fe+1),1)],2))),128))],2),s.createElementVNode("div",Ljg,[s.createElementVNode("div",Tjg,[s.createElementVNode("div",{class:"slider-modal__exit-button",onClick:rg[0]||(rg[0]=UC=>og.$emit("close"))},[s.createVNode(Jg,{class:"slider-modal__exit-icon",name:s.unref(dg).leftBig,width:16,height:16},null,8,["name"]),rg[5]||(rg[5]=s.createElementVNode("div",{class:"slider-modal__exit-text"},"Назад",-1))])]),s.createElementVNode("div",vjg,[i.isMobile?(s.openBlock(),s.createElementBlock("div",jjg,s.toDisplayString(i.defaultIndex+1)+" из "+s.toDisplayString(I.items.length),1)):s.createCommentVNode("",!0)]),rg[6]||(rg[6]=s.createElementVNode("div",{class:"slider-modal__mobile-header-block"},null,-1))]),s.createElementVNode("div",{ref_key:"mainRef",ref:a,class:"slider-modal__main",onMousedown:s.withModifiers($,["self"]),onMouseup:s.withModifiers(lg,["self"])},[s.unref(tl)((lC=i.file)==null?void 0:lC.path)||s.unref(tl)((oA=i.file)==null?void 0:oA.file)?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"itemRef",ref:l,class:"slider-modal__item",onMousedown:s.withModifiers($,["self"]),onMouseup:s.withModifiers(lg,["self"]),onWheel:D,onScroll:Gt,onTouchstart:kg,onTouchmove:xC},[i.isMobile?(s.openBlock(!0),s.createElementBlock(s.Fragment,{key:1},s.renderList(i.sideBarItems,(UC,fe)=>(s.openBlock(),s.createElementBlock("div",{key:fe,class:"slider-modal__viewport"},[s.createVNode(el,{ref_for:!0,ref:"miniPreviewsRef",class:"slider-modal__pdf slider-modal__pdf_mobile",src:UC,page:fe+1},null,8,["src","page"])]))),128)):(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"viewportRef",ref:o,class:"slider-modal__viewport",onMousedown:s.withModifiers(Bg,["stop"]),onMousemove:II,onMouseup:cI,onMouseleave:cI},[s.createVNode(el,{class:"slider-modal__pdf",ref_key:"pdfRef",ref:d,src:(lu=i==null?void 0:i.file)==null?void 0:lu.path,page:i.sideBarIndex+1},null,8,["src","page"])],544))],544)):s.unref(ZV)((su=i.file)==null?void 0:su.path)?(s.openBlock(),s.createElementBlock("div",{key:1,ref_key:"itemRef",ref:l,class:"slider-modal__item",onClick:s.withModifiers(y,["self"]),onPointerdown:Fg,onPointermove:WI},[s.createElementVNode("div",{ref_key:"viewportRef",ref:o,class:"slider-modal__viewport",onMousedown:s.withModifiers(Bg,["stop"]),onMousemove:II,onMouseup:cI,onMouseleave:cI},[s.createVNode(jw,{ref_key:"imagePreviewRef",ref:u,class:"slider-modal__image",src:(ou=i.file)==null?void 0:ou.path,onError:rg[1]||(rg[1]=UC=>q(UC,!0))},null,8,["src"])],544)],544)):s.unref(Jh)((au=i.file)==null?void 0:au.path)?(s.openBlock(),s.createElementBlock("div",{key:2,class:"slider-modal__item",onClick:s.withModifiers(y,["self"]),onTouchstart:s.withModifiers(kg,["prevent"]),onTouchmove:s.withModifiers(xC,["prevent"])},[s.createElementVNode("video",{controls:"",playsinline:"","webkit-playsinline":"",class:"slider-modal__video","data-testid":`${I.dataTestid}-Video`,onError:rg[2]||(rg[2]=UC=>q(UC,!0))},[s.createElementVNode("source",{src:((du=i.file)==null?void 0:du.path)??""},null,8,Ojg)],40,xjg)],32)):(s.openBlock(),s.createElementBlock("div",{key:3,class:"slider-modal__item",onClick:s.withModifiers(y,["self"]),onPointerdown:Fg,onPointermove:WI},[s.createElementVNode("img",{class:"slider-modal__image",src:s.unref(gl)},null,8,Qjg)],32)),s.createElementVNode("div",Ujg,[rg[7]||(rg[7]=s.createElementVNode("div",{class:"slider-modal__nav-block"},[s.createElementVNode("br")],-1)),s.createElementVNode("div",Ejg,[I.items.length>1?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[s.createElementVNode("button",{class:"slider-modal__side-button",disabled:b.value,onClick:Q},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).leftBig,width:24,height:24},null,8,["name"])],8,Pjg),s.createVNode(Rjg,{ref_key:"sliderRef",ref:m,class:"slider-modal__bottom-slider","active-index":i.defaultIndex},{default:s.withCtx(()=>[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(I.items,(UC,fe)=>(s.openBlock(),s.createBlock(Hjg,{class:s.normalizeClass(["slider-modal__slide",{"slider-modal__slide_active":fe===i.defaultIndex}]),key:fe,"is-active":fe===i.defaultIndex,onClick:Oo=>R(fe)},{default:s.withCtx(()=>{var Oo;return[s.unref(ZV)(UC.path)?(s.openBlock(),s.createElementBlock("img",{key:0,class:"slider-modal__slide-image",src:UC.path,alt:UC.path,onError:q},null,40,_jg)):s.unref(tl)(UC.path)||s.unref(tl)((Oo=i.file)==null?void 0:Oo.file)?(s.openBlock(),s.createBlock(el,{key:1,class:"slider-modal__slide-image",src:UC.path,page:1},null,8,["src"])):s.unref(Jh)(UC.path)?(s.openBlock(),s.createBlock(Lh,{key:2,class:"slider-modal__slide-image",src:UC.path},null,8,["src"])):(s.openBlock(),s.createElementBlock("img",{key:3,class:"slider-modal__slide-image",src:s.unref(gl)},null,8,$jg))]}),_:2},1032,["class","is-active","onClick"]))),128))]),_:1},8,["active-index"]),s.createElementVNode("button",{class:"slider-modal__side-button",disabled:Z.value,onClick:gg},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).rightBig,width:24,height:24},null,8,["name"])],8,qjg)],64)):s.createCommentVNode("",!0)]),s.createElementVNode("div",gxg,[s.createElementVNode("div",Ixg,[s.createElementVNode("button",{class:"slider-modal__side-button slider-modal__side-button_zoom",disabled:p.value,onClick:H},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).zoomMinus,width:24,height:24},null,8,["name"])],8,Cxg),s.createElementVNode("button",{class:"slider-modal__side-button slider-modal__side-button_zoom",disabled:p.value,onClick:J},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).zoomPlus,width:24,height:24},null,8,["name"])],8,exg),s.createElementVNode("button",{class:"slider-modal__side-button",disabled:w.value,onClick:F},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).reset,width:24,height:24},null,8,["name"])],8,txg)]),s.createElementVNode("div",ixg,[s.createElementVNode("button",{class:"slider-modal__side-button",disabled:B.value,onClick:E},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).uploadCloud,width:24,height:24},null,8,["name"])],8,Axg),s.createElementVNode("button",{class:"slider-modal__side-button slider-modal__side-button_printer",disabled:G.value,onClick:T},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).printer,width:24,height:24},null,8,["name"])],8,nxg)])])])],544)],512)]}),_:1},8,["open","height","width","animate-type"])}}}),[["__scopeId","data-v-da5b7284"]]),oxg=["data-testid"],axg=["data-testid"],dxg=["disabled","data-testid"],cxg=["data-testid"],rxg=["data-testid"],mxg=["src","data-testid"],uxg=["data-testid"],hxg=["data-testid"],bxg=["src"],Zxg=["src","data-testid"],Gxg=["disabled","data-testid"],wV=Vg(s.defineComponent({__name:"Slider",props:{items:{},defaultIndex:{},dataTestid:{default:"Slider"}},setup(C,{expose:g}){const I=C,e=s.reactive({files:I.items.length?I.items:[],file:null,currentIndex:I.defaultIndex||0,extension:null,filePath:null,isShowSliderModal:!1,indexModal:0});s.watch(()=>e.file,()=>{var G;e.filePath=((G=e.file)==null?void 0:G.path)??null},{immediate:!0}),s.watch(()=>I.items,()=>{e.files=I.items.length?I.items:[]});const t=()=>{e.filePath=gl},i=G=>{if(!G)return;const B=e.files.findIndex(p=>G.path===p.path);B!==-1&&(e.indexModal=B,e.isShowSliderModal=!0)},A=()=>{e.isShowSliderModal=!1},n=()=>{var G;return(G=I.items)!=null&&G.length?e.currentIndex===I.items.length-1:!0},l=G=>{if(!G)return null;const B=G.split("?")[0],p=/\.\w+$/,Y=B.match(p);return e.extension=Y?Y[0].replace(".",""):null,e.extension},o=G=>{const B=l(G);return B?Object.values(hh).includes(B.toLowerCase()):!1},a=G=>{const B=l(G);return B?Object.values(bh).includes(B):!1},d=G=>l(G)==="pdf",m=()=>{e.currentIndex--,e.file=e.files[e.currentIndex]},u=()=>{e.currentIndex++,e.file=e.files[e.currentIndex]},b=()=>e.files.length===0,Z=()=>{var G,B,p;return o(((G=e.file)==null?void 0:G.path)??null)==!1&&a(((B=e.file)==null?void 0:B.path)??null)==!1&&d(((p=e.file)==null?void 0:p.path)??null)==!1&&e.files.length>0};s.onMounted(()=>{if(!I.items)return 0;e.files=I.items,I.defaultIndex&&(e.file=e.files[e.currentIndex]),e.file=e.files[e.currentIndex]});const w=G=>{G>=0&&G<e.files.length&&(e.currentIndex=G,e.file=e.files[e.currentIndex])};return s.watch(()=>I.items,()=>{e.files=I.items},{deep:!0}),g({setSlide:w}),(G,B)=>{var p,Y,y,R,M;return s.openBlock(),s.createElementBlock("div",{class:"slider-yui-kit","data-testid":I.dataTestid},[s.createElementVNode("div",{class:"slider-yui-kit__wrapper",ref:"slider-yui-kitWrapperRef","data-testid":`${I.dataTestid}-Wrapper`},[s.createElementVNode("button",{class:"slider-yui-kit__button slider-yui-kit__button--prev",onClick:m,disabled:e.currentIndex===0,"data-testid":`${I.dataTestid}-Prev-Button`},[s.createVNode(Ng,{name:s.unref(dg).leftBig,"data-testid":`${I.dataTestid}-Prev-Icon`},null,8,["name","data-testid"])],8,dxg),s.createElementVNode("div",{class:"slider-yui-kit__slides","data-testid":`${I.dataTestid}-Slides-Container`},[b()?(s.openBlock(),s.createElementBlock("div",{key:0,class:"placeholder-yui-kit no-content","data-testid":`${I.dataTestid}-NoContent-Placeholder`},[s.createElementVNode("img",{src:s.unref(gl),alt:"",width:"111px",height:"111px","data-testid":`${I.dataTestid}-NoContent-Image`},null,8,mxg),s.createElementVNode("p",{"data-testid":`${I.dataTestid}-NoContent-Paragrpah`}," Контент отсутствует ",8,uxg)],8,rxg)):Z()?(s.openBlock(),s.createElementBlock("div",{key:1,class:"placeholder-yui-kit","data-testid":`${I.dataTestid}-Invalid-Extension-Placeholder`},[s.createElementVNode("img",{src:s.unref(gl),alt:"",width:"111px",height:"111px"},null,8,bxg),s.createElementVNode("p",null,"."+s.toDisplayString(e.extension),1)],8,hxg)):(s.openBlock(),s.createElementBlock(s.Fragment,{key:2},[o(((p=e.file)==null?void 0:p.path)??"")?(s.openBlock(),s.createElementBlock("img",{key:0,class:"slider__item",src:e.filePath??"","data-testid":`${I.dataTestid}-Image`,onClick:B[0]||(B[0]=D=>i(e.file)),onError:t},null,40,Zxg)):a(((Y=e.file)==null?void 0:Y.path)??"")?(s.openBlock(),s.createBlock(Lh,{key:1,class:"slider__item",src:((y=e.file)==null?void 0:y.path)??"",onClick:B[1]||(B[1]=D=>i(e.file))},null,8,["src"])):d(((R=e.file)==null?void 0:R.path)??"")?(s.openBlock(),s.createBlock(el,{key:2,class:"slider-yui-kit__pdf-preview slider__item",src:(M=e.file)==null?void 0:M.path,onClick:B[2]||(B[2]=D=>i(e.file))},null,8,["src"])):s.createCommentVNode("",!0)],64))],8,cxg),s.createElementVNode("button",{class:"slider-yui-kit__button slider-yui-kit__button--next",onClick:u,disabled:n(),"data-testid":`${I.dataTestid}-Next-Button`},[s.createVNode(Ng,{name:s.unref(dg).rightBig,"data-testid":`${I.dataTestid}-Next-Icon`},null,8,["name","data-testid"])],8,Gxg)],8,axg),(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[s.createVNode(xw,{open:e.isShowSliderModal,items:e.files,"default-index":e.indexModal,onClose:A},null,8,["open","items","default-index"])]))],8,oxg)}}}),[["__scopeId","data-v-50acfc4d"]]),wxg=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Wxg(C){return wxg.test(C)}function e9(){var C=URL.createObjectURL(new Blob),g=C.toString();return URL.revokeObjectURL(C),g.split(/[:\/]/g).pop().toLowerCase()}e9.valid=Wxg;const Bxg=(C="")=>C+e9();var Th=(C=>(C.small="small",C.medium="medium",C.big="big",C.large="large",C))(Th||{});const pxg=["disabled","data-testid"],yxg=["id","disabled","data-testid"],Yxg=["for","data-testid"],Vxg=s.defineComponent({__name:"Toggle",props:s.mergeModels({disabled:{type:Boolean,default:!1},backgroundColor:{},type:{default:Th.small},dataTestid:{default:"Toggle"}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:s.mergeModels(["change"],["update:modelValue"]),setup(C,{emit:g}){const I=C,e=g,t=s.useModel(C,"modelValue"),i=Bxg(),A=s.computed(()=>({"toggle-yui-kit":!0,"toggle-yui-kit_small":I.type===Th.small,"toggle-yui-kit_medium":I.type===Th.medium,"toggle-yui-kit_large":I.type===Th.large})),n=s.computed(()=>({backgroundColor:I.backgroundColor})),l=()=>e("change",!!t.value);return(o,a)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(A.value),disabled:I.disabled,style:s.normalizeStyle(n.value),"data-testid":`${I.dataTestid}-Toggle`},[s.withDirectives(s.createElementVNode("input",{class:"toggle-yui-kit-input",id:s.unref(i),type:"checkbox",disabled:C.disabled,"onUpdate:modelValue":a[0]||(a[0]=d=>t.value=d),onChange:l,"data-testid":`${I.dataTestid}-Input`},null,40,yxg),[[s.vModelCheckbox,t.value]]),s.createElementVNode("label",{class:"toggle-yui-kit-label",for:s.unref(i),"data-testid":`${I.dataTestid}-Label`},null,8,Yxg)],14,pxg))}}),Ow=Vg(Vxg,[["__scopeId","data-v-38cc7c65"]]);/*!
1336
+ `,Jg="max-height: 95vh; margin-bottom: 10px; max-width: 100%"),Sjg({printable:(lC=i.file)==null?void 0:lC.path,type:og,style:rg,imageStyle:Jg})},E=()=>{var og,rg,Jg;(og=i.file)!=null&&og.path&&fjg((rg=i.file)==null?void 0:rg.path,(Jg=i.file)==null?void 0:Jg.name)},q=(og,rg=!1)=>{const Jg=og.target;Jg&&(Jg.src=gl),rg&&(i.isErrorFile=!0)},gg=()=>{m.value&&wt(m.value.nextSlide())},Q=()=>{m.value&&wt(m.value.prevSlide())},$=og=>{if(i.isMobile)return;const rg=og.target;(rg===a.value||rg===l.value)&&(i.isClickOnExit=!0)},lg=og=>{const rg=og.target;(rg===a.value||rg===l.value)&&y(),i.isClickOnExit=!1},Bg=og=>{i.isDragging=!0,i.startX=og.clientX-i.offsetX,i.startY=og.clientY-i.offsetY},II=og=>{i.isDragging&&(i.offsetX=og.clientX-i.startX,i.offsetY=og.clientY-i.startY,QA(),requestAnimationFrame(()=>{o.value&&qI(Y.value,o.value)}))},cI=()=>{i.isDragging=!1},Fg=og=>{i.isMobile&&(i.startXForMobile=og.clientX,i.startYForMobile=og.clientY,i.isPointerActive=!0)},kg=og=>{i.isMobile&&(i.startXForMobile=og.touches[0].clientX,i.startYForMobile=og.touches[0].clientY,i.isPointerActive=!0)},Ug=()=>{i.isMobile&&(Qt(),OC())},iI=og=>{var lC,oA;if(!i.isMobile)return;const rg=og.clientX,Jg=og.clientY,uI=Math.abs(rg-i.startXForMobile),xI=Jg-i.startYForMobile;i.isExistSwipe&&xI>GV&&xI>uI&&e("close"),i.isChangeItemSwipe&&m.value&&(i.isSwipeNextSlide&&wt((lC=m.value)==null?void 0:lC.nextSlide()),i.isSwipePrevSlide&&wt((oA=m.value)==null?void 0:oA.prevSlide())),Qt(),s.nextTick(()=>{OC()})},NC=og=>{var lC,oA;if(!i.isMobile)return;const rg=og.changedTouches[0].clientX,Jg=og.changedTouches[0].clientY,uI=Math.abs(rg-i.startXForMobile),xI=Jg-i.startYForMobile;i.isExistSwipe&&xI>GV&&xI>uI&&e("close"),i.isChangeItemSwipe&&m.value&&(i.isSwipeNextSlide&&wt((lC=m.value)==null?void 0:lC.nextSlide()),i.isSwipePrevSlide&&wt((oA=m.value)==null?void 0:oA.prevSlide())),Qt(),s.nextTick(()=>{OC()})},WI=og=>{if(!i.isMobile||!i.isPointerActive)return;const rg=og.clientY-i.startYForMobile,Jg=og.clientX-i.startXForMobile;lA(Jg,rg)},xC=og=>{if(!i.isMobile)return;const rg=og.touches[0].clientX,Jg=og.touches[0].clientY,uI=rg-i.startXForMobile,xI=Jg-i.startYForMobile;lA(uI,xI)},Gt=og=>{const rg=og.target;!i.isMobile||!rg||rg.scrollHeight<=rg.clientHeight||!i.isExitScrollActive&&rg.scrollTop===0&&og.preventDefault()},lA=(og,rg)=>{const Jg=Math.abs(og);if(Jg<rg&&rg>C9&&!i.isChangeItemSwipe&&l.value&&l.value.scrollTop===0&&(i.isExistSwipe=!0),Jg>rg&&Jg>sxg&&!i.isExistSwipe&&(i.isChangeItemSwipe=!0),i.isExistSwipe){const uI=Math.max(0,1-(rg-C9)/GV);requestAnimationFrame(()=>{a.value&&qI({opacity:uI},a.value)})}if(i.isChangeItemSwipe&&Jg>lxg){const uI=i.defaultIndex===I.items.length-1,xI=i.defaultIndex===0;if(og>0){if(xI)return;i.isSwipePrevSlide=!0}if(og<0){if(uI)return;i.isSwipeNextSlide=!0}}},OC=()=>{requestAnimationFrame(()=>{a.value&&qI({opacity:1},a.value)})},Qt=()=>{i.isPointerActive=!1,i.isExistSwipe=!1,i.isSwipeNextSlide=!1,i.isSwipePrevSlide=!1,i.isChangeItemSwipe=!1},QA=()=>{if(!l.value||!o.value)return;const og=l.value.clientWidth,rg=l.value.clientHeight,Jg=o.value.offsetWidth*i.zoomValue,uI=o.value.offsetHeight*i.zoomValue,xI=Math.max(0,(Jg-og)/2);i.offsetX=Math.min(xI,Math.max(-xI,i.offsetX));const lC=Math.max(0,(uI-rg)/2);i.offsetY=Math.min(lC,Math.max(-lC,i.offsetY))},be=og=>{const rg=i.zoomValue;i.zoomValue+=og?1:-1,i.zoomValue=Math.min(Math.max(1,i.zoomValue),3);const Jg=i.zoomValue;if(rg===Jg)return;const uI=Jg/rg;i.offsetX*=uI,i.offsetY*=uI,QA(),o.value&&(u.value||d.value)&&qI(Y.value,o.value)},wt=og=>{I.items[og]&&(i.defaultIndex=og,QC(),i.file=I.items[og])},Au=og=>{let rg=i.sideBarIndex;og>0?(rg=i.sideBarIndex+1,rg=Math.min(i.sideBarLength-1,rg)):(rg=i.sideBarIndex-1,rg=Math.max(0,rg)),i.sideBarIndex=rg},Ut=()=>{s.nextTick(()=>{var og,rg;i.file&&(tl((og=i.file)==null?void 0:og.path)||tl((rg=i.file)==null?void 0:rg.file))&&(i.isErrorFile=!0,BZ())})},nu=()=>{s.nextTick(()=>{if(!A.value||!n.value)return;const og=A.value[i.sideBarIndex];bV(og,n.value)})},BZ=async()=>{var og,rg;try{if(!i.file)return;const Jg=Ra.getCache(i.file.path);let uI;if(Jg?uI=Jg:uI=await $Y((og=i.file)==null?void 0:og.path).promise,!uI){i.isErrorFile=!0;return}i.sideBarLength=uI.numPages,i.sideBarItems=new Array(uI.numPages).fill(((rg=i.file)==null?void 0:rg.path)??""),Ra.setCache(i.file.path,uI),Wt(0),i.isErrorFile=!1}catch(Jg){console.error(Jg),i.isErrorFile=!0}},Wt=async(og=0)=>{i.sideBarIndex=og},QC=()=>{i.sideBarItems=[],i.sideBarIndex=0,i.sideBarLength=0},sA=()=>{i.isMobile=t.matches};return s.onMounted(()=>{sA(),t.addEventListener("change",sA)}),s.onUnmounted(()=>{QC(),t.removeEventListener("change",sA)}),(og,rg)=>{const Jg=s.resolveComponent("YIcon");return s.openBlock(),s.createBlock(zh,{position:"center",class:"slider-modal",ref:"modalRef",open:C.open,height:C.height,width:C.width,"animate-type":s.unref(hV).fade,onClose:y,onEndAnimation:rg[3]||(rg[3]=uI=>og.$emit("end-animation")),onUnmounted:rg[4]||(rg[4]=uI=>og.$emit("unmounted")),onPointerup:iI,onPointerleave:Ug,onTouchend:NC},{default:s.withCtx(()=>{var uI,xI,lC,oA,lu,su,ou,au,du;return[s.createElementVNode("div",Fjg,[s.createElementVNode("div",{ref_key:"sideBarRef",ref:n,class:s.normalizeClass(["slider-modal__side-bar",[{"slider-modal__side-bar_active":s.unref(tl)((uI=i.file)==null?void 0:uI.path)||s.unref(tl)((xI=i.file)==null?void 0:xI.file)}]])},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.sideBarItems,(UC,fe)=>(s.openBlock(),s.createElementBlock("div",{ref_for:!0,ref_key:"miniItemsRef",ref:A,class:s.normalizeClass(["slider-modal__side-bar-item",{"slider-modal__side-bar-item_active":fe===i.sideBarIndex}]),key:fe},[s.createElementVNode("div",{class:"slider-modal__mini-prewiew-wrapper",onClick:Oo=>M(fe)},[s.createVNode(el,{ref_for:!0,ref:"miniPreviewsRef",class:"slider-modal__mini-preview",src:UC,page:fe+1},null,8,["src","page"])],8,zjg),s.createElementVNode("div",Jjg,s.toDisplayString(fe+1),1)],2))),128))],2),i.isMobile?(s.openBlock(),s.createElementBlock("div",Ljg,[s.createElementVNode("div",Tjg,[s.createElementVNode("div",{class:"slider-modal__exit-button",onClick:rg[0]||(rg[0]=UC=>og.$emit("close"))},[s.createVNode(Jg,{class:"slider-modal__exit-icon",name:s.unref(dg).leftBig,width:16,height:16},null,8,["name"]),rg[5]||(rg[5]=s.createElementVNode("div",{class:"slider-modal__exit-text"},"Назад",-1))])]),s.createElementVNode("div",vjg,[s.createElementVNode("div",jjg,s.toDisplayString(i.defaultIndex+1)+" из "+s.toDisplayString(I.items.length),1)]),rg[6]||(rg[6]=s.createElementVNode("div",{class:"slider-modal__mobile-header-block"},null,-1))])):s.createCommentVNode("",!0),s.createElementVNode("div",{ref_key:"mainRef",ref:a,class:"slider-modal__main",onMousedown:s.withModifiers($,["self"]),onMouseup:s.withModifiers(lg,["self"])},[s.unref(tl)((lC=i.file)==null?void 0:lC.path)||s.unref(tl)((oA=i.file)==null?void 0:oA.file)?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"itemRef",ref:l,class:"slider-modal__item",onMousedown:s.withModifiers($,["self"]),onMouseup:s.withModifiers(lg,["self"]),onWheel:D,onScroll:Gt,onTouchstart:kg,onTouchmove:xC},[i.isMobile?(s.openBlock(!0),s.createElementBlock(s.Fragment,{key:1},s.renderList(i.sideBarItems,(UC,fe)=>(s.openBlock(),s.createElementBlock("div",{key:fe,class:"slider-modal__viewport"},[s.createVNode(el,{ref_for:!0,ref:"miniPreviewsRef",class:"slider-modal__pdf slider-modal__pdf_mobile",src:UC,page:fe+1},null,8,["src","page"])]))),128)):(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"viewportRef",ref:o,class:"slider-modal__viewport",onMousedown:s.withModifiers(Bg,["stop"]),onMousemove:II,onMouseup:cI,onMouseleave:cI},[s.createVNode(el,{class:"slider-modal__pdf",ref_key:"pdfRef",ref:d,src:(lu=i==null?void 0:i.file)==null?void 0:lu.path,page:i.sideBarIndex+1},null,8,["src","page"])],544))],544)):s.unref(ZV)((su=i.file)==null?void 0:su.path)?(s.openBlock(),s.createElementBlock("div",{key:1,ref_key:"itemRef",ref:l,class:"slider-modal__item",onClick:s.withModifiers(y,["self"]),onPointerdown:Fg,onPointermove:WI},[s.createElementVNode("div",{ref_key:"viewportRef",ref:o,class:"slider-modal__viewport",onMousedown:s.withModifiers(Bg,["stop"]),onMousemove:II,onMouseup:cI,onMouseleave:cI},[s.createVNode(jw,{ref_key:"imagePreviewRef",ref:u,class:"slider-modal__image",src:(ou=i.file)==null?void 0:ou.path,onError:rg[1]||(rg[1]=UC=>q(UC,!0))},null,8,["src"])],544)],544)):s.unref(Jh)((au=i.file)==null?void 0:au.path)?(s.openBlock(),s.createElementBlock("div",{key:2,class:"slider-modal__item",onClick:s.withModifiers(y,["self"]),onTouchstart:s.withModifiers(kg,["prevent"]),onTouchmove:s.withModifiers(xC,["prevent"])},[s.createElementVNode("video",{controls:"",playsinline:"","webkit-playsinline":"",class:"slider-modal__video","data-testid":`${I.dataTestid}-Video`,onError:rg[2]||(rg[2]=UC=>q(UC,!0))},[s.createElementVNode("source",{src:((du=i.file)==null?void 0:du.path)??""},null,8,Ojg)],40,xjg)],32)):(s.openBlock(),s.createElementBlock("div",{key:3,class:"slider-modal__item",onClick:s.withModifiers(y,["self"]),onPointerdown:Fg,onPointermove:WI},[s.createElementVNode("img",{class:"slider-modal__image",src:s.unref(gl)},null,8,Qjg)],32)),s.createElementVNode("div",Ujg,[rg[7]||(rg[7]=s.createElementVNode("div",{class:"slider-modal__nav-block"},[s.createElementVNode("br")],-1)),s.createElementVNode("div",Ejg,[I.items.length>1?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[s.createElementVNode("button",{class:"slider-modal__side-button",disabled:b.value,onClick:Q},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).leftBig,width:24,height:24},null,8,["name"])],8,Pjg),s.createVNode(Rjg,{ref_key:"sliderRef",ref:m,class:"slider-modal__bottom-slider","active-index":i.defaultIndex},{default:s.withCtx(()=>[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(I.items,(UC,fe)=>(s.openBlock(),s.createBlock(Hjg,{class:s.normalizeClass(["slider-modal__slide",{"slider-modal__slide_active":fe===i.defaultIndex}]),key:fe,"is-active":fe===i.defaultIndex,onClick:Oo=>R(fe)},{default:s.withCtx(()=>{var Oo;return[s.unref(ZV)(UC.path)?(s.openBlock(),s.createElementBlock("img",{key:0,class:"slider-modal__slide-image",src:UC.path,alt:UC.path,onError:q},null,40,_jg)):s.unref(tl)(UC.path)||s.unref(tl)((Oo=i.file)==null?void 0:Oo.file)?(s.openBlock(),s.createBlock(el,{key:1,class:"slider-modal__slide-image",src:UC.path,page:1},null,8,["src"])):s.unref(Jh)(UC.path)?(s.openBlock(),s.createBlock(Lh,{key:2,class:"slider-modal__slide-image",src:UC.path},null,8,["src"])):(s.openBlock(),s.createElementBlock("img",{key:3,class:"slider-modal__slide-image",src:s.unref(gl)},null,8,$jg))]}),_:2},1032,["class","is-active","onClick"]))),128))]),_:1},8,["active-index"]),s.createElementVNode("button",{class:"slider-modal__side-button",disabled:Z.value,onClick:gg},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).rightBig,width:24,height:24},null,8,["name"])],8,qjg)],64)):s.createCommentVNode("",!0)]),s.createElementVNode("div",gxg,[s.createElementVNode("div",Ixg,[s.createElementVNode("button",{class:"slider-modal__side-button slider-modal__side-button_zoom",disabled:p.value,onClick:H},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).zoomMinus,width:24,height:24},null,8,["name"])],8,Cxg),s.createElementVNode("button",{class:"slider-modal__side-button slider-modal__side-button_zoom",disabled:p.value,onClick:J},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).zoomPlus,width:24,height:24},null,8,["name"])],8,exg),s.createElementVNode("button",{class:"slider-modal__side-button",disabled:w.value,onClick:F},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).reset,width:24,height:24},null,8,["name"])],8,txg)]),s.createElementVNode("div",ixg,[s.createElementVNode("button",{class:"slider-modal__side-button",disabled:B.value,onClick:E},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).uploadCloud,width:24,height:24},null,8,["name"])],8,Axg),s.createElementVNode("button",{class:"slider-modal__side-button slider-modal__side-button_printer",disabled:G.value,onClick:T},[s.createVNode(Ng,{class:"slider-modal__icon",name:s.unref(dg).printer,width:24,height:24},null,8,["name"])],8,nxg)])])])],544)],512)]}),_:1},8,["open","height","width","animate-type"])}}}),[["__scopeId","data-v-175e7a1f"]]),oxg=["data-testid"],axg=["data-testid"],dxg=["disabled","data-testid"],cxg=["data-testid"],rxg=["data-testid"],mxg=["src","data-testid"],uxg=["data-testid"],hxg=["data-testid"],bxg=["src"],Zxg=["src","data-testid"],Gxg=["disabled","data-testid"],wV=Vg(s.defineComponent({__name:"Slider",props:{items:{},defaultIndex:{},dataTestid:{default:"Slider"}},setup(C,{expose:g}){const I=C,e=s.reactive({files:I.items.length?I.items:[],file:null,currentIndex:I.defaultIndex||0,extension:null,filePath:null,isShowSliderModal:!1,indexModal:0});s.watch(()=>e.file,()=>{var G;e.filePath=((G=e.file)==null?void 0:G.path)??null},{immediate:!0}),s.watch(()=>I.items,()=>{e.files=I.items.length?I.items:[]});const t=()=>{e.filePath=gl},i=G=>{if(!G)return;const B=e.files.findIndex(p=>G.path===p.path);B!==-1&&(e.indexModal=B,e.isShowSliderModal=!0)},A=()=>{e.isShowSliderModal=!1},n=()=>{var G;return(G=I.items)!=null&&G.length?e.currentIndex===I.items.length-1:!0},l=G=>{if(!G)return null;const B=G.split("?")[0],p=/\.\w+$/,Y=B.match(p);return e.extension=Y?Y[0].replace(".",""):null,e.extension},o=G=>{const B=l(G);return B?Object.values(hh).includes(B.toLowerCase()):!1},a=G=>{const B=l(G);return B?Object.values(bh).includes(B):!1},d=G=>l(G)==="pdf",m=()=>{e.currentIndex--,e.file=e.files[e.currentIndex]},u=()=>{e.currentIndex++,e.file=e.files[e.currentIndex]},b=()=>e.files.length===0,Z=()=>{var G,B,p;return o(((G=e.file)==null?void 0:G.path)??null)==!1&&a(((B=e.file)==null?void 0:B.path)??null)==!1&&d(((p=e.file)==null?void 0:p.path)??null)==!1&&e.files.length>0};s.onMounted(()=>{if(!I.items)return 0;e.files=I.items,I.defaultIndex&&(e.file=e.files[e.currentIndex]),e.file=e.files[e.currentIndex]});const w=G=>{G>=0&&G<e.files.length&&(e.currentIndex=G,e.file=e.files[e.currentIndex])};return s.watch(()=>I.items,()=>{e.files=I.items},{deep:!0}),g({setSlide:w}),(G,B)=>{var p,Y,y,R,M;return s.openBlock(),s.createElementBlock("div",{class:"slider-yui-kit","data-testid":I.dataTestid},[s.createElementVNode("div",{class:"slider-yui-kit__wrapper",ref:"slider-yui-kitWrapperRef","data-testid":`${I.dataTestid}-Wrapper`},[s.createElementVNode("button",{class:"slider-yui-kit__button slider-yui-kit__button--prev",onClick:m,disabled:e.currentIndex===0,"data-testid":`${I.dataTestid}-Prev-Button`},[s.createVNode(Ng,{name:s.unref(dg).leftBig,"data-testid":`${I.dataTestid}-Prev-Icon`},null,8,["name","data-testid"])],8,dxg),s.createElementVNode("div",{class:"slider-yui-kit__slides","data-testid":`${I.dataTestid}-Slides-Container`},[b()?(s.openBlock(),s.createElementBlock("div",{key:0,class:"placeholder-yui-kit no-content","data-testid":`${I.dataTestid}-NoContent-Placeholder`},[s.createElementVNode("img",{src:s.unref(gl),alt:"",width:"111px",height:"111px","data-testid":`${I.dataTestid}-NoContent-Image`},null,8,mxg),s.createElementVNode("p",{"data-testid":`${I.dataTestid}-NoContent-Paragrpah`}," Контент отсутствует ",8,uxg)],8,rxg)):Z()?(s.openBlock(),s.createElementBlock("div",{key:1,class:"placeholder-yui-kit","data-testid":`${I.dataTestid}-Invalid-Extension-Placeholder`},[s.createElementVNode("img",{src:s.unref(gl),alt:"",width:"111px",height:"111px"},null,8,bxg),s.createElementVNode("p",null,"."+s.toDisplayString(e.extension),1)],8,hxg)):(s.openBlock(),s.createElementBlock(s.Fragment,{key:2},[o(((p=e.file)==null?void 0:p.path)??"")?(s.openBlock(),s.createElementBlock("img",{key:0,class:"slider__item",src:e.filePath??"","data-testid":`${I.dataTestid}-Image`,onClick:B[0]||(B[0]=D=>i(e.file)),onError:t},null,40,Zxg)):a(((Y=e.file)==null?void 0:Y.path)??"")?(s.openBlock(),s.createBlock(Lh,{key:1,class:"slider__item",src:((y=e.file)==null?void 0:y.path)??"",onClick:B[1]||(B[1]=D=>i(e.file))},null,8,["src"])):d(((R=e.file)==null?void 0:R.path)??"")?(s.openBlock(),s.createBlock(el,{key:2,class:"slider-yui-kit__pdf-preview slider__item",src:(M=e.file)==null?void 0:M.path,onClick:B[2]||(B[2]=D=>i(e.file))},null,8,["src"])):s.createCommentVNode("",!0)],64))],8,cxg),s.createElementVNode("button",{class:"slider-yui-kit__button slider-yui-kit__button--next",onClick:u,disabled:n(),"data-testid":`${I.dataTestid}-Next-Button`},[s.createVNode(Ng,{name:s.unref(dg).rightBig,"data-testid":`${I.dataTestid}-Next-Icon`},null,8,["name","data-testid"])],8,Gxg)],8,axg),(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[s.createVNode(xw,{open:e.isShowSliderModal,items:e.files,"default-index":e.indexModal,onClose:A},null,8,["open","items","default-index"])]))],8,oxg)}}}),[["__scopeId","data-v-50acfc4d"]]),wxg=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Wxg(C){return wxg.test(C)}function e9(){var C=URL.createObjectURL(new Blob),g=C.toString();return URL.revokeObjectURL(C),g.split(/[:\/]/g).pop().toLowerCase()}e9.valid=Wxg;const Bxg=(C="")=>C+e9();var Th=(C=>(C.small="small",C.medium="medium",C.big="big",C.large="large",C))(Th||{});const pxg=["disabled","data-testid"],yxg=["id","disabled","data-testid"],Yxg=["for","data-testid"],Vxg=s.defineComponent({__name:"Toggle",props:s.mergeModels({disabled:{type:Boolean,default:!1},backgroundColor:{},type:{default:Th.small},dataTestid:{default:"Toggle"}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:s.mergeModels(["change"],["update:modelValue"]),setup(C,{emit:g}){const I=C,e=g,t=s.useModel(C,"modelValue"),i=Bxg(),A=s.computed(()=>({"toggle-yui-kit":!0,"toggle-yui-kit_small":I.type===Th.small,"toggle-yui-kit_medium":I.type===Th.medium,"toggle-yui-kit_large":I.type===Th.large})),n=s.computed(()=>({backgroundColor:I.backgroundColor})),l=()=>e("change",!!t.value);return(o,a)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(A.value),disabled:I.disabled,style:s.normalizeStyle(n.value),"data-testid":`${I.dataTestid}-Toggle`},[s.withDirectives(s.createElementVNode("input",{class:"toggle-yui-kit-input",id:s.unref(i),type:"checkbox",disabled:C.disabled,"onUpdate:modelValue":a[0]||(a[0]=d=>t.value=d),onChange:l,"data-testid":`${I.dataTestid}-Input`},null,40,yxg),[[s.vModelCheckbox,t.value]]),s.createElementVNode("label",{class:"toggle-yui-kit-label",for:s.unref(i),"data-testid":`${I.dataTestid}-Label`},null,8,Yxg)],14,pxg))}}),Ow=Vg(Vxg,[["__scopeId","data-v-38cc7c65"]]);/*!
1337
1337
  * perfect-scrollbar v1.5.3
1338
1338
  * Copyright 2021 Hyunje Jun, MDBootstrap and Contributors
1339
1339
  * Licensed under MIT