dascom-le-editor 0.0.50 → 0.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/editor.js +1 -1
- package/dist/editor.umd.cjs +2 -2
- package/dist/{main-CQ7DTA4w.js → main-C1gk8J06.js} +2103 -2103
- package/dist/{pdf-7VRhAymd.js → pdf-CO2wY_nI.js} +1 -1
- package/package.json +1 -1
package/dist/editor.umd.cjs
CHANGED
|
@@ -927,7 +927,7 @@ void main() {
|
|
|
927
927
|
`+(rg.length?"<defs>"+rg.join("")+"</defs>":"")+(/^[0-9A-Fa-f]{6}$/.test(""+$g)?'<rect width="100%" height="100%" fill="#'+$g+`" />
|
|
928
928
|
`:"")+Gg+Cg+`</svg>
|
|
929
929
|
`}};function wg(Gg,Zg){Gg+=pg,Zg+=fg;var $g=tg*Gg+eg*Zg+gg*(mg-1)+ig*(bg-1),Bg=ng*Gg+og*Zg+ag*(mg-1)+sg*(bg-1);return""+(($g|0)==$g?$g:$g.toFixed(2))+" "+((Bg|0)==Bg?Bg:Bg.toFixed(2))}}var FontLib=(function(){var tg=[],eg={},gg={},ig={},ng=0;return ig.next=ig,ig.prev=ig,{lookup:ag,monochrome:sg,getglyph:Ig,getpaths:Cg,loadFont:og};function og(lg){var Ag=100,rg=100,cg=null;if(arguments.length==2)cg=arguments[1];else if(arguments.length==3)Ag=rg=+arguments[1]||100,cg=arguments[2];else if(arguments.length==4)rg=+arguments[1]||100,Ag=+arguments[2]||100,cg=arguments[3];else throw new Error("bwipjs: loadFont: invalid number of arguments");var ug=STBTT.InitFont(toUint8Array(cg));ug.bwipjs_name=lg,ug.bwipjs_multx=Ag,ug.bwipjs_multy=rg;var dg=tg.push(ug)-1;return eg[lg.toUpperCase()]=dg,dg}function ag(lg){var Ag=eg[lg.toUpperCase()];return Ag===void 0?1:Ag}function sg(lg){if(lg)throw new Error("bwipjs: monochrome fonts not implemented")}function Ig(lg,Ag,rg,cg){lg=lg|0,Ag=Ag|0,rg=+rg,cg=+cg,(!rg||rg<8)&&(rg=8),(!cg||cg<8)&&(cg=rg),(lg<0||lg>=tg.length)&&(lg=1),(!Ag||Ag<32)&&(Ag=32);var ug=""+lg+"c"+Ag+"w"+rg+"h"+cg,hg=gg[ug];if(hg){hg.prev.next=hg.next,hg.next.prev=hg.prev;var bg=ig;return bg.next.prev=hg,hg.next=bg.next,hg.prev=bg,bg.next=hg,hg}var dg=tg[lg],hg=STBTT.GetGlyph(dg,Ag,rg*dg.bwipjs_multx/100,cg*dg.bwipjs_multy/100)||STBTT.GetGlyph(dg,0,rg*dg.bwipjs_multx/100,cg*dg.bwipjs_multy/100);if(hg.bytes=hg.pixels,hg.cachekey=ug,hg.offset=0,ng>250){var bg=ig,mg=bg.prev;mg.prev.next=bg,bg.prev=mg.prev,mg.next=mg.prev=null,delete gg[mg.cachekey]}else ng++;gg[ug]=hg;var bg=ig;return bg.next.prev=hg,hg.next=bg.next,hg.prev=bg,bg.next=hg,hg}function Cg(lg,Ag,rg,cg){lg=lg|0,Ag=Ag|0,rg=+rg,cg=+cg,(!rg||rg<8)&&(rg=8),(!cg||cg<8)&&(cg=rg),(lg<0||lg>=tg.length)&&(lg=1),(!Ag||Ag<32)&&(Ag=32);var ug=tg[lg];return STBTT.GetPaths(ug,Ag,rg*ug.bwipjs_multx/100,cg*ug.bwipjs_multy/100)}})();function LoadFont(){return FontLib.loadFont.apply(FontLib,Array.prototype.slice.call(arguments))}var STBTT=(function(){var tg=1,eg=2,gg=3,ig=4,ng=0,og=3,ag=1,sg=10,Ig=Math.floor,Cg=Math.ceil,lg=Math.sqrt,Ag=Math.abs;function rg(Lg){for(var Fg=[],sa=0;sa<Lg;sa++)Fg.push({});return Fg}function cg(Lg){return Lg[Lg.cursor++]||0}function ug(Lg){return Lg[Lg.cursor]}function dg(Lg,Fg){Lg.cursor=Fg>Lg.length||Fg<0?Lg.length:Fg}function hg(Lg,Fg){dg(Lg,Lg.cursor+Fg)}function mg(Lg,Fg){for(var sa=0,cs=0;cs<Fg;cs++)sa=sa<<8|cg(Lg);return sa}function bg(){return{length:0}}function pg(Lg,Fg,sa){if(Fg<0||sa<0||Fg>Lg.length||sa>Lg.length-Fg)return bg();var cs=Lg.subarray(Fg,Fg+sa);return cs.cursor=0,cs}function fg(Lg){var Fg=Lg.cursor,sa=mg(Lg,2);if(sa){var cs=cg(Lg);hg(Lg,cs*sa),hg(Lg,mg(Lg,cs)-1)}return pg(Lg,Fg,Lg.cursor-Fg)}function wg(Lg){var Fg=cg(Lg);return Fg>=32&&Fg<=246?Fg-139:Fg>=247&&Fg<=250?(Fg-247)*256+cg(Lg)+108:Fg>=251&&Fg<=254?-(Fg-251)*256-cg(Lg)-108:Fg==28?mg(Lg,2):Fg==29?mg(Lg,4):0}function Gg(Lg){var Fg=ug(Lg);if(Fg==30)for(hg(Lg,1);Lg.cursor<Lg.length;){var sa=cg(Lg);if((sa&15)==15||sa>>4==15)break}else wg(Lg)}function Zg(Lg,Fg){for(dg(Lg,0);Lg.cursor<Lg.length;){for(var sa=Lg.cursor,cs,xg;ug(Lg)>=28;)Gg(Lg);if(cs=Lg.cursor,xg=cg(Lg),xg==12&&(xg=cg(Lg)|256),xg==Fg)return pg(Lg,sa,cs-sa)}return pg(Lg,0,0)}function $g(Lg,Fg,sa,cs){for(var xg=Zg(Lg,Fg),lo=0;lo<sa&&xg.cursor<xg.length;lo++)cs[lo]=wg(xg)}function Bg(Lg,Fg,sa){var cs=Zg(Lg,Fg);return cs.cursor<cs.length&&(sa=wg(cs)),sa}function Wg(Lg){return dg(Lg,0),mg(Lg,2)}function yg(Lg,Fg){var sa,cs,xg,lo;return dg(Lg,0),sa=mg(Lg,2),cs=cg(Lg),hg(Lg,Fg*cs),xg=mg(Lg,cs),lo=mg(Lg,cs),pg(Lg,2+(sa+1)*cs+xg,lo-xg)}function Ng(Lg){return Lg&32768?(4294901760|Lg)>>0:Lg}function vg(Lg,Fg){return Lg[Fg]*256+Lg[Fg+1]}function Sg(Lg,Fg){var sa=Lg[Fg]*256+Lg[Fg+1];return sa&32768?(4294901760|sa)>>0:sa}function Vg(Lg,Fg){return(Lg[Fg]<<24)+(Lg[Fg+1]<<16)+(Lg[Fg+2]<<8)+Lg[Fg+3]}function Xg(Lg,Fg,sa){for(var cs=vg(Lg,Fg+4),xg=Fg+12,lo=0;lo<cs;++lo){var oa=xg+16*lo;if(Lg[oa]==sa[0]&&Lg[oa+1]==sa[1]&&Lg[oa+2]==sa[2]&&Lg[oa+3]==sa[3])return Vg(Lg,oa+8)}return 0}function Yg(Lg,Fg){var sa=[0,0];if($g(Fg,18,2,sa),!sa[1]||!sa[0])return bg();var cs=pg(Lg,sa[1],sa[0]),xg=Bg(cs,19,0);return xg?(dg(Lg,sa[1]+xg),fg(Lg)):bg()}function Hg(Lg,Fg,sa){var cs,xg,lo,oa;if(Lg.data=Fg,Lg.fontstart=sa,Lg.cff=bg(),cs=Xg(Fg,sa,[99,109,97,112]),Lg.loca=Xg(Fg,sa,[108,111,99,97]),Lg.head=Xg(Fg,sa,[104,101,97,100]),Lg.glyf=Xg(Fg,sa,[103,108,121,102]),Lg.hhea=Xg(Fg,sa,[104,104,101,97]),Lg.hmtx=Xg(Fg,sa,[104,109,116,120]),Lg.kern=Xg(Fg,sa,[107,101,114,110]),!cs||!Lg.head||!Lg.hhea||!Lg.hmtx)return 0;if(Lg.glyf){if(!Lg.loca)return 0}else{var no,co,va,nI,ga=2,_g=0,La=0,aI=0;if(nI=Xg(Fg,sa,[67,70,70,32]),!nI||(Lg.fontdicts=bg(),Lg.fdselect=bg(),Lg.cff=Fg.subarray(nI),Lg.cff.cursor=0,no=Lg.cff,hg(no,2),dg(no,cg(no)),fg(no),va=fg(no),co=yg(va,0),fg(no),Lg.gsubrs=fg(no),_g=Bg(co,17,_g),ga=Bg(co,262,ga),La=Bg(co,292,La),aI=Bg(co,293,aI),Lg.subrs=Yg(no,co),ga!=2)||_g==0)return 0;if(La){if(!aI)return 0;dg(no,La),Lg.fontdicts=fg(no),Lg.fdselect=pg(no,aI,no.length-aI)}dg(no,_g),Lg.charstrings=fg(no)}for(xg=Xg(Fg,sa,[109,97,120,112]),xg?Lg.numGlyphs=vg(Fg,xg+4):Lg.numGlyphs=65535,oa=vg(Fg,cs+2),Lg.index_map=0,lo=0;lo<oa;++lo){var hs=cs+4+8*lo;switch(vg(Fg,hs)){case og:switch(vg(Fg,hs+2)){case ag:case sg:Lg.index_map=cs+Vg(Fg,hs+4);break}break;case ng:Lg.index_map=cs+Vg(Fg,hs+4);break}}return Lg.index_map==0?0:(Lg.indexToLocFormat=vg(Fg,Lg.head+50),1)}function kg(Lg,Fg){var sa=Lg.data,cs=Lg.index_map,xg=vg(sa,cs+0);if(xg==0){var lo=vg(sa,cs+2);return Fg<lo-6?sa[cs+6+Fg]:0}else if(xg==6){var oa=vg(sa,cs+6),no=vg(sa,cs+8);return Fg>=oa&&Fg<oa+no?vg(sa,cs+10+(Fg-oa)*2):0}else{if(xg==2)return 0;if(xg==4){var co=vg(sa,cs+6)>>1,va=vg(sa,cs+8)>>1,nI=vg(sa,cs+10),ga=vg(sa,cs+12)>>1,_g=cs+14,La=_g;if(Fg>65535)return 0;for(Fg>=vg(sa,La+ga*2)&&(La+=ga*2),La-=2;nI;){va>>=1;var aI=vg(sa,La+va*2);Fg>aI&&(La+=va*2),--nI}La+=2;var hs,oI,II=La-_g>>>1;return oI=vg(sa,cs+14+co*2+2+2*II),Fg<oI?0:(hs=vg(sa,cs+14+co*6+2+2*II),hs==0?Fg+Sg(sa,cs+14+co*4+2+2*II):vg(sa,hs+(Fg-oI)*2+cs+14+co*6+2+2*II))}else if(xg==12||xg==13){for(var cI=Vg(sa,cs+12),dI=0,uI=cI;dI<uI;){var GI=dI+(uI-dI>>1),mI=Vg(sa,cs+16+GI*12),pI=Vg(sa,cs+16+GI*12+4);if(Fg<mI)uI=GI;else if(Fg>pI)dI=GI+1;else{var wI=Vg(sa,cs+16+GI*12+8);return xg==12?wI+Fg-mI:wI}}return 0}}return 0}function Rg(Lg,Fg,sa,cs,xg,lo){Lg.type=Fg,Lg.x=sa,Lg.y=cs,Lg.cx=xg,Lg.cy=lo}function Kg(Lg,Fg){var sa,cs;return Fg>=Lg.numGlyphs||Lg.indexToLocFormat>=2?-1:(Lg.indexToLocFormat==0?(sa=Lg.glyf+vg(Lg.data,Lg.loca+Fg*2)*2,cs=Lg.glyf+vg(Lg.data,Lg.loca+Fg*2+2)*2):(sa=Lg.glyf+Vg(Lg.data,Lg.loca+Fg*4),cs=Lg.glyf+Vg(Lg.data,Lg.loca+Fg*4+4)),sa==cs?-1:sa)}function jg(Lg,Fg,sa){if(Lg.cff.length)Ca(Lg,Fg,sa);else{var cs=Kg(Lg,Fg);if(cs<0)return 0;sa.x0=Sg(Lg.data,cs+2),sa.y0=Sg(Lg.data,cs+4),sa.x1=Sg(Lg.data,cs+6),sa.y1=Sg(Lg.data,cs+8)}return 1}function Dg(Lg,Fg,sa,cs,xg,lo,oa,no,co,va){return cs?(sa&&Rg(Lg[Fg++],gg,co+oa>>1,va+no>>1,co,va),Rg(Lg[Fg++],gg,xg,lo,oa,no)):sa?Rg(Lg[Fg++],gg,xg,lo,co,va):Rg(Lg[Fg++],eg,xg,lo,0,0),Fg}function zg(Lg,Fg){var sa=Lg.data,cs=Kg(Lg,Fg);if(cs<0)return null;var xg=[],lo=Sg(sa,cs);if(lo>0){var oa=0,no,co,va=0,nI,ga,_g,La=0,aI,hs=0,oI,II,cI,dI,uI,GI,mI,pI,wI=cs+10,$I=vg(sa,cs+10+lo*2),BI=sa.subarray(cs+10+lo*2+2+$I),WI=0;for(ga=1+vg(sa,wI+lo*2-2),nI=ga+2*lo,xg=rg(nI),_g=0,no=0,aI=nI-ga,co=0;co<ga;++co)no==0?(oa=BI[WI++],oa&8&&(no=BI[WI++])):--no,xg[aI+co].type=oa;for(oI=0,co=0;co<ga;++co){if(oa=xg[aI+co].type,oa&2){var MI=BI[WI++];oI+=oa&16?MI:-MI}else oa&16||(oI=oI+Ng(BI[WI]*256+BI[WI+1]),WI+=2);xg[aI+co].x=oI}for(II=0,co=0;co<ga;++co){if(oa=xg[aI+co].type,oa&4){var XI=BI[WI++];II+=oa&32?XI:-XI}else oa&32||(II=II+Ng(BI[WI]*256+BI[WI+1]),WI+=2);xg[aI+co].y=II}var DI=0;for(uI=GI=cI=dI=mI=pI=0,co=0;co<ga;++co)oa=xg[aI+co].type,oI=xg[aI+co].x,II=xg[aI+co].y,_g==co?(co!=0&&(DI=Dg(xg,DI,La,hs,uI,GI,mI,pI,cI,dI)),hs=!(oa&1),hs?(mI=oI,pI=II,xg[aI+co+1].type&1?(uI=xg[aI+co+1].x,GI=xg[aI+co+1].y,++co):(uI=oI+xg[aI+co+1].x>>1,GI=II+xg[aI+co+1].y>>1)):(uI=oI,GI=II),Rg(xg[DI++],tg,uI,GI,0,0),La=0,_g=1+vg(sa,wI+va*2),++va):oa&1?(La?Rg(xg[DI++],gg,oI,II,cI,dI):Rg(xg[DI++],eg,oI,II,0,0),La=0):(La&&Rg(xg[DI++],gg,cI+oI>>1,dI+II>>1,cI,dI),cI=oI,dI=II,La=1);xg.length=Dg(xg,DI,La,hs,uI,GI,mI,pI,cI,dI)}else if(lo==-1)for(var TI=1,RI=cs+10;TI;){var oa,JI,SI=[1,0,0,1,0,0];oa=Sg(sa,RI),RI+=2,JI=Sg(sa,RI),RI+=2,oa&2&&(oa&1?(SI[4]=Sg(sa,RI),RI+=2,SI[5]=Sg(sa,RI),RI+=2):(SI[4]=cg(sa),RI+=1,SI[5]=cg(sa),RI+=1)),oa&8?(SI[0]=SI[3]=Sg(sa,RI)/16384,RI+=2,SI[1]=SI[2]=0):oa&64?(SI[0]=Sg(sa,RI)/16384,RI+=2,SI[1]=SI[2]=0,SI[3]=Sg(sa,RI)/16384,RI+=2):oa&128&&(SI[0]=Sg(sa,RI)/16384,RI+=2,SI[1]=Sg(sa,RI)/16384,RI+=2,SI[2]=Sg(sa,RI)/16384,RI+=2,SI[3]=Sg(sa,RI)/16384,RI+=2);var nI=lg(SI[0]*SI[0]+SI[1]*SI[1]),ga=lg(SI[2]*SI[2]+SI[3]*SI[3]),il=Eg(Lg,JI);if(il.length>0){for(var co=0,gl=il.length;co<gl;++co){var nl=il[co],oI,II;oI=nl.x,II=nl.y,nl.x=Ig(nI*(SI[0]*oI+SI[2]*II+SI[4])),nl.y=Ig(ga*(SI[1]*oI+SI[3]*II+SI[5])),oI=nl.cx,II=nl.cy,nl.cx=Ig(nI*(SI[0]*oI+SI[2]*II+SI[4])),nl.cy=Ig(ga*(SI[1]*oI+SI[3]*II+SI[5]))}xg=xg.concat(il)}TI=oa&32}return xg}function Og(Lg,Fg,sa){(Fg>Lg.max_x||!Lg.started)&&(Lg.max_x=Fg),(sa>Lg.max_y||!Lg.started)&&(Lg.max_y=sa),(Fg<Lg.min_x||!Lg.started)&&(Lg.min_x=Fg),(sa<Lg.min_y||!Lg.started)&&(Lg.min_y=sa),Lg.started=1}function Jg(Lg,Fg,sa,cs,xg,lo,oa,no){Og(Lg,sa,cs),Fg==ig&&(Og(Lg,xg,lo),Og(Lg,oa,no));var co={};Rg(co,Fg,sa,cs,xg,lo),co.cx1=oa,co.cy1=no,Lg.vertices.push(co)}function Qg(Lg){(Lg.first_x!=Lg.x||Lg.first_y!=Lg.y)&&Jg(Lg,eg,Lg.first_x,Lg.first_y,0,0,0,0)}function eo(Lg,Fg,sa){Qg(Lg),Lg.first_x=Lg.x=Lg.x+Fg,Lg.first_y=Lg.y=Lg.y+sa,Jg(Lg,tg,Lg.x,Lg.y,0,0,0,0)}function ca(Lg,Fg,sa){Lg.x+=Fg,Lg.y+=sa,Jg(Lg,eg,Lg.x,Lg.y,0,0,0,0)}function ua(Lg,Fg,sa,cs,xg,lo,oa){var no=Lg.x+Fg,co=Lg.y+sa,va=no+cs,nI=co+xg;Lg.x=va+lo,Lg.y=nI+oa,Jg(Lg,ig,Lg.x,Lg.y,no,co,va,nI)}function pa(Lg,Fg){var sa=Wg(Lg),cs=107;return sa>=33900?cs=32768:sa>=1240&&(cs=1131),Fg+=cs,Fg<0||Fg>=sa?bg():yg(Lg,Fg)}function is(Lg,Fg){var sa=Lg.fdselect,cs,xg,lo,oa,no,co=-1,va;if(dg(sa,0),no=cg(sa),no==0)hg(sa,Fg),co=cg(sa);else if(no==3)for(cs=mg(sa,2),xg=mg(sa,2),va=0;va<cs;va++){if(oa=cg(sa),lo=mg(sa,2),Fg>=xg&&Fg<lo){co=oa;break}xg=lo}return Yg(Lg.cff,yg(Lg.fontdicts,co))}function Pg(Lg,Fg,sa){var cs=1,xg=0,lo=0,oa=0,no,co,va,nI=0,ga,_g=[],La=[],aI=Lg.subrs,hs,oI;for(hs=yg(Lg.charstrings,Fg);hs.cursor<hs.length;){switch(co=0,ga=1,va=cg(hs),va){case 19:case 20:cs&&(xg+=oa/2|0),cs=0,hg(hs,(xg+7)/8|0);break;case 1:case 3:case 18:case 23:xg+=oa/2|0;break;case 21:if(cs=0,oa<2)return 0;eo(sa,_g[oa-2],_g[oa-1]);break;case 4:if(cs=0,oa<1)return 0;eo(sa,0,_g[oa-1]);break;case 22:if(cs=0,oa<1)return 0;eo(sa,_g[oa-1],0);break;case 5:if(oa<2)return 0;for(;co+1<oa;co+=2)ca(sa,_g[co],_g[co+1]);break;case 7:if(oa<1)return 0;for(;!(co>=oa||(ca(sa,0,_g[co]),co++,co>=oa));)ca(sa,_g[co],0),co++;break;case 6:if(oa<1)return 0;for(;!(co>=oa||(ca(sa,_g[co],0),co++,co>=oa));)ca(sa,0,_g[co]),co++;break;case 31:if(oa<4)return 0;for(;!(co+3>=oa||(ua(sa,_g[co],0,_g[co+1],_g[co+2],oa-co==5?_g[co+4]:0,_g[co+3]),co+=4,co+3>=oa));)ua(sa,0,_g[co],_g[co+1],_g[co+2],_g[co+3],oa-co==5?_g[co+4]:0),co+=4;break;case 30:if(oa<4)return 0;for(;!(co+3>=oa||(ua(sa,0,_g[co],_g[co+1],_g[co+2],_g[co+3],oa-co==5?_g[co+4]:0),co+=4,co+3>=oa));)ua(sa,_g[co],0,_g[co+1],_g[co+2],oa-co==5?_g[co+4]:0,_g[co+3]),co+=4;break;case 8:if(oa<6)return 0;for(;co+5<oa;co+=6)ua(sa,_g[co],_g[co+1],_g[co+2],_g[co+3],_g[co+4],_g[co+5]);break;case 24:if(oa<8)return 0;for(;co+5<oa-2;co+=6)ua(sa,_g[co],_g[co+1],_g[co+2],_g[co+3],_g[co+4],_g[co+5]);if(co+1>=oa)return 0;ca(sa,_g[co],_g[co+1]);break;case 25:if(oa<8)return 0;for(;co+1<oa-6;co+=2)ca(sa,_g[co],_g[co+1]);if(co+5>=oa)return 0;ua(sa,_g[co],_g[co+1],_g[co+2],_g[co+3],_g[co+4],_g[co+5]);break;case 26:case 27:if(oa<4)return 0;for(oI=0,oa&1&&(oI=_g[co],co++);co+3<oa;co+=4)va==27?ua(sa,_g[co],oI,_g[co+1],_g[co+2],_g[co+3],0):ua(sa,oI,_g[co],_g[co+1],_g[co+2],0,_g[co+3]),oI=0;break;case 10:nI||(Lg.fdselect.length&&(aI=is(Lg,Fg)),nI=1);case 29:if(oa<1||(no=_g[--oa]|0,lo>=10)||(La[lo++]=hs,hs=pa(va==10?aI:Lg.gsubrs,no),hs.length==0))return 0;hs.cursor=0,ga=0;break;case 11:if(lo<=0)return 0;hs=La[--lo],ga=0;break;case 14:return Qg(sa),1;case 12:var II,cI,dI,uI,GI,mI,pI,wI,$I,BI,WI,MI,XI,DI,TI=cg(hs);switch(TI){case 34:if(oa<7)return 0;II=_g[0],cI=_g[1],wI=_g[2],dI=_g[3],uI=_g[4],GI=_g[5],mI=_g[6],ua(sa,II,0,cI,wI,dI,0),ua(sa,uI,0,GI,-wI,mI,0);break;case 35:if(oa<13)return 0;II=_g[0],pI=_g[1],cI=_g[2],wI=_g[3],dI=_g[4],$I=_g[5],uI=_g[6],BI=_g[7],GI=_g[8],WI=_g[9],mI=_g[10],MI=_g[11],ua(sa,II,pI,cI,wI,dI,$I),ua(sa,uI,BI,GI,WI,mI,MI);break;case 36:if(oa<9)return 0;II=_g[0],pI=_g[1],cI=_g[2],wI=_g[3],dI=_g[4],uI=_g[5],GI=_g[6],WI=_g[7],mI=_g[8],ua(sa,II,pI,cI,wI,dI,0),ua(sa,uI,0,GI,WI,mI,-(pI+wI+WI));break;case 37:if(oa<11)return 0;II=_g[0],pI=_g[1],cI=_g[2],wI=_g[3],dI=_g[4],$I=_g[5],uI=_g[6],BI=_g[7],GI=_g[8],WI=_g[9],mI=MI=_g[10],XI=II+cI+dI+uI+GI,DI=pI+wI+$I+BI+WI,Ag(XI)>Ag(DI)?MI=-DI:mI=-XI,ua(sa,II,pI,cI,wI,dI,$I),ua(sa,uI,BI,GI,WI,mI,MI);break;default:return 0}break;default:if(va!=255&&va!=28&&(va<32||va>254)||(va==255?oI=(mg(hs,4)|0)/65536:(hg(hs,-1),oI=(wg(hs)<<16|0)>>16),oa>=48))return 0;_g[oa++]=oI,ga=0;break}ga&&(oa=0)}return 0}function la(){return{started:0,first_x:0,first_y:0,x:0,y:0,min_x:0,max_x:0,min_y:0,max_y:0,vertices:[]}}function ma(Lg,Fg){var sa=la();return Pg(Lg,Fg,sa)?sa.vertices:null}function Ca(Lg,Fg,sa){var cs=la(),xg=Pg(Lg,Fg,cs);return sa.x0=xg?cs.min_x:0,sa.y0=xg?cs.min_y:0,sa.x1=xg?cs.max_x:0,sa.y1=xg?cs.max_y:0,xg&&cs.vertices?cs.vertices.length:0}function Eg(Lg,Fg){return Lg.cff.length?ma(Lg,Fg):zg(Lg,Fg)}function Mg(Lg,Fg){var sa=vg(Lg.data,Lg.hhea+34);return Fg<sa?{advanceWidth:Sg(Lg.data,Lg.hmtx+4*Fg),leftSideBearing:Sg(Lg.data,Lg.hmtx+4*Fg+2)}:{advanceWidth:Sg(Lg.data,Lg.hmtx+4*(sa-1)),leftSideBearing:Sg(Lg.data,Lg.hmtx+4*sa+2*(Fg-sa))}}function Tg(Lg){return{ascent:Sg(Lg.data,Lg.hhea+4),descent:Sg(Lg.data,Lg.hhea+6),linegap:Sg(Lg.data,Lg.hhea+8)}}function Ug(Lg,Fg,sa,cs,xg,lo){var oa={};return jg(Lg,Fg,oa)?{x0:Ig(oa.x0*sa+xg),y0:Ig(-oa.y1*cs+lo),x1:Cg(oa.x1*sa+xg),y1:Cg(-oa.y0*cs+lo)}:{x0:0,y0:0,x1:0,y1:0}}function da(Lg,Fg,sa){var cs=(Lg.x1-Lg.x0)/(Lg.y1-Lg.y0);return{fdx:cs,fdy:cs!=0?1/cs:0,fx:Lg.x0+cs*(sa-Lg.y0)-(Fg|0),direction:Lg.invert?1:-1,sy:Lg.y0,ey:Lg.y1,next:0}}function ya(Lg,Fg,sa,cs,xg,lo,oa){Fg=Fg|0,xg!=oa&&(xg>sa.ey||oa<sa.sy||(xg<sa.sy&&(cs+=(lo-cs)*(sa.sy-xg)/(oa-xg),xg=sa.sy),oa>sa.ey&&(lo+=(lo-cs)*(sa.ey-oa)/(oa-xg),oa=sa.ey),cs<=Fg&&lo<=Fg?Lg[Fg]+=sa.direction*(oa-xg):cs>=Fg+1&&lo>=Fg+1||(Lg[Fg]+=sa.direction*(oa-xg)*(1-(cs-Fg+(lo-Fg))/2))))}function eI(Lg,Fg,sa,cs,xg){for(var lo=xg+1;cs;){if(cs.fdx==0){var oa=cs.fx;oa<sa&&(oa>=0?(ya(Lg,oa,cs,oa,xg,oa,lo),ya(Fg,oa+1,cs,oa,xg,oa,lo)):ya(Fg,0,cs,oa,xg,oa,lo))}else{var oa=cs.fx,no=cs.fdx,co=oa+no,va,nI,ga,_g,La=cs.fdy;if(cs.sy>xg?(va=oa+no*(cs.sy-xg),ga=cs.sy):(va=oa,ga=xg),cs.ey<lo?(nI=oa+no*(cs.ey-xg),_g=cs.ey):(nI=co,_g=lo),va>=0&&nI>=0&&va<sa&&nI<sa)if((va|0)==(nI|0)){var aI=_g-ga,hs=va|0;Lg[hs]+=cs.direction*(1-(va-hs+(nI-hs))/2)*aI,Fg[hs+1]+=cs.direction*aI}else{var oI,hs,II,cI,dI,uI,GI,mI;for(va>nI&&(ga=lo-(ga-xg),_g=lo-(_g-xg),oI=ga,ga=_g,_g=oI,oI=nI,nI=va,va=oI,no=-no,La=-La,oI=oa,oa=co,co=oI),II=va|0,cI=nI|0,dI=(II+1-oa)*La+xg,GI=cs.direction,mI=GI*(dI-ga),Lg[II]+=mI*(1-(va-II+(II+1-II))/2),uI=GI*La,hs=II+1;hs<cI;++hs)Lg[hs]+=mI+uI/2,mI+=uI;dI+=La*(cI-(II+1)),Lg[cI]+=mI+GI*(1-(cI-cI+(nI-cI))/2)*(_g-dI),Fg[cI+1]+=GI*(_g-ga)}else for(var hs=0;hs<sa;++hs){var pI=xg,II=hs,cI=hs+1,wI=co,$I=lo,BI=(hs-oa)/no+xg,WI=(hs+1-oa)/no+xg;oa<II&&wI>cI?(ya(Lg,hs,cs,oa,pI,II,BI),ya(Lg,hs,cs,II,BI,cI,WI),ya(Lg,hs,cs,cI,WI,wI,$I)):wI<II&&oa>cI?(ya(Lg,hs,cs,oa,pI,cI,WI),ya(Lg,hs,cs,cI,WI,II,BI),ya(Lg,hs,cs,II,BI,wI,$I)):oa<II&&wI>II||wI<II&&oa>II?(ya(Lg,hs,cs,oa,pI,II,BI),ya(Lg,hs,cs,II,BI,wI,$I)):oa<cI&&wI>cI||wI<cI&&oa>cI?(ya(Lg,hs,cs,oa,pI,cI,WI),ya(Lg,hs,cs,cI,WI,wI,$I)):ya(Lg,hs,cs,oa,pI,wI,$I)}}cs=cs.next}}function us(Lg,Fg,sa,cs,xg,lo){xg|=0,lo|=0;var oa=null,no,co=lo,va=0,nI,ga=new Float32Array(Lg.w*2+1),_g=ga.subarray(Lg.w),La=0;for(Fg[sa].y0=lo+Lg.h+1;va<Lg.h;){var aI=co+0,hs=co+1,oI=oa;if(ga.fill)ga.fill(0);else for(var II=0,cI=ga.length;II<cI;II++)ga[II]=0;for(;oI;)no=oI,oI=no.next,no.ey<=aI&&(no.direction=0);for(;Fg[La].y0<=hs;)Fg[La].y0!=Fg[La].y1&&(no=da(Fg[La],xg,aI),no.next=oa,oa=no),++La;oa&&eI(ga,_g,Lg.w,oa,aI);for(var nI=0,dI=0;nI<Lg.w;++nI){var uI,GI;dI+=_g[nI],uI=ga[nI]+dI,uI=Ag(uI)*255+.5,GI=uI>>>0,GI>255&&(GI=255),Lg.pixels[va*Lg.stride+nI]=GI}for(oI=oa;oI;)no=oI,no.fx+=no.fdx,oI=no.next;++co,++va}}function uo(Lg,Fg){for(var sa=1;sa<Fg;++sa){for(var cs=Lg[sa],xg=sa;xg>0&&cs.y0<Lg[xg-1].y0;)Lg[xg]=Lg[xg-1],--xg;sa!=xg&&(Lg[xg]=cs)}}function ha(Lg,Fg,sa){for(;sa>12;){var cs,xg,lo,oa,no,co=sa>>1,va=Lg[Fg].y0<Lg[Fg+co].y0,nI=Lg[Fg+co].y0<Lg[Fg+sa-1].y0;for(va!=nI&&(xg=Lg[Fg].y0<Lg[Fg+sa-11].y0,no=xg==nI?0:sa-1,cs=Lg[Fg+no],Lg[Fg+no]=Lg[Fg+co],Lg[Fg+co]=cs),cs=Lg[Fg],Lg[Fg]=Lg[Fg+co],Lg[Fg+co]=cs,lo=1,oa=sa-1;;){for(;Lg[Fg+lo].y0<Lg[Fg].y0;++lo);for(;Lg[Fg].y0<Lg[Fg+oa].y0;--oa);if(lo>=oa)break;cs=Lg[Fg+lo],Lg[Fg+lo]=Lg[Fg+oa],Lg[Fg+oa]=cs,++lo,--oa}oa<sa-lo?(ha(Lg,Fg,oa),Fg+=lo,sa-=lo):(ha(Lg,Fg+lo,sa-lo),sa=oa)}}function tI(Lg,Fg){ha(Lg,0,Fg),uo(Lg,Fg)}function AI(Lg,Fg,sa,cs,xg,lo,oa,no,co,va){var nI=-xg,ga,_g,La,aI,hs,oI,II=1;for(_g=0,La=0;La<sa.length;++La)_g+=sa[La];for(ga=rg(_g+1),_g=0,oI=0,La=0;La<sa.length;++La){var cI=oI;for(oI+=sa[La],aI=sa[La]-1,hs=0;hs<sa[La];aI=hs++){var dI=hs,uI=aI;Fg[cI+aI].y!=Fg[cI+hs].y&&(ga[_g].invert=0,Fg[cI+aI].y>Fg[cI+hs].y&&(ga[_g].invert=1,dI=aI,uI=hs),ga[_g].x0=Fg[cI+dI].x*cs+lo,ga[_g].y0=(Fg[cI+dI].y*nI+oa)*II,ga[_g].x1=Fg[cI+uI].x*cs+lo,ga[_g].y1=(Fg[cI+uI].y*nI+oa)*II,++_g)}}tI(ga,_g),us(Lg,ga,_g,II,no,co)}function rI(Lg,Fg,sa,cs,xg,lo,oa,no,co){var va=(Fg+2*cs+lo)/4,nI=(sa+2*xg+oa)/4,ga=(Fg+lo)/2-va,_g=(sa+oa)/2-nI;return co>16||(ga*ga+_g*_g>no?(rI(Lg,Fg,sa,(Fg+cs)/2,(sa+xg)/2,va,nI,no,co+1),rI(Lg,va,nI,(cs+lo)/2,(xg+oa)/2,lo,oa,no,co+1)):Lg.push({x:lo,y:oa})),1}function gI(Lg,Fg,sa,cs,xg,lo,oa,no,co,va,nI){var ga=cs-Fg,_g=xg-sa,La=lo-cs,aI=oa-xg,hs=no-lo,oI=co-oa,II=no-Fg,cI=co-sa,dI=lg(ga*ga+_g*_g)+lg(La*La+aI*aI)+lg(hs*hs+oI*oI),uI=lg(II*II+cI*cI),GI=dI*dI-uI*uI;if(!(nI>16))if(GI>va){var mI=(Fg+cs)/2,pI=(sa+xg)/2,wI=(cs+lo)/2,$I=(xg+oa)/2,BI=(lo+no)/2,WI=(oa+co)/2,MI=(mI+wI)/2,XI=(pI+$I)/2,DI=(wI+BI)/2,TI=($I+WI)/2,RI=(MI+DI)/2,JI=(XI+TI)/2;gI(Lg,Fg,sa,mI,pI,MI,XI,RI,JI,va,nI+1),gI(Lg,RI,JI,DI,TI,BI,WI,no,co,va,nI+1)}else Lg.push({x:no,y:co})}function qg(Lg,Fg,sa){for(var cs=[],xg=Fg*Fg,lo=-1,oa=0,no=0,co=0,va=0,nI=Lg.length;va<nI;++va)switch(Lg[va].type){case tg:lo>=0&&(sa[lo]=cs.length-oa),++lo,oa=cs.length,no=Lg[va].x,co=Lg[va].y,cs.push({x:no,y:co});break;case eg:no=Lg[va].x,co=Lg[va].y,cs.push({x:no,y:co});break;case gg:rI(cs,no,co,Lg[va].cx,Lg[va].cy,Lg[va].x,Lg[va].y,xg,0),no=Lg[va].x,co=Lg[va].y;break;case ig:gI(cs,no,co,Lg[va].cx,Lg[va].cy,Lg[va].cx1,Lg[va].cy1,Lg[va].x,Lg[va].y,xg,0),no=Lg[va].x,co=Lg[va].y;break}return sa[lo]=cs.length-oa,cs}function xa(Lg,Fg,sa,cs,xg,lo,oa,no,co,va){no|=0,co|=0;var nI=cs>xg?xg:cs,ga=[],_g=qg(sa,Fg/nI,ga);_g&&AI(Lg,_g,ga,cs,xg,lo,oa,no,co)}function iI(Lg){var Fg={};if(!Hg(Fg,Lg,0))return null;var sa=Tg(Fg);return Fg.ascent=sa.ascent,Fg.descent=sa.descent,Fg.linegap=sa.linegap,Fg}function sI(Lg,Fg,sa,cs){cs=cs||sa;var xg=sa/Lg.ascent,lo=cs/Lg.ascent,oa=kg(Lg,Fg);if(!oa&&Fg)return null;var no=Eg(Lg,oa),co=Ug(Lg,oa,xg,lo,0,0),va=co.x1-co.x0,nI=co.y1-co.y0,ga=null;if(va&&nI){var _g={pixels:ga=new Uint8Array(va*nI),w:va,h:nI,stride:va};xa(_g,.35,no,xg,lo,0,0,co.x0,co.y0)}var La=Mg(Lg,oa);return{glyph:oa,pixels:ga,width:va,height:nI,top:-co.y0,left:co.x0,advance:Ig(La.advanceWidth*xg)}}function fa(Lg,Fg,sa,cs){cs=cs||sa;var xg=sa/Lg.ascent,lo=cs/Lg.ascent,oa=kg(Lg,Fg);if(!oa&&Fg)return null;var no=Eg(Lg,oa),co=Mg(Lg,oa),va=0,nI=0,ga=[];if(no)for(var _g=0,La=no.length;_g<La;_g++){var aI=no[_g],hs;if(aI.type==tg)hs={type:"M",x:aI.x*xg,y:aI.y*lo};else if(aI.type==eg)hs={type:"L",x:aI.x*xg,y:aI.y*lo};else if(aI.type==gg)hs={type:"Q",x:aI.x*xg,y:aI.y*lo,cx:aI.cx*xg,cy:aI.cy*lo};else if(aI.type==ig)hs={type:"C",x:aI.x*xg,y:aI.y*lo,cx1:aI.cx*xg,cy1:aI.cy*lo,cx2:aI.cx1*xg,cy2:aI.cy1*lo};else continue;hs.y>va&&(va=hs.y),hs.y<nI&&(nI=hs.y),ga.push(hs)}return ga.advance=co.advanceWidth*xg,ga.ascent=va,ga.descent=nI,ga}return{InitFont:iI,GetGlyph:sI,GetPaths:fa}})();function toUint8Array(tg){if(typeof tg=="string"){for(var eg=/[^A-Za-z0-9+\/=\s]/.test(tg),gg=eg?tg:atob(tg),ig=gg.length,ng=new Uint8Array(ig),og=0;og<ig;og++)ng[og]=gg.charCodeAt(og);return ng}else{if(tg instanceof Uint8Array)return tg;if(tg instanceof ArrayBuffer)return new Uint8Array(tg)}throw new ReferenceError("data must be a binary or base64 encoded string or Uint8Array")}FontLib.loadFont("OCR-A",100,100,"AAEAAAAPAIAAAwBwRkZUTXxHoksAADPIAAAAHEdERUYAmQAGAAAyIAAAACBHUE9TuP+4/gAAM5gAAAAwR1NVQuq3l/0AADJAAAABWE9TLzKDm4kvAAABeAAAAGBjbWFwO6GiGgAAArgAAAFaZ2FzcP//AAMAADIYAAAACGdseWYfHUemAAAE8AAAKUBoZWFkFeCL3QAAAPwAAAA2aGhlYQcqAgQAAAE0AAAAJGhtdHgagBVHAAAB2AAAAOBsb2NhH+IWRAAABBQAAADabWF4cACxAF0AAAFYAAAAIG5hbWUIp3NfAAAuMAAAAoJwb3N0oJoboAAAMLQAAAFkAAEAAAACAAAhYPsHXw889QALA+gAAAAA2gMjvQAAAADaAyO9AD7/LAJ8BFIAAAAIAAIAAAAAAAAAAQAABFL/LABaAtMAAAAAAnwAAQAAAAAAAAAAAAAAAAAAAAQAAQAAAGwAWgADAAAAAAACAAAAAQABAAAAQAAAAAAAAAACAtMBkAAFAAACigK8AAAAjAKKArwAAAHgADEBAgAAAgAFCQAAAAAAAAAAACMAACoAAAAAAAAAAABQZkVkAEAAICWgAyD/OABaBFIA1AAAAAEAAAAAAjgDDAAAACAAAQLTAAAAAAAAAtMAAALTAAAA9gBJAEkASQBJAEkA3QDdAKwASQBJAKwASQDdAEkASQBJAEkASQBhAEkASQBJAEkASQDdAKwASQBJAEkASQBJAEYASQBJAEkASQBJAEkASQBJAHoASQBJAEkASQBJAEkASQBJAEkASQBJAEkASQBJAEkASABJAEkASQBIAEkAegBJAEkASQBJAEkAYQBJAEkAegB6AEkAegBBAEkASQBJAEkASQBJAEkASQBJAD4ASQBJAEkASQEPAEkASQBxAHEAcQE3AFcA7QBxAQMA1ABxAAAAAwAAAAMAAAAcAAEAAAAAAFQAAwABAAAAHAAEADgAAAAKAAgAAgACAH4kQiUCJaD//wAAACAkQCUCJaD////j3CLbY9rGAAEAAAAAAAAAAAAAAAABBgAAAQAAAAAAAAABAgAAAAIAAAAAAAAAAAAAAAAAAAABAAADBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/QEFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaW1xdXl9gYQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAFIApgDoAS4BigGqAdYCAgJKAnQCkAKsAsYC5AMIAzIDYAOcA8gD+gQmBFIEggSuBNwFDAU0BVwFhAXEBhIGPgZwBqgG5AcKBy4HageWB8QH7gggCDoIZgiICMoI8glMCYIJwAnmChAKNAp0Cq4K1gr6CyYLRAtwC5QLrgvODBYMdAysDRANag2eDhYOSA6EDsYO+A8iD2YPmA/yEFgQvBDqETQRbhGgEcwSDhJEEnoSqBLiEwITPBNyE5ITthPeE+wT+hQUFEYUaBSIFKAAAAACAPYAAAGNAwwADwAfAAA3NTQ2OwEyFh0BFAYrASImETQ2OwEyFh0BAxQGIyImJ/YeFTEVHh4VMRUeHhUxFB8ZHhQVHAIzKhUdHRUqFR4eArwUHhwTA/6BFR0dFQAAAAABAEkBqAI7AwwAEwAAEychFQYHBiMiJjUnIwcOASMiJidKAQHyJgsMKBQgKHIqAxwSExwDAsJKSrkvMhoS09YRGBgRAAIASQB/AjsDDAA9AEEAABM0NjsBNSMiJjQ2OwE1NDYyFh0BMzU0NjIWHQEzMhYUBisBFTMyFhUUBisBFRQGIiY9ASMVFAYiJj0BIyImNzM1I0kdFTExFR0dFTEdKh5hHiodMRUeHhUxMRUeHhUxHSoeYR4qHTEVHchhYQFcFB5vHiodeBQeHhR4eBQeHhR4HSoebx4UFR53FR4eFXd3FR4eFXceR28AAAEASQAAAjsDDAAxAAA2NDYzITUhIiY9ATQ2OwE1NDYzMhYdATMyFhQGIyEVITIWHQEUBisBFRQGIyImPQEjIkkdFQFb/qUVHR0VlB4VFB6UFR4eFf6lAVsVHh4VlB4UFR6UFccqHkQeFaoVHXgUHh4UeB0qHkQeFaoVHXcVHh4VdwAAAAMASQAAAjsDDAAPAB8ALwAANzQ3ATYzMhYVFAcBBiMiJhE1NDY7ATIWHQEUBisBIiYBNTQ2OwEyFh0BFAYrASImSQoBjQ4aFR4L/nMOGhUdHRVjFR4eFWMVHQEpHhVjFR4eFWMVHocUCwH+Ex0VEg3+AhMdAhNVFB4eFFUVHh79w1QVHh4VVBUeHgAAAwBJAAACOwK3AC4ANgBBAAA3NTQ/AScmPQE0NjsBMhYdARQPARc3NjMyFhUUDgIHFxYVFAYjIi8BBwYrASImNxQWOwE3JwcRFzc1NCYrASIGFUkRXGANWT5gPlkRfWszDxIVHhAPIQI0Dh4VFw43Sg8RYj5ZZR4UTzhrTlVvHhRgFB6XRRgPT2YPFEU+WVk+RRkOa3IsDB4VDRoOGAI4EBIVHhA7PwxZPhUdMHJCASpbXi4UHh0VAAEA3QFUAaYDDAARAAATETQ2OwEyFhcUBg8BDgEjIibdHhVjFRwCMhoZBRoSFR4BhgFUFB4dFQawVVURFR0AAAABAN0AAAHZAwwAGwAAEzU0PwE2MzIWFRQPAQYdARQfARYVFAYjIi8BJt0rdRAYFR8MdRYWdQodFRgQdSsBJsBFOJYTHhQOEpUdIsAiHZUPEBUeE5Y4AAAAAQCsAAABpgMMABsAADc0PwE2PQE0LwEmNTQ2MzIfARYdARQPAQYjIiasCnUWFnUKHRUYEHUrK3UQGBUdMxAPlR0iwCIdlQ8RFB4TljhFwEU4lhMeAAAAAAEASQBVAjsCtwAzAAA3ND8BJyY1NDYzMh8BNTQ2MzIWHQE3NjMyFhUUDwEXFhUUBiMiLwEVFAYjIiY9AQcGIyImSRGZmREdFRMOcx4VFB5zDRQVHhKZmRIeFRQNcx4UFR5zDhMVHdwYD4ODDxgVHQxikRUdHRWRYgwdFRcQg4MQFxUdDGKRFR0dFZFiDB0AAAEASQCNAjsCfwAdAAASNDY7ATU0NjMyFh0BMzIWFAYrARUUBiMiJj0BIyJJHRWUHhUUHpQVHh4VlB4UFR6UFQFxKh6UFB4eFJQeKh2UFR4eFZQAAAEArAAAAdcBZAAQAAASNDY7ATIWHQEUBiImPQEjIqwdFccVHR0qHpQVARwqHh4V/hUeHhXMAAAAAQBJASkCOwG5AA8AABM1NDYzITIWHQEUBiMhIiZJHRUBjRUeHhX+cxUdAVwqFR4eFSoVHh4AAAABAN0AfwGmATkADwAANzU0NjsBMhYdARQGKwEiJt0eFWMVHh4VYxUeslUVHR0VVRUeHgAAAQBJAAACOwMMAA8AADc0NwE2MzIWFRQHAQYjIiZJBgGNDx0VHgf+cw8dFR0zDQwCpxkeFAwO/VkZHgAAAgBJAAACOwMMAA8AEwAANxE0NjMhMhYVERQGIyEiJjchESFJPCkBKCg9PSj+2Ck8ZQEo/thlAkIpPDwp/b4pPDwpAkIAAAAAAQBJAAACOwMMABwAADc0NjsBESMiJjU0NjsBETM1NDYyFh0BFAYjISImSR0VlJQVHR0V+WIdKh4eFf5zFR0zFB4CQh4VFB79WcwVHh4V/hUeHgAAAQBJAAACOwMMAB4AADMRNDYzITUhIiY1NDYzITIWHQEUBiMhFSEyFhUUBiNJPCkBKP6lFR0dFQFbKD08Kf7YAVoVHh4VAVQpO+8eFRQePCnvKDzvHhQVHgAAAAABAEkAAAI7AwwAKgAANzQ2MyE1NCYrASImNDY7ATI2PQEhIiY1NDYzITIWHQEUBxYdARQGIyEiJkkdFQFbHxTFFR0dFcUVHv6lFR0dFQFbKD0oKD0o/qUVHTMUHrwUHx0qHh4UvB4VFB48Kbw6Kys6vCk8HgAAAAABAGEAAAIiAwwAHQAAExE0NjIWFREzETQ2MzIWFREyFhQGIxUUBiMiJj0BYR4qHcUeFRQeFR0dFR4UFR4A/wHbFB4eFP6KASEVHR0V/t8eKh3MFR4eFcwAAQBJAAACOwMMACIAADc0NjMyHwEzNSERITIWFRQGKwEVMzIWHQEUBisBIi4CJyZJHRUMCFrt/tYBXBUeHhX3xSg9PSjjFCkaLAkeXRUdBCbvAbgeFBUe7j0o7yk8CgsVBA0AAAIASQAAAjsDDAAXABsAADcRNDY7ATIWFRQGIxEhMhYdARQGIyEiJjchNSFJHRUyFR0dFQFbFR4eFf5zFR1kASn+1zMCpxQeHhQVHv69HhX+FR4eR5oAAAABAEkAAAI7AwwAGwAAEzU0NjMhERQPARUUBiMiJj0BND8BNSEOASMiJkkdFQHAErUeFBUeErX+1wMcExUdAq8rFB7+zxcQmucVHh4V/hcQmrUSGB0AAAAAAwBJAAACOwMMABcAGwAfAAA3NTQ2MxE0NjsBMhYVETIWHQEUBiMhIiY3ITUhNzM1I0k7KRwVxxUcKD09KP7XKTtkASn+12RhYWXvKTwBIRUdHRX+3z0o7yk8PCnvZe4AAgBJAAACOwMMABcAGwAAExE0NjMhMhYVERQGKwEiJjU0NjMRISImNyE1IUkdFQGNFR4eFTIVHR0V/qUVHWQBKf7XAdsA/xQeHhT9WRUeHhUUHgFDHkeaAAIA3QB/AaYCjQAPAB8AADc1NDY7ATIWHQEUBisBIiYRNTQ2OwEyFh0BFAYrASIm3R4VYxUeHhVjFR4eFWMVHh4VYxUeslUVHR0VVRUeHgFoVRUeHhVVFR0dAAAAAgCsAAAB1wK3ABAAIAAAEjQ2OwEyFh0BFAYiJj0BIyIDNTQ2OwEyFh0BFAYrASImrB0VxxUdHSoelBUdHRVkFB4eFGQVHQEcKh4eFf4VHh4VzAExVRUdHRVVFR4eAAAAAQBJAFUCOwK3ABYAABM1NDclNjMyFhUUBw0BFhUUBiMiJyUmSRgBjQsPFR4Z/pkBZxkeFQ8L/nMYAXArHQ/pBx0VHBDT0xAcFR0H6Q8AAAACAEkA/wI7AjgACwAXAAASNDYzITIWFAYjISImNDYzITIWFAYjISJJHRUBjRUeHhX+cxUdHRUBjRUeHhX+cxUBHCoeHiod8SoeHiodAAAAAAEASQBVAjsCtwAWAAA3NDctASY1NDYzMhcFFh0BFAcFBiMiJkkYAWj+mBgdFQ8LAY0ZFP5uCw8VHYcdD9PTDx0VHQfpEBwqHQzsBx0AAAAAAgBJAAACOwMMAB4AKAAAEzQ3ATYyHwEWHQEUBwUVFAYiJj0BNDclNScFBiMiJhM0NjIWFRQGIiZJEQEqDyQPYxIS/ugeKh0RARkx/vcPEhUdYx0qHh4qHQHbGA4A/wwMVQ8XVRcQ7z4VHR0VVRkO7yYq4wwe/m0UHh4UFR4eAAACAEkAAAI7AwwALQA4AAA3NTQ2OwEyFhURFBYyNjURNCYrASIGBwYjIiY1NDc2OwEyFhURFAYjIicGIyImNxQWMjY9ASMiBhVJWD1kFB4dKB0uH48ZLQwOHxUdNjdEj0lpWT05Kiw4PVhlHCgdMRQclrc+WB4V/uYUHR0UAcQgLSMXGx4VJDEyakj+PD1ZJydYPhQdHRToHRQAAAACAEYAAAI8AwwAFQAYAAA3Ez4BMhYXExQGIyImLwEjBw4BIyImNzMDRssFGiIcBMofFREaBSffJwUbERUfqqNSMwK1EBQUEP1LFR4UEIaGEBQe8QEWAAAAAwBJAAACOwMMAA4AGAAiAAAzESEyFh0BFAcWHQEUBiMnMzI2PQE0JisBNTMyNj0BNCYrAUkBKFJ4RkZ4UsPDKTw8KcPDKTw8KcMDDHhSJVk+PlklUnhlPSglKTxlPCglKD0AAAEASQAAAjsDDAAlAAATND8BPgE7ATIWFRQGKwEiDwEGFB8BFjsBMhYVFAYrASImJyYnJkkYZRBLLboVHh4Vuh8NZw0NZw0fuhUeHhW6LEkSShwYAYY1MswkLx4UFR4cyxw8HMscHhQVHjAkjT4zAAACAEkAAAI7AwwAGwAoAAA3NDY7AREjIiY1NDY7ATIWHwEWFA8BDgErASImNzMyPwE2NTQvASYrAUkdFTExFR0dFbosSRJmGRllEEstuhUdyCQfDWcODmcNHyQzFB4CQh4VFB4wJMs0ZjTMJC8eRxzLIhgeHMscAAABAEkAAAI7AwwAGQAAMxEhMhYVFAYjIRUzMhYUBisBFSEyFhUUBiNJAb8VHh4V/qaUFB4eFJQBWhUeHhUDDB4UFR7uHiod7x4UFR4AAQBJAAACOwMMABYAADcRITIWFRQGIyEVMzIWFAYrAREUBiImSQG/FR4eFf6m9xUdHRX3HiodMwLZHhQVHpodKh7+ixUeHgAAAQBJAAACOwMMACoAADcRND8BNjsBMhYVFAYrASIPAQYVERQWOwEyNj0BIyImNDY7ARUUBisBIiZJKogtS5UVHh4VlRkPiBUeFMMUH2MVHR0VyFo+wz9YmAEPRTawOh4UFR4Urhwi/vEVHh4VZx0qHsw+WlkAAAAAAQBJAAACOwMMABsAADcRNDYyFhURIRE0NjIWFREUBiImNREhERQGIiZJHSoeASgdKh4eKh3+2B4qHTMCpxQeHhT+3wEhFB4eFP1ZFR4eFQEh/t8VHh4AAAEASQAAAjsDDAAfAAA3NDY7AREjIiY1NDYzITIWFRQGKwERMzIWFRQGIyEiJkkdFZSUFR0dFQGNFR4eFZSUFR4eFf5zFR0zFB4CQh4VFB4eFBUe/b4eFBUeHgAAAQB6AAACCQMMABsAADc1NDYyFh0BFBY7ATI2NRE0NjIWFREUBisBIiZ6HiodHhVfFR4dKh5aPl8+WpeaFR4eFZoVHR4UAkMUHh4U/b0+WVkAAAAAAQBJAAACOwMMAB4AADcRNDYyFh0BATYzMhYVFAcJARYVFAYjIicBFRQGIiZJHSoeATkPEhUeEv6gAWASHhUSD/7HHiodMwKnFB4eFOYBDAweFBgP/tP+0w8XFR4MAQzlFR4eAAEASQAAAjsDDAAOAAAzETQ2MhYVESEyFhUUBiNJHSoeAVoVHh4VAtoUHh4U/YseFBUeAAABAEkAAAI7AwwAGwAANxEzFzczERQGIiY1EQcVFAYjIiY9AScRFAYiJkl+e3p/HiodYh4UFR5hHiodMwLZr6/9JxUeHhUCTowaFR4eFRqK/bQVHh4AAAAAAQBJAAACOwMMABEAADcRMwERNDYyFhURIwERFAYiJkmFAQgdKh6G/vkeKh0zAtn9pgIoFB4eFP0mAlj92xUeHgAAAAACAEkAAAI7AwwAFgApAAATND8BPgEzMhYfARYUDwEOASMiJi8BJjcGFB8BFjMyPwE2NTQvASYjIgdJGGsQPyYnPxBrGRlrED8nJj8QaxhyDQ1sCBIUCGsODmwIExEJAYY1MtcfKSkf1zRmNNcfKSkf1y5zHDwc1hEQ1yIYHhzVEhIAAAACAEkAAAI7AwwADwAZAAA3ESEyFh0BFAYrARUUBiImEzMyNj0BNCYrAUkBWj5aWj71HiodZfUUHx8U9TMC2Vk+tD5a9hUeHgFwHhW0FB4AAAIASQAAAjsDDAAhAEAAADcRND8BNjMyFhURFA4FBxczMhYVFAYrAScHBiMiJjcUOwE3JyY1NDYzMh4DFz4ENRE0JisBBwYVSUbhIC8ySggUDiMOLAUYQRUeHhWGJUsiLTJIZRUIbCUDHhUNFA8IDAIEHw4UCQ0KB+giewEaXj2+Hkky/uYXKSUZIg0kBD0eFBUeXkAeSTIWXF4HCxUeCxoRJAQEGQ0aHBEBGgkMwx4wAAAAAAIASQAAAjsDDAAZACMAADcRITIWHQEUBisBExYVFAYjIicDIxEUBiImEzMyNj0BNCYrAUkBWj5aWz06ywceFR0P6UUeKh1l9RQfHxT1MwLZWj40Plr+pA4LFR4ZAY/+ixUeHgHvHxQ0FR4AAAEASQAAAjsDDAAsAAA3NDYyFhUUFjsBMjUBJj0BNDY7ATIWFRQGIiY1NCYrASIdAgEWFQ4BKwEiJkkdKh4UDvkN/ooXQy75N1EeKh0VDvkMAXQZAkEv+TdQhxUeHhUOFA0B4iAmAy1CUDcVHh4VDRUKAwT+Ih4oL0NQAAABAEkAAAI7AwwAGAAAEzUhFRQGIiY9ASMRFAYjIiY1ESMVFAYiJkkB8h4qHWIeFBUeYR4qHQKFh4cVHh4VIv2MFR4eFQJ0IhUeHgAAAQBJAAACOwMMABsAADcRNDYyFhURFBY7ATI2NRE0NjIWFREUBisBIiZJHSoeHhTDFB8dKh5aPsM+WZcCQxQeHhT9vRUdHhQCQxQeHhT9vT5ZWQAAAQBJAAACOwMMABUAABM1NDYyFh0BGwE1NDYyFh0BAwYjIidJHSoelJQdKh7KDSIjDQIltRQeHhSh/oYBeqEUHh4UtP36ICAAAQBJAAACOwMMACsAADcRNDYyFhURFzM+ATcRNDYzMhYVER4BFzM3ETQ2MhYVEQcGKwEiJwYrASInSR0qHhwpAhQGHhUUHgYUAikdHSoeOQ8dYiASFR5hHg96AmAUHh4U/bswAyYKAUMVHR0V/r0KJgMwAkUUHh4U/aBhGSMjGQABAEkAAAI7AwwAIwAANzQ3EwMmNTQ2MzIXGwE2MzIWFRQHAxMWFRQGIyInCwEGIyImSQa4uAYdFR0Pm5oPHRUeB7i4Bx4VHQ+amw8dFR0zDQwBOgE6DA4UHhn++AEIGR4UDA7+xv7GDgsVHhkBCP74GR4AAAEASQAAAjsDDAAZAAATNTQ2MhYdARc3NTQ2MhYdAQcRFAYjIiY1EUkdKh6Ukx4qHsceFBUeAnNnFB4eFES+vkQUHh4UZ/7+vhUeHhUBQgAAAQBIAAACOwMMABMAADcBISImNTQ2MyEVASEyFhUUBiMhSAFo/ssVHR0VAcD+mAE1FR4eFf5BQAJnHhUUHkD9mR4UFR4AAAAAAgBJAAACOwMMABcAGwAANxE0NjMhMhYVFAYrAREzMhYVFAYjISImNzMRI0kdFQGNFR4eFcbGFR4eFf5zFR1kMDAzAqcUHh4UFR79vh4UFR4eRwJCAAAAAAEASQAAAjsDDAAPAAATNDYzMhcBFhUUBiMiJwEmSR0VHQ8BjQceFR0P/nMGAtoUHhn9WQ4LFR4ZAqcMAAIASQAAAjsDDAAXABsAADc0NjsBESMiJjU0NjMhMhYVERQGIyEiJiUzESNJHRXGxhUdHRUBjRUeHhX+cxUdAV0wMDMUHgJCHhUUHh4U/VkVHh5HAkIAAAABAEgAfwI7AmIAFAAANxM2MzIXExYVFAYjIi8BBwYjIiY1SM0NIB4OyAUeFRsOnZ4OGxUdvgGJGxv+gAwJFR4V7OwVHhUAAAABAEn/mwI7AAAADQAAFzQ2MyEyFhUUBiMhIiZJHRUBjRUeHhX+cxUdMhQeHhQVHh4AAAAAAQB6AagCCQMMABAAABM0NjsBMhcTFhUUBiMiJwEmeh4VYxoOywYeFRAQ/tYSAtoUHhP++gsNFR4MAP8PAAAAAAIASQAAAjsCOAAmADQAADc1NDY7ATIXNC4FKwEiJjQ2OwEyFhcTFAYjIiY1BwYrASImNxQWOwE3NTQmKwEiBhVJWD3BGBQBAQMGCxEMuhUdHRW6PVcCDR8VFB1KCg+VPVhlHBSHax8SwRMdljg+WAcHIQ8cDRAGHSoeVTz+ixUdHhQrB1g+FB0/LBIdHRQAAAIASQAAAjsDDAApAEMAADcRNDYyFh0BNjsBMh4FFxYdARQOBA8BBisBIi4BJxUUBiImNxQfARY7ATI+ATc2PQE0LgEnJisBIg8BBhVJHSoeRENLDRgYDhgHGwE1BA4HGgURESk4Sx02HRceKh1lEVYMFEsOFh4CEg0fARUUSxQMVhEzAqcUHh4U4kADCwUTBRcBLkTOEBsaDxoGDw4kFhcVDxUeHsIXDkoMDB4BDhfODhQaARMMSgsaAAAAAQBJAAACOwI4ACYAADc1NDc+AzsBMhYUBisBIg8BBh0BFB8BFjsBMhYVFAYrASIvASZJNAszITof0xUeHhXTFAxWERFWDBTTFR4eFdM5KVY04HhFLQkxGxkeKh0MSgsaeBcPSQweFBUeJEotAAAAAAIASQAAAjsDDAAtAEgAADc1NDY3Njc2OwEyHgQXNTQ2MhYVERQGIiY9AQ4CKwEiLgcnJjcUHgIXFjsBMj8BNj0BNC8BJisBIg4BBwYVSSonBQMpOEsQHhMeCB8CHSoeHiodFx02HksLExMOEQoRBhMCNGUMDRgEDxFLEg5WEhJWDBRLDhcaBBK1zjA7IAQCJAcHFAYcAecUHh4U/VkVHh4VEBYXFgIGBQoGDgURAitHDBYMEwMMDEoNGHgVEEoMDRoDEBYAAAAAAgBJAAACOwI4ADQAQQAANzU0PgE3NjsBMh4GHwEWHQEUBiMhFRQeAhcWMyEyFhUUBiMhIi4HJyY3ITU0JisBIg4BBwYVSSAaHyk4fQoTFAwUBxQECws1HhX+pgwNGAQPEQEFFR4eFf77CxMTDhEKEQYTAjRlASg8Gn0OFh4CEbXOIzwYGiQCBgQMBBECCgouRHwVHh8MFgwTAwweFBUeAgYFCgYOBRECK8tKGjYMHgEOFwAAAQBhAAACIQMMACQAABI0NjsBNTQ2OwEyFhUUBisBIgYdATMyFhQGKwERFAYiJjURIyJhHRUxaEp5FR0dFXkgLWMUHh4UYx0qHjEVAfAqHiJKaB4UFR4tICIeKh3+YBUeHhUBoAAAAAACAEn/LAI7AjgAQgBZAAA3NTQ+CDc2OwEyHgQXNTQ2MhYVERQOBA8BBisBIiY0NjsBMj4BNzY9AQ4CKwEiLgMvASY3FBY7ATI/ATY9ATQvASYrASIOAQcGFUkDAwsEEAQVAxcBKThLEB4THggfAh0qHgQOBxoFEREpONMVHh4V0w4XHAMSFx42HUsPHxIeBxARNGQ7G0sUDFYSElYMFEsPFxgGEuCjCxYQFAoTBhIDEwEkBwcUBhwBEhUeHhX93BAbGg8aBg8OJB0qHg4aAw4XjRUYFwcGFQUPDi1FGzYMSg4XThUQSgwOGAQSFAAAAAABAEkAAAI6AwwAIAAANxE0NjIWHQE3NjsBMhYXExQGIyImNQMuASsBBxEUBiImSR0qHmAmKzk9VwIMHRUUHg0CGxRHox4qHTMCpxQeHhT3PRhVPP6MFR4dFAFzExxp/skVHh4AAgB6AAACCQM2ABoAKgAANzQ2OwERIyImNDY7ATIWFREzMhYVFAYjISImEzU0NjsBMhYdARQGKwEiJnoeFWNjFR4eFZUUHmIVHh4V/tcVHmMeFTIUHh4UMhUeMxQeAW4dKh4eFf5gHhQVHh4CvCoVHR0VKhUeHgAAAgB6/ywCCQM2AB8ALwAAFzQ2MzIeAjsBMjY1ESMiJjQ2OwEyFhURFAYrASImJxM1NDY7ATIWHQEUBisBIiZ6HhUUGAkZFWIUH5UVHh4VxhUeWT5iOFYI+B4VMRUeHhUxFR5NFR4bHxsdFAIRHSoeHhX9vT5YSjUDLyoVHR0VKhUeHgAAAQBJAAACOwMMAB8AADcRNDYyFhURJTYzMhYVFA8BFxYVFAYjIiclBxUUBiImSR0qHgEIDhIVHhLL/RIdFRMP/vcwHiodMwKnFB4eFP5x4QweFRcPrtgPFxUeDOMqkhUeHgAAAAEAegAAAgkDDAAbAAA3NDY7AREjIiY1NDY7ATIWFREzMhYVFAYjISImeh4VYmIVHh4VlRQeYhUeHhX+1xUeMxQeAkIeFRQeHhT9ix4UFR4eAAAAAAEAQQAAAkICOAAuAAA3ETQ2MzIWFzYzMhc3NjMyFhcTFAYjIiYnAyYrAQcRFAYjIiY1ETQrAQcRFAYiJkEdFRAbBSktPSQWISovSAEPHRUUHgEOAg8GRB4UFR4WCEseKh0zAdIVHhQPIzASG0Iv/m8VHh0UAY8TOv6aFR4eFQGKFkH+oRUeHgABAEkAAAI6AjgAIAAANxE0NjIWHQE3NjsBMhYXExQGIyImNQMuASsBBxEUBiImSR0qHmAmKzk9VwIMHRUUHg0CGxRHox4qHTMB0hUeHhUiPRhVPP6MFR4dFAFzExxp/skVHh4AAgBJAAACOwI4ACYAQAAANzU0PgE3NjsBMh4FFxYdARQOBA8BBisBIi4EJyY3FB4CFxY7ATI+ATc2PQE0JisBIg4BBwYVSSAaHyk4fQ0YGA4YBxsBNQQOBxoFEREpOH0QHRQbCxsENGUMDRgEDxF9DhYeAhI8Gn0OFh4CEbXOIzwYGiQDCwUTBRcBLkTOEBsaDxoGDw4kBwcSCBgDK0cMFgwTAwwMHgEOF84aNgweAQ4XAAAAAgBJ/ywCOwJNACwASgAAFxE0NjIWHQE+CDsBMh4BFx4EHQEUDwEGKwEiLgEnFRQGIiYTFB4CFx4CFxY7ATI/ATY9ATQvASYrASIPAQYVSR0qHgITBhIKEg8TFQsVHTcbGQIwDB0KNVYpORUfNyAVHiodZQoKFQMHGBQJDhUVFAxXERFXDBQVFQ5aDqICvRQeHhQbAhQFEQYNBQcCGBUXAikPJiYXoUQuSiQYHBfYFR0dAZIMFQsSAwcZFAgODEoNGKEYDUsMDlsLFwAAAgBJ/ywCOwI4AC0ASAAANzU0Njc2NzY7ATIeBBc1NDYyFhURFAYiJj0BDgIrASIuBycmNxQeAhcWOwEyPwE2PQE0LwEmKwEiDgEHBhVJKicFAyk4SxAeEx4IHwIdKh4eKh0XHTYeSwsTEw4RChEGEwI0ZQwNGAQPEUsSDlYSElYMFEsOFxoEErXOMDsgBAIkBwcUBhwBEhUeHhX9WRUdHRXlFhcWAgYFCgYOBRECK0cMFgwTAwwMSg0YeBUQSgwNGgMQFgAAAAABAEkAAAI7AjgAHwAANxE0NjIWHQE3NjsBMhYdARQGIiY9ATQmKwEHERQGIiZJHSoedwsSYz1ZHiodHRRRph4qHTMB0hUeHhU7ZghZPRwVHR0VHBQdj/7vFR4eAAEASQAAAjoCOAA0AAA3NDYzMhYXHgE7ATI2NTQnJS4BNTQ3NjsBMhcWFRQGIyImKwEiBhUUFwUeAR0BDgErASInJkkcFRImCQIUBMsYGx3+6yIqJSY11kswCh4VEi0T1g0PEAEWJjUBWj+9ST4TXRUdHQMBCSAWIg14D0MnMyQmPw0RFR4rEgsSBngRTS4CP1k1EAABAEkAAAI7AuIAKgAAEjQ2OwE1NDYyFh0BMzIWFAYrAREUFjsBMj4CMzIWHQEOASsBIiY1ESMiSR0VMR0qHsUVHR0VxRwUZBQZCRkUFR4KVTdkPVgxFQHwKh53FR4eFXceKh3+wxQdGx8bHhUINEtZPQE9AAEASQAAAjsCOAAgAAATNDYzMhYVEx4BOwE3ETQ2MhYVERQGIiY9AQcGKwEiJidJHRUUHg0CGxRHpB0qHh4qHWEmKzk8WAICBRUeHRT+jRQbaAE4FR4eFf4uFR4eFSM+GFU7AAABAEkAAAI7AjgAGgAAEzU0NjIWHQEbATU0NjIWHQEUBwMGKwEiJwMmSR0qHpOVHSoeBacNIT8hDacEAbBVFR4eFUr+rQFTShUeHhVVCgr+gh4eAX4IAAAAAQA+AAACRQI4ACsAABM0NjMyFhcTFzc1NDYzMhYdARc3Ez4BMhYdAQMHDgErASIvAQcGKwEiJi8BPh4VFB0BCiBCHhUUHkIgCgEdKB8LMwUbETEdDzc4Dx0xERsFNAIEFR8dFP7dbHJyFB4eFHJybAEjFB0eFAL+yqoQFBlfXxkUELYAAQBJAAACOwI4ACMAADc0PwEnJjU0NjMyHwE3NjMyFhUUDwEXFhUUBiMiLwEHBiMiJkkKraEMHhUXEJWUEBcVHgyhrQseFRgPn6APGBUdMxMN0MIPERUeE7OzEx4VEQ/C0A4SFR4SwcESHgAAAQBJ/ywCOwI4ACMAABY0NjsBNyMiJwMmPQE0NjIWHQETMxM1NDYyFh0BFAcBBisBIkkdFWdDFSIMlQQdKh6DIIQeKh4F/vwNIogVtyoemR8BUwgMVRUeHhVK/tQBLEoVHh4VVQoK/a4eAAAAAQBJAAACOwI4ABwAADc1NDcBISImNDYzITIWHQEUBwEhMhYVFAYjISImSQ8BYP7bFR0dFQF1FR4Q/qEBPBUeHhX+cxUdMyoXDQFSHSoeHhUqFRD+rx4UFR4eAAABAEkAAAI7AwwAKgAAEjQ2OwEyNj0BNDY7ATIWFRQGKwEVFAcWHQEzMhYVFAYrASImPQE0JisBIkkdFWEWHT0olBUeHhWUJyeUFR4eFZQoPR4VYRUBcSoeHRW8KTweFBUevDksLDm8HhQVHjwpvBQfAAAAAAIBDwAAAXQDDAAIABEAACURMxEUBiMiJhkBNDYzMhYVEQEPZR4UFR4eFRQeMwEh/t8VHh4BmwEhFB4eFP7fAAABAEkAAAI7AwwAKgAANzQ2OwE1NDcmPQEjIiY1NDY7ATIWHQEUFjsBMhYUBisBIgYdARQGKwEiJkkdFZQnJ5QVHR0VlCk8HRViFR4eFWIVHTwplBUdMxQevDksLDm8HhUUHjwpvBQeHiodHxS8KTweAAAAAAEASQGqAjsDCwAmAAATNTQ2MzIWHQEUFjI2PQE0NjIWHQEUBiMiJyY9ATQmIgYdARQGIiZJXTw6WB0oHR0qHlw9PCssHSgcHiodAgVvQVZYPzQUHx8UbxUeHhVvQVUrLj00FB4eFG8VHR0AAAEAcQAAAmMDDAATAAAzETQ2MhYdATMRIREUBiImPQEjEXEdKh5hASweKh1iATEVHh4VzAKn/s8VHh4VzP1ZAAABAHEAAAJjAwwAFQAANxEhETQ2MhYVERQGIiY1ESERFAYiJnEBjR0qHh4qHf7YHiodMwGGASEUHh4U/VkVHh4VASH+3xUeHgABAHEAAAJjAwwAGAAAExE0NjIWFREhETQ2MhYVESMRFAYjIiY1EXEdKh4BKB0qHsceFBUeAVQBhhQeHhT+3wEhFB4eFP56/t8VHh4VASEAAAEBN/+bAZwEUgADAAAFETMRATdlZQS3+0kAAAABAFf/5wJ8AyUAAwAAFxEhEVcCJRkDPvzCAAAAAQDtAAAB5gD6AA8AADc1NDY7ATIWHQEUBisBIibtHRWVFR0dFZUVHTOUFR4eFZQVHh4AAAEAcQAAAmMDDAAeAAATNDcBNjIfARYdARQHBRUUBiImPQE0NyU1JwUGIyImcREBKg8kD2MSEv7oHiodEQEZMf73DxIVHQHbGA4A/wwMVQ8XVRcQ7+cVHh4V/hkO7yYq4wweAAABAQMBqAHRAwwAEwAAATQ2OwEyFhUUBhUDFAYiJjU0NjUBAyAVYxQiATMfKCEBAtoUHhoSAQQB/wAUHhoSAQQBAAAAAAEA1AAAAf8BZAAUAAATNTQ2OwEyFh0BFAYrASImPQEjIibUHRXHFR0dFTIVHWMVHQEHKhUeHhX+FR4eFaEeAAABAHEBVAJjAbkACwAAEjQ2MyEyFhQGIyEicR0VAY0VHh4V/nMVAXEqHh4qHQAAAAAAAA4ArgABAAAAAAAAAFYArgABAAAAAAABAAQBDwABAAAAAAACAAcBJAABAAAAAAADACEBcAABAAAAAAAEAAUBngABAAAAAAAFAAoBugABAAAAAAAGAAQBzwADAAEECQAAAKwAAAADAAEECQABAAgBBQADAAEECQACAA4BFAADAAEECQADAEIBLAADAAEECQAEAAoBkgADAAEECQAFABQBpAADAAEECQAGAAgBxQBNAGEAdAB0AGgAZQB3ACAAUwBrAGEAbABhACAAKAAyADAAMQAxAC0AMQAyACkAOwAgAGIAYQBzAGUAZAAgAG8AbgAgAGMAbwBkAGUAIABiAHkAIABSAGkAYwBoAGEAcgBkACAAQgAuACAAVwBhAGwAZQBzACAAKAAxADkAOAA4AC0AOAA5ACkAIABhAG4AZAAgAFQAbwByACAATABpAGwAbABxAHYAaQBzAHQAAE1hdHRoZXcgU2thbGEgKDIwMTEtMTIpOyBiYXNlZCBvbiBjb2RlIGJ5IFJpY2hhcmQgQi4gV2FsZXMgKDE5ODgtODkpIGFuZCBUb3IgTGlsbHF2aXN0AABPAEMAUgBBAABPQ1JBAABSAGUAZwB1AGwAYQByAABSZWd1bGFyAABGAG8AbgB0AEYAbwByAGcAZQAgADIALgAwACAAOgAgAE8AQwBSACAAQQAgADoAIAAyADcALQA5AC0AMgAwADEAMgAARm9udEZvcmdlIDIuMCA6IE9DUiBBIDogMjctOS0yMDEyAABPAEMAUgAgAEEAAE9DUiBBAABWAGUAcgBzAGkAbwBuACAAMgAgAABWZXJzaW9uIDIgAABPAEMAUgBBAABPQ1JBAAAAAAIAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAbAAAAAEAAgADAAQABQAGAAcACAAJALcACwAMAA0ADgAPABAAEQASABMAFAAVABYAFwAYABkAGgAbABwAHQAeAB8AIAAhACIAIwAkACUAJgAnACgAKQAqACsALAAtAC4ALwAwADEAMgAzADQANQA2ADcAOAA5ADoAOwA8AD0APgA/AEAAQQBCALYARABFAEYARwBIAEkASgBLAEwATQBOAE8AUABRAFIAUwBUAFUAVgBXAFgAWQBaAFsAXABdAF4AXwBgAGEBAgEDAQQBBQEGAQcBCAEJAQoBCwd1bmkyNDQwB3VuaTI0NDEHdW5pMjQ0MghTRjExMDAwMAtibGFja3NxdWFyZQpwZXJpb2QuYWx0DHF1ZXN0aW9uLmFsdA9xdW90ZXNpbmdsZS5hbHQJY29tbWEuYWx0Cmh5cGhlbi5hbHQAAAAB//8AAgABAAAADgAAABgAAAAAAAIAAQADAGsAAQAEAAAAAgAAAAEAAAAKAEQAogACREZMVAAObGF0bgAkAAQAAAAA//8ABgAAAAEAAgADAAQABQAEAAAAAP//AAYAAAABAAIAAwAEAAUABmFhbHQAJnNzMDEALHNzMDIAMnNzMDMAOHNzMDQAPnNzMDUARAAAAAEAAAAeAAEAAQAcAAEAAgAaAAEAAwAYAAEABAAWAAEABQAAAQAAAAEBAAABAgAAAQMAAAEEAAYADgAWAB4AJgAuADYAAwAAAAEAMAABAAAAAQBkAAEAAAABAGgAAQAAAAEAbAABAAAAAQBwAAEAAAABAHQAAQAuAAUAEAAWABwAIgAoAAIACgBpAAIADwBqAAIAEABrAAIAEQBnAAIAIgBoAAEABQAKAA8AEAARACIAAQAGAFYAAQABABEAAQAGAEYAAQABACIAAQAGAF8AAQABAAoAAQAGAFsAAQABAA8AAQAGAFsAAQABABAAAQAAAAoALAAuAAJERkxUAA5sYXRuABgABAAAAAD//wAAAAQAAAAA//8AAAAAAAAAAAABAAAAAMw9os8AAAAA1gbbzAAAAADaAyOv"),FontLib.loadFont("OCR-B",96,100,"AAEAAAAPAIAAAwBwRkZUTXxHn14AADmUAAAAHEdERUYAkwAEAAA4IAAAACBHUE9TuP+4/gAAOWQAAAAwR1NVQnZYZVQAADhAAAABJE9TLzJa+GPlAAABeAAAAGBjbWFwzJGg2QAAA2QAAAFCZ2FzcP//AAMAADgYAAAACGdseWbm+CwyAAAFeAAALwRoZWFkFgqHXQAAAPwAAAA2aGhlYQeFAeAAAAE0AAAAJGhtdHgIFCYVAAAB2AAAAYpsb2NhZAZYlAAABKgAAADObWF4cACtAGkAAAFYAAAAIG5hbWWukZg3AAA0fAAAAnlwb3N0tfQXywAANvgAAAEdAAEAAAACAADO4NltXw889QALA+gAAAAA2gMiKgAAAADaAyIqAA7/GQLWAwsAAAAIAAIAAAAAAAAAAQAABFL+sABaAtMAAP/9AtYAAQAAAAAAAAAAAAAAAAAAAF8AAQAAAGYAZgAFAAAAAAACAAAAAQABAAAAQAAAAAAAAAACAsMBkAAFAAACigK8AAAAjAKKArwAAAHgADEBAgAAAgAFCQAAAAAAAAAAAK8AAABoAAAAAAAAAABQZkVkAEAAIAB+AyD/OABaBFIBUAAAAAEAAAAAAiAC+QAAACAAAQLTAAAAAAAAAtMAAALTAAAC0wD1AtMAdALTAEQCvwA/Ar8APwLTAEQC0wDnAtMA0wLTAIgC0wBEAtMARALTAHIC0wBEAtMAxALTAIACvwA/AskAXgK/AFACvwA/Ar8APwK/AFkCvwA/Ar8APwK/AD8CvwA/AtMA1gLTAG8C0wBBAtMARALTAEEC0wBgAtMARAK/AEUCvwA/Ar8AbwK/AHICvwBtAr8AoAK/AEcCvwBbAr8AeAK/AFACvwBNAr8AWwK/AD8CvwBNAr8AQgK/AFsCvwBBAr8AZwK/AGECvwA/Ar8ATQK/AD4CvwA/Ar8AUwK/AFYCvwBbAtMApQLTAIAC0wBVAtMARALTAEQC0wC2Ar8ATQK/AEoCvwB1Ar8APwK/AE0CvwBhAr8AQgK/AGoCyQCDAskAZwK/AHsCyQDLAr8APwK/AE0CvwA/Ar8ASgK/AD8CvwCaAr8AZwK/AE0CvwBNAr8AQgK/AEECvwBhAr8APwK/AGEC0wBEAQwARABSAnICBgG2AA4AAAAAAAMAAAADAAAAHAABAAAAAAA8AAMAAQAAABwABAAgAAAABAAEAAEAAAB+//8AAAAg////4wABAAAAAAAAAQYAAAEAAAAAAAAAAQIAAAACAAAAAAAAAAAAAAAAAAAAAQAAAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALABiAMYBUAG6AkICYgKMArQC8gMaAzoDVgNwA5QEEgQ2BIgE2AUSBVYFngXSBjQGegaoBtwHDAcyB1oHxAhUCIQI2glACXgJrAnaCjQKYgqYCswLAgskC2QLlgvuDB4MgAzODUQNbA2eDcgOEg5ODoAOsg7WDvoPHA9ED2APgg/eECoQaBCyEPgRLBGUEdISAhJOEoASqBLyEygTVhOiE+gUIhSYFN4VGBVGFYYVvBXyFiAWbBaEFs4XDhcmF0QXaheCAAAAAgD1/7wBfQL9AA8AGwAAFzU0NjsBMhYdARQGKwEiJhMRNDYyFhURFAYiJvUbEi4SGxsSLhIbFxskGxomGhcuEhsbEi4SGxsBcgGHExobEv55EhsaAAAAAAIAdAHHAgkC/QASACMAABM1NDY7ATIXFhUwFQ8BDgEjIiYlNTQ2OwEyFxYdAQcOASMiJnQbEh0SDg4BHQIZEhEcASQbEhcRDg4ZBBYREhsB9NwSGw0MDwEC5BAXGxLcExoNDBAE5RAUGwAAAAIARP/4Ai4DAABEAEgAADc0NjsBNyMiJjQ2OwE3PgEzMhcWFQczNzYzMhYdAQcXHgEVFAYrAQczMhYUBisBBw4BIyImPQE3IwcOASMiJyY1NycuATczNyNEGhMVJicSGxoTOygDGRASDQ4liCgNHxIbIwUQFxsSFCUlExobEjopAxoPEhskhykDGRASDQ4mBRIXnoglh/4TGqcaJhqxDhUODhCosSMaEwqcAQMZERIbpxskG7YOFRsSCqK2DxQODRGsAQIaPqcAAwA///sCHwL9AEcAWABfAAA3JjU0NjMyFxYXFhczNScuAScuAjU0NzY/ATU0NjIWHQEXFhcxFhUUBiMiJyYvARUXFhcWFx4BFRQHBg8BFRQGIiY9ASMmJxMGFRQXFhcWFxYXHgIfATUTNzY1NC8BQQIbEhYVFwwYLQUEIS4cGyIWNjZSBBoiGgRpOAkbEhcOITUGBCwcHR8fHjc3UwQaIhoFlSi8YwMECAgFBgwMChwCB1YGZWQHoAUMExodIQYNBNwBChEPDyQ2IkwqKwoBCRMaGxIJAQ5SDA4SGhMsCwHFAQ4MDBYVPytNMDENAQYSGxoTBw1kAcoORQsKCggHBQUGBgUKAQKq/iABFEo8JAIAAAAABQA///gCHwMAAA0AHAAoADcARwAAJSIVFBcWHwEzMjc2NTQHJjU0NzYzMhcWFAcGIyIDIhUUFzsBMjc2NTQHJjU0NzYzMhcWFAcGIyICJjU0NwE2MzIWFRQHAQYjAaIhBQUOAQgRCQl6HyAfNzogICAgOjiuIxgBChEJB3wgISA6Nx8fHx83OycbBgGMDRQSGwb+exAYtTIPDxABAhAPEjKVKDg5KyspKXIqKQKuMikIEA8SMpUoODkrKykqcikp/hQbEw0JAq0MGxIMCv1dFwAAAAADAET/9wIuAwAAQgBOAFwAADc0PwEnJjU0NzYzMhcWFRQHDgEHDgIPARc3NjU0NjIWFRQPARcWFx4BFxYVFAYjIicmJyYnJicmJyYvAQcGKwEuATcUFzMyPwEnBwYHBhMUHwE3Njc2NTQnJiMiRF8EA0Q1NVhKNTQJChQYFxY+BASXBBUcJBs3AgICBwcHAwMbEgYFBgQDBAUCAQUGAQMEPlEGYnVafwYwKAShBRwPEBwwAwRMHiAcGyJozXJUAwRdVVQwMCgmRBsaGyMXGBMuAwPSCDRFExscEnxTAwIFCAgKCQgIEhsCAgEBBQUCAQcIAgICJwFyYnkCFwLhBB0bGwFXOEQEAzYlJx0eDgwAAAEA5wGIAY0C/QASAAATNDY7AR4BFTAVBwMGKwEiJyYn5xsSURAXARUIJCISDQ0BAtATGgIZDwEB/twlCwoRAAABANP/+AHpAwAAGQAAEzU2NzYzMhYVFAcGBwYHFRQXFhUUBiMiJybTA80LDhIbFE4sLQGoFBsSDgvQAXMG8I8IGhMXDjNKS20FvmsOGBMaB4wAAAABAIj/+AGfAwAAGAAANzQ3NjU0LwEmJyY1NDYzMhcWFRQHBiMiJogUqakBBwYGGxIOC9HRCw4SGyUYDm7AwnMBAgwMChIbCJDv7I4HGwAAAAEARACeAi4ChQAqAAATNDc2Mxc1NDYyFh0BNzE2MzIWFRQPARcWFRQGIyIvAQcGIyImNTQ/AScmRA4OEZsbJBuNBggSGyB6UAUaExQMV3AMFBMaCV6MHwG+Eg8OM54TGhsSni4DGxIgCymICwwTGguWlgsbEg0Ofy4MAAABAEQAagIuAo0AGwAAEjQ2OwE1NDYyFh0BMzIWFAYrARUUBiImPQEjIkQbEpsaJhqbEhsbEpsbJBubEgFpJhq3ExobErcbJBu4EhsaE7gAAAEAcv9NAeYAygASAAAXNDcTNjsBMhYdARQHAwYrASImcgWyDBVvEhsN/gwUHBMahgwKAS4MGhMfEwz++w0aAAABAEQBQQIuAbcADwAAEzU0NjMhMhYdARQGIyEiJkQaEwGQExoaE/5wExoBbhwTGhsSHBIbGgAAAAEAxP/7Aa0AtgAPAAA3NTQ2OwEyFh0BFAYrASImxBsSjxIbGxKPEhsoYRIbGhNhExobAAABAID/+AHyAwAAEwAANzQ3MwE+ATMyFhUUByMBDgEjIiaAAwEBGAQYDRIbAwH+6AQYDRIbJQoHAq4MEBsSCgf9UgwQGgAAAAACAD//+AIfAv8AJQBUAAAFIyYnLgEnJicmNTQ2Nz4BNz4CMzIeARceARceARUUDgUDFRQWFxYXHgE7ATI2Nz4BNz4BPQE0JicmJyYnJicmJyYnLgEjIg4CBw4BBw4BATMEOywsNA8QBQUDBgYVEhIySC4tSDITEhUGBgMEDRQmMEbFBQkIEBA4KBUcLA0OEgQFAwEBAQMDBQUICAsMDg8nGBknHhcICAoCAgMIARMSOy8vMC9AOVEvMEEhICYYGCYgIUIvL1I4KEFMOTYkFgGwUi1AJSUXGB8XFhUxHyA0Hy4fJRwdEBEXFw4ODw8ICQoLFB0SESkXFi8AAAABAF7/+wGMAv0AFQAAEiY1ND8BNjsBMhYVERQGIiY1EQcGI3gaDbcNECASGxskG4kNEQIJGxIVCp0LGxL9WBIbGhMCYXULAAABAFAABgILAwAANwAAEiY1NDc2MzIXFhUUBw4BBw4BBw4BBwYHBgcVITIWFAYjISImPQE0NzY3Njc2NzY1NCcmIyIHBiNrGxNbcVs9Pg0NISAgISMmIhgYCwsCASgTGhsS/qoSGwoRLy9EXhkcJSM0Wj4LDwJyGxEZDTw6OV0lIiMsGxsYFxkaGhkgHysFGyQbGxIVTiI8LzAuPyQkKDUhICwIAAEAP//4AhYC/AA3AAA3JjU0NjMyFxYzMjc2NzU0JyYnJiMiJjU0PwEhIiY0NjMhMhYdARQPARcWFxYdAQYHBiMiJyYnJlQVGxIGC0BGTDQ1BCAeLCs1ERoJuP7nEhsaEwFhEhsOoQhVNjUFUE5wHBwcIyMeEBgTGwQdJidKCjMkIw8OGxMSCswbJhobEiQQDrECFjs7WRBtQEADAwcIAAABAD//+wIfAv0AKAAANiY9ATQ3Ez4BMzIWFRQHAzM1NDYyFxYdATMyFhQGKwEVFAcGIiY9ASNaGwXVBBYMEhoFyMMaIg0OOhMaGxI6Dg0iGvWpGhMrCAsBzwsPGxIKCf5GeRIbDg0SeRskG4ESDQ4bEoEAAAIAWf/4AfcC/AAqAC0AABYmNDYzMjc2NTQnJiMiByMiJj0BEz4BMyEyFhQGKwEHMzIXFhUUBwYHBiMSIjN0GxsSyjsSIi1xHyAEEhsOAhkSARwTGhsS8ggTf01OFxgkYL4YAQEIGicacSIfSSU1AxkSAwD/EhgbJBydQUB+NS4vIVoBrQAAAAACAD//+AIfAv0AHwAvAAA3Jic1NDc2Nz4BNzYzMhYVFAcGDwE3NjMyFxYVFAcGIgMGFRQXFjMyNzY1NCcmIyKFQwNFHCgnNjILFBEaC3E1BwsdHm1BQkRE0AYoKilDQikrJyZJRzlBawx9ci80NT85DRsSEQ6ATQoCBkRFdGlCQgFkK0xEKCcoKENOKisAAAABAD//+wIfAvwAHwAAEiY0NjMhMhYVFAcGBwYHBhUUBiImNTQ3Njc2NzY/ASFaGxoTAYYTGjsSNDQWQRoiGkwXNDURGAkC/q8CoRsmGhsSTFkcQUIpeMETGxoU2o0pRUYaKBQHAAAAAAMAP//3Ah8DAAAVACQAQgAAEwYVFBYXHgEXOwE2NzY3PgE1NCcmIhMGFRQXFjsBMjc2NTQvAQMmNTQ/AScmNTQ3NjMyFxYVFAcGDwEXFhUUBgcjIuEmEhUUGxwCAhwODhQUEiYlUimXLSpAFDUmJ5ICrUWOBgZsQD9PTkBAHB0zBgaOdFIqZwKSFCYZJhAPEA4NCAgPECcZJhQU/s9PXjgfHyMjMF9OAv67Olx5YgQEQmtJLzAwMEg7KSghBARieU96BwACAD//+wIfAwAADwAtAAATBhUUFxYzMjc2NTQnJiMiAyY1NDc2MzIXFhUUBwYHBgcGIyImNDc2PwEHBiMixSwqKER3FQoqKUM/bURIRmJlRUYVFSZTeA0PERoOX0QFChogagJ1MENBKShJIShLLC3+tENlaEtLRkZyRzk5QpFvDBomDltuCgIEAAAAAAIA1v/7AZwCEAAPAB8AADc1NDY7ATIWHQEUBisBIiYRNTQ2OwEyFh0BFAYrASIm1hsSbBIbGxJsEhsbEmwSGxoTbBMaKFATGhsSUBIbGgF+UBMaGxJQEhsaAAAAAgBv/1IBswIQABIAIgAAFzQ/ATM2OwEyFhUUBwMGKwEiJhM1NDY7ATIWHQEUBisBIiZvA3wBCR9vEhsBzA4RKxIbexsSbBIbGhNsExqBDAf9GRsSDgP+9Q0aAidQExobElASGxoAAAABAEEARQIuArMAHQAAEy4BJyYnLgE1NDcBMDE2MzIWFRQHDQEWFRQGIyInTwEGAQECAQIOAZkLDhIbDf6hAV8NGxIOCwFcAQUBAgMECAcREAEPCBsSFwnq6g4SEhsIAAACAEQA3QIuAhsACwAXAAA2NDYzITIWFAYjISImNDYzITIWFAYjISJEGxIBkBIbGhP+cBMaGhMBkBMaGxL+cBL3JhobJBv+JhobJBsAAQBBAEUCLgKzABcAAAkBBiMiJjU0Ny0BJjU0NjMyFzAxARYVFAIg/mcLDhIbDQFf/qENGxIOCwGZDgFc/vEIGxISDurqCRcSGwj+8RAREgACAGD/vAH1AwEAOQBLAAATNTQ2NzYzMhcWHQEOAQcGBwYHBhUUBwYiJjU0NzY3Njc2NzY3NjU0JyMiJyYrAgYdARQHBiMiJyYTNTQ2OwEyFh0BFAcGKwEiJyZgPi8vNlA6OQEsHwcUFgkJDg0kGwoKCwwUFQgSEBFTAQUICgQDAW4NDRMSDQ2UGxIuEhsODRIuEg0OAjQMPFsVFTAwWAIxZCMIExQOCwsUDw8dFRoYFw4OFBUKEyIiG0IVAQIOUgkUDw4ODv3MMRUdHRUxFA8PDw8AAAIARP/yAi4DBABKAGUAADc1NDcyHwE3NjMyFxYVERY7ATY3Njc+AT0BNCYnLgEnJicmKwEGBw4BIyInJj0BNjc2NzMyFhcWFx4BHQEUBwYHBiMiLwEHBisBJjcUFxYXHgEXMzI3Njc9AiYnJiMiBwYHDgEVRIgvJwUCDhkSDQ4CHAETDQwEBQMDBQUXEBEbGyMJggsCGRETDQ0MPT9eCTpZGxsREQ0KCiMmNzYdAwQrPQiMWgEBBQQYEwYcEQ8NDRcXHBALCgMEAtIB7wIdAwUYDw8T/vk2AQwNFhUmHZgqPyYlNBcYDAwGVxIYDg8VB1ItLgMqIyM1NXBGfFsxMCInJgQDKAXWGw8QFBUVAREQHQGMARoTFAwMFhQiGAAAAAIARf/1AhoC9gAZABwAABYmPQETPgE7ATIWFxMUBwYjIiYvASMHDgEjEwMzYBufBBgOQg0XA6MODhIPGQMtyywDGQ+9T54LHRUOAp4OFREM/U0TDw8VD8PDDxUCov6qAAMAPwAGAh8C/QAhACsAOQAANiY1ETQ3NjsBMhcWFxYXHgEVFA8BFx4BHQEUBgcGBwYrARMVNzI9ASYnJiMDFRcyPQEmJyYnJicmI1obDQ0TpyQVFR4dFiwyOgQEIicnJCUvLz6nLXqyASspQZaWiAMODRgYGRkkBh0VApIWDw4BAgcIDRxiOVo4BAQeWDACMlkfHwsLAVr1AXwBPh0cATrVAWMLIRUWCwoDBAABAG//8gHwAwsARQAAEyYnNTQ2NzY3Njc2NzMyFxYXFRQHBiMiJyYnJicwMSYrAQYRFR4BFxYXFhceATMyNzY3PgEzMhcWHQEGBwYjIicmJyYnJnYGAQ0QERkYJyQvBTsuLQ0NDRITCQsICQsVHQWBAQQFBAoJDg4tHBwTFgQDGRASDQ0KLS09MiUoGBkREQD/NT8OQGw0MyUkFhYCJiY9ChQPDw0NFRYKEgf+6RIlOiMkGhoXFxoPDxoSFw8PFAo8JiYVFSQkMzMAAAACAHIABgIFAv4AFAAhAAA3JjURNDc2MzIXFhcWFRQHBgcGIyITJxE3Njc2NTQnJicmgA4NDRNmQ0M1RUhGayJLEkUGBmU5OyEgMysVDxUCkxQPDyssTmiFi19eFwcCkQH91AELQUB1UkFAKyQAAAAAAQBtAAYCEwL7ACIAADYmNRE0NzYzITIXFhQGIyEVMzIXFhQHBisBFSEyFxYUBiMhiBsNDRMBTBMNDRsS/uHvEg0ODQ0T7wEfEw0NGxL+tAYdFQKRFQ8ODg8qHdQPDykPDvUODyodAAABAKD/9QICAvoAHgAANyY1ETQ3NjMhMhcWFAYrARUzMhcWFAcGKwERFAcGIq4ODQ0TAQgTDQ0bEtuuEg0ODg0Srg4NJAQPFQKgFA8PDg8qHdQPDygPD/7KFQ8PAAEAR//xAg4DCAA+AAA3Jj0BNDc2NzYzMhcWFxYVFAYjIicmIyIHBgcGFRQXHgEzMj8BNSMiJyY0NjsBMhYVERQHDgEHDgEHBiMiJyZeFxcXLEZeExNYNwsbEhQOK0M+Kh8PEBwSTDUuMgNyEgwNGhGfEhsHCBIREhEQLC5sQivEV2MDYVNUME8DEEgOExQdETYxJD4+SWlYODoUAckODykdHRX+6Q4LDA4ICAYFDk0wAAAAAAEAW//1AgIDBAAdAAAWJjURNDc2MhYVETMRNDc2MhYVERQGIiY1ESMRFAZ2Gw4NJBvzDg0kGxskG/MbCx0VAqoVDw8dFv7lARsVDw8dFv1WFR0dFQEt/tMVHQAAAQB4AAYB5gL6ACMAADcmNDc2OwERIyInJjQ3NjsBMhcWFAcGKwERMzIXFhQHBiMhIoYODQ0TYEwSDQ4NDRPsEw0NDg0STGATDQ0ODRL+7BIVDykPDgIsDw8oDw8PDygPD/3UDg8pDw8AAAAAAQBQ//ABpQMHACMAADYmNTQzMhcWHQEGFRQXFjMyNzY1ETQ2MhYVERQXFBUUBiMiJ4Y2MBMMDQIcGiAeFRcbJBsBZ0EpJyBXN04ODxUKDAQpGhoYGS0CJBUdHRX95wMFBAJMchcAAAABAE3/9QIfAwcAHwAANyY1ETQ2MhYVEQE2MhYUBwMBFhUUBwYjIicBERQHBiJbDhskGwEUDiQbDvwBEw4ODRITDf7VDg0kBA8VAq0VHR0U/ucBOw8dKRD+3P6+ERIVDw8OAVv+yRQPDwAAAAABAFsACwIfAwcAEwAANyY1ETQ2MhYVESEyFxYUBwYjISJpDhskGwE9Ew0NDg0S/pYSGg8UApkUHR0U/ZkPDygPDwAAAAEAP//1Ah8DBAAoAAAWJjURNDY7ATIXFhcbAT4BOwEyFxYVERQGIiY1EQMGBwYjIiYnAxEUBlobGxJNDgwLBE1NAxgOTRINDhskG2wGCwoPDhcEbRsLHRUCqhYdCgsO/uUBGw4VDw8V/VYVHR0UAmv+cxAKChQPAY79lRQdAAAAAQBN//UCEQMIAB8AADcmNRE0NjsBMhYXExE0NjIWFREUBwYrASInAxEUBwYiWw4bEiUMFwXwGyQbDg0SJhwM7w4NJAQPFQKtFR0PDf3JAiMUHR0V/VMVDw8bAjf93xQPDwAAAAIAQv/yAhwDBwAeADkAADYmPQE0PgE3Njc2MzIXFhceAR0BFAYHBgcGIyInJicSBh0BFBYXFhcWMjc2Nz4BNTQmJyYnJiIHBgdkIhEmHRsoJy81LS4eHiEhHR4uLTY1LS4eLBESEREdHkgeHREREhERER0eSh8dEKuLRwM2bWcnJxcYIiE4OItJA0eLOjkjIyMjOQGdYSwELmItLx4fHx4vLWMtMWQtLR0dHh4vAAAAAgBb//UCHwL8ABUAHwAANyY1ETQ3NjsBMhcWFRQHBisBERQGIhMVMzI3NTQnJiNpDg0NE6hoQ0QmPYx7GyQ/e5AFKSdFBA8VAqEVDw85OWxRNVj+6BYdAqP1dAdEGxsAAgBB//UCHwMIACMAQwAANyY9ATQ3Njc2OwEyFxYXHgEVFA8BFxYVFAYjIi8BBwYjIicmEgYdARAzMj8BJyY1NDc2MzIfATc2NTQnJicmIyIHBgdfHh4ZMzFBCDYrKxsbHTACQwocEhYKOAQ1Oz03OTIMhSAeBGAKDQwRFwpRAxQPDyEiLiUbGw3DUYMDgk1BLy8fHzU1gUeMZAJfDxEUHg5SBC4uLwGzTS0D/tgZA4sPEBQPDw52CkFLRjs8KSkWFSUAAAIAZ//1AggC+AAkADEAABYmNRE0NzY7ARYXFhcWFxYHBgcGDwETFhUUBwYjIicDIxEUBwYTFTcyNzY3NjU0JyYjghsNDROfKiMkHx4REQEBICFCBYoFDg0SFgueWw4NG242GhoKCiUiOAsdFQKeFg8OAQoLFRUnJjRfOjobAv77ChEUDw8NAT7+6BUPDwKk9QIaGRwcLDAWFgAAAAEAYf/wAf0DBwBRAAA3Jic1NDYzMhYXFhcWMzI3NjU0JyYnLgEnLgInJicmJyYnJjU0NzY3MzIXFhcWFRQHBiInJicmJyYjIgcGFRQXFhcWFx4BFx4CFRQGBwYjIqU6ChsSERoCBiEfKTAlJAcHDg0WEw45IhoaDxAQDwgHPDxPBkcyNBECDQ0mCwwJCgobMC0jJBUTJBAjIyceHSEXZksSEkkiMk0IFB0YEi0YGCAcOxgUEw4OEQoIHxUQERARFxcdHCNSNTYCJydDCAQUDw4NDhUYChoZGSotGBgUCxITFxcWLUQpVXQOAwAAAQA///UCHwL4ABgAABMmNDc2MyEyFxYUBwYrAREUBwYiJjURIyJNDg0NEwGGEw0NDg0SmA0NIhqYEgKiDyoPDg8PKQ8P/ZQUDw8dFQJsAAABAE3/8gIRAwgAIAAANyY1ETQ2MhYVERQXFjMyNzY1ETQ2MhYVERQHBgcGIicmZRgbJBsyHzc+JCYbJBsYGCw1ojUscDY9AfMVHR0V/g1RJhcmJkEB8xUdHRX+Dj02NiAoKCAAAQA+//UCIAMGABgAADcDNDc2MzIWFxsBPgEzMhcWFQMOASsBIibjpQ4OEg8ZA5iXBhcPEg4OpwMYDkIOGhkCvBQODxUO/YACgA8UDw8T/UQPFRYAAQA///QCHwMFAC8AADcmAzU0NjIXFhcSHwE3NjsBMhcWHwE3NhM0NjMyFh0BAgMOAQcjIi8BBwYrASInJn4xDhskDQ0BCxgDPwsdEQ4LDAQ+AxkKHBIRHA4yAxkQBTQNPj8KIBsRDAwb9AHFAhQbDg8U/r+4GfUhCgsO6xjBATEUHR0TAv5G/wAOFgEw6/giCwsAAAEAU//1AgsDBgAlAAAWJj0BNDcTAyY1NDYzMhcbATYzMhcWFRQHAxMWFRQGIyInCwEGI24bBaCaBRsSFAyJgRMVEg0OBZqgBRsSFQ2NhxIWCx0VAQ8KAUYBMgwOFh0N/u0BBRsPDxUODP7O/roKDxUdDQEj/ukaAAEAVv/0AggC+QAeAAATJjU0NjMyFxsBMz4BMzIXFhUUBxUDERQGIiY1EQMwWwUbEhkPhIQBAxgMEg0OBakaIhqpArAIDxUdG/7rARULEA8PFA8IAf6l/tEUHR0UAS8BWwAAAAABAFsABgICAv4AHgAANyY1NDcBIyInJjQ3NjMhMhcWFRQHASEyFxYUBiMhImkOBQEL4BINDg0NEwEoEg0OBf73AQMTDQ0bEv6zEhUPFA4KAkkPDykPDw8QFA0K/bcPDyodAAAAAQCl//gCHQMAABUAADcRNDYzITIWFAYrAREzMhYUBiMhIialGxIBHhIbGhPx8RIbGxL+4hIbJQKuEhsbJBv9rBskGxsAAAAAAQCA//gB8gMAABQAABM0NjMyFhcBMDMWFRQGIyInATAjJoAbEgwZBAEYAQMbEh4L/ugBAwLTExoQDP1SBwoSGxwCrgcAAAAAAQBV//gBzQMAABUAADY0NjsBESMiJjQ2MyEyFhURFAYjISJVGxLx8RMaGxIBHhIbGxL+4hITJBsCVBskGxsS/VISGwABAEQBdAIuAvsAGAAAEzU0NxM2NzIXEzAxFhUUBiMiLwEHBiMiJkQHzg8QGAnNCBsSEw2pqAwTEhsBoQoOCwErCgEM/swLDhIbDbKyDRoAAAEARP8ZAi7/kAAPAAAXNDYzITIWHQEUBiMhIiY1RBsSAZASGxsS/nASG50TGhsSHRIbGhMAAAAAAQC2AgcBuQMAABIAAAEnJjU0PwE2MzIfAhYUBwYjIgFvqRALDw0XDgoDnwsLDRURAhGODRUQDRIQCQKmDh4NDwAAAAACAE3/7wH6AiAADQA/AAAlIhUUFxYXMzI/ATUjJgcmNTQ3Njc2NzY3PgE7AScmJyYjIgcGIyImNTQ3NjMyFxYVERQGIiY9AQcGIyIjJiMmAVixHRodCFZGAQUr7zQNDBkaHR0pKUQyBgEGGRo5PC4MEBMaEU9TWzU8GyQbCERPAgYFBD/3YCEVFQJ6ATAC1C9FKh8fExMMDQYGBAY/GRonCRoTFg06MjpY/sUSHBoTEwc9AQUAAAAAAgBK//ACHwMFAB4AMgAAFiY1ETQ2MhYdATc2MzIXHgEXFRQHBiMiJyYvARUUBjcVFhcWMzI3Nj0BJicmIyIHBg8BZRsbJBsIQkoYIE9fATo5aBEIRDsIGxsUKysxJSFAAiUlNxsdQCUBDRsTArcSGxoT+QY2CBV/XweBVVMBBzAGDhMa0gExJSUXLYgJQDIzDh9NAQAAAAABAHX/7gHwAhoAKgAANyY1NDc2MzIXFhcWFxUUBiMiJyYjIgcGFRQzMjc2Nz4BMzIWHQEGBwYjIuVwNTVjExQwIyMLGRMfDAw+JRg9bBIPMQsDGRASGg4yNDwwBz7NeElHAwYbGyoLExokIw0fgsoEDCsOFRsSCzckJQAAAgA///ECEwMFAB4AMQAANyY1NDc2NzYzMh8BNTQ2MhYVERQGIiYvAQcGIyInJhMGFRQXFjMyNzY3PQImJyYjImwtLy5RHBhKRggbJBsbJBoBAQc/TxocVUA/IiI9HB5MGRUpKTAoVEpvZkVEFwg1BvgSGxoT/UkUGhoRCgYxBhQBnCxuTzs8DiBQAYUBLyMjAAAAAAIATf/xAhECIAAkAC0AADcmNTQ3NjczMhcWFRQGIyEXFhcWMzI3Njc2MzIWFRQHBiMiJyYTByEnJicmIyJ2KT49ZgZoOjsbEv7EAQclJEMREh4UDBITGy0tPzMmTA8CAQQBCxwcPGNgSmhzTUwCR0dzEhwGSyssAwQVDRoTKxQVDRoBOgcGPBwdAAAAAQBh//MB/QMCACMAABImNDY7ATU0MzIWFAYjIgcGBwYdATMyFhQGKwETFAYiJjUDI3saGxJxzhIbGxIsICAJBHwSGxsSfAYaIhoFcQG7GyQbDt8bJBsPECINNw4bJBv+ZhIcGxMBmgACAEL/QgIGAhsANABJAAA3JjU0NzYzMhcWHwE3PgEzMhYVERUWHQEUBwYjIicmJyMmNTQ2MzIXFhcWMzI3Nj0BBwYjIhMGFRQXFjMyNjc2NzY/AT0BJicjIns5OjlmDwg/MgcBARsREhsBOzxhTjAwFQEDGxIUEBEKFkVbGAoIPlJfCCAfHjocMRISDAsPAStVDUJbR2t4S0sBBikGChEYGxP+UQEJDBdeNzcTEzEHCxMaFRgFCjgXLDsHNwF8L09CLC0UFBMQEBkCVgF3BgAAAQBq//MB9AMFACkAABYmNRE0NjIWHQE3NjMyFxYXFh0BFAYiJjURNCc0Jy4CIyIHBg8BERQGhRsbJBsIOUo4KioPChskGwEEBBAdFTEgHxoBGw0aFAK3ExobEvUHMSMjNyVb/RIcHBIBCxsRERUXGRMhHzMB/tQSHAAAAAIAg//zAZQDBQAQACAAABImNDY7ATIWFREUBiImNREjNiY9ATQ2OwEyFh0BFAYrAZ4bGhO0ExobJBuHeBsbEi0SGxsSLQGoGyQbGhP+SxMaGxIBiNUaEy4TGhoTLhMaAAIAZ/9JAZQDBAAPADQAAAAmPQE0NjsBMhYdARQGKwEDIj0BNDc2MzIXFjMyNzY3NjURIyImNDY7ATIWFREUBwYHBgcGASgbGxItEhsbEi10Xw4PFQQQEAoICD0UCmUSGxoTkhMaERMdHSciAnwaEy4TGhoTLhMa/M0uCREKCwECAQQtFkkBdBskGxsS/lJVJCUbGgYFAAAAAQB7//MCBQMFACEAABYmNRE0NjIWFREzNzM2MzIWFRQPARcWFRQGIyIvASMVFAaWGxskGwq7AQ0REhsOqssMGxIVC9kKGw0aFAK3ExobEv6Asg4cEhQNpOUOERIcDfTUEhsAAAEAy//5AfADBQAYAAA3JjUTNDYzMhYVAxQXFhcWMzIWFAYjIicm9CkGGhMSGwcQES8PQBIbGxJTMC48N28B9RMbGxP+Cj8iJAcCGyQbDQ4AAQA///MCHwIbADIAABYmNRE0NjMyHwE3NjMyHwE3NjMyFhURFAYiJjURJiMiBwYVERQGIiY1ESYjIgcGFREUBlobGxIXDgMEIig4JAMEKTQ2RxskGwIhHxUUGiIaAiAgFRQbDRsTAckTGxUEAxktBQUtTzX+ihIcGxMBbzEvLif+5BIcGxMBbzEwLib+5BIcAAAAAAEATf/zAhECGwAjAAAWJjURNDYyFh0BNzYzMhcWHQEUBiImNRE0JyYjIgcGBxURFAZoGxskGwhDWGUxMRskGxcXPzsoKBgbDRwSAckSGxoSFAc9Q0N3/RIcGxMA/08oKiopOwH+7xIcAAAAAAIAP//wAh8CIAAPABsAADcmNTQ3NjMyFxYVFAcGIyIDBhQXFjI3NjQnJiKAQUFAb2xCQkJBbW4BJycmkiYnJyeQPk96e09PT1B6eU9PAaA2pjU1NTWmNjYAAAAAAgBK/0gCHwIbABUAMwAANxcWMzI3NjU0JyYjIgciIzEGBwYHFQImNRE0NjIWHQE3NjMyFxYXFhUUBwYrASYvARUUBqQBPlQPFWohIUQDBAMDLyUlFUAaGyQbCD5LGSFWLS09PGkRRjoIGssBgAUdlVQ2NwEDJCMvAf4BGxICdRMbGhMLBzQIFkZHb3dNTQQxB7cTGgAAAAACAD//SAITAhsAHAAvAAA3JjU0NzYzMh8BNTQ2MhYVERQGIiY9AQcGIyInJhMGFRQXFjMyNzY3PQImJyYjIm0uryEZSz4IGyQbGiYaCD5OHBtTPT8jIzwZIEIjFygpMSNQRmvmLAg0BwsSGxsT/YsTGhsStgc0BxMBoCiBSzY4DR1VAX0BMiQlAAAAAAEAmv/zAg4CGwAnAAAWJjURNDYzMhYdATc2MzIWFxQGIiYnNCcjIicmIgcGKwEGBwYdARQGtRsbEhMaCDdPPE8BGyQaASMBAgQFBwcGAwE3ICIbDRwSAckSGxkTCwc0TTgTGxoSIggBAgIBCTg3QOUTGwAAAQBn//AB/QIgAFEAADcmNTQ2MzIXFhcWMzI3NjU0JyYnJicuAicuAScmJyYnJjU0NzY7ARYXFhcWFRQGIyImJyYnIyIHBgcGFRQXFhceARcWFxYXFhcWFRQHBgcjImwFGxITEhUJITIwIyYPDgwKFgs5GhkaGRISCQgHBzg4Uh02LC0MAhsSEBkDCEAZGxMUEhQ+Dx8gIhwdDxAREQcHOjxYCYVFCA8TGhUYBBESEyYTDg0EBQYDDwgJCQ8ODg8OFhUZTiUmAxsbLwkDEhsTDiIEAwIODxswEgQHCAsKCQwLEREWFx1SJygCAAABAE3/8wHjAqYAMQAAEiY0NjsBNzQ2MhYVBzMyFhQGKwEHFBUWFx4COwEyNzYzMhYVFAcGIyInJicmPQE3I2gbGxJSARkkGAKWEhsbEpcDAQMEDRsUAhAcGw0SGyMlNCofLxQUA1ABshslG2wUGRsSbBwkHO0aDQwTExENCgobEiAQEQwTLi9MDOsAAAEATf/wAhECGAAoAAA3Jj0BNDYzMhYdARQXFhczMjc2NzERNDYyFhURFAYiJj0BBwYrASYnJlcKGxESHBUVQwU7KCYVGyQbGyQbCEFYBEgwMYEmS/gSHBwS6lwrLQIsKz8BChMbHBL+NxIcGhMSBzsBJyYAAQBC//MCHAIYAB0AABMmNTQ2MzIXEzMTMDU+ATMyFhUUBzEDDgErASImJ0UDGxIfC5EKkQMZDhIbA54DGQ1GDhcEAdsGCRMbH/5eAaIBDBIcEgkG/jYMEhENAAABAEH/8wIeAhgAKAAANwM0NzYzMhYXEzc+ATsBMh8BEz4BMzIXFh0BAw4BKwEiLwEHBisBIiZ4Nw4OEhEZAiorAxcPLCAKKikDGRESDg44AhkRMCAJMTELHTERGhsBzxMNDhcR/qSWDRMglgFcEBgNDRAE/jEQGB+wryAYAAAAAAEAYf/zAf0CGAAjAAAWJjU0PwEnJjU0NjMyHwE3NjMyFhUUDwEXFhUUBiMiLwEHBiN8GwiMgQcbEhcJdXUNExIbB4KMCRsSGAmAgQwUDRwSDg3OxgwOExsMtbUMHBIODMbODg0SHAy/vwwAAAEAP/9JAh8CGAAjAAAWJjU0NjsBMj8BAyY1NDYzMhcbATYzMhYVFAcBMDEGBwYjIidTFBsSEBYHa78GGxITDaicDhQSGwX+zQ0dHSMNDrEZEBMaEMsBVAkNExsM/tcBKQwbEw0K/bccEhMDAAEAYQAEAgUCBwAcAAA2Jj0BNDcBIyImNDYzITIWHQEUBxUBITIWFAYjIXsaDAEU6hIbGhMBKhMaDf7zAQQSGxoT/rYEGxIjDw4BPBomGhoTKBEMAf7KGyQbAAAAAQBE//gCLgMAADQAABI0NjMyNzY9ATQ3Njc2MzIWFAYrASIHBgcGFRQPARcWFRQXFhcWMzIWFAYjIicmNTQnJiMiRBsSVhcRJiE0NmESGxoTIjUdHxEUMQUEMgcIGhd4EhsbEpAtVRYYUBMBaCYbGxQ9CmM1Lg0OGyQbBgYYGkl7JQMFMWE3Hh8RDhskGxsznzsXGAAAAAABAQz/ZAFmAwAACwAABRE0NjIWFREUBiImAQwbJBsaJhpvA0ITGhsS/L4SGxoAAAABAET/+AIuAwAAMwAANjQ2OwEyNzY3NjU0PwEnJjU0JyYnJiMiJjQ2MzIXFhcWFRQXFjsBMhYUBiMiBhUUBwYjIkQbEiE9HyIOCjIEBTENDScVYRMaGxJhNjQhJRIXUgQSGxsSUC9UK5ISEiYaCQkgGUhhMQUDJXs1HyELBxomGg4NLjNlRhUbHCQaLzufMxsAAAAAAQBSAhwCIALNACsAABM1Njc2MzIzFjMWFxYzMjc+ATMyFhUUBxUOASMiIyYjJicmIyIHMQ4BIyImUgonJzACBQQDLj4rICAIAxoPEhsCCkwwAgUEAy4+KiAgCQMZEBIbAlUKMB8fAQUvIicPFRsSAwUBMD8BBDAhJg8VGwAAAAABAnIB9QLWAq8ACwAAATU0NjIWHQEUBiImAnIeKB4eKB4CJ1YVHR4UVhQeHQAAAAABAgYB9QKgAq8ADwAAATQ2MzIfARYVFAYjIi8BJgIGHhQbCTwIHhQTET0HAn0VHQ5fDQ4UHg9eCwAAAAACAbYCVALWAwIACwAXAAABNTQ2MhYdARQGIiY3NTQ2MhYdARQGIiYBth4oHh0qHbweKB4dKh0ChkoVHR4UShQeHRVKFB4eFEoUHh4AAQAO/4cAcgK1AAsAABcRNDYyFhURFAYiJg4eKB4dKh1HAsoUHh4U/TYUHh4AAAAAAAAOAK4AAQAAAAAAAABDAIgAAQAAAAAAAQAEANYAAQAAAAAAAgAHAOsAAQAAAAAAAwApAUcAAQAAAAAABAANAY0AAQAAAAAABQAKAbEAAQAAAAAABgAEAcYAAwABBAkAAACGAAAAAwABBAkAAQAIAMwAAwABBAkAAgAOANsAAwABBAkAAwBSAPMAAwABBAkABAAaAXEAAwABBAkABQAUAZsAAwABBAkABgAIAbwATQBhAHQAdABoAGUAdwAgAFMAawBhAGwAYQAgACgAMgAwADEAMQApADsAIABiAGEAcwBlAGQAIABvAG4AIABjAG8AZABlACAAYgB5ACAATgBvAHIAYgBlAHIAdAAgAFMAYwBoAHcAYQByAHoAIAAoADEAOQA4ADYALAAgADIAMAAxADEAKQAATWF0dGhldyBTa2FsYSAoMjAxMSk7IGJhc2VkIG9uIGNvZGUgYnkgTm9yYmVydCBTY2h3YXJ6ICgxOTg2LCAyMDExKQAATwBDAFIAQgAAT0NSQgAAUgBlAGcAdQBsAGEAcgAAUmVndWxhcgAARgBvAG4AdABGAG8AcgBnAGUAIAAyAC4AMAAgADoAIABPAEMAUgAgAEIAIABSAGUAZwB1AGwAYQByACAAOgAgADIANwAtADkALQAyADAAMQAyAABGb250Rm9yZ2UgMi4wIDogT0NSIEIgUmVndWxhciA6IDI3LTktMjAxMgAATwBDAFIAIABCACAAUgBlAGcAdQBsAGEAcgAAT0NSIEIgUmVndWxhcgAAVgBlAHIAcwBpAG8AbgAgADIAIAAAVmVyc2lvbiAyIAAATwBDAFIAQgAAT0NSQgAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmAAAAAQACAAMABAAFAAYABwAIAAkAtwALAAwADQAOAA8AEAARABIAEwAUABUAFgAXABgAGQAaABsAHAAdAB4AHwAgACEAIgAjACQAJQAmACcAKAApACoAKwAsAC0ALgAvADAAMQAyADMANAA1ADYANwA4ADkAOgA7ADwAPQA+AD8AQABBAEIAtgBEAEUARgBHAEgASQBKAEsATABNAE4ATwBQAFEAUgBTAFQAVQBWAFcAWABZAFoAWwBcAF0AXgBfAGAAYQECAQMBBAEFD3F1b3Rlc2luZ2xlLmFsdAlncmF2ZS5hbHQMcXVvdGVkYmwuYWx0B2Jhci5hbHQAAAAAAAAB//8AAgABAAAADgAAABgAAAAAAAIAAQABAGUAAQAEAAAAAgAAAAEAAAAKAEAAjgACREZMVAAObGF0bgAiAAQAAAAA//8ABQAAAAEAAgADAAQABAAAAAD//wAFAAAAAQACAAMABAAFYWFsdAAgc3MwMQAmc3MwMgAsc3MwMwAyc3MwNAA4AAAAAQAAABgAAQABABYAAQACABQAAQADABIAAQAEAAABAAAAAQEAAAECAAABAwAFAAwAFAAcACQALAADAAAAAQAoAAEAAAABAFIAAQAAAAEAVgABAAAAAQBaAAEAAAABAF4AAQAmAAQADgAUABoAIAACAAUAZAACAAoAYgACAEMAYwACAF8AZQABAAQABQAKAEMAXwABAAYAIAABAAEAQwABAAYAXwABAAEABQABAAYAWAABAAEACgABAAYABgABAAEAXwABAAAACgAsAC4AAkRGTFQADmxhdG4AGAAEAAAAAP//AAAABAAAAAD//wAAAAAAAAAAAAEAAAAAzD2izwAAAADWBtqRAAAAANoDIf0=");const BwipJs={toCanvas:ToCanvas,toSVG:ToSVG,render:Render,raw:ToRaw,drawingCanvas:DrawingCanvas,drawingSVG:DrawingSVG,fixupOptions:FixupOptions,loadFont:LoadFont,FontLib,BWIPJS_VERSION,BWIPP_VERSION};let customBcid=["ean13","upca","upce","ean8"];function getEffectiveBarcodeType(tg,eg){const gg=String(eg??"");return tg==="gs1-128"&&!/\(\d{2,4}\)/.test(gg)?"code128":tg}function generateCanvas(tg){var ng;if(tg.barcolor&&(tg.barcolor.charAt(0)==="#"?tg.barcolor.length>7&&(tg.barcolor=tg.barcolor.substring(0,7)):tg.barcolor.length>6&&(tg.barcolor=tg.barcolor.substring(0,6))),tg.extra&&(tg.bcid.startsWith("aztec")&&(ng=tg.extra)!=null&&ng.version&&(tg.extra.layers=tg.extra.version),tg.extra.version&&tg.bcid==="micropdf417")){const og=tg.extra.version.split("x");og.length==2&&(tg.extra.version=og[1]+"x"+og[0])}const eg=document.createElement("canvas");tg.width&&tg.height&&(eg.width=tg.width,eg.height=tg.height);let gg=tg.extra||{};const ig={...tg,...gg,textcolor:""};return customBcid.includes(ig.bcid)&&(ig.textsize=1),BwipJs.toCanvas(eg,ig),eg}const mixMultCode={LPMixQrCode:[{label:"龙贝码",value:""},{label:"QR Code",value:""}]},OBJECT_NAME_MAP={text:"文本",textname:"名字",image:"图片",rect:"矩形",triangle:"三角形",table:"表格",circle:"圆形",line:"直线",barcode:"条码",barcode2d:"二维码",counter:"日期计数器",group:"组合"},canvasNameMap=new WeakMap,canvasNameResolvers=new WeakMap;function setObjectNameResolver(tg,eg){canvasNameResolvers.set(tg,eg)}function initCountObjsName(tg,eg){let gg=tg.filter(ig=>ig.id!=="workspace");deepTraverse(gg,ig=>{addObjName(eg,ig,"init")})}function deepTraverse(tg,eg){const gg=[...tg];let ig=gg.length;for(;gg.length>0;){const ng=gg.shift();let og=!1;ig>0&&(ig--,og=!0),ng.type==="group"?(eg&&eg(ng,og),gg.push(...ng.getObjects())):eg&&eg(ng,og)}}function addObjName(tg,eg,gg="add"){var ag;const ig=eg.type??"";let ng=canvasNameMap.get(tg);ng||(ng={},canvasNameMap.set(tg,ng));const og=(ng[ig]??0)+1;if(ng[ig]=og,gg==="add"){const sg=OBJECT_NAME_MAP[ig],Ig=((ag=canvasNameResolvers.get(tg))==null?void 0:ag(ig))??sg;if(Ig){const Cg=/[\u3400-\u9fff]/.test(Ig)?"":" ";eg.name=`${Ig}${Cg}${og}`}}}function refreshObjectCenterProperties(tg){tg.forEach(eg=>{const gg=eg;if(gg.id==="workspace")return;const ig=gg.getCenterPoint();if(gg.set({centerX:ig.x,centerY:ig.y}),gg.type==="group"){const ng=gg.getObjects();refreshObjectCenterProperties(ng)}})}const cloneCommonField=["id","name","locked","databaseSheet","databaseColumn","outsideInput","outsideInputOrder","hasControls","hasBorders","fromJson","jsonFieldKey","databaseTid","increaseCount","fromBarCode","fromBarCode2d","fromBarCode2dID","increaseDate","barcodeDateFormatType","addCombObject","databaseMixConcat","imageSource","imageSourceType","databaseImageEnabled","databaseImageFrame","databaseImageError","relativePosition","rows","columns","tableTexts","tableCellStyles","tableCellBorders","tableCellSpans","columnWidths","rowHeights","fontSize","fontFamily","fontWeight","fontStyle","underline","linethrough","charSpacing","lineHeight","textAlign","verticalType","centerX","centerY"];let targetDPI=203;const setTargetDpi=tg=>{targetDPI=tg||203},getTargetDpi=()=>targetDPI||203;function anyRgbToHex(tg){const eg=tg.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(!eg)return tg;const gg=ig=>Math.min(255,Math.max(0,parseInt(ig))).toString(16).padStart(2,"0").toUpperCase();return`#${gg(eg[1])}${gg(eg[2])}${gg(eg[3])}`}function expandHexColor(tg){const eg=tg.startsWith("#")?tg.slice(1):tg;if(eg.length!==3)throw new Error("请输入一个有效的3位16进制颜色代码");return"#"+eg.split("").map(ig=>ig+ig).join("")}function addAlphaToHex(tg,eg){let gg=tg.replace("#","").toUpperCase();return typeof eg=="number"&&(gg=gg+Math.round(eg/100*255).toString(16).padStart(2,"0")),"#"+gg}function hexToHex6_blend(tg,eg="#FFFFFF"){if(!tg)return tg;let gg=tg.replace("#","").toUpperCase();if(gg.length===3&&(gg=gg.split("").map(rg=>rg+rg).join("")),gg.length===4&&(gg=gg.split("").map(rg=>rg+rg).join("")),gg.length===6)return`#${gg}`;if(gg.length!==8)return tg;const ig=parseInt(gg.slice(0,2),16),ng=parseInt(gg.slice(2,4),16),og=parseInt(gg.slice(4,6),16),ag=parseInt(gg.slice(6,8),16)/255,sg=eg.replace("#",""),Ig=parseInt(sg.slice(0,2),16),Cg=parseInt(sg.slice(2,4),16),lg=parseInt(sg.slice(4,6),16),Ag=(rg,cg)=>Math.round(rg*ag+cg*(1-ag));return"#"+[Ag(ig,Ig),Ag(ng,Cg),Ag(og,lg)].map(rg=>rg.toString(16).padStart(2,"0")).join("")}function rgbaStringToHex8(tg){const eg=tg.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(!eg)return tg;const[,gg,ig,ng,og=1]=eg,ag=Ig=>Number(Ig).toString(16).padStart(2,"0"),sg=Math.round(og*255);return`#${ag(gg)}${ag(ig)}${ag(ng)}${ag(sg)}`}function splitLongWord(tg,eg,gg){const ig=[];let ng="";for(const og of eg){const ag=ng+og;tg.measureText(ag).width>gg?(ig.push(ng),ng=og):ng=ag}return ng&&ig.push(ng),ig}function wrapText(tg,eg,gg,ig){return ig&&(tg.font=ig),eg.split(`
|
|
930
|
-
`).flatMap(ng=>{let og="";const ag=ng.split(/\s+/).filter(sg=>sg);return ag.reduce((sg,Ig,Cg)=>{const lg=og?`${og} ${Ig}`:Ig;return tg.measureText(lg).width<=gg?og=lg:(og&&sg.push(og),og=Ig,(Cg===ag.length-1||tg.measureText(Ig).width>gg)&&(sg.push(...splitLongWord(tg,Ig,gg)),og="")),Cg===ag.length-1&&og&&sg.push(og),sg},[])})}function getLineHeight(tg){const eg=tg.font.match(/\d+/),gg=10;return eg?parseInt(eg[0],gg):gg}function generateThumbnail(tg,eg,gg){let{width:ig,height:ng}=tg;const og=Math.min(eg/ig,gg/ng);ig*=og,ng*=og;const ag=document.createElement("canvas"),sg=ag.getContext("2d");if(!sg)throw new Error("Canvas context not available");return ag.width=ig,ag.height=ng,sg.drawImage(tg,0,0,ig,ng),ag.toDataURL("image/png",.85)}class LuxonError extends Error{}class InvalidDateTimeError extends LuxonError{constructor(eg){super(`Invalid DateTime: ${eg.toMessage()}`)}}class InvalidIntervalError extends LuxonError{constructor(eg){super(`Invalid Interval: ${eg.toMessage()}`)}}class InvalidDurationError extends LuxonError{constructor(eg){super(`Invalid Duration: ${eg.toMessage()}`)}}class ConflictingSpecificationError extends LuxonError{}class InvalidUnitError extends LuxonError{constructor(eg){super(`Invalid unit ${eg}`)}}class InvalidArgumentError extends LuxonError{}class ZoneIsAbstractError extends LuxonError{constructor(){super("Zone is an abstract class")}}const n="numeric",s="short",l="long",DATE_SHORT={year:n,month:n,day:n},DATE_MED={year:n,month:s,day:n},DATE_MED_WITH_WEEKDAY={year:n,month:s,day:n,weekday:s},DATE_FULL={year:n,month:l,day:n},DATE_HUGE={year:n,month:l,day:n,weekday:l},TIME_SIMPLE={hour:n,minute:n},TIME_WITH_SECONDS={hour:n,minute:n,second:n},TIME_WITH_SHORT_OFFSET={hour:n,minute:n,second:n,timeZoneName:s},TIME_WITH_LONG_OFFSET={hour:n,minute:n,second:n,timeZoneName:l},TIME_24_SIMPLE={hour:n,minute:n,hourCycle:"h23"},TIME_24_WITH_SECONDS={hour:n,minute:n,second:n,hourCycle:"h23"},TIME_24_WITH_SHORT_OFFSET={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:s},TIME_24_WITH_LONG_OFFSET={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:l},DATETIME_SHORT={year:n,month:n,day:n,hour:n,minute:n},DATETIME_SHORT_WITH_SECONDS={year:n,month:n,day:n,hour:n,minute:n,second:n},DATETIME_MED={year:n,month:s,day:n,hour:n,minute:n},DATETIME_MED_WITH_SECONDS={year:n,month:s,day:n,hour:n,minute:n,second:n},DATETIME_MED_WITH_WEEKDAY={year:n,month:s,day:n,weekday:s,hour:n,minute:n},DATETIME_FULL={year:n,month:l,day:n,hour:n,minute:n,timeZoneName:s},DATETIME_FULL_WITH_SECONDS={year:n,month:l,day:n,hour:n,minute:n,second:n,timeZoneName:s},DATETIME_HUGE={year:n,month:l,day:n,weekday:l,hour:n,minute:n,timeZoneName:l},DATETIME_HUGE_WITH_SECONDS={year:n,month:l,day:n,weekday:l,hour:n,minute:n,second:n,timeZoneName:l};class Zone{get type(){throw new ZoneIsAbstractError}get name(){throw new ZoneIsAbstractError}get ianaName(){return this.name}get isUniversal(){throw new ZoneIsAbstractError}offsetName(eg,gg){throw new ZoneIsAbstractError}formatOffset(eg,gg){throw new ZoneIsAbstractError}offset(eg){throw new ZoneIsAbstractError}equals(eg){throw new ZoneIsAbstractError}get isValid(){throw new ZoneIsAbstractError}}let singleton$1=null;class SystemZone extends Zone{static get instance(){return singleton$1===null&&(singleton$1=new SystemZone),singleton$1}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(eg,{format:gg,locale:ig}){return parseZoneInfo(eg,gg,ig)}formatOffset(eg,gg){return formatOffset(this.offset(eg),gg)}offset(eg){return-new Date(eg).getTimezoneOffset()}equals(eg){return eg.type==="system"}get isValid(){return!0}}const dtfCache=new Map;function makeDTF(tg){let eg=dtfCache.get(tg);return eg===void 0&&(eg=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:tg,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),dtfCache.set(tg,eg)),eg}const typeToPos={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function hackyOffset(tg,eg){const gg=tg.format(eg).replace(/\u200E/g,""),ig=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(gg),[,ng,og,ag,sg,Ig,Cg,lg]=ig;return[ag,ng,og,sg,Ig,Cg,lg]}function partsOffset(tg,eg){const gg=tg.formatToParts(eg),ig=[];for(let ng=0;ng<gg.length;ng++){const{type:og,value:ag}=gg[ng],sg=typeToPos[og];og==="era"?ig[sg]=ag:isUndefined$1(sg)||(ig[sg]=parseInt(ag,10))}return ig}const ianaZoneCache=new Map;class IANAZone extends Zone{static create(eg){let gg=ianaZoneCache.get(eg);return gg===void 0&&ianaZoneCache.set(eg,gg=new IANAZone(eg)),gg}static resetCache(){ianaZoneCache.clear(),dtfCache.clear()}static isValidSpecifier(eg){return this.isValidZone(eg)}static isValidZone(eg){if(!eg)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:eg}).format(),!0}catch{return!1}}constructor(eg){super(),this.zoneName=eg,this.valid=IANAZone.isValidZone(eg)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(eg,{format:gg,locale:ig}){return parseZoneInfo(eg,gg,ig,this.name)}formatOffset(eg,gg){return formatOffset(this.offset(eg),gg)}offset(eg){if(!this.valid)return NaN;const gg=new Date(eg);if(isNaN(gg))return NaN;const ig=makeDTF(this.name);let[ng,og,ag,sg,Ig,Cg,lg]=ig.formatToParts?partsOffset(ig,gg):hackyOffset(ig,gg);sg==="BC"&&(ng=-Math.abs(ng)+1);const rg=objToLocalTS({year:ng,month:og,day:ag,hour:Ig===24?0:Ig,minute:Cg,second:lg,millisecond:0});let cg=+gg;const ug=cg%1e3;return cg-=ug>=0?ug:1e3+ug,(rg-cg)/(60*1e3)}equals(eg){return eg.type==="iana"&&eg.name===this.name}get isValid(){return this.valid}}let intlLFCache={};function getCachedLF(tg,eg={}){const gg=JSON.stringify([tg,eg]);let ig=intlLFCache[gg];return ig||(ig=new Intl.ListFormat(tg,eg),intlLFCache[gg]=ig),ig}const intlDTCache=new Map;function getCachedDTF(tg,eg={}){const gg=JSON.stringify([tg,eg]);let ig=intlDTCache.get(gg);return ig===void 0&&(ig=new Intl.DateTimeFormat(tg,eg),intlDTCache.set(gg,ig)),ig}const intlNumCache=new Map;function getCachedINF(tg,eg={}){const gg=JSON.stringify([tg,eg]);let ig=intlNumCache.get(gg);return ig===void 0&&(ig=new Intl.NumberFormat(tg,eg),intlNumCache.set(gg,ig)),ig}const intlRelCache=new Map;function getCachedRTF(tg,eg={}){const{base:gg,...ig}=eg,ng=JSON.stringify([tg,ig]);let og=intlRelCache.get(ng);return og===void 0&&(og=new Intl.RelativeTimeFormat(tg,eg),intlRelCache.set(ng,og)),og}let sysLocaleCache=null;function systemLocale(){return sysLocaleCache||(sysLocaleCache=new Intl.DateTimeFormat().resolvedOptions().locale,sysLocaleCache)}const intlResolvedOptionsCache=new Map;function getCachedIntResolvedOptions(tg){let eg=intlResolvedOptionsCache.get(tg);return eg===void 0&&(eg=new Intl.DateTimeFormat(tg).resolvedOptions(),intlResolvedOptionsCache.set(tg,eg)),eg}const weekInfoCache=new Map;function getCachedWeekInfo(tg){let eg=weekInfoCache.get(tg);if(!eg){const gg=new Intl.Locale(tg);eg="getWeekInfo"in gg?gg.getWeekInfo():gg.weekInfo,"minimalDays"in eg||(eg={...fallbackWeekSettings,...eg}),weekInfoCache.set(tg,eg)}return eg}function parseLocaleString(tg){const eg=tg.indexOf("-x-");eg!==-1&&(tg=tg.substring(0,eg));const gg=tg.indexOf("-u-");if(gg===-1)return[tg];{let ig,ng;try{ig=getCachedDTF(tg).resolvedOptions(),ng=tg}catch{const Ig=tg.substring(0,gg);ig=getCachedDTF(Ig).resolvedOptions(),ng=Ig}const{numberingSystem:og,calendar:ag}=ig;return[ng,og,ag]}}function intlConfigString(tg,eg,gg){return(gg||eg)&&(tg.includes("-u-")||(tg+="-u"),gg&&(tg+=`-ca-${gg}`),eg&&(tg+=`-nu-${eg}`)),tg}function mapMonths(tg){const eg=[];for(let gg=1;gg<=12;gg++){const ig=DateTime.utc(2009,gg,1);eg.push(tg(ig))}return eg}function mapWeekdays(tg){const eg=[];for(let gg=1;gg<=7;gg++){const ig=DateTime.utc(2016,11,13+gg);eg.push(tg(ig))}return eg}function listStuff(tg,eg,gg,ig){const ng=tg.listingMode();return ng==="error"?null:ng==="en"?gg(eg):ig(eg)}function supportsFastNumbers(tg){return tg.numberingSystem&&tg.numberingSystem!=="latn"?!1:tg.numberingSystem==="latn"||!tg.locale||tg.locale.startsWith("en")||getCachedIntResolvedOptions(tg.locale).numberingSystem==="latn"}class PolyNumberFormatter{constructor(eg,gg,ig){this.padTo=ig.padTo||0,this.floor=ig.floor||!1;const{padTo:ng,floor:og,...ag}=ig;if(!gg||Object.keys(ag).length>0){const sg={useGrouping:!1,...ig};ig.padTo>0&&(sg.minimumIntegerDigits=ig.padTo),this.inf=getCachedINF(eg,sg)}}format(eg){if(this.inf){const gg=this.floor?Math.floor(eg):eg;return this.inf.format(gg)}else{const gg=this.floor?Math.floor(eg):roundTo(eg,3);return padStart(gg,this.padTo)}}}class PolyDateFormatter{constructor(eg,gg,ig){this.opts=ig,this.originalZone=void 0;let ng;if(this.opts.timeZone)this.dt=eg;else if(eg.zone.type==="fixed"){const ag=-1*(eg.offset/60),sg=ag>=0?`Etc/GMT+${ag}`:`Etc/GMT${ag}`;eg.offset!==0&&IANAZone.create(sg).valid?(ng=sg,this.dt=eg):(ng="UTC",this.dt=eg.offset===0?eg:eg.setZone("UTC").plus({minutes:eg.offset}),this.originalZone=eg.zone)}else eg.zone.type==="system"?this.dt=eg:eg.zone.type==="iana"?(this.dt=eg,ng=eg.zone.name):(ng="UTC",this.dt=eg.setZone("UTC").plus({minutes:eg.offset}),this.originalZone=eg.zone);const og={...this.opts};og.timeZone=og.timeZone||ng,this.dtf=getCachedDTF(gg,og)}format(){return this.originalZone?this.formatToParts().map(({value:eg})=>eg).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const eg=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?eg.map(gg=>{if(gg.type==="timeZoneName"){const ig=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...gg,value:ig}}else return gg}):eg}resolvedOptions(){return this.dtf.resolvedOptions()}}class PolyRelFormatter{constructor(eg,gg,ig){this.opts={style:"long",...ig},!gg&&hasRelative()&&(this.rtf=getCachedRTF(eg,ig))}format(eg,gg){return this.rtf?this.rtf.format(eg,gg):formatRelativeTime(gg,eg,this.opts.numeric,this.opts.style!=="long")}formatToParts(eg,gg){return this.rtf?this.rtf.formatToParts(eg,gg):[]}}const fallbackWeekSettings={firstDay:1,minimalDays:4,weekend:[6,7]};class Locale{static fromOpts(eg){return Locale.create(eg.locale,eg.numberingSystem,eg.outputCalendar,eg.weekSettings,eg.defaultToEN)}static create(eg,gg,ig,ng,og=!1){const ag=eg||Settings.defaultLocale,sg=ag||(og?"en-US":systemLocale()),Ig=gg||Settings.defaultNumberingSystem,Cg=ig||Settings.defaultOutputCalendar,lg=validateWeekSettings(ng)||Settings.defaultWeekSettings;return new Locale(sg,Ig,Cg,lg,ag)}static resetCache(){sysLocaleCache=null,intlDTCache.clear(),intlNumCache.clear(),intlRelCache.clear(),intlResolvedOptionsCache.clear(),weekInfoCache.clear()}static fromObject({locale:eg,numberingSystem:gg,outputCalendar:ig,weekSettings:ng}={}){return Locale.create(eg,gg,ig,ng)}constructor(eg,gg,ig,ng,og){const[ag,sg,Ig]=parseLocaleString(eg);this.locale=ag,this.numberingSystem=gg||sg||null,this.outputCalendar=ig||Ig||null,this.weekSettings=ng,this.intl=intlConfigString(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=og,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=supportsFastNumbers(this)),this.fastNumbersCached}listingMode(){const eg=this.isEnglish(),gg=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return eg&&gg?"en":"intl"}clone(eg){return!eg||Object.getOwnPropertyNames(eg).length===0?this:Locale.create(eg.locale||this.specifiedLocale,eg.numberingSystem||this.numberingSystem,eg.outputCalendar||this.outputCalendar,validateWeekSettings(eg.weekSettings)||this.weekSettings,eg.defaultToEN||!1)}redefaultToEN(eg={}){return this.clone({...eg,defaultToEN:!0})}redefaultToSystem(eg={}){return this.clone({...eg,defaultToEN:!1})}months(eg,gg=!1){return listStuff(this,eg,months,()=>{const ig=this.intl==="ja"||this.intl.startsWith("ja-");gg&=!ig;const ng=gg?{month:eg,day:"numeric"}:{month:eg},og=gg?"format":"standalone";if(!this.monthsCache[og][eg]){const ag=ig?sg=>this.dtFormatter(sg,ng).format():sg=>this.extract(sg,ng,"month");this.monthsCache[og][eg]=mapMonths(ag)}return this.monthsCache[og][eg]})}weekdays(eg,gg=!1){return listStuff(this,eg,weekdays,()=>{const ig=gg?{weekday:eg,year:"numeric",month:"long",day:"numeric"}:{weekday:eg},ng=gg?"format":"standalone";return this.weekdaysCache[ng][eg]||(this.weekdaysCache[ng][eg]=mapWeekdays(og=>this.extract(og,ig,"weekday"))),this.weekdaysCache[ng][eg]})}meridiems(){return listStuff(this,void 0,()=>meridiems,()=>{if(!this.meridiemCache){const eg={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[DateTime.utc(2016,11,13,9),DateTime.utc(2016,11,13,19)].map(gg=>this.extract(gg,eg,"dayperiod"))}return this.meridiemCache})}eras(eg){return listStuff(this,eg,eras,()=>{const gg={era:eg};return this.eraCache[eg]||(this.eraCache[eg]=[DateTime.utc(-40,1,1),DateTime.utc(2017,1,1)].map(ig=>this.extract(ig,gg,"era"))),this.eraCache[eg]})}extract(eg,gg,ig){const ng=this.dtFormatter(eg,gg),og=ng.formatToParts(),ag=og.find(sg=>sg.type.toLowerCase()===ig);return ag?ag.value:null}numberFormatter(eg={}){return new PolyNumberFormatter(this.intl,eg.forceSimple||this.fastNumbers,eg)}dtFormatter(eg,gg={}){return new PolyDateFormatter(eg,this.intl,gg)}relFormatter(eg={}){return new PolyRelFormatter(this.intl,this.isEnglish(),eg)}listFormatter(eg={}){return getCachedLF(this.intl,eg)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||getCachedIntResolvedOptions(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:hasLocaleWeekInfo()?getCachedWeekInfo(this.locale):fallbackWeekSettings}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(eg){return this.locale===eg.locale&&this.numberingSystem===eg.numberingSystem&&this.outputCalendar===eg.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let singleton=null;class FixedOffsetZone extends Zone{static get utcInstance(){return singleton===null&&(singleton=new FixedOffsetZone(0)),singleton}static instance(eg){return eg===0?FixedOffsetZone.utcInstance:new FixedOffsetZone(eg)}static parseSpecifier(eg){if(eg){const gg=eg.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(gg)return new FixedOffsetZone(signedOffset(gg[1],gg[2]))}return null}constructor(eg){super(),this.fixed=eg}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${formatOffset(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${formatOffset(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(eg,gg){return formatOffset(this.fixed,gg)}get isUniversal(){return!0}offset(){return this.fixed}equals(eg){return eg.type==="fixed"&&eg.fixed===this.fixed}get isValid(){return!0}}class InvalidZone extends Zone{constructor(eg){super(),this.zoneName=eg}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function normalizeZone(tg,eg){if(isUndefined$1(tg)||tg===null)return eg;if(tg instanceof Zone)return tg;if(isString$1(tg)){const gg=tg.toLowerCase();return gg==="default"?eg:gg==="local"||gg==="system"?SystemZone.instance:gg==="utc"||gg==="gmt"?FixedOffsetZone.utcInstance:FixedOffsetZone.parseSpecifier(gg)||IANAZone.create(tg)}else return isNumber$1(tg)?FixedOffsetZone.instance(tg):typeof tg=="object"&&"offset"in tg&&typeof tg.offset=="function"?tg:new InvalidZone(tg)}const numberingSystems={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},numberingSystemsUTF16={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},hanidecChars=numberingSystems.hanidec.replace(/[\[|\]]/g,"").split("");function parseDigits(tg){let eg=parseInt(tg,10);if(isNaN(eg)){eg="";for(let gg=0;gg<tg.length;gg++){const ig=tg.charCodeAt(gg);if(tg[gg].search(numberingSystems.hanidec)!==-1)eg+=hanidecChars.indexOf(tg[gg]);else for(const ng in numberingSystemsUTF16){const[og,ag]=numberingSystemsUTF16[ng];ig>=og&&ig<=ag&&(eg+=ig-og)}}return parseInt(eg,10)}else return eg}const digitRegexCache=new Map;function resetDigitRegexCache(){digitRegexCache.clear()}function digitRegex({numberingSystem:tg},eg=""){const gg=tg||"latn";let ig=digitRegexCache.get(gg);ig===void 0&&(ig=new Map,digitRegexCache.set(gg,ig));let ng=ig.get(eg);return ng===void 0&&(ng=new RegExp(`${numberingSystems[gg]}${eg}`),ig.set(eg,ng)),ng}let now=()=>Date.now(),defaultZone="system",defaultLocale=null,defaultNumberingSystem=null,defaultOutputCalendar=null,twoDigitCutoffYear=60,throwOnInvalid,defaultWeekSettings=null;class Settings{static get now(){return now}static set now(eg){now=eg}static set defaultZone(eg){defaultZone=eg}static get defaultZone(){return normalizeZone(defaultZone,SystemZone.instance)}static get defaultLocale(){return defaultLocale}static set defaultLocale(eg){defaultLocale=eg}static get defaultNumberingSystem(){return defaultNumberingSystem}static set defaultNumberingSystem(eg){defaultNumberingSystem=eg}static get defaultOutputCalendar(){return defaultOutputCalendar}static set defaultOutputCalendar(eg){defaultOutputCalendar=eg}static get defaultWeekSettings(){return defaultWeekSettings}static set defaultWeekSettings(eg){defaultWeekSettings=validateWeekSettings(eg)}static get twoDigitCutoffYear(){return twoDigitCutoffYear}static set twoDigitCutoffYear(eg){twoDigitCutoffYear=eg%100}static get throwOnInvalid(){return throwOnInvalid}static set throwOnInvalid(eg){throwOnInvalid=eg}static resetCaches(){Locale.resetCache(),IANAZone.resetCache(),DateTime.resetCache(),resetDigitRegexCache()}}class Invalid{constructor(eg,gg){this.reason=eg,this.explanation=gg}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const nonLeapLadder=[0,31,59,90,120,151,181,212,243,273,304,334],leapLadder=[0,31,60,91,121,152,182,213,244,274,305,335];function unitOutOfRange(tg,eg){return new Invalid("unit out of range",`you specified ${eg} (of type ${typeof eg}) as a ${tg}, which is invalid`)}function dayOfWeek(tg,eg,gg){const ig=new Date(Date.UTC(tg,eg-1,gg));tg<100&&tg>=0&&ig.setUTCFullYear(ig.getUTCFullYear()-1900);const ng=ig.getUTCDay();return ng===0?7:ng}function computeOrdinal(tg,eg,gg){return gg+(isLeapYear(tg)?leapLadder:nonLeapLadder)[eg-1]}function uncomputeOrdinal(tg,eg){const gg=isLeapYear(tg)?leapLadder:nonLeapLadder,ig=gg.findIndex(og=>og<eg),ng=eg-gg[ig];return{month:ig+1,day:ng}}function isoWeekdayToLocal(tg,eg){return(tg-eg+7)%7+1}function gregorianToWeek(tg,eg=4,gg=1){const{year:ig,month:ng,day:og}=tg,ag=computeOrdinal(ig,ng,og),sg=isoWeekdayToLocal(dayOfWeek(ig,ng,og),gg);let Ig=Math.floor((ag-sg+14-eg)/7),Cg;return Ig<1?(Cg=ig-1,Ig=weeksInWeekYear(Cg,eg,gg)):Ig>weeksInWeekYear(ig,eg,gg)?(Cg=ig+1,Ig=1):Cg=ig,{weekYear:Cg,weekNumber:Ig,weekday:sg,...timeObject(tg)}}function weekToGregorian(tg,eg=4,gg=1){const{weekYear:ig,weekNumber:ng,weekday:og}=tg,ag=isoWeekdayToLocal(dayOfWeek(ig,1,eg),gg),sg=daysInYear(ig);let Ig=ng*7+og-ag-7+eg,Cg;Ig<1?(Cg=ig-1,Ig+=daysInYear(Cg)):Ig>sg?(Cg=ig+1,Ig-=daysInYear(ig)):Cg=ig;const{month:lg,day:Ag}=uncomputeOrdinal(Cg,Ig);return{year:Cg,month:lg,day:Ag,...timeObject(tg)}}function gregorianToOrdinal(tg){const{year:eg,month:gg,day:ig}=tg,ng=computeOrdinal(eg,gg,ig);return{year:eg,ordinal:ng,...timeObject(tg)}}function ordinalToGregorian(tg){const{year:eg,ordinal:gg}=tg,{month:ig,day:ng}=uncomputeOrdinal(eg,gg);return{year:eg,month:ig,day:ng,...timeObject(tg)}}function usesLocalWeekValues(tg,eg){if(!isUndefined$1(tg.localWeekday)||!isUndefined$1(tg.localWeekNumber)||!isUndefined$1(tg.localWeekYear)){if(!isUndefined$1(tg.weekday)||!isUndefined$1(tg.weekNumber)||!isUndefined$1(tg.weekYear))throw new ConflictingSpecificationError("Cannot mix locale-based week fields with ISO-based week fields");return isUndefined$1(tg.localWeekday)||(tg.weekday=tg.localWeekday),isUndefined$1(tg.localWeekNumber)||(tg.weekNumber=tg.localWeekNumber),isUndefined$1(tg.localWeekYear)||(tg.weekYear=tg.localWeekYear),delete tg.localWeekday,delete tg.localWeekNumber,delete tg.localWeekYear,{minDaysInFirstWeek:eg.getMinDaysInFirstWeek(),startOfWeek:eg.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function hasInvalidWeekData(tg,eg=4,gg=1){const ig=isInteger(tg.weekYear),ng=integerBetween(tg.weekNumber,1,weeksInWeekYear(tg.weekYear,eg,gg)),og=integerBetween(tg.weekday,1,7);return ig?ng?og?!1:unitOutOfRange("weekday",tg.weekday):unitOutOfRange("week",tg.weekNumber):unitOutOfRange("weekYear",tg.weekYear)}function hasInvalidOrdinalData(tg){const eg=isInteger(tg.year),gg=integerBetween(tg.ordinal,1,daysInYear(tg.year));return eg?gg?!1:unitOutOfRange("ordinal",tg.ordinal):unitOutOfRange("year",tg.year)}function hasInvalidGregorianData(tg){const eg=isInteger(tg.year),gg=integerBetween(tg.month,1,12),ig=integerBetween(tg.day,1,daysInMonth(tg.year,tg.month));return eg?gg?ig?!1:unitOutOfRange("day",tg.day):unitOutOfRange("month",tg.month):unitOutOfRange("year",tg.year)}function hasInvalidTimeData(tg){const{hour:eg,minute:gg,second:ig,millisecond:ng}=tg,og=integerBetween(eg,0,23)||eg===24&&gg===0&&ig===0&&ng===0,ag=integerBetween(gg,0,59),sg=integerBetween(ig,0,59),Ig=integerBetween(ng,0,999);return og?ag?sg?Ig?!1:unitOutOfRange("millisecond",ng):unitOutOfRange("second",ig):unitOutOfRange("minute",gg):unitOutOfRange("hour",eg)}function isUndefined$1(tg){return typeof tg>"u"}function isNumber$1(tg){return typeof tg=="number"}function isInteger(tg){return typeof tg=="number"&&tg%1===0}function isString$1(tg){return typeof tg=="string"}function isDate$1(tg){return Object.prototype.toString.call(tg)==="[object Date]"}function hasRelative(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function hasLocaleWeekInfo(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function maybeArray(tg){return Array.isArray(tg)?tg:[tg]}function bestBy(tg,eg,gg){if(tg.length!==0)return tg.reduce((ig,ng)=>{const og=[eg(ng),ng];return ig&&gg(ig[0],og[0])===ig[0]?ig:og},null)[1]}function pick(tg,eg){return eg.reduce((gg,ig)=>(gg[ig]=tg[ig],gg),{})}function hasOwnProperty(tg,eg){return Object.prototype.hasOwnProperty.call(tg,eg)}function validateWeekSettings(tg){if(tg==null)return null;if(typeof tg!="object")throw new InvalidArgumentError("Week settings must be an object");if(!integerBetween(tg.firstDay,1,7)||!integerBetween(tg.minimalDays,1,7)||!Array.isArray(tg.weekend)||tg.weekend.some(eg=>!integerBetween(eg,1,7)))throw new InvalidArgumentError("Invalid week settings");return{firstDay:tg.firstDay,minimalDays:tg.minimalDays,weekend:Array.from(tg.weekend)}}function integerBetween(tg,eg,gg){return isInteger(tg)&&tg>=eg&&tg<=gg}function floorMod(tg,eg){return tg-eg*Math.floor(tg/eg)}function padStart(tg,eg=2){const gg=tg<0;let ig;return gg?ig="-"+(""+-tg).padStart(eg,"0"):ig=(""+tg).padStart(eg,"0"),ig}function parseInteger(tg){if(!(isUndefined$1(tg)||tg===null||tg===""))return parseInt(tg,10)}function parseFloating(tg){if(!(isUndefined$1(tg)||tg===null||tg===""))return parseFloat(tg)}function parseMillis(tg){if(!(isUndefined$1(tg)||tg===null||tg==="")){const eg=parseFloat("0."+tg)*1e3;return Math.floor(eg)}}function roundTo(tg,eg,gg="round"){const ig=10**eg;switch(gg){case"expand":return tg>0?Math.ceil(tg*ig)/ig:Math.floor(tg*ig)/ig;case"trunc":return Math.trunc(tg*ig)/ig;case"round":return Math.round(tg*ig)/ig;case"floor":return Math.floor(tg*ig)/ig;case"ceil":return Math.ceil(tg*ig)/ig;default:throw new RangeError(`Value rounding ${gg} is out of range`)}}function isLeapYear(tg){return tg%4===0&&(tg%100!==0||tg%400===0)}function daysInYear(tg){return isLeapYear(tg)?366:365}function daysInMonth(tg,eg){const gg=floorMod(eg-1,12)+1,ig=tg+(eg-gg)/12;return gg===2?isLeapYear(ig)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][gg-1]}function objToLocalTS(tg){let eg=Date.UTC(tg.year,tg.month-1,tg.day,tg.hour,tg.minute,tg.second,tg.millisecond);return tg.year<100&&tg.year>=0&&(eg=new Date(eg),eg.setUTCFullYear(tg.year,tg.month-1,tg.day)),+eg}function firstWeekOffset(tg,eg,gg){return-isoWeekdayToLocal(dayOfWeek(tg,1,eg),gg)+eg-1}function weeksInWeekYear(tg,eg=4,gg=1){const ig=firstWeekOffset(tg,eg,gg),ng=firstWeekOffset(tg+1,eg,gg);return(daysInYear(tg)-ig+ng)/7}function untruncateYear(tg){return tg>99?tg:tg>Settings.twoDigitCutoffYear?1900+tg:2e3+tg}function parseZoneInfo(tg,eg,gg,ig=null){const ng=new Date(tg),og={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};ig&&(og.timeZone=ig);const ag={timeZoneName:eg,...og},sg=new Intl.DateTimeFormat(gg,ag).formatToParts(ng).find(Ig=>Ig.type.toLowerCase()==="timezonename");return sg?sg.value:null}function signedOffset(tg,eg){let gg=parseInt(tg,10);Number.isNaN(gg)&&(gg=0);const ig=parseInt(eg,10)||0,ng=gg<0||Object.is(gg,-0)?-ig:ig;return gg*60+ng}function asNumber(tg){const eg=Number(tg);if(typeof tg=="boolean"||tg===""||!Number.isFinite(eg))throw new InvalidArgumentError(`Invalid unit value ${tg}`);return eg}function normalizeObject(tg,eg){const gg={};for(const ig in tg)if(hasOwnProperty(tg,ig)){const ng=tg[ig];if(ng==null)continue;gg[eg(ig)]=asNumber(ng)}return gg}function formatOffset(tg,eg){const gg=Math.trunc(Math.abs(tg/60)),ig=Math.trunc(Math.abs(tg%60)),ng=tg>=0?"+":"-";switch(eg){case"short":return`${ng}${padStart(gg,2)}:${padStart(ig,2)}`;case"narrow":return`${ng}${gg}${ig>0?`:${ig}`:""}`;case"techie":return`${ng}${padStart(gg,2)}${padStart(ig,2)}`;default:throw new RangeError(`Value format ${eg} is out of range for property format`)}}function timeObject(tg){return pick(tg,["hour","minute","second","millisecond"])}const monthsLong=["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],monthsNarrow=["J","F","M","A","M","J","J","A","S","O","N","D"];function months(tg){switch(tg){case"narrow":return[...monthsNarrow];case"short":return[...monthsShort];case"long":return[...monthsLong];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const weekdaysLong=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],weekdaysShort=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],weekdaysNarrow=["M","T","W","T","F","S","S"];function weekdays(tg){switch(tg){case"narrow":return[...weekdaysNarrow];case"short":return[...weekdaysShort];case"long":return[...weekdaysLong];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const meridiems=["AM","PM"],erasLong=["Before Christ","Anno Domini"],erasShort=["BC","AD"],erasNarrow=["B","A"];function eras(tg){switch(tg){case"narrow":return[...erasNarrow];case"short":return[...erasShort];case"long":return[...erasLong];default:return null}}function meridiemForDateTime(tg){return meridiems[tg.hour<12?0:1]}function weekdayForDateTime(tg,eg){return weekdays(eg)[tg.weekday-1]}function monthForDateTime(tg,eg){return months(eg)[tg.month-1]}function eraForDateTime(tg,eg){return eras(eg)[tg.year<0?0:1]}function formatRelativeTime(tg,eg,gg="always",ig=!1){const ng={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},og=["hours","minutes","seconds"].indexOf(tg)===-1;if(gg==="auto"&&og){const Ag=tg==="days";switch(eg){case 1:return Ag?"tomorrow":`next ${ng[tg][0]}`;case-1:return Ag?"yesterday":`last ${ng[tg][0]}`;case 0:return Ag?"today":`this ${ng[tg][0]}`}}const ag=Object.is(eg,-0)||eg<0,sg=Math.abs(eg),Ig=sg===1,Cg=ng[tg],lg=ig?Ig?Cg[1]:Cg[2]||Cg[1]:Ig?ng[tg][0]:tg;return ag?`${sg} ${lg} ago`:`in ${sg} ${lg}`}function stringifyTokens(tg,eg){let gg="";for(const ig of tg)ig.literal?gg+=ig.val:gg+=eg(ig.val);return gg}const macroTokenToFormatOpts={D:DATE_SHORT,DD:DATE_MED,DDD:DATE_FULL,DDDD:DATE_HUGE,t:TIME_SIMPLE,tt:TIME_WITH_SECONDS,ttt:TIME_WITH_SHORT_OFFSET,tttt:TIME_WITH_LONG_OFFSET,T:TIME_24_SIMPLE,TT:TIME_24_WITH_SECONDS,TTT:TIME_24_WITH_SHORT_OFFSET,TTTT:TIME_24_WITH_LONG_OFFSET,f:DATETIME_SHORT,ff:DATETIME_MED,fff:DATETIME_FULL,ffff:DATETIME_HUGE,F:DATETIME_SHORT_WITH_SECONDS,FF:DATETIME_MED_WITH_SECONDS,FFF:DATETIME_FULL_WITH_SECONDS,FFFF:DATETIME_HUGE_WITH_SECONDS};class Formatter{static create(eg,gg={}){return new Formatter(eg,gg)}static parseFormat(eg){let gg=null,ig="",ng=!1;const og=[];for(let ag=0;ag<eg.length;ag++){const sg=eg.charAt(ag);sg==="'"?((ig.length>0||ng)&&og.push({literal:ng||/^\s+$/.test(ig),val:ig===""?"'":ig}),gg=null,ig="",ng=!ng):ng||sg===gg?ig+=sg:(ig.length>0&&og.push({literal:/^\s+$/.test(ig),val:ig}),ig=sg,gg=sg)}return ig.length>0&&og.push({literal:ng||/^\s+$/.test(ig),val:ig}),og}static macroTokenToFormatOpts(eg){return macroTokenToFormatOpts[eg]}constructor(eg,gg){this.opts=gg,this.loc=eg,this.systemLoc=null}formatWithSystemDefault(eg,gg){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(eg,{...this.opts,...gg}).format()}dtFormatter(eg,gg={}){return this.loc.dtFormatter(eg,{...this.opts,...gg})}formatDateTime(eg,gg){return this.dtFormatter(eg,gg).format()}formatDateTimeParts(eg,gg){return this.dtFormatter(eg,gg).formatToParts()}formatInterval(eg,gg){return this.dtFormatter(eg.start,gg).dtf.formatRange(eg.start.toJSDate(),eg.end.toJSDate())}resolvedOptions(eg,gg){return this.dtFormatter(eg,gg).resolvedOptions()}num(eg,gg=0,ig=void 0){if(this.opts.forceSimple)return padStart(eg,gg);const ng={...this.opts};return gg>0&&(ng.padTo=gg),ig&&(ng.signDisplay=ig),this.loc.numberFormatter(ng).format(eg)}formatDateTimeFromString(eg,gg){const ig=this.loc.listingMode()==="en",ng=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",og=(cg,ug)=>this.loc.extract(eg,cg,ug),ag=cg=>eg.isOffsetFixed&&eg.offset===0&&cg.allowZ?"Z":eg.isValid?eg.zone.formatOffset(eg.ts,cg.format):"",sg=()=>ig?meridiemForDateTime(eg):og({hour:"numeric",hourCycle:"h12"},"dayperiod"),Ig=(cg,ug)=>ig?monthForDateTime(eg,cg):og(ug?{month:cg}:{month:cg,day:"numeric"},"month"),Cg=(cg,ug)=>ig?weekdayForDateTime(eg,cg):og(ug?{weekday:cg}:{weekday:cg,month:"long",day:"numeric"},"weekday"),lg=cg=>{const ug=Formatter.macroTokenToFormatOpts(cg);return ug?this.formatWithSystemDefault(eg,ug):cg},Ag=cg=>ig?eraForDateTime(eg,cg):og({era:cg},"era"),rg=cg=>{switch(cg){case"S":return this.num(eg.millisecond);case"u":case"SSS":return this.num(eg.millisecond,3);case"s":return this.num(eg.second);case"ss":return this.num(eg.second,2);case"uu":return this.num(Math.floor(eg.millisecond/10),2);case"uuu":return this.num(Math.floor(eg.millisecond/100));case"m":return this.num(eg.minute);case"mm":return this.num(eg.minute,2);case"h":return this.num(eg.hour%12===0?12:eg.hour%12);case"hh":return this.num(eg.hour%12===0?12:eg.hour%12,2);case"H":return this.num(eg.hour);case"HH":return this.num(eg.hour,2);case"Z":return ag({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return ag({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return ag({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return eg.zone.offsetName(eg.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return eg.zone.offsetName(eg.ts,{format:"long",locale:this.loc.locale});case"z":return eg.zoneName;case"a":return sg();case"d":return ng?og({day:"numeric"},"day"):this.num(eg.day);case"dd":return ng?og({day:"2-digit"},"day"):this.num(eg.day,2);case"c":return this.num(eg.weekday);case"ccc":return Cg("short",!0);case"cccc":return Cg("long",!0);case"ccccc":return Cg("narrow",!0);case"E":return this.num(eg.weekday);case"EEE":return Cg("short",!1);case"EEEE":return Cg("long",!1);case"EEEEE":return Cg("narrow",!1);case"L":return ng?og({month:"numeric",day:"numeric"},"month"):this.num(eg.month);case"LL":return ng?og({month:"2-digit",day:"numeric"},"month"):this.num(eg.month,2);case"LLL":return Ig("short",!0);case"LLLL":return Ig("long",!0);case"LLLLL":return Ig("narrow",!0);case"M":return ng?og({month:"numeric"},"month"):this.num(eg.month);case"MM":return ng?og({month:"2-digit"},"month"):this.num(eg.month,2);case"MMM":return Ig("short",!1);case"MMMM":return Ig("long",!1);case"MMMMM":return Ig("narrow",!1);case"y":return ng?og({year:"numeric"},"year"):this.num(eg.year);case"yy":return ng?og({year:"2-digit"},"year"):this.num(eg.year.toString().slice(-2),2);case"yyyy":return ng?og({year:"numeric"},"year"):this.num(eg.year,4);case"yyyyyy":return ng?og({year:"numeric"},"year"):this.num(eg.year,6);case"G":return Ag("short");case"GG":return Ag("long");case"GGGGG":return Ag("narrow");case"kk":return this.num(eg.weekYear.toString().slice(-2),2);case"kkkk":return this.num(eg.weekYear,4);case"W":return this.num(eg.weekNumber);case"WW":return this.num(eg.weekNumber,2);case"n":return this.num(eg.localWeekNumber);case"nn":return this.num(eg.localWeekNumber,2);case"ii":return this.num(eg.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(eg.localWeekYear,4);case"o":return this.num(eg.ordinal);case"ooo":return this.num(eg.ordinal,3);case"q":return this.num(eg.quarter);case"qq":return this.num(eg.quarter,2);case"X":return this.num(Math.floor(eg.ts/1e3));case"x":return this.num(eg.ts);default:return lg(cg)}};return stringifyTokens(Formatter.parseFormat(gg),rg)}formatDurationFromString(eg,gg){const ig=this.opts.signMode==="negativeLargestOnly"?-1:1,ng=lg=>{switch(lg[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},og=(lg,Ag)=>rg=>{const cg=ng(rg);if(cg){const ug=Ag.isNegativeDuration&&cg!==Ag.largestUnit?ig:1;let dg;return this.opts.signMode==="negativeLargestOnly"&&cg!==Ag.largestUnit?dg="never":this.opts.signMode==="all"?dg="always":dg="auto",this.num(lg.get(cg)*ug,rg.length,dg)}else return rg},ag=Formatter.parseFormat(gg),sg=ag.reduce((lg,{literal:Ag,val:rg})=>Ag?lg:lg.concat(rg),[]),Ig=eg.shiftTo(...sg.map(ng).filter(lg=>lg)),Cg={isNegativeDuration:Ig<0,largestUnit:Object.keys(Ig.values)[0]};return stringifyTokens(ag,og(Ig,Cg))}}const ianaRegex=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function combineRegexes(...tg){const eg=tg.reduce((gg,ig)=>gg+ig.source,"");return RegExp(`^${eg}$`)}function combineExtractors(...tg){return eg=>tg.reduce(([gg,ig,ng],og)=>{const[ag,sg,Ig]=og(eg,ng);return[{...gg,...ag},sg||ig,Ig]},[{},null,1]).slice(0,2)}function parse(tg,...eg){if(tg==null)return[null,null];for(const[gg,ig]of eg){const ng=gg.exec(tg);if(ng)return ig(ng)}return[null,null]}function simpleParse(...tg){return(eg,gg)=>{const ig={};let ng;for(ng=0;ng<tg.length;ng++)ig[tg[ng]]=parseInteger(eg[gg+ng]);return[ig,null,gg+ng]}}const offsetRegex=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,isoExtendedZone=`(?:${offsetRegex.source}?(?:\\[(${ianaRegex.source})\\])?)?`,isoTimeBaseRegex=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,isoTimeRegex=RegExp(`${isoTimeBaseRegex.source}${isoExtendedZone}`),isoTimeExtensionRegex=RegExp(`(?:[Tt]${isoTimeRegex.source})?`),isoYmdRegex=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,isoWeekRegex=/(\d{4})-?W(\d\d)(?:-?(\d))?/,isoOrdinalRegex=/(\d{4})-?(\d{3})/,extractISOWeekData=simpleParse("weekYear","weekNumber","weekDay"),extractISOOrdinalData=simpleParse("year","ordinal"),sqlYmdRegex=/(\d{4})-(\d\d)-(\d\d)/,sqlTimeRegex=RegExp(`${isoTimeBaseRegex.source} ?(?:${offsetRegex.source}|(${ianaRegex.source}))?`),sqlTimeExtensionRegex=RegExp(`(?: ${sqlTimeRegex.source})?`);function int(tg,eg,gg){const ig=tg[eg];return isUndefined$1(ig)?gg:parseInteger(ig)}function extractISOYmd(tg,eg){return[{year:int(tg,eg),month:int(tg,eg+1,1),day:int(tg,eg+2,1)},null,eg+3]}function extractISOTime(tg,eg){return[{hours:int(tg,eg,0),minutes:int(tg,eg+1,0),seconds:int(tg,eg+2,0),milliseconds:parseMillis(tg[eg+3])},null,eg+4]}function extractISOOffset(tg,eg){const gg=!tg[eg]&&!tg[eg+1],ig=signedOffset(tg[eg+1],tg[eg+2]),ng=gg?null:FixedOffsetZone.instance(ig);return[{},ng,eg+3]}function extractIANAZone(tg,eg){const gg=tg[eg]?IANAZone.create(tg[eg]):null;return[{},gg,eg+1]}const isoTimeOnly=RegExp(`^T?${isoTimeBaseRegex.source}$`),isoDuration=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function extractISODuration(tg){const[eg,gg,ig,ng,og,ag,sg,Ig,Cg]=tg,lg=eg[0]==="-",Ag=Ig&&Ig[0]==="-",rg=(cg,ug=!1)=>cg!==void 0&&(ug||cg&&lg)?-cg:cg;return[{years:rg(parseFloating(gg)),months:rg(parseFloating(ig)),weeks:rg(parseFloating(ng)),days:rg(parseFloating(og)),hours:rg(parseFloating(ag)),minutes:rg(parseFloating(sg)),seconds:rg(parseFloating(Ig),Ig==="-0"),milliseconds:rg(parseMillis(Cg),Ag)}]}const obsOffsets={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function fromStrings(tg,eg,gg,ig,ng,og,ag){const sg={year:eg.length===2?untruncateYear(parseInteger(eg)):parseInteger(eg),month:monthsShort.indexOf(gg)+1,day:parseInteger(ig),hour:parseInteger(ng),minute:parseInteger(og)};return ag&&(sg.second=parseInteger(ag)),tg&&(sg.weekday=tg.length>3?weekdaysLong.indexOf(tg)+1:weekdaysShort.indexOf(tg)+1),sg}const rfc2822=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function extractRFC2822(tg){const[,eg,gg,ig,ng,og,ag,sg,Ig,Cg,lg,Ag]=tg,rg=fromStrings(eg,ng,ig,gg,og,ag,sg);let cg;return Ig?cg=obsOffsets[Ig]:Cg?cg=0:cg=signedOffset(lg,Ag),[rg,new FixedOffsetZone(cg)]}function preprocessRFC2822(tg){return tg.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const rfc1123=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,rfc850=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,ascii=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function extractRFC1123Or850(tg){const[,eg,gg,ig,ng,og,ag,sg]=tg;return[fromStrings(eg,ng,ig,gg,og,ag,sg),FixedOffsetZone.utcInstance]}function extractASCII(tg){const[,eg,gg,ig,ng,og,ag,sg]=tg;return[fromStrings(eg,sg,gg,ig,ng,og,ag),FixedOffsetZone.utcInstance]}const isoYmdWithTimeExtensionRegex=combineRegexes(isoYmdRegex,isoTimeExtensionRegex),isoWeekWithTimeExtensionRegex=combineRegexes(isoWeekRegex,isoTimeExtensionRegex),isoOrdinalWithTimeExtensionRegex=combineRegexes(isoOrdinalRegex,isoTimeExtensionRegex),isoTimeCombinedRegex=combineRegexes(isoTimeRegex),extractISOYmdTimeAndOffset=combineExtractors(extractISOYmd,extractISOTime,extractISOOffset,extractIANAZone),extractISOWeekTimeAndOffset=combineExtractors(extractISOWeekData,extractISOTime,extractISOOffset,extractIANAZone),extractISOOrdinalDateAndTime=combineExtractors(extractISOOrdinalData,extractISOTime,extractISOOffset,extractIANAZone),extractISOTimeAndOffset=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseISODate(tg){return parse(tg,[isoYmdWithTimeExtensionRegex,extractISOYmdTimeAndOffset],[isoWeekWithTimeExtensionRegex,extractISOWeekTimeAndOffset],[isoOrdinalWithTimeExtensionRegex,extractISOOrdinalDateAndTime],[isoTimeCombinedRegex,extractISOTimeAndOffset])}function parseRFC2822Date(tg){return parse(preprocessRFC2822(tg),[rfc2822,extractRFC2822])}function parseHTTPDate(tg){return parse(tg,[rfc1123,extractRFC1123Or850],[rfc850,extractRFC1123Or850],[ascii,extractASCII])}function parseISODuration(tg){return parse(tg,[isoDuration,extractISODuration])}const extractISOTimeOnly=combineExtractors(extractISOTime);function parseISOTimeOnly(tg){return parse(tg,[isoTimeOnly,extractISOTimeOnly])}const sqlYmdWithTimeExtensionRegex=combineRegexes(sqlYmdRegex,sqlTimeExtensionRegex),sqlTimeCombinedRegex=combineRegexes(sqlTimeRegex),extractISOTimeOffsetAndIANAZone=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseSQL(tg){return parse(tg,[sqlYmdWithTimeExtensionRegex,extractISOYmdTimeAndOffset],[sqlTimeCombinedRegex,extractISOTimeOffsetAndIANAZone])}const INVALID$2="Invalid Duration",lowOrderMatrix={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},casualMatrix={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...lowOrderMatrix},daysInYearAccurate=146097/400,daysInMonthAccurate=146097/4800,accurateMatrix={years:{quarters:4,months:12,weeks:daysInYearAccurate/7,days:daysInYearAccurate,hours:daysInYearAccurate*24,minutes:daysInYearAccurate*24*60,seconds:daysInYearAccurate*24*60*60,milliseconds:daysInYearAccurate*24*60*60*1e3},quarters:{months:3,weeks:daysInYearAccurate/28,days:daysInYearAccurate/4,hours:daysInYearAccurate*24/4,minutes:daysInYearAccurate*24*60/4,seconds:daysInYearAccurate*24*60*60/4,milliseconds:daysInYearAccurate*24*60*60*1e3/4},months:{weeks:daysInMonthAccurate/7,days:daysInMonthAccurate,hours:daysInMonthAccurate*24,minutes:daysInMonthAccurate*24*60,seconds:daysInMonthAccurate*24*60*60,milliseconds:daysInMonthAccurate*24*60*60*1e3},...lowOrderMatrix},orderedUnits$1=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],reverseUnits=orderedUnits$1.slice(0).reverse();function clone$1(tg,eg,gg=!1){const ig={values:gg?eg.values:{...tg.values,...eg.values||{}},loc:tg.loc.clone(eg.loc),conversionAccuracy:eg.conversionAccuracy||tg.conversionAccuracy,matrix:eg.matrix||tg.matrix};return new Duration(ig)}function durationToMillis(tg,eg){let gg=eg.milliseconds??0;for(const ig of reverseUnits.slice(1))eg[ig]&&(gg+=eg[ig]*tg[ig].milliseconds);return gg}function normalizeValues(tg,eg){const gg=durationToMillis(tg,eg)<0?-1:1;orderedUnits$1.reduceRight((ig,ng)=>{if(isUndefined$1(eg[ng]))return ig;if(ig){const og=eg[ig]*gg,ag=tg[ng][ig],sg=Math.floor(og/ag);eg[ng]+=sg*gg,eg[ig]-=sg*ag*gg}return ng},null),orderedUnits$1.reduce((ig,ng)=>{if(isUndefined$1(eg[ng]))return ig;if(ig){const og=eg[ig]%1;eg[ig]-=og,eg[ng]+=og*tg[ig][ng]}return ng},null)}function removeZeroes(tg){const eg={};for(const[gg,ig]of Object.entries(tg))ig!==0&&(eg[gg]=ig);return eg}class Duration{constructor(eg){const gg=eg.conversionAccuracy==="longterm"||!1;let ig=gg?accurateMatrix:casualMatrix;eg.matrix&&(ig=eg.matrix),this.values=eg.values,this.loc=eg.loc||Locale.create(),this.conversionAccuracy=gg?"longterm":"casual",this.invalid=eg.invalid||null,this.matrix=ig,this.isLuxonDuration=!0}static fromMillis(eg,gg){return Duration.fromObject({milliseconds:eg},gg)}static fromObject(eg,gg={}){if(eg==null||typeof eg!="object")throw new InvalidArgumentError(`Duration.fromObject: argument expected to be an object, got ${eg===null?"null":typeof eg}`);return new Duration({values:normalizeObject(eg,Duration.normalizeUnit),loc:Locale.fromObject(gg),conversionAccuracy:gg.conversionAccuracy,matrix:gg.matrix})}static fromDurationLike(eg){if(isNumber$1(eg))return Duration.fromMillis(eg);if(Duration.isDuration(eg))return eg;if(typeof eg=="object")return Duration.fromObject(eg);throw new InvalidArgumentError(`Unknown duration argument ${eg} of type ${typeof eg}`)}static fromISO(eg,gg){const[ig]=parseISODuration(eg);return ig?Duration.fromObject(ig,gg):Duration.invalid("unparsable",`the input "${eg}" can't be parsed as ISO 8601`)}static fromISOTime(eg,gg){const[ig]=parseISOTimeOnly(eg);return ig?Duration.fromObject(ig,gg):Duration.invalid("unparsable",`the input "${eg}" can't be parsed as ISO 8601`)}static invalid(eg,gg=null){if(!eg)throw new InvalidArgumentError("need to specify a reason the Duration is invalid");const ig=eg instanceof Invalid?eg:new Invalid(eg,gg);if(Settings.throwOnInvalid)throw new InvalidDurationError(ig);return new Duration({invalid:ig})}static normalizeUnit(eg){const gg={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[eg&&eg.toLowerCase()];if(!gg)throw new InvalidUnitError(eg);return gg}static isDuration(eg){return eg&&eg.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(eg,gg={}){const ig={...gg,floor:gg.round!==!1&&gg.floor!==!1};return this.isValid?Formatter.create(this.loc,ig).formatDurationFromString(this,eg):INVALID$2}toHuman(eg={}){if(!this.isValid)return INVALID$2;const gg=eg.showZeros!==!1,ig=orderedUnits$1.map(ng=>{const og=this.values[ng];return isUndefined$1(og)||og===0&&!gg?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...eg,unit:ng.slice(0,-1)}).format(og)}).filter(ng=>ng);return this.loc.listFormatter({type:"conjunction",style:eg.listStyle||"narrow",...eg}).format(ig)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let eg="P";return this.years!==0&&(eg+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(eg+=this.months+this.quarters*3+"M"),this.weeks!==0&&(eg+=this.weeks+"W"),this.days!==0&&(eg+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(eg+="T"),this.hours!==0&&(eg+=this.hours+"H"),this.minutes!==0&&(eg+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(eg+=roundTo(this.seconds+this.milliseconds/1e3,3)+"S"),eg==="P"&&(eg+="T0S"),eg}toISOTime(eg={}){if(!this.isValid)return null;const gg=this.toMillis();return gg<0||gg>=864e5?null:(eg={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...eg,includeOffset:!1},DateTime.fromMillis(gg,{zone:"UTC"}).toISOTime(eg))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?durationToMillis(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg),ig={};for(const ng of orderedUnits$1)(hasOwnProperty(gg.values,ng)||hasOwnProperty(this.values,ng))&&(ig[ng]=gg.get(ng)+this.get(ng));return clone$1(this,{values:ig},!0)}minus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg);return this.plus(gg.negate())}mapUnits(eg){if(!this.isValid)return this;const gg={};for(const ig of Object.keys(this.values))gg[ig]=asNumber(eg(this.values[ig],ig));return clone$1(this,{values:gg},!0)}get(eg){return this[Duration.normalizeUnit(eg)]}set(eg){if(!this.isValid)return this;const gg={...this.values,...normalizeObject(eg,Duration.normalizeUnit)};return clone$1(this,{values:gg})}reconfigure({locale:eg,numberingSystem:gg,conversionAccuracy:ig,matrix:ng}={}){const ag={loc:this.loc.clone({locale:eg,numberingSystem:gg}),matrix:ng,conversionAccuracy:ig};return clone$1(this,ag)}as(eg){return this.isValid?this.shiftTo(eg).get(eg):NaN}normalize(){if(!this.isValid)return this;const eg=this.toObject();return normalizeValues(this.matrix,eg),clone$1(this,{values:eg},!0)}rescale(){if(!this.isValid)return this;const eg=removeZeroes(this.normalize().shiftToAll().toObject());return clone$1(this,{values:eg},!0)}shiftTo(...eg){if(!this.isValid)return this;if(eg.length===0)return this;eg=eg.map(ag=>Duration.normalizeUnit(ag));const gg={},ig={},ng=this.toObject();let og;for(const ag of orderedUnits$1)if(eg.indexOf(ag)>=0){og=ag;let sg=0;for(const Cg in ig)sg+=this.matrix[Cg][ag]*ig[Cg],ig[Cg]=0;isNumber$1(ng[ag])&&(sg+=ng[ag]);const Ig=Math.trunc(sg);gg[ag]=Ig,ig[ag]=(sg*1e3-Ig*1e3)/1e3}else isNumber$1(ng[ag])&&(ig[ag]=ng[ag]);for(const ag in ig)ig[ag]!==0&&(gg[og]+=ag===og?ig[ag]:ig[ag]/this.matrix[og][ag]);return normalizeValues(this.matrix,gg),clone$1(this,{values:gg},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const eg={};for(const gg of Object.keys(this.values))eg[gg]=this.values[gg]===0?0:-this.values[gg];return clone$1(this,{values:eg},!0)}removeZeros(){if(!this.isValid)return this;const eg=removeZeroes(this.values);return clone$1(this,{values:eg},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(eg){if(!this.isValid||!eg.isValid||!this.loc.equals(eg.loc))return!1;function gg(ig,ng){return ig===void 0||ig===0?ng===void 0||ng===0:ig===ng}for(const ig of orderedUnits$1)if(!gg(this.values[ig],eg.values[ig]))return!1;return!0}}const INVALID$1="Invalid Interval";function validateStartEnd(tg,eg){return!tg||!tg.isValid?Interval.invalid("missing or invalid start"):!eg||!eg.isValid?Interval.invalid("missing or invalid end"):eg<tg?Interval.invalid("end before start",`The end of an interval must be after its start, but you had start=${tg.toISO()} and end=${eg.toISO()}`):null}class Interval{constructor(eg){this.s=eg.start,this.e=eg.end,this.invalid=eg.invalid||null,this.isLuxonInterval=!0}static invalid(eg,gg=null){if(!eg)throw new InvalidArgumentError("need to specify a reason the Interval is invalid");const ig=eg instanceof Invalid?eg:new Invalid(eg,gg);if(Settings.throwOnInvalid)throw new InvalidIntervalError(ig);return new Interval({invalid:ig})}static fromDateTimes(eg,gg){const ig=friendlyDateTime(eg),ng=friendlyDateTime(gg),og=validateStartEnd(ig,ng);return og??new Interval({start:ig,end:ng})}static after(eg,gg){const ig=Duration.fromDurationLike(gg),ng=friendlyDateTime(eg);return Interval.fromDateTimes(ng,ng.plus(ig))}static before(eg,gg){const ig=Duration.fromDurationLike(gg),ng=friendlyDateTime(eg);return Interval.fromDateTimes(ng.minus(ig),ng)}static fromISO(eg,gg){const[ig,ng]=(eg||"").split("/",2);if(ig&&ng){let og,ag;try{og=DateTime.fromISO(ig,gg),ag=og.isValid}catch{ag=!1}let sg,Ig;try{sg=DateTime.fromISO(ng,gg),Ig=sg.isValid}catch{Ig=!1}if(ag&&Ig)return Interval.fromDateTimes(og,sg);if(ag){const Cg=Duration.fromISO(ng,gg);if(Cg.isValid)return Interval.after(og,Cg)}else if(Ig){const Cg=Duration.fromISO(ig,gg);if(Cg.isValid)return Interval.before(sg,Cg)}}return Interval.invalid("unparsable",`the input "${eg}" can't be parsed as ISO 8601`)}static isInterval(eg){return eg&&eg.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(eg="milliseconds"){return this.isValid?this.toDuration(eg).get(eg):NaN}count(eg="milliseconds",gg){if(!this.isValid)return NaN;const ig=this.start.startOf(eg,gg);let ng;return gg!=null&&gg.useLocaleWeeks?ng=this.end.reconfigure({locale:ig.locale}):ng=this.end,ng=ng.startOf(eg,gg),Math.floor(ng.diff(ig,eg).get(eg))+(ng.valueOf()!==this.end.valueOf())}hasSame(eg){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,eg):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(eg){return this.isValid?this.s>eg:!1}isBefore(eg){return this.isValid?this.e<=eg:!1}contains(eg){return this.isValid?this.s<=eg&&this.e>eg:!1}set({start:eg,end:gg}={}){return this.isValid?Interval.fromDateTimes(eg||this.s,gg||this.e):this}splitAt(...eg){if(!this.isValid)return[];const gg=eg.map(friendlyDateTime).filter(ag=>this.contains(ag)).sort((ag,sg)=>ag.toMillis()-sg.toMillis()),ig=[];let{s:ng}=this,og=0;for(;ng<this.e;){const ag=gg[og]||this.e,sg=+ag>+this.e?this.e:ag;ig.push(Interval.fromDateTimes(ng,sg)),ng=sg,og+=1}return ig}splitBy(eg){const gg=Duration.fromDurationLike(eg);if(!this.isValid||!gg.isValid||gg.as("milliseconds")===0)return[];let{s:ig}=this,ng=1,og;const ag=[];for(;ig<this.e;){const sg=this.start.plus(gg.mapUnits(Ig=>Ig*ng));og=+sg>+this.e?this.e:sg,ag.push(Interval.fromDateTimes(ig,og)),ig=og,ng+=1}return ag}divideEqually(eg){return this.isValid?this.splitBy(this.length()/eg).slice(0,eg):[]}overlaps(eg){return this.e>eg.s&&this.s<eg.e}abutsStart(eg){return this.isValid?+this.e==+eg.s:!1}abutsEnd(eg){return this.isValid?+eg.e==+this.s:!1}engulfs(eg){return this.isValid?this.s<=eg.s&&this.e>=eg.e:!1}equals(eg){return!this.isValid||!eg.isValid?!1:this.s.equals(eg.s)&&this.e.equals(eg.e)}intersection(eg){if(!this.isValid)return this;const gg=this.s>eg.s?this.s:eg.s,ig=this.e<eg.e?this.e:eg.e;return gg>=ig?null:Interval.fromDateTimes(gg,ig)}union(eg){if(!this.isValid)return this;const gg=this.s<eg.s?this.s:eg.s,ig=this.e>eg.e?this.e:eg.e;return Interval.fromDateTimes(gg,ig)}static merge(eg){const[gg,ig]=eg.sort((ng,og)=>ng.s-og.s).reduce(([ng,og],ag)=>og?og.overlaps(ag)||og.abutsStart(ag)?[ng,og.union(ag)]:[ng.concat([og]),ag]:[ng,ag],[[],null]);return ig&&gg.push(ig),gg}static xor(eg){let gg=null,ig=0;const ng=[],og=eg.map(Ig=>[{time:Ig.s,type:"s"},{time:Ig.e,type:"e"}]),ag=Array.prototype.concat(...og),sg=ag.sort((Ig,Cg)=>Ig.time-Cg.time);for(const Ig of sg)ig+=Ig.type==="s"?1:-1,ig===1?gg=Ig.time:(gg&&+gg!=+Ig.time&&ng.push(Interval.fromDateTimes(gg,Ig.time)),gg=null);return Interval.merge(ng)}difference(...eg){return Interval.xor([this].concat(eg)).map(gg=>this.intersection(gg)).filter(gg=>gg&&!gg.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:INVALID$1}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(eg=DATE_SHORT,gg={}){return this.isValid?Formatter.create(this.s.loc.clone(gg),eg).formatInterval(this):INVALID$1}toISO(eg){return this.isValid?`${this.s.toISO(eg)}/${this.e.toISO(eg)}`:INVALID$1}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:INVALID$1}toISOTime(eg){return this.isValid?`${this.s.toISOTime(eg)}/${this.e.toISOTime(eg)}`:INVALID$1}toFormat(eg,{separator:gg=" – "}={}){return this.isValid?`${this.s.toFormat(eg)}${gg}${this.e.toFormat(eg)}`:INVALID$1}toDuration(eg,gg){return this.isValid?this.e.diff(this.s,eg,gg):Duration.invalid(this.invalidReason)}mapEndpoints(eg){return Interval.fromDateTimes(eg(this.s),eg(this.e))}}class Info{static hasDST(eg=Settings.defaultZone){const gg=DateTime.now().setZone(eg).set({month:12});return!eg.isUniversal&&gg.offset!==gg.set({month:6}).offset}static isValidIANAZone(eg){return IANAZone.isValidZone(eg)}static normalizeZone(eg){return normalizeZone(eg,Settings.defaultZone)}static getStartOfWeek({locale:eg=null,locObj:gg=null}={}){return(gg||Locale.create(eg)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:eg=null,locObj:gg=null}={}){return(gg||Locale.create(eg)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:eg=null,locObj:gg=null}={}){return(gg||Locale.create(eg)).getWeekendDays().slice()}static months(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null,outputCalendar:og="gregory"}={}){return(ng||Locale.create(gg,ig,og)).months(eg)}static monthsFormat(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null,outputCalendar:og="gregory"}={}){return(ng||Locale.create(gg,ig,og)).months(eg,!0)}static weekdays(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null}={}){return(ng||Locale.create(gg,ig,null)).weekdays(eg)}static weekdaysFormat(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null}={}){return(ng||Locale.create(gg,ig,null)).weekdays(eg,!0)}static meridiems({locale:eg=null}={}){return Locale.create(eg).meridiems()}static eras(eg="short",{locale:gg=null}={}){return Locale.create(gg,null,"gregory").eras(eg)}static features(){return{relative:hasRelative(),localeWeek:hasLocaleWeekInfo()}}}function dayDiff(tg,eg){const gg=ng=>ng.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),ig=gg(eg)-gg(tg);return Math.floor(Duration.fromMillis(ig).as("days"))}function highOrderDiffs(tg,eg,gg){const ig=[["years",(Ig,Cg)=>Cg.year-Ig.year],["quarters",(Ig,Cg)=>Cg.quarter-Ig.quarter+(Cg.year-Ig.year)*4],["months",(Ig,Cg)=>Cg.month-Ig.month+(Cg.year-Ig.year)*12],["weeks",(Ig,Cg)=>{const lg=dayDiff(Ig,Cg);return(lg-lg%7)/7}],["days",dayDiff]],ng={},og=tg;let ag,sg;for(const[Ig,Cg]of ig)gg.indexOf(Ig)>=0&&(ag=Ig,ng[Ig]=Cg(tg,eg),sg=og.plus(ng),sg>eg?(ng[Ig]--,tg=og.plus(ng),tg>eg&&(sg=tg,ng[Ig]--,tg=og.plus(ng))):tg=sg);return[tg,ng,sg,ag]}function diff(tg,eg,gg,ig){let[ng,og,ag,sg]=highOrderDiffs(tg,eg,gg);const Ig=eg-ng,Cg=gg.filter(Ag=>["hours","minutes","seconds","milliseconds"].indexOf(Ag)>=0);Cg.length===0&&(ag<eg&&(ag=ng.plus({[sg]:1})),ag!==ng&&(og[sg]=(og[sg]||0)+Ig/(ag-ng)));const lg=Duration.fromObject(og,ig);return Cg.length>0?Duration.fromMillis(Ig,ig).shiftTo(...Cg).plus(lg):lg}const MISSING_FTP="missing Intl.DateTimeFormat.formatToParts support";function intUnit(tg,eg=gg=>gg){return{regex:tg,deser:([gg])=>eg(parseDigits(gg))}}const NBSP=" ",spaceOrNBSP=`[ ${NBSP}]`,spaceOrNBSPRegExp=new RegExp(spaceOrNBSP,"g");function fixListRegex(tg){return tg.replace(/\./g,"\\.?").replace(spaceOrNBSPRegExp,spaceOrNBSP)}function stripInsensitivities(tg){return tg.replace(/\./g,"").replace(spaceOrNBSPRegExp," ").toLowerCase()}function oneOf(tg,eg){return tg===null?null:{regex:RegExp(tg.map(fixListRegex).join("|")),deser:([gg])=>tg.findIndex(ig=>stripInsensitivities(gg)===stripInsensitivities(ig))+eg}}function offset(tg,eg){return{regex:tg,deser:([,gg,ig])=>signedOffset(gg,ig),groups:eg}}function simple(tg){return{regex:tg,deser:([eg])=>eg}}function escapeToken(tg){return tg.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function unitForToken(tg,eg){const gg=digitRegex(eg),ig=digitRegex(eg,"{2}"),ng=digitRegex(eg,"{3}"),og=digitRegex(eg,"{4}"),ag=digitRegex(eg,"{6}"),sg=digitRegex(eg,"{1,2}"),Ig=digitRegex(eg,"{1,3}"),Cg=digitRegex(eg,"{1,6}"),lg=digitRegex(eg,"{1,9}"),Ag=digitRegex(eg,"{2,4}"),rg=digitRegex(eg,"{4,6}"),cg=hg=>({regex:RegExp(escapeToken(hg.val)),deser:([mg])=>mg,literal:!0}),dg=(hg=>{if(tg.literal)return cg(hg);switch(hg.val){case"G":return oneOf(eg.eras("short"),0);case"GG":return oneOf(eg.eras("long"),0);case"y":return intUnit(Cg);case"yy":return intUnit(Ag,untruncateYear);case"yyyy":return intUnit(og);case"yyyyy":return intUnit(rg);case"yyyyyy":return intUnit(ag);case"M":return intUnit(sg);case"MM":return intUnit(ig);case"MMM":return oneOf(eg.months("short",!0),1);case"MMMM":return oneOf(eg.months("long",!0),1);case"L":return intUnit(sg);case"LL":return intUnit(ig);case"LLL":return oneOf(eg.months("short",!1),1);case"LLLL":return oneOf(eg.months("long",!1),1);case"d":return intUnit(sg);case"dd":return intUnit(ig);case"o":return intUnit(Ig);case"ooo":return intUnit(ng);case"HH":return intUnit(ig);case"H":return intUnit(sg);case"hh":return intUnit(ig);case"h":return intUnit(sg);case"mm":return intUnit(ig);case"m":return intUnit(sg);case"q":return intUnit(sg);case"qq":return intUnit(ig);case"s":return intUnit(sg);case"ss":return intUnit(ig);case"S":return intUnit(Ig);case"SSS":return intUnit(ng);case"u":return simple(lg);case"uu":return simple(sg);case"uuu":return intUnit(gg);case"a":return oneOf(eg.meridiems(),0);case"kkkk":return intUnit(og);case"kk":return intUnit(Ag,untruncateYear);case"W":return intUnit(sg);case"WW":return intUnit(ig);case"E":case"c":return intUnit(gg);case"EEE":return oneOf(eg.weekdays("short",!1),1);case"EEEE":return oneOf(eg.weekdays("long",!1),1);case"ccc":return oneOf(eg.weekdays("short",!0),1);case"cccc":return oneOf(eg.weekdays("long",!0),1);case"Z":case"ZZ":return offset(new RegExp(`([+-]${sg.source})(?::(${ig.source}))?`),2);case"ZZZ":return offset(new RegExp(`([+-]${sg.source})(${ig.source})?`),2);case"z":return simple(/[a-z_+-/]{1,256}?/i);case" ":return simple(/[^\S\n\r]/);default:return cg(hg)}})(tg)||{invalidReason:MISSING_FTP};return dg.token=tg,dg}const partTypeStyleToTokenVal={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function tokenForPart(tg,eg,gg){const{type:ig,value:ng}=tg;if(ig==="literal"){const Ig=/^\s+$/.test(ng);return{literal:!Ig,val:Ig?" ":ng}}const og=eg[ig];let ag=ig;ig==="hour"&&(eg.hour12!=null?ag=eg.hour12?"hour12":"hour24":eg.hourCycle!=null?eg.hourCycle==="h11"||eg.hourCycle==="h12"?ag="hour12":ag="hour24":ag=gg.hour12?"hour12":"hour24");let sg=partTypeStyleToTokenVal[ag];if(typeof sg=="object"&&(sg=sg[og]),sg)return{literal:!1,val:sg}}function buildRegex(tg){return[`^${tg.map(gg=>gg.regex).reduce((gg,ig)=>`${gg}(${ig.source})`,"")}$`,tg]}function match(tg,eg,gg){const ig=tg.match(eg);if(ig){const ng={};let og=1;for(const ag in gg)if(hasOwnProperty(gg,ag)){const sg=gg[ag],Ig=sg.groups?sg.groups+1:1;!sg.literal&&sg.token&&(ng[sg.token.val[0]]=sg.deser(ig.slice(og,og+Ig))),og+=Ig}return[ig,ng]}else return[ig,{}]}function dateTimeFromMatches(tg){const eg=og=>{switch(og){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let gg=null,ig;return isUndefined$1(tg.z)||(gg=IANAZone.create(tg.z)),isUndefined$1(tg.Z)||(gg||(gg=new FixedOffsetZone(tg.Z)),ig=tg.Z),isUndefined$1(tg.q)||(tg.M=(tg.q-1)*3+1),isUndefined$1(tg.h)||(tg.h<12&&tg.a===1?tg.h+=12:tg.h===12&&tg.a===0&&(tg.h=0)),tg.G===0&&tg.y&&(tg.y=-tg.y),isUndefined$1(tg.u)||(tg.S=parseMillis(tg.u)),[Object.keys(tg).reduce((og,ag)=>{const sg=eg(ag);return sg&&(og[sg]=tg[ag]),og},{}),gg,ig]}let dummyDateTimeCache=null;function getDummyDateTime(){return dummyDateTimeCache||(dummyDateTimeCache=DateTime.fromMillis(1555555555555)),dummyDateTimeCache}function maybeExpandMacroToken(tg,eg){if(tg.literal)return tg;const gg=Formatter.macroTokenToFormatOpts(tg.val),ig=formatOptsToTokens(gg,eg);return ig==null||ig.includes(void 0)?tg:ig}function expandMacroTokens(tg,eg){return Array.prototype.concat(...tg.map(gg=>maybeExpandMacroToken(gg,eg)))}class TokenParser{constructor(eg,gg){if(this.locale=eg,this.format=gg,this.tokens=expandMacroTokens(Formatter.parseFormat(gg),eg),this.units=this.tokens.map(ig=>unitForToken(ig,eg)),this.disqualifyingUnit=this.units.find(ig=>ig.invalidReason),!this.disqualifyingUnit){const[ig,ng]=buildRegex(this.units);this.regex=RegExp(ig,"i"),this.handlers=ng}}explainFromTokens(eg){if(this.isValid){const[gg,ig]=match(eg,this.regex,this.handlers),[ng,og,ag]=ig?dateTimeFromMatches(ig):[null,null,void 0];if(hasOwnProperty(ig,"a")&&hasOwnProperty(ig,"H"))throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");return{input:eg,tokens:this.tokens,regex:this.regex,rawMatches:gg,matches:ig,result:ng,zone:og,specificOffset:ag}}else return{input:eg,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function explainFromTokens(tg,eg,gg){return new TokenParser(tg,gg).explainFromTokens(eg)}function parseFromTokens(tg,eg,gg){const{result:ig,zone:ng,specificOffset:og,invalidReason:ag}=explainFromTokens(tg,eg,gg);return[ig,ng,og,ag]}function formatOptsToTokens(tg,eg){if(!tg)return null;const ig=Formatter.create(eg,tg).dtFormatter(getDummyDateTime()),ng=ig.formatToParts(),og=ig.resolvedOptions();return ng.map(ag=>tokenForPart(ag,tg,og))}const INVALID="Invalid DateTime",MAX_DATE=864e13;function unsupportedZone(tg){return new Invalid("unsupported zone",`the zone "${tg.name}" is not supported`)}function possiblyCachedWeekData(tg){return tg.weekData===null&&(tg.weekData=gregorianToWeek(tg.c)),tg.weekData}function possiblyCachedLocalWeekData(tg){return tg.localWeekData===null&&(tg.localWeekData=gregorianToWeek(tg.c,tg.loc.getMinDaysInFirstWeek(),tg.loc.getStartOfWeek())),tg.localWeekData}function clone(tg,eg){const gg={ts:tg.ts,zone:tg.zone,c:tg.c,o:tg.o,loc:tg.loc,invalid:tg.invalid};return new DateTime({...gg,...eg,old:gg})}function fixOffset(tg,eg,gg){let ig=tg-eg*60*1e3;const ng=gg.offset(ig);if(eg===ng)return[ig,eg];ig-=(ng-eg)*60*1e3;const og=gg.offset(ig);return ng===og?[ig,ng]:[tg-Math.min(ng,og)*60*1e3,Math.max(ng,og)]}function tsToObj(tg,eg){tg+=eg*60*1e3;const gg=new Date(tg);return{year:gg.getUTCFullYear(),month:gg.getUTCMonth()+1,day:gg.getUTCDate(),hour:gg.getUTCHours(),minute:gg.getUTCMinutes(),second:gg.getUTCSeconds(),millisecond:gg.getUTCMilliseconds()}}function objToTS(tg,eg,gg){return fixOffset(objToLocalTS(tg),eg,gg)}function adjustTime(tg,eg){const gg=tg.o,ig=tg.c.year+Math.trunc(eg.years),ng=tg.c.month+Math.trunc(eg.months)+Math.trunc(eg.quarters)*3,og={...tg.c,year:ig,month:ng,day:Math.min(tg.c.day,daysInMonth(ig,ng))+Math.trunc(eg.days)+Math.trunc(eg.weeks)*7},ag=Duration.fromObject({years:eg.years-Math.trunc(eg.years),quarters:eg.quarters-Math.trunc(eg.quarters),months:eg.months-Math.trunc(eg.months),weeks:eg.weeks-Math.trunc(eg.weeks),days:eg.days-Math.trunc(eg.days),hours:eg.hours,minutes:eg.minutes,seconds:eg.seconds,milliseconds:eg.milliseconds}).as("milliseconds"),sg=objToLocalTS(og);let[Ig,Cg]=fixOffset(sg,gg,tg.zone);return ag!==0&&(Ig+=ag,Cg=tg.zone.offset(Ig)),{ts:Ig,o:Cg}}function parseDataToDateTime(tg,eg,gg,ig,ng,og){const{setZone:ag,zone:sg}=gg;if(tg&&Object.keys(tg).length!==0||eg){const Ig=eg||sg,Cg=DateTime.fromObject(tg,{...gg,zone:Ig,specificOffset:og});return ag?Cg:Cg.setZone(sg)}else return DateTime.invalid(new Invalid("unparsable",`the input "${ng}" can't be parsed as ${ig}`))}function toTechFormat(tg,eg,gg=!0){return tg.isValid?Formatter.create(Locale.create("en-US"),{allowZ:gg,forceSimple:!0}).formatDateTimeFromString(tg,eg):null}function toISODate(tg,eg,gg){const ig=tg.c.year>9999||tg.c.year<0;let ng="";if(ig&&tg.c.year>=0&&(ng+="+"),ng+=padStart(tg.c.year,ig?6:4),gg==="year")return ng;if(eg){if(ng+="-",ng+=padStart(tg.c.month),gg==="month")return ng;ng+="-"}else if(ng+=padStart(tg.c.month),gg==="month")return ng;return ng+=padStart(tg.c.day),ng}function toISOTime(tg,eg,gg,ig,ng,og,ag){let sg=!gg||tg.c.millisecond!==0||tg.c.second!==0,Ig="";switch(ag){case"day":case"month":case"year":break;default:if(Ig+=padStart(tg.c.hour),ag==="hour")break;if(eg){if(Ig+=":",Ig+=padStart(tg.c.minute),ag==="minute")break;sg&&(Ig+=":",Ig+=padStart(tg.c.second))}else{if(Ig+=padStart(tg.c.minute),ag==="minute")break;sg&&(Ig+=padStart(tg.c.second))}if(ag==="second")break;sg&&(!ig||tg.c.millisecond!==0)&&(Ig+=".",Ig+=padStart(tg.c.millisecond,3))}return ng&&(tg.isOffsetFixed&&tg.offset===0&&!og?Ig+="Z":tg.o<0?(Ig+="-",Ig+=padStart(Math.trunc(-tg.o/60)),Ig+=":",Ig+=padStart(Math.trunc(-tg.o%60))):(Ig+="+",Ig+=padStart(Math.trunc(tg.o/60)),Ig+=":",Ig+=padStart(Math.trunc(tg.o%60)))),og&&(Ig+="["+tg.zone.ianaName+"]"),Ig}const defaultUnitValues={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},defaultWeekUnitValues={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},defaultOrdinalUnitValues={ordinal:1,hour:0,minute:0,second:0,millisecond:0},orderedUnits=["year","month","day","hour","minute","second","millisecond"],orderedWeekUnits=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],orderedOrdinalUnits=["year","ordinal","hour","minute","second","millisecond"];function normalizeUnit(tg){const eg={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[tg.toLowerCase()];if(!eg)throw new InvalidUnitError(tg);return eg}function normalizeUnitWithLocalWeeks(tg){switch(tg.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return normalizeUnit(tg)}}function guessOffsetForZone(tg){if(zoneOffsetTs===void 0&&(zoneOffsetTs=Settings.now()),tg.type!=="iana")return tg.offset(zoneOffsetTs);const eg=tg.name;let gg=zoneOffsetGuessCache.get(eg);return gg===void 0&&(gg=tg.offset(zoneOffsetTs),zoneOffsetGuessCache.set(eg,gg)),gg}function quickDT(tg,eg){const gg=normalizeZone(eg.zone,Settings.defaultZone);if(!gg.isValid)return DateTime.invalid(unsupportedZone(gg));const ig=Locale.fromObject(eg);let ng,og;if(isUndefined$1(tg.year))ng=Settings.now();else{for(const Ig of orderedUnits)isUndefined$1(tg[Ig])&&(tg[Ig]=defaultUnitValues[Ig]);const ag=hasInvalidGregorianData(tg)||hasInvalidTimeData(tg);if(ag)return DateTime.invalid(ag);const sg=guessOffsetForZone(gg);[ng,og]=objToTS(tg,sg,gg)}return new DateTime({ts:ng,zone:gg,loc:ig,o:og})}function diffRelative(tg,eg,gg){const ig=isUndefined$1(gg.round)?!0:gg.round,ng=isUndefined$1(gg.rounding)?"trunc":gg.rounding,og=(sg,Ig)=>(sg=roundTo(sg,ig||gg.calendary?0:2,gg.calendary?"round":ng),eg.loc.clone(gg).relFormatter(gg).format(sg,Ig)),ag=sg=>gg.calendary?eg.hasSame(tg,sg)?0:eg.startOf(sg).diff(tg.startOf(sg),sg).get(sg):eg.diff(tg,sg).get(sg);if(gg.unit)return og(ag(gg.unit),gg.unit);for(const sg of gg.units){const Ig=ag(sg);if(Math.abs(Ig)>=1)return og(Ig,sg)}return og(tg>eg?-0:0,gg.units[gg.units.length-1])}function lastOpts(tg){let eg={},gg;return tg.length>0&&typeof tg[tg.length-1]=="object"?(eg=tg[tg.length-1],gg=Array.from(tg).slice(0,tg.length-1)):gg=Array.from(tg),[eg,gg]}let zoneOffsetTs;const zoneOffsetGuessCache=new Map;class DateTime{constructor(eg){const gg=eg.zone||Settings.defaultZone;let ig=eg.invalid||(Number.isNaN(eg.ts)?new Invalid("invalid input"):null)||(gg.isValid?null:unsupportedZone(gg));this.ts=isUndefined$1(eg.ts)?Settings.now():eg.ts;let ng=null,og=null;if(!ig)if(eg.old&&eg.old.ts===this.ts&&eg.old.zone.equals(gg))[ng,og]=[eg.old.c,eg.old.o];else{const sg=isNumber$1(eg.o)&&!eg.old?eg.o:gg.offset(this.ts);ng=tsToObj(this.ts,sg),ig=Number.isNaN(ng.year)?new Invalid("invalid input"):null,ng=ig?null:ng,og=ig?null:sg}this._zone=gg,this.loc=eg.loc||Locale.create(),this.invalid=ig,this.weekData=null,this.localWeekData=null,this.c=ng,this.o=og,this.isLuxonDateTime=!0}static now(){return new DateTime({})}static local(){const[eg,gg]=lastOpts(arguments),[ig,ng,og,ag,sg,Ig,Cg]=gg;return quickDT({year:ig,month:ng,day:og,hour:ag,minute:sg,second:Ig,millisecond:Cg},eg)}static utc(){const[eg,gg]=lastOpts(arguments),[ig,ng,og,ag,sg,Ig,Cg]=gg;return eg.zone=FixedOffsetZone.utcInstance,quickDT({year:ig,month:ng,day:og,hour:ag,minute:sg,second:Ig,millisecond:Cg},eg)}static fromJSDate(eg,gg={}){const ig=isDate$1(eg)?eg.valueOf():NaN;if(Number.isNaN(ig))return DateTime.invalid("invalid input");const ng=normalizeZone(gg.zone,Settings.defaultZone);return ng.isValid?new DateTime({ts:ig,zone:ng,loc:Locale.fromObject(gg)}):DateTime.invalid(unsupportedZone(ng))}static fromMillis(eg,gg={}){if(isNumber$1(eg))return eg<-MAX_DATE||eg>MAX_DATE?DateTime.invalid("Timestamp out of range"):new DateTime({ts:eg,zone:normalizeZone(gg.zone,Settings.defaultZone),loc:Locale.fromObject(gg)});throw new InvalidArgumentError(`fromMillis requires a numerical input, but received a ${typeof eg} with value ${eg}`)}static fromSeconds(eg,gg={}){if(isNumber$1(eg))return new DateTime({ts:eg*1e3,zone:normalizeZone(gg.zone,Settings.defaultZone),loc:Locale.fromObject(gg)});throw new InvalidArgumentError("fromSeconds requires a numerical input")}static fromObject(eg,gg={}){eg=eg||{};const ig=normalizeZone(gg.zone,Settings.defaultZone);if(!ig.isValid)return DateTime.invalid(unsupportedZone(ig));const ng=Locale.fromObject(gg),og=normalizeObject(eg,normalizeUnitWithLocalWeeks),{minDaysInFirstWeek:ag,startOfWeek:sg}=usesLocalWeekValues(og,ng),Ig=Settings.now(),Cg=isUndefined$1(gg.specificOffset)?ig.offset(Ig):gg.specificOffset,lg=!isUndefined$1(og.ordinal),Ag=!isUndefined$1(og.year),rg=!isUndefined$1(og.month)||!isUndefined$1(og.day),cg=Ag||rg,ug=og.weekYear||og.weekNumber;if((cg||lg)&&ug)throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(rg&&lg)throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");const dg=ug||og.weekday&&!cg;let hg,mg,bg=tsToObj(Ig,Cg);dg?(hg=orderedWeekUnits,mg=defaultWeekUnitValues,bg=gregorianToWeek(bg,ag,sg)):lg?(hg=orderedOrdinalUnits,mg=defaultOrdinalUnitValues,bg=gregorianToOrdinal(bg)):(hg=orderedUnits,mg=defaultUnitValues);let pg=!1;for(const Wg of hg){const yg=og[Wg];isUndefined$1(yg)?pg?og[Wg]=mg[Wg]:og[Wg]=bg[Wg]:pg=!0}const fg=dg?hasInvalidWeekData(og,ag,sg):lg?hasInvalidOrdinalData(og):hasInvalidGregorianData(og),wg=fg||hasInvalidTimeData(og);if(wg)return DateTime.invalid(wg);const Gg=dg?weekToGregorian(og,ag,sg):lg?ordinalToGregorian(og):og,[Zg,$g]=objToTS(Gg,Cg,ig),Bg=new DateTime({ts:Zg,zone:ig,o:$g,loc:ng});return og.weekday&&cg&&eg.weekday!==Bg.weekday?DateTime.invalid("mismatched weekday",`you can't specify both a weekday of ${og.weekday} and a date of ${Bg.toISO()}`):Bg.isValid?Bg:DateTime.invalid(Bg.invalid)}static fromISO(eg,gg={}){const[ig,ng]=parseISODate(eg);return parseDataToDateTime(ig,ng,gg,"ISO 8601",eg)}static fromRFC2822(eg,gg={}){const[ig,ng]=parseRFC2822Date(eg);return parseDataToDateTime(ig,ng,gg,"RFC 2822",eg)}static fromHTTP(eg,gg={}){const[ig,ng]=parseHTTPDate(eg);return parseDataToDateTime(ig,ng,gg,"HTTP",gg)}static fromFormat(eg,gg,ig={}){if(isUndefined$1(eg)||isUndefined$1(gg))throw new InvalidArgumentError("fromFormat requires an input string and a format");const{locale:ng=null,numberingSystem:og=null}=ig,ag=Locale.fromOpts({locale:ng,numberingSystem:og,defaultToEN:!0}),[sg,Ig,Cg,lg]=parseFromTokens(ag,eg,gg);return lg?DateTime.invalid(lg):parseDataToDateTime(sg,Ig,ig,`format ${gg}`,eg,Cg)}static fromString(eg,gg,ig={}){return DateTime.fromFormat(eg,gg,ig)}static fromSQL(eg,gg={}){const[ig,ng]=parseSQL(eg);return parseDataToDateTime(ig,ng,gg,"SQL",eg)}static invalid(eg,gg=null){if(!eg)throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");const ig=eg instanceof Invalid?eg:new Invalid(eg,gg);if(Settings.throwOnInvalid)throw new InvalidDateTimeError(ig);return new DateTime({invalid:ig})}static isDateTime(eg){return eg&&eg.isLuxonDateTime||!1}static parseFormatForOpts(eg,gg={}){const ig=formatOptsToTokens(eg,Locale.fromObject(gg));return ig?ig.map(ng=>ng?ng.val:null).join(""):null}static expandFormat(eg,gg={}){return expandMacroTokens(Formatter.parseFormat(eg),Locale.fromObject(gg)).map(ng=>ng.val).join("")}static resetCache(){zoneOffsetTs=void 0,zoneOffsetGuessCache.clear()}get(eg){return this[eg]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?possiblyCachedWeekData(this).weekYear:NaN}get weekNumber(){return this.isValid?possiblyCachedWeekData(this).weekNumber:NaN}get weekday(){return this.isValid?possiblyCachedWeekData(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?possiblyCachedLocalWeekData(this).weekday:NaN}get localWeekNumber(){return this.isValid?possiblyCachedLocalWeekData(this).weekNumber:NaN}get localWeekYear(){return this.isValid?possiblyCachedLocalWeekData(this).weekYear:NaN}get ordinal(){return this.isValid?gregorianToOrdinal(this.c).ordinal:NaN}get monthShort(){return this.isValid?Info.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Info.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Info.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Info.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const eg=864e5,gg=6e4,ig=objToLocalTS(this.c),ng=this.zone.offset(ig-eg),og=this.zone.offset(ig+eg),ag=this.zone.offset(ig-ng*gg),sg=this.zone.offset(ig-og*gg);if(ag===sg)return[this];const Ig=ig-ag*gg,Cg=ig-sg*gg,lg=tsToObj(Ig,ag),Ag=tsToObj(Cg,sg);return lg.hour===Ag.hour&&lg.minute===Ag.minute&&lg.second===Ag.second&&lg.millisecond===Ag.millisecond?[clone(this,{ts:Ig}),clone(this,{ts:Cg})]:[this]}get isInLeapYear(){return isLeapYear(this.year)}get daysInMonth(){return daysInMonth(this.year,this.month)}get daysInYear(){return this.isValid?daysInYear(this.year):NaN}get weeksInWeekYear(){return this.isValid?weeksInWeekYear(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?weeksInWeekYear(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(eg={}){const{locale:gg,numberingSystem:ig,calendar:ng}=Formatter.create(this.loc.clone(eg),eg).resolvedOptions(this);return{locale:gg,numberingSystem:ig,outputCalendar:ng}}toUTC(eg=0,gg={}){return this.setZone(FixedOffsetZone.instance(eg),gg)}toLocal(){return this.setZone(Settings.defaultZone)}setZone(eg,{keepLocalTime:gg=!1,keepCalendarTime:ig=!1}={}){if(eg=normalizeZone(eg,Settings.defaultZone),eg.equals(this.zone))return this;if(eg.isValid){let ng=this.ts;if(gg||ig){const og=eg.offset(this.ts),ag=this.toObject();[ng]=objToTS(ag,og,eg)}return clone(this,{ts:ng,zone:eg})}else return DateTime.invalid(unsupportedZone(eg))}reconfigure({locale:eg,numberingSystem:gg,outputCalendar:ig}={}){const ng=this.loc.clone({locale:eg,numberingSystem:gg,outputCalendar:ig});return clone(this,{loc:ng})}setLocale(eg){return this.reconfigure({locale:eg})}set(eg){if(!this.isValid)return this;const gg=normalizeObject(eg,normalizeUnitWithLocalWeeks),{minDaysInFirstWeek:ig,startOfWeek:ng}=usesLocalWeekValues(gg,this.loc),og=!isUndefined$1(gg.weekYear)||!isUndefined$1(gg.weekNumber)||!isUndefined$1(gg.weekday),ag=!isUndefined$1(gg.ordinal),sg=!isUndefined$1(gg.year),Ig=!isUndefined$1(gg.month)||!isUndefined$1(gg.day),Cg=sg||Ig,lg=gg.weekYear||gg.weekNumber;if((Cg||ag)&&lg)throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(Ig&&ag)throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");let Ag;og?Ag=weekToGregorian({...gregorianToWeek(this.c,ig,ng),...gg},ig,ng):isUndefined$1(gg.ordinal)?(Ag={...this.toObject(),...gg},isUndefined$1(gg.day)&&(Ag.day=Math.min(daysInMonth(Ag.year,Ag.month),Ag.day))):Ag=ordinalToGregorian({...gregorianToOrdinal(this.c),...gg});const[rg,cg]=objToTS(Ag,this.o,this.zone);return clone(this,{ts:rg,o:cg})}plus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg);return clone(this,adjustTime(this,gg))}minus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg).negate();return clone(this,adjustTime(this,gg))}startOf(eg,{useLocaleWeeks:gg=!1}={}){if(!this.isValid)return this;const ig={},ng=Duration.normalizeUnit(eg);switch(ng){case"years":ig.month=1;case"quarters":case"months":ig.day=1;case"weeks":case"days":ig.hour=0;case"hours":ig.minute=0;case"minutes":ig.second=0;case"seconds":ig.millisecond=0;break}if(ng==="weeks")if(gg){const og=this.loc.getStartOfWeek(),{weekday:ag}=this;ag<og&&(ig.weekNumber=this.weekNumber-1),ig.weekday=og}else ig.weekday=1;if(ng==="quarters"){const og=Math.ceil(this.month/3);ig.month=(og-1)*3+1}return this.set(ig)}endOf(eg,gg){return this.isValid?this.plus({[eg]:1}).startOf(eg,gg).minus(1):this}toFormat(eg,gg={}){return this.isValid?Formatter.create(this.loc.redefaultToEN(gg)).formatDateTimeFromString(this,eg):INVALID}toLocaleString(eg=DATE_SHORT,gg={}){return this.isValid?Formatter.create(this.loc.clone(gg),eg).formatDateTime(this):INVALID}toLocaleParts(eg={}){return this.isValid?Formatter.create(this.loc.clone(eg),eg).formatDateTimeParts(this):[]}toISO({format:eg="extended",suppressSeconds:gg=!1,suppressMilliseconds:ig=!1,includeOffset:ng=!0,extendedZone:og=!1,precision:ag="milliseconds"}={}){if(!this.isValid)return null;ag=normalizeUnit(ag);const sg=eg==="extended";let Ig=toISODate(this,sg,ag);return orderedUnits.indexOf(ag)>=3&&(Ig+="T"),Ig+=toISOTime(this,sg,gg,ig,ng,og,ag),Ig}toISODate({format:eg="extended",precision:gg="day"}={}){return this.isValid?toISODate(this,eg==="extended",normalizeUnit(gg)):null}toISOWeekDate(){return toTechFormat(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:eg=!1,suppressSeconds:gg=!1,includeOffset:ig=!0,includePrefix:ng=!1,extendedZone:og=!1,format:ag="extended",precision:sg="milliseconds"}={}){return this.isValid?(sg=normalizeUnit(sg),(ng&&orderedUnits.indexOf(sg)>=3?"T":"")+toISOTime(this,ag==="extended",gg,eg,ig,og,sg)):null}toRFC2822(){return toTechFormat(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return toTechFormat(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?toISODate(this,!0):null}toSQLTime({includeOffset:eg=!0,includeZone:gg=!1,includeOffsetSpace:ig=!0}={}){let ng="HH:mm:ss.SSS";return(gg||eg)&&(ig&&(ng+=" "),gg?ng+="z":eg&&(ng+="ZZ")),toTechFormat(this,ng,!0)}toSQL(eg={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(eg)}`:null}toString(){return this.isValid?this.toISO():INVALID}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(eg={}){if(!this.isValid)return{};const gg={...this.c};return eg.includeConfig&&(gg.outputCalendar=this.outputCalendar,gg.numberingSystem=this.loc.numberingSystem,gg.locale=this.loc.locale),gg}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(eg,gg="milliseconds",ig={}){if(!this.isValid||!eg.isValid)return Duration.invalid("created by diffing an invalid DateTime");const ng={locale:this.locale,numberingSystem:this.numberingSystem,...ig},og=maybeArray(gg).map(Duration.normalizeUnit),ag=eg.valueOf()>this.valueOf(),sg=ag?this:eg,Ig=ag?eg:this,Cg=diff(sg,Ig,og,ng);return ag?Cg.negate():Cg}diffNow(eg="milliseconds",gg={}){return this.diff(DateTime.now(),eg,gg)}until(eg){return this.isValid?Interval.fromDateTimes(this,eg):this}hasSame(eg,gg,ig){if(!this.isValid)return!1;const ng=eg.valueOf(),og=this.setZone(eg.zone,{keepLocalTime:!0});return og.startOf(gg,ig)<=ng&&ng<=og.endOf(gg,ig)}equals(eg){return this.isValid&&eg.isValid&&this.valueOf()===eg.valueOf()&&this.zone.equals(eg.zone)&&this.loc.equals(eg.loc)}toRelative(eg={}){if(!this.isValid)return null;const gg=eg.base||DateTime.fromObject({},{zone:this.zone}),ig=eg.padding?this<gg?-eg.padding:eg.padding:0;let ng=["years","months","days","hours","minutes","seconds"],og=eg.unit;return Array.isArray(eg.unit)&&(ng=eg.unit,og=void 0),diffRelative(gg,this.plus(ig),{...eg,numeric:"always",units:ng,unit:og})}toRelativeCalendar(eg={}){return this.isValid?diffRelative(eg.base||DateTime.fromObject({},{zone:this.zone}),this,{...eg,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...eg){if(!eg.every(DateTime.isDateTime))throw new InvalidArgumentError("min requires all arguments be DateTimes");return bestBy(eg,gg=>gg.valueOf(),Math.min)}static max(...eg){if(!eg.every(DateTime.isDateTime))throw new InvalidArgumentError("max requires all arguments be DateTimes");return bestBy(eg,gg=>gg.valueOf(),Math.max)}static fromFormatExplain(eg,gg,ig={}){const{locale:ng=null,numberingSystem:og=null}=ig,ag=Locale.fromOpts({locale:ng,numberingSystem:og,defaultToEN:!0});return explainFromTokens(ag,eg,gg)}static fromStringExplain(eg,gg,ig={}){return DateTime.fromFormatExplain(eg,gg,ig)}static buildFormatParser(eg,gg={}){const{locale:ig=null,numberingSystem:ng=null}=gg,og=Locale.fromOpts({locale:ig,numberingSystem:ng,defaultToEN:!0});return new TokenParser(og,eg)}static fromFormatParser(eg,gg,ig={}){if(isUndefined$1(eg)||isUndefined$1(gg))throw new InvalidArgumentError("fromFormatParser requires an input string and a format parser");const{locale:ng=null,numberingSystem:og=null}=ig,ag=Locale.fromOpts({locale:ng,numberingSystem:og,defaultToEN:!0});if(!ag.equals(gg.locale))throw new InvalidArgumentError(`fromFormatParser called with a locale of ${ag}, but the format parser was created for ${gg.locale}`);const{result:sg,zone:Ig,specificOffset:Cg,invalidReason:lg}=gg.explainFromTokens(eg);return lg?DateTime.invalid(lg):parseDataToDateTime(sg,Ig,ig,`format ${gg.format}`,eg,Cg)}static get DATE_SHORT(){return DATE_SHORT}static get DATE_MED(){return DATE_MED}static get DATE_MED_WITH_WEEKDAY(){return DATE_MED_WITH_WEEKDAY}static get DATE_FULL(){return DATE_FULL}static get DATE_HUGE(){return DATE_HUGE}static get TIME_SIMPLE(){return TIME_SIMPLE}static get TIME_WITH_SECONDS(){return TIME_WITH_SECONDS}static get TIME_WITH_SHORT_OFFSET(){return TIME_WITH_SHORT_OFFSET}static get TIME_WITH_LONG_OFFSET(){return TIME_WITH_LONG_OFFSET}static get TIME_24_SIMPLE(){return TIME_24_SIMPLE}static get TIME_24_WITH_SECONDS(){return TIME_24_WITH_SECONDS}static get TIME_24_WITH_SHORT_OFFSET(){return TIME_24_WITH_SHORT_OFFSET}static get TIME_24_WITH_LONG_OFFSET(){return TIME_24_WITH_LONG_OFFSET}static get DATETIME_SHORT(){return DATETIME_SHORT}static get DATETIME_SHORT_WITH_SECONDS(){return DATETIME_SHORT_WITH_SECONDS}static get DATETIME_MED(){return DATETIME_MED}static get DATETIME_MED_WITH_SECONDS(){return DATETIME_MED_WITH_SECONDS}static get DATETIME_MED_WITH_WEEKDAY(){return DATETIME_MED_WITH_WEEKDAY}static get DATETIME_FULL(){return DATETIME_FULL}static get DATETIME_FULL_WITH_SECONDS(){return DATETIME_FULL_WITH_SECONDS}static get DATETIME_HUGE(){return DATETIME_HUGE}static get DATETIME_HUGE_WITH_SECONDS(){return DATETIME_HUGE_WITH_SECONDS}}function friendlyDateTime(tg){if(DateTime.isDateTime(tg))return tg;if(tg&&tg.valueOf&&isNumber$1(tg.valueOf()))return DateTime.fromJSDate(tg);if(tg&&typeof tg=="object")return DateTime.fromObject(tg);throw new InvalidArgumentError(`Unknown datetime argument: ${tg}, of type ${typeof tg}`)}const WEEK_ZH=["一","二","三","四","五","六","日"],MONTH_ZH_NUM=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],MONTH_ZH_CN=["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];function formatDate(tg,{years:eg=0,months:gg=0,days:ig=0}={}){const ng=DateTime.now().plus({years:eg,months:gg,days:ig}).setLocale("zh-CN");let og=formatWithZhMonth(ng,tg),ag=ng.toFormat(og);return ag=formatWithZhWeekday(ng,ag),ag}function formatWithZhWeekday(tg,eg){const gg=WEEK_ZH[tg.weekday-1];return eg.replace(/dddd/g,`星期${gg}`).replace(/ddd/g,`周${gg}`)}function formatWithZhMonth(tg,eg){const gg=tg.month-1;return eg.replace(/MMMM/g,MONTH_ZH_CN[gg]).replace(/MMM/g,MONTH_ZH_NUM[gg])}function throttle$1(tg,eg=300){let gg=0;return function(...ig){const ng=Date.now();ng-gg>=eg&&(tg.apply(this,ig),gg=ng)}}function ptToPx$1(tg,eg=o.DPI){return tg*eg/72}function mitt(tg){return{all:tg=tg||new Map,on:function(eg,gg){var ig=tg.get(eg);ig?ig.push(gg):tg.set(eg,[gg])},off:function(eg,gg){var ig=tg.get(eg);ig&&(gg?ig.splice(ig.indexOf(gg)>>>0,1):tg.set(eg,[]))},emit:function(eg,gg){var ig=tg.get(eg);ig&&ig.slice().map(function(ng){ng(gg)}),(ig=tg.get("*"))&&ig.slice().map(function(ng){ng(eg,gg)})}}}const canvasEventBus=mitt();let allObjMap=new Proxy({},{get(tg,eg){return eg in tg?tg[eg]:[]},set(tg,eg,gg){return tg[eg]=gg,!0}});function clearObjectMap(){allObjMap=new Proxy({},{get(tg,eg){return eg in tg?tg[eg]:[]},set(tg,eg,gg){return tg[eg]=gg,!0}})}function updateObjectMap(tg){tg.type!=="group"&&tg.id!=="workspace"?!allObjMap[tg.type]||allObjMap[tg.type]&&allObjMap[tg.type].length===0?allObjMap[tg.type]=[tg]:allObjMap[tg.type].push(tg):tg._objects.forEach(eg=>updateObjectMap(eg))}function getAllObjectMap(tg=null,eg="get"){if(eg==="get"&&Object.keys(allObjMap).length)return allObjMap;{if(!tg)return allObjMap;clearObjectMap();const gg=ig=>{ig.type==="group"&&ig._objects?ig._objects.forEach(ng=>gg(ng)):ig.id!=="workspace"&&(!allObjMap[ig.type]||allObjMap[ig.type]&&allObjMap[ig.type].length===0?allObjMap[ig.type]=[ig]:allObjMap[ig.type].push(ig))};tg==null||tg.getObjects().forEach(ig=>gg(ig))}return allObjMap}function getObjectList(tg,eg){tg.type!=="group"&&tg.type!=="activeselection"?eg&&eg(tg):tg._objects.forEach(gg=>getObjectList(gg,eg))}function getCounterIncrement(tg){const eg=Number(tg.incremental);return Number.isFinite(eg)?Math.trunc(eg):0}function getCounterValueType(tg){return tg.valueType==="letter"?"letter":"number"}function normalizeLetterValue(tg){return String(tg??"").toUpperCase().replace(/[^A-Z]/g,"")||"A"}function letterValueToNumber(tg){return normalizeLetterValue(tg).split("").reduce((eg,gg)=>eg*26+gg.charCodeAt(0)-64,0)}function numberToLetterValue(tg){let eg=Math.max(1,Math.trunc(tg)),gg="";for(;eg>0;)eg--,gg=String.fromCharCode(65+eg%26)+gg,eg=Math.floor(eg/26);return gg}function formatCounterValue(tg){if(getCounterValueType(tg)==="letter"){const ig=normalizeLetterValue(tg.value);return tg.zeroPadding?ig.padStart(Math.max(0,tg.length),"0"):ig}let eg=String(tg.value??"");if(!tg.zeroPadding)return eg;let gg=Number(eg);return gg<0?(gg=Math.abs(gg),`-${gg.toString().padStart(tg.length,"0")}`):eg.padStart(tg.length,"0")}function getNextCounterValue(tg){const eg=getCounterIncrement(tg);if(getCounterValueType(tg)==="letter"){const ng=letterValueToNumber(normalizeLetterValue(tg.value))+eg;if(ng<1)return null;const og=numberToLetterValue(ng);return og.length<=tg.length?og:null}const gg=Number(tg.value);if(!Number.isFinite(gg))return null;const ig=gg+eg;return Math.abs(ig).toString().length<=tg.length?ig:null}const GS1_AI_TABLE={"00":{length:18,desc:"SSCC"},"01":{length:14,desc:"GTIN"},"02":{length:14,desc:"GTIN inside"},11:{length:6,desc:"生产日期"},12:{length:6,desc:"付款截止日"},13:{length:6,desc:"包装日期"},15:{length:6,desc:"最佳保质期"},16:{length:6,desc:"销售截止日"},17:{length:6,desc:"有效期"},18:{length:6,desc:"接收日期"},20:{length:2,desc:"产品变体"},410:{length:13,desc:"收货方GLN"},411:{length:13,desc:"付款方GLN"},412:{length:13,desc:"购方GLN"},413:{length:13,desc:"发货方GLN"},414:{length:13,desc:"交货方GLN"},415:{length:13,desc:"开票方GLN"},416:{length:13,desc:"生产/服务方GLN"},417:{length:13,desc:"参与方GLN"},7001:{length:13,desc:"NHS编号"},10:{variable:!0,max:20,desc:"批号"},21:{variable:!0,max:20,desc:"序列号"},22:{variable:!0,max:20,desc:"次级数据"},30:{variable:!0,max:8,desc:"数量(件)"},37:{variable:!0,max:8,desc:"物流单元数量"},400:{variable:!0,max:30,desc:"客户订单号"},401:{variable:!0,max:30,desc:"货物标识号"},402:{variable:!0,max:20,desc:"GSIN"},403:{variable:!0,max:30,desc:"路线代码"},420:{variable:!0,max:20,desc:"收货方邮编"},421:{variable:!0,max:20,desc:"收货方邮编(含ISO)"},7002:{variable:!0,max:30,desc:"CE标识"},7010:{variable:!0,max:30,desc:"医院编号"},8001:{variable:!0,max:14,desc:"卷材信息"},8002:{variable:!0,max:20,desc:"手机电子序列号"},8003:{variable:!0,max:30,desc:"全球可回收资产标识"},8004:{variable:!0,max:30,desc:"全球单个资产标识"},8005:{variable:!0,max:6,desc:"价格"},8006:{variable:!0,max:18,desc:"组件标识"},8007:{variable:!0,max:34,desc:"IBAN"},8008:{variable:!0,max:12,desc:"生产日期时间"},8010:{variable:!0,max:30,desc:"CPID"},8011:{variable:!0,max:30,desc:"CPID序列号"},8012:{variable:!0,max:20,desc:"软件版本"},8013:{variable:!0,max:30,desc:"型号"},8017:{variable:!0,max:18,desc:"GSRN"},8018:{variable:!0,max:18,desc:"GSRN-Provider"},8020:{variable:!0,max:25,desc:"支付单号"},8110:{variable:!0,max:70,desc:"优惠券扩展"},8200:{variable:!0,max:25,desc:"包裹编号"},90:{variable:!0,max:30,desc:"双方约定"},91:{variable:!0,max:90,desc:"双方约定"},92:{variable:!0,max:90,desc:"双方约定"},93:{variable:!0,max:90,desc:"双方约定"},94:{variable:!0,max:90,desc:"双方约定"},95:{variable:!0,max:90,desc:"双方约定"},96:{variable:!0,max:90,desc:"双方约定"},97:{variable:!0,max:90,desc:"双方约定"},98:{variable:!0,max:90,desc:"双方约定"},99:{variable:!0,max:90,desc:"双方约定"}};for(let tg=310;tg<=369;tg++)GS1_AI_TABLE[String(tg)]={length:6,desc:"量度值"};class GS1Parser{static getAIInfo(eg){return GS1_AI_TABLE[eg]||null}static matchAIPrefix(eg,gg){for(const ig of[4,3,2]){if(gg+ig>eg.length)continue;const ng=eg.slice(gg,gg+ig);if(GS1_AI_TABLE[ng])return{ai:ng,info:GS1_AI_TABLE[ng]}}return null}static parse(eg){const gg=/\((\d{2,4})\)/g;let ig;const ng=[];for(;(ig=gg.exec(eg))!==null;){if(ng.length>0){const og=ng[ng.length-1];og.data=eg.slice(og.dataStart,ig.index)}ng.push({ai:ig[1],dataStart:ig.index+ig[0].length})}return ng.length>0&&(ng[ng.length-1].data=eg.slice(ng[ng.length-1].dataStart)),ng.map(og=>({ai:og.ai,data:og.data??""}))}static calcCheckDigit(eg){const gg=String(eg).split("").map(Number);let ig=0;for(let ng=0;ng<gg.length;ng++){const og=(gg.length-ng)%2===1?3:1;ig+=gg[ng]*og}return(10-ig%10)%10}static normalizeGTIN(eg){let gg=String(eg).replace(/\D/g,"");if(gg.length===14)return gg;gg=gg.padStart(13,"0");const ig=this.calcCheckDigit(gg);return gg+ig}static format(eg){return Array.isArray(eg)?eg.map(({ai:gg,data:ig})=>`(${gg})${ig}`).join(""):eg}static process(eg){const gg=this.parse(eg);if(gg.length===0)throw new Error("GS1-128 data must include an Application Identifier, e.g. (01)...");return gg.map(({ai:ig,data:ng})=>{if(this.getAIInfo(ig),ig==="01"||ig==="02")return{ai:ig,data:this.normalizeGTIN(ng)};if(ig==="00"){const og=String(ng).padStart(17,"0"),ag=this.calcCheckDigit(og);return{ai:ig,data:og+ag}}if(ig>="410"&&ig<="417"){const og=String(ng).padStart(12,"0"),ag=this.calcCheckDigit(og);return{ai:ig,data:og+ag}}return{ai:ig,data:ng}})}}function withObjectStrokeDash(tg,eg,gg){const ig=tg.getLineDash(),ng=tg.lineDashOffset,og=eg.strokeDashArray;tg.setLineDash(Array.isArray(og)&&og.length?og:[]),tg.lineDashOffset=eg.strokeDashOffset||0;try{gg()}finally{tg.setLineDash(ig),tg.lineDashOffset=ng}}function getBarcodeRenderWidth(tg,eg){if(eg>tg)return eg;const gg=Math.round(tg/eg)||1;return eg*gg}const iC=class iC extends ji{constructor(eg,gg){super(gg),this.hasFireChange=!1,this.minScaleLimit=.1,this.orginTextWidth=0,this.orginTextgaps=2,this.orginTextSize=0,this.orginTextHeight=0,this.lockScalingFlip=!0,this.objectCaching=!1,this._scaleAnchor=void 0,this.counterProps=null,this.reviewValueArgs=null,this.barcodeDateFormatType="",this.increaseDate=!1,this.concatTextIdListObj=null,this.connectObjIds=[],this.stretchMode="scale",this.barcodeTextHeight=0,this.barcodeTextGap=5,this._textLayoutInitialized=!1,this._lastTextAreaHeight=0,this._cache={canvas:void 0,error:void 0,update:!0},this.increaseDate=gg&&gg.increaseDate?gg.increaseDate:this.increaseDate,this.barcodeDateFormatType=gg&&gg.barcodeDateFormatType?gg.barcodeDateFormatType:this.barcodeDateFormatType,this.counterProps=gg&&gg.counterProps?gg.counterProps:this.counterProps,this.stretchMode=gg&&gg.stretchMode?gg.stretchMode:this.stretchMode,this.barcodeTextGap=gg&&gg.barcodeTextGap!=null?gg.barcodeTextGap:this.barcodeTextGap,this.barcodeOptions=cloneDeep(eg),this.barcodeOptions.textsize=eg.textsize||14,this.barcodeOptions.textposition=eg.includetext?eg.textposition||"bottom":void 0,this.barcodeOptions.textfontname=eg.textfontname||"Arial",this.set({width:this.width||1,height:this.height||80}),this.barcodeBaseWidth=this.width,this.on("scaling",ig=>{const ng=ig.transform;if(!ng)return;const og=ng.corner,ag=["ml","tl","bl"].includes(og),sg=["mr","tr","br"].includes(og),Ig=["mt","tl","tr"].includes(og),Cg=["mb","bl","br"].includes(og);if(!this._scaleAnchor){const dg=ag?"right":sg?"left":"center",hg=Ig?"bottom":Cg?"top":"center",mg=this.getPointByOrigin(dg,hg);this._scaleAnchor={p:mg,ox:dg,oy:hg}}const lg=Math.max(1,this.width*this.scaleX),Ag=Math.max(1,this.height*this.scaleY);this.width=lg,this.height=Ag,this.scaleX=1,this.scaleY=1,this.barcodeBaseWidth=this.width;const{p:rg,ox:cg,oy:ug}=this._scaleAnchor;if(this.group){const dg=kn.invertTransform(this.group.calcTransformMatrix()),hg=kn.transformPoint(rg,dg);this.setPositionByOrigin(hg,cg,ug)}else this.setPositionByOrigin(rg,cg,ug);this.setCoords()}),this.on("modified",()=>{this._scaleAnchor=void 0}),this.concatTextIdListObj=gg.concatTextIdListObj??this.concatTextIdListObj,this.connectObjIds=gg.connectObjIds??this.connectObjIds,canvasEventBus.off(`update:barcode:${this.id}`),canvasEventBus.on(`update:barcode:${this.id}`,async({list:ig,callback:ng=function(){}}={})=>{let og=await this.updateBarCode2d(ig);ng&&ng(og)})}cropBuiltInText(eg,gg){const ig=eg.getContext("2d");if(!ig)return;const ng=gg.height?Number(gg.height)/25.4:1,og=Number(gg.scale)||2,ag=Math.min(Math.round(ng*72*og)+1,eg.height-1);ag>=eg.height||ig.clearRect(0,ag,eg.width,eg.height-ag)}measureText(eg,gg,ig){if(gg.textposition&&gg.textposition!=="none"&&gg.textsize){eg.font=`${gg.textsize}px ${gg.textfontname}`,gg.textgaps&&(eg.letterSpacing=gg.textgaps+"px");const ng=eg.measureText(gg.text);ig.textWidth=ng.actualBoundingBoxRight-ng.actualBoundingBoxLeft,ig.textHeight=ng.fontBoundingBoxAscent+ng.fontBoundingBoxDescent}}drawText(eg,gg,ig){if(gg.textposition&&gg.textposition!=="none"&&gg.textsize){gg.textcolor&&(eg.fillStyle=gg.textcolor);const ng=(Ig,Cg)=>{let lg=(Ig==null?void 0:Ig.textWidth)||0;return Cg.textxalign==="left"?-this.width/2+this.strokeWidth/2:Cg.textxalign==="center"?-lg/2:Cg.textxalign==="right"&&this._cache.canvas?this.width/2-this.strokeWidth/2-lg:0},og=(Ig,Cg)=>{let lg=(Ig==null?void 0:Ig.textHeight)||0;if(Cg.textposition==="top"){if(this._cache.canvas){const Ag=-this.height/2+lg+this.strokeWidth/2;return Ig.y+=Ig.textHeight,Ag}}else if(Cg.textposition==="bottom"&&this._cache.canvas)return this.height/2-this.strokeWidth/2;return 0},ag=ng(ig,gg),sg=og(ig,gg);eg.save(),eg.fillText(gg.text,ag*this.scaleX,sg*this.scaleY),eg.restore()}}countDate(){if(this.barcodeDateFormatType&&this.increaseDate){const eg=formatDate(this.barcodeDateFormatType);return console.log("formatted",eg),this.dirty=!0,this.setBarcodeOption({bcid:this.barcodeOptions.bcid,text:eg}),eg}}countCurrent(eg){let gg=this.counterProps||eg;if(gg){let ig=gg;if(!ig.value&&ig.value!==0)return"";const ng=formatCounterValue(ig);return(ig.prefix&&ig.prefix.length>0?ig.prefix:"")+ng+(ig.suffix&&ig.suffix.length>0?ig.suffix:"")}return""}countNext(eg="print"){if(this.counterProps){let gg=this.counterProps;if(!gg.value&&gg.value!==0)return;eg==="review"&&!this.reviewValueArgs&&(this.reviewValueArgs={...gg});const ig=formatCounterValue(gg);let ng=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:"");const og=getNextCounterValue(gg);return og!==null&&(gg.value=og,this.counterProps.value=og),this.dirty=!0,this._cache.update=!0,ng}else return""}reviewRecover(){if(this.reviewValueArgs){const eg=this.reviewValueArgs;this.counterProps=eg,this.reviewValueArgs=null;const gg=formatCounterValue(eg);let ig=(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:"");this.setBarcodeOption({bcid:this.barcodeOptions.bcid,text:ig})}}calculateCheckDigit(eg){if(!/^\d{13}$/.test(eg))return"";let gg=0;for(let ig=0;ig<13;ig++){const ng=parseInt(eg[ig]);gg+=ng*(ig%2===0?3:1)}return(10-gg%10)%10}_render(eg){var dg,hg,mg,bg;let gg=cloneDeep(this.barcodeOptions);console.log("_render======",gg),gg.bcid=getEffectiveBarcodeType(gg.bcid,gg.text);let ig=gg.bcid==="ean13",ng=gg.bcid==="upca",og=gg.bcid==="upce",ag=gg.bcid==="ean8";if(this.scaleX!==1&&(this.scaleX=1),this.scaleY!==1&&(this.scaleY=1),this.orginTextgaps>Number(gg.textgaps),this.orginTextSize>Number(gg.textsize),gg.bcid==="gs1-128")try{const pg=GS1Parser.process(gg.text);gg.text=GS1Parser.format(pg)}catch(pg){this._cache.error=pg instanceof Error?pg.message:String(pg),this._cache.canvas=void 0,this._cache.update=!1}gg.textgaps=gg.textgaps||1,this.orginTextgaps=gg.textgaps||1,this.orginTextSize=gg.textsize||0,eg.font=`${gg.textsize}px ${gg.textfontname}`,gg.textgaps&&(eg.letterSpacing=gg.textgaps+"px");const sg=eg.measureText(gg.text);let Ig=sg.width/this.scaleX,Cg=(sg.actualBoundingBoxAscent+sg.actualBoundingBoxDescent)/this.scaleY;this.orginTextWidth=Ig,this.orginTextHeight=Cg,this.height>0||(this.height=Cg+30);const lg=["ean13","upca","upce","ean8"],Ag=!lg.includes(gg.bcid)&&(gg.textposition==="top"||gg.textposition==="bottom"),rg=Ag?Cg+this.barcodeTextGap:0;this._textLayoutInitialized&&(this.height=Math.max(1,this.height+rg-this._lastTextAreaHeight)),this._textLayoutInitialized=!0,this._lastTextAreaHeight=rg,this.barcodeTextHeight=Ag?Cg:0,this._lastTextVisible=Ag;let cg={w:this.width,h:this.height,x:-this.width/2,y:-this.height/2};cg.textWidth=Ig,cg.textHeight=Cg,gg.includetext=!1,gg.scale=1,gg.paddingleft=0,gg.paddingright=0,lg.includes(gg.bcid)&&(gg={...gg,includetext:!0,textyoffset:-10},gg.bcid==="upca"&&(gg.textyoffset=-15),delete gg.paddingtop,delete gg.paddingbottom,delete gg.paddingleft,delete gg.paddingright,delete gg.textposition,delete gg.textxalign);const ug=lg.includes(gg.bcid);if(typeof this.fill=="string"){let pg=rgbaStringToHex8(this.fill);gg.barcolor=hexToHex6_blend(pg)}if(this._cache.update)if(console.log("this._cache.update=====",this._cache.update),/[\u4e00-\u9fff]/.test(gg.text||""))this._cache.error="Not Support zh-CN character",this._cache.canvas=void 0,this._cache.update=!1;else try{this._cache.canvas=generateCanvas(gg),ug&&this.cropBuiltInText(this._cache.canvas,gg);let pg=this._cache.canvas.width;if(!lg.includes(gg.bcid)){let fg=getTargetDpi();this.canvas&&fg===300&&(pg=pg*1.32)}if(this.stretchMode==="free"){if((!this.width||this.width<1)&&(this.width=pg),this.width>pg){let fg=Math.min(32,Math.max(1,Math.ceil(this.width/pg)));fg>1&&(gg.scale=fg,this._cache.canvas=generateCanvas(gg),ug&&this.cropBuiltInText(this._cache.canvas,gg),console.log("barcodeOption=====",gg),pg=this._cache.canvas.width)}}else{const fg=this.barcodeBaseWidth??this.width;this.width=getBarcodeRenderWidth(fg,pg)}cg.w=this.width,cg.x=-this.width/2,this._cache.error&&(this._cache.error=void 0),this.setCoords(),(dg=this.canvas)==null||dg.requestRenderAll(),this._cache.update=!1,(hg=this.canvas)!=null&&hg.getActiveObject&&((mg=this.canvas)==null?void 0:mg.getActiveObject())===this&&((bg=this.canvas)==null||bg.fire("custom:object:changed",{target:this,action:"barcode"}))}catch(pg){console.warn("draw barcode",pg),this.dirty=!0,pg instanceof Error&&(console.log("error",pg.message),this._cache.error="error:"+pg.message),this._cache.canvas=void 0}if(eg.imageSmoothingEnabled=!1,this.strokeWidth>0&&typeof this.stroke=="string"&&(eg.lineWidth=this.strokeWidth,eg.strokeStyle=this.stroke,withObjectStrokeDash(eg,this,()=>eg.strokeRect(cg.x,cg.y,cg.w,cg.h))),cg.barcodeCanvas=this._cache.canvas,!this._cache.error&&cg.barcodeCanvas){this.strokeWidth>0&&(cg.x+=this.strokeWidth/2,cg.y+=this.strokeWidth/2);let pg=cg.h-(cg.textHeight||0)-this.strokeWidth/2,fg=cg.y;gg.textposition==="top"?(pg=pg-this.barcodeTextGap,fg=fg+cg.textHeight/this.scaleY+this.barcodeTextGap):gg.textposition==="bottom"?pg=pg-this.barcodeTextGap/this.scaleY:pg=cg.h-this.strokeWidth/2;let Gg=cg.w-this.strokeWidth/2,Zg=pg;lg.includes(gg.bcid)&&(Zg=cg.h-this.strokeWidth/2),eg.drawImage(cg.barcodeCanvas,0,0,cg.barcodeCanvas.width,cg.barcodeCanvas.height,cg.x,fg,Gg,Zg);let $g=this.barcodeOptions.text;const Bg=this.width;if(ig){let Wg=this.calcEAN13CheckDigit($g);$g=$g+""+Wg,eg.save();const yg=Math.trunc(Bg/95),Ng=-cg.y-Math.trunc(Zg/6);let vg=cg.x+Math.trunc(Gg/13);eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top";let Sg=cg.barcodeCanvas.width;this.width/Sg===1&&(eg.letterSpacing="-2px"),eg.fillText($g[0],-yg*2+vg,Ng),eg.fillText($g.slice(1,7),yg*(3+42/2)+cg.x+Math.trunc(Gg/10),Ng),eg.fillText($g.slice(7),yg*(50+42/2)+cg.x+Math.trunc(Gg/10),Ng),eg.restore()}else if(ag){let Wg=this.calcEAN8CheckDigit($g);$g=$g+""+Wg,eg.save();const yg=Math.trunc(Bg/67),Ng=-cg.y-Math.trunc(Zg/6);cg.x+Math.trunc(Gg/13),eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top";let vg=cg.barcodeCanvas.width;this.width/vg===1&&(eg.letterSpacing="-1px");const Vg=yg*12+cg.x+4,Xg=yg*55+cg.x-4;eg.fillText($g.slice(0,4),Vg,Ng),eg.fillText($g.slice(4),Xg,Ng),eg.restore()}else if(ng){eg.save();const Wg=-cg.y-Math.trunc(Zg/6),yg=cg.x;let Ng=this.calcUPCACheckDigit($g);$g=$g+""+Ng,eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top";let vg=cg.barcodeCanvas.width;this.width/vg===1&&(eg.letterSpacing="-1px"),this.drawUPCAText(eg,$g,Bg,Wg,yg),eg.restore()}else if(og){eg.save();const Wg=-cg.y-Math.trunc(Zg/8),yg=cg.x;let Ng=this.calcUPCECheckDigit($g);$g=$g+""+Ng,console.log("digits========",$g),eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top",this.drawUPCEText(eg,$g,Bg,Wg,yg),eg.restore()}else this.drawText(eg,gg,cg)}if(eg.save(),/[\u4e00-\u9fff]/.test(gg.text||"")&&(this._cache.error="Not Support zh-CN character"),this._cache.error){const pg=wrapText(eg,this._cache.error,cg.w),fg=getLineHeight(eg);let wg=cg.y+fg;const Gg=eg.fillStyle;eg.fillStyle="red";for(const Zg of pg)if(eg.fillText(Zg,cg.x,wg),wg+=fg,wg>cg.y+this.height)break;eg.fillStyle=Gg}eg.restore(),console.log("_render barcode")}calcEAN13CheckDigit(eg){if(!/^\d{12}$/.test(eg))return"";let gg=0,ig=0;for(let ag=0;ag<12;ag++){const sg=Number(eg[11-ag]);(ag+1)%2===1?gg+=sg:ig+=sg}const og=(gg+ig*3)%10;return og===0?0:10-og}calcEAN8CheckDigit(eg){if(!/^\d{7}$/.test(eg))return"";let gg=0,ig=0;for(let ag=0;ag<7;ag++){const sg=Number(eg[6-ag]);(ag+1)%2===1?ig+=sg:gg+=sg}const og=(gg*3+ig)%10;return og===0?0:10-og}calcUPCACheckDigit(eg){if(!/^\d{11}$/.test(eg))return"";let gg=0,ig=0;for(let sg=0;sg<11;sg++){const Ig=parseInt(eg[sg],10);(sg+1)%2===1?gg+=Ig:ig+=Ig}const og=(gg*3+ig)%10;return(og===0?0:10-og).toString()}calcUPCECheckDigit(eg){if(!/^\d{7}$/.test(eg))return"";const gg=eg.split("").map(Number),ig=gg[0],[ng,og,ag,sg,Ig,Cg]=gg.slice(1);let lg="";switch(Cg){case 0:case 1:case 2:lg=`${ig}${ng}${og}${Cg}0000${ag}${sg}${Ig}`;break;case 3:lg=`${ig}${ng}${og}${ag}00000${sg}${Ig}`;break;case 4:lg=`${ig}${ng}${og}${ag}${sg}00000${Ig}`;break;default:lg=`${ig}${ng}${og}${ag}${sg}${Ig}0000${Cg}`}const Ag=lg.split("").map(Number);let rg=0;for(let cg=0;cg<Ag.length;cg++)cg%2===0?rg+=Ag[cg]*3:rg+=Ag[cg];return(10-rg%10)%10}drawUPCAText(eg,gg,ig,ng,og){const ag=gg[0],sg=gg.substring(1,6),Ig=gg.substring(6,11),Cg=gg[11],lg=ng,Ag=ig/95;[{text:ag,x:og+Ag*3.5},{text:sg,x:og+Ag*28+10},{text:Ig,x:og+Ag*67},{text:Cg,x:og+Ag*91.5+10}].forEach(cg=>{cg.text&&eg.fillText(cg.text,cg.x,lg)})}drawUPCEText(eg,gg,ig,ng,og){[{i:0,x:og+4},{i:1,x:og+ig*.25},{i:2,x:og+ig*.33},{i:3,x:og+ig*.44},{i:4,x:og+ig*.56},{i:5,x:og+ig*.68},{i:6,x:og+ig*.78},{i:7,x:og+ig+4}].forEach(sg=>{gg[sg.i]&&eg.fillText(gg[sg.i],sg.x,ng)})}set(eg,gg){return this._cache&&(this._cache.update=!0),super.set(eg,gg)}setBarcodeOption(eg){eg.bcid!==this.barcodeOptions.bcid&&(this.barcodeBaseWidth=void 0),merge(this.barcodeOptions,eg),this.dirty=!0,this._cache.update=!0;let gg=this.group;for(;gg;)gg.dirty=!0,gg=gg.group;let ig=getAllObjectMap();this.updateBarCode2d([...ig.text,...ig.counter])}updateInGroup(){this.dirty=!0,this.setCoords();let eg=this.group;for(;eg;)eg.dirty=!0,eg==null||eg.triggerLayout("childUpdate"),eg.setCoords(),eg=eg.group}getBarcodeOption(){return cloneDeep(this.barcodeOptions)}async updateBarCode2d(eg=[],gg=""){var ig;if(this.concatTextIdListObj||this.connectObjIds&&this.connectObjIds.length>0){let ng=!1,og="",ag=[],sg=[];const Ig=lg=>{if(this.connectObjIds){let Ag=0;for(let rg of this.connectObjIds){if(rg.index=Ag,rg.id&&rg.id===lg.id){ng=!0;let cg=lg.text+"";if(lg.type==="counter"&&(lg._props.mode==="1"?cg=lg.countCurrent():lg._props.mode==="2"&&(lg.updateText({isUpdateBarCodeDate:!1}),cg=lg.text+"")),rg.maxEnd=cg.length,rg.isSplit){rg.start=Math.min(rg.start,rg.maxEnd);let ug=cg.slice(rg.start,rg.end);ag[Ag]=ug}else ag[Ag]=cg}Ag++}}},Cg=lg=>{lg.type==="text"&&this.concatTextIdListObj&&this.concatTextIdListObj[lg.id]&&(ng||(lg==null||lg.set("text",this.barcodeOptions.text),lg.updateInGroup()),sg.push(lg))};if(eg.length>0)eg.forEach(lg=>{Ig(lg),Cg(lg)});else{const lg=Ag=>{Ag.type==="group"&&Ag._objects?Ag._objects.forEach(rg=>lg(rg)):(Ig(Ag),Cg(Ag))};(ig=this.canvas)==null||ig.getObjects().forEach(Ag=>lg(Ag))}return ng?(og=ag.join(""),this.barcodeOptions.text=og,this.dirty=!0,this._cache.update=!0,gg&&this.updateInGroup(),sg.forEach(lg=>{lg.updateInGroup(),lg==null||lg.set("text",og)}),setTimeout(()=>{var lg;(lg=this.canvas)==null||lg.requestRenderAll()},0),og):""}else return""}toObject(eg){let gg=["barcodeOptions","connectObjIds","concatTextIdListObj","counterProps","increaseDate","barcodeDateFormatType","stretchMode","barcodeTextHeight","barcodeTextGap"];return super.toObject(eg?[...eg,...gg]:gg)}};iC.type="Barcode";let ABarcode=iC;ABarcode.fromObject=(tg,eg)=>ABarcode._fromObject(tg,{...eg,extraParam:"barcodeOptions"}),tt.setClass(ABarcode),tt.setSVGClass(ABarcode);function getBase64Data({x:tg=0,y:eg=0,Content:gg="",ErrLevel:ig=1,Width:ng=0,Height:og=0,id:ag="",rWidth:sg=0,rHeight:Ig=0,CellSize:Cg="8"}={},lg=""){let Ag=ng/(og||1),rg=`${gg}-${ig}-${ng+og}-${Ag}-${Cg}`;if(lpCodeMap.has(rg)){let cg=lpCodeMap.get(rg);return lg!=="noSaveCache"&&setCacheLpCode({sKey:rg,img:cg,rWidth:sg,rHeight:Ig,x:tg,y:eg}),cg}return new Promise(async(cg,ug)=>{console.log("getLongbeiBase64Data=====");let dg=[JSON.stringify({Content:gg,ErrLevel:ig,Width:ng,Height:og,CellSize:Cg})],hg=await window.dsapi.driverAction.DSLE_Custom_LPCodeCreate(dg);if(hg=JSON.parse(hg),hg.code===0){let mg=hg.payload;if(mg){let bg=await loadBase64ToPic(mg);lpCodeMap.set(rg,bg),lg!=="noSaveCache"&&setCacheLpCode({sKey:rg,img:bg,rWidth:sg,rHeight:Ig,x:tg,y:eg}),cg(bg)}else ug("")}else ug(hg)})}function getMixBase64Data({x:tg=0,y:eg=0,Content:gg="",ErrLevel:ig="",Width:ng=0,Height:og=0,id:ag="",DPI:sg=203,rWidth:Ig=0,rHeight:Cg=0,CellSize:lg="8"}={},Ag=""){let rg=ng/(og||1),cg=`${gg}-${ig}-${ng+og}-${rg}-${lg}`;if(lpCodeMap.has(cg)){let ug=lpCodeMap.get(cg);return Ag!=="noSaveCache"&&setCacheMixLpCode({sKey:cg,img:ug,rWidth:Ig,rHeight:Cg,x:tg,y:eg}),ug}return new Promise(async(ug,dg)=>{console.log("getMixLongbeiBase64Data=====");let hg=ig.split("-"),mg=hg[0]||"0",bg=hg[1]||"0",pg=gg.split("|&&&|"),fg=pg.shift(),wg=pg.join("")||fg,Gg=[JSON.stringify({LPContent:fg||"",LPErrLevel:mg,QRContent:wg,QRErrLevel:bg,Width:ng,Height:og,DPI:sg+"",CellSize:lg})],Zg=await window.dsapi.driverAction.DSLE_Custom_LPMixCreate(Gg);if(Zg=JSON.parse(Zg),Zg.code===0){let $g=Zg.payload;if($g){let Bg=await loadBase64ToPic($g);lpCodeMap.set(cg,Bg),Ag!=="noSaveCache"&&setCacheMixLpCode({sKey:cg,img:Bg,rWidth:Ig,rHeight:Cg,x:tg,y:eg}),ug(Bg)}else dg("")}else dg(Zg)})}function loadBase64ToPic(tg){return new Promise(async(eg,gg)=>{let ig=new Image;ig.onload=()=>{eg(ig)},ig.src=tg})}let maxCacheLength=2e3;function setCacheLpCode({x:tg=0,y:eg=0,id:gg="",sKey:ig="",img:ng=null,rWidth:og=0,rHeight:ag=0}={}){if(!ig||!ng||!gg)return;let sg={sKey:ig,img:ng,rWidth:og,rHeight:ag,x:tg,y:eg};if(!cacheLpCodeMap.has(gg))cacheLpCodeMap.set(gg,[sg]);else{let Ig=cacheLpCodeMap.get(gg);Ig.length>maxCacheLength&&Ig.splice(0,500),Ig.push(sg),cacheLpCodeMap.set(gg,Ig)}}function setCacheMixLpCode({x:tg=0,y:eg=0,id:gg="",sKey:ig="",img:ng=null,rWidth:og=0,rHeight:ag=0}={}){if(!ig||!ng||!gg)return;let sg={sKey:ig,img:ng,rWidth:og,rHeight:ag,x:tg,y:eg};if(!cacheMixLpCodeMap.has(gg))cacheMixLpCodeMap.set(gg,[sg]);else{let Ig=cacheMixLpCodeMap.get(gg);Ig.length>maxCacheLength&&Ig.splice(0,500),Ig.push(sg),cacheMixLpCodeMap.set(gg,Ig)}console.log("cacheMixLpCodeMap========",cacheMixLpCodeMap)}class cappedMap extends Map{constructor(eg=60){super(),this.limit=eg}set(eg,gg){if(!this.has(eg)&&this.size>=this.limit){const ig=this.keys().next().value;this.delete(ig)}return super.set(eg,gg)}}class fastMap extends Map{constructor(eg=60){super(),this.lastKey=null,this.limit=eg}set(eg,gg){if(!this.has(eg)&&this.size>=this.limit){const ig=this.keys().next().value;this.delete(ig)}return this.lastKey=eg,super.set(eg,gg)}getLast(){return super.get(this.lastKey)||null}}let cacheMixLpCodeMap=new fastMap(2e3),cacheLpCodeMap=new fastMap(2e3),errorLpCodeMap=new cappedMap(5555),lpCodeMap=new cappedMap(5555),lpBcid=["LPCode","LPMixQrCode"];function clearLpAndMixCacheById(tg){cacheMixLpCodeMap.has(tg)&&cacheMixLpCodeMap.delete(tg),cacheLpCodeMap.has(tg)&&cacheLpCodeMap.delete(tg)}function getLastCacheLpcode(tg){let eg=cacheLpCodeMap.get(tg);return eg?eg[eg.length-1]:null}function getLastMixCacheLpcode(tg){let eg=cacheMixLpCodeMap.get(tg);return eg?eg[eg.length-1]:null}const isff=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function addEvent(tg,eg,gg,ig){tg.addEventListener?tg.addEventListener(eg,gg,ig):tg.attachEvent&&tg.attachEvent("on".concat(eg),gg)}function removeEvent(tg,eg,gg,ig){tg.removeEventListener?tg.removeEventListener(eg,gg,ig):tg.detachEvent&&tg.detachEvent("on".concat(eg),gg)}function getMods(tg,eg){const gg=eg.slice(0,eg.length-1);for(let ig=0;ig<gg.length;ig++)gg[ig]=tg[gg[ig].toLowerCase()];return gg}function getKeys(tg){typeof tg!="string"&&(tg=""),tg=tg.replace(/\s/g,"");const eg=tg.split(",");let gg=eg.lastIndexOf("");for(;gg>=0;)eg[gg-1]+=",",eg.splice(gg,1),gg=eg.lastIndexOf("");return eg}function compareArray(tg,eg){const gg=tg.length>=eg.length?tg:eg,ig=tg.length>=eg.length?eg:tg;let ng=!0;for(let og=0;og<gg.length;og++)ig.indexOf(gg[og])===-1&&(ng=!1);return ng}const _keyMap={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":isff?173:189,"=":isff?61:187,";":isff?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},_modifier={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},_mods={16:!1,18:!1,17:!1,91:!1},_handlers={};for(let tg=1;tg<20;tg++)_keyMap["f".concat(tg)]=111+tg;let _downKeys=[],winListendFocus=null,_scope="all";const elementEventMap=new Map,code=tg=>_keyMap[tg.toLowerCase()]||_modifier[tg.toLowerCase()]||tg.toUpperCase().charCodeAt(0),getKey=tg=>Object.keys(_keyMap).find(eg=>_keyMap[eg]===tg),getModifier=tg=>Object.keys(_modifier).find(eg=>_modifier[eg]===tg);function setScope(tg){_scope=tg||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(tg=>getKey(tg)||getModifier(tg)||String.fromCharCode(tg))}function getAllKeyCodes(){const tg=[];return Object.keys(_handlers).forEach(eg=>{_handlers[eg].forEach(gg=>{let{key:ig,scope:ng,mods:og,shortcut:ag}=gg;tg.push({scope:ng,shortcut:ag,mods:og,keys:ig.split("+").map(sg=>code(sg))})})}),tg}function filter(tg){const eg=tg.target||tg.srcElement,{tagName:gg}=eg;let ig=!0;const ng=gg==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(eg.type);return(eg.isContentEditable||(ng||gg==="TEXTAREA"||gg==="SELECT")&&!eg.readOnly)&&(ig=!1),ig}function isPressed(tg){return typeof tg=="string"&&(tg=code(tg)),_downKeys.indexOf(tg)!==-1}function deleteScope(tg,eg){let gg,ig;tg||(tg=getScope());for(const ng in _handlers)if(Object.prototype.hasOwnProperty.call(_handlers,ng))for(gg=_handlers[ng],ig=0;ig<gg.length;)gg[ig].scope===tg?gg.splice(ig,1).forEach(ag=>{let{element:sg}=ag;return removeKeyEvent(sg)}):ig++;getScope()===tg&&setScope(eg||"all")}function clearModifier(tg){let eg=tg.keyCode||tg.which||tg.charCode;tg.key&&tg.key.toLowerCase()==="capslock"&&(eg=code(tg.key));const gg=_downKeys.indexOf(eg);if(gg>=0&&_downKeys.splice(gg,1),tg.key&&tg.key.toLowerCase()==="meta"&&_downKeys.splice(0,_downKeys.length),(eg===93||eg===224)&&(eg=91),eg in _mods){_mods[eg]=!1;for(const ig in _modifier)_modifier[ig]===eg&&(hotkeys[ig]=!1)}}function unbind(tg){if(typeof tg>"u")Object.keys(_handlers).forEach(ng=>{Array.isArray(_handlers[ng])&&_handlers[ng].forEach(og=>eachUnbind(og)),delete _handlers[ng]}),removeKeyEvent(null);else if(Array.isArray(tg))tg.forEach(ng=>{ng.key&&eachUnbind(ng)});else if(typeof tg=="object")tg.key&&eachUnbind(tg);else if(typeof tg=="string"){for(var eg=arguments.length,gg=new Array(eg>1?eg-1:0),ig=1;ig<eg;ig++)gg[ig-1]=arguments[ig];let[ng,og]=gg;typeof ng=="function"&&(og=ng,ng=""),eachUnbind({key:tg,scope:ng,method:og,splitKey:"+"})}}const eachUnbind=tg=>{let{key:eg,scope:gg,method:ig,splitKey:ng="+"}=tg;getKeys(eg).forEach(ag=>{const sg=ag.split(ng),Ig=sg.length,Cg=sg[Ig-1],lg=Cg==="*"?"*":code(Cg);if(!_handlers[lg])return;gg||(gg=getScope());const Ag=Ig>1?getMods(_modifier,sg):[],rg=[];_handlers[lg]=_handlers[lg].filter(cg=>{const dg=(ig?cg.method===ig:!0)&&cg.scope===gg&&compareArray(cg.mods,Ag);return dg&&rg.push(cg.element),!dg}),rg.forEach(cg=>removeKeyEvent(cg))})};function eventHandler(tg,eg,gg,ig){if(eg.element!==ig)return;let ng;if(eg.scope===gg||eg.scope==="all"){ng=eg.mods.length>0;for(const og in _mods)Object.prototype.hasOwnProperty.call(_mods,og)&&(!_mods[og]&&eg.mods.indexOf(+og)>-1||_mods[og]&&eg.mods.indexOf(+og)===-1)&&(ng=!1);(eg.mods.length===0&&!_mods[16]&&!_mods[18]&&!_mods[17]&&!_mods[91]||ng||eg.shortcut==="*")&&(eg.keys=[],eg.keys=eg.keys.concat(_downKeys),eg.method(tg,eg)===!1&&(tg.preventDefault?tg.preventDefault():tg.returnValue=!1,tg.stopPropagation&&tg.stopPropagation(),tg.cancelBubble&&(tg.cancelBubble=!0)))}}function dispatch(tg,eg){const gg=_handlers["*"];let ig=tg.keyCode||tg.which||tg.charCode;if(tg.key&&tg.key.toLowerCase()==="capslock"||!hotkeys.filter.call(this,tg))return;if((ig===93||ig===224)&&(ig=91),_downKeys.indexOf(ig)===-1&&ig!==229&&_downKeys.push(ig),["metaKey","ctrlKey","altKey","shiftKey"].forEach(sg=>{const Ig=modifierMap[sg];tg[sg]&&_downKeys.indexOf(Ig)===-1?_downKeys.push(Ig):!tg[sg]&&_downKeys.indexOf(Ig)>-1?_downKeys.splice(_downKeys.indexOf(Ig),1):sg==="metaKey"&&tg[sg]&&(_downKeys=_downKeys.filter(Cg=>Cg in modifierMap||Cg===ig))}),ig in _mods){_mods[ig]=!0;for(const sg in _modifier)if(Object.prototype.hasOwnProperty.call(_modifier,sg)){const Ig=modifierMap[_modifier[sg]];hotkeys[sg]=tg[Ig]}if(!gg)return}for(const sg in _mods)Object.prototype.hasOwnProperty.call(_mods,sg)&&(_mods[sg]=tg[modifierMap[sg]]);tg.getModifierState&&!(tg.altKey&&!tg.ctrlKey)&&tg.getModifierState("AltGraph")&&(_downKeys.indexOf(17)===-1&&_downKeys.push(17),_downKeys.indexOf(18)===-1&&_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);const ng=getScope();if(gg)for(let sg=0;sg<gg.length;sg++)gg[sg].scope===ng&&(tg.type==="keydown"&&gg[sg].keydown||tg.type==="keyup"&&gg[sg].keyup)&&eventHandler(tg,gg[sg],ng,eg);if(!(ig in _handlers))return;const og=_handlers[ig],ag=og.length;for(let sg=0;sg<ag;sg++)if((tg.type==="keydown"&&og[sg].keydown||tg.type==="keyup"&&og[sg].keyup)&&og[sg].key){const Ig=og[sg],{splitKey:Cg}=Ig,lg=Ig.key.split(Cg),Ag=[];for(let rg=0;rg<lg.length;rg++)Ag.push(code(lg[rg]));Ag.sort().join("")===_downKeys.sort().join("")&&eventHandler(tg,Ig,ng,eg)}}function hotkeys(tg,eg,gg){_downKeys=[];const ig=getKeys(tg);let ng=[],og="all",ag=document,sg=0,Ig=!1,Cg=!0,lg="+",Ag=!1,rg=!1;for(gg===void 0&&typeof eg=="function"&&(gg=eg),Object.prototype.toString.call(eg)==="[object Object]"&&(eg.scope&&(og=eg.scope),eg.element&&(ag=eg.element),eg.keyup&&(Ig=eg.keyup),eg.keydown!==void 0&&(Cg=eg.keydown),eg.capture!==void 0&&(Ag=eg.capture),typeof eg.splitKey=="string"&&(lg=eg.splitKey),eg.single===!0&&(rg=!0)),typeof eg=="string"&&(og=eg),rg&&unbind(tg,og);sg<ig.length;sg++)tg=ig[sg].split(lg),ng=[],tg.length>1&&(ng=getMods(_modifier,tg)),tg=tg[tg.length-1],tg=tg==="*"?"*":code(tg),tg in _handlers||(_handlers[tg]=[]),_handlers[tg].push({keyup:Ig,keydown:Cg,scope:og,mods:ng,shortcut:ig[sg],method:gg,key:ig[sg],splitKey:lg,element:ag});if(typeof ag<"u"&&window){if(!elementEventMap.has(ag)){const cg=function(){let dg=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return dispatch(dg,ag)},ug=function(){let dg=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;dispatch(dg,ag),clearModifier(dg)};elementEventMap.set(ag,{keydownListener:cg,keyupListenr:ug,capture:Ag}),addEvent(ag,"keydown",cg,Ag),addEvent(ag,"keyup",ug,Ag)}if(!winListendFocus){const cg=()=>{_downKeys=[]};winListendFocus={listener:cg,capture:Ag},addEvent(window,"focus",cg,Ag)}}}function trigger(tg){let eg=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(_handlers).forEach(gg=>{_handlers[gg].filter(ng=>ng.scope===eg&&ng.shortcut===tg).forEach(ng=>{ng&&ng.method&&ng.method()})})}function removeKeyEvent(tg){const eg=Object.values(_handlers).flat();if(eg.findIndex(ig=>{let{element:ng}=ig;return ng===tg})<0){const{keydownListener:ig,keyupListenr:ng,capture:og}=elementEventMap.get(tg)||{};ig&&ng&&(removeEvent(tg,"keyup",ng,og),removeEvent(tg,"keydown",ig,og),elementEventMap.delete(tg))}if((eg.length<=0||elementEventMap.size<=0)&&(Object.keys(elementEventMap).forEach(ng=>{const{keydownListener:og,keyupListenr:ag,capture:sg}=elementEventMap.get(ng)||{};og&&ag&&(removeEvent(ng,"keyup",ag,sg),removeEvent(ng,"keydown",og,sg),elementEventMap.delete(ng))}),elementEventMap.clear(),Object.keys(_handlers).forEach(ng=>delete _handlers[ng]),winListendFocus)){const{listener:ng,capture:og}=winListendFocus;removeEvent(window,"focus",ng,og),winListendFocus=null}}const _api={getPressedKeyString,setScope,getScope,deleteScope,getPressedKeyCodes,getAllKeyCodes,isPressed,filter,trigger,unbind,keyMap:_keyMap,modifier:_modifier,modifierMap};for(const tg in _api)Object.prototype.hasOwnProperty.call(_api,tg)&&(hotkeys[tg]=_api[tg]);if(typeof window<"u"){const tg=window.hotkeys;hotkeys.noConflict=eg=>(eg&&window.hotkeys===hotkeys&&(window.hotkeys=tg),hotkeys),window.hotkeys=hotkeys}function getSupportDistance(tg,eg){var ng;const gg=(ng=tg==null?void 0:tg.getCenterPoint)==null?void 0:ng.call(tg),ig=getVisibleCoords(tg);return!gg||!Array.isArray(ig)||ig.length===0?0:Math.max(...ig.map(og=>(og.x-gg.x)*eg.x+(og.y-gg.y)*eg.y))}function getVisibleCoords(tg){var ng,og;if(!((ng=tg==null?void 0:tg._textLines)!=null&&ng.length)||typeof tg.getLineWidth!="function"||typeof tg._getLineLeftOffset!="function"||typeof tg.getHeightOfLine!="function"||typeof tg.calcTransformMatrix!="function")return(og=tg==null?void 0:tg.getCoords)==null?void 0:og.call(tg);const eg=tg.calcTransformMatrix(),gg=[];let ig=-tg.height/2;return tg._textLines.forEach((ag,sg)=>{const Ig=-tg.width/2+tg._getLineLeftOffset(sg),Cg=Ig+tg.getLineWidth(sg),lg=ig+tg.getHeightOfLine(sg);gg.push(new ot(Ig,ig).transform(eg),new ot(Cg,ig).transform(eg),new ot(Cg,lg).transform(eg),new ot(Ig,lg).transform(eg)),ig=lg}),gg}function getRelativePositionBounds(tg){const eg=getVisibleCoords(tg);if(eg!=null&&eg.length)return eg.reduce((gg,ig)=>({left:Math.min(gg.left,ig.x),top:Math.min(gg.top,ig.y),right:Math.max(gg.right,ig.x),bottom:Math.max(gg.bottom,ig.y)}),{left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY})}function captureRelativePosition(tg,eg){var Cg,lg;const gg=(Cg=tg==null?void 0:tg.getCenterPoint)==null?void 0:Cg.call(tg),ig=(lg=eg==null?void 0:eg.getCenterPoint)==null?void 0:lg.call(eg);if(!gg||!ig||!(eg!=null&&eg.id))return;const ng=gg.x-ig.x,og=gg.y-ig.y,ag=Math.hypot(ng,og),sg=new ot(ag?ng/ag:1,ag?og/ag:0),Ig=new ot(-sg.x,-sg.y);return{targetId:eg.id,directionX:sg.x,directionY:sg.y,gap:ag-getSupportDistance(eg,sg)-getSupportDistance(tg,Ig)}}function placeRelativeObject(tg,eg,gg){var Ag,rg,cg;const ig=gg||(tg==null?void 0:tg.relativePosition),ng=(Ag=eg==null?void 0:eg.getCenterPoint)==null?void 0:Ag.call(eg);if(!ig||!ng||!(eg!=null&&eg.id))return!1;let og=ig.directionX,ag=ig.directionY,sg=ig.gap;if(!Number.isFinite(og)||!Number.isFinite(ag)){const ug=ig.dx||0,dg=ig.dy||0,hg=Math.hypot(ug,dg);og=hg?ug/hg:1,ag=hg?dg/hg:0;const mg=new ot(og,ag);sg=hg-getSupportDistance(eg,mg)-getSupportDistance(tg,new ot(-og,-ag)),gg||tg.set("relativePosition",{targetId:ig.targetId,directionX:og,directionY:ag,gap:sg})}const Ig=new ot(og,ag),Cg=new ot(-og,-ag),lg=getSupportDistance(eg,Ig)+sg+getSupportDistance(tg,Cg);return(rg=tg.setPositionByOrigin)==null||rg.call(tg,new ot(ng.x+og*lg,ng.y+ag*lg),"center","center"),(cg=tg.setCoords)==null||cg.call(tg),!0}class EditorData{constructor(){this.relativePositionGeometrySnapshots=new Map,this.enabled=!0,this.dirty=!1,this.originState="",this.hasSetActiveSelection=!1,this.relativePositionEditHandle=eg=>{var og;const gg=(eg==null?void 0:eg.target)||(eg==null?void 0:eg.activeObj);if(!(gg!=null&&gg.id)||!this.canvas)return;const ig=this.canvas.getObjects();if((og=gg.getCenterPoint)!=null&&og.call(gg))for(const ag of ig){const sg=ag.relativePosition;if(sg){if(ag.id===gg.id){const Ig=ig.find(lg=>lg.id===sg.targetId),Cg=captureRelativePosition(ag,Ig);Cg&&ag.set("relativePosition",Cg)}else if(sg.targetId===gg.id){const Ig=captureRelativePosition(ag,gg);Ig&&ag.set("relativePosition",Ig)}}}},this.relativePositionPrepareHandle=()=>{if(!this.canvas)return;const eg=this.canvas.getObjects();this.relativePositionGeometrySnapshots.clear();for(const gg of eg){gg.id&&this.relativePositionGeometrySnapshots.set(gg.id,{left:gg.left,top:gg.top,width:gg.width,height:gg.height,scaleX:gg.scaleX,scaleY:gg.scaleY,angle:gg.angle,visibleBounds:getRelativePositionBounds(gg)});const ig=gg.relativePosition;if(!ig||Number.isFinite(ig.directionX)&&Number.isFinite(ig.directionY)&&Number.isFinite(ig.gap))continue;const ng=eg.find(ag=>ag.id===ig.targetId),og=captureRelativePosition(gg,ng);og&&gg.set("relativePosition",og)}},this.relativePositionRenderHandle=eg=>{var Cg;const gg=(eg==null?void 0:eg.target)||(eg==null?void 0:eg.activeObj);if(!(gg!=null&&gg.id)||!this.canvas||!((Cg=gg.getCenterPoint)==null?void 0:Cg.call(gg)))return;const ng=new Set,og=!!(eg!=null&&eg.preserveUnchangedAxes),ag=lg=>{const Ag=lg!=null&&lg.id?this.relativePositionGeometrySnapshots.get(lg.id):void 0;if(!Ag)return;const rg=getRelativePositionBounds(lg),cg=ug=>!!Ag.visibleBounds&&!!rg&&Math.abs(rg[ug]-Ag.visibleBounds[ug])>1e-6;return{x:lg.left!==Ag.left||lg.width!==Ag.width||lg.scaleX!==Ag.scaleX||lg.angle!==Ag.angle||cg("left")||cg("right"),y:lg.top!==Ag.top||lg.height!==Ag.height||lg.scaleY!==Ag.scaleY||lg.angle!==Ag.angle||cg("top")||cg("bottom")}},sg=(lg,Ag,rg)=>{var Wg,yg,Ng,vg,Sg;const cg=(Wg=lg.getCenterPoint)==null?void 0:Wg.call(lg),ug=(yg=Ag.getCenterPoint)==null?void 0:yg.call(Ag),dg=rg||lg.relativePosition,hg=og?ag(lg):void 0,mg=og?ag(Ag):void 0;if(!placeRelativeObject(lg,Ag,rg)||!og||!cg||!ug||!hg&&!mg)return;const bg=!!(hg!=null&&hg.x)||!!(mg!=null&&mg.x),pg=!!(hg!=null&&hg.y)||!!(mg!=null&&mg.y),fg=(Ng=lg.getCenterPoint)==null?void 0:Ng.call(lg),wg=dg==null?void 0:dg.directionX,Gg=dg==null?void 0:dg.directionY;if(!fg||!Number.isFinite(wg)||!Number.isFinite(Gg)||bg&&pg)return;const Zg=(fg.x-ug.x)*wg+(fg.y-ug.y)*Gg;let $g=fg.x,Bg=fg.y;bg&&!pg?(Bg=cg.y,$g=Math.abs(wg)>1e-8?ug.x+(Zg-Gg*(Bg-ug.y))/wg:cg.x):!bg&&pg?($g=cg.x,Bg=Math.abs(Gg)>1e-8?ug.y+(Zg-wg*($g-ug.x))/Gg:cg.y):($g=cg.x,Bg=cg.y),(vg=lg.setPositionByOrigin)==null||vg.call(lg,new ot($g,Bg),"center","center"),(Sg=lg.setCoords)==null||Sg.call(lg)},Ig=(lg,Ag=!1)=>{var cg;if(ng.has(lg.id))return;ng.add(lg.id);const rg=lg.relativePosition;if(Ag&&rg){const ug=this.canvas.getObjects().find(dg=>dg.id===rg.targetId);ug&&sg(ug,lg,{...rg,targetId:ug.id,directionX:-rg.directionX,directionY:-rg.directionY,dx:rg.dx===void 0?void 0:-rg.dx,dy:rg.dy===void 0?void 0:-rg.dy})}for(const ug of this.canvas.getObjects()){const dg=ug.relativePosition;if((dg==null?void 0:dg.targetId)!==lg.id)continue;sg(ug,lg),((cg=ug.getCenterPoint)==null?void 0:cg.call(ug))&&Ig(ug)}};Ig(gg,!0),this.canvas.requestRenderAll()},this.handle={selectionHandles:new Set,modifyHandles:new Set,mouseDownHandles:new Set,mouseUpHandles:new Set,doubleClickHandles:new Set,objectUpdateHandles:new Set,mouseOverHandles:new Set,mouseOutHandles:new Set,checkDirtyHandles:new Set},this.selectHandle=eg=>{if(this.enabled)for(const gg of this.handle.selectionHandles)if(eg.selected){const ig=this.canvas.getActiveObject();gg(eg.e,ig?[ig]:[]),this.canvas&&this.canvas.elements.container.focus({preventScroll:!0})}else gg(eg.e,[])},this.modifyHandle=throttle$3(eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))){if(eg.target)for(const gg of this.handle.modifyHandles)gg(eg.e,eg.target);this.checkDirty(eg)}},200),this.doubleClickHandle=eg=>{var gg,ig;if(!(!this.enabled||this.isWorkspace(eg.target))&&eg.target){eg.target.type==="table"&&eg.scenePoint&&(this.canvas.getActiveObject()!==eg.target&&(this.canvas.setActiveObject(eg.target,eg.e),this.canvas.requestRenderAll()),(ig=(gg=eg.target).handleCellDoubleClick)==null||ig.call(gg,eg.scenePoint));for(const ng of this.handle.doubleClickHandles)ng(eg.e,eg.target)}},this.mouseDownHandle=eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))&&eg.target)for(const gg of this.handle.mouseDownHandles)gg(eg.e,eg.target)},this.mouseUpHandle=eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))&&eg.target)for(const gg of this.handle.mouseUpHandles)gg(eg.e,eg.target)},this.checkDirty=debounce$2(eg=>{if(!this.canvas)return!1;const gg=this.canvas.toJSON(),ig=JSON.stringify(gg);this.originState||(this.originState=ig),this.dirty=this.originState!==ig,eg.isToDirty&&(this.dirty=!0),console.log("this.dirty=========",this.dirty);for(const ng of this.handle.checkDirtyHandles)ng();return this.dirty},100),this.objectUpdateHandle=debounce$2(eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))){for(const gg of this.handle.objectUpdateHandles)gg(eg.target);this.checkDirty(eg)}},100),this.mouseOver=eg=>{for(const gg of this.handle.mouseOverHandles)gg()},this.mouseOut=eg=>{for(const gg of this.handle.mouseOutHandles)gg()}}init(eg){this.editor=eg,this.canvas=eg.getCanvas(),this.bind(),this.originState=JSON.stringify(this.canvas.toJSON())}getActiveObject(){return this.canvas.getActiveObject()}getActiveObjects(){return this.canvas.getActiveObjects()}getObjects(){return this.canvas.getObjects()||[]}getAllObjects(){if(!this.canvas)return[];const eg=[];function gg(ig){ig.type==="group"&&ig._objects?ig._objects.forEach(ng=>gg(ng)):ig.id!=="workspace"&&eg.push(ig)}return this.canvas.getObjects().forEach(ig=>gg(ig)),eg}clearActiveSelection(){this.canvas&&this.hasSetActiveSelection&&(this.canvas.discardActiveObject(),this.canvas.requestRenderAll(),this.hasSetActiveSelection=!1)}setObjectsActive(eg){if(!(!this.canvas||eg.length===0)){if(this.canvas.discardActiveObject(),eg.length===1)this.canvas.setActiveObject(eg[0]);else{this.hasSetActiveSelection=!0;const gg=new Jo(eg,{canvas:this.canvas});this.canvas.setActiveObject(gg)}this.canvas.requestRenderAll()}}getObjectsList(){if(!this.canvas)return[];const eg=this.canvas.getObjects(),gg=[];for(const ig of eg)if(ig.id!=="workspace"&&ig.drawObjectType!=="ignoreObject"){if(ig instanceof Jo)continue;ig.parent?ig.parent instanceof Jo?gg.push(ig):console.log("obj.parent isn't ActiveSelection",ig.parent,ig.parent.type):gg.push(ig)}return gg}setActiveObjectProps(eg,gg=!0){if(this.canvas){const ig=this.canvas.getActiveObject();if(ig){for(const ng in eg)console.log("object set",ng,eg[ng]),ig.type==="text"?(ig.set(ng,eg[ng]),ig.splitByGrapheme&&ig.verticalTypeChange()):ig.set(ng,eg[ng]);return gg&&this.canvas.fire("custom:object:history",{target:ig,action:"history:update"}),!0}}return!1}setActiveObjectPos(eg){var gg;this.setActiveObjectProps(eg)&&((gg=this.canvas)==null||gg.getActiveObject().setCoords())}setActiveObjectPositionByOrigin(eg,gg="left",ig="top"){var og,ag;const ng=(og=this.canvas)==null?void 0:og.getActiveObject();return ng!=null&&ng.setPositionByOrigin?(ng.setPositionByOrigin(eg,gg,ig),ng.setCoords(),(ag=this.canvas)==null||ag.fire("custom:object:history",{target:ng,action:"history:update"}),!0):!1}updateCanvas(){this.canvas.renderAll()}addModifyHandle(eg){this.handle.modifyHandles.add(eg)}addSelectionHandle(eg){this.handle.selectionHandles.add(eg)}addMouseDownHandle(eg){this.handle.mouseDownHandles.add(eg)}addMouseUpHandle(eg){this.handle.mouseUpHandles.add(eg)}addDoubleClickHandle(eg){this.handle.doubleClickHandles.add(eg)}addObjectUpdateHandle(eg){this.handle.objectUpdateHandles.add(eg)}addMouseOverHandle(eg){this.handle.mouseOverHandles.add(eg)}addMouseOutHandle(eg){this.handle.mouseOutHandles.add(eg)}removeMouseOverHandle(eg){this.handle.mouseOverHandles.delete(eg)}removeMouseOutHandle(eg){this.handle.mouseOutHandles.delete(eg)}removeModifyHandle(eg){this.handle.modifyHandles.delete(eg)}removeSelectionHandle(eg){this.handle.selectionHandles.delete(eg)}removeMouseDownHandle(eg){this.handle.mouseDownHandles.delete(eg)}removeMouseUpHandle(eg){this.handle.mouseUpHandles.delete(eg)}removeDoubleClickHandle(eg){this.handle.doubleClickHandles.delete(eg)}remvoeObjectUpdateHandle(eg){this.handle.objectUpdateHandles.delete(eg)}addCheckDirtyHandles(eg){this.handle.checkDirtyHandles.add(eg)}removeCheckDirtyHandles(eg){this.handle.checkDirtyHandles.delete(eg)}setOriginState(){if(!this.canvas)return!1;const eg=this.canvas.toJSON(),gg=JSON.stringify(eg);this.originState=gg}isWorkspace(eg){return eg&&eg.id==="workspace"}setEnabled(eg){this.enabled=eg}bind(){if(!this.canvas)return;const eg=this.canvas,gg=eg.findTarget.bind(eg);eg.findTarget=ig=>{if(ig&&ig.type==="dblclick"){const ng=[],og=[];for(const sg of eg.getObjects())sg.type==="table"&&sg.perPixelTargetFind&&(ng.push(sg),og.push(sg.perPixelTargetFind),sg.perPixelTargetFind=!1);const ag=gg(ig);return ng.forEach((sg,Ig)=>{sg.perPixelTargetFind=og[Ig]}),ag}return gg(ig)},eg.on("selection:created",this.selectHandle),eg.on("selection:updated",this.selectHandle),eg.on("selection:cleared",this.selectHandle),eg.on("object:modified",this.modifyHandle),eg.on("object:scaling",this.modifyHandle),eg.on("object:rotating",this.modifyHandle),eg.on("object:moving",this.modifyHandle),eg.on("object:skewing",this.modifyHandle),eg.on("custom:object:changed",this.modifyHandle),eg.on("custom:object:basechanged",this.modifyHandle),eg.on("object:modified",this.relativePositionEditHandle),eg.on("custom:object:basechanged",this.relativePositionEditHandle),eg.on("custom:object:relativeposition:prepare",this.relativePositionPrepareHandle),eg.on("custom:object:relativeposition:update",this.relativePositionRenderHandle),eg.on("mouse:dblclick",this.doubleClickHandle),eg.on("mouse:down",this.mouseDownHandle),eg.on("mouse:up",this.mouseUpHandle),eg.on("object:added",this.objectUpdateHandle),eg.on("object:removed",this.objectUpdateHandle),eg.on("custom:object:checkdirty",this.checkDirty),this.editor.on("group",this.objectUpdateHandle),this.editor.on("ungroup",this.objectUpdateHandle)}unbind(){if(!this.canvas)return;const eg=this.canvas;eg.off("selection:created",this.selectHandle),eg.off("selection:updated",this.selectHandle),eg.off("selection:cleared",this.selectHandle),eg.off("object:modified",this.modifyHandle),eg.off("object:scaling",this.modifyHandle),eg.off("object:rotating",this.modifyHandle),eg.off("object:moving",this.modifyHandle),eg.off("object:skewing",this.modifyHandle),eg.off("custom:object:changed",this.modifyHandle),eg.off("custom:object:basechanged",this.modifyHandle),eg.off("object:modified",this.relativePositionEditHandle),eg.off("custom:object:basechanged",this.relativePositionEditHandle),eg.off("custom:object:relativeposition:prepare",this.relativePositionPrepareHandle),eg.off("custom:object:relativeposition:update",this.relativePositionRenderHandle),eg.off("mouse:dblclick",this.doubleClickHandle),eg.off("mouse:down",this.mouseDownHandle),eg.off("mouse:up",this.mouseUpHandle),eg.off("object:added",this.objectUpdateHandle),eg.off("object:removed",this.objectUpdateHandle),eg.off("custom:object:checkdirty",this.checkDirty),this.editor.off("group",this.objectUpdateHandle),this.editor.off("ungroup",this.objectUpdateHandle)}}const byteToHex=[];for(let tg=0;tg<256;++tg)byteToHex.push((tg+256).toString(16).slice(1));function unsafeStringify(tg,eg=0){return(byteToHex[tg[eg+0]]+byteToHex[tg[eg+1]]+byteToHex[tg[eg+2]]+byteToHex[tg[eg+3]]+"-"+byteToHex[tg[eg+4]]+byteToHex[tg[eg+5]]+"-"+byteToHex[tg[eg+6]]+byteToHex[tg[eg+7]]+"-"+byteToHex[tg[eg+8]]+byteToHex[tg[eg+9]]+"-"+byteToHex[tg[eg+10]]+byteToHex[tg[eg+11]]+byteToHex[tg[eg+12]]+byteToHex[tg[eg+13]]+byteToHex[tg[eg+14]]+byteToHex[tg[eg+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(tg,eg,gg){var ng;if(native.randomUUID&&!tg)return native.randomUUID();tg=tg||{};const ig=tg.random??((ng=tg.rng)==null?void 0:ng.call(tg))??rng();if(ig.length<16)throw new Error("Random bytes length must be >= 16");return ig[6]=ig[6]&15|64,ig[8]=ig[8]&63|128,unsafeStringify(ig)}function handleConcatBarcode2d(tg,eg,gg=!0,ig=null){if(tg){let ng=[],og=getAllObjectMap(eg);ng=[...og.text,...og.counter];let ag=[...og.barcode2d],sg=[...og.barcode],Ig={};ag.forEach(lg=>{Ig[lg.id]=lg});let Cg={};sg.forEach(lg=>{Cg[lg.id]=lg});for(let lg of Object.keys(tg)){if(ag.length){let Ag=Ig[lg];if(!Ag)return;let rg=!0;if(ig&&ig.type==="counter"&&ig.data==="2"&&(Ag.barcode2dOptions.bcid==="LPCode"?(rg=!Ag.hasLpemit,Ag.hasLpemit=!0):Ag.barcode2dOptions.bcid==="LPMixQrCode"&&(rg=!Ag.hasLpMixemit,Ag.hasLpMixemit=!0)),!rg)return;canvasEventBus.emit(`update:barcode2d:${lg}`,{list:ng,callback:cg=>{Ag.dirty=!0,Ag.barcode2dOptions.text=cg||Ag.barcode2dOptions.text,Ag.updateInGroup(),gg&&setTimeout(()=>{eg==null||eg.requestRenderAll()},30)}})}if(sg.length){let Ag=Cg[lg];if(!Ag)return;canvasEventBus.emit(`update:barcode:${lg}`,{list:ng,callback:rg=>{Ag.dirty=!0,Ag.barcodeOptions.text=rg||Ag.barcodeOptions.text,Ag.updateInGroup(),gg&&setTimeout(()=>{eg==null||eg.requestRenderAll(),Ag.group&&setTimeout(()=>{Ag.updateInGroup(),eg==null||eg.requestRenderAll()},0)},30)}})}}}}function addHandle(tg,eg,gg){if(tg){let ig={},ng=getAllObjectMap(eg);[...ng.barcode2d,...ng.barcode].forEach(ag=>{ig[ag.id]=ag});for(let ag of Object.keys(tg)){let sg=ig[ag];if(sg){let Ig=sg.connectObjIds||[],Cg=cacheObj[gg];Cg&&(Ig.some(lg=>lg.id===Cg.id)||(Ig.splice(Cg.index,0,Cg),sg.set("connectObjIds",Ig)))}}}}let cacheObj={};function deleteHandle(tg,eg,gg){if(tg){let ig={},ng=getAllObjectMap(eg);[...ng.barcode2d,...ng.barcode].forEach(ag=>{ig[ag.id]=ag});for(let ag of Object.keys(tg)){let sg=ig[ag];if(sg){let Ig=sg.connectObjIds||[];Ig=Ig.filter(Cg=>(Cg.id===gg&&(cacheObj[gg]=Cg),Cg.id!==gg)),sg.set("connectObjIds",Ig)}}}}const isAnchorX$1=tg=>tg==="left"||tg==="center"||tg==="right",isAnchorY$1=tg=>tg==="top"||tg==="center"||tg==="bottom";function getTextAnchor(tg){return{x:isAnchorX$1(tg==null?void 0:tg.textAnchorX)?tg.textAnchorX:isAnchorX$1(tg==null?void 0:tg.originX)?tg.originX:"left",y:isAnchorY$1(tg==null?void 0:tg.textAnchorY)?tg.textAnchorY:isAnchorY$1(tg==null?void 0:tg.originY)?tg.originY:"top"}}const isTextAnchorPosition=tg=>Number.isFinite(tg==null?void 0:tg.x)&&Number.isFinite(tg==null?void 0:tg.y);function captureTextAnchorPosition(tg,eg=getTextAnchor(tg)){var ig;const gg=(ig=tg==null?void 0:tg.getPointByOrigin)==null?void 0:ig.call(tg,eg.x,eg.y);if(isTextAnchorPosition(gg))return tg.textAnchorPosition={x:gg.x,y:gg.y},tg.textAnchorPosition}function reflowTextWithAnchor(tg,eg,gg=!1){var ag;const ig=getTextAnchor(tg),ng=gg&&isTextAnchorPosition(tg==null?void 0:tg.textAnchorPosition)?tg.textAnchorPosition:captureTextAnchorPosition(tg,ig),og=eg();return ng&&(tg!=null&&tg.setPositionByOrigin)&&(tg.setPositionByOrigin(ng,ig.x,ig.y),(ag=tg.setCoords)==null||ag.call(tg),captureTextAnchorPosition(tg,ig)),og}function setTextAnchor(tg,eg,gg){var ig;tg.set({textAnchorX:eg,textAnchorY:gg}),captureTextAnchorPosition(tg,{x:eg,y:gg}),(ig=tg.canvas)==null||ig.fire("custom:object:history",{target:tg,action:"history:update"})}const myanmarCharacters=/[\u1000-\u109F\uA9E0-\uA9FF\uAA60-\uAA7F]/,aC=class aC extends No{constructor(eg,gg){const ig=gg.width,ng=gg.height;super(eg,gg),this.hasSetSplit=!1,this.objectCaching=!0,this.hasSetItalic=!1,this.isClearCopyTextStyle=!1,this.propsMinHeight=0,this.strokeUniform=!0,this.isBgBlackColor=!1,this.customExportFields={varnish:"none"},this.backgroundColor="",this.connectBar2dMap=null,this.__canvasRef=null,this.fontFamily="微软雅黑",this.verticalType="top",this.arcEnable=!1,this.arcRadius=100,this.fixedSize=!1,this.verticalLayout=!1,this.fixedHeight=!1,this.extraScale=1,this.textAnchorX="left",this.textAnchorY="top",this.isNormalizingParagraphScale=!1,this.textAnchorX=gg.textAnchorX??gg.originX??"left",this.textAnchorY=gg.textAnchorY??gg.originY??"top";const og=gg.textAnchorPosition;this.textAnchorPosition=Number.isFinite(og==null?void 0:og.x)&&Number.isFinite(og==null?void 0:og.y)?{x:og.x,y:og.y}:this.getPointByOrigin(this.textAnchorX,this.textAnchorY),this.fixedHeight=gg.fixedHeight??!1,this.fixedHeight&&this.splitByGrapheme&&ng!==void 0&&reflowTextWithAnchor(this,()=>{this.height=ng},!0),this.customExportFields=gg.customExportFields??this.customExportFields,this._originGetTopOffset=this._getTopOffset?this._getTopOffset.bind(this):()=>0,this.fontFamily=gg.fontFamily??this.fontFamily,gg.hasSetItalic&&gg.fontStyle!=="italic"&&(this.fontStyle="italic",gg.skewX===-15&&(this.skewX=0)),gg.propsMinHeight&&reflowTextWithAnchor(this,()=>{this.propsMinHeight=gg.propsMinHeight,this.fixedHeight||(this.height=Math.max(this.height,this.propsMinHeight))}),gg.verticalType&&(this.verticalType=gg.verticalType),gg.backgroundColor&&(this.backgroundColor=gg.backgroundColor),this.isBgBlackColor=gg.isBgBlackColor??this.isBgBlackColor,this.connectBar2dMap=gg.connectBar2dMap??this.connectBar2dMap,gg.arcEnable!==void 0&&(this.arcEnable=gg.arcEnable),gg.arcRadius!==void 0&&(this.arcRadius=gg.arcRadius),gg.fixedSize!==void 0&&(this.fixedSize=gg.fixedSize),gg.verticalLayout!==void 0&&(this.verticalLayout=gg.verticalLayout),gg.horizontalLayoutWidth!==void 0?this.horizontalLayoutWidth=gg.horizontalLayoutWidth:this.verticalLayout&&(this.horizontalLayoutWidth=ig??this.width),gg.extraScale!==void 0&&(this.extraScale=gg.extraScale),gg.baseFontSize!==void 0&&(this.baseFontSize=gg.baseFontSize),this.fixedSize&&(this.arcEnable=!1,this.baseFontSize??(this.baseFontSize=this.fontSize),ig!==void 0&&reflowTextWithAnchor(this,()=>{this.width=ig})),this.on("removed",ag=>{if(ag.target.type!=="activeselection"){if(this.inGroupRemove){this.inGroupRemove=!1;return}deleteHandle(this.connectBar2dMap,this.__canvasRef,this.id)}}),this.on("added",()=>{this.__canvasRef=this.canvas,addHandle(this.connectBar2dMap,this.__canvasRef,this.id)}),this.on("modified",ag=>{(ag==null?void 0:ag.action)!=="drag"&&this.type==="text"&&(this.verticalTypeChange(),this.tiggerHandleConcatBarcode2d())}),this.on("changed",()=>{this.type==="text"&&this.verticalTypeChange()}),this.on("moving",()=>{captureTextAnchorPosition(this)}),this.on("rotating",()=>{captureTextAnchorPosition(this)}),this.on("scaling",()=>{this.applyFixedSizeScale(),captureTextAnchorPosition(this)}),this.verticalLayout&&this.setVerticalLayout(!0),this.verticalTypeChange()}getExtraScale(){const eg=this.extraScale;return Number.isFinite(eg)&&eg>0?eg:1}shouldPreserveTextAnchor(eg){return this.textAnchorX===void 0||this.textAnchorY===void 0||!this.textAnchorPosition?!1:typeof eg=="object"&&eg?"scaleX"in eg||"scaleY"in eg?!1:!("left"in eg)&&!("top"in eg)&&["text","width","height","splitByGrapheme","verticalLayout","propsMinHeight"].some(gg=>gg in eg):["text","width","height","splitByGrapheme","verticalLayout","propsMinHeight"].includes(eg)}tiggerHandleConcatBarcode2d(){this.connectBar2dMap&&handleConcatBarcode2d(this.connectBar2dMap,this.canvas)}_wrapText(eg,gg){return!this.verticalLayout||this.splitByGrapheme?super._wrapText(eg,gg):eg.flatMap(ig=>this.graphemeSplit(ig).map(ng=>[ng]))}setVerticalLayout(eg){var ig;const gg=this.textAnchorPosition??this.getPointByOrigin(this.textAnchorX,this.textAnchorY);eg&&!Number.isFinite(this.horizontalLayoutWidth)&&(this.horizontalLayoutWidth=this.width),this.verticalLayout=eg,!eg&&Number.isFinite(this.horizontalLayoutWidth)&&(this.width=this.horizontalLayoutWidth),this.initDimensions(),eg||(this.horizontalLayoutWidth=void 0),gg&&this.setPositionByOrigin(gg,this.textAnchorX,this.textAnchorY),this.setCoords(),(ig=this.canvas)==null||ig.requestRenderAll()}updateInGroup(){reflowTextWithAnchor(this,()=>{this.dirty=!0,this.setCoords();let eg=this.group;for(;eg;)eg.dirty=!0,eg==null||eg.triggerLayout("childUpdate"),eg.setCoords(),eg=eg.group},this.splitByGrapheme)}_calcTextHeight(){const eg=this._textLines&&this._textLines.length||0,gg=this.fontSize*this.lineHeight,ig=(this.padding||0)*2;return eg*gg+ig}verticalTypeChange(){var eg;this.splitByGrapheme&&this.propsMinHeight&&(reflowTextWithAnchor(this,()=>{const gg=Math.max(this.height,this.propsMinHeight);this.height!==gg&&(this.height=gg),this.verticalType==="top"?this._getTopOffset=this._originGetTopOffset:this.verticalType==="vcenter"?this._getTopOffset=()=>{let ig=this._calcTextHeight();return(this.fontSize*this.lineHeight-this.fontSize)/2-ig/2}:this.verticalType==="bottom"&&(this._getTopOffset=()=>{const ig=this._calcTextHeight(),og=Math.max(ig,this.propsMinHeight)-ig;return this._originGetTopOffset()+og})},!0),this.setCoords(),(eg=this.canvas)==null||eg.requestRenderAll())}set(eg,gg){if(eg==="hasSetItalic")return this.hasSetItalic=!1,gg===!0?super.set("fontStyle","italic"):this;if(typeof eg=="object"&&eg){const ng={...eg};ng.left===null&&(ng.left=0),ng.top===null&&(ng.top=0),ng.scaleX===null&&(ng.scaleX=1),ng.scaleY===null&&(ng.scaleY=1),"hasSetItalic"in ng&&(ng.hasSetItalic===!0&&(ng.fontStyle="italic"),delete ng.hasSetItalic),ng.fixedSize&&(ng.arcEnable=!1,this.baseFontSize??(this.baseFontSize=ng.fontSize??this.fontSize)),this.fixedSize&&ng.fontSize!==void 0&&(this.baseFontSize=ng.fontSize);const og=this.shouldPreserveTextAnchor(ng)?reflowTextWithAnchor(this,()=>super.set(ng),this.splitByGrapheme):super.set(ng);return this.fixedSize&&this.updateFixedSize(),("left"in ng||"top"in ng)&&captureTextAnchorPosition(this),og}(eg==="left"||eg==="top")&&gg===null&&(gg=0),(eg==="scaleX"||eg==="scaleY")&&gg===null&&(gg=1),eg==="fixedSize"&&gg&&(this.baseFontSize??(this.baseFontSize=this.fontSize),super.set("arcEnable",!1)),this.fixedSize&&eg==="fontSize"&&gg!==void 0&&(this.baseFontSize=gg),(eg==="fill"||eg==="stroke"||eg==="underline"||eg==="overline"||eg==="linethrough"||eg==="fontWeight"||eg==="fontStyle")&&(this.styles={});const ig=this.shouldPreserveTextAnchor(eg)?reflowTextWithAnchor(this,()=>super.set(eg,gg),this.splitByGrapheme):super.set(eg,gg);return this.fixedSize&&this.updateFixedSize(),(eg==="left"||eg==="top")&&captureTextAnchorPosition(this),ig}getFixedTextWidth(eg){const ig=kn.createCanvasElement().getContext("2d");if(!ig)return 0;const ng=this.fontStyle==="italic"?"italic ":"",og=this.fontWeight==="bold"?"bold ":"";ig.font=`${ng}${og}${eg}px ${this.fontFamily}`;const ag=this.text.replace(/\u00A0/g," "),sg=(this.charSpacing||0)/1e3*eg;return ig.measureText(ag).width+Math.max(0,Array.from(ag).length-1)*sg}getFixedTextEllipsisOffset(eg){const gg=4*o.DPI/72;if(!this.fixedSize||this.splitByGrapheme||this.arcEnable||this.fontSize>gg+.01||this.getFixedTextWidth(gg)<=this.width)return null;const ig=this.text.replace(/\u00A0/g," "),ng="…",og=this.width;eg.save();const ag=eg.measureText(ng).width;let sg=0,Ig="";const Cg=(this.charSpacing||0)/1e3*this.fontSize;for(const lg of ig){const Ag=eg.measureText(lg).width+(Ig?Cg:0),rg=Ig||lg?Cg:0;if(sg+Ag+rg+ag>og)break;Ig+=lg,sg+=Ag}return eg.restore(),sg+(Ig?Cg:0)}_renderText(eg){const gg=this.getFixedTextEllipsisOffset(eg);if(gg===null){super._renderText(eg);return}const ig=this._getLeftOffset(),ng=this._getTopOffset(),og=ig+this._getLineLeftOffset(0),ag=this._getTopOffset()+this.getHeightOfLine(0)/this.lineHeight,sg=eg.textAlign,Ig=eg.fillStyle,Cg=eg.strokeStyle,lg=eg.lineWidth;eg.save(),eg.beginPath(),eg.rect(ig,ng,this.width,this.height),eg.clip(),super._renderText(eg),eg.restore(),eg.save(),eg.textAlign="left",eg.textBaseline="alphabetic",eg.fillStyle=Ig,eg.strokeStyle=Cg,eg.lineWidth=lg;const Ag=og+gg,rg=this.getHeightOfLine(0);eg.fillStyle="#fff",eg.fillRect(Ag,ag-rg/this.lineHeight,ig+this.width-Ag+this.fontSize*2,rg),eg.fillStyle=Ig,this.paintFirst==="stroke"&&this.stroke&&eg.strokeText("…",Ag,ag),eg.fillText("…",Ag,ag),this.paintFirst!=="stroke"&&this.stroke&&eg.strokeText("…",Ag,ag),eg.textAlign=sg,eg.restore()}updateFixedSize(){if(!this.fixedSize||this.splitByGrapheme||this.arcEnable||this.text===void 0)return;const eg=4*o.DPI/72,gg=Math.max(this.baseFontSize??this.fontSize,eg);this.baseFontSize=gg;const ig=this.width;let ng=gg;if(this.getFixedTextWidth(gg)>this.width)if(this.getFixedTextWidth(eg)>this.width)ng=eg;else{let og=eg,ag=gg;for(let sg=0;sg<20;sg+=1){const Ig=(og+ag)/2;this.getFixedTextWidth(Ig)<=this.width?og=Ig:ag=Ig}ng=og}this.fontSize!==ng&&super.set("fontSize",ng),this.width=ig,this.dirty=!0,this.verticalTypeChange()}applyFixedSizeScale(){if(!this.fixedSize)return;const eg=this.getExtraScale(),gg=this.scaleX/eg;gg!==1&&(reflowTextWithAnchor(this,()=>{this.width=Math.max(1,this.width*Math.abs(gg)),this.scaleX=eg}),this.updateFixedSize(),this.setCoords())}set locked(eg){super.locked=eg,this.editable=!eg}get locked(){return super.locked}_measureLine(eg){let gg=this._textLines[eg];return Array.isArray(gg)&&(gg=gg.map(ig=>ig.replace(" "," "))),this._textLines[eg]=gg,super._measureLine(eg)}getStandardSpaceWidth(eg=" ",gg="Arial"){const ng=kn.createCanvasElement().getContext("2d");let og=0;return ng&&(ng.font=`${this.fontSize}px ${gg}`,og=ng.measureText(eg).width),og}getTextWidth(eg="",gg=0,ig="Arial"){const og=kn.createCanvasElement().getContext("2d");let ag=0;return og&&(og.font=`${gg}px ${ig}`,ag=og.measureText(eg).width),ag}getTextHeight(eg="测",gg=!0){const ng=kn.createCanvasElement().getContext("2d");let og=0;if(ng){ng.font=`${this.fontSize}px ${this.fontFamily}`;let ag=ng.measureText(eg);og=ag.fontBoundingBoxAscent+ag.fontBoundingBoxDescent+(gg?Math.trunc(this.fontSize/3):0)}return og*this._textLines.length}_renderChars(eg,gg,ig,ng,og,ag){if(!ig.some(Ig=>myanmarCharacters.test(Ig))||this.charSpacing===0||this.path||!this.isEmptyStyles(ag)||!("letterSpacing"in gg)){super._renderChars(eg,gg,ig,ng,og,ag);return}gg.save();try{gg.letterSpacing=`${this._getWidthOfCharSpacing()}px`,this._renderChar(eg,gg,ag,0,ig.join(""),ng,og)}finally{gg.restore()}}_measureChar(eg,gg,ig,ng){if(eg!==" "&&eg!==" ")return super._measureChar(eg,gg,ig,ng);{const og=this.getStandardSpaceWidth(" ",this.fontFamily);return{width:og,kernedWidth:og}}}parseColor(eg){if(!eg)return null;if(eg.startsWith("#")){let ig=eg.slice(1);ig.length===3&&(ig=ig.split("").map(og=>og+og).join(""));const ng=parseInt(ig,16);return{r:ng>>16&255,g:ng>>8&255,b:ng&255,a:1}}const gg=eg.match(/rgba?\(([^)]+)\)/);if(gg){const[ig,ng,og,ag=1]=gg[1].split(",").map(sg=>Number(sg.trim()));return{r:ig,g:ng,b:og,a:ag}}return null}luminance({r:eg,g:gg,b:ig}){return .2126*eg+.7152*gg+.0722*ig}isDark(eg,gg=40){const ig=this.parseColor(eg);return ig?this.luminance(ig)<=gg:!1}_renderArcText(eg){const gg=this.text.replace(/\u00A0/g," "),ig=this.fontSize,ng=Math.abs(this.arcRadius),og=this.arcRadius>=0;eg.save(),eg.font=`${this.fontStyle==="italic"?"italic ":""}${this.fontWeight==="bold"?"bold ":""}${ig}px ${this.fontFamily}`,eg.fillStyle=this.fill||"#000000",eg.textAlign="center",eg.textBaseline="middle";const ag=(this.charSpacing||0)/1e3*ig,sg=[];let Ig=0;for(const ug of gg){const dg=eg.measureText(ug).width+ag;sg.push(dg),Ig+=dg}const Cg=Ig/ng,lg=ng-ng*Math.cos(Cg/2),Ag=og?ng-lg/2:-(ng-lg/2);let cg=(og?-Math.PI/2:Math.PI/2)-Cg/2;for(let ug=0;ug<gg.length;ug++){const dg=gg[ug],hg=sg[ug]/2,mg=cg+hg/ng,bg=Math.cos(mg)*ng,pg=Math.sin(mg)*ng;eg.save(),eg.translate(bg,Ag+pg),og?eg.rotate(mg+Math.PI/2):eg.rotate(mg-Math.PI/2),eg.fillText(dg,0,0),eg.restore(),cg+=sg[ug]/ng}eg.restore()}_getArcParams(){const eg=this.text.replace(/\u00A0/g," "),gg=this.fontSize,ig=Math.abs(this.arcRadius),ng=this.arcRadius>=0,ag=kn.createCanvasElement().getContext("2d");ag.font=`${this.fontStyle==="italic"?"italic ":""}${this.fontWeight==="bold"?"bold ":""}${gg}px ${this.fontFamily}`;const sg=(this.charSpacing||0)/1e3*gg,Ig=[];let Cg=0;for(const ug of eg){const dg=ag.measureText(ug).width+sg;Ig.push(dg),Cg+=dg}const lg=Cg/ig,Ag=ig-ig*Math.cos(lg/2),rg=ng?ig-Ag/2:-(ig-Ag/2),cg=ng?-Math.PI/2:Math.PI/2;return{text:eg,fontSize:gg,r:ig,bendUp:ng,charWidths:Ig,totalWidth:Cg,totalAngle:lg,sagitta:Ag,circleCenterOffsetY:rg,baseAngle:cg}}_getArcCursorInfo(eg){const{text:gg,r:ig,bendUp:ng,charWidths:og,totalAngle:ag,circleCenterOffsetY:sg,baseAngle:Ig}=this._getArcParams();let Cg=0;for(let hg=0;hg<Math.min(eg,gg.length);hg++)Cg+=og[hg]/ig;const lg=Ig-ag/2+Cg,Ag=Math.cos(lg)*ig,rg=Math.sin(lg)*ig,cg=Ag,ug=sg+rg,dg=ng?lg+Math.PI/2:lg-Math.PI/2;return{x:cg,y:ug,angle:dg}}_calcArcBoundingBox(){const{text:eg,r:gg,bendUp:ig,charWidths:ng,totalAngle:og,circleCenterOffsetY:ag,baseAngle:sg}=this._getArcParams(),Ig=this.fontSize,Cg=Ig/2+4;if(!eg.length)return{w:Ig+Cg*2,h:Ig*1.2+Cg*2};let lg=1/0,Ag=-1/0,rg=1/0,cg=-1/0,ug=sg-og/2;for(let mg=0;mg<eg.length;mg++){const bg=ug,pg=ug+ng[mg]/gg,fg=(bg+pg)/2,wg=Math.cos(fg)*gg,Gg=Math.sin(fg)*gg,Zg=wg,$g=ag+Gg,Bg=ig?fg+Math.PI/2:fg-Math.PI/2,Wg=Math.cos(Bg),yg=Math.sin(Bg),Ng=ng[mg]/2+Cg,vg=Ig/2+Cg,Sg=[{dx:-Ng,dy:-vg},{dx:Ng,dy:-vg},{dx:Ng,dy:vg},{dx:-Ng,dy:vg}];for(const{dx:Vg,dy:Xg}of Sg){const Yg=Zg+Vg*Wg-Xg*yg,Hg=$g+Vg*yg+Xg*Wg;Yg<lg&&(lg=Yg),Yg>Ag&&(Ag=Yg),Hg<rg&&(rg=Hg),Hg>cg&&(cg=Hg)}ug=pg}const dg=Ag-lg,hg=cg-rg;return{w:Math.max(dg,1),h:Math.max(hg,1)}}getMyanmarBottomOverflow(){if(this.fixedHeight&&this.splitByGrapheme)return 0;const eg=this._textLines.length-1,gg=this._textLines[eg];if(!(gg!=null&&gg.some(ag=>myanmarCharacters.test(ag))))return 0;const ng=kn.createCanvasElement().getContext("2d");if(!ng)return 0;ng.font=this._getFontDeclaration(this.getCompleteStyleDeclaration(eg,0));const og=ng.measureText(gg.join("")).actualBoundingBoxDescent;return Number.isFinite(og)?Math.max(0,og):0}initDimensions(){const eg=()=>{if(this.arcEnable&&!this.splitByGrapheme){this._splitText(),this._clearCache(),this.dirty=!0;const gg=this._calcArcBoundingBox();this.width=gg.w,this.height=gg.h}else{const gg=this.fixedSize?this.width:void 0,ig=this.fixedHeight&&this.splitByGrapheme?this.height:void 0;super.initDimensions(),gg!==void 0&&(this.width=gg,this.updateFixedSize()),ig!==void 0?this.height=ig:this.splitByGrapheme&&this.propsMinHeight&&(this.height=Math.max(this.height,this.propsMinHeight)),this.verticalLayout&&!this.splitByGrapheme&&(this.width=this.calcTextWidth()||this.width),this.height+=this.getMyanmarBottomOverflow()}};this.textAnchorPosition&&!this.isNormalizingParagraphScale?reflowTextWithAnchor(this,eg,this.splitByGrapheme):eg()}_render(eg){this.withFixedHeightClip(eg,()=>{this.arcEnable&&!this.splitByGrapheme?this._renderArcText(eg):super._render(eg)})}__getCursorBoundariesOffsets(eg){if(this.arcEnable&&!this.splitByGrapheme){const{charIndex:gg}=this.get2DCursorLocation(eg),ig=this._getArcCursorInfo(gg);return{left:ig.x+this.width/2,top:ig.y+this.height/2}}return super.__getCursorBoundariesOffsets(eg)}_renderCursor(eg,gg,ig){if(this.arcEnable&&!this.splitByGrapheme){const{charIndex:ng}=this.get2DCursorLocation(ig),og=this._getArcCursorInfo(ng),ag=this.fontSize,sg=this.getObjectScaling().x*this.canvas.getZoom(),Ig=this.cursorWidth/sg;eg.save(),eg.fillStyle=this.cursorColor||this.fill||"#000000",eg.globalAlpha=this._currentCursorOpacity,eg.translate(og.x,og.y),eg.rotate(og.angle),eg.fillRect(-Ig/2,-ag/2,Ig,ag),eg.restore()}else this.withFixedHeightClip(eg,()=>{super._renderCursor(eg,gg,ig)})}withFixedHeightClip(eg,gg){if(!this.fixedHeight||!this.splitByGrapheme){gg();return}const ig=-this.height/2,ng=this.getFixedHeightClipBottom();eg.save();try{eg.beginPath(),eg.rect(-this.width/2,ig,this.width,Math.max(0,ng-ig)),eg.clip(),gg()}finally{eg.restore()}}getFixedHeightClipBottom(){const eg=this.height/2;let gg=this._getTopOffset(),ig=-this.height/2;for(let ng=0;ng<this._textLines.length;ng++){const og=this.getHeightOfLine(ng),ag=gg+og/this.lineHeight;if(ag>eg+.01)break;ig=ag,gg+=og}return Math.max(-this.height/2,ig)}getSelectionStartFromPointer(eg){if(this.arcEnable&&!this.splitByGrapheme){const gg=this.canvas.getScenePoint(eg).transform(kn.invertTransform(this.calcTransformMatrix())),{text:ig,r:ng,bendUp:og,charWidths:ag,totalAngle:sg,circleCenterOffsetY:Ig,baseAngle:Cg}=this._getArcParams();let lg=1/0,Ag=0,rg=Cg-sg/2;for(let cg=0;cg<=ig.length;cg++){const ug=rg,dg=Math.cos(ug)*ng,hg=Math.sin(ug)*ng,mg=dg,bg=Ig+hg,pg=gg.x-mg,fg=gg.y-bg,wg=pg*pg+fg*fg;wg<lg&&(lg=wg,Ag=cg),cg<ig.length&&(rg+=ag[cg]/ng)}return Math.min(Ag,this._text.length)}return super.getSelectionStartFromPointer(eg)}_renderSelection(eg,gg,ig){if(this.arcEnable&&!this.splitByGrapheme){const{text:ng,r:og,bendUp:ag,charWidths:sg,totalAngle:Ig,circleCenterOffsetY:Cg,baseAngle:lg}=this._getArcParams(),Ag=this.fontSize,rg=Math.min(gg.selectionStart,gg.selectionEnd),cg=Math.max(gg.selectionStart,gg.selectionEnd);eg.save(),eg.fillStyle=this.selectionColor||"rgba(0,0,255,0.3)";let ug=lg-Ig/2;for(let dg=0;dg<ng.length;dg++){const hg=ug,mg=ug+sg[dg]/og,bg=(hg+mg)/2;if(dg>=rg&&dg<cg){const pg=Math.cos(bg)*og,fg=Math.sin(bg)*og,wg=pg,Gg=Cg+fg,Zg=ag?bg+Math.PI/2:bg-Math.PI/2;eg.save(),eg.translate(wg,Gg),eg.rotate(Zg),eg.fillRect(-sg[dg]/2,-Ag/2,sg[dg],Ag),eg.restore()}ug=mg}eg.restore()}else this.withFixedHeightClip(eg,()=>{super._renderSelection(eg,gg,ig)})}render(eg){if(eg.shadowBlur=0,eg.shadowColor="transparent",eg.imageSmoothingEnabled=!1,eg.textRendering="geometricPrecision",this.isClearCopyTextStyle&&(this.styles={},this.isClearCopyTextStyle=!1),this.splitByGrapheme){let ig=this.width*this.scaleX,ng=this.height*this.scaleY,og=this.calcTextHeight();if(!this.fixedHeight&&ng<og&&(ng=og),this.hasSetSplit=!0,ig!==this.width||ng!==this.height||this.scaleY!==1){this.isNormalizingParagraphScale=!0;try{this.set({width:ig,height:ng,scaleX:1,scaleY:1})}finally{this.isNormalizingParagraphScale=!1}this.height=ng,this.propsMinHeight=this.height,this.setCoords()}}else if(this.arcEnable){this.propsMinHeight=0,this.hasSetSplit&&(this.hasSetSplit=!1);const ig=this._calcArcBoundingBox();(this.width!==ig.w||this.height!==ig.h||this.scaleX!==1||this.scaleY!==1)&&(reflowTextWithAnchor(this,()=>{this.set({width:ig.w,height:ig.h,scaleX:1,scaleY:1})}),this.setCoords()),this._forceClearCache=!0}else{this.propsMinHeight=0,this.hasSetSplit&&(this.hasSetSplit=!1);const ig=this.text.replace(/ /g," ");if(ig!==this.text&&(this.text=ig),this.fixedSize)this.applyFixedSizeScale(),this.updateFixedSize();else{let ng=eg.measureText(this.text);ng.width!==this.width&&this.set({width:ng.width})}this._forceClearCache=!0}const gg=this.getFixedTextEllipsisOffset(eg);this.objectCaching=gg===null&&this.charSpacing<=1e5&&this.text.length<=800,this.dirty=!0,super.render(eg)}toObject(eg){let gg=["propsMinHeight","verticalType","backgroundColor","isBgBlackColor","fromBarCodeID","fromBarCode2dID","connectBar2dMap","arcEnable","arcRadius","fixedSize","verticalLayout","horizontalLayoutWidth","fixedHeight","baseFontSize","extraScale","textAnchorX","textAnchorY","textAnchorPosition"];return super.toObject(eg?[...eg,...gg]:gg)}};aC.type="Text";let AText=aC;tt.setClass(AText);const AC=class AC extends AText{constructor(eg,gg){super("",gg),this.update=!0,this.reviewValueArgs=null,this.toStopDateUpdateBarcode=!1,this.fontSize=ptToPx$1(12),this.increaseYearVal=0,this.increaseMonthVal=0,this.increaseDayVal=0,this.charSpacing=1,this.fontFamily="微软雅黑",console.log("ACounter",eg),this.props=eg,this._props.mode==="3"&&this.updateText(),AC.isMode1Args(this._props.args)&&(this._props.args.nextValue=void 0),this.fontSize=gg.fontSize??this.fontSize,this.charSpacing=gg.charSpacing??this.charSpacing,this.fontFamily=gg.fontFamily??this.fontFamily,this.increaseYearVal=gg.increaseYearVal??this.increaseYearVal,this.increaseMonthVal=gg.increaseMonthVal??this.increaseMonthVal,this.increaseDayVal=gg.increaseDayVal??this.increaseDayVal}render(eg){console.log("_render======"),this.updateText(),super.render(eg)}reviewRecover(){if(this._props.mode==="1"&&AC.isMode1Args(this._props.args)&&this.reviewValueArgs){this._props.args=this.reviewValueArgs,this.reviewValueArgs=null;const eg=this._props.args,gg=formatCounterValue(eg);this.text=(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:""),this.dirty=!1,this.update=!1,this._forceClearCache=!0}}countCurrent(){if(this._props.mode==="1"){const eg=this._props.args;if(!eg.value&&eg.value!==0)return"";const gg=formatCounterValue(eg);return(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:"")}return""}countNext(eg="print"){if(this._props.mode==="1"&&AC.isMode1Args(this._props.args)){const gg=this._props.args;if(!gg.value&&gg.value!==0)return;eg==="review"&&!this.reviewValueArgs&&(this.reviewValueArgs={...gg});const ig=formatCounterValue(gg);this.text=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:"");const ng=getNextCounterValue(gg);ng!==null&&(gg.value=ng,console.log("update value f",gg.value)),this.update=!0,this.dirty=!0,this._forceClearCache=!0}}updateText({isUpdateBarCodeDate:eg=!0}={}){if(this.update&&this._props.mode==="1")if(AC.isMode1Args(this._props.args)){const gg=this._props.args;if(!gg.value&&gg.value!==0)return;const ig=formatCounterValue(gg);this.text=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:""),this.dirty=!0,this._forceClearCache=!0,console.log("updateText",this.text,gg)}else return;else if(this._props.mode==="2")if(AC.isMode2Args(this._props.args)){if(!this.toStopDateUpdateBarcode){const gg=formatDate(this._props.args.format,{years:this.increaseYearVal,months:this.increaseMonthVal,days:this.increaseDayVal});console.log("formatted",this._props.args.format,gg),this.text=gg,this.dirty=!0,this._forceClearCache=!0,eg&&handleConcatBarcode2d(this.connectBar2dMap,this.canvas,!1,{type:this.type,data:this._props.mode})}}else return;else this.update&&this._props.mode==="3"&&AC.isMode3Args(this._props.args)&&(this.text=this._props.args.text,this.dirty=!0,this._forceClearCache=!0);this.set("dirty",!0),this.update&&(this.initDimensions(),this.setCoords(),this.update=!1,this.canvas&&this._props.mode!=="2"&&(handleConcatBarcode2d(this.connectBar2dMap,this.canvas),this.canvas.fire("custom:object:changed",{target:this})))}set(eg,gg){return super.set(eg,gg)}set props(eg){this.editable=eg.mode==="3",this._props=eg,this.dirty=!0,this.update=!0}get props(){return this._props}static isMode1Args(eg){return"value"in eg}static isMode2Args(eg){return"format"in eg}static isMode3Args(eg){return"text"in eg}toObject(eg){AC.isMode3Args(this._props.args)&&(this._props.args.text=this.text);let gg=["connectBar2dMap","increaseYearVal","increaseMonthVal","increaseDayVal"];return super.toObject(eg?[...eg,"_props",...gg]:["_props",...gg])}};AC.type="Counter";let ACounter=AC;ACounter.fromObject=tg=>ACounter._fromObject(tg,{extraParam:"_props"}),tt.setClass(ACounter),tt.setSVGClass(ACounter);const Yc=class Yc extends na{constructor(eg,gg){super(eg,gg),this.imgScaleType="1",this.originRatio=0,this.setGrayFilter=!1,this.isScaleOtherSidedys=!1,this.isSetSharpen=!1,this.imageAlign="leftTop",this.imageAnchorMode="legacy",this.imageAnchorX="left",this.imageAnchorY="top",this.customExportFields={varnish:"none"},this.prevCoordsPoints=null,this.gasolineLayer="none",this.noSetOtherPrevCoordsPoints=!1,this.imageSource="",this.imageSourceType="unsupported",this.databaseImageEnabled=!1,this.customExportFields=gg.customExportFields??this.customExportFields,gg.imgScaleType&&(this.imgScaleType=gg.imgScaleType),gg.setGrayFilter&&(this.setGrayFilter=gg.setGrayFilter),this.isScaleOtherSidedys=gg.isScaleOtherSidedys??this.isScaleOtherSidedys,this.isSetSharpen=gg.isSetSharpen??this.isSetSharpen,this.imageAlign=gg.imageAlign??this.imageAlign,this.imageAnchorMode=gg.imageAnchorMode??this.imageAnchorMode,this.imageAnchorX=gg.imageAnchorX??this.imageAnchorX,this.imageAnchorY=gg.imageAnchorY??this.imageAnchorY,this.prevCoordsPoints=gg.prevCoordsPoints??this.prevCoordsPoints,this.gasolineLayer=gg.gasolineLayer??this.gasolineLayer,this.imageSource=gg.imageSource??this.imageSource,this.imageSourceType=gg.imageSourceType??this.imageSourceType,this.databaseImageEnabled=gg.databaseImageEnabled??this.databaseImageEnabled}async setSrc(eg,gg){const ig=this.getScaledWidth(),ng=this.getScaledHeight();await super.setSrc(eg,gg),(gg==null?void 0:gg.imageSource)!==void 0&&(this.imageSource=gg.imageSource);const og=this._element,ag=og.naturalWidth||og.width,sg=og.naturalHeight||og.height,Ig=ag/sg;let Cg=this.imgScaleType;(Cg==="2"||Cg==="3")&&(Cg=Ig>1?"3":(Ig<1,"2"));let lg=ig,Ag=ng;return Cg==="2"?lg=ng*Ig:Cg==="3"&&(Ag=ig/Ig),this.set({width:lg,height:Ag,scaleX:1,scaleY:1,imgScaleType:Cg,isScaleOtherSidedys:!1}),this.setCoords(),this}refreshAlignCoords(eg=203){var gg;if(this.prevCoordsPoints){this.setCoords();let ig=o.DPI/eg;const{bl:ng,br:og,tl:ag,tr:sg}=this.aCoords,{bl:Ig,br:Cg,tl:lg,tr:Ag}=this.prevCoordsPoints;Ig.x=Ig.x*ig,Ig.y=Ig.y*ig,Cg.x=Cg.x*ig,Cg.y=Cg.y*ig,lg.x=lg.x*ig,lg.y=lg.y*ig,Ag.x=Ag.x*ig,Ag.y=Ag.y*ig;const rg={x:0,y:0};switch(this.imageAlign){case"leftTop":break;case"leftBottom":rg.x=Ig.x-ng.x,rg.y=Ig.y-ng.y;break;case"leftCenter":let cg={x:ng.x,y:(ng.y-ag.y)/2},ug={x:Ig.x,y:(Ig.y-lg.y)/2};rg.x=ug.x-cg.x,rg.y=ug.y-cg.y;break;case"topCenter":let dg={x:(sg.x-ag.x)/2,y:sg.y},hg={x:(Ag.x-lg.x)/2,y:Ag.y};rg.x=hg.x-dg.x,rg.y=hg.y-dg.y;break;case"rightCenter":let mg={x:sg.x,y:(og.y-sg.y)/2},bg={x:Ag.x,y:(Cg.y-Ag.y)/2};rg.x=bg.x-mg.x,rg.y=bg.y-mg.y;break;case"bottomCenter":let pg={x:(og.x-ng.x)/2,y:og.y},fg={x:(Cg.x-Ig.x)/2,y:Cg.y};rg.x=fg.x-pg.x,rg.y=fg.y-pg.y;break;case"center":let wg={x:(sg.x-ag.x)/2,y:(ng.y-ag.y)/2},Gg={x:(Ag.x-lg.x)/2,y:(Ig.y-lg.y)/2};rg.x=Gg.x-wg.x,rg.y=Gg.y-wg.y;break;case"rightTop":rg.x=Ag.x-sg.x,rg.y=Ag.y-sg.y;break;case"rightBottom":rg.x=Cg.x-og.x,rg.y=Cg.y-og.y;break}this.set({left:this.left+rg.x,top:this.top+rg.y}),this.setCoords(),(gg=this.canvas)==null||gg.requestRenderAll()}}_render(eg){const gg=this._element;if(!gg)return;const ig=this._filterScalingX,ng=this._filterScalingY,og=Math.max(this.cropX,0),ag=Math.max(this.cropY,0),sg=gg.naturalWidth||gg.width,Ig=gg.naturalHeight||gg.height,Cg=og*ig,lg=ag*ng;this.originRatio=sg/Ig,eg.save(),eg.beginPath(),eg.rect(-this.width/2,-this.height/2,this.width,this.height),eg.clip(),this.fill&&(eg.fillStyle=this.fill,eg.fillRect(-this.width/2,-this.height/2,this.width,this.height)),this.stroke&&this.strokeWidth&&(eg.strokeStyle=this.stroke,eg.lineWidth=this.strokeWidth,withObjectStrokeDash(eg,this,()=>eg.strokeRect(-this.width/2,-this.height/2,this.width,this.height))),eg.imageSmoothingEnabled=!0,eg.imageSmoothingQuality="high",eg.drawImage(gg,Cg,lg,sg,Ig,-this.width/2,-this.height/2,this.width,this.height),eg.restore();const Ag=this.filters.findIndex(rg=>rg.type==="Grayscale");if(this.setGrayFilter&&Ag<0){const rg=new bh.Grayscale;this.filters.push(rg)}else!this.setGrayFilter&&Ag>=0&&this.filters.splice(Ag,1);this.applyFilters(),this.canvas.leRenderEnv!=="transform"&&!this.noSetOtherPrevCoordsPoints&&(this.prevCoordsPoints=this.aCoords)}set(eg,gg){return super.set(eg,gg)}toObject(eg){let gg=["imgScaleType","setGrayFilter","isScaleOtherSidedys","isSetSharpen","imageAlign","imageAnchorMode","imageAnchorX","imageAnchorY","prevCoordsPoints","gasolineLayer","imageSource","imageSourceType","databaseImageEnabled","databaseImageFrame","databaseSheet","databaseColumn","databaseIndex"];return super.toObject(eg?[...eg,...gg]:gg)}fromObject(eg){return Yc._fromObject(eg)}};Yc.type="Image";let AImage=Yc;tt.setClass(AImage),tt.setSVGClass(AImage);const LEGACY_IMAGE_ANCHORS={leftTop:{x:"left",y:"top"},topCenter:{x:"center",y:"top"},rightTop:{x:"right",y:"top"},leftCenter:{x:"left",y:"center"},center:{x:"center",y:"center"},rightCenter:{x:"right",y:"center"},leftBottom:{x:"left",y:"bottom"},bottomCenter:{x:"center",y:"bottom"},rightBottom:{x:"right",y:"bottom"}},isAnchorX=tg=>tg==="left"||tg==="center"||tg==="right",isAnchorY=tg=>tg==="top"||tg==="center"||tg==="bottom";function imageAlignToOrigin(tg){return LEGACY_IMAGE_ANCHORS[String(tg)]||LEGACY_IMAGE_ANCHORS.leftTop}function originToImageAlign(tg){const eg=Object.entries(LEGACY_IMAGE_ANCHORS).find(([,gg])=>gg.x===tg.x&&gg.y===tg.y);return(eg==null?void 0:eg[0])||"leftTop"}function isNativeImageAnchor(tg){return((tg==null?void 0:tg.imageAnchorMode)==="origin"||(tg==null?void 0:tg.imageAnchorMode)==="metadata")&&isAnchorX(tg.imageAnchorX)&&isAnchorY(tg.imageAnchorY)}function getImageAnchor(tg){return isNativeImageAnchor(tg)?{x:tg.imageAnchorX,y:tg.imageAnchorY}:imageAlignToOrigin(tg==null?void 0:tg.imageAlign)}function captureObjectAnchor(tg,eg=getImageAnchor(tg)){var gg;return(gg=tg==null?void 0:tg.getPointByOrigin)==null?void 0:gg.call(tg,eg.x,eg.y)}function setObjectAnchor(tg,eg,gg){var ng;const ig=captureObjectAnchor(tg,{x:eg,y:gg});return tg.set({imageAnchorMode:"metadata",imageAnchorX:eg,imageAnchorY:gg,imageAlign:originToImageAlign({x:eg,y:gg})}),(ng=tg.canvas)==null||ng.fire("custom:object:history",{target:tg,action:"history:update"}),ig}const cd=class cd extends ho{constructor(){super(...arguments),this.perPixelTargetFind=!0}_render(eg){eg.beginPath();const{width:gg,height:ig}=this,ng=gg/2,og=ig/2;eg.ellipse(0,0,ng,og,0,0,Math.PI*2),this._renderPaintInOrder(eg)}set(eg,gg){return super.set(eg,gg)}};cd.type="Circle";let ACircle=cd;tt.setClass(ACircle);class ARect extends Er{constructor(eg){super(eg),this.perPixelTargetFind=!0}set(eg,gg){return super.set(eg,gg)}}tt.setClass(ARect);class ATriangle extends vo{constructor(eg={}){super(eg),this.perPixelTargetFind=!0}set(eg,gg){return super.set(eg,gg)}}tt.setClass(ATriangle),tt.setSVGClass(ATriangle);class ALine extends mo{constructor(eg,gg={}){super(eg,gg),this.perPixelTargetFind=!0}set(eg,gg){return super.set(eg,gg)}}tt.setClass(ALine);const su=class su extends na{constructor(){super(...arguments),this.hasControls=!1,this.selectable=!1,this.evented=!0,this.hoverCursor="pointer"}_renderFill(eg){const gg=this._element;if(!gg)return;const ig=this._filterScalingX,ng=this._filterScalingY,og=this.width,ag=this.height,sg=Math.max(this.cropX,0),Ig=Math.max(this.cropY,0),Cg=gg.naturalWidth||gg.width,lg=gg.naturalHeight||gg.height,Ag=sg*ig,rg=Ig*ng,cg=-og/2,ug=-ag/2;gg&&eg.drawImage(gg,Ag,rg,Cg,lg,cg,ug,og,ag)}};su.type="Rfid";let RfidIcon=su;tt.setClass(RfidIcon),tt.setSVGClass(RfidIcon);const Iu=class Iu extends No{constructor(eg,gg){if(super(eg,gg),this.hasSetSplit=!1,this.objectCaching=!0,this.hasSetItalic=!1,this.isClearCopyTextStyle=!1,this.propsMinHeight=0,this.splitByGrapheme=!0,this.customExportFields={varnish:"none"},this.fontFamily="微软雅黑",this._renderTimer=null,this.verticalType="top",this.currentFontLevel=0,this.baseFontSize=118,this.splitByGrapheme=!0,this._originGetTopOffset=this._getTopOffset?this._getTopOffset.bind(this):()=>0,this.fontFamily=gg.fontFamily??this.fontFamily,gg.hasSetItalic&&gg.fontStyle!=="italic"&&(this.fontStyle="italic",gg.skewX===-15&&(this.skewX=0)),gg.propsMinHeight){this.propsMinHeight=gg.propsMinHeight;let ig=Math.max(this.height,this.propsMinHeight);this.height=ig}gg.verticalType&&(this.verticalType=gg.verticalType),this.customExportFields=gg.customExportFields??this.customExportFields,this.on("modified",()=>{this.verticalTypeChange()}),this.on("changed",()=>{this.verticalTypeChange()}),this.verticalTypeChange()}_calcTextHeight(){const eg=this._textLines&&this._textLines.length||0,gg=this.fontSize*this.lineHeight,ig=(this.padding||0)*2;return eg*gg+ig}_handleDotLineBreak(eg,gg){var ig;if(eg.includes("·")){const ng=eg.indexOf("·"),og=/[\u4e00-\u9fa5]/g,ag=((ig=eg.substring(ng+1).match(og))==null?void 0:ig.length)||0;if(this.charSpacing=1,ng==2&&(ag==2||ag==1))return[eg];let sg=0;if(ag>=11||ng>=10?sg=5:ag>=10||ng>=9?sg=4:ag>=9||ng>=8?sg=3:ag>=8||ng>=7?sg=2:ag>=7||ng>=6?sg=1:sg=0,sg!==this.currentFontLevel){switch(sg){case 5:this.fontSize=64;break;case 4:this.fontSize=70;break;case 3:this.fontSize=78;break;case 2:this.fontSize=88;break;case 1:this.fontSize=100;break;case 0:this.fontSize=this.baseFontSize??118;break}this.currentFontLevel=sg}const Ig=eg.substring(0,ng+1),Cg=eg.substring(ng+1).trim();return Cg?[Ig,Cg]:[eg]}else eg.length<=4?(this.fontSize=this.baseFontSize??118,this.currentFontLevel=0,eg.length===2?this.charSpacing=800:eg.length===3?this.charSpacing=300:eg.length===4&&(this.charSpacing=300)):(this.charSpacing=1,this.fontSize=this.baseFontSize,this.currentFontLevel=0);return[...gg]}_wrapText(eg,gg){if(this.isClearCopyTextStyle&&(this.styles={},this.verticalTypeChange()),this.splitByGrapheme){const ig=o.DPI??96,ag=3*.393701*ig,sg=this.text;let Ig=[...eg];return Ig=this._handleDotLineBreak(sg,eg),this.width!==ag&&(this.width=ag,this.setCoords(),this._renderTimer&&clearTimeout(this._renderTimer),this._renderTimer=setTimeout(()=>{var Cg;(Cg=this.canvas)==null||Cg.requestRenderAll()},0)),super._wrapText(Ig,ag)}else return super._wrapText(eg,gg)}verticalTypeChange(){var gg;if(!this.splitByGrapheme||!this.propsMinHeight)return;const eg=Math.max(this._calcTextHeight(),this.propsMinHeight);this.height!==eg&&(this.height=eg),this.verticalType==="top"?this._getTopOffset=this._originGetTopOffset:this.verticalType==="vcenter"?this._getTopOffset=()=>{let ig=this._calcTextHeight();return(this.fontSize*this.lineHeight-this.fontSize)/2-ig/2}:this.verticalType==="bottom"&&(this._getTopOffset=()=>{const ig=this._calcTextHeight(),og=Math.max(ig,this.propsMinHeight)-ig;return this._originGetTopOffset()+og}),this.setCoords(),(gg=this.canvas)==null||gg.requestRenderAll()}set(eg,gg){if(eg==="hasSetItalic")return this.hasSetItalic=!1,gg===!0?super.set("fontStyle","italic"):this;if(typeof eg=="object"&&eg){const ig={...eg};return"hasSetItalic"in ig&&(ig.hasSetItalic===!0&&(ig.fontStyle="italic"),delete ig.hasSetItalic),super.set(ig)}return(eg==="fill"||eg==="stroke"||eg==="underline"||eg==="overline"||eg==="linethrough"||eg==="fontWeight"||eg==="fontStyle")&&(this.styles={}),super.set(eg,gg)}set locked(eg){super.locked=eg,this.editable=!eg}get locked(){return super.locked}_measureLine(eg){let gg=this._textLines[eg];return Array.isArray(gg)&&(gg=gg.map(ig=>ig.replace(" "," "))),this._textLines[eg]=gg,super._measureLine(eg)}getStandardSpaceWidth(eg=" ",gg="Arial"){const ng=kn.createCanvasElement().getContext("2d");let og=0;return ng&&(ng.font=`${this.fontSize}px ${gg}`,og=ng.measureText(eg).width),og}getTextWidth(eg="",gg=0,ig="Arial"){const og=kn.createCanvasElement().getContext("2d");let ag=0;return og&&(og.font=`${gg}px ${ig}`,ag=og.measureText(eg).width),ag}getTextHeight(eg="测",gg=!0){const ng=kn.createCanvasElement().getContext("2d");let og=0;if(ng){ng.font=`${this.fontSize}px ${this.fontFamily}`;let ag=ng.measureText(eg);og=ag.fontBoundingBoxAscent+ag.fontBoundingBoxDescent+(gg?Math.trunc(this.fontSize/3):0)}return og*this._textLines.length}_measureChar(eg,gg,ig,ng){if(eg!==" "&&eg!==" ")return super._measureChar(eg,gg,ig,ng);{const og=this.getStandardSpaceWidth(" ",this.fontFamily);return{width:og,kernedWidth:og}}}render(eg){if(eg.shadowBlur=0,eg.shadowColor="transparent",eg.imageSmoothingEnabled=!1,this.isClearCopyTextStyle&&(this.styles={}),this.splitByGrapheme){let gg=this.width*this.scaleX,ig=this.height*this.scaleY,ng=this.getTextHeight();ig<ng&&(ig=ng),this.hasSetSplit=!0,(gg!==this.width||ig!==this.height||this.scaleY!==1)&&(this.set({width:gg,height:ig,scaleX:1,scaleY:1}),this.height=ig,this.propsMinHeight=this.height,this.setCoords())}else{this.propsMinHeight=0,this.hasSetSplit&&(this.hasSetSplit=!1);const gg=this.text.replace(/ /g," ");gg!==this.text&&(this.text=gg);let ig=eg.measureText(this.text);ig.width!==this.width&&this.set({width:ig.width}),this._forceClearCache=!0}this.charSpacing>1e5?this.objectCaching=!1:this.objectCaching=!0,this.dirty=!0,super.render(eg)}toObject(eg){let gg=["propsMinHeight","verticalType","customExportFields"];return super.toObject(eg?[...eg,...gg]:gg)}};Iu.type="TextName";let ATextName=Iu;tt.setClass(ATextName);const lu=class lu extends Er{constructor(eg={}){const{rows:gg,columns:ig,tableTexts:ng,tableCellStyles:og,tableCellBorders:ag,tableCellSpans:sg,columnWidths:Ig,rowHeights:Cg,fontSize:lg,fontFamily:Ag,fontWeight:rg,fontStyle:cg,underline:ug,linethrough:dg,charSpacing:hg,lineHeight:mg,textAlign:bg,verticalType:pg,...fg}=eg;super({fill:"#000000FF",backgroundColor:"#FFFFFF00",stroke:"#000000",strokeWidth:1,...fg}),this.perPixelTargetFind=!0,this.rows=2,this.columns=2,this.tableTexts=[],this.tableCellStyles=[],this.tableCellBorders=[],this.tableCellSpans=[],this.columnWidths=[],this.rowHeights=[],this.fontSize=24,this.fontFamily="微软雅黑",this.fontWeight="normal",this.fontStyle="normal",this.underline=!1,this.linethrough=!1,this.charSpacing=0,this.lineHeight=1.2,this.textAlign="center",this.verticalType="vcenter",this.strokeUniform=!0,this.selectedCellIndex=null,this.editingTextarea=null,this.keepEditingOnNextBlur=!1,this.editingPointerDownHandler=null,this.editingViewportChangeHandler=null,this.editingResizeObserver=null,this.editingUpdateFrame=0,this.rows=this.normalizeCount(gg,2),this.columns=this.normalizeCount(ig,2),this.tableTexts=[...ng||[]],this.tableCellStyles=[...og||[]],this.tableCellBorders=[...ag||[]],this.tableCellSpans=[...sg||[]],this.columnWidths=[...Ig||[]],this.rowHeights=[...Cg||[]],this.syncTextCount(),this.applyTextOptions({fontSize:lg,fontFamily:Ag,fontWeight:rg,fontStyle:cg,underline:ug,linethrough:dg,charSpacing:hg,lineHeight:mg,textAlign:bg,verticalType:pg}),this.on("scaling",wg=>this.resizeDuringScaling(wg)),this.on("modified",()=>{this.scaleAnchor=void 0}),this.on("removed",()=>{this.removeEditingTextarea(!1)})}get isEditing(){return this.editingTextarea!==null}set(eg,gg){var ng,og,ag,sg,Ig,Cg,lg;if(typeof eg=="object"&&eg)return Object.keys(eg).forEach(Ag=>this.set(Ag,eg[Ag])),this;if(eg==="rows"||eg==="columns"){this.removeEditingTextarea(!0);const Ag=this.normalizeCount(gg,eg==="rows"?this.rows:this.columns),rg=this.rows,cg=this.columns,ug=eg==="rows"?Ag:this.rows,dg=eg==="columns"?Ag:this.columns;return this.resizeByCountChange(eg,Ag),this.remapCellData(rg,cg,ug,dg),this[eg]=Ag,this.syncTextCount(),this.selectedCellIndex!==null&&this.selectedCellIndex>=this.rows*this.columns&&(this.selectedCellIndex=null),this.dirty=!0,this.setCoords(),(ng=this.canvas)==null||ng.requestRenderAll(),this}if(eg==="tableTexts")return this.tableTexts=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(og=this.canvas)==null||og.requestRenderAll(),this;if(eg==="tableCellStyles")return this.tableCellStyles=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(ag=this.canvas)==null||ag.requestRenderAll(),this;if(eg==="tableCellBorders")return this.tableCellBorders=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(sg=this.canvas)==null||sg.requestRenderAll(),this;if(eg==="tableCellSpans")return this.tableCellSpans=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(Ig=this.canvas)==null||Ig.requestRenderAll(),this;if(eg==="columnWidths"||eg==="rowHeights")return this[eg]=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(Cg=this.canvas)==null||Cg.requestRenderAll(),this;const ig=super.set(eg,gg);return this.isTextStyleKey(eg)&&(this.dirty=!0,(lg=this.canvas)==null||lg.requestRenderAll(),this.updateEditingTextarea()),ig}toObject(eg){const gg=["rows","columns","tableTexts","tableCellStyles","tableCellBorders","tableCellSpans","columnWidths","rowHeights","fontSize","fontFamily","fontWeight","fontStyle","underline","linethrough","charSpacing","lineHeight","textAlign","verticalType","backgroundColor"];return super.toObject(eg?[...eg,...gg]:gg)}normalizeCount(eg,gg){const ig=Math.floor(Number(eg));return Number.isFinite(ig)?Math.min(Math.max(ig,1),50):gg}resizeDuringScaling(eg){const gg=eg==null?void 0:eg.transform;if(!gg)return;const ig=gg.corner,ng=["ml","tl","bl"].includes(ig),og=["mr","tr","br"].includes(ig),ag=["mt","tl","tr"].includes(ig),sg=["mb","bl","br"].includes(ig);if(!this.scaleAnchor){const Ag=ng?"right":og?"left":"center",rg=ag?"bottom":sg?"top":"center";this.scaleAnchor={point:this.getPointByOrigin(Ag,rg),originX:Ag,originY:rg}}this.width=Math.max(1,(this.width||1)*Math.abs(this.scaleX||1)),this.height=Math.max(1,(this.height||1)*Math.abs(this.scaleY||1)),this.scaleX=1,this.scaleY=1;const{point:Ig,originX:Cg,originY:lg}=this.scaleAnchor;if(this.group){const Ag=kn.invertTransform(this.group.calcTransformMatrix()),rg=kn.transformPoint(Ig,Ag);this.setPositionByOrigin(rg,Cg,lg)}else this.setPositionByOrigin(Ig,Cg,lg);this.updateEditingTextarea(),this.dirty=!0,this.setCoords()}resizeByCountChange(eg,gg){if(eg==="columns"){const ig=this.width||0,ng=Array.from({length:this.columns},(Cg,lg)=>(this.columnWidths[lg]||1/this.columns)*ig),og=ng.reduce((Cg,lg)=>Cg+lg,0)/(ng.length||1)||ig/(this.columns||1)||1,ag=Array.from({length:gg},(Cg,lg)=>lg<ng.length?ng[lg]:og),sg=ag.reduce((Cg,lg)=>Cg+lg,0);this.width=sg;const Ig=sg||1;this.columnWidths=ag.map(Cg=>Cg/Ig)}if(eg==="rows"){const ig=this.height||0,ng=Array.from({length:this.rows},(Cg,lg)=>(this.rowHeights[lg]||1/this.rows)*ig),og=ng.reduce((Cg,lg)=>Cg+lg,0)/(ng.length||1)||ig/(this.rows||1)||1,ag=Array.from({length:gg},(Cg,lg)=>lg<ng.length?ng[lg]:og),sg=ag.reduce((Cg,lg)=>Cg+lg,0);this.height=sg;const Ig=sg||1;this.rowHeights=ag.map(Cg=>Cg/Ig)}}remapCellData(eg,gg,ig,ng){if(eg===ig&&gg===ng)return;const og=Array.isArray(this.tableTexts)?[...this.tableTexts]:[],ag=Array.isArray(this.tableCellStyles)?[...this.tableCellStyles]:[],sg=Array.isArray(this.tableCellBorders)?[...this.tableCellBorders]:[],Ig=Array.isArray(this.tableCellSpans)?[...this.tableCellSpans]:[],Cg=ig*ng;this.tableTexts=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;return rg>=eg||cg>=gg?"":og[rg*gg+cg]||""}),this.tableCellStyles=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;return rg>=eg||cg>=gg?{}:{...ag[rg*gg+cg]||{}}}),this.tableCellBorders=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;return rg>=eg||cg>=gg?{}:{...sg[rg*gg+cg]||{}}}),this.tableCellSpans=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;if(rg>=eg||cg>=gg)return this.createDefaultCellSpan();const ug=Ig[rg*gg+cg]||{},dg=Number(ug.masterIndex),hg=Number.isFinite(dg)&&dg>=0?this.mapOldCellIndex(dg,gg,ig,ng):null;return{...this.createDefaultCellSpan(),...ug,masterIndex:hg}}),this.selectedCellIndex!==null&&(this.selectedCellIndex=this.mapOldCellIndex(this.selectedCellIndex,gg,ig,ng))}mapOldCellIndex(eg,gg,ig,ng){const og=Math.floor(eg/gg),ag=eg%gg;return og>=ig||ag>=ng?null:og*ng+ag}createDefaultCellSpan(){return{rowSpan:1,colSpan:1,hidden:!1,masterIndex:null}}getCellData(eg){return{text:this.tableTexts[eg]||"",style:{...this.tableCellStyles[eg]||{}},border:{...this.tableCellBorders[eg]||{}},span:{...this.createDefaultCellSpan(),...this.tableCellSpans[eg]||{}}}}applyStructureChange(eg,gg,ig,ng,og,ag,sg,Ig,Cg){var ug,dg;const lg=this.getPointByOrigin(Ig,Cg),Ag=eg*gg,rg=new Map;for(let hg=0;hg<eg;hg++)for(let mg=0;mg<gg;mg++){const bg=ig(hg,mg);bg!==null&&rg.set(bg,hg*gg+mg)}const cg=Array.from({length:Ag},(hg,mg)=>{const bg=Math.floor(mg/gg),pg=mg%gg,fg=ig(bg,pg);if(fg===null)return null;const wg=this.getCellData(fg),Gg=Number(wg.span.masterIndex);return wg.span.masterIndex=Number.isFinite(Gg)&&Gg>=0?rg.get(Gg)??null:null,wg});if(this.rows=eg,this.columns=gg,this.width=ag.reduce((hg,mg)=>hg+mg,0),this.height=sg.reduce((hg,mg)=>hg+mg,0),this.columnWidths=this.normalizeRatios(ag,gg),this.rowHeights=this.normalizeRatios(sg,eg),this.tableTexts=cg.map(hg=>(hg==null?void 0:hg.text)||""),this.tableCellStyles=cg.map(hg=>(hg==null?void 0:hg.style)||{}),this.tableCellBorders=cg.map(hg=>(hg==null?void 0:hg.border)||{}),this.tableCellSpans=cg.map(hg=>(hg==null?void 0:hg.span)||this.createDefaultCellSpan()),this.selectedCellIndex=Math.min(ng,eg-1)*gg+Math.min(og,gg-1),this.group){const hg=kn.invertTransform(this.group.calcTransformMatrix());this.setPositionByOrigin(kn.transformPoint(lg,hg),Ig,Cg)}else this.setPositionByOrigin(lg,Ig,Cg);this.syncTextCount(),this.dirty=!0,this.setCoords(),(ug=this.canvas)==null||ug.requestRenderAll(),(dg=this.canvas)==null||dg.fire("object:modified",{target:this,action:"modifyprops"})}insertColumn(eg,gg="right"){if(this.columns>=50)return;const ig=!!this.editingTextarea,ng=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const og=Math.min(Math.max(eg,0),this.columns),ag=this.columns,sg=this.columnWidths.map(Ag=>Ag*(this.width||0)),Ig=Math.min(og,ag-1),Cg=sg[Ig]||(this.width||1)/Math.max(ag,1);sg.splice(og,0,Cg);const lg=this.rowHeights.map(Ag=>Ag*(this.height||0));this.applyStructureChange(this.rows,ag+1,(Ag,rg)=>{if(rg===og)return null;const cg=rg>og?rg-1:rg;return Ag*ag+cg},Math.floor(ng/ag),ng%ag+(gg==="left"?1:0),sg,lg,gg==="left"?"right":"left","top"),this.restoreEditingTextareaAfterStructureChange(ig)}insertRow(eg,gg="down"){if(this.rows>=50)return;const ig=!!this.editingTextarea,ng=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const og=Math.min(Math.max(eg,0),this.rows),ag=this.rows,sg=this.columns,Ig=this.rowHeights.map(rg=>rg*(this.height||0)),Cg=Math.min(og,ag-1),lg=Ig[Cg]||(this.height||1)/Math.max(ag,1);Ig.splice(og,0,lg);const Ag=this.columnWidths.map(rg=>rg*(this.width||0));this.applyStructureChange(ag+1,sg,(rg,cg)=>rg===og?null:(rg>og?rg-1:rg)*sg+cg,Math.floor(ng/sg)+(gg==="up"?1:0),ng%sg,Ag,Ig,"left",gg==="up"?"bottom":"top"),this.restoreEditingTextareaAfterStructureChange(ig)}deleteColumn(eg){if(this.columns<=1)return;const gg=!!this.editingTextarea,ig=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const ng=Math.min(Math.max(eg,0),this.columns-1),og=this.columns,ag=this.columnWidths.map(Ig=>Ig*(this.width||0));ag.splice(ng,1);const sg=this.rowHeights.map(Ig=>Ig*(this.height||0));this.applyStructureChange(this.rows,og-1,(Ig,Cg)=>{const lg=Cg>=ng?Cg+1:Cg;return Ig*og+lg},Math.floor(ig/og),Math.min(ng,og-2),ag,sg,ng===0?"right":"left","top"),this.restoreEditingTextareaAfterStructureChange(gg)}deleteRow(eg){if(this.rows<=1)return;const gg=!!this.editingTextarea,ig=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const ng=Math.min(Math.max(eg,0),this.rows-1),og=this.rows,ag=this.columns,sg=this.rowHeights.map(Cg=>Cg*(this.height||0));sg.splice(ng,1);const Ig=this.columnWidths.map(Cg=>Cg*(this.width||0));this.applyStructureChange(og-1,ag,(Cg,lg)=>(Cg>=ng?Cg+1:Cg)*ag+lg,Math.min(ng,og-2),ig%ag,Ig,sg,"left",ng===0?"bottom":"top"),this.restoreEditingTextareaAfterStructureChange(gg)}restoreEditingTextareaAfterStructureChange(eg){if(!eg||this.selectedCellIndex===null)return;const gg=this.selectedCellIndex;requestAnimationFrame(()=>{this.selectedCellIndex!==gg||this.editingTextarea||this.startCellEditing(gg)})}syncTextCount(){Array.isArray(this.tableTexts)||(this.tableTexts=[]);const eg=this.rows*this.columns;for(this.tableTexts.length>eg&&(this.tableTexts=this.tableTexts.slice(0,eg));this.tableTexts.length<eg;)this.tableTexts.push("");for(Array.isArray(this.tableCellStyles)||(this.tableCellStyles=[]),this.tableCellStyles.length>eg&&(this.tableCellStyles=this.tableCellStyles.slice(0,eg));this.tableCellStyles.length<eg;)this.tableCellStyles.push({});for(Array.isArray(this.tableCellBorders)||(this.tableCellBorders=[]),this.tableCellBorders.length>eg&&(this.tableCellBorders=this.tableCellBorders.slice(0,eg));this.tableCellBorders.length<eg;)this.tableCellBorders.push({});for(Array.isArray(this.tableCellSpans)||(this.tableCellSpans=[]),this.tableCellSpans.length>eg&&(this.tableCellSpans=this.tableCellSpans.slice(0,eg));this.tableCellSpans.length<eg;)this.tableCellSpans.push(this.createDefaultCellSpan());this.syncDimensionRatios(),this.selectedCellIndex!==null&&this.selectedCellIndex>=eg&&(this.selectedCellIndex=null)}syncDimensionRatios(){this.columnWidths=this.normalizeRatios(this.columnWidths,this.columns),this.rowHeights=this.normalizeRatios(this.rowHeights,this.rows)}normalizeRatios(eg,gg){const ig=Array.from({length:gg},(og,ag)=>{const sg=Number(eg[ag]);return Number.isFinite(sg)&&sg>0?sg:1}),ng=ig.reduce((og,ag)=>og+ag,0)||gg||1;return ig.map(og=>og/ng)}applyTextOptions(eg){["fontSize","fontFamily","fontWeight","fontStyle","underline","linethrough","charSpacing","lineHeight","textAlign","verticalType"].forEach(ig=>{eg[ig]!==void 0&&(this[ig]=eg[ig])})}isTextStyleKey(eg){return["fontSize","fontFamily","fontWeight","fontStyle","underline","linethrough","charSpacing","lineHeight","textAlign","verticalType","fill"].includes(eg)}getTextX(eg,gg,ig){return this.getTextXByAlign(eg,gg,ig,this.textAlign)}getTextXByAlign(eg,gg,ig,ng="center"){return ng==="left"?eg+ig:ng==="right"?eg+gg-ig:eg+gg/2}getTextStartYByVertical(eg,gg,ig,ng,og,ag="vcenter"){return ag==="top"?eg+ig+og/2:ag==="bottom"?eg+gg-ig-ng+og/2:eg+gg/2-ng/2+og/2}getTextareaVerticalPadding(eg,gg,ig){if(eg.verticalType==="top")return{top:0,bottom:0};const ng=Math.max(gg-ig,0);return eg.verticalType==="bottom"?{top:ng,bottom:0}:{top:ng/2,bottom:0}}getDefaultCellStyle(){return{fontSize:Number(this.fontSize)||12,fontFamily:this.fontFamily||"微软雅黑",fill:this.fill||"#000000",fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",underline:!!this.underline,linethrough:!!this.linethrough,charSpacing:Number(this.charSpacing)||0,lineHeight:Number(this.lineHeight)||1.2,textAlign:this.textAlign||"center",verticalType:this.verticalType||"vcenter"}}getCellStyle(eg){return this.syncTextCount(),{...this.getDefaultCellStyle(),...this.tableCellStyles[eg]||{}}}setCellStyle(eg,gg){var ig,ng;this.syncTextCount(),!(eg<0||eg>=this.rows*this.columns)&&(this.tableCellStyles[eg]={...this.tableCellStyles[eg]||{},...gg},this.updateEditingTextarea(eg),this.dirty=!0,(ig=this.canvas)==null||ig.requestRenderAll(),(ng=this.canvas)==null||ng.fire("object:modified",{target:this}))}getCellBorderStyle(eg){return this.syncTextCount(),{top:"solid",right:"solid",bottom:"solid",left:"solid",...this.tableCellBorders[eg]||{}}}setCellBorderStyle(eg,gg){var ig,ng;this.syncTextCount(),!(eg<0||eg>=this.rows*this.columns)&&(this.tableCellBorders[eg]={...this.tableCellBorders[eg]||{},...gg},this.dirty=!0,(ig=this.canvas)==null||ig.requestRenderAll(),(ng=this.canvas)==null||ng.fire("object:modified",{target:this}))}setAllCellBorderStyle(eg){var gg,ig;this.syncTextCount(),this.tableCellBorders=Array.from({length:this.rows*this.columns},()=>({top:eg,right:eg,bottom:eg,left:eg})),this.dirty=!0,(gg=this.canvas)==null||gg.requestRenderAll(),(ig=this.canvas)==null||ig.fire("object:modified",{target:this,action:"modifyprops"})}getCellLayout(eg){return{...this.getCellRect(eg),row:Math.floor(eg/this.columns),col:eg%this.columns}}setColumnWidth(eg,gg){var sg,Ig;const ig=this.width||0;if(eg<0||eg>=this.columns||!ig)return;const ng=Math.max(Number(gg)||0,8),og=Array.from({length:this.columns},(Cg,lg)=>(this.columnWidths[lg]||1/this.columns)*ig);og[eg]=ng;const ag=og.reduce((Cg,lg)=>Cg+lg,0)||ng;this.width=ag,this.columnWidths=og.map(Cg=>Cg/ag),this.setCoords(),this.updateEditingTextarea(),this.dirty=!0,(sg=this.canvas)==null||sg.requestRenderAll(),(Ig=this.canvas)==null||Ig.fire("object:modified",{target:this})}setRowHeight(eg,gg){var sg,Ig;const ig=this.height||0;if(eg<0||eg>=this.rows||!ig)return;const ng=Math.max(Number(gg)||0,8),og=Array.from({length:this.rows},(Cg,lg)=>(this.rowHeights[lg]||1/this.rows)*ig);og[eg]=ng;const ag=og.reduce((Cg,lg)=>Cg+lg,0)||ng;this.height=ag,this.rowHeights=og.map(Cg=>Cg/ag),this.setCoords(),this.updateEditingTextarea(),this.dirty=!0,(sg=this.canvas)==null||sg.requestRenderAll(),(Ig=this.canvas)==null||Ig.fire("object:modified",{target:this})}getColumnOffset(eg){const gg=this.width||0;return-gg/2+this.columnWidths.slice(0,eg).reduce((ig,ng)=>ig+ng*gg,0)}getRowOffset(eg){const gg=this.height||0;return-gg/2+this.rowHeights.slice(0,eg).reduce((ig,ng)=>ig+ng*gg,0)}getCellRect(eg){const gg=this.width||0,ig=this.height||0,ng=Math.floor(eg/this.columns),og=eg%this.columns,ag=(this.columnWidths[og]||0)*gg,sg=(this.rowHeights[ng]||0)*ig;return{left:this.getColumnOffset(og),top:this.getRowOffset(ng),width:ag,height:sg}}getCellIndexByPoint(eg){const gg=this.width||0,ig=this.height||0;if(!gg||!ig||!this.rows||!this.columns)return-1;const ng=kn.invertTransform(this.calcTransformMatrix()),og=kn.transformPoint(new ot(eg.x,eg.y),ng),ag=og.x+gg/2,sg=og.y+ig/2;if(ag<0||sg<0||ag>gg||sg>ig)return-1;let Ig=0,Cg=this.columns-1;for(let rg=0;rg<this.columns;rg++)if(Ig+=this.columnWidths[rg]*gg,ag<=Ig){Cg=rg;break}let lg=0,Ag=this.rows-1;for(let rg=0;rg<this.rows;rg++)if(lg+=this.rowHeights[rg]*ig,sg<=lg){Ag=rg;break}return Ag*this.columns+Cg}getViewportCellTransform(eg){if(!this.canvas)return null;const gg=this.getCellRect(eg),ig=this.calcTransformMatrix(),ng=this.canvas.viewportTransform||[1,0,0,1,0,0],og=kn.multiplyTransformMatrices(ng,ig),ag=Math.hypot(og[0],og[1])||1,sg=Math.hypot(og[2],og[3])||1;return{...gg,matrix:og,scaleX:ag,scaleY:sg}}getCanvasElementRect(){var gg,ig;return this.canvas?(((ig=(gg=this.canvas.elements)==null?void 0:gg.upper)==null?void 0:ig.el)||this.canvas.upperCanvasEl||this.canvas.getElement()).getBoundingClientRect():null}removeEditingTextarea(eg=!0){var ng,og,ag;if(!this.editingTextarea)return;const gg=this.editingTextarea;this.editingTextarea=null;const ig=Number(gg.dataset.cellIndex);this.editingPointerDownHandler&&(document.removeEventListener("pointerdown",this.editingPointerDownHandler,!0),this.editingPointerDownHandler=null),this.unbindEditingViewportChange(),eg&&Number.isFinite(ig)&&(this.tableTexts[ig]=gg.value,this.dirty=!0,(ng=this.canvas)==null||ng.fire("object:modified",{target:this})),(og=gg.parentNode)==null||og.removeChild(gg),this.selectedCellIndex=null,this.dirty=!0,(ag=this.canvas)==null||ag.requestRenderAll()}isEditingAssistantTarget(eg){return!!eg.closest([".right-side-bar",".ant-select-dropdown",".ant-select-item",".ant-select-selector",".ant-select-selection-search-input",".ant-input-number",".ant-input-number-dropdown",".ant-dropdown",".ant-tooltip",".ant-popover",".color-wrap",".color-preview-wrap",".hu-color-picker"].join(","))}bindEditingPointerDown(eg){this.editingPointerDownHandler&&document.removeEventListener("pointerdown",this.editingPointerDownHandler,!0),this.editingPointerDownHandler=gg=>{const ig=gg.target;if(!(!ig||ig===eg||eg.contains(ig))){if(this.isEditingAssistantTarget(ig)){this.keepEditingOnNextBlur=!0;return}this.removeEditingTextarea(!0)}},document.addEventListener("pointerdown",this.editingPointerDownHandler,!0)}scheduleEditingTextareaUpdate(eg){this.editingUpdateFrame&&cancelAnimationFrame(this.editingUpdateFrame),this.editingUpdateFrame=requestAnimationFrame(()=>{this.editingUpdateFrame=0,this.updateEditingTextarea(eg)})}bindEditingViewportChange(eg){var ng,og,ag,sg,Ig,Cg,lg;this.unbindEditingViewportChange(),this.editingViewportChangeHandler=()=>{this.scheduleEditingTextareaUpdate(eg)},window.addEventListener("resize",this.editingViewportChangeHandler),window.addEventListener("scroll",this.editingViewportChangeHandler,!0),(ng=window.visualViewport)==null||ng.addEventListener("resize",this.editingViewportChangeHandler),(og=window.visualViewport)==null||og.addEventListener("scroll",this.editingViewportChangeHandler);const gg=((Ig=(sg=(ag=this.canvas)==null?void 0:ag.elements)==null?void 0:sg.upper)==null?void 0:Ig.el)||((Cg=this.canvas)==null?void 0:Cg.upperCanvasEl)||((lg=this.canvas)==null?void 0:lg.getElement()),ig=(gg==null?void 0:gg.parentElement)||gg;ig&&typeof ResizeObserver<"u"&&(this.editingResizeObserver=new ResizeObserver(()=>{this.scheduleEditingTextareaUpdate(eg)}),this.editingResizeObserver.observe(ig))}unbindEditingViewportChange(){var eg,gg,ig;this.editingUpdateFrame&&(cancelAnimationFrame(this.editingUpdateFrame),this.editingUpdateFrame=0),this.editingViewportChangeHandler&&(window.removeEventListener("resize",this.editingViewportChangeHandler),window.removeEventListener("scroll",this.editingViewportChangeHandler,!0),(eg=window.visualViewport)==null||eg.removeEventListener("resize",this.editingViewportChangeHandler),(gg=window.visualViewport)==null||gg.removeEventListener("scroll",this.editingViewportChangeHandler),this.editingViewportChangeHandler=null),(ig=this.editingResizeObserver)==null||ig.disconnect(),this.editingResizeObserver=null}updateEditingTextarea(eg){if(!this.editingTextarea)return;const gg=this.editingTextarea,ig=Number(gg.dataset.cellIndex);if(!Number.isFinite(ig)||eg!==void 0&&eg!==ig)return;const ng=this.getViewportCellTransform(ig),og=this.getCanvasElementRect();if(!ng||!og)return;const ag=this.getCellStyle(ig),sg=this.getCellEditFontSize(ig,ng.scaleY),Ig=Math.max(Math.min(ng.scaleX,ng.scaleY),.01),Cg=Math.max(2/Ig,Math.min(sg*.18,8)),lg=Math.max(ng.width-Cg*2,12/ng.scaleX),Ag=Math.max(ng.height-Cg*2,12/ng.scaleY),rg=sg*(Number(ag.lineHeight)||1.2),cg=this.getEditingLineCount(gg.value,ag,sg,lg),ug=this.getTextareaVerticalPadding(ag,Ag,rg*cg),dg=kn.transformPoint(new ot(ng.left+Cg,ng.top+Cg),ng.matrix);gg.style.left=`${og.left+dg.x}px`,gg.style.top=`${og.top+dg.y}px`,gg.style.width=`${lg}px`,gg.style.height=`${Ag}px`,gg.style.transform=`matrix(${ng.matrix[0]}, ${ng.matrix[1]}, ${ng.matrix[2]}, ${ng.matrix[3]}, 0, 0)`,gg.style.color=ag.fill,gg.style.font=this.getFont(sg,ag),gg.style.lineHeight=`${rg}px`,gg.style.textAlign=ag.textAlign,gg.style.letterSpacing=`${this.getSpacingPx(ag,sg)}px`,gg.style.padding=`${ug.top}px 0 ${ug.bottom}px 0`}startCellEditing(eg){if(!this.canvas)return;this.removeEditingTextarea(!0),this.selectedCellIndex=eg;const gg=this.getViewportCellTransform(eg);if(!gg)return;const ig=this.getCanvasElementRect();if(!ig)return;const ng=this.getCellEditFontSize(eg,gg.scaleY),og=Math.max(Math.min(gg.scaleX,gg.scaleY),.01),ag=Math.max(2/og,Math.min(ng*.18,8)),sg=kn.transformPoint(new ot(gg.left+ag,gg.top+ag),gg.matrix),Ig=document.createElement("textarea");Ig.value=this.tableTexts[eg]||"",Ig.dataset.cellIndex=`${eg}`,Ig.spellcheck=!1,Ig.style.position="fixed",Ig.style.left=`${ig.left+sg.x}px`,Ig.style.top=`${ig.top+sg.y}px`,Ig.style.width=`${Math.max(gg.width-ag*2,12/gg.scaleX)}px`,Ig.style.height=`${Math.max(gg.height-ag*2,12/gg.scaleY)}px`,Ig.style.zIndex="9999",Ig.style.padding="0",Ig.style.margin="0",Ig.style.border="1px solid #2F54EB",Ig.style.outline="none",Ig.style.resize="none",Ig.style.overflow="hidden",Ig.style.background="rgba(255, 255, 255, 0.92)",Ig.style.whiteSpace="pre-wrap",Ig.style.overflowWrap="break-word";const Cg=this.getCellStyle(eg);Ig.style.color=Cg.fill,Ig.style.font=this.getFont(ng,Cg),Ig.style.lineHeight=`${Cg.lineHeight}`,Ig.style.textAlign=Cg.textAlign,Ig.style.letterSpacing=`${this.getSpacingPx(Cg,ng)}px`,Ig.style.boxSizing="border-box",Ig.style.transformOrigin="left top",Ig.style.transform=`matrix(${gg.matrix[0]}, ${gg.matrix[1]}, ${gg.matrix[2]}, ${gg.matrix[3]}, 0, 0)`;const lg=Ag=>Ag.stopPropagation();Ig.addEventListener("mousedown",lg),Ig.addEventListener("pointerdown",lg),Ig.addEventListener("dblclick",lg),Ig.addEventListener("keydown",Ag=>{Ag.stopPropagation(),Ag.key==="Escape"&&(Ag.preventDefault(),this.removeEditingTextarea(!1))}),Ig.addEventListener("input",()=>this.updateEditingTextarea(eg)),Ig.addEventListener("paste",Ag=>this.handleCellEditPaste(eg,Ag)),Ig.addEventListener("copy",Ag=>this.handleCellEditCopy(eg,Ag)),Ig.addEventListener("cut",Ag=>this.handleCellEditCut(eg,Ag)),Ig.addEventListener("blur",()=>{if(this.keepEditingOnNextBlur){this.keepEditingOnNextBlur=!1;return}this.removeEditingTextarea(!0)}),document.body.appendChild(Ig),this.editingTextarea=Ig,this.bindEditingPointerDown(Ig),this.bindEditingViewportChange(eg),this.updateEditingTextarea(eg),Ig.focus(),Ig.select()}handleCellEditPaste(eg,gg){const ig=gg.clipboardData;if(!ig)return;const ng=ig.getData("text/html");if(!ng)return;const og=this.extractCellStyleFromHtml(ng);og&&Object.keys(og).length>0&&this.setCellStyle(eg,og)}handleCellEditCopy(eg,gg){const ig=gg.clipboardData;if(!ig)return;const ng=this.editingTextarea;if(!ng)return;const og=ng.value.substring(ng.selectionStart,ng.selectionEnd);if(!og)return;const ag=this.getCellStyle(eg),sg=this.buildClipboardHtml(og,ag);gg.preventDefault(),ig.setData("text/plain",og),ig.setData("text/html",sg)}handleCellEditCut(eg,gg){var ag;this.handleCellEditCopy(eg,gg);const ig=this.editingTextarea;if(!ig)return;const ng=ig.selectionStart,og=ig.selectionEnd;ng!==og&&(ig.value=ig.value.slice(0,ng)+ig.value.slice(og),ig.selectionStart=ig.selectionEnd=ng,this.tableTexts[eg]=ig.value,this.updateEditingTextarea(eg),this.dirty=!0,(ag=this.canvas)==null||ag.requestRenderAll())}buildClipboardHtml(eg,gg){const ig=[];gg.fill&&ig.push(`color:${gg.fill}`),gg.fontSize&&ig.push(`font-size:${gg.fontSize}px`),gg.fontFamily&&ig.push(`font-family:${gg.fontFamily}`),gg.fontWeight&&ig.push(`font-weight:${gg.fontWeight}`),gg.fontStyle&&ig.push(`font-style:${gg.fontStyle}`);const ng=[];gg.underline&&ng.push("underline"),gg.linethrough&&ng.push("line-through"),ng.length&&ig.push(`text-decoration:${ng.join(" ")}`),gg.textAlign&&ig.push(`text-align:${gg.textAlign}`),gg.lineHeight&&ig.push(`line-height:${gg.lineHeight}`);const og=eg.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>");return`<span style="${ig.join(";")}">${og}</span>`}extractCellStyleFromHtml(eg){try{const gg=document.createElement("div");gg.style.position="absolute",gg.style.left="-9999px",gg.style.top="-9999px",gg.style.visibility="hidden",gg.innerHTML=eg,document.body.appendChild(gg);let ig=null;const ng=document.createTreeWalker(gg,NodeFilter.SHOW_TEXT);let og;for(;og=ng.nextNode();)if(og.textContent&&og.textContent.trim()){ig=og.parentElement;break}ig||(ig=gg);const ag=window.getComputedStyle(ig),sg={};ag.color&&(sg.fill=ag.color);const Ig=parseFloat(ag.fontSize);if(Number.isFinite(Ig)&&Ig>0&&(sg.fontSize=Ig),ag.fontFamily){const rg=(ag.fontFamily.split(",")[0]||"").trim();sg.fontFamily=rg.replace(/^["']|["']$/g,"")}if(ag.fontWeight&&ag.fontWeight!=="normal"&&ag.fontWeight!=="400"){const rg=Number(ag.fontWeight);sg.fontWeight=ag.fontWeight==="bold"||Number.isFinite(rg)&&rg>=600?"bold":ag.fontWeight}ag.fontStyle&&ag.fontStyle!=="normal"&&(sg.fontStyle=ag.fontStyle);const Cg=ag.textDecorationLine||ag.textDecoration||"";/underline/i.test(Cg)&&(sg.underline=!0),/line-through/i.test(Cg)&&(sg.linethrough=!0);const lg=ag.textAlign;(lg==="left"||lg==="center"||lg==="right")&&(sg.textAlign=lg);const Ag=parseFloat(ag.lineHeight);return Number.isFinite(Ag)&&Ag>=.5&&Ag<=5&&(sg.lineHeight=Ag),document.body.removeChild(gg),sg}catch{return null}}selectCell(eg){var gg;this.selectedCellIndex=eg,this.dirty=!0,(gg=this.canvas)==null||gg.requestRenderAll()}handleCellDoubleClick(eg){const gg=this.getCellIndexByPoint(eg);gg<0||(this.removeEditingTextarea(!0),this.selectCell(gg),this.startCellEditing(gg))}getFont(eg,gg){const ig=gg.fontStyle==="italic"?"italic ":"",ng=Number(gg.fontWeight),ag=gg.fontWeight==="bold"||Number.isFinite(ng)&&ng>=600?"bold ":"";return`${ig}${ag}${eg}px ${gg.fontFamily}`}getCellEditFontSize(eg,gg=1){const ig=this.getCellStyle(eg).fontSize||12;return Math.max(ig,8/Math.max(gg,.01))}getSpacingPx(eg,gg){return(Number(eg.charSpacing)||0)/1e3*gg}getEditingLineCount(eg,gg,ig,ng){const ag=document.createElement("canvas").getContext("2d");return ag?(ag.font=this.getFont(ig,gg),Math.max(this.wrapTextLines(ag,eg,gg,ig,ng).length,1)):Math.max(eg.split(/\r?\n/).length,1)}measureTextWidth(eg,gg,ig,ng){const og=this.getSpacingPx(ig,ng);return!gg||!og?eg.measureText(gg).width:Array.from(gg).reduce((ag,sg)=>ag+eg.measureText(sg).width,0)+Math.max(Array.from(gg).length-1,0)*og}wrapTextLine(eg,gg,ig,ng,og){if(!gg)return[""];if(this.measureTextWidth(eg,gg,ig,ng)<=og)return[gg];const ag=[];let sg="";return Array.from(gg).forEach(Ig=>{const Cg=`${sg}${Ig}`;if(sg&&this.measureTextWidth(eg,Cg,ig,ng)>og){ag.push(sg),sg=Ig;return}sg=Cg}),ag.push(sg),ag}wrapTextLines(eg,gg,ig,ng,og){return String(gg).split(/\r?\n/).flatMap(ag=>this.wrapTextLine(eg,ag,ig,ng,og))}drawTextLine(eg,gg,ig,ng,og,ag){const sg=this.getSpacingPx(ig,ag);if(!sg){eg.fillText(gg,ng,og);return}const Ig=Array.from(gg);let Cg=ng;const lg=this.measureTextWidth(eg,gg,ig,ag);ig.textAlign==="center"&&(Cg=ng-lg/2),ig.textAlign==="right"&&(Cg=ng-lg),eg.textAlign="left",Ig.forEach(Ag=>{eg.fillText(Ag,Cg,og),Cg+=eg.measureText(Ag).width+sg})}drawTextDecoration(eg,gg,ig,ng,og,ag,sg){if(!sg.underline&&!sg.linethrough)return;const Ig=Math.min(this.measureTextWidth(eg,gg,sg,ag),og);let Cg=ig-Ig/2;if(sg.textAlign==="left"&&(Cg=ig),sg.textAlign==="right"&&(Cg=ig-Ig),eg.strokeStyle=sg.fill||"#000000",eg.lineWidth=Math.max(ag/16,1),sg.underline){const lg=ng+ag*.38;eg.beginPath(),eg.moveTo(Cg,lg),eg.lineTo(Cg+Ig,lg),eg.stroke()}sg.linethrough&&(eg.beginPath(),eg.moveTo(Cg,ng),eg.lineTo(Cg+Ig,ng),eg.stroke())}drawCellText(eg,gg,ig,ng,og,ag,sg){if(!gg)return;const Ig=Math.min(4,og/6,ag/6),Cg=Math.max(og-Ig*2,1),lg=this.getCellStyle(sg),Ag=this.getTextXByAlign(ig,og,Ig,lg.textAlign),rg=this.scaleX||1,cg=this.scaleY||1,ug=Math.max(Number(lg.fontSize)||12,1),dg=ug*(Number(lg.lineHeight)||1.2);eg.font=this.getFont(ug,lg);const hg=this.wrapTextLines(eg,gg,lg,ug,Cg*rg),mg=hg.length*dg,bg=this.getTextStartYByVertical(ng,ag,Ig,mg,dg,lg.verticalType);eg.save(),eg.beginPath(),eg.rect(ig+.5,ng+.5,Math.max(og-1,1),Math.max(ag-1,1)),eg.clip(),eg.translate(Ag,bg),eg.scale(1/rg,1/cg),eg.fillStyle=lg.fill||"#000000",eg.font=this.getFont(ug,lg),eg.textAlign=lg.textAlign,eg.textBaseline="middle",hg.forEach((pg,fg)=>{const wg=fg*dg*cg;this.drawTextLine(eg,pg,lg,0,wg,ug),this.drawTextDecoration(eg,pg,0,wg,Cg*rg,ug,lg)}),eg.restore()}drawSelectedCell(eg){if(this.selectedCellIndex===null)return;const gg=this.selectedCellIndex;if(gg<0||gg>=this.rows*this.columns)return;const ig=this.getCellRect(gg);eg.save(),eg.fillStyle="rgba(47, 84, 235, 0.14)",eg.strokeStyle="#2F54EB",eg.lineWidth=1,eg.fillRect(ig.left,ig.top,ig.width,ig.height),eg.strokeRect(ig.left+.5,ig.top+.5,Math.max(ig.width-1,1),Math.max(ig.height-1,1)),eg.restore()}resolveBorderStyle(eg,gg){return eg==="none"||gg==="none"?"none":eg==="dashed"||gg==="dashed"?"dashed":"solid"}getDefaultBorderStyle(){return Array.isArray(this.strokeDashArray)&&this.strokeDashArray.length?"dashed":"solid"}getBorderSideStyle(eg,gg){var ig;return((ig=this.tableCellBorders[eg])==null?void 0:ig[gg])||this.getDefaultBorderStyle()}drawBorderSegment(eg,gg,ig,ng,og,ag){gg!=="none"&&(eg.save(),eg.strokeStyle=this.stroke||"#000000",eg.lineWidth=this.strokeWidth||1,eg.setLineDash(gg==="dashed"&&Array.isArray(this.strokeDashArray)?this.strokeDashArray:gg==="dashed"?[6,4]:[]),eg.beginPath(),eg.moveTo(ig,ng),eg.lineTo(og,ag),eg.stroke(),eg.restore())}drawTableBorders(eg){for(let gg=0;gg<=this.rows;gg++){const ig=this.getRowOffset(gg);for(let ng=0;ng<this.columns;ng++){const og=this.getColumnOffset(ng),ag=this.getColumnOffset(ng+1),sg=gg>0?(gg-1)*this.columns+ng:-1,Ig=gg<this.rows?gg*this.columns+ng:-1,Cg=sg>=0?this.getBorderSideStyle(sg,"bottom"):void 0,lg=Ig>=0?this.getBorderSideStyle(Ig,"top"):void 0,Ag=this.resolveBorderStyle(Cg||lg||"solid",Cg&&lg?lg:void 0);this.drawBorderSegment(eg,Ag,og,ig,ag,ig)}}for(let gg=0;gg<=this.columns;gg++){const ig=this.getColumnOffset(gg);for(let ng=0;ng<this.rows;ng++){const og=this.getRowOffset(ng),ag=this.getRowOffset(ng+1),sg=gg>0?ng*this.columns+gg-1:-1,Ig=gg<this.columns?ng*this.columns+gg:-1,Cg=sg>=0?this.getBorderSideStyle(sg,"right"):void 0,lg=Ig>=0?this.getBorderSideStyle(Ig,"left"):void 0,Ag=this.resolveBorderStyle(Cg||lg||"solid",Cg&&lg?lg:void 0);this.drawBorderSegment(eg,Ag,ig,og,ig,ag)}}}_render(eg){const gg=this.width||0,ig=this.height||0;if(!gg||!ig||!this.rows||!this.columns)return;const ng=-gg/2,og=-ig/2;eg.save(),eg.fillStyle=this.backgroundColor||"#FFFFFF00",eg.fillRect(ng,og,gg,ig),eg.restore(),this.drawSelectedCell(eg),this.drawTableBorders(eg),this.syncTextCount();for(let ag=0;ag<this.rows;ag++)for(let sg=0;sg<this.columns;sg++){const Ig=ag*this.columns+sg,Cg=this.getCellRect(Ig);this.drawCellText(eg,this.tableTexts[Ig]||"",Cg.left,Cg.top,Cg.width,Cg.height,Ig)}}};lu.type="table";let ATable=lu;tt.setClass(ATable);const RIBBON_BORDER_PATTERN_OPTIONS=[{label:"无描边",value:"none",source:{x:57,y:29,width:169,height:169}},{label:"图案 1",value:"ribbon-01",source:{x:293,y:29,width:169,height:169}},{label:"图案 2",value:"ribbon-02",source:{x:546,y:29,width:169,height:169}},{label:"图案 3",value:"ribbon-03",source:{x:781,y:29,width:169,height:169}},{label:"图案 4",value:"ribbon-04",source:{x:1005,y:29,width:169,height:169}},{label:"图案 5",value:"ribbon-05",source:{x:1230,y:29,width:169,height:169}},{label:"图案 6",value:"ribbon-06",source:{x:1436,y:29,width:169,height:169}},{label:"图案 7",value:"ribbon-07",source:{x:1660,y:29,width:169,height:169}},{label:"图案 8",value:"ribbon-08",source:{x:57,y:255,width:169,height:169}},{label:"图案 9",value:"ribbon-09",source:{x:296,y:255,width:169,height:169}},{label:"图案 10",value:"ribbon-10",source:{x:550,y:254,width:168,height:169}},{label:"图案 11",value:"ribbon-11",source:{x:781,y:255,width:169,height:169}},{label:"图案 12",value:"ribbon-12",source:{x:1003,y:254,width:169,height:169}},{label:"图案 13",value:"ribbon-13",source:{x:1230,y:255,width:169,height:169}},{label:"图案 14",value:"ribbon-14",source:{x:1436,y:255,width:169,height:169}},{label:"图案 15",value:"ribbon-15",source:{x:1660,y:254,width:169,height:169}},{label:"图案 16",value:"ribbon-16",source:{x:57,y:629,width:169,height:169}},{label:"图案 17",value:"ribbon-17",source:{x:550,y:480,width:168,height:169}},{label:"图案 18",value:"ribbon-18",source:{x:781,y:483,width:169,height:169}},{label:"图案 19",value:"ribbon-19",source:{x:1003,y:483,width:169,height:169}},{label:"图案 20",value:"ribbon-20",source:{x:1230,y:471,width:169,height:169}},{label:"图案 21",value:"ribbon-21",source:{x:1436,y:473,width:169,height:169}},{label:"图案 22",value:"ribbon-22",source:{x:1660,y:473,width:169,height:169}},{label:"图案 23",value:"ribbon-23",source:{x:781,y:693,width:169,height:169}},{label:"图案 24",value:"ribbon-24",source:{x:1003,y:686,width:169,height:169}},{label:"图案 25",value:"ribbon-25",source:{x:1230,y:683,width:169,height:169}},{label:"图案 26",value:"ribbon-26",source:{x:1436,y:683,width:169,height:169}},{label:"图案 27",value:"ribbon-27",source:{x:1660,y:683,width:169,height:169}}];RIBBON_BORDER_PATTERN_OPTIONS.map(tg=>tg.value);function drawRibbonBorder(tg,eg,gg,ig){if(eg==="none"||!(ig!=null&&ig.left)||!(ig!=null&&ig.right))return;const{width:ng,height:og}=gg,ag=gg.left??0,sg=gg.top??0,Ig=getRibbonBorderBandWidth(ng);drawTextureSide(tg,ig.left,ag,sg,Ig,og,"left"),drawTextureSide(tg,ig.right,ag+ng-Ig,sg,Ig,og,"right")}function getRibbonBorderBandWidth(tg){return Math.max(16,Math.min(56,Math.round(tg*.11)))}function drawTextureSide(tg,eg,gg,ig,ng,og,ag){const sg=getImageSourceWidth(eg),Ig=Number(eg.naturalHeight||eg.height);if(!sg||!Ig)return;const Cg=Math.max(1,Math.min(ng,Math.round(sg))),lg=ag==="right"?gg+ng-Cg:gg,Ag=Math.max(1,Math.round(Ig*(Cg/sg)));let rg=ig;for(;rg<ig+og;){const cg=Math.min(Ag,ig+og-rg),ug=Math.max(1,Math.round(Ig*(cg/Ag)));tg.drawImage(eg,0,0,sg,ug,lg,rg,Cg,cg),rg+=Ag}}function getImageSourceWidth(tg){return tg?Number(tg.naturalWidth||tg.width||0):0}const objectMap={line:(tg,eg)=>new ALine([0,0,0,0],{...tg}),rect:(tg,eg)=>new ARect(tg),triangle:(tg,eg)=>new ATriangle(tg),table:(tg,eg)=>new ATable(tg),circle:(tg,eg)=>new ACircle(tg),barcode:(tg,eg)=>new ABarcode(eg,tg),barcode2d:(tg,eg)=>new ABarcode2D(eg,tg),text:(tg,eg)=>new AText(eg??"",tg),textname:(tg,eg)=>new ATextName(eg??"",tg),counter:(tg,eg)=>new ACounter(eg,tg),image:(tg,eg)=>new AImage(eg,tg),rfid:(tg,eg)=>new RfidIcon(eg,tg)};o.DPI=203;const printRenderMetrics={count:0,textRenderMs:0,imageRenderMs:0,thresholdReadMs:0,thresholdLoopMs:0,thresholdWriteMs:0,cpuCopyMs:0};function isPrintRenderMetricsEnabled(){if(window.__LE_PRINT_RENDER_METRICS__===!0)return!0;try{return localStorage.getItem("le:print-render-metrics")==="1"}catch{return!1}}function reportPrintRenderMetrics(){var eg;if(!isPrintRenderMetricsEnabled()||(printRenderMetrics.count++,printRenderMetrics.count%100!==0))return;const tg=window;tg.__LE_PRINT_RENDER_DETAILS__||(tg.__LE_PRINT_RENDER_DETAILS__={}),(eg=tg.__LE_PRINT_RENDER_DETAILS__).baseEditor||(eg.baseEditor=[]),tg.__LE_PRINT_RENDER_DETAILS__.baseEditor.push({...printRenderMetrics}),printRenderMetrics.count=0,printRenderMetrics.textRenderMs=0,printRenderMetrics.imageRenderMs=0,printRenderMetrics.thresholdReadMs=0,printRenderMetrics.thresholdLoopMs=0,printRenderMetrics.thresholdWriteMs=0,printRenderMetrics.cpuCopyMs=0}class BaseEditor{constructor(){this.bindData=new EditorData,this.ribbonBorderPattern="none",this.ribbonBorderTextures=null}get width(){var eg;return(eg=this.canvas)==null?void 0:eg.elements.lower.el.offsetWidth}get height(){var eg;return(eg=this.canvas)==null?void 0:eg.elements.lower.el.offsetHeight}init(eg,gg){this.canvas=new In(eg,{...gg,imageSmoothingEnabled:!1,fireMiddleClick:!0,fireRightClick:!0,stopContextMenu:!1,controlsAboveOverlay:!0,preserveObjectStacking:!0,selectionKey:"ctrlKey"}),this.bindData.init(this);const ig=ng=>{if(!this.canvas)return;const og=this.canvas.getActiveObject();if(!og||og.type!=="textname")return;const ag=og;ag.isEditing===!0&&(ng.key==="Enter"||ng.keyCode===13||ng.key===" "||ng.key==="Space"||ng.keyCode===32)&&(ng.preventDefault(),ng.stopImmediatePropagation(),ag.selectionStart!==void 0&&(ag.selectionStart=ag.selectionEnd=ag.selectionStart))};document.addEventListener("keydown",ig),this.canvas.on("dispose",()=>{document.removeEventListener("keydown",ig)})}removeObject(eg){var gg;eg&&((gg=this.canvas)==null||gg.remove(eg))}addObject(eg,gg,ig,ng){if(this.canvas)if(eg==="image")kn.loadImage(ig,{crossOrigin:"anonymous"}).then(og=>{let ag=og.width/og.height;const sg=imageAlignToOrigin(gg.imageAlign);gg.imgScaleType=ag>1?"3":ag<1?"2":"1";const Ig=new AImage(og,{...gg,imageAnchorMode:"metadata",imageAnchorX:sg.x,imageAnchorY:sg.y,originX:"left",originY:"top",imageSource:gg.imageSource||ig});Ig.id=v4(),Ig.canvas=this.canvas,addObjName(this.canvas,Ig),this.canvas.add(Ig),this.canvas.setActiveObject(Ig)});else{const og=objectMap[eg](gg,ig);og.id=v4(),og.canvas=this.canvas,og.padding=3,addObjName(this.canvas,og),this.canvas.add(og),this.canvas.setActiveObject(og)}}getActiveObjects(){return this.canvas.getActiveObjects()}getActiveObject(){return this.canvas.getActiveObject()}getObjects(){return this.canvas.getObjects()}getAllObjects(){const eg=this.getCanvas(),gg=[];function ig(ng){ng.type==="group"&&ng._objects?ng._objects.forEach(og=>ig(og)):ng.id!=="workspace"&&gg.push(ng)}return eg.getObjects().forEach(ng=>ig(ng)),gg}getBind(){return this.bindData}setRibbonBorderTextures(eg){var gg;this.ribbonBorderTextures=eg,(gg=this.canvas)==null||gg.requestRenderAll()}_toDataUrl(eg,gg,{exclude:ig=[],targetDPI:ng=203,type:og="",ribbonBorderPattern:ag=this.ribbonBorderPattern}={},sg=null){let Ig=sg;if(gg&&Ig){const{left:$g,top:Bg,right:Wg,bottom:yg}=gg;Ig.width=Ig.width+$g+Wg,Ig.height=Ig.height+Bg+yg}const{left:Cg,top:lg,width:Ag,height:rg}=Ig,cg=eg.viewportTransform,ug=new ot(Cg,lg).transform(cg),dg=new ot(Ag,rg).transform(cg),hg=dg.x-ug.x,mg=dg.y-ug.y;let bg=Ag/hg*(Math.trunc(ng/o.DPI*100)/100);const pg={format:"png",quality:1,width:hg,height:mg,left:ug.x,top:ug.y,multiplier:bg};eg.set("flagToDataURL",!0),(Ig&&Ig.type==="ellipse"||Ig.type==="rect"&&Ig.rx&&Ig.ry)&&(eg.clipPath=Ig);let fg="",wg="",Gg="";const Zg=og==="print"&&isPrintRenderMetricsEnabled();if(og==="print"){let $g=Zg?performance.now():0,Bg=["text","counter","rect","circle","barcode","group","table","triangle"],Wg=["line","ellipse","image","barcode2d"];wg=eg.toCanvasElement(bg,{...pg,filter:Yg=>!ig.includes(Yg.id)&&(Bg.includes(Yg.type)||Yg.id==="workspace")}),Zg&&(printRenderMetrics.textRenderMs+=performance.now()-$g),$g=Zg?performance.now():0,Gg=eg.toCanvasElement(bg,{...pg,filter:Yg=>!ig.includes(Yg.id)&&Yg.id!=="workspace"&&Wg.includes(Yg.type)}),Zg&&(printRenderMetrics.imageRenderMs+=performance.now()-$g);let yg=wg.getContext("2d");$g=Zg?performance.now():0;let Ng=yg.getImageData(0,0,wg.width,wg.height);Zg&&(printRenderMetrics.thresholdReadMs+=performance.now()-$g);let vg=Ng.data;const Sg=vg.length,Vg=Sg-Sg%16;let Xg=window.myThreshold||200;$g=Zg?performance.now():0;for(let Yg=0;Yg<Vg;Yg+=16){let Hg=vg[Yg],kg=vg[Yg+1],Rg=vg[Yg+2],Kg=.299*Hg+.587*kg+.114*Rg;Kg=Kg>Xg?255:0,vg[Yg]=vg[Yg+1]=vg[Yg+2]=Kg,Hg=vg[Yg+4],kg=vg[Yg+5],Rg=vg[Yg+6],Kg=.299*Hg+.587*kg+.114*Rg,Kg=Kg>Xg?255:0,vg[Yg+4]=vg[Yg+5]=vg[Yg+6]=Kg,Hg=vg[Yg+8],kg=vg[Yg+9],Rg=vg[Yg+10],Kg=.299*Hg+.587*kg+.114*Rg,Kg=Kg>Xg?255:0,vg[Yg+8]=vg[Yg+9]=vg[Yg+10]=Kg,Hg=vg[Yg+12],kg=vg[Yg+13],Rg=vg[Yg+14],Kg=.299*Hg+.587*kg+.114*Rg,Kg=Kg>Xg?255:0,vg[Yg+12]=vg[Yg+13]=vg[Yg+14]=Kg}for(let Yg=Vg;Yg<Sg;Yg+=4){const Hg=vg[Yg],kg=vg[Yg+1],Rg=vg[Yg+2];let Kg=.299*Hg+.587*kg+.114*Rg;Kg=Kg>Xg?255:0,vg[Yg]=vg[Yg+1]=vg[Yg+2]=Kg}if(Zg&&(printRenderMetrics.thresholdLoopMs+=performance.now()-$g),$g=Zg?performance.now():0,yg.save(),yg.putImageData(Ng,0,0),yg.globalCompositeOperation="multiply",yg.fillStyle="rgba(255, 255, 255, 1)",yg==null||yg.fillRect(0,0,wg.width,wg.height),yg.drawImage(Gg,0,0,Gg.width,Gg.height),Gg.width=0,Gg.height=0,yg.restore(),Zg&&(printRenderMetrics.thresholdWriteMs+=performance.now()-$g),fg=wg,fg instanceof HTMLCanvasElement){const{width:Yg,height:Hg}=fg;$g=Zg?performance.now():0;const kg=document.createElement("canvas");kg.width=Yg,kg.height=Hg,kg.getContext("2d",{willReadFrequently:!0}).drawImage(fg,0,0),fg.width=0,fg.height=0,fg=kg,Zg&&(printRenderMetrics.cpuCopyMs+=performance.now()-$g)}Zg&&reportPrintRenderMetrics()}else og==="review"?fg=eg.toCanvasElement(bg,{...pg,filter:$g=>!ig.includes($g.id)}):ag!=="none"?fg=eg.toCanvasElement(bg,{...pg,filter:$g=>!ig.includes($g.id)}):fg=eg.toDataURL({...pg,filter:$g=>!ig.includes($g.id)});if(ag!=="none"&&fg instanceof HTMLCanvasElement){const $g=fg.getContext("2d");$g&&drawRibbonBorder($g,ag,{width:fg.width,height:fg.height},this.ribbonBorderTextures),og!=="print"&&og!=="review"&&(fg=fg.toDataURL("image/png",1))}return eg.clipPath&&(eg.clipPath=void 0),eg.set("flagToDataURL",!1),fg}storeStatus(){var eg;this.activeObjects=(eg=this.canvas)==null?void 0:eg.getActiveObject()}restoreStatus(eg=!1){var gg,ig,ng;this.activeObjects?(console.log("restoreStatus"),(gg=this.canvas)==null||gg.setActiveObject(this.activeObjects),(ig=this.canvas)==null||ig.requestRenderAll(),this.activeObjects=void 0):eg&&((ng=this.canvas)==null||ng.requestRenderAll())}getCanvas(){if(!this.canvas)throw new Error("Editor uninit!!!");return this.canvas}static set DPI(eg){o.DPI=eg}static get DPI(){return o.DPI}dispose(){this.canvas&&this.canvas.dispose()}}const printExportMetrics={count:0,methodMs:0,exportMs:0,editorRenderMs:0},EMPTY_IMAGE_DATA_URL="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function isNetworkImageSource(tg){return typeof tg=="string"&&/^(?:https?:)?\/\//i.test(tg)}function canLoadNetworkImage(tg){return new Promise(eg=>{const gg=new Image,ig=window.setTimeout(()=>ng(!1),8e3),ng=og=>{window.clearTimeout(ig),gg.onload=null,gg.onerror=null,eg(og)};gg.crossOrigin="anonymous",gg.onload=()=>ng(!0),gg.onerror=()=>ng(!1),gg.src=tg})}async function prepareCanvasImages(tg,eg=!1){let gg;try{gg=JSON.parse(tg)}catch{return tg}const ig=[],ng=new Set,og=ag=>{!ag||typeof ag!="object"||ng.has(ag)||(ng.add(ag),String(ag.type||"").toLowerCase()==="image"&&ig.push(ag),Array.isArray(ag.objects)&&ag.objects.forEach(og),ag.clipPath&&og(ag.clipPath))};return(Array.isArray(gg)?gg:gg.objects||[]).forEach(og),await Promise.all(ig.map(async ag=>{const sg=isNetworkImageSource(ag.src)?ag.src:ag.src===EMPTY_IMAGE_DATA_URL&&isNetworkImageSource(ag.imageSource)?ag.imageSource:void 0;sg&&(eg||!await canLoadNetworkImage(sg)?(ag.imageSource=ag.imageSource||sg,ag.src=EMPTY_IMAGE_DATA_URL):ag.src===EMPTY_IMAGE_DATA_URL&&(ag.src=sg))})),JSON.stringify(gg)}function isPrintExportMetricsEnabled(){try{return window.__LE_PRINT_RENDER_METRICS__===!0||localStorage.getItem("le:print-render-metrics")==="1"}catch{return!1}}Object.defineProperty(ji.prototype,"locked",{configurable:!0,enumerable:!0,get:function(){return this.lockMovementX&&this.lockMovementY&&this.lockRotation&&this.lockScalingX&&this.lockScalingY&&this.lockSkewingX&&this.lockSkewingY&&this.lockScalingFlip},set:function(tg){this.lockMovementX=this.lockMovementY=this.lockRotation=this.lockScalingX=this.lockScalingY=this.lockSkewingX=this.lockSkewingY=this.lockScalingFlip=tg,this.canvas&&this.canvas.fire("custom:object:locked",{target:this})}});class Editor extends BaseEditor{constructor(){super(...arguments),this.plugins=new Map,this.hooks=new Map,this.events=new Map,this.id=v4(),this._isShown=!1,this._isHasRfid=!1}get filePath(){return this._filePath}set filePath(eg){this._filePath=eg}get labelConfig(){return this._labelConfig}set labelConfig(eg){this._labelConfig=eg}get rfidConfig(){return this._rfidConfig}set rfidConfig(eg){this._rfidConfig=eg}get databaseConfig(){return this._databaseConfig}set databaseConfig(eg){this._databaseConfig=eg}init(eg,gg){super.init(eg,gg),this.canvas&&(this.canvas.on("custom:object:locked",ig=>{this.emit("custom:object:locked",ig)}),this.canvas.on("custom:object:refreshList",ig=>{this.emit("custom:object:refreshList",ig)}))}dispose(){this.canvas&&(this.canvas.off("custom:object:locked"),this.canvas.off("custom:object:refreshList")),this.plugins.forEach(eg=>eg.uninstall&&eg.uninstall()),super.dispose()}addHotKey(eg,gg){hotkeys(eg,{single:!0},(ig,ng)=>{ig.preventDefault(),gg({kbe:ig,hke:ng})})}removeHotKey(eg){hotkeys.unbind(eg)}editActivated(){for(let eg of this.plugins.values())eg.enabled&&eg.enabled()}editDeactivated(){for(let eg of this.plugins.values())eg.disabled&&eg.disabled()}use(eg,gg){const ig=typeof eg=="function"?new eg(gg):eg;return this.checkDependencies(ig),this.runLifecycleHooks(ig,gg),ig.name&&this.plugins.set(ig.name,ig),this}checkDependencies(eg){eg.dependencies&&eg.dependencies.forEach(gg=>{if(!this.plugins.has(gg))throw new Error(`Plugin ${eg.name} requires ${gg} to be installed first`)})}runLifecycleHooks(eg,gg){eg.install&&eg.install(this,gg)}addHook(eg,gg){this.hooks.set(eg,gg)}triggerHook(eg,...gg){const ig=this.hooks.get(eg);if(ig)return ig(...gg)}getPlugin(eg){return this.plugins.get(eg)}on(eg,gg){this.events.has(eg)||this.events.set(eg,[]),this.events.get(eg).push(gg)}emit(eg,...gg){this.events.has(eg)&&this.events.get(eg).forEach(ig=>ig(...gg))}off(eg,gg){this.events.has(eg)&&(gg?this.events.set(eg,this.events.get(eg).filter(ig=>ig!==gg)):this.events.delete(eg))}toDataUrl({padding:eg,type:gg="",exclude:ig=[],targetDPI:ng=203,isJudgeGrid:og=!1,skipCanvasRender:ag=!1,ribbonBorderPattern:sg=this.ribbonBorderPattern}={}){var pg;if(!this.canvas)return;const Ig=gg==="print"&&isPrintExportMetricsEnabled(),Cg=Ig?performance.now():0;this.canvas.discardActiveObject();const lg=this.getPlugin("RulerPlugin"),Ag=this.getPlugin("HistoryPlugin"),rg=this.getPlugin("WorkspacePlugin"),cg=rg.workspace;let ug=!1;og&&(ug=(cg==null?void 0:cg.isHasGrid)||!1,ug&&(rg==null||rg.hideGrid())),lg&&lg.disabled(),Ag&&Ag.disabled();const dg=Ig?performance.now():0,hg=this._toDataUrl(this.canvas,eg,{exclude:ig,targetDPI:ng,type:gg,ribbonBorderPattern:sg},cg),mg=Ig?performance.now():0;ag||this.canvas.renderAll();const bg=Ig?performance.now()-mg:0;if(lg&&lg.enabled(),Ag&&Ag.enabled(),og&&ug&&(rg==null||rg.showGrid()),Ig&&(printExportMetrics.count++,printExportMetrics.methodMs+=performance.now()-Cg,printExportMetrics.exportMs+=mg-dg,printExportMetrics.editorRenderMs+=bg,printExportMetrics.count===100)){const fg=window;fg.__LE_PRINT_RENDER_DETAILS__||(fg.__LE_PRINT_RENDER_DETAILS__={}),(pg=fg.__LE_PRINT_RENDER_DETAILS__).editor||(pg.editor=[]),fg.__LE_PRINT_RENDER_DETAILS__.editor.push({...printExportMetrics,unmeasuredMs:Number((printExportMetrics.methodMs-printExportMetrics.exportMs-printExportMetrics.editorRenderMs).toFixed(1))}),printExportMetrics.count=0,printExportMetrics.methodMs=0,printExportMetrics.exportMs=0,printExportMetrics.editorRenderMs=0}return hg}async toDataUrlOffscreen({padding:eg,type:gg="",exclude:ig=[],targetDPI:ng=203,isJudgeGrid:og=!1,ribbonBorderPattern:ag=this.ribbonBorderPattern,json:sg}={}){if(!this.canvas)return"";const Ig=this.getPlugin("WorkspacePlugin"),Cg=Ig==null?void 0:Ig.workspace;if(!Cg)return"";const lg=sg||this.canvas.toObject(cloneCommonField),Ag=this.canvas.getWidth(),rg=this.canvas.getHeight(),cg=document.createElement("canvas");cg.width=Ag,cg.height=rg;const ug=new In(cg,{enableRetinaScaling:!1,skipOffscreen:!1,selection:!1,preserveObjectStacking:!0});ug.setViewportTransform(this.canvas.viewportTransform?Array.from(this.canvas.viewportTransform):[1,0,0,1,0,0]);let dg=!1;const hg=Cg.width,mg=Cg.height;try{return await ug.loadFromJSON(lg),ug.renderAll(),typeof(Ig==null?void 0:Ig.createExportWorkspace)=="function"&&(Ig.createExportWorkspace(ug),ug.renderAll()),og&&(dg=Cg.isHasGrid||!1),this._toDataUrl(ug,eg,{exclude:ig,targetDPI:ng,type:gg,ribbonBorderPattern:ag},Cg)}finally{Cg.width=hg,Cg.height=mg,ug.dispose(),cg.remove()}}toTemplateJson(){const eg={};eg.Version="1.0.0-alpha.1",refreshObjectCenterProperties(this.canvas.getObjects());let gg=this.canvas.toObject(cloneCommonField);if(eg.canvas=JSON.stringify(gg),this._labelConfig){const ig=this._labelConfig;ig.fileId.length===0&&(ig.fileId=v4()),eg.labelConfig=ig}return this._databaseConfig&&(eg.databaseConfig=this._databaseConfig),this._rfidConfig&&(eg.rfidConfig=this._rfidConfig),this._filePath&&(eg.filePath=this._filePath),JSON.stringify(eg)}toJSON(){return refreshObjectCenterProperties(this.canvas.getObjects()),JSON.stringify(this.canvas.toObject(cloneCommonField))}fromTemplateJson(eg,gg){this.canvas&&(async()=>{const ig=await prepareCanvasImages(eg);try{await this.canvas.loadFromJSON(ig)}catch(og){console.warn("加载网络图片失败,已使用占位图继续打开模板",og),this.canvas.clear();const ag=await prepareCanvasImages(eg,!0);await this.canvas.loadFromJSON(ag)}this.canvas.renderAll(),gg(),this.bindData&&this.canvas&&(this.bindData.originState=JSON.stringify(this.canvas.toJSON()))})()}}const state$2=reactive({barcode2dSizeRatio:""});function getAlignedTextLeft(tg,eg,gg,ig){return ig==="center"?tg+(eg-gg)/2:ig==="right"?tg+eg-gg:tg}function getTextWidth(tg,eg,gg=0){return tg.measureText(eg).width+Math.max(0,Array.from(eg).length-1)*gg}let sRatio=Math.trunc(4/3*100)/100,longbeiClearCode=["10000502","10002500","10000503"];const Cu=class Cu extends ji{constructor(eg,gg){var og,ag;super(gg),this.lastCtx=null,this.lastDrawOption=null,this.hasToDataUrl=!1,this.counterProps=null,this.reviewValueArgs=null,this.barcodeDateFormatType="",this.increaseDate=!1,this.concatTextIdListObj=null,this.connectObjIds=[],this.isFirstLoad=!1,this.canModified=!0,this.useLongbeiCache=!0,this.inWorkerRender=!1,this.workerOtherImgData="",this.barcodeBodyHeight=0,this.textAreaHeight=0,this.isSyncingTextHeight=!1,this.emitErrorMessage=throttle$1(sg=>{canvasEventBus.emit("canvasShowError",sg)},800),this._cache={canvas:void 0,error:void 0},this.counterProps=gg&&gg.counterProps?gg.counterProps:this.counterProps,this.increaseDate=gg&&gg.increaseDate?gg.increaseDate:this.increaseDate,this.barcodeDateFormatType=gg&&gg.barcodeDateFormatType?gg.barcodeDateFormatType:this.barcodeDateFormatType,((og=eg.extra)==null?void 0:og.version)==="0"&&(eg.extra=omit(eg.extra,["version"])),((ag=eg.extra)==null?void 0:ag.eclevel)==="0"&&(eg.extra=omit(eg.extra,["eclevel"])),eg.custom||(eg.custom={}),this.barcode2dOptions=cloneDeep(eg),this.concatTextIdListObj=gg&&gg.concatTextIdListObj?gg.concatTextIdListObj:this.concatTextIdListObj,this.connectObjIds=gg.connectObjIds??this.connectObjIds,this.barcode2dOptions.includetext=eg.includetext??!1,this.barcode2dOptions.textposition=this.barcode2dOptions.includetext?this.barcode2dOptions.textposition||"bottom":"none",this.barcode2dOptions.textsize=this.barcode2dOptions.textsize||14,this.barcode2dOptions.textfontname=this.barcode2dOptions.textfontname||"Arial",this.barcode2dOptions.textxalign=this.barcode2dOptions.textxalign||"center",this.barcode2dOptions.textgaps=this.barcode2dOptions.textgaps||0,this.textAreaHeight=this.measureTextAreaHeight(this.barcode2dOptions),this.barcodeBodyHeight=Math.max(1,(this.height||1)-this.textAreaHeight),this.set({width:this.width,height:this.height}),this.on("modified",sg=>{console.log("eee=======",sg),lpBcid.includes(this.barcode2dOptions.bcid)&&(sg==null?void 0:sg.action)!=="drag"&&(this.canModified=!0,setTimeout(()=>{let Ig=this.barcode2dOptions.custom,Cg=this.width*this.scaleX,lg=this.height*this.scaleY,Ag=Math.max(Cg/lg,lg/Cg);Ag=Math.trunc(Ag*100)/100,[1,2,sRatio].includes(Ag)?(Ig.sizeRatio=Ag===1?"1x1":Ag===2?"2x1":"4x3",state$2.barcode2dSizeRatio=Ig.sizeRatio):(Ig.sizeRatio="auto",state$2.barcode2dSizeRatio=Ig.sizeRatio),console.log("state.barcode2dSizeRatio========",state$2.barcode2dSizeRatio)},30)),lpBcid.includes(this.barcode2dOptions.bcid)&&(sg==null?void 0:sg.action)==="drag"&&this.updateLpCodePosition()}),this.on("scaling",()=>{lpBcid.includes(this.barcode2dOptions.bcid)&&(this.canModified=!1,this.clearErrorLpCodeMap())}),canvasEventBus.off(`update:barcode2d:${this.id}`),canvasEventBus.on(`update:barcode2d:${this.id}`,async({list:sg,callback:Ig=function(){}}={})=>{let Cg=await this.updateBarCode2d(sg);Ig&&Ig(Cg)})}updateLpCodePosition(){let eg=this.getLpCache();eg&&(eg.x=this.left,eg.y=this.top)}clearErrorLpCodeMap(){errorLpCodeMap.delete(this.id)}getLpCache(){let eg="",gg=this.id;return this.barcode2dOptions.bcid==="LPCode"?eg=getLastCacheLpcode(gg):this.barcode2dOptions.bcid==="LPMixQrCode"&&(eg=getLastMixCacheLpcode(gg)),eg}drawLpCode(eg,gg,ig,ng,og,ag="",sg=null){var lg;let Ig=eg||this.lastCtx;if(this._cache.error=void 0,ag==="cache"&&(this.width=ng,this.height=og,this.scaleX=1,this.scaleY=1,sg&&(this.left=sg.x,this.top=sg.y),this.lastDrawOption={w:this.width,h:this.height,x:-this.width/2,y:-this.height/2},ig.w=this.lastDrawOption.w,ig.h=this.lastDrawOption.h,ig.x=this.lastDrawOption.x,ig.y=this.lastDrawOption.y,this.strokeWidth>0&&(ig.x+=this.strokeWidth,ig.y+=this.strokeWidth),this.setCoords()),this.inWorkerRender||(this.workerOtherImgData=gg),Ig.drawImage(gg,ig.x,ig.y,ng,og),this.strokeWidth>0){let Ag=this.stroke||"#fff";Ig.lineWidth=this.strokeWidth,Ig.strokeStyle=Ag,withObjectStrokeDash(Ig,this,()=>Ig.strokeRect(-this.width/2,-this.height/2,ng+this.strokeWidth*2,og+this.strokeWidth*2))}this.dirty=!0;let Cg=this.group;for(;Cg;)Cg.dirty=!0,Cg=Cg.group;this.isFirstLoad||(this.objectCaching=!1,this.isFirstLoad=!0),(lg=this.canvas)==null||lg.requestRenderAll(),this.objectCaching||setTimeout(()=>{this.objectCaching=!0},60)}getTextLayout(eg,gg,ig){if(!this.shouldShowText(gg))return{showText:!1,textGap:0,textLineHeight:0,textAreaHeight:0,barcodeHeight:ig};const{scaleY:og}=this.getRenderScale(),ag=14/og,sg=6/og,Ig=this.measureTextLineHeight(gg,eg),Cg=Math.ceil(Ig/og+ag+sg);return{showText:!0,textGap:ag,textLineHeight:Ig,textAreaHeight:Cg,barcodeHeight:ig}}shouldShowText(eg){return eg.includetext&&eg.textposition!=="none"&&!!eg.text}getMeasureContext(){return typeof document>"u"?null:document.createElement("canvas").getContext("2d")}measureTextLineHeight(eg,gg){const ig=Number(eg.textsize)||14,ng=gg||this.getMeasureContext();if(!ng)return ig*1.2;ng.save(),ng.font=`${ig}px ${eg.textfontname||"Arial"}`;const og=ng.measureText(eg.text||"");return ng.restore(),og.actualBoundingBoxAscent+og.actualBoundingBoxDescent||ig*1.2}measureTextAreaHeight(eg){if(!this.shouldShowText(eg))return 0;const{scaleY:gg}=this.getRenderScale(),ig=14/gg,ng=6/gg;return Math.ceil(this.measureTextLineHeight(eg)/gg+ig+ng)}syncTextHeight(eg){var og;const gg=this.barcodeBodyHeight||Math.max(1,(this.height||1)-this.textAreaHeight),ig=gg+eg;if(this.barcodeBodyHeight=gg,this.textAreaHeight=eg,Math.abs((this.height||0)-ig)<.01)return;this.isSyncingTextHeight=!0,this.set("height",ig),this.isSyncingTextHeight=!1,this.setCoords();let ng=this.group;for(;ng;)ng.dirty=!0,ng==null||ng.triggerLayout("childUpdate"),ng.setCoords(),ng=ng.group;(og=this.canvas)==null||og.requestRenderAll()}getRenderScale(){var ng;const eg=(ng=this.getObjectScaling)==null?void 0:ng.call(this),gg=Math.abs((eg==null?void 0:eg.x)||this.scaleX||1)||1,ig=Math.abs((eg==null?void 0:eg.y)||this.scaleY||1)||1;return{scaleX:gg,scaleY:ig}}renderText(eg,gg,ig,ng,og){if(!gg.includetext||gg.textposition==="none"||!gg.text)return;const ag=gg.textxalign||"center";eg.save();const{scaleX:sg,scaleY:Ig}=this.getRenderScale();eg.scale(1/sg,1/Ig),eg.font=`${gg.textsize||14}px ${gg.textfontname||"Arial"}`,eg.fillStyle=gg.textcolor||"#000";const Cg=Number(gg.textgaps)||0,lg=getTextWidth(eg,gg.text,Cg),Ag=Math.max(0,ig.w-(this.strokeWidth>0?this.strokeWidth*2:0)),rg=getAlignedTextLeft(ig.x,Ag,lg/sg,ag);eg.textAlign="left",eg.textBaseline="top",Cg&&(eg.letterSpacing=Cg+"px"),eg.fillText(gg.text,rg*sg,(ig.y+ng+og)*Ig),eg.restore()}async _render(eg){var og,ag,sg,Ig,Cg;const gg=cloneDeep(this.barcode2dOptions);this.lastCtx=eg;const ig=this.getTextLayout(eg,gg,this.barcodeBodyHeight||this.height),ng={w:this.width,h:this.height,x:-this.width/2,y:-this.height/2};if(eg.save(),eg.imageSmoothingEnabled=!1,this.dirty){if(gg.width=ng.w,gg.height=ig.barcodeHeight,typeof this.fill=="string"){let lg=rgbaStringToHex8(this.fill);gg.barcolor=hexToHex6_blend(lg)}this.strokeWidth>0&&(gg.width-=this.strokeWidth*2,gg.height-=this.strokeWidth*2);try{lpBcid.includes(gg.bcid)||(this._cache.canvas=generateCanvas(gg),this.dirty=!1,this._cache.error&&(this._cache.error=void 0))}catch(lg){this.dirty=!0,lg instanceof Error&&(console.log("error",lg.message),this._cache.error=lg.message),this._cache.canvas=void 0}}if(this.strokeWidth>0&&(ng.x+=this.strokeWidth,ng.y+=this.strokeWidth),this.lastDrawOption=ng,lpBcid.includes(gg.bcid)){let lg=this.lastDrawOption;const Ag=this.strokeWidth>0?lg.w-this.strokeWidth*2:lg.w,rg=Math.max(1,this.strokeWidth>0?ig.barcodeHeight-this.strokeWidth*2:ig.barcodeHeight);let cg=Ag*this.scaleX,ug=rg*this.scaleY,dg=gg.text,hg=Number((og=gg.extra)==null?void 0:og.eclevel)||1;hg=hg+"";let mg=Math.trunc(cg/Editor.DPI*25.4*100)/100,bg=Math.trunc(ug/Editor.DPI*25.4*100)/100,pg=mg/(bg||1),fg=((ag=gg.custom)==null?void 0:ag.CellSize)||"8",wg=`${dg}-${hg}-${mg+bg}-${pg}-${fg}`,Gg=`${this.id}`,Zg=null;if(gg.bcid==="LPMixQrCode"){let $g=((sg=gg.custom)==null?void 0:sg.LPErrLevel)||"0",Bg=((Ig=gg.custom)==null?void 0:Ig.QRErrLevel)||"0";hg=`${$g}-${Bg}`,wg=`${dg}-${hg}-${mg+bg}-${pg}-${fg}`}try{if(errorLpCodeMap.has(Gg)){errorLpCodeMap.set(Gg,this._cache.error||"龙贝码生成错误");let $g=this.getLpCache();if($g&&this.useLongbeiCache){let Bg=$g||{};Zg=Bg.img,this.drawLpCode(eg,Zg,lg,Bg.rWidth,Bg.rHeight,"cache",Bg),this._cache.error=void 0}else this._cache.error=errorLpCodeMap.get(Gg)||"龙贝码生成错误"}else{if(lpCodeMap.has(wg)&&this.useLongbeiCache){Zg=lpCodeMap.get(wg);let $g={id:this.id,sKey:wg,img:Zg,rWidth:cg,rHeight:ug,x:this.left,y:this.top};this.barcode2dOptions.bcid==="LPCode"?setCacheLpCode($g):setCacheMixLpCode($g)}else if(this.canModified){let $g={Content:dg,ErrLevel:hg,Width:mg,Height:bg,id:this.id,rWidth:cg,rHeight:ug,CellSize:fg,x:this.left,y:this.top,DPI:Editor.DPI};this.useLongbeiCache||lpCodeMap.delete(wg),this.barcode2dOptions.bcid==="LPCode"?Zg=await getBase64Data($g):Zg=await getMixBase64Data($g),this.useLongbeiCache=!0}if(lpCodeMap.has(wg)&&this.useLongbeiCache)this._cache.error=void 0,this.drawLpCode(eg,Zg,lg,Ag,rg);else if(this.useLongbeiCache){let $g=this.getLpCache();$g&&(Zg=($g||{}).img,this.drawLpCode(eg,Zg,lg,Ag,rg),this._cache.error=void 0)}}}catch($g){let Bg=$g&&$g.code,Wg=this.getLpCache();if(errorLpCodeMap.set(Gg,this._cache.error||"龙贝码生成错误"),Bg&&(longbeiClearCode.includes(Bg+"")&&(this.useLongbeiCache=!1,clearLpAndMixCacheById(this.id),this._cache.error=`龙贝码: ${$g.payload}`),this.emitErrorMessage($g.payload)),Wg&&this.useLongbeiCache){let yg=Wg||{};Zg=yg.img,this.drawLpCode(eg,Zg,lg,yg.rWidth,yg.rHeight,"cache",yg),this._cache.error=void 0}else Bg&&(this._cache.error=`龙贝码: ${$g.payload}`,this.dirty=!0,(Cg=this.canvas)==null||Cg.requestRenderAll())}}else this.objectCaching=!0;if(!this._cache.error&&!lpBcid.includes(gg.bcid)){if(this._cache.canvas){const lg=this.strokeWidth>0?ng.w-this.strokeWidth*2:ng.w,Ag=Math.max(1,this.strokeWidth>0?ig.barcodeHeight-this.strokeWidth*2:ig.barcodeHeight),rg=this._cache.canvas;if(eg.drawImage(rg,0,0,rg.width,rg.height,ng.x,ng.y,lg,Ag),this.strokeWidth>0){let cg=this.stroke||"#fff";eg.lineWidth=this.strokeWidth,eg.strokeStyle=cg,withObjectStrokeDash(eg,this,()=>eg.strokeRect(-this.width/2,-this.height/2,ng.w,ng.h))}}}if(!this._cache.error&&ig.showText&&this.renderText(eg,gg,ng,ig.barcodeHeight,ig.textGap),eg.translate(.5,.5),this._cache.error){const lg=wrapText(eg,this._cache.error,ng.w,"bold 18px 宋体"),Ag=getLineHeight(eg);let rg=ng.y+Ag;const cg=eg.fillStyle;eg.fillStyle="red";for(const ug of lg)eg.fillText(ug,ng.x,rg),rg+=Ag;eg.fillStyle=cg}eg.restore()}async getLongBeiImg(eg){var dg,hg,mg,bg;if(!lpBcid.includes(eg.bcid))return;let gg=this.lastDrawOption;const ig=this.strokeWidth>0?gg.w-this.strokeWidth*2:gg.w,ng=this.strokeWidth>0?gg.h-this.strokeWidth*2:gg.h;let og=eg.text,ag=Number((dg=eg.extra)==null?void 0:dg.eclevel)||1,sg=ig*this.scaleX,Ig=ng*this.scaleY,Cg=Math.trunc(sg/Editor.DPI*25.4*100)/100,lg=Math.trunc(Ig/Editor.DPI*25.4*100)/100,Ag=Cg/(lg||1),rg=((hg=eg.custom)==null?void 0:hg.CellSize)||"8",cg=`${og}-${ag}-${Cg+lg}-${Ag}-${rg}`,ug=null;if(eg.bcid==="LPMixQrCode"){let pg=((mg=eg.custom)==null?void 0:mg.LPErrLevel)||"0",fg=((bg=eg.custom)==null?void 0:bg.QRErrLevel)||"0";ag=`${pg}-${fg}`,cg=`${og}-${ag}-${Cg+lg}-${Ag}-${rg}`}this.clearErrorLpCodeMap();try{if(lpCodeMap.has(cg)&&this.useLongbeiCache)ug=lpCodeMap.get(cg);else{let pg={Content:og,ErrLevel:ag,Width:Cg,Height:lg,id:this.id,rWidth:sg,rHeight:Ig,CellSize:rg,x:this.left,y:this.top,DPI:Editor.DPI};this.barcode2dOptions.bcid==="LPCode"?ug=await getBase64Data(pg,"noSaveCache"):ug=await getMixBase64Data(pg,"noSaveCache"),this.useLongbeiCache=!0}return this.workerOtherImgData=ug,this._cache.error=void 0,ug}catch(pg){console.error(pg)}}dispose(){super.dispose()}set(eg,gg){return this.isSyncingTextHeight||(typeof eg=="string"?eg==="height"&&typeof gg=="number"&&(this.barcodeBodyHeight=Math.max(1,gg-this.textAreaHeight)):typeof eg.height=="number"&&(this.barcodeBodyHeight=Math.max(1,eg.height-this.textAreaHeight))),super.set(eg,gg)}countDate(eg=""){if(this.barcodeDateFormatType&&this.increaseDate){const gg=formatDate(this.barcodeDateFormatType);return console.log("formatted",gg),this.dirty=!0,eg!=="print"&&this.setBarcode2DOption({bcid:this.barcode2dOptions.bcid,text:gg}),gg}}countCurrent(eg){let gg=this.counterProps||eg;if(gg){let ig=gg;if(!ig.value&&ig.value!==0)return"";const ng=formatCounterValue(ig);return(ig.prefix&&ig.prefix.length>0?ig.prefix:"")+ng+(ig.suffix&&ig.suffix.length>0?ig.suffix:"")}return""}countNext(eg="print"){if(this.counterProps){let gg=this.counterProps;if(!gg.value&&gg.value!==0)return;eg==="review"&&!this.reviewValueArgs&&(this.reviewValueArgs={...gg});const ig=formatCounterValue(gg);let ng=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:"");const og=getNextCounterValue(gg);return og!==null&&(gg.value=og,this.counterProps.value=og),this.dirty=!0,ng}else return""}reviewRecover(){if(this.reviewValueArgs){const eg=this.reviewValueArgs;this.counterProps=eg,this.reviewValueArgs=null;const gg=formatCounterValue(eg);let ig=(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:"");this.setBarcode2DOption({bcid:this.barcode2dOptions.bcid,text:ig})}}updateInGroup(){this.setCoords(),this.dirty=!0;let eg=this.group;for(;eg;)eg.dirty=!0,eg==null||eg.triggerLayout("childUpdate"),eg.setCoords(),eg=eg.group}async updateBarCode2d(eg=[],gg=""){var ig;if(this.concatTextIdListObj||this.connectObjIds&&this.connectObjIds.length>0){let ng=!1,og="",ag=[],sg=[];const Ig=lg=>{if(this.connectObjIds){let Ag=0;for(let rg of this.connectObjIds){if(rg.index=Ag,rg.id&&rg.id===lg.id){ng=!0;let cg=lg.text+"";if(lg.type==="counter"&&(lg._props.mode==="1"?cg=lg.countCurrent():lg._props.mode==="2"&&(lg.updateText({isUpdateBarCodeDate:!1}),cg=lg.text+"")),rg.maxEnd=cg.length,rg.isSplit){rg.start=Math.min(rg.start,rg.maxEnd);let ug=cg.slice(rg.start,rg.end);ag[Ag]=ug}else ag[Ag]=cg}Ag++}}},Cg=lg=>{lg.type==="text"&&this.concatTextIdListObj&&this.concatTextIdListObj[lg.id]&&(ng||(this.barcode2dOptions.bcid==="LPMixQrCode"?lg==null||lg.set("text",this.barcode2dOptions.text.replace(/\|&&&\|/g,"")):lg==null||lg.set("text",this.barcode2dOptions.text),lg.updateInGroup()),sg.push(lg))};if(eg.length>0)eg.forEach(lg=>{Ig(lg),Cg(lg)});else{const lg=Ag=>{Ag.type==="group"&&Ag._objects?Ag._objects.forEach(rg=>lg(rg)):(Ig(Ag),Cg(Ag))};(ig=this.canvas)==null||ig.getObjects().forEach(Ag=>lg(Ag))}return ng?(og=ag.join(""),this.barcode2dOptions.text=og,lpBcid.includes(this.barcode2dOptions.bcid)&&gg&&await this.getLongBeiImg(this.barcode2dOptions),this.dirty=!0,gg&&this.updateInGroup(),setTimeout(()=>{var lg;(lg=this.canvas)==null||lg.requestRenderAll()},0),sg.forEach(lg=>{lg==null||lg.set("text",og),lg.updateInGroup()}),og):""}else return""}setBarcode2DOption(eg){if(this.barcode2dOptions.bcid!==eg.bcid&&(eg.extra={},this.barcode2dOptions.extra={}),merge(this.barcode2dOptions,eg),eg.extra&&(typeof+eg.extra.version=="number"&&eg.extra.version==="0"&&(this.barcode2dOptions.extra=omit(this.barcode2dOptions.extra,["version"])),eg.extra.eclevel==="0"&&(this.barcode2dOptions.extra=omit(this.barcode2dOptions.extra,["eclevel"]))),this.syncTextHeight(this.measureTextAreaHeight(this.barcode2dOptions)),this.dirty=!0,!lpBcid.includes(this.barcode2dOptions.bcid)){let ig=this.group;for(;ig;)ig.dirty=!0,ig=ig.group}let gg=getAllObjectMap();this.updateBarCode2d([...gg.text,...gg.counter])}getBarcode2DOption(){return cloneDeep(this.barcode2dOptions)}toObject(eg){let gg=["barcode2dOptions","counterProps","concatTextIdListObj","increaseDate","barcodeDateFormatType","connectObjIds"];return super.toObject(eg?[...eg,...gg]:gg)}};Cu.type="Barcode2D";let ABarcode2D=Cu;ABarcode2D.fromObject=(tg,eg)=>ABarcode2D._fromObject(tg,{...eg,extraParam:"barcode2dOptions"}),tt.setClass(ABarcode2D),tt.setSVGClass(ABarcode2D);let contextMenuTextResolver=null;function setContextMenuTextResolver(tg){contextMenuTextResolver=tg}class ContextMenu{constructor(eg,gg){this.container=eg,this.menuItems=gg,this.activeSubmenus=[],this.shown=!1,this.disableTop=!1,this.disableBottom=!1,this.activeSubmenuHandler=this._activeSubmenuHandler.bind(this),this.menuItems=gg,this.menuElement=this.createMenuElement(),eg.appendChild(this.menuElement),this.setupEventListeners()}setTargetObj(eg){this.targetObj=eg}createMenuElement(){const eg=document.createElement("div");return eg.id="custom-context-menu",eg}resolveText(eg){if(eg==null)return"";const gg=eg;return(contextMenuTextResolver==null?void 0:contextMenuTextResolver(gg))??gg}createMenuItemElement(eg){const gg={itemText:eg.text??""};if(eg.isShow&&!eg.isShow(this.targetObj,gg))return document.createElement("div");if(gg.itemText=this.resolveText(gg.itemText),eg.isSeparator){const ag=document.createElement("div");return ag.classList.add("item-separator"),ag}if(eg.isGroupTitle){const ag=document.createElement("div");return ag.textContent=gg.itemText,ag.classList.add("item-group"),ag}const ig=document.createElement("div");ig.className="menu-item",ig.dataset.id=eg.id,eg.disabled&&ig.classList.add("canvas-contextmenu-disabled"),eg.subItems&&eg.subItems.length>0&&ig.classList.add("has-submenu");const ng=document.createElement("div");ng.textContent=gg.itemText;const og=document.createElement("div");if(og.classList.add("menu-item-content"),og.appendChild(ng),!eg.subItems||eg.subItems.length===0){const ag=document.createElement("div");ag.style.marginLeft="20px",ag.style.color="#999",ag.textContent=eg.hotKey||"",og.appendChild(ag)}if(ig.appendChild(og),eg.subItems&&eg.subItems.length>0){const ag=document.createElement("span");ag.className="arrow",ag.textContent="›",ig.appendChild(ag)}if(eg.subItems&&!eg.disabled){if(eg.subItems.length>0){const ag=this.activeSubmenus.length+1,sg=document.createElement("div");sg.className="submenu",sg.style.zIndex=ag+"",eg.subItems.forEach(Ig=>{const Cg=this.createMenuItemElement(Ig);Cg&&sg.appendChild(Cg)}),ig.appendChild(sg),ig.addEventListener("mouseenter",Ig=>{this.activeSubmenuHandler(Ig)||(sg.style.display="block",this.positionSubmenu(ig,sg),this.activeSubmenus.push(ig,sg))})}}else eg.disabled||(ig.addEventListener("click",ag=>{if(eg.handler){const sg=eg.handler(eg,ag);this.canvasContainer&&this.canvasContainer.focus({preventScroll:!0}),sg!==!1&&this.hide()}else this.hide();ag.stopPropagation()}),ig.addEventListener("mouseenter",this.activeSubmenuHandler));return ig}_activeSubmenuHandler(eg){if(this.activeSubmenus.length>0){const gg=eg.target;for(let ig=this.activeSubmenus.length-1;ig>0;ig-=2){const ng=this.activeSubmenus[ig-1],og=this.activeSubmenus[ig];if(ng.parentElement===gg.parentElement){if(ng===gg)return!0;og.style.display="none"}else{if(og.contains(gg))return!1;og.style.display="none"}this.activeSubmenus.pop(),this.activeSubmenus.pop()}}return!1}setupEventListeners(){document.addEventListener("click",eg=>{!this.menuElement.contains(eg.target)&&this.shown&&this.hide()}),document.addEventListener("keydown",eg=>{eg.key==="Escape"&&this.shown&&this.hide()})}positionMenu(eg,gg){const ig=window.innerWidth,ng=window.innerHeight,og=this.menuElement.offsetWidth,ag=this.menuElement.offsetHeight;eg+og>ig&&(eg=ig-og-5),gg+ag>ng&&(gg=ng-ag-5),this.menuElement.style.left=`${eg}px`,this.menuElement.style.top=`${gg}px`}positionSubmenu(eg,gg){const ig=eg.getBoundingClientRect(),ng=gg.offsetWidth,og=window.innerWidth,ag=getComputedStyle(gg);let sg=0,Ig=0;ig.right+ng>og?(sg=-ng-parseInt(ag.paddingLeft),gg.classList.add("left")):sg=ig.width+parseInt(ag.paddingLeft);const Cg=gg.offsetHeight,lg=window.innerHeight;ig.top+Cg>lg?Ig=ig.height-Cg+parseInt(ag.paddingBottom):Ig=-parseInt(ag.paddingTop),gg.style.left=`${sg}px`,gg.style.top=`${Ig}px`}show(eg,gg){console.time("show"),this.shown&&this.hide(),this.menuElement.innerHTML="",this.menuItems.forEach(ig=>{const ng=this.createMenuItemElement(ig);ng&&this.menuElement.appendChild(ng)}),this.menuElement.style.display="block",this.positionMenu(eg,gg),this.shown=!0,console.timeEnd("show")}hide(){this.shown&&(this.menuElement.style.display="none",this.menuElement.innerHTML="",this.shown=!1)}addItems(eg,gg){gg?this.addItemsToSubmenu(eg,gg,this.menuItems):this.menuItems.push(...eg)}addItemsToSubmenu(eg,gg,ig){for(const ng of ig){if(ng.id===gg)return ng.subItems||(ng.subItems=[]),ng.subItems.push(...eg),!0;if(ng.subItems&&this.addItemsToSubmenu(eg,gg,ng.subItems))return!0}return!1}updateItem(eg,gg){return this.updateItemRecursive(eg,gg,this.menuItems)}updateItemRecursive(eg,gg,ig){for(const ng of ig){if(ng.id===eg)return Object.assign(ng,gg),!0;if(ng.subItems&&this.updateItemRecursive(eg,gg,ng.subItems))return!0}return!1}removeItem(eg){return this.removeItemRecursive(eg,this.menuItems)}removeItemRecursive(eg,gg){const ig=gg.findIndex(ng=>ng.id===eg);if(ig!==-1)return gg.splice(ig,1),!0;for(const ng of gg)if(ng.subItems&&this.removeItemRecursive(eg,ng.subItems))return!0;return!1}getItems(){return this.menuItems}setItems(eg){this.menuItems=eg}}class ContextMenuPlugin{constructor(){this.name="ContextMenuPlugin",this.eventHandler={contextmenu:this.contextMenuHandler.bind(this)}}addItem(eg){var ig;const gg=Array.isArray(eg)?eg:[eg];(ig=this.contextMenu)==null||ig.addItems(gg),gg.forEach(ng=>{!ng.isGroupTitle&&!ng.isSeparator&&ng.hotKey&&ng.hotKeyHandler&&this.editor.addHotKey(ng.hotKey,ng.hotKeyHandler)})}removeItem(eg){var gg;(gg=this.contextMenu)==null||gg.removeItem(eg)}updateItem(eg,gg){if(this.contextMenu&&(this.contextMenu.updateItem(eg,gg),gg.hotKey&&gg.hotKeyHandler)){const ig=this.contextMenu.getItems().find(ng=>ng.id===eg);ig&&(ig.hotKey&&this.editor.removeHotKey(ig.hotKey),ig.hotKey=gg.hotKey,ig.hotKeyHandler=gg.hotKeyHandler,this.editor.addHotKey(ig.hotKey,ig.hotKeyHandler))}}disabled(){this.contextMenu&&this.container&&(this.editor.getCanvas().off("contextmenu",this.eventHandler.contextmenu),this.contextMenu.hide(),this.contextMenu.getItems().forEach(eg=>{!eg.isGroupTitle&&!eg.isSeparator&&eg.hotKey&&eg.hotKeyHandler&&this.editor.removeHotKey(eg.hotKey)}))}contextMenuHandler(eg){var gg;if(eg.e){const ig=eg.e;if(ig.button===2&&eg.target&&this.contextMenu){if(eg.target.id==="workspace")return;let ng=((gg=this.canvas)==null?void 0:gg.getObjects())||[];ng=ng.filter(Ig=>Ig.id!=="workspace");let og=ng==null?void 0:ng.indexOf(eg.target);const ag=og===(ng==null?void 0:ng.length)-1,sg=og===0;this.contextMenu.disableTop=ag,this.contextMenu.disableBottom=sg,eg.target.type==="activeselection"?eg.target.getObjects().length>1?(this.contextMenu.updateItem("lock",{disabled:!0}),this.contextMenu.updateItem("layer",{disabled:!0})):(this.contextMenu.updateItem("lock",{disabled:!1}),this.contextMenu.updateItem("layer",{disabled:!1})):(this.contextMenu.updateItem("lock",{disabled:!1}),this.contextMenu.updateItem("layer",{disabled:!1})),this.contextMenu.updateItem("layer-top",{disabled:!1}),this.contextMenu.updateItem("layer-up",{disabled:!1}),this.contextMenu.updateItem("layer-bottom",{disabled:!1}),this.contextMenu.updateItem("layer-down",{disabled:!1}),ag&&(this.contextMenu.updateItem("layer-top",{disabled:!0}),this.contextMenu.updateItem("layer-up",{disabled:!0})),sg&&(this.contextMenu.updateItem("layer-bottom",{disabled:!0}),this.contextMenu.updateItem("layer-down",{disabled:!0})),ig.preventDefault(),this.canvas.setActiveObject(eg.target),this.contextMenu.setTargetObj(eg.target),this.contextMenu.show(ig.clientX,ig.clientY)}}}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.container=document.getElementById("app"),this.contextMenu=new ContextMenu(this.container,[]),this.contextMenu.canvasContainer=this.canvas.elements.container,this.enabled()}enabled(){this.contextMenu&&this.container&&(this.editor.getCanvas().on("contextmenu",this.eventHandler.contextmenu),this.contextMenu.getItems().forEach(eg=>{!eg.isGroupTitle&&!eg.isSeparator&&eg.hotKey&&eg.hotKeyHandler&&this.editor.addHotKey(eg.hotKey,eg.hotKeyHandler)}))}}class Ruler{constructor(eg,gg){this.ctx=eg,this.dpi=96,this.isShown=!1,this.gapValue=0,this.getGapMM=ig=>{const ng=[.02,.05,.1,.2,.5,1,2,5,10],og=[500,200,100,50,25,10,5,2,1];let ag=0;for(;ag<ng.length&&ng[ag]<ig;)ag++;return og[ag-1]||1e3},this.options=gg}show(){this.isShown=!0}hide(){this.isShown=!1}drawLine(eg,gg,ig,ng,og,ag){this.ctx.save(),this.ctx.beginPath(),og&&(this.ctx.strokeStyle=og),this.ctx.lineWidth=ag??1,this.ctx.moveTo(eg+.5,gg+.5),this.ctx.lineTo(eg+ig+.5,gg+ng+.5),this.ctx.stroke(),this.ctx.restore()}drawText({text:eg="",left:gg=0,top:ig=0,fillStyle:ng,align:og,angle:ag,fontSize:sg=this.options.fontSize}){this.ctx.save(),ng&&(this.ctx.fillStyle=ng),this.ctx.textAlign=og??"left",this.ctx.textBaseline="top",this.ctx.font=`${sg??10}px sans-serif, Noto Sans, SourceHanSansCN`,ag&&(this.ctx.translate(gg,ig),this.ctx.rotate(Math.PI/180*ag),this.ctx.translate(-gg,-ig)),this.ctx.fillText(eg,gg,ig),this.ctx.restore()}darwRect({left:eg=0,top:gg=0,width:ig,height:ng,fillStyle:og,stroke:ag,strokeWidth:sg}){this.ctx.save(),this.ctx.beginPath(),og&&(this.ctx.fillStyle=og),this.ctx.rect(eg,gg,ig,ng),this.ctx.fill(),ag&&(this.ctx.strokeStyle=ag,this.ctx.lineWidth=sg??1,this.ctx.stroke()),this.ctx.restore()}drawMask(eg,gg,ig,ng,og,ag){this.ctx.save();const sg=eg?this.ctx.createLinearGradient(gg,og/2,gg+ng,og/2):this.ctx.createLinearGradient(ng/2,ig,ng/2,og+ig),Ig=new Le(ag);Ig.setAlpha(0),sg.addColorStop(0,Ig.toRgba()),sg.addColorStop(.33,ag),sg.addColorStop(.67,ag),sg.addColorStop(1,Ig.toRgba()),this.darwRect({left:gg,top:ig,width:ng,height:og,fillStyle:sg}),this.ctx.restore()}drawBackground(eg,gg,ig){const ng=this.options.rulerSize,og=this.options.canvasWidth,ag=this.options.canvasHeight;eg?this.darwRect({left:0,top:0,width:og,height:ng,fillStyle:this.options.backgroundColor}):this.darwRect({left:0,top:0,width:ng,height:ag,fillStyle:this.options.backgroundColor})}drawMM(eg,gg,ig){const ng=this.options.rulerSize,og=this.options.canvasWidth,ag=this.options.canvasHeight,sg=this.getGapMM(ig);this.gapValue=sg;const Ig=this.dpi/25.4*ig*sg,Cg=ng*.2,lg=ng*.8,Ag=new Le(this.options.textColor).toRgb();eg?(this.drawLine(0,0,og,0,this.options.borderColor),this.drawLine(0,ng,og,0,Ag)):(this.drawLine(0,0,0,ag,this.options.borderColor),this.drawLine(ng,0,0,ag,Ag)),this.ctx.save(),this.ctx.beginPath();let rg=sg>2,cg=sg>10?10:sg>=5?5:1;if(eg){if(this.ctx.rect(ng,0,og-ng,ng),this.ctx.clip(),gg<0){let hg=-gg*ig-Ig,mg=1;for(;hg>ng;){if(rg&&mg===1)for(let wg=1;wg<10;wg++){const Gg=hg+Ig/cg*wg;Gg>ng&&this.drawLine(Gg,Cg+13,0,lg*.3,Ag,1)}if(this.drawLine(hg,Cg+10,0,lg*.6,Ag),rg)for(let wg=1;wg<10;wg++){const Gg=hg-Ig/cg*wg;Gg>ng&&this.drawLine(Gg,Cg+13,0,lg*.3,Ag,1)}const bg=-mg*sg+"",pg=10*bg.length/4,fg=ng-this.options.fontSize-2;this.drawText({text:bg,left:hg-pg,top:fg-7,fillStyle:Ag,align:void 0,angle:0}),hg-=Ig,mg++}}let ug=-gg*ig,dg=0;for(;ug<og;){if(Math.ceil(ug)>=ng){if(this.drawLine(ug,Cg+10,0,lg*.6,Ag),rg)for(let pg=1;pg<10;pg++){const fg=ug+Ig/cg*pg;fg<og&&this.drawLine(fg,Cg+13,0,lg*.3,Ag,1)}const hg=dg*sg+"",mg=10*hg.length/4,bg=ng-this.options.fontSize-2;this.drawText({text:hg,left:ug-mg,top:bg-7,fillStyle:Ag,align:void 0,angle:0})}ug+=Ig,dg++}}else{if(this.ctx.rect(0,ng,ng,ag-ng),this.ctx.clip(),gg<0){let hg=-gg*ig-Ig,mg=1;for(;hg>ng;){if(rg&&mg===1)for(let wg=1;wg<10;wg++){const Gg=hg+Ig/cg*wg;Gg>ng&&this.drawLine(Cg+13,Gg,lg*.3,0,Ag,1)}if(this.drawLine(Cg+10,hg,lg*.6,0,Ag),rg)for(let wg=1;wg<10;wg++){const Gg=hg-Ig/cg*wg;Gg>ng&&this.drawLine(Cg+13,Gg,lg*.3,0,Ag,1)}const bg=-mg*sg+"",pg=10*bg.length/4,fg=ng-this.options.fontSize-2;this.drawText({text:bg,left:fg-7,top:hg+pg,fillStyle:Ag,align:void 0,angle:-90}),hg-=Ig,mg++}}let ug=-gg*ig,dg=0;for(;ug<ag;){if(ug>ng){if(this.drawLine(Cg+10,ug,lg*.6,0,Ag),rg)for(let pg=1;pg<10;pg++){const fg=ug+Ig/cg*pg;fg<ag&&this.drawLine(Cg+13,fg,lg*.3,0,Ag,1)}const hg=dg*sg+"",mg=10*hg.length/4,bg=ng-this.options.fontSize-2;this.drawText({text:hg,left:bg-7,top:ug+mg,fillStyle:Ag,align:void 0,angle:-90})}ug+=Ig,dg++}}this.ctx.restore()}drawActiveLine(eg,gg,ig){if(!this.objectRect)return;const ng=this.options.rulerSize,og=eg?"x":"y",ag=new Le(this.options.maskColor);this.objectRect[og].forEach(sg=>{if(ag.setAlpha(.5),sg.skip===og)return;let Ig=eg?sg.left:sg.top,Cg=eg?sg.width:sg.height,lg=(Ig-gg)*ig,Ag=Cg*ig;const rg={width:eg?Ag:ng-8,height:eg?ng-8:Ag,backgroundColor:this.options.backgroundColor};this.drawMask(eg,eg?lg:0,eg?2:lg,rg.width,rg.height,rg.backgroundColor),this.darwRect({left:eg?lg:ng-8,top:eg?ng-8:lg,width:eg?Ag:8,height:eg?8:Ag,fillStyle:ag.toRgba()});const cg=ng/2-(this.options.fontSize??12)/2-4,ug=pg=>Math.round(pg*(25.4/Editor.DPI)*100)/100+"",dg=ug(Ig),hg=ug(Ig+Cg),mg={fill:ag.toRgba(),angle:eg?0:-90};this.drawText({text:dg,left:eg?lg-2:cg,top:eg?cg:lg-15,fillStyle:mg.fill,align:eg?"right":"center",angle:mg.angle}),dg!==hg&&this.drawText({text:hg,left:eg?lg+Ag+2:cg,top:eg?cg:lg+Ag+17,fillStyle:mg.fill,align:eg?"left":"center",angle:mg.angle});const bg=dg===hg?8:14;ag.setAlpha(1),this.drawLine(eg?lg:ng-bg,eg?ng-bg:lg,eg?0:bg,eg?bg:0,ag.toRgba()),dg!==hg&&this.drawLine(eg?lg+Ag:ng-bg,eg?ng-bg:lg+Ag,eg?0:bg,eg?bg:0,ag.toRgba())})}}class RulerPlugin{constructor(){this.name="RulerPlugin",this.eventHandler={calcObjectRect:throttle$3(this.calcObjectRect.bind(this),15),selectinClear:throttle$3(this.selectionClear.bind(this),15),renderRuler:eg=>{eg.ctx&&this.renderRuler()},canvasMouseDown:throttle$3(this.canvasMouseDown.bind(this),15),canvasMouseMove:throttle$3(this.canvasMouseMove.bind(this),15),canvasMouseUp:throttle$3(this.canvasMouseUp.bind(this),15)}}uninstall(){}install(eg,gg){this.editor=eg;const ig=Object.assign({rulerSize:25,fontSize:12,canvasWidth:this.editor.getCanvas().width,canvasHeight:this.editor.getCanvas().height,backgroundColor:"#fff",borderColor:"#ddd",maskColor:"#007fff",textColor:"#888"},gg);this.ruler=new Ruler(eg.getCanvas().elements.lower.ctx,ig),eg.getPlugin("ContextMenuPlugin")}enabled(){if(this.editor&&this.ruler&&!this.ruler.isShown){const eg=this.editor.getCanvas();eg.on("after:render",this.eventHandler.calcObjectRect),eg.on("after:render",this.eventHandler.renderRuler),eg.on("mouse:down",this.eventHandler.canvasMouseDown),eg.on("mouse:move",this.eventHandler.canvasMouseMove),eg.on("mouse:up",this.eventHandler.canvasMouseUp),eg.on("selection:cleared",this.eventHandler.selectinClear),this.ruler.dpi=Editor.DPI,this.ruler.show(),this.renderRuler()}}disabled(){if(this.editor&&this.ruler&&this.ruler.isShown){this.ruler.hide();const eg=this.editor.getCanvas();eg.off("after:render",this.eventHandler.calcObjectRect),eg.off("after:render",this.eventHandler.renderRuler),eg.off("mouse:down",this.eventHandler.canvasMouseDown),eg.off("mouse:move",this.eventHandler.canvasMouseMove),eg.off("mouse:up",this.eventHandler.canvasMouseUp),eg.off("selection:cleared",this.eventHandler.selectinClear),this.editor.getCanvas().renderAll()}}setCanvasSize(eg,gg){this.ruler&&(this.ruler.options.canvasWidth=eg,this.ruler.options.canvasHeight=gg)}calcObjectRect(){if(!this.editor)return;const gg=this.editor.getCanvas().getActiveObjects();if(gg.length===0)return;const ig=gg.reduce((ng,og)=>{const ag=og.getBoundingRect();return ng.push(ag),ng},[]);ig.length!==0&&(this.ruler.objectRect={x:mergeLines(ig,!0),y:mergeLines(ig,!1)})}renderRuler(){if(!this.editor||!this.ruler||!this.ruler.isShown)return;const eg=this.editor.getCanvas(),gg=eg.viewportTransform;gg&&(this.ruler.drawBackground(!0,-(gg[4]/gg[0]),eg.getZoom()),this.ruler.drawBackground(!1,-(gg[5]/gg[3]),eg.getZoom()),this.ruler.drawMM(!0,-(gg[4]/gg[0]),eg.getZoom()),this.ruler.drawMM(!1,-(gg[5]/gg[3]),eg.getZoom()),this.ruler.drawActiveLine(!0,-(gg[4]/gg[0]),eg.getZoom()),this.ruler.drawActiveLine(!1,-(gg[5]/gg[3]),eg.getZoom()),this.ruler.options.callback&&this.ruler.options.callback(this.ruler.gapValue))}canvasMouseDown(){}canvasMouseUp(){}canvasMouseMove(){}selectionClear(){this.ruler&&(this.ruler.objectRect=void 0)}}const mergeLines=(tg,eg)=>{const gg=eg?"left":"top",ig=eg?"width":"height",ng=1e-6;if(!tg||tg.length===0)return[];if(tg.length===1)return[Object.assign({},tg[0])];tg.sort((sg,Ig)=>sg[gg]-Ig[gg]);const og=[];let ag=Object.assign({},tg[0]);for(let sg=1;sg<tg.length;sg++){const Ig=tg[sg],Cg=ag[gg]+ag[ig],lg=Ig[gg];if(Cg>=lg-ng){const Ag=Math.max(Cg,Ig[gg]+Ig[ig]);ag[ig]=Ag-ag[gg]}else og.push(ag),ag=Object.assign({},Ig)}return og.push(ag),og};class WorkspacePlugin{constructor(){this.name="WorkspacePlugin",this.gapVal=20,this.backgroundColor="#FFFFFFFF",this.backgroundImage="",this.backgroundImageCover=!0,this.backgroundImageElement=null,this.backgroundImageLoadId=0,this.resizeFrame=0,this.resizeTimer=null,this.lastCanvasSize={width:0,height:0},this.resizeObserver=new ResizeObserver(eg=>{!eg.find(ig=>ig.target===this.workspaceEl)||!this.canvas||(cancelAnimationFrame(this.resizeFrame),this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(()=>{this.resizeFrame=requestAnimationFrame(()=>{this.applyCanvasViewportSize()})},80))}),this.initWorkspace=()=>{const eg=this.canvas,gg=this.option.type;let ig;gg==="Rectangle"||gg==="RoundedRectangle"?ig=new Er({fill:this.option.backgroundColor??"yellow",width:this.option.width,height:this.option.height,rx:this.option.rx,ry:this.option.ry,strokeWidth:0}):ig=new _o({fill:this.option.backgroundColor??"yellow",width:this.option.width,height:this.option.height,rx:this.option.rx,ry:this.option.ry,strokeWidth:0}),ig.set("id","workspace"),ig.set("workspaceBackgroundColor",this.backgroundColor),ig.set("workspaceBackgroundImage",this.backgroundImage),ig.set("workspaceBackgroundImageCover",this.backgroundImageCover),this.bindRibbonBorderRender(ig),ig.set("selectable",!1),ig.set("hasControls",!1),ig.excludeFromExport=!0,ig.moveCursor="default",ig.hoverCursor="default",eg.insertAt(0,ig),this.workspace=ig,this.refreshWorkspaceBackground(),eg.renderAll();const{width:ng,height:og}=this.getWorkspaceViewportSize();eg.setDimensions({width:ng,height:og}),this.lastCanvasSize={width:ng,height:og},this.resizeObserver.observe(this.workspaceEl),eg.on("mouse:wheel",this.onWheel);const ag=eg.getWidth()*.7,sg=eg.getHeight()*.7,Ig=ag/this.option.width,Cg=sg/this.option.height;this.setZoomAuto(Math.min(Ig,Cg))},this.onWheel=eg=>{if(!this.canvas)return;const gg=eg.e.deltaY;let ig=this.canvas.getZoom();ig*=.999**gg,ig=this.clampZoom(ig);const ng=this.canvas.getCenter();this.canvas.zoomToPoint(new ot(ng.left,ng.top),ig),eg.e.preventDefault(),eg.e.stopPropagation()}}getWorkspaceViewportSize(){return{width:Math.floor(this.workspaceEl.clientWidth),height:Math.floor(this.workspaceEl.clientHeight)}}applyCanvasViewportSize(){if(!this.canvas)return;const{width:eg,height:gg}=this.getWorkspaceViewportSize();if(!(eg<=0||gg<=0)&&!(eg===this.lastCanvasSize.width&&gg===this.lastCanvasSize.height)){if(this.lastCanvasSize={width:eg,height:gg},this.editor){const ig=this.editor.getPlugin("RulerPlugin");ig&&ig.setCanvasSize(eg,gg)}this.canvas.setDimensions({width:eg,height:gg}),this.workspace&&this.setCenterFromObject(this.workspace)}}findParent(eg){for(;eg;){if(eg.id==="workspace")return eg;eg=eg.parentElement}return null}install(eg,gg){const ig=this.findParent(eg.getCanvas().elements.container);if(!ig)throw new Error("element #workspace is missing, plz check!");this.editor=eg,this.workspaceEl=ig,this.workspace=void 0,this.option=gg,this.backgroundColor=(gg==null?void 0:gg.backgroundColor)||"#FFFFFFFF",this.backgroundImage=(gg==null?void 0:gg.backgroundImage)||"",this.backgroundImageCover=(gg==null?void 0:gg.backgroundImageCover)!==!1,this.loadBackgroundImageElement(this.backgroundImage),this.editor.addHook("setSize",this.initWorkspace);const ng=eg.getCanvas();ng.backgroundImage=void 0,this.canvas=ng,this.initWorkspace()}uninstall(){var eg,gg;cancelAnimationFrame(this.resizeFrame),this.resizeTimer&&(clearTimeout(this.resizeTimer),this.resizeTimer=null),this.resizeObserver.disconnect(),(eg=this.canvas)==null||eg.off("mouse:wheel",this.onWheel),this.workspace&&((gg=this.canvas)==null||gg.remove(this.workspace)),this.workspace=void 0,this.canvas=void 0,this.editor=void 0}bindRibbonBorderRender(eg){const gg=eg._render.bind(eg);eg._render=ig=>{var sg,Ig,Cg;if(gg(ig),this.drawBackgroundImage(ig,eg),this.drawGrid(ig,eg),(sg=this.editor)!=null&&sg.getCanvas().get("flagToDataURL"))return;const ng=(Ig=this.editor)==null?void 0:Ig.ribbonBorderPattern;if(!ng||ng==="none")return;const og=eg.width||this.option.width,ag=eg.height||this.option.height;drawRibbonBorder(ig,ng,{left:-og/2,top:-ag/2,width:og,height:ag},(Cg=this.editor)==null?void 0:Cg.ribbonBorderTextures)}}createWorkspacePath(eg,gg){const ig=gg.width||this.option.width,ng=gg.height||this.option.height,og=-ig/2,ag=-ng/2;if(eg.beginPath(),gg.type==="ellipse"){eg.ellipse(0,0,ig/2,ng/2,0,0,Math.PI*2);return}const sg=Math.min(Math.abs(gg.rx||0),ig/2),Ig=Math.min(Math.abs(gg.ry||0),ng/2);if(!sg&&!Ig){eg.rect(og,ag,ig,ng);return}eg.moveTo(og+sg,ag),eg.lineTo(og+ig-sg,ag),eg.quadraticCurveTo(og+ig,ag,og+ig,ag+Ig),eg.lineTo(og+ig,ag+ng-Ig),eg.quadraticCurveTo(og+ig,ag+ng,og+ig-sg,ag+ng),eg.lineTo(og+sg,ag+ng),eg.quadraticCurveTo(og,ag+ng,og,ag+ng-Ig),eg.lineTo(og,ag+Ig),eg.quadraticCurveTo(og,ag,og+sg,ag)}drawBackgroundImage(eg,gg){const ig=this.backgroundImageElement;if(!ig||!this.backgroundImage)return;const ng=gg.width||this.option.width,og=gg.height||this.option.height,ag=ig.naturalWidth||ig.width,sg=ig.naturalHeight||ig.height;if(!ag||!sg)return;const Ig=this.backgroundImageCover?ng:ag,Cg=this.backgroundImageCover?og:sg,lg=-Ig/2,Ag=-Cg/2;eg.save(),this.createWorkspacePath(eg,gg),eg.clip(),eg.drawImage(ig,lg,Ag,Ig,Cg),eg.restore()}drawGrid(eg,gg){var Ig;if(!gg.isHasGrid||(Ig=this.editor)!=null&&Ig.getCanvas().get("flagToDataURL"))return;const ig=gg.width||this.option.width,ng=gg.height||this.option.height,og=-ig/2,ag=-ng/2,sg=20;eg.save(),this.createWorkspacePath(eg,gg),eg.clip(),eg.strokeStyle="#888",eg.lineWidth=1,eg.globalAlpha=1;for(let Cg=og+sg;Cg<og+ig;Cg+=sg)eg.beginPath(),eg.moveTo(Cg,ag),eg.lineTo(Cg,ag+ng),eg.stroke();for(let Cg=ag+sg;Cg<ag+ng;Cg+=sg)eg.beginPath(),eg.moveTo(og,Cg),eg.lineTo(og+ig,Cg),eg.stroke();eg.restore()}setZoomAuto(eg){if(!this.editor||!this.canvas)return;this.workspaceEl;const gg=this.editor.getCanvas();if(!gg)return;const ig=gg.getCenterPoint();gg.setViewportTransform(T$1),gg.zoomToPoint(new ot(ig.x,ig.y),eg),this.workspace&&this.setCenterFromObject(this.workspace)}setCenterFromObject(eg){if(!this.editor||!this.canvas)return;const gg=this.editor.getCanvas(),ig=eg.getCenterPoint(),ng=gg.viewportTransform;gg.width===void 0||gg.height===void 0||!ng||(ng[4]=gg.width/2-ig.x*ng[0],ng[5]=gg.height/2-ig.y*ng[3],gg.setViewportTransform(ng),gg.renderAll())}showGrid(){this.createGridBackground()}hideGrid(){this.createGridBackground(!1)}async setBackground({color:eg,image:gg,cover:ig}){eg!==void 0&&(this.backgroundColor=eg||"#FFFFFFFF"),gg!==void 0&&(this.backgroundImage=gg||""),ig!==void 0&&(this.backgroundImageCover=ig),this.workspace&&(this.workspace.set("workspaceBackgroundColor",this.backgroundColor),this.workspace.set("workspaceBackgroundImage",this.backgroundImage),this.workspace.set("workspaceBackgroundImageCover",this.backgroundImageCover)),gg!==void 0&&await this.loadBackgroundImageElement(this.backgroundImage),this.refreshWorkspaceBackground()}refreshWorkspaceBackground(){!this.workspace||!this.canvas||(this.workspace.set("fill",this.backgroundColor||"#FFFFFFFF"),this.workspace.dirty=!0,this.canvas.requestRenderAll())}async loadBackgroundImageElement(eg){var ig;const gg=++this.backgroundImageLoadId;if(!eg){this.backgroundImageElement=null;return}try{const ng=await new Promise((og,ag)=>{const sg=new Image;sg.onload=()=>og(sg),sg.onerror=ag,sg.src=eg});if(gg!==this.backgroundImageLoadId)return;this.backgroundImageElement=ng,this.workspace&&(this.workspace.dirty=!0),(ig=this.canvas)==null||ig.requestRenderAll()}catch(ng){if(gg!==this.backgroundImageLoadId)return;this.backgroundImageElement=null,console.log("load background image error",ng)}}createGridBackground(eg=!0){!this.canvas||!this.workspace||(this.workspace.set("isHasGrid",eg),this.workspace.dirty=!0,this.canvas.renderAll())}getFitZoom(){if(!this.canvas||!this.option)return .2;const eg=this.canvas.getWidth()*.7,gg=this.canvas.getHeight()*.7,ig=eg/this.option.width,ng=gg/this.option.height;return Math.min(ig,ng)}getMinZoom(){return Math.max(.005,Math.min(.2,this.getFitZoom()*.5))}getMaxZoom(){return 12}clampZoom(eg){return Math.min(this.getMaxZoom(),Math.max(this.getMinZoom(),eg))}big(){let eg=this.canvas.getZoom();eg+=.05;const gg=this.canvas.getCenter();this.canvas.zoomToPoint(new ot(gg.left,gg.top),this.clampZoom(eg))}small(){let eg=this.canvas.getZoom();eg-=.05;const gg=this.canvas.getCenter();this.canvas.zoomToPoint(new ot(gg.left,gg.top),this.clampZoom(eg))}auto(){this.setZoomAuto(this.getFitZoom())}one(){this.setZoomAuto(1)}createExportWorkspace(eg){if(!this.workspace)return null;const gg=this.workspace,ig=gg.type==="ellipse",ng={fill:this.backgroundColor,width:gg.width,height:gg.height,rx:gg.rx,ry:gg.ry,strokeWidth:0,left:gg.left,top:gg.top};let og;if(ig?og=new _o(ng):og=new Er(ng),og.set("id","workspace"),og.set("selectable",!1),this.backgroundImageElement&&this.backgroundImage){const ag=og._render.bind(og);og._render=sg=>{ag(sg),this.drawBackgroundImage(sg,og)}}return eg.insertAt(0,og),og}enabled(){}disabled(){}}const aligningLineConfig={margin:4,width:1,color:"rgb(255,0,0,0.9)"};function getDistance(tg,eg){return Math.abs(tg-eg)}function setPositionDir(tg,eg,gg){const ig=tg.translateToCenterPoint(eg,"center","center"),ng=tg.translateToOriginPoint(ig,tg.originX,tg.originY);gg=="x"?tg.setX(ng.x):tg.setY(ng.y)}const originXArr=["left","center","right"],originYArr=["top","center","bottom"];function collectVerticalPoint(tg){var eg,gg;const ig=aligningLineConfig.margin,{activeObject:ng,isScale:og,index:ag,point:sg,list:Ig}=tg,{dis:Cg,arr:lg}=getDistanceList(sg,Ig,"x"),Ag=ig/((eg=(gg=ng.canvas)===null||gg===void 0?void 0:gg.getZoom())!==null&&eg!==void 0?eg:1);if(Cg>Ag)return[];let rg=lg[lg.length-1].x-sg.x;const cg=ag==0||ag==3?-1:1;rg*=cg;const{width:ug,scaleX:dg,left:hg}=ng,mg=ng._getTransformedDimensions(),bg=(rg+mg.x)/mg.x;og?ng.set("scaleX",dg*bg):ng.set("width",ug*bg);const pg=[0,rg/2*cg,rg*cg];cg<0&&pg.reverse();const fg=pg[originXArr.indexOf(ng.originX)];return ng.set("left",hg+fg),ng.setCoords(),lg.map(wg=>({x:wg.x,y1:wg.y,y2:sg.y}))}function collectHorizontalPoint(tg){var eg,gg;const ig=aligningLineConfig.margin,{activeObject:ng,isScale:og,index:ag,point:sg,list:Ig}=tg,{dis:Cg,arr:lg}=getDistanceList(sg,Ig,"y"),Ag=ig/((eg=(gg=ng.canvas)===null||gg===void 0?void 0:gg.getZoom())!==null&&eg!==void 0?eg:1);if(Cg>Ag)return[];let rg=lg[lg.length-1].y-sg.y;const cg=ag<2?-1:1;rg*=cg;const{height:ug,scaleY:dg,top:hg}=ng,mg=ng._getTransformedDimensions(),bg=(rg+mg.y)/mg.y;og?ng.set("scaleY",dg*bg):ng.set("height",ug*bg);const pg=[0,rg/2*cg,rg*cg];cg<0&&pg.reverse();const fg=pg[originYArr.indexOf(ng.originY)];return ng.set("top",hg+fg),ng.setCoords(),lg.map(wg=>({y:wg.y,x1:wg.x,x2:sg.x}))}function getDistanceList(tg,eg,gg){let ig=1/0,ng=[];for(const og of eg){const ag=getDistance(tg[gg],og[gg]);ig>ag&&(ng=[],ig=ag),ig==ag&&ng.push(og)}return{dis:ig,arr:ng}}function drawLine(tg,eg,gg){const{width:ig,color:ng}=aligningLineConfig,og=tg.getSelectionContext(),ag=tg.viewportTransform,sg=tg.getZoom();og.save(),og.transform(...ag),og.lineWidth=ig/sg,og.strokeStyle=ng,og.beginPath(),og.moveTo(eg.x,eg.y),og.lineTo(gg.x,gg.y),og.stroke(),drawX(og,sg,eg),drawX(og,sg,gg),og.restore()}const xSize=2.4;function drawX(tg,eg,gg){const ig=xSize/eg;tg.save(),tg.translate(gg.x,gg.y),tg.beginPath(),tg.moveTo(-ig,-ig),tg.lineTo(ig,ig),tg.moveTo(ig,-ig),tg.lineTo(-ig,ig),tg.stroke(),tg.restore()}function drawPoint(tg,eg){const{width:gg,color:ig}=aligningLineConfig,ng=tg.getSelectionContext(),og=tg.viewportTransform,ag=tg.getZoom();ng.save(),ng.transform(...og),ng.lineWidth=gg/ag,ng.strokeStyle=ig;for(const sg of eg)drawX(ng,ag,sg);ng.restore()}function drawPointList(tg,eg){const gg=eg.map(ig=>{const ng="y2"in ig,og=ng?ig.x:ig.x1,ag=ng?ig.y1:ig.y;return new ot(og,ag)});drawPoint(tg,gg)}function drawVerticalLine(tg,eg){const gg=eg.x,ig=new ot(gg,eg.y1),ng=new ot(gg,eg.y2);drawLine(tg,ig,ng)}function drawHorizontalLine(tg,eg){const gg=eg.y,ig=new ot(eg.x1,gg),ng=new ot(eg.x2,gg);drawLine(tg,ig,ng)}function getObjectsByTarget(tg){const eg=new Set,gg=tg.canvas;if(!gg)return eg;const ig=tg instanceof Jo?tg.getObjects():[tg];return gg.forEachObject(ng=>{if(ng.isOnScreen()&&ng.visible){if(ng.constructor==Hr){collectObjectsByGroup(eg,ng);return}eg.add(ng)}}),deleteObjectsByList(eg,ig),eg}function deleteObjectsByList(tg,eg){for(const gg of eg)gg.constructor==Hr?deleteObjectsByList(tg,gg.getObjects()):tg.delete(gg)}function collectObjectsByGroup(tg,eg){const gg=eg.getObjects();for(const ig of gg)if(ig.visible){if(ig.constructor==Hr){collectObjectsByGroup(tg,ig);continue}tg.add(ig)}}function collectLine(tg){var eg,gg;const ig=aligningLineConfig.margin,{activeObject:ng,activeObjectRect:og,objectRect:ag}=tg,sg=makeLineByRect(ag),Ig=makeLineByRect(og),Cg=ig/((eg=(gg=ng.canvas)===null||gg===void 0?void 0:gg.getZoom())!==null&&eg!==void 0?eg:1),lg={target:ng,list:sg,aList:Ig,margin:Cg},Ag=collectVerticalLine(lg),rg=collectHorizontalLine(lg);return{vLines:Ag,hLines:rg}}function collectVerticalLine(tg){const{target:eg,list:gg,aList:ig,margin:ng}=tg,og=ig.map(Ag=>getDistanceLine(Ag,gg,"x")),ag=Math.min(...og.map(Ag=>Ag.dis));if(ag>ng)return[];const sg=[],Ig=ig[0].x2-ig[0].x,Cg=ig[0].y2-ig[0].y;let lg=!1;for(let Ag=0;Ag<og.length;Ag++){const rg=og[Ag];if(ag==rg.dis){const cg=gg[rg.index],ug=ig[rg.index],dg=cg.x,hg=ug.y,mg=Math.min(cg.y,cg.y2,hg,ug.y2),bg=Math.max(cg.y,cg.y2,hg,ug.y2);if(sg.push({x:dg,y1:mg,y2:bg}),lg)continue;lg=!0,setPos({target:eg,x:dg,y:hg,centerX:Ag-1,centerY:rg.index-1,width:Ig,height:Cg,dir:"x"});const pg=ag*rg.dir;ig.forEach(fg=>fg.x-=pg)}}return sg}function collectHorizontalLine(tg){const{target:eg,list:gg,aList:ig,margin:ng}=tg,og=ig.map(Ag=>getDistanceLine(Ag,gg,"y")),ag=Math.min(...og.map(Ag=>Ag.dis));if(ag>ng)return[];const sg=[],Ig=ig[0].x2-ig[0].x,Cg=ig[0].y2-ig[0].y;let lg=!1;for(let Ag=0;Ag<og.length;Ag++){const rg=og[Ag];if(ag==rg.dis){const cg=gg[rg.index],ug=ig[rg.index],dg=cg.y,hg=ug.x,mg=Math.min(cg.x,cg.x2,hg,ug.x2),bg=Math.max(cg.x,cg.x2,hg,ug.x2);if(sg.push({y:dg,x1:mg,x2:bg}),lg)continue;lg=!0,setPos({target:eg,x:hg,y:dg,centerX:rg.index-1,centerY:Ag-1,width:Ig,height:Cg,dir:"y"});const pg=ag*rg.dir;ig.forEach(fg=>fg.y-=pg)}}return sg}function getDistanceLine(tg,eg,gg){let ig=1/0,ng=-1,og=1;for(let ag=0;ag<eg.length;ag++){const sg=getDistance(tg[gg],eg[ag][gg]);ig>sg&&(ng=ag,ig=sg,og=tg[gg]>eg[ag][gg]?1:-1)}return{dis:ig,index:ng,dir:og}}function makeLineByRect(tg){const{left:eg,top:gg,width:ig,height:ng}=tg,og={x:eg,y:gg,x2:eg+ig,y2:gg+ng},ag=eg+ig/2,sg=gg+ng/2,Ig={x:ag,y:sg,x2:ag,y2:sg},Cg={x:eg+ig,x2:eg,y:gg+ng,y2:gg};return[og,Ig,Cg]}function setPos(tg){const{target:eg,centerX:gg,centerY:ig,width:ng,height:og,dir:ag}=tg;let{x:sg,y:Ig}=tg;sg-=gg*ng/2,Ig-=ig*og/2,setPositionDir(eg,new ot(sg,Ig),ag),eg.setCoords()}function initAligningGuidelines(tg){let eg=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(aligningLineConfig,eg);const gg=new Set,ig=new Set;let ng=!1;const og=new Map,ag=rg=>{const cg=[rg.calcTransformMatrix().toString(),rg.width,rg.height].join(),ug=og.get(cg);if(ug)return ug;const dg=rg.getCoords(),mg=[kn.makeBoundingBoxFromPoints(dg),dg];return og.set(cg,mg),mg};function sg(rg){const cg=rg.target;cg.setCoords(),ng=!1,ig.clear(),gg.clear();const ug=getObjectsByTarget(cg),dg=cg.getBoundingRect();for(const hg of ug){const mg=ag(hg)[0],{vLines:bg,hLines:pg}=collectLine({activeObject:cg,activeObjectRect:dg,objectRect:mg});bg.forEach(fg=>{ig.add(JSON.stringify(fg))}),pg.forEach(fg=>{gg.add(JSON.stringify(fg))})}}function Ig(rg){const cg=rg.target;cg.setCoords();const ug=String(rg.transform.action).startsWith("scale");ig.clear(),gg.clear();const dg=getObjectsByTarget(cg);let hg=rg.transform.corner;cg.flipX&&(hg=hg.replace("l","r").replace("r","l")),cg.flipY&&(hg=hg.replace("t","b").replace("b","t"));let mg=["tl","tr","br","bl","mt","mr","mb","ml"].indexOf(hg);if(mg==-1)return;if(ng=mg>3,ng){if(cg.getTotalAngle()%90!=0)return;mg-=4}let bg=cg.getCoords()[mg];for(const pg of dg){const[fg,wg]=ag(pg),Gg=new ot(fg.left+fg.width/2,fg.top+fg.height/2),Zg=[...wg,Gg],$g={activeObject:cg,point:bg,list:Zg,isScale:ug,index:mg},Bg=collectVerticalPoint($g),Wg=collectHorizontalPoint($g);Bg.forEach(yg=>{ig.add(JSON.stringify(yg))}),Wg.forEach(yg=>{gg.add(JSON.stringify(yg))}),(Bg.length||Wg.length)&&(bg=cg.getCoords()[mg])}}function Cg(){tg.clearContext(tg.contextTop)}function lg(){if(ng){const rg=[];for(const cg of ig)rg.push(JSON.parse(cg));for(const cg of gg)rg.push(JSON.parse(cg));drawPointList(tg,rg)}else{for(const rg of ig)drawVerticalLine(tg,JSON.parse(rg));for(const rg of gg)drawHorizontalLine(tg,JSON.parse(rg))}}function Ag(){ig.clear(),gg.clear(),og.clear(),tg.requestRenderAll()}return tg.on("object:resizing",Ig),tg.on("object:scaling",Ig),tg.on("object:moving",sg),tg.on("before:render",Cg),tg.on("after:render",lg),tg.on("mouse:up",Ag),()=>{tg.off("object:resizing",Ig),tg.off("object:scaling",Ig),tg.off("object:moving",sg),tg.off("before:render",Cg),tg.off("after:render",lg),tg.off("mouse:up",Ag)}}class GuidelinesPlugin{constructor(){this.name="GuidelinesPlugin"}install(eg,gg={}){this.editor=eg,this.options=gg,this.enabled()}enabled(){this.editor&&(this.deactivate=initAligningGuidelines(this.editor.getCanvas(),this.options))}disabled(){this.deactivate&&this.deactivate()}}const getEffectiveCanvasTool=(tg,eg)=>eg.size>0?"pan":tg,isEditableShortcutTarget=tg=>{var ig;if(!tg||typeof tg.tagName!="string")return!1;const eg=tg,gg=eg.tagName.toUpperCase();return gg==="INPUT"||gg==="TEXTAREA"||gg==="SELECT"||!!((ig=eg.closest)!=null&&ig.call(eg,'[contenteditable="true"]'))};class DringPlugin{constructor(){this.name="DringPlugin",this.persistentTool="select",this.temporaryPanSources=new Set,this.isDragging=!1,this.isEnabled=!1,this.lastPosX=0,this.lastPosY=0,this.previousCanvasSelection=!0,this.previousSkipTargetFind=!1,this.previousDefaultCursor="default",this.dispose=[],this.mouseDown=eg=>{const gg=eg.e,ig=this.getPointerPanSource(gg);ig&&this.temporaryPanSources.add(ig),!(!(gg.button===0&&this.getEffectiveTool()==="pan")&&!ig)&&(gg.preventDefault(),this.isDragging=!0,this.lastPosX=gg.clientX,this.lastPosY=gg.clientY,this.applyEffectiveTool())},this.mouseMove=eg=>{if(!this.isDragging||!this.canvas.viewportTransform)return;const gg=eg.e,ig=this.canvas.viewportTransform;ig[4]+=gg.clientX-this.lastPosX,ig[5]+=gg.clientY-this.lastPosY,this.lastPosX=gg.clientX,this.lastPosY=gg.clientY,this.canvas.setCursor("grabbing"),this.canvas.requestRenderAll()},this.mouseUp=()=>{this.finishDragging()},this.windowMouseUp=()=>{this.finishDragging()},this.keyDown=eg=>{if(isEditableShortcutTarget(eg.target)||this.isFabricTextEditing())return;if(eg.code==="Space"){eg.preventDefault(),this.temporaryPanSources.add("space"),this.applyEffectiveTool();return}if(eg.repeat)return;const gg=eg.key.toLowerCase();gg==="v"?this.setTool("select"):gg==="h"&&this.setTool("pan")},this.keyUp=eg=>{eg.code==="Space"&&(this.temporaryPanSources.delete("space"),this.applyEffectiveTool())},this.windowBlur=()=>{this.temporaryPanSources.clear(),this.isDragging=!1,this.applyEffectiveTool()}}install(eg){this.editor=eg,this.canvas=eg.getCanvas(),this.previousCanvasSelection=this.canvas.selection,this.previousSkipTargetFind=this.canvas.skipTargetFind,this.previousDefaultCursor=this.canvas.defaultCursor,this.enabled()}uninstall(){this.disabled()}enabled(){this.isEnabled||(this.isEnabled=!0,this.dispose.push(this.canvas.on("mouse:down",this.mouseDown)),this.dispose.push(this.canvas.on("mouse:move",this.mouseMove)),this.dispose.push(this.canvas.on("mouse:up",this.mouseUp)),document.addEventListener("keydown",this.keyDown),document.addEventListener("keyup",this.keyUp),window.addEventListener("mouseup",this.windowMouseUp),window.addEventListener("blur",this.windowBlur),this.applyEffectiveTool())}disabled(){this.isEnabled&&(this.isEnabled=!1,this.dispose.forEach(eg=>eg()),this.dispose.length=0,document.removeEventListener("keydown",this.keyDown),document.removeEventListener("keyup",this.keyUp),window.removeEventListener("mouseup",this.windowMouseUp),window.removeEventListener("blur",this.windowBlur),this.temporaryPanSources.clear(),this.isDragging=!1,this.canvas.selection=this.previousCanvasSelection,this.canvas.skipTargetFind=this.previousSkipTargetFind,this.canvas.defaultCursor=this.previousDefaultCursor,this.canvas.setCursor(this.previousDefaultCursor),this.canvas.requestRenderAll())}getTool(){return this.persistentTool}setTool(eg){this.persistentTool!==eg&&(this.persistentTool=eg,eg==="pan"&&this.canvas.discardActiveObject(),this.applyEffectiveTool(),canvasEventBus.emit("canvasToolChanged",{editor:this.editor,tool:eg}))}getEffectiveTool(){return getEffectiveCanvasTool(this.persistentTool,this.temporaryPanSources)}applyEffectiveTool(){const eg=this.getEffectiveTool()==="pan",gg=this.isDragging?"grabbing":eg?"grab":this.previousDefaultCursor;this.canvas.selection=eg?!1:this.previousCanvasSelection,this.canvas.skipTargetFind=eg?!0:this.previousSkipTargetFind,this.canvas.defaultCursor=gg,this.canvas.setCursor(gg),this.canvas.requestRenderAll()}finishDragging(){!this.isDragging&&!this.hasPointerPanSource()||(this.isDragging=!1,this.temporaryPanSources.delete("alt"),this.applyEffectiveTool())}getPointerPanSource(eg){if(eg.button!==1&&eg.altKey)return"alt"}hasPointerPanSource(){return this.temporaryPanSources.has("alt")}isFabricTextEditing(){const eg=this.canvas.getActiveObject();return!!(eg&&"isEditing"in eg&&eg.isEditing)}}class LockPlugin{constructor(){this.name="LockPlugin"}install(eg,gg){this.editor=eg,this.enabled()}switchLock(){const eg=this.editor;if(eg){const gg=eg.getCanvas(),ig=gg.getActiveObject();ig&&(ig.locked=!ig.locked,gg.fire("custom:object:history",{target:ig,action:"history:update"}))}}enabled(){if(this.editor){const gg=this.editor.getPlugin("ContextMenuPlugin");gg&&gg.addItem([{id:"lock",text:"editor.contextMenu.lock",hotKey:"Ctrl+L",hotKeyHandler:ig=>{this.switchLock()},handler:(ig,ng)=>(this.switchLock(),!0),isShow:(ig,ng)=>(ng&&(ng.itemText=ig!=null&&ig.locked?"editor.contextMenu.unlock":"editor.contextMenu.lock"),!!ig)}])}}disabled(){if(this.editor){const gg=this.editor.getPlugin("ContextMenuPlugin");gg&&gg.removeItem("lock")}}}class LayerPlugin{constructor(){this.name="LayerPlugin"}workspaceSendToBack(){const eg=this.canvas,gg=eg.getObjects().find(ig=>ig.id==="workspace");gg&&eg.sendObjectToBack(gg)}layerChangeRefresh(){this.canvas.fire("custom:object:refreshList")}up(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=eg.getActiveObjects()[0];ig&&eg.bringObjectForward(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}down(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=eg.getActiveObjects()[0];ig&&eg.sendObjectBackwards(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}toFront(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=gg[0];ig&&eg.bringObjectToFront(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}toBack(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=gg[0];ig&&eg.sendObjectToBack(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}install(eg,gg){this.editor=eg;const ig=eg.getCanvas();this.canvas=ig;const ng=eg.getPlugin("ContextMenuPlugin");ng&&ng.addItem({id:"layer",text:"editor.contextMenu.layers",subItems:[{id:"layer-up",text:"editor.contextMenu.bringForward",handler:(og,ag)=>(this.up(),!0)},{id:"layer-down",text:"editor.contextMenu.sendBackwards",handler:(og,ag)=>(this.down(),!0)},{id:"layer-top",text:"editor.contextMenu.bringToFront",handler:(og,ag)=>(this.toFront(),!0)},{id:"layer-bottom",text:"editor.contextMenu.sendToBack",handler:(og,ag)=>(this.toBack(),!0)}]})}enabled(){}disabled(){}}class ControlsPlugin{constructor(){this.name="ControlsPlugin",this.controls={}}drawImg(eg,gg,ig,ng,og,ag,sg){sg!==void 0&&(eg.save(),eg.translate(gg,ig),eg.rotate(kn.degreesToRadians(sg)),eg.drawImage(ng,-og/2,-ag/2,og,ag),eg.restore())}intervalControl(){const eg=document.createElement("img");eg.src=this.option.verticalImg;const gg=document.createElement("img");gg.src=this.option.horizontalImg;const ig=(og,ag,sg,Ig,Cg)=>{this.drawImg(og,ag,sg,eg,20,25,Cg.angle)},ng=(og,ag,sg,Ig,Cg)=>{this.drawImg(og,ag,sg,gg,25,20,Cg.angle)};return{ml:new ni({x:-.5,y:0,offsetX:-1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingXOrSkewingY,getActionName:ja.scaleOrSkewActionName,render:ig}),mr:new ni({x:.5,y:0,offsetX:1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingXOrSkewingY,getActionName:ja.scaleOrSkewActionName,render:ig}),mb:new ni({x:0,y:.5,offsetY:1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingYOrSkewingX,getActionName:ja.scaleOrSkewActionName,render:ng}),mt:new ni({x:0,y:-.5,offsetY:-1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingYOrSkewingX,getActionName:ja.scaleOrSkewActionName,render:ng})}}peakControl(){const eg=document.createElement("img");eg.src=this.option.edgeImg;const gg=(ig,ng,og,ag,sg)=>{this.drawImg(ig,ng,og,eg,25,25,sg.angle)};return{tl:new ni({x:-.5,y:-.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg}),bl:new ni({x:-.5,y:.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg}),tr:new ni({x:.5,y:-.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg}),br:new ni({x:.5,y:.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg})}}rotationControl(){const eg=document.createElement("img");eg.src=this.option.rotateImg;const gg=(ig,ng,og,ag,sg)=>{this.drawImg(ig,ng,og,eg,40,40,sg.angle)};return{mtr:new ni({x:0,y:.5,cursorStyleHandler:ja.rotationStyleHandler,actionHandler:ja.rotationWithSnapping,offsetY:30,actionName:"rotate",render:gg})}}install(eg,gg){if(!gg||!gg.verticalImg||!gg.horizontalImg||!gg.edgeImg)throw new Error("ControlsPluginOption参数必需");this.option=gg,this.canvas=eg.getCanvas(),this.controls={...this.peakControl(),...this.intervalControl(),...this.rotationControl()},Ei.createControls=()=>({controls:{...this.controls}}),Ei.ownDefaults.controls={...this.controls},Ei.ownDefaults.snapAngle=15,Ei.ownDefaults.snapThreshold=5,this.refreshObjectControls()}refreshObjectControls(){if(!this.canvas)return;const eg=gg=>{gg.id!=="workspace"&&gg.locked!==!0&&gg.set({selectable:!0,evented:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1}),gg.id!=="workspace"&&gg.hasControls!==!1&&(gg.controls={...this.controls},gg.setCoords());const ig=gg._objects;Array.isArray(ig)&&ig.forEach(eg)};this.canvas.getObjects().forEach(eg),this.canvas.requestRenderAll()}enabled(){}disabled(){}}class AlignPlugin{constructor(){this.name="AlignPlugin",this.left=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{left:og=0}=ig;gg.discardActiveObject(),ng.forEach(sg=>{const Ig=sg.getBoundingRect();console.log("getBoundingRect",Ig),console.log("item",sg.left,sg.width),sg.set({left:og-Ig.left+Number(sg.left)}),sg.setCoords()}),console.log("align-left",ng),gg.fire("custom:object:history",{action:"align-left"});const ag=new Jo(ng,{canvas:gg});gg.setActiveObject(ag),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"left")},this.right=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{left:og=0,width:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({left:og+ag-(Cg.left+Cg.width)+Number(Ig.left)})}),gg.fire("custom:object:history",{action:"align-right"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"right")},this.xcenter=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{left:og=0,width:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({left:og+ag/2-(Cg.left+Cg.width/2)+Number(Ig.left)})}),gg.fire("custom:object:history",{action:"align-xcenter"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}},this.ycenter=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{top:og=0,height:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({top:og+ag/2-(Cg.top+Cg.height/2)+Number(Ig.top)})}),gg.fire("custom:object:history",{action:"align-ycenter"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}},this.top=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{top:og=0}=ig;gg.discardActiveObject(),ng.forEach(sg=>{const Ig=sg.getBoundingRect();sg.set({top:og-Ig.top+Number(sg.top)})}),gg.fire("custom:object:history",{action:"align-top"});const ag=new Jo(ng,{canvas:gg});gg.setActiveObject(ag),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"top")},this.bottom=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{top:og=0,height:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({top:og+ag-(Cg.top+Cg.height)+Number(Ig.top)})}),gg.fire("custom:object:history",{action:"align-bottom"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"bottom")},this.xequation=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject();function ng(lg){let Ag=1/0,rg=-1/0;for(const cg in lg.aCoords){const ug=cg;lg.aCoords[ug].x<Ag&&(Ag=lg.aCoords[ug].x),lg.aCoords[ug].x>rg&&(rg=lg.aCoords[ug].x)}return rg-Ag}function og(){let lg=0;return ig&&ig.forEachObject(Ag=>{lg+=ng(Ag)}),lg}function ag(){const lg=og();if(ig)return(Number(ig.width)-lg)/(ig._objects.length-1)}function sg(lg){if(lg===0)return 0;let Ag=0;if(ig)for(let rg=0;rg<lg;rg++)Ag+=ng(ig._objects[rg]);return Ag}if(ig&&ig.type==="activeselection"){const lg=ig;if(lg.getObjects().length<2)return;lg._objects.sort((cg,ug)=>cg.left-ug.left);const Ag=ag(),rg=Number(ig.width)/2;ig.forEachObject((cg,ug)=>{const dg=sg(ug),hg=Ag*ug+dg-rg;cg.set("left",hg)})}const Ig=gg.getActiveObjects();if(Ig.length<2)return;gg.discardActiveObject(),Ig.forEach(lg=>{let Ag=1/0;for(const rg in lg.aCoords){const cg=rg;lg.aCoords[cg].x<Ag&&(Ag=lg.aCoords[cg].x)}lg.set("left",2*lg.left-Ag)}),gg.fire("custom:object:history",{action:"align-xequation"});const Cg=new Jo(Ig,{canvas:gg});gg.setActiveObject(Cg),gg.requestRenderAll()},this.yequation=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject()||{top:0,height:0};function ng(lg){let Ag=1/0,rg=-1/0;for(const cg in lg.aCoords){const ug=cg;lg.aCoords[ug].y<Ag&&(Ag=lg.aCoords[ug].y),lg.aCoords[ug].y>rg&&(rg=lg.aCoords[ug].y)}return rg-Ag}function og(){let lg=0;return ig.forEachObject(Ag=>{lg+=ng(Ag)}),lg}function ag(){const lg=og();return(ig.height-lg)/(ig._objects.length-1)}function sg(lg){if(lg===0)return 0;let Ag=0;for(let rg=0;rg<lg;rg++)Ag+=ng(ig._objects[rg]);return Ag}if(console.log("activeObject",ig.type),ig&&ig.type==="activeselection"){const lg=ig;if(lg.getObjects().length<2)return;lg._objects.sort((cg,ug)=>cg.top-ug.top);const Ag=ag(),rg=Number(ig.height)/2;ig.forEachObject((cg,ug)=>{const dg=sg(ug),hg=Ag*ug+dg-rg;cg.set("top",hg)})}const Ig=gg.getActiveObjects();if(Ig.length<2)return;gg.discardActiveObject(),Ig.forEach(lg=>{let Ag=1/0;for(const rg in lg.aCoords){const cg=rg;lg.aCoords[cg].y<Ag&&(Ag=lg.aCoords[cg].y)}lg.set("top",2*lg.top-Ag)}),gg.fire("custom:object:history",{action:"align-yequation"});const Cg=new Jo(Ig,{canvas:gg});gg.setActiveObject(Cg),gg.requestRenderAll()}}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.enabled()}enabled(){this.editor&&(this.editor.addHook("left",this.left),this.editor.addHook("right",this.right),this.editor.addHook("top",this.top),this.editor.addHook("bottom",this.bottom),this.editor.addHook("xcenter",this.xcenter),this.editor.addHook("ycenter",this.ycenter),this.editor.addHook("x-equidistant",this.xequation),this.editor.addHook("y-equidistant",this.yequation))}disabled(){}alignSingleToWorkspace(eg,gg){var Cg;if(!this.canvas)return;const ig=this.canvas.getObjects().find(lg=>lg.id==="workspace");if(!ig)return;const ng=eg.getBoundingRect(),og=ig.getBoundingRect(),ag={};let Ig=((Cg=this.editor)==null?void 0:Cg.ribbonBorderPattern)&&this.editor.ribbonBorderPattern!=="none"?30:0;gg==="left"?ag.left=Number(eg.left||0)+og.left+Ig-ng.left:gg==="right"?ag.left=Number(eg.left||0)+og.left+og.width-Ig-ng.left-ng.width:gg==="top"?ag.top=Number(eg.top||0)+og.top-ng.top:gg==="bottom"&&(ag.top=Number(eg.top||0)+og.top+og.height-ng.top-ng.height),eg.set(ag),eg.setCoords(),this.canvas.fire("custom:object:history",{action:`align-${gg}`}),this.canvas.fire("custom:object:checkdirty",{isToDirty:!0}),this.canvas.requestRenderAll()}}class GroupPlugin{constructor(){this.name="GroupPlugin"}group(){if(!this.editor)return;const eg=this.editor.getCanvas();if(!eg.getActiveObject())return;const gg=this.editor.getPlugin("HistoryPlugin");gg&&(gg.pause=!0);const ig=eg.getActiveObject();console.log("group",ig.type),getObjectList(ig,og=>{(og.type==="text"||og.type==="counter")&&(og.inGroupRemove=!0)});let ng;if(ig.type!=="activeSelection"&&ig.type!=="activeselection"){const og=eg.remove(ig);console.log("rmobj",og),ng=new Hr(og)}else{const og=ig.removeAll();eg.remove(...og),ng=new Hr(og)}console.log("group====1111",ng),ng.id=v4(),addObjName(eg,ng),ng.subTargetCheck=!0,gg&&(gg.pause=!1),eg.add(ng),eg.setActiveObject(ng),eg.requestRenderAll(),this.editor.emit("group",{target:ng}),console.log("group",eg.getObjects())}ungroup(){if(!this.editor)return;const eg=this.editor.getCanvas(),gg=eg.getActiveObject();if(!gg||gg.type!=="group")return;const ig=this.editor.getPlugin("HistoryPlugin");ig&&(ig.pause=!0),eg.remove(gg);const ng=gg.removeAll();eg.add(...ng);var og=new Jo(ng,{canvas:eg});ig&&(ig.pause=!1),eg.setActiveObject(og),eg.requestRenderAll(),this.editor.emit("ungroup",{target:og})}install(eg,gg){this.editor=eg,this.enabled()}enabled(){if(this.editor){const gg=this.editor.getPlugin("ContextMenuPlugin");gg&&gg.addItem([{id:"group1",text:"editor.contextMenu.group",isShow:(ig,ng)=>!ig||ig.type!=="group",handler:(ig,ng)=>(this.group(),!0)},{id:"group2",text:"editor.contextMenu.ungroup",isShow:(ig,ng)=>!!(ig&&ig.type==="group"),handler:(ig,ng)=>(this.ungroup(),!0)}])}}disabled(){if(this.editor){const eg=this.editor.getPlugin("ContextMenuPlugin");eg&&(eg.removeItem("group1"),eg.removeItem("group2"))}}}class HistoryList{constructor(eg){this.canvas=eg,this.history=[],this.historyRedo=[],this.customProp={id:"id",locked:!1,name:"name"},this.isProcess=!1,this.flagClearing=!1,this.undoTimer=void 0,this.extraKeys=Object.keys(this.customProp),this.updateList()}async updateList(){if(this.flagClearing||this.isProcess)return;let eg=null;const gg=this.canvas.getObjects();let ig=[...cloneCommonField,"hasSetHistory"];const ng=gg.filter(ag=>ag.id!=="workspace"&&!ag.parent&&ag.drawObjectType!=="ignoreObject").map(async ag=>{if(ag.group&&ag.group.type==="activeselection"){eg||(eg=cloneDeep(ag.group));const sg=eg._objects.find(Cg=>Cg.id===ag.id);eg.remove(sg);let Ig=await sg.clone(ig);return Ig.set("flagActive",!0),Ig.canvas=void 0,Ig.evented=!0,Ig}else{const sg=await ag.clone(ig);return sg.canvas=void 0,sg.evented=!0,sg}}),og=await Promise.all(ng);this.history.push(og),console.log("history======",this.history),this.historyRedo=[]}clearCanvas(){this.flagClearing=!0;const eg=this.canvas.getObjects().filter(gg=>gg.id!=="workspace");this.canvas.remove(...eg),this.flagClearing=!1}async canvasRestore(eg){this.canvas.discardActiveObject();let gg;clearObjectMap();for(const ig of eg){const ng=await ig.clone([...cloneCommonField,"flagActive"]);this.canvas.add(ng),ng.get("flagActive")&&(gg||(gg=[]),gg.push(ng)),updateObjectMap(ng)}gg&&this.canvas.setActiveObject(new Jo(gg)),this.canvas.requestRenderAll()}undo(){if(this.isProcess||this.history.length<=1)return;clearTimeout(this.undoTimer);let eg=this.history.pop();this.historyRedo.push(eg);const gg=this.history[this.history.length-1];console.log("history========",this.history,gg),this.isProcess=!0,this.clearCanvas(),this.canvasRestore(gg).then(()=>{this.isProcess=!1})}redo(){if(this.isProcess||this.historyRedo.length===0)return;const eg=this.historyRedo.pop();this.history.push(eg),this.isProcess=!0,this.clearCanvas(),this.canvasRestore(eg).then(()=>{this.isProcess=!1})}}class HistoryPlugin{constructor(){this.name="HistoryPlugin",this.historyScopeId="default",this.historyScopeMap=new Map,this.pause=!1,this.isMouseDown=!1,this.isObjectModify=!1,this.objectAddedTimer=null,this.hotKeyHandle=eg=>{this.pause||(eg.hke.key==="ctrl+z"||eg.hke.key==="⌘+z"?this.toUndo():(eg.hke.key==="ctrl+shift+z"||eg.hke.key==="⌘+shift+z")&&this.toRedo())},this.objectAdded=({target:eg})=>{var gg;clearTimeout(this.objectAddedTimer),!(this.pause||this.isMouseDown||(gg=this.historyList)!=null&&gg.isProcess)&&(eg.drawObjectType&&eg.drawObjectType==="ignoreObject"||(this.objectAddedTimer=setTimeout(()=>{var ig;this.pause||(ig=this.historyList)!=null&&ig.isProcess||this.historyList&&this.historyList.updateList()},10)))},this.objectRemoved=({target:eg})=>{var gg;this.pause||(gg=this.historyList)!=null&&gg.isProcess||eg.drawObjectType&&eg.drawObjectType==="ignoreObject"||(this.historyList&&this.historyList.updateList(),this.canvas&&this.canvas.discardActiveObject())},this.objectModified=({})=>{if(!this.pause){if(this.isMouseDown){this.isObjectModify=!0;return}this.historyList&&this.historyList.updateList()}},this.objectSkewing=()=>{if(!this.pause){if(this.isMouseDown){this.isObjectModify=!0;return}this.historyList&&this.historyList.updateList()}},this.historyUpdate=eg=>{if(!this.pause){if(this.isMouseDown){this.isObjectModify=!0;return}this.historyList&&this.historyList.updateList()}},this.mouseDown=()=>{this.isMouseDown=!0},this.mouseUp=eg=>{var gg;this.isObjectModify?(this.isObjectModify=!1,this.isMouseDown=!1,(gg=this.canvas)==null||gg.fire("custom:object:history",{action:"mouse:up:clear"})):this.isMouseDown=!1}}toUndo(){var eg;(eg=this.historyList)==null||eg.undo()}toRedo(){var eg;(eg=this.historyList)==null||eg.redo()}switchScope(eg="default"){if(!this.canvas)return;clearTimeout(this.objectAddedTimer),this.historyScopeId=eg||"default";let gg=this.historyScopeMap.get(this.historyScopeId);gg||(gg=new HistoryList(this.canvas),this.historyScopeMap.set(this.historyScopeId,gg)),this.historyList=gg,this.isMouseDown=!1,this.isObjectModify=!1}clearScope(eg){if(!eg){if(this.historyScopeMap.clear(),this.canvas){const gg=new HistoryList(this.canvas);this.historyScopeMap.set(this.historyScopeId,gg),this.historyList=gg}return}this.historyScopeMap.delete(eg),this.historyScopeId===eg&&this.switchScope("default")}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.historyScopeId=(gg==null?void 0:gg.scopeId)||"default",this.historyList=new HistoryList(this.canvas),this.historyScopeMap.set(this.historyScopeId,this.historyList),this.enabled()}enabled(){this.editor&&(this.editor.addHotKey("ctrl+z",this.hotKeyHandle),this.editor.addHotKey("⌘+z",this.hotKeyHandle),this.editor.addHotKey("ctrl+shift+z",this.hotKeyHandle),this.editor.addHotKey("⌘+shift+z",this.hotKeyHandle)),this.canvas&&(this.canvas.on("mouse:down",this.mouseDown),this.canvas.on("mouse:up",this.mouseUp),this.canvas.on("object:added",this.objectAdded),this.canvas.on("object:removed",this.objectRemoved),this.canvas.on("object:modified",this.objectModified),this.canvas.on("object:skewing",this.objectSkewing),this.canvas.on("custom:object:history",this.historyUpdate))}disabled(){this.editor&&(this.editor.removeHotKey("ctrl+z"),this.editor.removeHotKey("⌘+z"),this.editor.removeHotKey("ctrl+shift+z"),this.editor.removeHotKey("⌘+shift+z")),this.canvas&&(this.canvas.off("mouse:down",this.mouseDown),this.canvas.off("mouse:up",this.mouseUp),this.canvas.off("object:added",this.objectAdded),this.canvas.off("object:removed",this.objectRemoved),this.canvas.off("object:modified",this.objectModified),this.canvas.off("object:skewing",this.objectSkewing),this.canvas.off("custom:object:history",this.historyUpdate))}uninstall(){this.disabled(),clearTimeout(this.objectAddedTimer),this.objectAddedTimer=null,this.historyScopeMap.clear(),this.historyList=void 0,this.editor=void 0,this.canvas=void 0,this.pause=!1,this.isMouseDown=!1,this.isObjectModify=!1}}class MoveHotKeyPlugin{constructor(){this.name="MoveHotKeyPlugin",this.keys={},this.holder=new Map}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.holder.set("keydown",this.keyDown.bind(this)),this.holder.set("keyup",this.keyUp.bind(this)),this.enabled()}move(){const eg=this.canvas.getActiveObject();if(eg!=null&&eg.locked)return;let gg=!0;if(eg&&eg.top!==void 0&&(this.keys.ArrowUp&&(eg.set("top",eg.top-1),gg=!1),this.keys.ArrowDown&&(eg.set("top",eg.top+1),gg=!1),this.keys.ArrowLeft&&(eg.set("left",eg.left-1),gg=!1),this.keys.ArrowRight&&(eg.set("left",eg.left+1),gg=!1),!gg&&(eg.setCoords(),this.canvas))){this.canvas.renderAll(),this.canvas.fire("custom:object:changed",{target:eg});return}this.intervalHolder,clearInterval(this.intervalHolder),this.intervalHolder=void 0,console.log("clearInterval")}keyDown(eg){if(this.keys[eg.code]=!0,["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(eg.code))eg.preventDefault();else return;this.move(),this.intervalHolder===void 0&&(this.intervalHolder=setInterval(this.move.bind(this),96))}keyUp(eg){this.keys[eg.code]=!1}enabled(){var eg;if((eg=this.canvas)!=null&&eg.elements.container){const gg=this.canvas.elements.container;gg.tabIndex=-1,this.holder.forEach((ig,ng)=>{gg.addEventListener(ng,ig)})}}disabled(){var eg;if((eg=this.canvas)!=null&&eg.elements.container){const gg=this.canvas.elements.container;this.holder.forEach((ig,ng)=>{gg.removeEventListener(ng,ig)})}}}class DeletePlugin{constructor(){this.name="DeletePlugin"}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.enabled()}flat(eg,gg){if(gg.push(eg),eg instanceof Hr){const ig=eg.getObjects();if(ig.length>0)for(const ng of ig)ng.locked||(gg.push(ng),ng instanceof Hr&&this.flat(ng,gg))}}enabled(){if(this.editor){const eg=this.editor.getPlugin("ContextMenuPlugin");eg&&eg.addItem({id:"delete",text:"editor.contextMenu.delete",hotKey:"delete,backspace",hotKeyHandler:gg=>this.toDelete(),handler:(gg,ig)=>this.toDelete()})}}toDelete(){var og;const gg=this.editor.getPlugin("HistoryPlugin");gg&&(gg.pause=!0);let ig=this.canvas.getActiveObjects();const ng=[];for(const ag of ig)this.flat(ag,ng);return ng.length>0&&(this.canvas.remove(...ng),this.canvas.requestRenderAll(),ig=ig.filter(ag=>{ng.includes(ag)}),ig.length>0?this.canvas.setActiveObject(new Jo(ig)):this.canvas.discardActiveObject()),gg&&(gg.pause=!1),(og=this.canvas)==null||og.fire("custom:object:history",{target:null,action:"delete"}),!0}disabled(){if(this.editor){const eg=this.editor.getPlugin("ContextMenuPlugin");eg&&eg.removeItem("delete")}}}let isDrawing=!1;class AddObjectPlugin{constructor(){this.name="AddObjectPlugin",this.startPoint={},this.isMoverUp=!1,this.mouseDown=eg=>{if(!this.canvas)return;this.isMoverUp=!1;const gg=this.canvas,ig=eg.scenePoint;this.startPoint=ig,this.canvas.off("mouse:move",this.mouseMove),this.canvas.off("mouse:up",this.mouseUp),gg.on("mouse:move",this.mouseMove),gg.on("mouse:up",this.mouseUp)},this.mouseMove=eg=>{if(!this.canvas||this.isMoverUp)return;const gg=this.canvas,ig=eg.scenePoint;this.object||(this.object=new ALine([this.startPoint.x,this.startPoint.y,ig.x,ig.y],{...this.objectProps,id:v4(),evented:!1,strokeUniform:!0,hasControls:!1}),addObjName(this.canvas,this.object),this.object.strokeWidth=3,gg.add(this.object)),this.object.set({x2:ig.x,y2:ig.y}),this.object.setCoords(),gg.renderAll()},this.mouseUp=eg=>{var gg;!this.canvas||!this.object||(this.isMoverUp=!0,console.log("end",this.object),this.canvas.fire("object:modified",{target:this.object}),(gg=this.canvas)==null||gg.setActiveObject(this.object),this.object=void 0,this.canvas.off("mouse:move",this.mouseMove),this.canvas.off("mouse:up",this.mouseUp),this.end())},this.start=eg=>{if(!this.canvas||isDrawing)return;isDrawing=!0,this.objectProps=eg;const gg=this.canvas;gg.defaultCursor="crosshair",gg.selection=!1,gg.forEachObject(ig=>{ig.set({evented:!1})}),this.canvas.on("mouse:down",this.mouseDown)},this.end=()=>{if(!this.canvas)return;const eg=this.canvas;eg.defaultCursor="default",eg.selection=!0,eg.forEachObject(gg=>{gg.set({evented:!0})}),eg.off("mouse:down",this.mouseDown),isDrawing=!1}}install(eg,gg){this.editor=eg,this.canvas=this.editor.getCanvas(),this.enabled()}enabled(){var eg,gg;this.canvas&&((eg=this.editor)==null||eg.addHook("addLine",this.start),(gg=this.editor)==null||gg.addHook("cancelAdd",this.end))}disabled(){this.canvas&&this.canvas.off("mouse:down",this.mouseDown)}}let _clipboard=null,isInCut=!1;const activePluginStack=[],getClipboard=()=>{if(!(typeof navigator>"u"))return navigator.clipboard},writeClipboardText=async tg=>{const eg=getClipboard();if(!(eg!=null&&eg.writeText))return!1;try{return await eg.writeText(tg),!0}catch{return!1}},readClipboardText=async()=>{const tg=getClipboard();if(!(tg!=null&&tg.readText))return"";try{return await tg.readText()}catch{return""}};class CopyPaste{constructor(eg){this.canvas=eg,this.copyId="",this.pasteId="",this.cloneField=[...cloneCommonField,"hasSetHistory"]}getObjData(eg="copy"){return new Promise(async(gg,ig)=>{let ng=this.canvas.getActiveObject();if(ng){let og=null;if(await writeClipboardText(JSON.stringify({type:"fabric",data:""})),eg==="copy"){let ag=this.cloneField.filter(sg=>sg!=="locked");og=await ng.clone(ag)}else ng instanceof Jo?(og=this.canvas.remove(...ng._objects),og=new Jo(og)):og=this.canvas.remove(ng)[0],this.canvas.discardActiveObject(),this.canvas.requestRenderAll();_clipboard=og,gg(og)}else gg(null)})}async copy(){this.getObjData()}handleObject(eg,gg=!1){var ig;if(!gg){if(eg.relativePosition&&typeof eg.relativePosition=="object"&&eg.set("relativePosition",{...eg.relativePosition}),eg.counterProps&&typeof eg.counterProps=="object"&&(eg.counterProps={...eg.counterProps}),eg._props&&typeof eg._props=="object"&&(eg._props=JSON.parse(JSON.stringify(eg._props))),eg.databaseMixConcat&&typeof eg.databaseMixConcat=="object"&&(eg.databaseMixConcat=JSON.parse(JSON.stringify(eg.databaseMixConcat))),eg.connectObjIds&&typeof eg.connectObjIds=="object"&&(eg.connectObjIds=JSON.parse(JSON.stringify(eg.connectObjIds))),(eg.type==="text"||eg.type==="counter")&&delete eg.connectBar2dMap,eg.type==="barcode2d"||eg.type==="barcode")delete eg.concatTextIdListObj;else if(eg.type==="text"&&eg.fromBarCode2dID){const og=ag=>{if(ag.type==="group"&&ag._objects)return ag._objects.some(sg=>og(sg));if((ag.type==="barcode2d"||ag.type==="barcode")&&ag.id===eg.fromBarCode2dID){let sg=ag.concatTextIdListObj;return sg&&(sg[eg.id]=!0,ag.set("concatTextIdListObj",sg)),!0}};(ig=this.canvas)==null||ig.getObjects().some(ag=>og(ag))}}}async paste(){if(!_clipboard)return"no-data";let eg=this.cloneField;this.copyId!==this.pasteId&&(eg=eg.filter(og=>!["databaseSheet","databaseColumn","databaseTid","outsideInput","outsideInputOrder","increaseCount","fromBarCode2d","fromBarCode2dID","increaseDate","barcodeDateFormatType"].includes(og)));let ig=await _clipboard.clone(eg);if(!ig)return"no-data";let ng=isInCut;if(isInCut?isInCut=!1:(ig.set({left:ig.left+10,top:ig.top+10,evented:!0}),_clipboard&&(_clipboard.left+=10,_clipboard.top+=10)),ig.type==="activeselection")ig.canvas=this.canvas,deepTraverse(ig.getObjects(),(og,ag)=>{addObjName(this.canvas,og),ag&&(ng||(og.id=v4()),this.handleObject(og,ng),this.canvas.add(og))});else if(ig.type==="group"){ig.canvas=this.canvas;const og=new Hr;og.id=v4(),addObjName(this.canvas,og),deepTraverse(ig.getObjects(),(ag,sg)=>{addObjName(this.canvas,ag),sg&&(ng||(ag.id=v4()),this.handleObject(ag,ng),og.add(ag))}),this.canvas.add(og),ig=og}else ng||(ig.id=v4()),this.handleObject(ig,ng),addObjName(this.canvas,ig),this.canvas.add(ig);this.canvas.setActiveObject(ig),this.canvas.requestRenderAll()}async cut(){if(isInCut=!0,!await this.getObjData("cut"))return"no-data"}}class CopyPlugin{constructor(){this.name="CopyPlugin",this.pause=!1,this.shouldHandleClipboardEvent=eg=>{var ng;const gg=eg.target;if(gg instanceof Element&&gg.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'))return!1;const ig=(ng=this.canvas)==null?void 0:ng.getActiveObject();return!!(ig&&!ig.isEditing)},this.setFabricClipboardData=eg=>{eg.clipboardData&&(eg.clipboardData.setData("text/plain",JSON.stringify({type:"fabric",data:""})),eg.preventDefault())},this.copyHandle=eg=>{this.pause||!this.isActivePlugin()||this.shouldHandleClipboardEvent(eg)&&(this.setFabricClipboardData(eg),this.toCopy())},this.cutHandle=eg=>{this.pause||!this.isActivePlugin()||this.shouldHandleClipboardEvent(eg)&&(this.setFabricClipboardData(eg),this.toCut())},this.pasteHandle=eg=>{var sg;if(!this.isActivePlugin())return;const gg=(sg=this.canvas)==null?void 0:sg.getActiveObject(),ig=eg.target,ng=ig instanceof Element&&!!ig.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]');if(gg&&gg.isEditing||ng)return;let og=eg.clipboardData,ag=(og==null?void 0:og.items)||[];for(let Ig of ag){if(Ig.type.startsWith("image")){console.log("粘贴图片");let Cg=Ig.getAsFile();canvasEventBus.emit("copyAddImageObj",Cg),console.log("file=====",Cg)}Ig.type==="text/plain"&&Ig.kind==="string"&&Ig.getAsString(Cg=>{console.log("粘贴文本=====",Cg);let lg=Cg;try{lg=JSON.parse(Cg)}catch{lg=Cg}typeof lg=="string"?canvasEventBus.emit("copyAddTextObj",lg):lg.type&&lg.type==="fabric"&&this.toPaste(lg)})}},this.copyHandleFn=throttle$1(this.copyHandle,80),this.cutHandleFn=throttle$1(this.cutHandle,80),this.pasteHandleFn=throttle$1(this.pasteHandle,80)}isActivePlugin(){return activePluginStack[activePluginStack.length-1]===this}setActivePlugin(eg){const gg=activePluginStack.indexOf(this);gg>-1&&activePluginStack.splice(gg,1),eg&&activePluginStack.push(this)}toCopy(){var gg;const eg=this.editor;this.CopyPaste.copyId=eg.id||"",(gg=this.CopyPaste)==null||gg.copy()}async toPaste(eg=null){var og;const gg=this.editor;this.CopyPaste.pasteId=gg.id||"";const ig=gg.getPlugin("HistoryPlugin");ig&&(ig.pause=!0);let ng={};if(window.isInElectron)try{ng=await window.dsapi.systemApi.readClipboard(),ng=JSON.parse(ng)}catch{}else eg?ng.text=eg:(ng.text=await readClipboardText(),!ng.text&&_clipboard&&(ng.text=JSON.stringify({type:"fabric",data:""})));if(ng.text){let ag=ng.text;try{ag=JSON.parse(ng.text)}catch{ag=ng.text}typeof ag=="string"?(ig&&(ig.pause=!1),canvasEventBus.emit("copyAddTextObj",ag)):ag.type&&ag.type==="fabric"&&((og=this.CopyPaste)==null||og.paste().then(sg=>{var Ig;ig&&(ig.pause=!1),sg!=="no-data"&&((Ig=this.canvas)==null||Ig.fire("custom:object:history",{action:"paste"}))}))}else ng.imageData&&ng.imageData.length?ng.imageData.forEach(ag=>{canvasEventBus.emit("copyAddImageObj",ag)}):ig&&(ig.pause=!1)}toCut(){var ig;const eg=this.editor;this.CopyPaste.copyId=eg.id||"";const gg=eg.getPlugin("HistoryPlugin");gg&&(gg.pause=!0),(ig=this.CopyPaste)==null||ig.cut().then(ng=>{var og;gg&&(gg.pause=!1),ng!=="no-data"&&((og=this.canvas)==null||og.fire("custom:object:history",{target:null,action:"cut"}))})}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.CopyPaste=new CopyPaste(this.canvas),this.enabled()}enabled(){this.setActivePlugin(!0),document.removeEventListener("copy",this.copyHandleFn),document.addEventListener("copy",this.copyHandleFn),document.removeEventListener("cut",this.cutHandleFn),document.addEventListener("cut",this.cutHandleFn),document.removeEventListener("paste",this.pasteHandleFn),document.addEventListener("paste",this.pasteHandleFn)}disabled(){this.setActivePlugin(!1),document.removeEventListener("copy",this.copyHandleFn),document.removeEventListener("cut",this.cutHandleFn),document.removeEventListener("paste",this.pasteHandleFn)}uninstall(){this.disabled()}}class SelectPlugin{constructor(){this.name="SelectPlugin",this.selectAll=()=>{if(this.canvas){const eg=this.canvas.getObjects().filter(ig=>ig.id!=="workspace"),gg=new Jo(eg);this.canvas.setActiveObject(gg),this.canvas.requestRenderAll()}}}install(eg,gg){this.canvas=eg.getCanvas(),this.enabled()}uninstall(){this.disabled()}enabled(){hotkeys("ctrl+a",this.selectAll)}disabled(){hotkeys.unbind("ctrl+a",this.selectAll)}}class LineContorlPlugin{constructor(){this.name="LineContorlPlugin",this._lastLeft=0,this._lastTop=0,this.moveTimer=null}install(eg,gg){this.canvas=eg.getCanvas(),this.enabled()}uninstall(){this.disabled()}_createHandle(eg,gg){return new ho({drawObjectType:"ignoreObject",idType:"lineHandle",excludeFromExport:!0,left:eg,top:gg,radius:6,fill:"#fff",stroke:"#1976d2",strokeWidth:2,originX:"center",originY:"center",hasControls:!1,hasBorders:!1,selectable:!0,hoverCursor:"pointer",objectCaching:!1})}_bindEvents(){this.canvas&&(canvasEventBus.off("positionChange"),canvasEventBus.on("positionChange",eg=>{eg.type==="line"&&setTimeout(()=>{this._onSelection({selected:[eg]})},0)}),this.canvas.on("selection:created",eg=>this._onSelection(eg)),this.canvas.on("selection:updated",eg=>this._onSelection(eg)),this.canvas.on("custom:object:basechanged",eg=>{let gg=eg.type,ig=eg.activeObj,ng=eg.val,og=eg.oldVal,ag=ng-og;gg==="x"?(ig.x1=ig.x1+ag,ig.x2=ig.x2+ag):gg==="y"?(ig.y1=ig.y1+ag,ig.y2=ig.y2+ag):gg==="w"?ig.x2>ig.x1?ig.x2=ig.x2+ag:ig.x1=ig.x1+ag:gg==="h"&&(ig.y2>ig.y1?ig.y2=ig.y2+ag:ig.y1=ig.y1+ag),this._onSelection({selected:[ig]})}),this.canvas.on("selection:cleared",()=>this._hideHandles()))}_updateLineFromHandles(){var eg;this.lineObject&&this.handle1&&this.handle2&&(this.lineObject.set({x1:this.handle1.left,y1:this.handle1.top,x2:this.handle2.left,y2:this.handle2.top}),this.lineObject.setCoords(),(eg=this.canvas)==null||eg.requestRenderAll())}_updateHandlesFromLine(){var ig,ng,og;if(!this.lineObject||!this.handle1||!this.handle2)return;const eg=this.lineObject.left-(this._lastLeft??this.lineObject.left),gg=this.lineObject.top-(this._lastTop??this.lineObject.top);(eg!==0||gg!==0)&&((ig=this.handle1)==null||ig.set({left:this.handle1.left+eg,top:this.handle1.top+gg}),(ng=this.handle2)==null||ng.set({left:this.handle2.left+eg,top:this.handle2.top+gg}),this.lineObject.set({x1:this.handle1.left,y1:this.handle1.top,x2:this.handle2.left,y2:this.handle2.top}),this.handle1.setCoords(),this.handle2.setCoords(),this.lineObject.setCoords()),this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top,(og=this.canvas)==null||og.requestRenderAll()}_onSelection(eg){var ig,ng,og,ag,sg,Ig,Cg,lg;let gg=(eg==null?void 0:eg.selected[0])||{};if(eg.selected.length===1&&gg.type==="line"){if(this.lineObject=eg.selected[0],!this.lineObject||(this.handle1&&this.handle2&&((ig=this.canvas)==null||ig.remove(this.handle1,this.handle2)),this.lineObject.group))return;this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top;let Ag=0,rg=0,cg=0,ug=0;this.lineObject.x1<=this.lineObject.x2?(this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top,Ag=this._lastLeft,rg=this._lastLeft+this.lineObject.width):this.lineObject.x1>this.lineObject.x2&&(this._lastLeft=this.lineObject.left+this.lineObject.width,this._lastTop=this.lineObject.top,Ag=this._lastLeft,rg=this._lastLeft-this.lineObject.width),this.lineObject.y1>=this.lineObject.y2?(this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top,cg=this._lastTop+this.lineObject.height,ug=this._lastTop):this.lineObject.y1<this.lineObject.y2&&(cg=this._lastTop,ug=this._lastTop+this.lineObject.height),this.handle1=this._createHandle(Ag,cg),this.handle2=this._createHandle(rg,ug),(ng=this.handle1)==null||ng.on("moving",()=>this._updateLineFromHandles()),(og=this.handle2)==null||og.on("moving",()=>this._updateLineFromHandles()),(ag=this.handle2)==null||ag.on("mouseup",()=>{var dg;(dg=this.canvas)==null||dg.discardActiveObject(),setTimeout(()=>{var hg,mg;this.lineObject&&((hg=this.canvas)==null||hg.setActiveObject(this.lineObject)),(mg=this.canvas)==null||mg.requestRenderAll()},220)}),(sg=this.handle1)==null||sg.on("mouseup",()=>{var dg;(dg=this.canvas)==null||dg.discardActiveObject(),setTimeout(()=>{var hg;this.lineObject&&((hg=this.canvas)==null||hg.setActiveObject(this.lineObject))},220)}),(Ig=this.lineObject)==null||Ig.on("moving",()=>this._updateHandlesFromLine()),(Cg=this.canvas)==null||Cg.add(this.handle1,this.handle2),(lg=this.canvas)==null||lg.requestRenderAll()}else gg&&gg.drawObjectType!=="ignoreObject"&&this._hideHandles()}_showHandles(){}_hideHandles(){var eg,gg;this.handle1&&this.handle2&&((eg=this.canvas)==null||eg.remove(this.handle1,this.handle2),(gg=this.canvas)==null||gg.requestRenderAll())}enabled(){this._bindEvents()}disabled(){canvasEventBus.off("positionChange")}}async function applyJsonFieldDiff(tg,eg,gg){const ig={renamedCount:0,unlinkedCount:0,valueUpdatedCount:0,unlinkedIds:[]};if(!(eg!=null&&eg.length))return ig;const ng=collectObjects(eg).filter(sg=>sg.fromJson);for(const{from:sg,to:Ig}of tg.renamed)for(const Cg of ng)Cg.jsonFieldKey===sg&&(Cg.jsonFieldKey=Ig,Cg.dirty=!0,ig.renamedCount++);if(gg!=null&&gg.jsonData)return await reconcileWithJsonData(ng,gg.jsonData,ig,gg),ig;const og=new Set(tg.renamed.map(({to:sg})=>sg));for(const{key:sg,newValue:Ig}of tg.valueChanged){if(og.has(sg)){for(const Cg of ng)Cg.jsonFieldKey===sg&&(await setElementContent(Cg,Ig,gg),Cg.dirty=!0,ig.valueUpdatedCount++);continue}for(const Cg of ng)Cg.jsonFieldKey===sg&&(await setElementContent(Cg,Ig,gg),Cg.dirty=!0,ig.valueUpdatedCount++)}const ag=new Set(tg.removed);for(const sg of ng)sg.jsonFieldKey&&ag.has(sg.jsonFieldKey)&&unlinkObject(sg,ig);return ig}function collectObjects(tg){const eg=[],gg=new Set,ig=ng=>{var ag;if(!ng||gg.has(ng))return;gg.add(ng),eg.push(ng),(((ag=ng.getObjects)==null?void 0:ag.call(ng))??ng._objects??ng.objects??[]).forEach(ig)};return tg.forEach(ig),eg}async function reconcileWithJsonData(tg,eg,gg,ig){for(const ng of tg){const og=ng.jsonFieldKey;if(!og||!Object.prototype.hasOwnProperty.call(eg,og)){unlinkObject(ng,gg);continue}await setElementContent(ng,toElementValue(eg[og]),ig),ng.dirty=!0,gg.valueUpdatedCount++}}function unlinkObject(tg,eg){tg.jsonFieldKey="",tg.fromJson=!1,tg.type==="text"&&(tg.set?tg.set("editable",!0):tg.editable=!0),tg.dirty=!0,tg.id&&eg.unlinkedIds.push(tg.id),eg.unlinkedCount++}function toElementValue(tg){return typeof tg=="object"&&tg!==null?JSON.stringify(tg):String(tg??"")}async function setElementContent(tg,eg,gg){var ig,ng;if(String(tg.type).toLowerCase()==="image"){if(!(gg!=null&&gg.resolveImageSource))return;try{const og=await gg.resolveImageSource(eg);tg.setSrc?await tg.setSrc(og,{imageSource:tg.imageSource}):tg.set?tg.set("src",og):tg.src=og,(ig=tg.updateInGroup)==null||ig.call(tg)}catch(og){const ag=(og==null?void 0:og.message)||"图片加载失败";tg.set?tg.set("databaseImageError",ag):tg.databaseImageError=ag}return}if(tg.type==="barcode"){tg.setBarcodeOption?tg.setBarcodeOption({text:eg}):tg.barcodeOptions&&(tg.barcodeOptions.text=eg);return}if(tg.type==="barcode2d"){tg.setBarcode2DOption?tg.setBarcode2DOption({text:eg}):tg.barcode2dOptions&&(tg.barcode2dOptions.text=eg);return}tg.set?tg.set("text",eg):tg.text=eg,(ng=tg.updateInGroup)==null||ng.call(tg)}ji.customProperties=["customExportFields"];const _hoisted_1$15={class:"nest-menu"},_sfc_main$17=defineComponent({__name:"nest-menu",props:{items:{type:Array,required:!0}},setup(tg){const eg=useSlots(),gg=(ig,ng="")=>ig.map((og,ag)=>{if(og.children&&og.children.length){let sg=(ng?ng+"-":"")+(ag+1);return h$2(Menu.SubMenu,{key:sg,title:og.label,popupClassName:"le-target-menu"},{default:()=>gg(og.children,sg)})}else return h$2(Menu.Item,{key:(ng?ng+"-":"")+(ag+1)},{default:()=>eg.item({data:og})})});return(ig,ng)=>(openBlock(),createElementBlock("div",_hoisted_1$15,[createVNode(unref(Menu),mergeProps({mode:"horizontal"},ig.$attrs),{default:withCtx(()=>[(openBlock(!0),createElementBlock(Fragment,null,renderList(gg(tg.items),og=>(openBlock(),createBlock(resolveDynamicComponent(og),{key:og.key}))),128))]),_:1},16)]))}}),_export_sfc=(tg,eg)=>{const gg=tg.__vccOpts||tg;for(const[ig,ng]of eg)gg[ig]=ng;return gg},nestedMenu=_export_sfc(_sfc_main$17,[["__scopeId","data-v-ebd540f8"]]),emitter=mitt(),IconClose$1="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='21'%20height='20.5078125'%20viewBox='0%200%2021%2020.5078125'%3e%3cg%3e%3cg%3e%3cellipse%20cx='10.5'%20cy='10.25390625'%20rx='10.5'%20ry='10.25390625'%20fill='%23EAEAEA'%20fill-opacity='1'%20/%3e%3c/g%3e%3cg%20transform='matrix(0,1,-1,0,21.315007209777832,-11.299349784851074)'%3e%3cpath%20d='M26.872478497314454,5.368129712463379L26.872478497314454,5.368129712463379Q26.914278497314456,5.410926712463379,26.951778497314454,5.457711712463379Q26.98927849731445,5.504496712463379,27.022078497314453,5.554820712463379Q27.054878497314455,5.605143712463379,27.082778497314454,5.658520712463379Q27.110678497314453,5.7118977124633785,27.133278497314453,5.767813712463379Q27.155878497314454,5.823730712463379,27.173078497314453,5.881647712463379Q27.190178497314452,5.939565712463379,27.201778497314454,5.998925712463379Q27.213278497314455,6.058288712463379,27.219078497314452,6.118518712463379Q27.224878497314453,6.178748712463379,27.224878497314453,6.239278712463379Q27.224878497314453,6.299798712463379,27.219078497314452,6.360028712463379Q27.213278497314455,6.420258712463379,27.201778497314454,6.479618712463379Q27.190178497314452,6.538978712463379,27.173078497314453,6.5968987124633784Q27.155878497314454,6.654818712463379,27.133278497314453,6.7107287124633785Q27.110678497314453,6.766648712463379,27.082778497314454,6.820028712463379Q27.054878497314455,6.8734087124633785,27.022078497314453,6.923728712463379Q26.98927849731445,6.974048712463379,26.951778497314454,7.020838712463378Q26.914278497314456,7.0676187124633785,26.872478497314454,7.110418712463379L18.361158497314452,15.826028712463378Q18.319358497314454,15.86882871246338,18.273668497314453,15.907228712463379Q18.227988497314453,15.945628712463378,18.17883849731445,15.979228712463378Q18.129698497314454,16.01282871246338,18.077568497314452,16.04132871246338Q18.025448497314454,16.06992871246338,17.970838497314453,16.09302871246338Q17.916228497314453,16.11622871246338,17.859668497314452,16.133828712463377Q17.803108497314454,16.15132871246338,17.745148497314453,16.16312871246338Q17.687178497314452,16.174928712463377,17.62835849731445,16.180928712463377Q17.569538497314454,16.18682871246338,17.510428497314454,16.18682871246338Q17.451328497314453,16.18682871246338,17.392508497314452,16.180928712463377Q17.333688497314455,16.174928712463377,17.275714497314453,16.16312871246338Q17.217745497314453,16.15132871246338,17.161185497314452,16.133828712463377Q17.10462549731445,16.11622871246338,17.05001949731445,16.09302871246338Q16.995413497314452,16.06992871246338,16.943287497314454,16.04132871246338Q16.891162497314454,16.01282871246338,16.842018497314452,15.979228712463378Q16.792874497314454,15.945628712463378,16.747185497314454,15.907228712463379Q16.70149649731445,15.86882871246338,16.659703497314453,15.826028712463378L16.659703497314453,15.826028712463378Q16.617909497314454,15.783228712463378,16.580413497314453,15.736428712463379Q16.542918497314453,15.68962871246338,16.510081497314452,15.63932871246338Q16.47724449731445,15.58902871246338,16.449382497314453,15.535628712463378Q16.421520497314454,15.482228712463378,16.398901797314455,15.426328712463379Q16.376283297314455,15.37042871246338,16.359125997314454,15.31252871246338Q16.341968697314453,15.25452871246338,16.330437797314453,15.19522871246338Q16.318906997314453,15.135828712463379,16.313113657314453,15.075628712463379Q16.307320322314453,15.015428712463379,16.307320289314454,14.954858712463379Q16.307320256314455,14.894338712463378,16.313113517314452,14.834098712463378Q16.318906797314455,14.77386871246338,16.330437597314454,14.71450871246338Q16.34196829731445,14.65514871246338,16.359125597314453,14.597228712463378Q16.376282797314452,14.539308712463379,16.398901297314453,14.483398712463378Q16.421519497314453,14.42747871246338,16.44938149731445,14.374098712463379Q16.477243497314454,14.32072871246338,16.510080497314455,14.270398712463379Q16.542917497314452,14.220078712463378,16.580413497314453,14.173298712463378Q16.617908497314453,14.126508712463378,16.659702497314452,14.083708712463379L25.171018497314453,5.368129712463379Q25.212808497314455,5.325333712463379,25.258498497314456,5.286937712463379Q25.304188497314453,5.248541712463379,25.353328497314454,5.214916712463379Q25.40246849731445,5.181291712463379,25.454598497314453,5.152761712463379Q25.506728497314455,5.124230712463379,25.561328497314452,5.101069512463379Q25.615938497314453,5.077908212463379,25.672498497314454,5.060339212463379Q25.729058497314455,5.042770112463379,25.787028497314452,5.030962612463379Q25.844998497314453,5.019155012463379,25.903818497314454,5.013222702463379Q25.96263849731445,5.007290366463379,26.021738497314452,5.007290366463379Q26.080848497314452,5.007290366463379,26.139668497314453,5.013222702463379Q26.198488497314454,5.019155012463379,26.256458497314455,5.030962612463379Q26.31437849731445,5.042770112463379,26.370978497314454,5.060339212463379Q26.427578497314453,5.077908212463379,26.482178497314454,5.101069512463379Q26.53677849731445,5.124230712463379,26.588878497314454,5.152761712463379Q26.640978497314453,5.181291712463379,26.690178497314452,5.214916712463379Q26.73927849731445,5.248541712463379,26.784978497314455,5.286937712463379Q26.83067849731445,5.325333712463379,26.872478497314454,5.368129712463379Z'%20fill='%238C8C8C'%20fill-opacity='1'%20/%3e%3c/g%3e%3cg%20transform='rotate(90%2010.5%2010.5)%20matrix(0,1,-1,0,21.315007209777832,-11.299349784851074)'%3e%3cpath%20d='M26.872478497314454,5.368129712463379L26.872478497314454,5.368129712463379Q26.914278497314456,5.410926712463379,26.951778497314454,5.457711712463379Q26.98927849731445,5.504496712463379,27.022078497314453,5.554820712463379Q27.054878497314455,5.605143712463379,27.082778497314454,5.658520712463379Q27.110678497314453,5.7118977124633785,27.133278497314453,5.767813712463379Q27.155878497314454,5.823730712463379,27.173078497314453,5.881647712463379Q27.190178497314452,5.939565712463379,27.201778497314454,5.998925712463379Q27.213278497314455,6.058288712463379,27.219078497314452,6.118518712463379Q27.224878497314453,6.178748712463379,27.224878497314453,6.239278712463379Q27.224878497314453,6.299798712463379,27.219078497314452,6.360028712463379Q27.213278497314455,6.420258712463379,27.201778497314454,6.479618712463379Q27.190178497314452,6.538978712463379,27.173078497314453,6.5968987124633784Q27.155878497314454,6.654818712463379,27.133278497314453,6.7107287124633785Q27.110678497314453,6.766648712463379,27.082778497314454,6.820028712463379Q27.054878497314455,6.8734087124633785,27.022078497314453,6.923728712463379Q26.98927849731445,6.974048712463379,26.951778497314454,7.020838712463378Q26.914278497314456,7.0676187124633785,26.872478497314454,7.110418712463379L18.361158497314452,15.826028712463378Q18.319358497314454,15.86882871246338,18.273668497314453,15.907228712463379Q18.227988497314453,15.945628712463378,18.17883849731445,15.979228712463378Q18.129698497314454,16.01282871246338,18.077568497314452,16.04132871246338Q18.025448497314454,16.06992871246338,17.970838497314453,16.09302871246338Q17.916228497314453,16.11622871246338,17.859668497314452,16.133828712463377Q17.803108497314454,16.15132871246338,17.745148497314453,16.16312871246338Q17.687178497314452,16.174928712463377,17.62835849731445,16.180928712463377Q17.569538497314454,16.18682871246338,17.510428497314454,16.18682871246338Q17.451328497314453,16.18682871246338,17.392508497314452,16.180928712463377Q17.333688497314455,16.174928712463377,17.275714497314453,16.16312871246338Q17.217745497314453,16.15132871246338,17.161185497314452,16.133828712463377Q17.10462549731445,16.11622871246338,17.05001949731445,16.09302871246338Q16.995413497314452,16.06992871246338,16.943287497314454,16.04132871246338Q16.891162497314454,16.01282871246338,16.842018497314452,15.979228712463378Q16.792874497314454,15.945628712463378,16.747185497314454,15.907228712463379Q16.70149649731445,15.86882871246338,16.659703497314453,15.826028712463378L16.659703497314453,15.826028712463378Q16.617909497314454,15.783228712463378,16.580413497314453,15.736428712463379Q16.542918497314453,15.68962871246338,16.510081497314452,15.63932871246338Q16.47724449731445,15.58902871246338,16.449382497314453,15.535628712463378Q16.421520497314454,15.482228712463378,16.398901797314455,15.426328712463379Q16.376283297314455,15.37042871246338,16.359125997314454,15.31252871246338Q16.341968697314453,15.25452871246338,16.330437797314453,15.19522871246338Q16.318906997314453,15.135828712463379,16.313113657314453,15.075628712463379Q16.307320322314453,15.015428712463379,16.307320289314454,14.954858712463379Q16.307320256314455,14.894338712463378,16.313113517314452,14.834098712463378Q16.318906797314455,14.77386871246338,16.330437597314454,14.71450871246338Q16.34196829731445,14.65514871246338,16.359125597314453,14.597228712463378Q16.376282797314452,14.539308712463379,16.398901297314453,14.483398712463378Q16.421519497314453,14.42747871246338,16.44938149731445,14.374098712463379Q16.477243497314454,14.32072871246338,16.510080497314455,14.270398712463379Q16.542917497314452,14.220078712463378,16.580413497314453,14.173298712463378Q16.617908497314453,14.126508712463378,16.659702497314452,14.083708712463379L25.171018497314453,5.368129712463379Q25.212808497314455,5.325333712463379,25.258498497314456,5.286937712463379Q25.304188497314453,5.248541712463379,25.353328497314454,5.214916712463379Q25.40246849731445,5.181291712463379,25.454598497314453,5.152761712463379Q25.506728497314455,5.124230712463379,25.561328497314452,5.101069512463379Q25.615938497314453,5.077908212463379,25.672498497314454,5.060339212463379Q25.729058497314455,5.042770112463379,25.787028497314452,5.030962612463379Q25.844998497314453,5.019155012463379,25.903818497314454,5.013222702463379Q25.96263849731445,5.007290366463379,26.021738497314452,5.007290366463379Q26.080848497314452,5.007290366463379,26.139668497314453,5.013222702463379Q26.198488497314454,5.019155012463379,26.256458497314455,5.030962612463379Q26.31437849731445,5.042770112463379,26.370978497314454,5.060339212463379Q26.427578497314453,5.077908212463379,26.482178497314454,5.101069512463379Q26.53677849731445,5.124230712463379,26.588878497314454,5.152761712463379Q26.640978497314453,5.181291712463379,26.690178497314452,5.214916712463379Q26.73927849731445,5.248541712463379,26.784978497314455,5.286937712463379Q26.83067849731445,5.325333712463379,26.872478497314454,5.368129712463379Z'%20fill='%238C8C8C'%20fill-opacity='1'%20/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";function useDraggableWithBoundary(tg){const{elRef:eg}=tg,gg=ref(0),ig=ref(0),ng=ref(!1);let og=0,ag=0,sg=0,Ig=0;const Cg=()=>{if(!eg.value)return;const dg=eg.value.getBoundingClientRect();sg=dg.width,Ig=dg.height},lg=(dg,hg)=>Math.min(Math.max(dg,-hg),hg),Ag=dg=>{if(!ng.value)return;let hg=dg.clientX-og,mg=dg.clientY-ag;const bg=(window.innerWidth-sg)/2,pg=(window.innerHeight-Ig)/2;hg=lg(hg,bg),mg=lg(mg,pg),gg.value=hg,ig.value=mg},rg=()=>{ng.value=!1,document.removeEventListener("mousemove",Ag),document.removeEventListener("mouseup",rg)},cg=async dg=>{dg.button===0&&(ng.value=!0,await nextTick(),Cg(),og=dg.clientX-gg.value,ag=dg.clientY-ig.value,document.addEventListener("mousemove",Ag),document.addEventListener("mouseup",rg))},ug=()=>{Cg(),gg.value=lg(gg.value,window.innerWidth-sg),ig.value=lg(ig.value,window.innerHeight-Ig)};return window.addEventListener("resize",ug),onUnmounted(()=>{document.removeEventListener("mousemove",Ag),document.removeEventListener("mouseup",rg),window.removeEventListener("resize",ug)}),{x:gg,y:ig,onMouseDown:cg}}const _hoisted_1$14={class:"d-container"},_hoisted_2$Q={key:0,class:"d-mask"},_hoisted_3$I={class:"d-t-header"},_hoisted_4$C=["src"],_hoisted_5$z={key:0,class:"footer"},_sfc_main$16=defineComponent({__name:"Dialog",props:mergeModels({width:{type:String,default:"40%",required:!1},height:{type:String,default:"50%",required:!1},minHeight:{type:String,default:"300px",required:!1},maxHeight:{type:String,default:"auto",required:!1},minWidth:{type:String,default:void 0,required:!1},title:{type:String,required:!1},okBtnText:{type:String,default:void 0,require:!1},cancelBtnText:{type:String,default:void 0,require:!1},showOkBtn:{type:Boolean,default:!0,require:!1},showCancelBtn:{type:Boolean,default:!0,require:!1},showClose:{type:Boolean,default:!0,require:!1},noFooter:{type:Boolean,default:!1},maskShow:{type:Boolean,default:!1}},{open:{type:Boolean,default:!0},openModifiers:{},enabledOk:{type:Boolean,default:!0},enabledOkModifiers:{}}),emits:mergeModels(["finish"],["update:open","update:enabledOk"]),setup(tg,{emit:eg}){const{t:gg}=useI18n(),ig=ref(),ng=eg,og=useModel(tg,"open"),ag=tg;useModel(tg,"enabledOk");const{x:sg,y:Ig,onMouseDown:Cg}=useDraggableWithBoundary({elRef:ig}),lg=Ag=>{Ag.stopPropagation(),ng("finish","close")};return(Ag,rg)=>{const cg=Button$1;return og.value?(openBlock(),createBlock(Teleport,{key:0,to:"body"},[createBaseVNode("div",_hoisted_1$14,[tg.maskShow?(openBlock(),createElementBlock("div",_hoisted_2$Q)):createCommentVNode("",!0),createBaseVNode("div",{ref_key:"dialogRef",ref:ig,class:"dialog-content",style:normalizeStyle$1({height:ag.height,minHeight:ag.minHeight,width:ag.width,minWidth:ag.minWidth,maxHeight:ag.maxHeight,transform:`translate(${unref(sg)}px, ${unref(Ig)}px)`})},[createBaseVNode("div",_hoisted_3$I,[createBaseVNode("div",{class:"d-t-header-title",onMousedown:rg[0]||(rg[0]=(...ug)=>unref(Cg)&&unref(Cg)(...ug))},toDisplayString$1(ag.title),33),tg.showClose?(openBlock(),createElementBlock("img",{key:0,class:"m-close-icon",src:unref(IconClose$1),onClick:lg},null,8,_hoisted_4$C)):createCommentVNode("",!0)]),createBaseVNode("div",mergeProps({class:"custom-content"},Ag.$attrs),[renderSlot(Ag.$slots,"default",{},void 0)],16),tg.noFooter?createCommentVNode("",!0):(openBlock(),createElementBlock("div",_hoisted_5$z,[renderSlot(Ag.$slots,"ext-button",{},void 0),tg.showOkBtn?(openBlock(),createBlock(cg,{key:0,type:"primary",onClick:rg[1]||(rg[1]=ug=>ng("finish","ok")),disabled:!tg.enabledOk},{default:withCtx(()=>[createTextVNode(toDisplayString$1(ag.okBtnText??unref(gg)("common.actions.confirm")),1)]),_:1},8,["disabled"])):createCommentVNode("",!0),tg.showCancelBtn?(openBlock(),createBlock(cg,{key:1,style:{background:"#ffffff",color:"#828282"},onClick:rg[2]||(rg[2]=ug=>ng("finish","cancel"))},{default:withCtx(()=>[createTextVNode(toDisplayString$1(ag.cancelBtnText??unref(gg)("common.actions.cancel")),1)]),_:1})):createCommentVNode("",!0)]))],4)])])):createCommentVNode("",!0)}}}),__unplugin_components_1$1=_export_sfc(_sfc_main$16,[["__scopeId","data-v-e477a1bc"]]);function formatSafeError(tg){const eg=getActiveEditorLocale(),gg=toSafeError(tg);if(gg.logDetail!==void 0&&console.error("[Service error]",gg.logDetail),eg==="zh-CN"&&gg.key.startsWith("errors.unknown")){const ig=getErrorParts(tg).detail;if(ig)return ig}return translate(gg.key,{code:gg.code??""})}var browser={},canPromise,hasRequiredCanPromise;function requireCanPromise(){return hasRequiredCanPromise||(hasRequiredCanPromise=1,canPromise=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),canPromise}var qrcode$1={},utils$1={},hasRequiredUtils$1;function requireUtils$1(){if(hasRequiredUtils$1)return utils$1;hasRequiredUtils$1=1;let tg;const eg=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return utils$1.getSymbolSize=function(ig){if(!ig)throw new Error('"version" cannot be null or undefined');if(ig<1||ig>40)throw new Error('"version" should be in range from 1 to 40');return ig*4+17},utils$1.getSymbolTotalCodewords=function(ig){return eg[ig]},utils$1.getBCHDigit=function(gg){let ig=0;for(;gg!==0;)ig++,gg>>>=1;return ig},utils$1.setToSJISFunction=function(ig){if(typeof ig!="function")throw new Error('"toSJISFunc" is not a valid function.');tg=ig},utils$1.isKanjiModeEnabled=function(){return typeof tg<"u"},utils$1.toSJIS=function(ig){return tg(ig)},utils$1}var errorCorrectionLevel={},hasRequiredErrorCorrectionLevel;function requireErrorCorrectionLevel(){return hasRequiredErrorCorrectionLevel||(hasRequiredErrorCorrectionLevel=1,(function(tg){tg.L={bit:1},tg.M={bit:0},tg.Q={bit:3},tg.H={bit:2};function eg(gg){if(typeof gg!="string")throw new Error("Param is not a string");switch(gg.toLowerCase()){case"l":case"low":return tg.L;case"m":case"medium":return tg.M;case"q":case"quartile":return tg.Q;case"h":case"high":return tg.H;default:throw new Error("Unknown EC Level: "+gg)}}tg.isValid=function(ig){return ig&&typeof ig.bit<"u"&&ig.bit>=0&&ig.bit<4},tg.from=function(ig,ng){if(tg.isValid(ig))return ig;try{return eg(ig)}catch{return ng}}})(errorCorrectionLevel)),errorCorrectionLevel}var bitBuffer,hasRequiredBitBuffer;function requireBitBuffer(){if(hasRequiredBitBuffer)return bitBuffer;hasRequiredBitBuffer=1;function tg(){this.buffer=[],this.length=0}return tg.prototype={get:function(eg){const gg=Math.floor(eg/8);return(this.buffer[gg]>>>7-eg%8&1)===1},put:function(eg,gg){for(let ig=0;ig<gg;ig++)this.putBit((eg>>>gg-ig-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(eg){const gg=Math.floor(this.length/8);this.buffer.length<=gg&&this.buffer.push(0),eg&&(this.buffer[gg]|=128>>>this.length%8),this.length++}},bitBuffer=tg,bitBuffer}var bitMatrix,hasRequiredBitMatrix;function requireBitMatrix(){if(hasRequiredBitMatrix)return bitMatrix;hasRequiredBitMatrix=1;function tg(eg){if(!eg||eg<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=eg,this.data=new Uint8Array(eg*eg),this.reservedBit=new Uint8Array(eg*eg)}return tg.prototype.set=function(eg,gg,ig,ng){const og=eg*this.size+gg;this.data[og]=ig,ng&&(this.reservedBit[og]=!0)},tg.prototype.get=function(eg,gg){return this.data[eg*this.size+gg]},tg.prototype.xor=function(eg,gg,ig){this.data[eg*this.size+gg]^=ig},tg.prototype.isReserved=function(eg,gg){return this.reservedBit[eg*this.size+gg]},bitMatrix=tg,bitMatrix}var alignmentPattern={},hasRequiredAlignmentPattern;function requireAlignmentPattern(){return hasRequiredAlignmentPattern||(hasRequiredAlignmentPattern=1,(function(tg){const eg=requireUtils$1().getSymbolSize;tg.getRowColCoords=function(ig){if(ig===1)return[];const ng=Math.floor(ig/7)+2,og=eg(ig),ag=og===145?26:Math.ceil((og-13)/(2*ng-2))*2,sg=[og-7];for(let Ig=1;Ig<ng-1;Ig++)sg[Ig]=sg[Ig-1]-ag;return sg.push(6),sg.reverse()},tg.getPositions=function(ig){const ng=[],og=tg.getRowColCoords(ig),ag=og.length;for(let sg=0;sg<ag;sg++)for(let Ig=0;Ig<ag;Ig++)sg===0&&Ig===0||sg===0&&Ig===ag-1||sg===ag-1&&Ig===0||ng.push([og[sg],og[Ig]]);return ng}})(alignmentPattern)),alignmentPattern}var finderPattern={},hasRequiredFinderPattern;function requireFinderPattern(){if(hasRequiredFinderPattern)return finderPattern;hasRequiredFinderPattern=1;const tg=requireUtils$1().getSymbolSize,eg=7;return finderPattern.getPositions=function(ig){const ng=tg(ig);return[[0,0],[ng-eg,0],[0,ng-eg]]},finderPattern}var maskPattern={},hasRequiredMaskPattern;function requireMaskPattern(){return hasRequiredMaskPattern||(hasRequiredMaskPattern=1,(function(tg){tg.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const eg={N1:3,N2:3,N3:40,N4:10};tg.isValid=function(ng){return ng!=null&&ng!==""&&!isNaN(ng)&&ng>=0&&ng<=7},tg.from=function(ng){return tg.isValid(ng)?parseInt(ng,10):void 0},tg.getPenaltyN1=function(ng){const og=ng.size;let ag=0,sg=0,Ig=0,Cg=null,lg=null;for(let Ag=0;Ag<og;Ag++){sg=Ig=0,Cg=lg=null;for(let rg=0;rg<og;rg++){let cg=ng.get(Ag,rg);cg===Cg?sg++:(sg>=5&&(ag+=eg.N1+(sg-5)),Cg=cg,sg=1),cg=ng.get(rg,Ag),cg===lg?Ig++:(Ig>=5&&(ag+=eg.N1+(Ig-5)),lg=cg,Ig=1)}sg>=5&&(ag+=eg.N1+(sg-5)),Ig>=5&&(ag+=eg.N1+(Ig-5))}return ag},tg.getPenaltyN2=function(ng){const og=ng.size;let ag=0;for(let sg=0;sg<og-1;sg++)for(let Ig=0;Ig<og-1;Ig++){const Cg=ng.get(sg,Ig)+ng.get(sg,Ig+1)+ng.get(sg+1,Ig)+ng.get(sg+1,Ig+1);(Cg===4||Cg===0)&&ag++}return ag*eg.N2},tg.getPenaltyN3=function(ng){const og=ng.size;let ag=0,sg=0,Ig=0;for(let Cg=0;Cg<og;Cg++){sg=Ig=0;for(let lg=0;lg<og;lg++)sg=sg<<1&2047|ng.get(Cg,lg),lg>=10&&(sg===1488||sg===93)&&ag++,Ig=Ig<<1&2047|ng.get(lg,Cg),lg>=10&&(Ig===1488||Ig===93)&&ag++}return ag*eg.N3},tg.getPenaltyN4=function(ng){let og=0;const ag=ng.data.length;for(let Ig=0;Ig<ag;Ig++)og+=ng.data[Ig];return Math.abs(Math.ceil(og*100/ag/5)-10)*eg.N4};function gg(ig,ng,og){switch(ig){case tg.Patterns.PATTERN000:return(ng+og)%2===0;case tg.Patterns.PATTERN001:return ng%2===0;case tg.Patterns.PATTERN010:return og%3===0;case tg.Patterns.PATTERN011:return(ng+og)%3===0;case tg.Patterns.PATTERN100:return(Math.floor(ng/2)+Math.floor(og/3))%2===0;case tg.Patterns.PATTERN101:return ng*og%2+ng*og%3===0;case tg.Patterns.PATTERN110:return(ng*og%2+ng*og%3)%2===0;case tg.Patterns.PATTERN111:return(ng*og%3+(ng+og)%2)%2===0;default:throw new Error("bad maskPattern:"+ig)}}tg.applyMask=function(ng,og){const ag=og.size;for(let sg=0;sg<ag;sg++)for(let Ig=0;Ig<ag;Ig++)og.isReserved(Ig,sg)||og.xor(Ig,sg,gg(ng,Ig,sg))},tg.getBestMask=function(ng,og){const ag=Object.keys(tg.Patterns).length;let sg=0,Ig=1/0;for(let Cg=0;Cg<ag;Cg++){og(Cg),tg.applyMask(Cg,ng);const lg=tg.getPenaltyN1(ng)+tg.getPenaltyN2(ng)+tg.getPenaltyN3(ng)+tg.getPenaltyN4(ng);tg.applyMask(Cg,ng),lg<Ig&&(Ig=lg,sg=Cg)}return sg}})(maskPattern)),maskPattern}var errorCorrectionCode={},hasRequiredErrorCorrectionCode;function requireErrorCorrectionCode(){if(hasRequiredErrorCorrectionCode)return errorCorrectionCode;hasRequiredErrorCorrectionCode=1;const tg=requireErrorCorrectionLevel(),eg=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],gg=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return errorCorrectionCode.getBlocksCount=function(ng,og){switch(og){case tg.L:return eg[(ng-1)*4+0];case tg.M:return eg[(ng-1)*4+1];case tg.Q:return eg[(ng-1)*4+2];case tg.H:return eg[(ng-1)*4+3];default:return}},errorCorrectionCode.getTotalCodewordsCount=function(ng,og){switch(og){case tg.L:return gg[(ng-1)*4+0];case tg.M:return gg[(ng-1)*4+1];case tg.Q:return gg[(ng-1)*4+2];case tg.H:return gg[(ng-1)*4+3];default:return}},errorCorrectionCode}var polynomial={},galoisField={},hasRequiredGaloisField;function requireGaloisField(){if(hasRequiredGaloisField)return galoisField;hasRequiredGaloisField=1;const tg=new Uint8Array(512),eg=new Uint8Array(256);return(function(){let ig=1;for(let ng=0;ng<255;ng++)tg[ng]=ig,eg[ig]=ng,ig<<=1,ig&256&&(ig^=285);for(let ng=255;ng<512;ng++)tg[ng]=tg[ng-255]})(),galoisField.log=function(ig){if(ig<1)throw new Error("log("+ig+")");return eg[ig]},galoisField.exp=function(ig){return tg[ig]},galoisField.mul=function(ig,ng){return ig===0||ng===0?0:tg[eg[ig]+eg[ng]]},galoisField}var hasRequiredPolynomial;function requirePolynomial(){return hasRequiredPolynomial||(hasRequiredPolynomial=1,(function(tg){const eg=requireGaloisField();tg.mul=function(ig,ng){const og=new Uint8Array(ig.length+ng.length-1);for(let ag=0;ag<ig.length;ag++)for(let sg=0;sg<ng.length;sg++)og[ag+sg]^=eg.mul(ig[ag],ng[sg]);return og},tg.mod=function(ig,ng){let og=new Uint8Array(ig);for(;og.length-ng.length>=0;){const ag=og[0];for(let Ig=0;Ig<ng.length;Ig++)og[Ig]^=eg.mul(ng[Ig],ag);let sg=0;for(;sg<og.length&&og[sg]===0;)sg++;og=og.slice(sg)}return og},tg.generateECPolynomial=function(ig){let ng=new Uint8Array([1]);for(let og=0;og<ig;og++)ng=tg.mul(ng,new Uint8Array([1,eg.exp(og)]));return ng}})(polynomial)),polynomial}var reedSolomonEncoder,hasRequiredReedSolomonEncoder;function requireReedSolomonEncoder(){if(hasRequiredReedSolomonEncoder)return reedSolomonEncoder;hasRequiredReedSolomonEncoder=1;const tg=requirePolynomial();function eg(gg){this.genPoly=void 0,this.degree=gg,this.degree&&this.initialize(this.degree)}return eg.prototype.initialize=function(ig){this.degree=ig,this.genPoly=tg.generateECPolynomial(this.degree)},eg.prototype.encode=function(ig){if(!this.genPoly)throw new Error("Encoder not initialized");const ng=new Uint8Array(ig.length+this.degree);ng.set(ig);const og=tg.mod(ng,this.genPoly),ag=this.degree-og.length;if(ag>0){const sg=new Uint8Array(this.degree);return sg.set(og,ag),sg}return og},reedSolomonEncoder=eg,reedSolomonEncoder}var version={},mode={},versionCheck={},hasRequiredVersionCheck;function requireVersionCheck(){return hasRequiredVersionCheck||(hasRequiredVersionCheck=1,versionCheck.isValid=function(eg){return!isNaN(eg)&&eg>=1&&eg<=40}),versionCheck}var regex={},hasRequiredRegex;function requireRegex(){if(hasRequiredRegex)return regex;hasRequiredRegex=1;const tg="[0-9]+",eg="[A-Z $%*+\\-./:]+";let gg="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";gg=gg.replace(/u/g,"\\u");const ig="(?:(?![A-Z0-9 $%*+\\-./:]|"+gg+`)(?:.|[\r
|
|
930
|
+
`).flatMap(ng=>{let og="";const ag=ng.split(/\s+/).filter(sg=>sg);return ag.reduce((sg,Ig,Cg)=>{const lg=og?`${og} ${Ig}`:Ig;return tg.measureText(lg).width<=gg?og=lg:(og&&sg.push(og),og=Ig,(Cg===ag.length-1||tg.measureText(Ig).width>gg)&&(sg.push(...splitLongWord(tg,Ig,gg)),og="")),Cg===ag.length-1&&og&&sg.push(og),sg},[])})}function getLineHeight(tg){const eg=tg.font.match(/\d+/),gg=10;return eg?parseInt(eg[0],gg):gg}function generateThumbnail(tg,eg,gg){let{width:ig,height:ng}=tg;const og=Math.min(eg/ig,gg/ng);ig*=og,ng*=og;const ag=document.createElement("canvas"),sg=ag.getContext("2d");if(!sg)throw new Error("Canvas context not available");return ag.width=ig,ag.height=ng,sg.drawImage(tg,0,0,ig,ng),ag.toDataURL("image/png",.85)}class LuxonError extends Error{}class InvalidDateTimeError extends LuxonError{constructor(eg){super(`Invalid DateTime: ${eg.toMessage()}`)}}class InvalidIntervalError extends LuxonError{constructor(eg){super(`Invalid Interval: ${eg.toMessage()}`)}}class InvalidDurationError extends LuxonError{constructor(eg){super(`Invalid Duration: ${eg.toMessage()}`)}}class ConflictingSpecificationError extends LuxonError{}class InvalidUnitError extends LuxonError{constructor(eg){super(`Invalid unit ${eg}`)}}class InvalidArgumentError extends LuxonError{}class ZoneIsAbstractError extends LuxonError{constructor(){super("Zone is an abstract class")}}const n="numeric",s="short",l="long",DATE_SHORT={year:n,month:n,day:n},DATE_MED={year:n,month:s,day:n},DATE_MED_WITH_WEEKDAY={year:n,month:s,day:n,weekday:s},DATE_FULL={year:n,month:l,day:n},DATE_HUGE={year:n,month:l,day:n,weekday:l},TIME_SIMPLE={hour:n,minute:n},TIME_WITH_SECONDS={hour:n,minute:n,second:n},TIME_WITH_SHORT_OFFSET={hour:n,minute:n,second:n,timeZoneName:s},TIME_WITH_LONG_OFFSET={hour:n,minute:n,second:n,timeZoneName:l},TIME_24_SIMPLE={hour:n,minute:n,hourCycle:"h23"},TIME_24_WITH_SECONDS={hour:n,minute:n,second:n,hourCycle:"h23"},TIME_24_WITH_SHORT_OFFSET={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:s},TIME_24_WITH_LONG_OFFSET={hour:n,minute:n,second:n,hourCycle:"h23",timeZoneName:l},DATETIME_SHORT={year:n,month:n,day:n,hour:n,minute:n},DATETIME_SHORT_WITH_SECONDS={year:n,month:n,day:n,hour:n,minute:n,second:n},DATETIME_MED={year:n,month:s,day:n,hour:n,minute:n},DATETIME_MED_WITH_SECONDS={year:n,month:s,day:n,hour:n,minute:n,second:n},DATETIME_MED_WITH_WEEKDAY={year:n,month:s,day:n,weekday:s,hour:n,minute:n},DATETIME_FULL={year:n,month:l,day:n,hour:n,minute:n,timeZoneName:s},DATETIME_FULL_WITH_SECONDS={year:n,month:l,day:n,hour:n,minute:n,second:n,timeZoneName:s},DATETIME_HUGE={year:n,month:l,day:n,weekday:l,hour:n,minute:n,timeZoneName:l},DATETIME_HUGE_WITH_SECONDS={year:n,month:l,day:n,weekday:l,hour:n,minute:n,second:n,timeZoneName:l};class Zone{get type(){throw new ZoneIsAbstractError}get name(){throw new ZoneIsAbstractError}get ianaName(){return this.name}get isUniversal(){throw new ZoneIsAbstractError}offsetName(eg,gg){throw new ZoneIsAbstractError}formatOffset(eg,gg){throw new ZoneIsAbstractError}offset(eg){throw new ZoneIsAbstractError}equals(eg){throw new ZoneIsAbstractError}get isValid(){throw new ZoneIsAbstractError}}let singleton$1=null;class SystemZone extends Zone{static get instance(){return singleton$1===null&&(singleton$1=new SystemZone),singleton$1}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(eg,{format:gg,locale:ig}){return parseZoneInfo(eg,gg,ig)}formatOffset(eg,gg){return formatOffset(this.offset(eg),gg)}offset(eg){return-new Date(eg).getTimezoneOffset()}equals(eg){return eg.type==="system"}get isValid(){return!0}}const dtfCache=new Map;function makeDTF(tg){let eg=dtfCache.get(tg);return eg===void 0&&(eg=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:tg,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),dtfCache.set(tg,eg)),eg}const typeToPos={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function hackyOffset(tg,eg){const gg=tg.format(eg).replace(/\u200E/g,""),ig=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(gg),[,ng,og,ag,sg,Ig,Cg,lg]=ig;return[ag,ng,og,sg,Ig,Cg,lg]}function partsOffset(tg,eg){const gg=tg.formatToParts(eg),ig=[];for(let ng=0;ng<gg.length;ng++){const{type:og,value:ag}=gg[ng],sg=typeToPos[og];og==="era"?ig[sg]=ag:isUndefined$1(sg)||(ig[sg]=parseInt(ag,10))}return ig}const ianaZoneCache=new Map;class IANAZone extends Zone{static create(eg){let gg=ianaZoneCache.get(eg);return gg===void 0&&ianaZoneCache.set(eg,gg=new IANAZone(eg)),gg}static resetCache(){ianaZoneCache.clear(),dtfCache.clear()}static isValidSpecifier(eg){return this.isValidZone(eg)}static isValidZone(eg){if(!eg)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:eg}).format(),!0}catch{return!1}}constructor(eg){super(),this.zoneName=eg,this.valid=IANAZone.isValidZone(eg)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(eg,{format:gg,locale:ig}){return parseZoneInfo(eg,gg,ig,this.name)}formatOffset(eg,gg){return formatOffset(this.offset(eg),gg)}offset(eg){if(!this.valid)return NaN;const gg=new Date(eg);if(isNaN(gg))return NaN;const ig=makeDTF(this.name);let[ng,og,ag,sg,Ig,Cg,lg]=ig.formatToParts?partsOffset(ig,gg):hackyOffset(ig,gg);sg==="BC"&&(ng=-Math.abs(ng)+1);const rg=objToLocalTS({year:ng,month:og,day:ag,hour:Ig===24?0:Ig,minute:Cg,second:lg,millisecond:0});let cg=+gg;const ug=cg%1e3;return cg-=ug>=0?ug:1e3+ug,(rg-cg)/(60*1e3)}equals(eg){return eg.type==="iana"&&eg.name===this.name}get isValid(){return this.valid}}let intlLFCache={};function getCachedLF(tg,eg={}){const gg=JSON.stringify([tg,eg]);let ig=intlLFCache[gg];return ig||(ig=new Intl.ListFormat(tg,eg),intlLFCache[gg]=ig),ig}const intlDTCache=new Map;function getCachedDTF(tg,eg={}){const gg=JSON.stringify([tg,eg]);let ig=intlDTCache.get(gg);return ig===void 0&&(ig=new Intl.DateTimeFormat(tg,eg),intlDTCache.set(gg,ig)),ig}const intlNumCache=new Map;function getCachedINF(tg,eg={}){const gg=JSON.stringify([tg,eg]);let ig=intlNumCache.get(gg);return ig===void 0&&(ig=new Intl.NumberFormat(tg,eg),intlNumCache.set(gg,ig)),ig}const intlRelCache=new Map;function getCachedRTF(tg,eg={}){const{base:gg,...ig}=eg,ng=JSON.stringify([tg,ig]);let og=intlRelCache.get(ng);return og===void 0&&(og=new Intl.RelativeTimeFormat(tg,eg),intlRelCache.set(ng,og)),og}let sysLocaleCache=null;function systemLocale(){return sysLocaleCache||(sysLocaleCache=new Intl.DateTimeFormat().resolvedOptions().locale,sysLocaleCache)}const intlResolvedOptionsCache=new Map;function getCachedIntResolvedOptions(tg){let eg=intlResolvedOptionsCache.get(tg);return eg===void 0&&(eg=new Intl.DateTimeFormat(tg).resolvedOptions(),intlResolvedOptionsCache.set(tg,eg)),eg}const weekInfoCache=new Map;function getCachedWeekInfo(tg){let eg=weekInfoCache.get(tg);if(!eg){const gg=new Intl.Locale(tg);eg="getWeekInfo"in gg?gg.getWeekInfo():gg.weekInfo,"minimalDays"in eg||(eg={...fallbackWeekSettings,...eg}),weekInfoCache.set(tg,eg)}return eg}function parseLocaleString(tg){const eg=tg.indexOf("-x-");eg!==-1&&(tg=tg.substring(0,eg));const gg=tg.indexOf("-u-");if(gg===-1)return[tg];{let ig,ng;try{ig=getCachedDTF(tg).resolvedOptions(),ng=tg}catch{const Ig=tg.substring(0,gg);ig=getCachedDTF(Ig).resolvedOptions(),ng=Ig}const{numberingSystem:og,calendar:ag}=ig;return[ng,og,ag]}}function intlConfigString(tg,eg,gg){return(gg||eg)&&(tg.includes("-u-")||(tg+="-u"),gg&&(tg+=`-ca-${gg}`),eg&&(tg+=`-nu-${eg}`)),tg}function mapMonths(tg){const eg=[];for(let gg=1;gg<=12;gg++){const ig=DateTime.utc(2009,gg,1);eg.push(tg(ig))}return eg}function mapWeekdays(tg){const eg=[];for(let gg=1;gg<=7;gg++){const ig=DateTime.utc(2016,11,13+gg);eg.push(tg(ig))}return eg}function listStuff(tg,eg,gg,ig){const ng=tg.listingMode();return ng==="error"?null:ng==="en"?gg(eg):ig(eg)}function supportsFastNumbers(tg){return tg.numberingSystem&&tg.numberingSystem!=="latn"?!1:tg.numberingSystem==="latn"||!tg.locale||tg.locale.startsWith("en")||getCachedIntResolvedOptions(tg.locale).numberingSystem==="latn"}class PolyNumberFormatter{constructor(eg,gg,ig){this.padTo=ig.padTo||0,this.floor=ig.floor||!1;const{padTo:ng,floor:og,...ag}=ig;if(!gg||Object.keys(ag).length>0){const sg={useGrouping:!1,...ig};ig.padTo>0&&(sg.minimumIntegerDigits=ig.padTo),this.inf=getCachedINF(eg,sg)}}format(eg){if(this.inf){const gg=this.floor?Math.floor(eg):eg;return this.inf.format(gg)}else{const gg=this.floor?Math.floor(eg):roundTo(eg,3);return padStart(gg,this.padTo)}}}class PolyDateFormatter{constructor(eg,gg,ig){this.opts=ig,this.originalZone=void 0;let ng;if(this.opts.timeZone)this.dt=eg;else if(eg.zone.type==="fixed"){const ag=-1*(eg.offset/60),sg=ag>=0?`Etc/GMT+${ag}`:`Etc/GMT${ag}`;eg.offset!==0&&IANAZone.create(sg).valid?(ng=sg,this.dt=eg):(ng="UTC",this.dt=eg.offset===0?eg:eg.setZone("UTC").plus({minutes:eg.offset}),this.originalZone=eg.zone)}else eg.zone.type==="system"?this.dt=eg:eg.zone.type==="iana"?(this.dt=eg,ng=eg.zone.name):(ng="UTC",this.dt=eg.setZone("UTC").plus({minutes:eg.offset}),this.originalZone=eg.zone);const og={...this.opts};og.timeZone=og.timeZone||ng,this.dtf=getCachedDTF(gg,og)}format(){return this.originalZone?this.formatToParts().map(({value:eg})=>eg).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const eg=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?eg.map(gg=>{if(gg.type==="timeZoneName"){const ig=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...gg,value:ig}}else return gg}):eg}resolvedOptions(){return this.dtf.resolvedOptions()}}class PolyRelFormatter{constructor(eg,gg,ig){this.opts={style:"long",...ig},!gg&&hasRelative()&&(this.rtf=getCachedRTF(eg,ig))}format(eg,gg){return this.rtf?this.rtf.format(eg,gg):formatRelativeTime(gg,eg,this.opts.numeric,this.opts.style!=="long")}formatToParts(eg,gg){return this.rtf?this.rtf.formatToParts(eg,gg):[]}}const fallbackWeekSettings={firstDay:1,minimalDays:4,weekend:[6,7]};class Locale{static fromOpts(eg){return Locale.create(eg.locale,eg.numberingSystem,eg.outputCalendar,eg.weekSettings,eg.defaultToEN)}static create(eg,gg,ig,ng,og=!1){const ag=eg||Settings.defaultLocale,sg=ag||(og?"en-US":systemLocale()),Ig=gg||Settings.defaultNumberingSystem,Cg=ig||Settings.defaultOutputCalendar,lg=validateWeekSettings(ng)||Settings.defaultWeekSettings;return new Locale(sg,Ig,Cg,lg,ag)}static resetCache(){sysLocaleCache=null,intlDTCache.clear(),intlNumCache.clear(),intlRelCache.clear(),intlResolvedOptionsCache.clear(),weekInfoCache.clear()}static fromObject({locale:eg,numberingSystem:gg,outputCalendar:ig,weekSettings:ng}={}){return Locale.create(eg,gg,ig,ng)}constructor(eg,gg,ig,ng,og){const[ag,sg,Ig]=parseLocaleString(eg);this.locale=ag,this.numberingSystem=gg||sg||null,this.outputCalendar=ig||Ig||null,this.weekSettings=ng,this.intl=intlConfigString(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=og,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=supportsFastNumbers(this)),this.fastNumbersCached}listingMode(){const eg=this.isEnglish(),gg=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return eg&&gg?"en":"intl"}clone(eg){return!eg||Object.getOwnPropertyNames(eg).length===0?this:Locale.create(eg.locale||this.specifiedLocale,eg.numberingSystem||this.numberingSystem,eg.outputCalendar||this.outputCalendar,validateWeekSettings(eg.weekSettings)||this.weekSettings,eg.defaultToEN||!1)}redefaultToEN(eg={}){return this.clone({...eg,defaultToEN:!0})}redefaultToSystem(eg={}){return this.clone({...eg,defaultToEN:!1})}months(eg,gg=!1){return listStuff(this,eg,months,()=>{const ig=this.intl==="ja"||this.intl.startsWith("ja-");gg&=!ig;const ng=gg?{month:eg,day:"numeric"}:{month:eg},og=gg?"format":"standalone";if(!this.monthsCache[og][eg]){const ag=ig?sg=>this.dtFormatter(sg,ng).format():sg=>this.extract(sg,ng,"month");this.monthsCache[og][eg]=mapMonths(ag)}return this.monthsCache[og][eg]})}weekdays(eg,gg=!1){return listStuff(this,eg,weekdays,()=>{const ig=gg?{weekday:eg,year:"numeric",month:"long",day:"numeric"}:{weekday:eg},ng=gg?"format":"standalone";return this.weekdaysCache[ng][eg]||(this.weekdaysCache[ng][eg]=mapWeekdays(og=>this.extract(og,ig,"weekday"))),this.weekdaysCache[ng][eg]})}meridiems(){return listStuff(this,void 0,()=>meridiems,()=>{if(!this.meridiemCache){const eg={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[DateTime.utc(2016,11,13,9),DateTime.utc(2016,11,13,19)].map(gg=>this.extract(gg,eg,"dayperiod"))}return this.meridiemCache})}eras(eg){return listStuff(this,eg,eras,()=>{const gg={era:eg};return this.eraCache[eg]||(this.eraCache[eg]=[DateTime.utc(-40,1,1),DateTime.utc(2017,1,1)].map(ig=>this.extract(ig,gg,"era"))),this.eraCache[eg]})}extract(eg,gg,ig){const ng=this.dtFormatter(eg,gg),og=ng.formatToParts(),ag=og.find(sg=>sg.type.toLowerCase()===ig);return ag?ag.value:null}numberFormatter(eg={}){return new PolyNumberFormatter(this.intl,eg.forceSimple||this.fastNumbers,eg)}dtFormatter(eg,gg={}){return new PolyDateFormatter(eg,this.intl,gg)}relFormatter(eg={}){return new PolyRelFormatter(this.intl,this.isEnglish(),eg)}listFormatter(eg={}){return getCachedLF(this.intl,eg)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||getCachedIntResolvedOptions(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:hasLocaleWeekInfo()?getCachedWeekInfo(this.locale):fallbackWeekSettings}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(eg){return this.locale===eg.locale&&this.numberingSystem===eg.numberingSystem&&this.outputCalendar===eg.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let singleton=null;class FixedOffsetZone extends Zone{static get utcInstance(){return singleton===null&&(singleton=new FixedOffsetZone(0)),singleton}static instance(eg){return eg===0?FixedOffsetZone.utcInstance:new FixedOffsetZone(eg)}static parseSpecifier(eg){if(eg){const gg=eg.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(gg)return new FixedOffsetZone(signedOffset(gg[1],gg[2]))}return null}constructor(eg){super(),this.fixed=eg}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${formatOffset(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${formatOffset(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(eg,gg){return formatOffset(this.fixed,gg)}get isUniversal(){return!0}offset(){return this.fixed}equals(eg){return eg.type==="fixed"&&eg.fixed===this.fixed}get isValid(){return!0}}class InvalidZone extends Zone{constructor(eg){super(),this.zoneName=eg}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function normalizeZone(tg,eg){if(isUndefined$1(tg)||tg===null)return eg;if(tg instanceof Zone)return tg;if(isString$1(tg)){const gg=tg.toLowerCase();return gg==="default"?eg:gg==="local"||gg==="system"?SystemZone.instance:gg==="utc"||gg==="gmt"?FixedOffsetZone.utcInstance:FixedOffsetZone.parseSpecifier(gg)||IANAZone.create(tg)}else return isNumber$1(tg)?FixedOffsetZone.instance(tg):typeof tg=="object"&&"offset"in tg&&typeof tg.offset=="function"?tg:new InvalidZone(tg)}const numberingSystems={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},numberingSystemsUTF16={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},hanidecChars=numberingSystems.hanidec.replace(/[\[|\]]/g,"").split("");function parseDigits(tg){let eg=parseInt(tg,10);if(isNaN(eg)){eg="";for(let gg=0;gg<tg.length;gg++){const ig=tg.charCodeAt(gg);if(tg[gg].search(numberingSystems.hanidec)!==-1)eg+=hanidecChars.indexOf(tg[gg]);else for(const ng in numberingSystemsUTF16){const[og,ag]=numberingSystemsUTF16[ng];ig>=og&&ig<=ag&&(eg+=ig-og)}}return parseInt(eg,10)}else return eg}const digitRegexCache=new Map;function resetDigitRegexCache(){digitRegexCache.clear()}function digitRegex({numberingSystem:tg},eg=""){const gg=tg||"latn";let ig=digitRegexCache.get(gg);ig===void 0&&(ig=new Map,digitRegexCache.set(gg,ig));let ng=ig.get(eg);return ng===void 0&&(ng=new RegExp(`${numberingSystems[gg]}${eg}`),ig.set(eg,ng)),ng}let now=()=>Date.now(),defaultZone="system",defaultLocale=null,defaultNumberingSystem=null,defaultOutputCalendar=null,twoDigitCutoffYear=60,throwOnInvalid,defaultWeekSettings=null;class Settings{static get now(){return now}static set now(eg){now=eg}static set defaultZone(eg){defaultZone=eg}static get defaultZone(){return normalizeZone(defaultZone,SystemZone.instance)}static get defaultLocale(){return defaultLocale}static set defaultLocale(eg){defaultLocale=eg}static get defaultNumberingSystem(){return defaultNumberingSystem}static set defaultNumberingSystem(eg){defaultNumberingSystem=eg}static get defaultOutputCalendar(){return defaultOutputCalendar}static set defaultOutputCalendar(eg){defaultOutputCalendar=eg}static get defaultWeekSettings(){return defaultWeekSettings}static set defaultWeekSettings(eg){defaultWeekSettings=validateWeekSettings(eg)}static get twoDigitCutoffYear(){return twoDigitCutoffYear}static set twoDigitCutoffYear(eg){twoDigitCutoffYear=eg%100}static get throwOnInvalid(){return throwOnInvalid}static set throwOnInvalid(eg){throwOnInvalid=eg}static resetCaches(){Locale.resetCache(),IANAZone.resetCache(),DateTime.resetCache(),resetDigitRegexCache()}}class Invalid{constructor(eg,gg){this.reason=eg,this.explanation=gg}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const nonLeapLadder=[0,31,59,90,120,151,181,212,243,273,304,334],leapLadder=[0,31,60,91,121,152,182,213,244,274,305,335];function unitOutOfRange(tg,eg){return new Invalid("unit out of range",`you specified ${eg} (of type ${typeof eg}) as a ${tg}, which is invalid`)}function dayOfWeek(tg,eg,gg){const ig=new Date(Date.UTC(tg,eg-1,gg));tg<100&&tg>=0&&ig.setUTCFullYear(ig.getUTCFullYear()-1900);const ng=ig.getUTCDay();return ng===0?7:ng}function computeOrdinal(tg,eg,gg){return gg+(isLeapYear(tg)?leapLadder:nonLeapLadder)[eg-1]}function uncomputeOrdinal(tg,eg){const gg=isLeapYear(tg)?leapLadder:nonLeapLadder,ig=gg.findIndex(og=>og<eg),ng=eg-gg[ig];return{month:ig+1,day:ng}}function isoWeekdayToLocal(tg,eg){return(tg-eg+7)%7+1}function gregorianToWeek(tg,eg=4,gg=1){const{year:ig,month:ng,day:og}=tg,ag=computeOrdinal(ig,ng,og),sg=isoWeekdayToLocal(dayOfWeek(ig,ng,og),gg);let Ig=Math.floor((ag-sg+14-eg)/7),Cg;return Ig<1?(Cg=ig-1,Ig=weeksInWeekYear(Cg,eg,gg)):Ig>weeksInWeekYear(ig,eg,gg)?(Cg=ig+1,Ig=1):Cg=ig,{weekYear:Cg,weekNumber:Ig,weekday:sg,...timeObject(tg)}}function weekToGregorian(tg,eg=4,gg=1){const{weekYear:ig,weekNumber:ng,weekday:og}=tg,ag=isoWeekdayToLocal(dayOfWeek(ig,1,eg),gg),sg=daysInYear(ig);let Ig=ng*7+og-ag-7+eg,Cg;Ig<1?(Cg=ig-1,Ig+=daysInYear(Cg)):Ig>sg?(Cg=ig+1,Ig-=daysInYear(ig)):Cg=ig;const{month:lg,day:Ag}=uncomputeOrdinal(Cg,Ig);return{year:Cg,month:lg,day:Ag,...timeObject(tg)}}function gregorianToOrdinal(tg){const{year:eg,month:gg,day:ig}=tg,ng=computeOrdinal(eg,gg,ig);return{year:eg,ordinal:ng,...timeObject(tg)}}function ordinalToGregorian(tg){const{year:eg,ordinal:gg}=tg,{month:ig,day:ng}=uncomputeOrdinal(eg,gg);return{year:eg,month:ig,day:ng,...timeObject(tg)}}function usesLocalWeekValues(tg,eg){if(!isUndefined$1(tg.localWeekday)||!isUndefined$1(tg.localWeekNumber)||!isUndefined$1(tg.localWeekYear)){if(!isUndefined$1(tg.weekday)||!isUndefined$1(tg.weekNumber)||!isUndefined$1(tg.weekYear))throw new ConflictingSpecificationError("Cannot mix locale-based week fields with ISO-based week fields");return isUndefined$1(tg.localWeekday)||(tg.weekday=tg.localWeekday),isUndefined$1(tg.localWeekNumber)||(tg.weekNumber=tg.localWeekNumber),isUndefined$1(tg.localWeekYear)||(tg.weekYear=tg.localWeekYear),delete tg.localWeekday,delete tg.localWeekNumber,delete tg.localWeekYear,{minDaysInFirstWeek:eg.getMinDaysInFirstWeek(),startOfWeek:eg.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function hasInvalidWeekData(tg,eg=4,gg=1){const ig=isInteger(tg.weekYear),ng=integerBetween(tg.weekNumber,1,weeksInWeekYear(tg.weekYear,eg,gg)),og=integerBetween(tg.weekday,1,7);return ig?ng?og?!1:unitOutOfRange("weekday",tg.weekday):unitOutOfRange("week",tg.weekNumber):unitOutOfRange("weekYear",tg.weekYear)}function hasInvalidOrdinalData(tg){const eg=isInteger(tg.year),gg=integerBetween(tg.ordinal,1,daysInYear(tg.year));return eg?gg?!1:unitOutOfRange("ordinal",tg.ordinal):unitOutOfRange("year",tg.year)}function hasInvalidGregorianData(tg){const eg=isInteger(tg.year),gg=integerBetween(tg.month,1,12),ig=integerBetween(tg.day,1,daysInMonth(tg.year,tg.month));return eg?gg?ig?!1:unitOutOfRange("day",tg.day):unitOutOfRange("month",tg.month):unitOutOfRange("year",tg.year)}function hasInvalidTimeData(tg){const{hour:eg,minute:gg,second:ig,millisecond:ng}=tg,og=integerBetween(eg,0,23)||eg===24&&gg===0&&ig===0&&ng===0,ag=integerBetween(gg,0,59),sg=integerBetween(ig,0,59),Ig=integerBetween(ng,0,999);return og?ag?sg?Ig?!1:unitOutOfRange("millisecond",ng):unitOutOfRange("second",ig):unitOutOfRange("minute",gg):unitOutOfRange("hour",eg)}function isUndefined$1(tg){return typeof tg>"u"}function isNumber$1(tg){return typeof tg=="number"}function isInteger(tg){return typeof tg=="number"&&tg%1===0}function isString$1(tg){return typeof tg=="string"}function isDate$1(tg){return Object.prototype.toString.call(tg)==="[object Date]"}function hasRelative(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function hasLocaleWeekInfo(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function maybeArray(tg){return Array.isArray(tg)?tg:[tg]}function bestBy(tg,eg,gg){if(tg.length!==0)return tg.reduce((ig,ng)=>{const og=[eg(ng),ng];return ig&&gg(ig[0],og[0])===ig[0]?ig:og},null)[1]}function pick(tg,eg){return eg.reduce((gg,ig)=>(gg[ig]=tg[ig],gg),{})}function hasOwnProperty(tg,eg){return Object.prototype.hasOwnProperty.call(tg,eg)}function validateWeekSettings(tg){if(tg==null)return null;if(typeof tg!="object")throw new InvalidArgumentError("Week settings must be an object");if(!integerBetween(tg.firstDay,1,7)||!integerBetween(tg.minimalDays,1,7)||!Array.isArray(tg.weekend)||tg.weekend.some(eg=>!integerBetween(eg,1,7)))throw new InvalidArgumentError("Invalid week settings");return{firstDay:tg.firstDay,minimalDays:tg.minimalDays,weekend:Array.from(tg.weekend)}}function integerBetween(tg,eg,gg){return isInteger(tg)&&tg>=eg&&tg<=gg}function floorMod(tg,eg){return tg-eg*Math.floor(tg/eg)}function padStart(tg,eg=2){const gg=tg<0;let ig;return gg?ig="-"+(""+-tg).padStart(eg,"0"):ig=(""+tg).padStart(eg,"0"),ig}function parseInteger(tg){if(!(isUndefined$1(tg)||tg===null||tg===""))return parseInt(tg,10)}function parseFloating(tg){if(!(isUndefined$1(tg)||tg===null||tg===""))return parseFloat(tg)}function parseMillis(tg){if(!(isUndefined$1(tg)||tg===null||tg==="")){const eg=parseFloat("0."+tg)*1e3;return Math.floor(eg)}}function roundTo(tg,eg,gg="round"){const ig=10**eg;switch(gg){case"expand":return tg>0?Math.ceil(tg*ig)/ig:Math.floor(tg*ig)/ig;case"trunc":return Math.trunc(tg*ig)/ig;case"round":return Math.round(tg*ig)/ig;case"floor":return Math.floor(tg*ig)/ig;case"ceil":return Math.ceil(tg*ig)/ig;default:throw new RangeError(`Value rounding ${gg} is out of range`)}}function isLeapYear(tg){return tg%4===0&&(tg%100!==0||tg%400===0)}function daysInYear(tg){return isLeapYear(tg)?366:365}function daysInMonth(tg,eg){const gg=floorMod(eg-1,12)+1,ig=tg+(eg-gg)/12;return gg===2?isLeapYear(ig)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][gg-1]}function objToLocalTS(tg){let eg=Date.UTC(tg.year,tg.month-1,tg.day,tg.hour,tg.minute,tg.second,tg.millisecond);return tg.year<100&&tg.year>=0&&(eg=new Date(eg),eg.setUTCFullYear(tg.year,tg.month-1,tg.day)),+eg}function firstWeekOffset(tg,eg,gg){return-isoWeekdayToLocal(dayOfWeek(tg,1,eg),gg)+eg-1}function weeksInWeekYear(tg,eg=4,gg=1){const ig=firstWeekOffset(tg,eg,gg),ng=firstWeekOffset(tg+1,eg,gg);return(daysInYear(tg)-ig+ng)/7}function untruncateYear(tg){return tg>99?tg:tg>Settings.twoDigitCutoffYear?1900+tg:2e3+tg}function parseZoneInfo(tg,eg,gg,ig=null){const ng=new Date(tg),og={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};ig&&(og.timeZone=ig);const ag={timeZoneName:eg,...og},sg=new Intl.DateTimeFormat(gg,ag).formatToParts(ng).find(Ig=>Ig.type.toLowerCase()==="timezonename");return sg?sg.value:null}function signedOffset(tg,eg){let gg=parseInt(tg,10);Number.isNaN(gg)&&(gg=0);const ig=parseInt(eg,10)||0,ng=gg<0||Object.is(gg,-0)?-ig:ig;return gg*60+ng}function asNumber(tg){const eg=Number(tg);if(typeof tg=="boolean"||tg===""||!Number.isFinite(eg))throw new InvalidArgumentError(`Invalid unit value ${tg}`);return eg}function normalizeObject(tg,eg){const gg={};for(const ig in tg)if(hasOwnProperty(tg,ig)){const ng=tg[ig];if(ng==null)continue;gg[eg(ig)]=asNumber(ng)}return gg}function formatOffset(tg,eg){const gg=Math.trunc(Math.abs(tg/60)),ig=Math.trunc(Math.abs(tg%60)),ng=tg>=0?"+":"-";switch(eg){case"short":return`${ng}${padStart(gg,2)}:${padStart(ig,2)}`;case"narrow":return`${ng}${gg}${ig>0?`:${ig}`:""}`;case"techie":return`${ng}${padStart(gg,2)}${padStart(ig,2)}`;default:throw new RangeError(`Value format ${eg} is out of range for property format`)}}function timeObject(tg){return pick(tg,["hour","minute","second","millisecond"])}const monthsLong=["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],monthsNarrow=["J","F","M","A","M","J","J","A","S","O","N","D"];function months(tg){switch(tg){case"narrow":return[...monthsNarrow];case"short":return[...monthsShort];case"long":return[...monthsLong];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const weekdaysLong=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],weekdaysShort=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],weekdaysNarrow=["M","T","W","T","F","S","S"];function weekdays(tg){switch(tg){case"narrow":return[...weekdaysNarrow];case"short":return[...weekdaysShort];case"long":return[...weekdaysLong];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const meridiems=["AM","PM"],erasLong=["Before Christ","Anno Domini"],erasShort=["BC","AD"],erasNarrow=["B","A"];function eras(tg){switch(tg){case"narrow":return[...erasNarrow];case"short":return[...erasShort];case"long":return[...erasLong];default:return null}}function meridiemForDateTime(tg){return meridiems[tg.hour<12?0:1]}function weekdayForDateTime(tg,eg){return weekdays(eg)[tg.weekday-1]}function monthForDateTime(tg,eg){return months(eg)[tg.month-1]}function eraForDateTime(tg,eg){return eras(eg)[tg.year<0?0:1]}function formatRelativeTime(tg,eg,gg="always",ig=!1){const ng={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},og=["hours","minutes","seconds"].indexOf(tg)===-1;if(gg==="auto"&&og){const Ag=tg==="days";switch(eg){case 1:return Ag?"tomorrow":`next ${ng[tg][0]}`;case-1:return Ag?"yesterday":`last ${ng[tg][0]}`;case 0:return Ag?"today":`this ${ng[tg][0]}`}}const ag=Object.is(eg,-0)||eg<0,sg=Math.abs(eg),Ig=sg===1,Cg=ng[tg],lg=ig?Ig?Cg[1]:Cg[2]||Cg[1]:Ig?ng[tg][0]:tg;return ag?`${sg} ${lg} ago`:`in ${sg} ${lg}`}function stringifyTokens(tg,eg){let gg="";for(const ig of tg)ig.literal?gg+=ig.val:gg+=eg(ig.val);return gg}const macroTokenToFormatOpts={D:DATE_SHORT,DD:DATE_MED,DDD:DATE_FULL,DDDD:DATE_HUGE,t:TIME_SIMPLE,tt:TIME_WITH_SECONDS,ttt:TIME_WITH_SHORT_OFFSET,tttt:TIME_WITH_LONG_OFFSET,T:TIME_24_SIMPLE,TT:TIME_24_WITH_SECONDS,TTT:TIME_24_WITH_SHORT_OFFSET,TTTT:TIME_24_WITH_LONG_OFFSET,f:DATETIME_SHORT,ff:DATETIME_MED,fff:DATETIME_FULL,ffff:DATETIME_HUGE,F:DATETIME_SHORT_WITH_SECONDS,FF:DATETIME_MED_WITH_SECONDS,FFF:DATETIME_FULL_WITH_SECONDS,FFFF:DATETIME_HUGE_WITH_SECONDS};class Formatter{static create(eg,gg={}){return new Formatter(eg,gg)}static parseFormat(eg){let gg=null,ig="",ng=!1;const og=[];for(let ag=0;ag<eg.length;ag++){const sg=eg.charAt(ag);sg==="'"?((ig.length>0||ng)&&og.push({literal:ng||/^\s+$/.test(ig),val:ig===""?"'":ig}),gg=null,ig="",ng=!ng):ng||sg===gg?ig+=sg:(ig.length>0&&og.push({literal:/^\s+$/.test(ig),val:ig}),ig=sg,gg=sg)}return ig.length>0&&og.push({literal:ng||/^\s+$/.test(ig),val:ig}),og}static macroTokenToFormatOpts(eg){return macroTokenToFormatOpts[eg]}constructor(eg,gg){this.opts=gg,this.loc=eg,this.systemLoc=null}formatWithSystemDefault(eg,gg){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(eg,{...this.opts,...gg}).format()}dtFormatter(eg,gg={}){return this.loc.dtFormatter(eg,{...this.opts,...gg})}formatDateTime(eg,gg){return this.dtFormatter(eg,gg).format()}formatDateTimeParts(eg,gg){return this.dtFormatter(eg,gg).formatToParts()}formatInterval(eg,gg){return this.dtFormatter(eg.start,gg).dtf.formatRange(eg.start.toJSDate(),eg.end.toJSDate())}resolvedOptions(eg,gg){return this.dtFormatter(eg,gg).resolvedOptions()}num(eg,gg=0,ig=void 0){if(this.opts.forceSimple)return padStart(eg,gg);const ng={...this.opts};return gg>0&&(ng.padTo=gg),ig&&(ng.signDisplay=ig),this.loc.numberFormatter(ng).format(eg)}formatDateTimeFromString(eg,gg){const ig=this.loc.listingMode()==="en",ng=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",og=(cg,ug)=>this.loc.extract(eg,cg,ug),ag=cg=>eg.isOffsetFixed&&eg.offset===0&&cg.allowZ?"Z":eg.isValid?eg.zone.formatOffset(eg.ts,cg.format):"",sg=()=>ig?meridiemForDateTime(eg):og({hour:"numeric",hourCycle:"h12"},"dayperiod"),Ig=(cg,ug)=>ig?monthForDateTime(eg,cg):og(ug?{month:cg}:{month:cg,day:"numeric"},"month"),Cg=(cg,ug)=>ig?weekdayForDateTime(eg,cg):og(ug?{weekday:cg}:{weekday:cg,month:"long",day:"numeric"},"weekday"),lg=cg=>{const ug=Formatter.macroTokenToFormatOpts(cg);return ug?this.formatWithSystemDefault(eg,ug):cg},Ag=cg=>ig?eraForDateTime(eg,cg):og({era:cg},"era"),rg=cg=>{switch(cg){case"S":return this.num(eg.millisecond);case"u":case"SSS":return this.num(eg.millisecond,3);case"s":return this.num(eg.second);case"ss":return this.num(eg.second,2);case"uu":return this.num(Math.floor(eg.millisecond/10),2);case"uuu":return this.num(Math.floor(eg.millisecond/100));case"m":return this.num(eg.minute);case"mm":return this.num(eg.minute,2);case"h":return this.num(eg.hour%12===0?12:eg.hour%12);case"hh":return this.num(eg.hour%12===0?12:eg.hour%12,2);case"H":return this.num(eg.hour);case"HH":return this.num(eg.hour,2);case"Z":return ag({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return ag({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return ag({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return eg.zone.offsetName(eg.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return eg.zone.offsetName(eg.ts,{format:"long",locale:this.loc.locale});case"z":return eg.zoneName;case"a":return sg();case"d":return ng?og({day:"numeric"},"day"):this.num(eg.day);case"dd":return ng?og({day:"2-digit"},"day"):this.num(eg.day,2);case"c":return this.num(eg.weekday);case"ccc":return Cg("short",!0);case"cccc":return Cg("long",!0);case"ccccc":return Cg("narrow",!0);case"E":return this.num(eg.weekday);case"EEE":return Cg("short",!1);case"EEEE":return Cg("long",!1);case"EEEEE":return Cg("narrow",!1);case"L":return ng?og({month:"numeric",day:"numeric"},"month"):this.num(eg.month);case"LL":return ng?og({month:"2-digit",day:"numeric"},"month"):this.num(eg.month,2);case"LLL":return Ig("short",!0);case"LLLL":return Ig("long",!0);case"LLLLL":return Ig("narrow",!0);case"M":return ng?og({month:"numeric"},"month"):this.num(eg.month);case"MM":return ng?og({month:"2-digit"},"month"):this.num(eg.month,2);case"MMM":return Ig("short",!1);case"MMMM":return Ig("long",!1);case"MMMMM":return Ig("narrow",!1);case"y":return ng?og({year:"numeric"},"year"):this.num(eg.year);case"yy":return ng?og({year:"2-digit"},"year"):this.num(eg.year.toString().slice(-2),2);case"yyyy":return ng?og({year:"numeric"},"year"):this.num(eg.year,4);case"yyyyyy":return ng?og({year:"numeric"},"year"):this.num(eg.year,6);case"G":return Ag("short");case"GG":return Ag("long");case"GGGGG":return Ag("narrow");case"kk":return this.num(eg.weekYear.toString().slice(-2),2);case"kkkk":return this.num(eg.weekYear,4);case"W":return this.num(eg.weekNumber);case"WW":return this.num(eg.weekNumber,2);case"n":return this.num(eg.localWeekNumber);case"nn":return this.num(eg.localWeekNumber,2);case"ii":return this.num(eg.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(eg.localWeekYear,4);case"o":return this.num(eg.ordinal);case"ooo":return this.num(eg.ordinal,3);case"q":return this.num(eg.quarter);case"qq":return this.num(eg.quarter,2);case"X":return this.num(Math.floor(eg.ts/1e3));case"x":return this.num(eg.ts);default:return lg(cg)}};return stringifyTokens(Formatter.parseFormat(gg),rg)}formatDurationFromString(eg,gg){const ig=this.opts.signMode==="negativeLargestOnly"?-1:1,ng=lg=>{switch(lg[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},og=(lg,Ag)=>rg=>{const cg=ng(rg);if(cg){const ug=Ag.isNegativeDuration&&cg!==Ag.largestUnit?ig:1;let dg;return this.opts.signMode==="negativeLargestOnly"&&cg!==Ag.largestUnit?dg="never":this.opts.signMode==="all"?dg="always":dg="auto",this.num(lg.get(cg)*ug,rg.length,dg)}else return rg},ag=Formatter.parseFormat(gg),sg=ag.reduce((lg,{literal:Ag,val:rg})=>Ag?lg:lg.concat(rg),[]),Ig=eg.shiftTo(...sg.map(ng).filter(lg=>lg)),Cg={isNegativeDuration:Ig<0,largestUnit:Object.keys(Ig.values)[0]};return stringifyTokens(ag,og(Ig,Cg))}}const ianaRegex=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function combineRegexes(...tg){const eg=tg.reduce((gg,ig)=>gg+ig.source,"");return RegExp(`^${eg}$`)}function combineExtractors(...tg){return eg=>tg.reduce(([gg,ig,ng],og)=>{const[ag,sg,Ig]=og(eg,ng);return[{...gg,...ag},sg||ig,Ig]},[{},null,1]).slice(0,2)}function parse(tg,...eg){if(tg==null)return[null,null];for(const[gg,ig]of eg){const ng=gg.exec(tg);if(ng)return ig(ng)}return[null,null]}function simpleParse(...tg){return(eg,gg)=>{const ig={};let ng;for(ng=0;ng<tg.length;ng++)ig[tg[ng]]=parseInteger(eg[gg+ng]);return[ig,null,gg+ng]}}const offsetRegex=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,isoExtendedZone=`(?:${offsetRegex.source}?(?:\\[(${ianaRegex.source})\\])?)?`,isoTimeBaseRegex=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,isoTimeRegex=RegExp(`${isoTimeBaseRegex.source}${isoExtendedZone}`),isoTimeExtensionRegex=RegExp(`(?:[Tt]${isoTimeRegex.source})?`),isoYmdRegex=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,isoWeekRegex=/(\d{4})-?W(\d\d)(?:-?(\d))?/,isoOrdinalRegex=/(\d{4})-?(\d{3})/,extractISOWeekData=simpleParse("weekYear","weekNumber","weekDay"),extractISOOrdinalData=simpleParse("year","ordinal"),sqlYmdRegex=/(\d{4})-(\d\d)-(\d\d)/,sqlTimeRegex=RegExp(`${isoTimeBaseRegex.source} ?(?:${offsetRegex.source}|(${ianaRegex.source}))?`),sqlTimeExtensionRegex=RegExp(`(?: ${sqlTimeRegex.source})?`);function int(tg,eg,gg){const ig=tg[eg];return isUndefined$1(ig)?gg:parseInteger(ig)}function extractISOYmd(tg,eg){return[{year:int(tg,eg),month:int(tg,eg+1,1),day:int(tg,eg+2,1)},null,eg+3]}function extractISOTime(tg,eg){return[{hours:int(tg,eg,0),minutes:int(tg,eg+1,0),seconds:int(tg,eg+2,0),milliseconds:parseMillis(tg[eg+3])},null,eg+4]}function extractISOOffset(tg,eg){const gg=!tg[eg]&&!tg[eg+1],ig=signedOffset(tg[eg+1],tg[eg+2]),ng=gg?null:FixedOffsetZone.instance(ig);return[{},ng,eg+3]}function extractIANAZone(tg,eg){const gg=tg[eg]?IANAZone.create(tg[eg]):null;return[{},gg,eg+1]}const isoTimeOnly=RegExp(`^T?${isoTimeBaseRegex.source}$`),isoDuration=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function extractISODuration(tg){const[eg,gg,ig,ng,og,ag,sg,Ig,Cg]=tg,lg=eg[0]==="-",Ag=Ig&&Ig[0]==="-",rg=(cg,ug=!1)=>cg!==void 0&&(ug||cg&&lg)?-cg:cg;return[{years:rg(parseFloating(gg)),months:rg(parseFloating(ig)),weeks:rg(parseFloating(ng)),days:rg(parseFloating(og)),hours:rg(parseFloating(ag)),minutes:rg(parseFloating(sg)),seconds:rg(parseFloating(Ig),Ig==="-0"),milliseconds:rg(parseMillis(Cg),Ag)}]}const obsOffsets={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function fromStrings(tg,eg,gg,ig,ng,og,ag){const sg={year:eg.length===2?untruncateYear(parseInteger(eg)):parseInteger(eg),month:monthsShort.indexOf(gg)+1,day:parseInteger(ig),hour:parseInteger(ng),minute:parseInteger(og)};return ag&&(sg.second=parseInteger(ag)),tg&&(sg.weekday=tg.length>3?weekdaysLong.indexOf(tg)+1:weekdaysShort.indexOf(tg)+1),sg}const rfc2822=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function extractRFC2822(tg){const[,eg,gg,ig,ng,og,ag,sg,Ig,Cg,lg,Ag]=tg,rg=fromStrings(eg,ng,ig,gg,og,ag,sg);let cg;return Ig?cg=obsOffsets[Ig]:Cg?cg=0:cg=signedOffset(lg,Ag),[rg,new FixedOffsetZone(cg)]}function preprocessRFC2822(tg){return tg.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const rfc1123=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,rfc850=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,ascii=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function extractRFC1123Or850(tg){const[,eg,gg,ig,ng,og,ag,sg]=tg;return[fromStrings(eg,ng,ig,gg,og,ag,sg),FixedOffsetZone.utcInstance]}function extractASCII(tg){const[,eg,gg,ig,ng,og,ag,sg]=tg;return[fromStrings(eg,sg,gg,ig,ng,og,ag),FixedOffsetZone.utcInstance]}const isoYmdWithTimeExtensionRegex=combineRegexes(isoYmdRegex,isoTimeExtensionRegex),isoWeekWithTimeExtensionRegex=combineRegexes(isoWeekRegex,isoTimeExtensionRegex),isoOrdinalWithTimeExtensionRegex=combineRegexes(isoOrdinalRegex,isoTimeExtensionRegex),isoTimeCombinedRegex=combineRegexes(isoTimeRegex),extractISOYmdTimeAndOffset=combineExtractors(extractISOYmd,extractISOTime,extractISOOffset,extractIANAZone),extractISOWeekTimeAndOffset=combineExtractors(extractISOWeekData,extractISOTime,extractISOOffset,extractIANAZone),extractISOOrdinalDateAndTime=combineExtractors(extractISOOrdinalData,extractISOTime,extractISOOffset,extractIANAZone),extractISOTimeAndOffset=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseISODate(tg){return parse(tg,[isoYmdWithTimeExtensionRegex,extractISOYmdTimeAndOffset],[isoWeekWithTimeExtensionRegex,extractISOWeekTimeAndOffset],[isoOrdinalWithTimeExtensionRegex,extractISOOrdinalDateAndTime],[isoTimeCombinedRegex,extractISOTimeAndOffset])}function parseRFC2822Date(tg){return parse(preprocessRFC2822(tg),[rfc2822,extractRFC2822])}function parseHTTPDate(tg){return parse(tg,[rfc1123,extractRFC1123Or850],[rfc850,extractRFC1123Or850],[ascii,extractASCII])}function parseISODuration(tg){return parse(tg,[isoDuration,extractISODuration])}const extractISOTimeOnly=combineExtractors(extractISOTime);function parseISOTimeOnly(tg){return parse(tg,[isoTimeOnly,extractISOTimeOnly])}const sqlYmdWithTimeExtensionRegex=combineRegexes(sqlYmdRegex,sqlTimeExtensionRegex),sqlTimeCombinedRegex=combineRegexes(sqlTimeRegex),extractISOTimeOffsetAndIANAZone=combineExtractors(extractISOTime,extractISOOffset,extractIANAZone);function parseSQL(tg){return parse(tg,[sqlYmdWithTimeExtensionRegex,extractISOYmdTimeAndOffset],[sqlTimeCombinedRegex,extractISOTimeOffsetAndIANAZone])}const INVALID$2="Invalid Duration",lowOrderMatrix={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},casualMatrix={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...lowOrderMatrix},daysInYearAccurate=146097/400,daysInMonthAccurate=146097/4800,accurateMatrix={years:{quarters:4,months:12,weeks:daysInYearAccurate/7,days:daysInYearAccurate,hours:daysInYearAccurate*24,minutes:daysInYearAccurate*24*60,seconds:daysInYearAccurate*24*60*60,milliseconds:daysInYearAccurate*24*60*60*1e3},quarters:{months:3,weeks:daysInYearAccurate/28,days:daysInYearAccurate/4,hours:daysInYearAccurate*24/4,minutes:daysInYearAccurate*24*60/4,seconds:daysInYearAccurate*24*60*60/4,milliseconds:daysInYearAccurate*24*60*60*1e3/4},months:{weeks:daysInMonthAccurate/7,days:daysInMonthAccurate,hours:daysInMonthAccurate*24,minutes:daysInMonthAccurate*24*60,seconds:daysInMonthAccurate*24*60*60,milliseconds:daysInMonthAccurate*24*60*60*1e3},...lowOrderMatrix},orderedUnits$1=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],reverseUnits=orderedUnits$1.slice(0).reverse();function clone$1(tg,eg,gg=!1){const ig={values:gg?eg.values:{...tg.values,...eg.values||{}},loc:tg.loc.clone(eg.loc),conversionAccuracy:eg.conversionAccuracy||tg.conversionAccuracy,matrix:eg.matrix||tg.matrix};return new Duration(ig)}function durationToMillis(tg,eg){let gg=eg.milliseconds??0;for(const ig of reverseUnits.slice(1))eg[ig]&&(gg+=eg[ig]*tg[ig].milliseconds);return gg}function normalizeValues(tg,eg){const gg=durationToMillis(tg,eg)<0?-1:1;orderedUnits$1.reduceRight((ig,ng)=>{if(isUndefined$1(eg[ng]))return ig;if(ig){const og=eg[ig]*gg,ag=tg[ng][ig],sg=Math.floor(og/ag);eg[ng]+=sg*gg,eg[ig]-=sg*ag*gg}return ng},null),orderedUnits$1.reduce((ig,ng)=>{if(isUndefined$1(eg[ng]))return ig;if(ig){const og=eg[ig]%1;eg[ig]-=og,eg[ng]+=og*tg[ig][ng]}return ng},null)}function removeZeroes(tg){const eg={};for(const[gg,ig]of Object.entries(tg))ig!==0&&(eg[gg]=ig);return eg}class Duration{constructor(eg){const gg=eg.conversionAccuracy==="longterm"||!1;let ig=gg?accurateMatrix:casualMatrix;eg.matrix&&(ig=eg.matrix),this.values=eg.values,this.loc=eg.loc||Locale.create(),this.conversionAccuracy=gg?"longterm":"casual",this.invalid=eg.invalid||null,this.matrix=ig,this.isLuxonDuration=!0}static fromMillis(eg,gg){return Duration.fromObject({milliseconds:eg},gg)}static fromObject(eg,gg={}){if(eg==null||typeof eg!="object")throw new InvalidArgumentError(`Duration.fromObject: argument expected to be an object, got ${eg===null?"null":typeof eg}`);return new Duration({values:normalizeObject(eg,Duration.normalizeUnit),loc:Locale.fromObject(gg),conversionAccuracy:gg.conversionAccuracy,matrix:gg.matrix})}static fromDurationLike(eg){if(isNumber$1(eg))return Duration.fromMillis(eg);if(Duration.isDuration(eg))return eg;if(typeof eg=="object")return Duration.fromObject(eg);throw new InvalidArgumentError(`Unknown duration argument ${eg} of type ${typeof eg}`)}static fromISO(eg,gg){const[ig]=parseISODuration(eg);return ig?Duration.fromObject(ig,gg):Duration.invalid("unparsable",`the input "${eg}" can't be parsed as ISO 8601`)}static fromISOTime(eg,gg){const[ig]=parseISOTimeOnly(eg);return ig?Duration.fromObject(ig,gg):Duration.invalid("unparsable",`the input "${eg}" can't be parsed as ISO 8601`)}static invalid(eg,gg=null){if(!eg)throw new InvalidArgumentError("need to specify a reason the Duration is invalid");const ig=eg instanceof Invalid?eg:new Invalid(eg,gg);if(Settings.throwOnInvalid)throw new InvalidDurationError(ig);return new Duration({invalid:ig})}static normalizeUnit(eg){const gg={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[eg&&eg.toLowerCase()];if(!gg)throw new InvalidUnitError(eg);return gg}static isDuration(eg){return eg&&eg.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(eg,gg={}){const ig={...gg,floor:gg.round!==!1&&gg.floor!==!1};return this.isValid?Formatter.create(this.loc,ig).formatDurationFromString(this,eg):INVALID$2}toHuman(eg={}){if(!this.isValid)return INVALID$2;const gg=eg.showZeros!==!1,ig=orderedUnits$1.map(ng=>{const og=this.values[ng];return isUndefined$1(og)||og===0&&!gg?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...eg,unit:ng.slice(0,-1)}).format(og)}).filter(ng=>ng);return this.loc.listFormatter({type:"conjunction",style:eg.listStyle||"narrow",...eg}).format(ig)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let eg="P";return this.years!==0&&(eg+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(eg+=this.months+this.quarters*3+"M"),this.weeks!==0&&(eg+=this.weeks+"W"),this.days!==0&&(eg+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(eg+="T"),this.hours!==0&&(eg+=this.hours+"H"),this.minutes!==0&&(eg+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(eg+=roundTo(this.seconds+this.milliseconds/1e3,3)+"S"),eg==="P"&&(eg+="T0S"),eg}toISOTime(eg={}){if(!this.isValid)return null;const gg=this.toMillis();return gg<0||gg>=864e5?null:(eg={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...eg,includeOffset:!1},DateTime.fromMillis(gg,{zone:"UTC"}).toISOTime(eg))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?durationToMillis(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg),ig={};for(const ng of orderedUnits$1)(hasOwnProperty(gg.values,ng)||hasOwnProperty(this.values,ng))&&(ig[ng]=gg.get(ng)+this.get(ng));return clone$1(this,{values:ig},!0)}minus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg);return this.plus(gg.negate())}mapUnits(eg){if(!this.isValid)return this;const gg={};for(const ig of Object.keys(this.values))gg[ig]=asNumber(eg(this.values[ig],ig));return clone$1(this,{values:gg},!0)}get(eg){return this[Duration.normalizeUnit(eg)]}set(eg){if(!this.isValid)return this;const gg={...this.values,...normalizeObject(eg,Duration.normalizeUnit)};return clone$1(this,{values:gg})}reconfigure({locale:eg,numberingSystem:gg,conversionAccuracy:ig,matrix:ng}={}){const ag={loc:this.loc.clone({locale:eg,numberingSystem:gg}),matrix:ng,conversionAccuracy:ig};return clone$1(this,ag)}as(eg){return this.isValid?this.shiftTo(eg).get(eg):NaN}normalize(){if(!this.isValid)return this;const eg=this.toObject();return normalizeValues(this.matrix,eg),clone$1(this,{values:eg},!0)}rescale(){if(!this.isValid)return this;const eg=removeZeroes(this.normalize().shiftToAll().toObject());return clone$1(this,{values:eg},!0)}shiftTo(...eg){if(!this.isValid)return this;if(eg.length===0)return this;eg=eg.map(ag=>Duration.normalizeUnit(ag));const gg={},ig={},ng=this.toObject();let og;for(const ag of orderedUnits$1)if(eg.indexOf(ag)>=0){og=ag;let sg=0;for(const Cg in ig)sg+=this.matrix[Cg][ag]*ig[Cg],ig[Cg]=0;isNumber$1(ng[ag])&&(sg+=ng[ag]);const Ig=Math.trunc(sg);gg[ag]=Ig,ig[ag]=(sg*1e3-Ig*1e3)/1e3}else isNumber$1(ng[ag])&&(ig[ag]=ng[ag]);for(const ag in ig)ig[ag]!==0&&(gg[og]+=ag===og?ig[ag]:ig[ag]/this.matrix[og][ag]);return normalizeValues(this.matrix,gg),clone$1(this,{values:gg},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const eg={};for(const gg of Object.keys(this.values))eg[gg]=this.values[gg]===0?0:-this.values[gg];return clone$1(this,{values:eg},!0)}removeZeros(){if(!this.isValid)return this;const eg=removeZeroes(this.values);return clone$1(this,{values:eg},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(eg){if(!this.isValid||!eg.isValid||!this.loc.equals(eg.loc))return!1;function gg(ig,ng){return ig===void 0||ig===0?ng===void 0||ng===0:ig===ng}for(const ig of orderedUnits$1)if(!gg(this.values[ig],eg.values[ig]))return!1;return!0}}const INVALID$1="Invalid Interval";function validateStartEnd(tg,eg){return!tg||!tg.isValid?Interval.invalid("missing or invalid start"):!eg||!eg.isValid?Interval.invalid("missing or invalid end"):eg<tg?Interval.invalid("end before start",`The end of an interval must be after its start, but you had start=${tg.toISO()} and end=${eg.toISO()}`):null}class Interval{constructor(eg){this.s=eg.start,this.e=eg.end,this.invalid=eg.invalid||null,this.isLuxonInterval=!0}static invalid(eg,gg=null){if(!eg)throw new InvalidArgumentError("need to specify a reason the Interval is invalid");const ig=eg instanceof Invalid?eg:new Invalid(eg,gg);if(Settings.throwOnInvalid)throw new InvalidIntervalError(ig);return new Interval({invalid:ig})}static fromDateTimes(eg,gg){const ig=friendlyDateTime(eg),ng=friendlyDateTime(gg),og=validateStartEnd(ig,ng);return og??new Interval({start:ig,end:ng})}static after(eg,gg){const ig=Duration.fromDurationLike(gg),ng=friendlyDateTime(eg);return Interval.fromDateTimes(ng,ng.plus(ig))}static before(eg,gg){const ig=Duration.fromDurationLike(gg),ng=friendlyDateTime(eg);return Interval.fromDateTimes(ng.minus(ig),ng)}static fromISO(eg,gg){const[ig,ng]=(eg||"").split("/",2);if(ig&&ng){let og,ag;try{og=DateTime.fromISO(ig,gg),ag=og.isValid}catch{ag=!1}let sg,Ig;try{sg=DateTime.fromISO(ng,gg),Ig=sg.isValid}catch{Ig=!1}if(ag&&Ig)return Interval.fromDateTimes(og,sg);if(ag){const Cg=Duration.fromISO(ng,gg);if(Cg.isValid)return Interval.after(og,Cg)}else if(Ig){const Cg=Duration.fromISO(ig,gg);if(Cg.isValid)return Interval.before(sg,Cg)}}return Interval.invalid("unparsable",`the input "${eg}" can't be parsed as ISO 8601`)}static isInterval(eg){return eg&&eg.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(eg="milliseconds"){return this.isValid?this.toDuration(eg).get(eg):NaN}count(eg="milliseconds",gg){if(!this.isValid)return NaN;const ig=this.start.startOf(eg,gg);let ng;return gg!=null&&gg.useLocaleWeeks?ng=this.end.reconfigure({locale:ig.locale}):ng=this.end,ng=ng.startOf(eg,gg),Math.floor(ng.diff(ig,eg).get(eg))+(ng.valueOf()!==this.end.valueOf())}hasSame(eg){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,eg):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(eg){return this.isValid?this.s>eg:!1}isBefore(eg){return this.isValid?this.e<=eg:!1}contains(eg){return this.isValid?this.s<=eg&&this.e>eg:!1}set({start:eg,end:gg}={}){return this.isValid?Interval.fromDateTimes(eg||this.s,gg||this.e):this}splitAt(...eg){if(!this.isValid)return[];const gg=eg.map(friendlyDateTime).filter(ag=>this.contains(ag)).sort((ag,sg)=>ag.toMillis()-sg.toMillis()),ig=[];let{s:ng}=this,og=0;for(;ng<this.e;){const ag=gg[og]||this.e,sg=+ag>+this.e?this.e:ag;ig.push(Interval.fromDateTimes(ng,sg)),ng=sg,og+=1}return ig}splitBy(eg){const gg=Duration.fromDurationLike(eg);if(!this.isValid||!gg.isValid||gg.as("milliseconds")===0)return[];let{s:ig}=this,ng=1,og;const ag=[];for(;ig<this.e;){const sg=this.start.plus(gg.mapUnits(Ig=>Ig*ng));og=+sg>+this.e?this.e:sg,ag.push(Interval.fromDateTimes(ig,og)),ig=og,ng+=1}return ag}divideEqually(eg){return this.isValid?this.splitBy(this.length()/eg).slice(0,eg):[]}overlaps(eg){return this.e>eg.s&&this.s<eg.e}abutsStart(eg){return this.isValid?+this.e==+eg.s:!1}abutsEnd(eg){return this.isValid?+eg.e==+this.s:!1}engulfs(eg){return this.isValid?this.s<=eg.s&&this.e>=eg.e:!1}equals(eg){return!this.isValid||!eg.isValid?!1:this.s.equals(eg.s)&&this.e.equals(eg.e)}intersection(eg){if(!this.isValid)return this;const gg=this.s>eg.s?this.s:eg.s,ig=this.e<eg.e?this.e:eg.e;return gg>=ig?null:Interval.fromDateTimes(gg,ig)}union(eg){if(!this.isValid)return this;const gg=this.s<eg.s?this.s:eg.s,ig=this.e>eg.e?this.e:eg.e;return Interval.fromDateTimes(gg,ig)}static merge(eg){const[gg,ig]=eg.sort((ng,og)=>ng.s-og.s).reduce(([ng,og],ag)=>og?og.overlaps(ag)||og.abutsStart(ag)?[ng,og.union(ag)]:[ng.concat([og]),ag]:[ng,ag],[[],null]);return ig&&gg.push(ig),gg}static xor(eg){let gg=null,ig=0;const ng=[],og=eg.map(Ig=>[{time:Ig.s,type:"s"},{time:Ig.e,type:"e"}]),ag=Array.prototype.concat(...og),sg=ag.sort((Ig,Cg)=>Ig.time-Cg.time);for(const Ig of sg)ig+=Ig.type==="s"?1:-1,ig===1?gg=Ig.time:(gg&&+gg!=+Ig.time&&ng.push(Interval.fromDateTimes(gg,Ig.time)),gg=null);return Interval.merge(ng)}difference(...eg){return Interval.xor([this].concat(eg)).map(gg=>this.intersection(gg)).filter(gg=>gg&&!gg.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:INVALID$1}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(eg=DATE_SHORT,gg={}){return this.isValid?Formatter.create(this.s.loc.clone(gg),eg).formatInterval(this):INVALID$1}toISO(eg){return this.isValid?`${this.s.toISO(eg)}/${this.e.toISO(eg)}`:INVALID$1}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:INVALID$1}toISOTime(eg){return this.isValid?`${this.s.toISOTime(eg)}/${this.e.toISOTime(eg)}`:INVALID$1}toFormat(eg,{separator:gg=" – "}={}){return this.isValid?`${this.s.toFormat(eg)}${gg}${this.e.toFormat(eg)}`:INVALID$1}toDuration(eg,gg){return this.isValid?this.e.diff(this.s,eg,gg):Duration.invalid(this.invalidReason)}mapEndpoints(eg){return Interval.fromDateTimes(eg(this.s),eg(this.e))}}class Info{static hasDST(eg=Settings.defaultZone){const gg=DateTime.now().setZone(eg).set({month:12});return!eg.isUniversal&&gg.offset!==gg.set({month:6}).offset}static isValidIANAZone(eg){return IANAZone.isValidZone(eg)}static normalizeZone(eg){return normalizeZone(eg,Settings.defaultZone)}static getStartOfWeek({locale:eg=null,locObj:gg=null}={}){return(gg||Locale.create(eg)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:eg=null,locObj:gg=null}={}){return(gg||Locale.create(eg)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:eg=null,locObj:gg=null}={}){return(gg||Locale.create(eg)).getWeekendDays().slice()}static months(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null,outputCalendar:og="gregory"}={}){return(ng||Locale.create(gg,ig,og)).months(eg)}static monthsFormat(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null,outputCalendar:og="gregory"}={}){return(ng||Locale.create(gg,ig,og)).months(eg,!0)}static weekdays(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null}={}){return(ng||Locale.create(gg,ig,null)).weekdays(eg)}static weekdaysFormat(eg="long",{locale:gg=null,numberingSystem:ig=null,locObj:ng=null}={}){return(ng||Locale.create(gg,ig,null)).weekdays(eg,!0)}static meridiems({locale:eg=null}={}){return Locale.create(eg).meridiems()}static eras(eg="short",{locale:gg=null}={}){return Locale.create(gg,null,"gregory").eras(eg)}static features(){return{relative:hasRelative(),localeWeek:hasLocaleWeekInfo()}}}function dayDiff(tg,eg){const gg=ng=>ng.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),ig=gg(eg)-gg(tg);return Math.floor(Duration.fromMillis(ig).as("days"))}function highOrderDiffs(tg,eg,gg){const ig=[["years",(Ig,Cg)=>Cg.year-Ig.year],["quarters",(Ig,Cg)=>Cg.quarter-Ig.quarter+(Cg.year-Ig.year)*4],["months",(Ig,Cg)=>Cg.month-Ig.month+(Cg.year-Ig.year)*12],["weeks",(Ig,Cg)=>{const lg=dayDiff(Ig,Cg);return(lg-lg%7)/7}],["days",dayDiff]],ng={},og=tg;let ag,sg;for(const[Ig,Cg]of ig)gg.indexOf(Ig)>=0&&(ag=Ig,ng[Ig]=Cg(tg,eg),sg=og.plus(ng),sg>eg?(ng[Ig]--,tg=og.plus(ng),tg>eg&&(sg=tg,ng[Ig]--,tg=og.plus(ng))):tg=sg);return[tg,ng,sg,ag]}function diff(tg,eg,gg,ig){let[ng,og,ag,sg]=highOrderDiffs(tg,eg,gg);const Ig=eg-ng,Cg=gg.filter(Ag=>["hours","minutes","seconds","milliseconds"].indexOf(Ag)>=0);Cg.length===0&&(ag<eg&&(ag=ng.plus({[sg]:1})),ag!==ng&&(og[sg]=(og[sg]||0)+Ig/(ag-ng)));const lg=Duration.fromObject(og,ig);return Cg.length>0?Duration.fromMillis(Ig,ig).shiftTo(...Cg).plus(lg):lg}const MISSING_FTP="missing Intl.DateTimeFormat.formatToParts support";function intUnit(tg,eg=gg=>gg){return{regex:tg,deser:([gg])=>eg(parseDigits(gg))}}const NBSP=" ",spaceOrNBSP=`[ ${NBSP}]`,spaceOrNBSPRegExp=new RegExp(spaceOrNBSP,"g");function fixListRegex(tg){return tg.replace(/\./g,"\\.?").replace(spaceOrNBSPRegExp,spaceOrNBSP)}function stripInsensitivities(tg){return tg.replace(/\./g,"").replace(spaceOrNBSPRegExp," ").toLowerCase()}function oneOf(tg,eg){return tg===null?null:{regex:RegExp(tg.map(fixListRegex).join("|")),deser:([gg])=>tg.findIndex(ig=>stripInsensitivities(gg)===stripInsensitivities(ig))+eg}}function offset(tg,eg){return{regex:tg,deser:([,gg,ig])=>signedOffset(gg,ig),groups:eg}}function simple(tg){return{regex:tg,deser:([eg])=>eg}}function escapeToken(tg){return tg.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function unitForToken(tg,eg){const gg=digitRegex(eg),ig=digitRegex(eg,"{2}"),ng=digitRegex(eg,"{3}"),og=digitRegex(eg,"{4}"),ag=digitRegex(eg,"{6}"),sg=digitRegex(eg,"{1,2}"),Ig=digitRegex(eg,"{1,3}"),Cg=digitRegex(eg,"{1,6}"),lg=digitRegex(eg,"{1,9}"),Ag=digitRegex(eg,"{2,4}"),rg=digitRegex(eg,"{4,6}"),cg=hg=>({regex:RegExp(escapeToken(hg.val)),deser:([mg])=>mg,literal:!0}),dg=(hg=>{if(tg.literal)return cg(hg);switch(hg.val){case"G":return oneOf(eg.eras("short"),0);case"GG":return oneOf(eg.eras("long"),0);case"y":return intUnit(Cg);case"yy":return intUnit(Ag,untruncateYear);case"yyyy":return intUnit(og);case"yyyyy":return intUnit(rg);case"yyyyyy":return intUnit(ag);case"M":return intUnit(sg);case"MM":return intUnit(ig);case"MMM":return oneOf(eg.months("short",!0),1);case"MMMM":return oneOf(eg.months("long",!0),1);case"L":return intUnit(sg);case"LL":return intUnit(ig);case"LLL":return oneOf(eg.months("short",!1),1);case"LLLL":return oneOf(eg.months("long",!1),1);case"d":return intUnit(sg);case"dd":return intUnit(ig);case"o":return intUnit(Ig);case"ooo":return intUnit(ng);case"HH":return intUnit(ig);case"H":return intUnit(sg);case"hh":return intUnit(ig);case"h":return intUnit(sg);case"mm":return intUnit(ig);case"m":return intUnit(sg);case"q":return intUnit(sg);case"qq":return intUnit(ig);case"s":return intUnit(sg);case"ss":return intUnit(ig);case"S":return intUnit(Ig);case"SSS":return intUnit(ng);case"u":return simple(lg);case"uu":return simple(sg);case"uuu":return intUnit(gg);case"a":return oneOf(eg.meridiems(),0);case"kkkk":return intUnit(og);case"kk":return intUnit(Ag,untruncateYear);case"W":return intUnit(sg);case"WW":return intUnit(ig);case"E":case"c":return intUnit(gg);case"EEE":return oneOf(eg.weekdays("short",!1),1);case"EEEE":return oneOf(eg.weekdays("long",!1),1);case"ccc":return oneOf(eg.weekdays("short",!0),1);case"cccc":return oneOf(eg.weekdays("long",!0),1);case"Z":case"ZZ":return offset(new RegExp(`([+-]${sg.source})(?::(${ig.source}))?`),2);case"ZZZ":return offset(new RegExp(`([+-]${sg.source})(${ig.source})?`),2);case"z":return simple(/[a-z_+-/]{1,256}?/i);case" ":return simple(/[^\S\n\r]/);default:return cg(hg)}})(tg)||{invalidReason:MISSING_FTP};return dg.token=tg,dg}const partTypeStyleToTokenVal={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function tokenForPart(tg,eg,gg){const{type:ig,value:ng}=tg;if(ig==="literal"){const Ig=/^\s+$/.test(ng);return{literal:!Ig,val:Ig?" ":ng}}const og=eg[ig];let ag=ig;ig==="hour"&&(eg.hour12!=null?ag=eg.hour12?"hour12":"hour24":eg.hourCycle!=null?eg.hourCycle==="h11"||eg.hourCycle==="h12"?ag="hour12":ag="hour24":ag=gg.hour12?"hour12":"hour24");let sg=partTypeStyleToTokenVal[ag];if(typeof sg=="object"&&(sg=sg[og]),sg)return{literal:!1,val:sg}}function buildRegex(tg){return[`^${tg.map(gg=>gg.regex).reduce((gg,ig)=>`${gg}(${ig.source})`,"")}$`,tg]}function match(tg,eg,gg){const ig=tg.match(eg);if(ig){const ng={};let og=1;for(const ag in gg)if(hasOwnProperty(gg,ag)){const sg=gg[ag],Ig=sg.groups?sg.groups+1:1;!sg.literal&&sg.token&&(ng[sg.token.val[0]]=sg.deser(ig.slice(og,og+Ig))),og+=Ig}return[ig,ng]}else return[ig,{}]}function dateTimeFromMatches(tg){const eg=og=>{switch(og){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let gg=null,ig;return isUndefined$1(tg.z)||(gg=IANAZone.create(tg.z)),isUndefined$1(tg.Z)||(gg||(gg=new FixedOffsetZone(tg.Z)),ig=tg.Z),isUndefined$1(tg.q)||(tg.M=(tg.q-1)*3+1),isUndefined$1(tg.h)||(tg.h<12&&tg.a===1?tg.h+=12:tg.h===12&&tg.a===0&&(tg.h=0)),tg.G===0&&tg.y&&(tg.y=-tg.y),isUndefined$1(tg.u)||(tg.S=parseMillis(tg.u)),[Object.keys(tg).reduce((og,ag)=>{const sg=eg(ag);return sg&&(og[sg]=tg[ag]),og},{}),gg,ig]}let dummyDateTimeCache=null;function getDummyDateTime(){return dummyDateTimeCache||(dummyDateTimeCache=DateTime.fromMillis(1555555555555)),dummyDateTimeCache}function maybeExpandMacroToken(tg,eg){if(tg.literal)return tg;const gg=Formatter.macroTokenToFormatOpts(tg.val),ig=formatOptsToTokens(gg,eg);return ig==null||ig.includes(void 0)?tg:ig}function expandMacroTokens(tg,eg){return Array.prototype.concat(...tg.map(gg=>maybeExpandMacroToken(gg,eg)))}class TokenParser{constructor(eg,gg){if(this.locale=eg,this.format=gg,this.tokens=expandMacroTokens(Formatter.parseFormat(gg),eg),this.units=this.tokens.map(ig=>unitForToken(ig,eg)),this.disqualifyingUnit=this.units.find(ig=>ig.invalidReason),!this.disqualifyingUnit){const[ig,ng]=buildRegex(this.units);this.regex=RegExp(ig,"i"),this.handlers=ng}}explainFromTokens(eg){if(this.isValid){const[gg,ig]=match(eg,this.regex,this.handlers),[ng,og,ag]=ig?dateTimeFromMatches(ig):[null,null,void 0];if(hasOwnProperty(ig,"a")&&hasOwnProperty(ig,"H"))throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");return{input:eg,tokens:this.tokens,regex:this.regex,rawMatches:gg,matches:ig,result:ng,zone:og,specificOffset:ag}}else return{input:eg,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function explainFromTokens(tg,eg,gg){return new TokenParser(tg,gg).explainFromTokens(eg)}function parseFromTokens(tg,eg,gg){const{result:ig,zone:ng,specificOffset:og,invalidReason:ag}=explainFromTokens(tg,eg,gg);return[ig,ng,og,ag]}function formatOptsToTokens(tg,eg){if(!tg)return null;const ig=Formatter.create(eg,tg).dtFormatter(getDummyDateTime()),ng=ig.formatToParts(),og=ig.resolvedOptions();return ng.map(ag=>tokenForPart(ag,tg,og))}const INVALID="Invalid DateTime",MAX_DATE=864e13;function unsupportedZone(tg){return new Invalid("unsupported zone",`the zone "${tg.name}" is not supported`)}function possiblyCachedWeekData(tg){return tg.weekData===null&&(tg.weekData=gregorianToWeek(tg.c)),tg.weekData}function possiblyCachedLocalWeekData(tg){return tg.localWeekData===null&&(tg.localWeekData=gregorianToWeek(tg.c,tg.loc.getMinDaysInFirstWeek(),tg.loc.getStartOfWeek())),tg.localWeekData}function clone(tg,eg){const gg={ts:tg.ts,zone:tg.zone,c:tg.c,o:tg.o,loc:tg.loc,invalid:tg.invalid};return new DateTime({...gg,...eg,old:gg})}function fixOffset(tg,eg,gg){let ig=tg-eg*60*1e3;const ng=gg.offset(ig);if(eg===ng)return[ig,eg];ig-=(ng-eg)*60*1e3;const og=gg.offset(ig);return ng===og?[ig,ng]:[tg-Math.min(ng,og)*60*1e3,Math.max(ng,og)]}function tsToObj(tg,eg){tg+=eg*60*1e3;const gg=new Date(tg);return{year:gg.getUTCFullYear(),month:gg.getUTCMonth()+1,day:gg.getUTCDate(),hour:gg.getUTCHours(),minute:gg.getUTCMinutes(),second:gg.getUTCSeconds(),millisecond:gg.getUTCMilliseconds()}}function objToTS(tg,eg,gg){return fixOffset(objToLocalTS(tg),eg,gg)}function adjustTime(tg,eg){const gg=tg.o,ig=tg.c.year+Math.trunc(eg.years),ng=tg.c.month+Math.trunc(eg.months)+Math.trunc(eg.quarters)*3,og={...tg.c,year:ig,month:ng,day:Math.min(tg.c.day,daysInMonth(ig,ng))+Math.trunc(eg.days)+Math.trunc(eg.weeks)*7},ag=Duration.fromObject({years:eg.years-Math.trunc(eg.years),quarters:eg.quarters-Math.trunc(eg.quarters),months:eg.months-Math.trunc(eg.months),weeks:eg.weeks-Math.trunc(eg.weeks),days:eg.days-Math.trunc(eg.days),hours:eg.hours,minutes:eg.minutes,seconds:eg.seconds,milliseconds:eg.milliseconds}).as("milliseconds"),sg=objToLocalTS(og);let[Ig,Cg]=fixOffset(sg,gg,tg.zone);return ag!==0&&(Ig+=ag,Cg=tg.zone.offset(Ig)),{ts:Ig,o:Cg}}function parseDataToDateTime(tg,eg,gg,ig,ng,og){const{setZone:ag,zone:sg}=gg;if(tg&&Object.keys(tg).length!==0||eg){const Ig=eg||sg,Cg=DateTime.fromObject(tg,{...gg,zone:Ig,specificOffset:og});return ag?Cg:Cg.setZone(sg)}else return DateTime.invalid(new Invalid("unparsable",`the input "${ng}" can't be parsed as ${ig}`))}function toTechFormat(tg,eg,gg=!0){return tg.isValid?Formatter.create(Locale.create("en-US"),{allowZ:gg,forceSimple:!0}).formatDateTimeFromString(tg,eg):null}function toISODate(tg,eg,gg){const ig=tg.c.year>9999||tg.c.year<0;let ng="";if(ig&&tg.c.year>=0&&(ng+="+"),ng+=padStart(tg.c.year,ig?6:4),gg==="year")return ng;if(eg){if(ng+="-",ng+=padStart(tg.c.month),gg==="month")return ng;ng+="-"}else if(ng+=padStart(tg.c.month),gg==="month")return ng;return ng+=padStart(tg.c.day),ng}function toISOTime(tg,eg,gg,ig,ng,og,ag){let sg=!gg||tg.c.millisecond!==0||tg.c.second!==0,Ig="";switch(ag){case"day":case"month":case"year":break;default:if(Ig+=padStart(tg.c.hour),ag==="hour")break;if(eg){if(Ig+=":",Ig+=padStart(tg.c.minute),ag==="minute")break;sg&&(Ig+=":",Ig+=padStart(tg.c.second))}else{if(Ig+=padStart(tg.c.minute),ag==="minute")break;sg&&(Ig+=padStart(tg.c.second))}if(ag==="second")break;sg&&(!ig||tg.c.millisecond!==0)&&(Ig+=".",Ig+=padStart(tg.c.millisecond,3))}return ng&&(tg.isOffsetFixed&&tg.offset===0&&!og?Ig+="Z":tg.o<0?(Ig+="-",Ig+=padStart(Math.trunc(-tg.o/60)),Ig+=":",Ig+=padStart(Math.trunc(-tg.o%60))):(Ig+="+",Ig+=padStart(Math.trunc(tg.o/60)),Ig+=":",Ig+=padStart(Math.trunc(tg.o%60)))),og&&(Ig+="["+tg.zone.ianaName+"]"),Ig}const defaultUnitValues={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},defaultWeekUnitValues={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},defaultOrdinalUnitValues={ordinal:1,hour:0,minute:0,second:0,millisecond:0},orderedUnits=["year","month","day","hour","minute","second","millisecond"],orderedWeekUnits=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],orderedOrdinalUnits=["year","ordinal","hour","minute","second","millisecond"];function normalizeUnit(tg){const eg={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[tg.toLowerCase()];if(!eg)throw new InvalidUnitError(tg);return eg}function normalizeUnitWithLocalWeeks(tg){switch(tg.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return normalizeUnit(tg)}}function guessOffsetForZone(tg){if(zoneOffsetTs===void 0&&(zoneOffsetTs=Settings.now()),tg.type!=="iana")return tg.offset(zoneOffsetTs);const eg=tg.name;let gg=zoneOffsetGuessCache.get(eg);return gg===void 0&&(gg=tg.offset(zoneOffsetTs),zoneOffsetGuessCache.set(eg,gg)),gg}function quickDT(tg,eg){const gg=normalizeZone(eg.zone,Settings.defaultZone);if(!gg.isValid)return DateTime.invalid(unsupportedZone(gg));const ig=Locale.fromObject(eg);let ng,og;if(isUndefined$1(tg.year))ng=Settings.now();else{for(const Ig of orderedUnits)isUndefined$1(tg[Ig])&&(tg[Ig]=defaultUnitValues[Ig]);const ag=hasInvalidGregorianData(tg)||hasInvalidTimeData(tg);if(ag)return DateTime.invalid(ag);const sg=guessOffsetForZone(gg);[ng,og]=objToTS(tg,sg,gg)}return new DateTime({ts:ng,zone:gg,loc:ig,o:og})}function diffRelative(tg,eg,gg){const ig=isUndefined$1(gg.round)?!0:gg.round,ng=isUndefined$1(gg.rounding)?"trunc":gg.rounding,og=(sg,Ig)=>(sg=roundTo(sg,ig||gg.calendary?0:2,gg.calendary?"round":ng),eg.loc.clone(gg).relFormatter(gg).format(sg,Ig)),ag=sg=>gg.calendary?eg.hasSame(tg,sg)?0:eg.startOf(sg).diff(tg.startOf(sg),sg).get(sg):eg.diff(tg,sg).get(sg);if(gg.unit)return og(ag(gg.unit),gg.unit);for(const sg of gg.units){const Ig=ag(sg);if(Math.abs(Ig)>=1)return og(Ig,sg)}return og(tg>eg?-0:0,gg.units[gg.units.length-1])}function lastOpts(tg){let eg={},gg;return tg.length>0&&typeof tg[tg.length-1]=="object"?(eg=tg[tg.length-1],gg=Array.from(tg).slice(0,tg.length-1)):gg=Array.from(tg),[eg,gg]}let zoneOffsetTs;const zoneOffsetGuessCache=new Map;class DateTime{constructor(eg){const gg=eg.zone||Settings.defaultZone;let ig=eg.invalid||(Number.isNaN(eg.ts)?new Invalid("invalid input"):null)||(gg.isValid?null:unsupportedZone(gg));this.ts=isUndefined$1(eg.ts)?Settings.now():eg.ts;let ng=null,og=null;if(!ig)if(eg.old&&eg.old.ts===this.ts&&eg.old.zone.equals(gg))[ng,og]=[eg.old.c,eg.old.o];else{const sg=isNumber$1(eg.o)&&!eg.old?eg.o:gg.offset(this.ts);ng=tsToObj(this.ts,sg),ig=Number.isNaN(ng.year)?new Invalid("invalid input"):null,ng=ig?null:ng,og=ig?null:sg}this._zone=gg,this.loc=eg.loc||Locale.create(),this.invalid=ig,this.weekData=null,this.localWeekData=null,this.c=ng,this.o=og,this.isLuxonDateTime=!0}static now(){return new DateTime({})}static local(){const[eg,gg]=lastOpts(arguments),[ig,ng,og,ag,sg,Ig,Cg]=gg;return quickDT({year:ig,month:ng,day:og,hour:ag,minute:sg,second:Ig,millisecond:Cg},eg)}static utc(){const[eg,gg]=lastOpts(arguments),[ig,ng,og,ag,sg,Ig,Cg]=gg;return eg.zone=FixedOffsetZone.utcInstance,quickDT({year:ig,month:ng,day:og,hour:ag,minute:sg,second:Ig,millisecond:Cg},eg)}static fromJSDate(eg,gg={}){const ig=isDate$1(eg)?eg.valueOf():NaN;if(Number.isNaN(ig))return DateTime.invalid("invalid input");const ng=normalizeZone(gg.zone,Settings.defaultZone);return ng.isValid?new DateTime({ts:ig,zone:ng,loc:Locale.fromObject(gg)}):DateTime.invalid(unsupportedZone(ng))}static fromMillis(eg,gg={}){if(isNumber$1(eg))return eg<-MAX_DATE||eg>MAX_DATE?DateTime.invalid("Timestamp out of range"):new DateTime({ts:eg,zone:normalizeZone(gg.zone,Settings.defaultZone),loc:Locale.fromObject(gg)});throw new InvalidArgumentError(`fromMillis requires a numerical input, but received a ${typeof eg} with value ${eg}`)}static fromSeconds(eg,gg={}){if(isNumber$1(eg))return new DateTime({ts:eg*1e3,zone:normalizeZone(gg.zone,Settings.defaultZone),loc:Locale.fromObject(gg)});throw new InvalidArgumentError("fromSeconds requires a numerical input")}static fromObject(eg,gg={}){eg=eg||{};const ig=normalizeZone(gg.zone,Settings.defaultZone);if(!ig.isValid)return DateTime.invalid(unsupportedZone(ig));const ng=Locale.fromObject(gg),og=normalizeObject(eg,normalizeUnitWithLocalWeeks),{minDaysInFirstWeek:ag,startOfWeek:sg}=usesLocalWeekValues(og,ng),Ig=Settings.now(),Cg=isUndefined$1(gg.specificOffset)?ig.offset(Ig):gg.specificOffset,lg=!isUndefined$1(og.ordinal),Ag=!isUndefined$1(og.year),rg=!isUndefined$1(og.month)||!isUndefined$1(og.day),cg=Ag||rg,ug=og.weekYear||og.weekNumber;if((cg||lg)&&ug)throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(rg&&lg)throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");const dg=ug||og.weekday&&!cg;let hg,mg,bg=tsToObj(Ig,Cg);dg?(hg=orderedWeekUnits,mg=defaultWeekUnitValues,bg=gregorianToWeek(bg,ag,sg)):lg?(hg=orderedOrdinalUnits,mg=defaultOrdinalUnitValues,bg=gregorianToOrdinal(bg)):(hg=orderedUnits,mg=defaultUnitValues);let pg=!1;for(const Wg of hg){const yg=og[Wg];isUndefined$1(yg)?pg?og[Wg]=mg[Wg]:og[Wg]=bg[Wg]:pg=!0}const fg=dg?hasInvalidWeekData(og,ag,sg):lg?hasInvalidOrdinalData(og):hasInvalidGregorianData(og),wg=fg||hasInvalidTimeData(og);if(wg)return DateTime.invalid(wg);const Gg=dg?weekToGregorian(og,ag,sg):lg?ordinalToGregorian(og):og,[Zg,$g]=objToTS(Gg,Cg,ig),Bg=new DateTime({ts:Zg,zone:ig,o:$g,loc:ng});return og.weekday&&cg&&eg.weekday!==Bg.weekday?DateTime.invalid("mismatched weekday",`you can't specify both a weekday of ${og.weekday} and a date of ${Bg.toISO()}`):Bg.isValid?Bg:DateTime.invalid(Bg.invalid)}static fromISO(eg,gg={}){const[ig,ng]=parseISODate(eg);return parseDataToDateTime(ig,ng,gg,"ISO 8601",eg)}static fromRFC2822(eg,gg={}){const[ig,ng]=parseRFC2822Date(eg);return parseDataToDateTime(ig,ng,gg,"RFC 2822",eg)}static fromHTTP(eg,gg={}){const[ig,ng]=parseHTTPDate(eg);return parseDataToDateTime(ig,ng,gg,"HTTP",gg)}static fromFormat(eg,gg,ig={}){if(isUndefined$1(eg)||isUndefined$1(gg))throw new InvalidArgumentError("fromFormat requires an input string and a format");const{locale:ng=null,numberingSystem:og=null}=ig,ag=Locale.fromOpts({locale:ng,numberingSystem:og,defaultToEN:!0}),[sg,Ig,Cg,lg]=parseFromTokens(ag,eg,gg);return lg?DateTime.invalid(lg):parseDataToDateTime(sg,Ig,ig,`format ${gg}`,eg,Cg)}static fromString(eg,gg,ig={}){return DateTime.fromFormat(eg,gg,ig)}static fromSQL(eg,gg={}){const[ig,ng]=parseSQL(eg);return parseDataToDateTime(ig,ng,gg,"SQL",eg)}static invalid(eg,gg=null){if(!eg)throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");const ig=eg instanceof Invalid?eg:new Invalid(eg,gg);if(Settings.throwOnInvalid)throw new InvalidDateTimeError(ig);return new DateTime({invalid:ig})}static isDateTime(eg){return eg&&eg.isLuxonDateTime||!1}static parseFormatForOpts(eg,gg={}){const ig=formatOptsToTokens(eg,Locale.fromObject(gg));return ig?ig.map(ng=>ng?ng.val:null).join(""):null}static expandFormat(eg,gg={}){return expandMacroTokens(Formatter.parseFormat(eg),Locale.fromObject(gg)).map(ng=>ng.val).join("")}static resetCache(){zoneOffsetTs=void 0,zoneOffsetGuessCache.clear()}get(eg){return this[eg]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?possiblyCachedWeekData(this).weekYear:NaN}get weekNumber(){return this.isValid?possiblyCachedWeekData(this).weekNumber:NaN}get weekday(){return this.isValid?possiblyCachedWeekData(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?possiblyCachedLocalWeekData(this).weekday:NaN}get localWeekNumber(){return this.isValid?possiblyCachedLocalWeekData(this).weekNumber:NaN}get localWeekYear(){return this.isValid?possiblyCachedLocalWeekData(this).weekYear:NaN}get ordinal(){return this.isValid?gregorianToOrdinal(this.c).ordinal:NaN}get monthShort(){return this.isValid?Info.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Info.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Info.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Info.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const eg=864e5,gg=6e4,ig=objToLocalTS(this.c),ng=this.zone.offset(ig-eg),og=this.zone.offset(ig+eg),ag=this.zone.offset(ig-ng*gg),sg=this.zone.offset(ig-og*gg);if(ag===sg)return[this];const Ig=ig-ag*gg,Cg=ig-sg*gg,lg=tsToObj(Ig,ag),Ag=tsToObj(Cg,sg);return lg.hour===Ag.hour&&lg.minute===Ag.minute&&lg.second===Ag.second&&lg.millisecond===Ag.millisecond?[clone(this,{ts:Ig}),clone(this,{ts:Cg})]:[this]}get isInLeapYear(){return isLeapYear(this.year)}get daysInMonth(){return daysInMonth(this.year,this.month)}get daysInYear(){return this.isValid?daysInYear(this.year):NaN}get weeksInWeekYear(){return this.isValid?weeksInWeekYear(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?weeksInWeekYear(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(eg={}){const{locale:gg,numberingSystem:ig,calendar:ng}=Formatter.create(this.loc.clone(eg),eg).resolvedOptions(this);return{locale:gg,numberingSystem:ig,outputCalendar:ng}}toUTC(eg=0,gg={}){return this.setZone(FixedOffsetZone.instance(eg),gg)}toLocal(){return this.setZone(Settings.defaultZone)}setZone(eg,{keepLocalTime:gg=!1,keepCalendarTime:ig=!1}={}){if(eg=normalizeZone(eg,Settings.defaultZone),eg.equals(this.zone))return this;if(eg.isValid){let ng=this.ts;if(gg||ig){const og=eg.offset(this.ts),ag=this.toObject();[ng]=objToTS(ag,og,eg)}return clone(this,{ts:ng,zone:eg})}else return DateTime.invalid(unsupportedZone(eg))}reconfigure({locale:eg,numberingSystem:gg,outputCalendar:ig}={}){const ng=this.loc.clone({locale:eg,numberingSystem:gg,outputCalendar:ig});return clone(this,{loc:ng})}setLocale(eg){return this.reconfigure({locale:eg})}set(eg){if(!this.isValid)return this;const gg=normalizeObject(eg,normalizeUnitWithLocalWeeks),{minDaysInFirstWeek:ig,startOfWeek:ng}=usesLocalWeekValues(gg,this.loc),og=!isUndefined$1(gg.weekYear)||!isUndefined$1(gg.weekNumber)||!isUndefined$1(gg.weekday),ag=!isUndefined$1(gg.ordinal),sg=!isUndefined$1(gg.year),Ig=!isUndefined$1(gg.month)||!isUndefined$1(gg.day),Cg=sg||Ig,lg=gg.weekYear||gg.weekNumber;if((Cg||ag)&&lg)throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(Ig&&ag)throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");let Ag;og?Ag=weekToGregorian({...gregorianToWeek(this.c,ig,ng),...gg},ig,ng):isUndefined$1(gg.ordinal)?(Ag={...this.toObject(),...gg},isUndefined$1(gg.day)&&(Ag.day=Math.min(daysInMonth(Ag.year,Ag.month),Ag.day))):Ag=ordinalToGregorian({...gregorianToOrdinal(this.c),...gg});const[rg,cg]=objToTS(Ag,this.o,this.zone);return clone(this,{ts:rg,o:cg})}plus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg);return clone(this,adjustTime(this,gg))}minus(eg){if(!this.isValid)return this;const gg=Duration.fromDurationLike(eg).negate();return clone(this,adjustTime(this,gg))}startOf(eg,{useLocaleWeeks:gg=!1}={}){if(!this.isValid)return this;const ig={},ng=Duration.normalizeUnit(eg);switch(ng){case"years":ig.month=1;case"quarters":case"months":ig.day=1;case"weeks":case"days":ig.hour=0;case"hours":ig.minute=0;case"minutes":ig.second=0;case"seconds":ig.millisecond=0;break}if(ng==="weeks")if(gg){const og=this.loc.getStartOfWeek(),{weekday:ag}=this;ag<og&&(ig.weekNumber=this.weekNumber-1),ig.weekday=og}else ig.weekday=1;if(ng==="quarters"){const og=Math.ceil(this.month/3);ig.month=(og-1)*3+1}return this.set(ig)}endOf(eg,gg){return this.isValid?this.plus({[eg]:1}).startOf(eg,gg).minus(1):this}toFormat(eg,gg={}){return this.isValid?Formatter.create(this.loc.redefaultToEN(gg)).formatDateTimeFromString(this,eg):INVALID}toLocaleString(eg=DATE_SHORT,gg={}){return this.isValid?Formatter.create(this.loc.clone(gg),eg).formatDateTime(this):INVALID}toLocaleParts(eg={}){return this.isValid?Formatter.create(this.loc.clone(eg),eg).formatDateTimeParts(this):[]}toISO({format:eg="extended",suppressSeconds:gg=!1,suppressMilliseconds:ig=!1,includeOffset:ng=!0,extendedZone:og=!1,precision:ag="milliseconds"}={}){if(!this.isValid)return null;ag=normalizeUnit(ag);const sg=eg==="extended";let Ig=toISODate(this,sg,ag);return orderedUnits.indexOf(ag)>=3&&(Ig+="T"),Ig+=toISOTime(this,sg,gg,ig,ng,og,ag),Ig}toISODate({format:eg="extended",precision:gg="day"}={}){return this.isValid?toISODate(this,eg==="extended",normalizeUnit(gg)):null}toISOWeekDate(){return toTechFormat(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:eg=!1,suppressSeconds:gg=!1,includeOffset:ig=!0,includePrefix:ng=!1,extendedZone:og=!1,format:ag="extended",precision:sg="milliseconds"}={}){return this.isValid?(sg=normalizeUnit(sg),(ng&&orderedUnits.indexOf(sg)>=3?"T":"")+toISOTime(this,ag==="extended",gg,eg,ig,og,sg)):null}toRFC2822(){return toTechFormat(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return toTechFormat(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?toISODate(this,!0):null}toSQLTime({includeOffset:eg=!0,includeZone:gg=!1,includeOffsetSpace:ig=!0}={}){let ng="HH:mm:ss.SSS";return(gg||eg)&&(ig&&(ng+=" "),gg?ng+="z":eg&&(ng+="ZZ")),toTechFormat(this,ng,!0)}toSQL(eg={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(eg)}`:null}toString(){return this.isValid?this.toISO():INVALID}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(eg={}){if(!this.isValid)return{};const gg={...this.c};return eg.includeConfig&&(gg.outputCalendar=this.outputCalendar,gg.numberingSystem=this.loc.numberingSystem,gg.locale=this.loc.locale),gg}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(eg,gg="milliseconds",ig={}){if(!this.isValid||!eg.isValid)return Duration.invalid("created by diffing an invalid DateTime");const ng={locale:this.locale,numberingSystem:this.numberingSystem,...ig},og=maybeArray(gg).map(Duration.normalizeUnit),ag=eg.valueOf()>this.valueOf(),sg=ag?this:eg,Ig=ag?eg:this,Cg=diff(sg,Ig,og,ng);return ag?Cg.negate():Cg}diffNow(eg="milliseconds",gg={}){return this.diff(DateTime.now(),eg,gg)}until(eg){return this.isValid?Interval.fromDateTimes(this,eg):this}hasSame(eg,gg,ig){if(!this.isValid)return!1;const ng=eg.valueOf(),og=this.setZone(eg.zone,{keepLocalTime:!0});return og.startOf(gg,ig)<=ng&&ng<=og.endOf(gg,ig)}equals(eg){return this.isValid&&eg.isValid&&this.valueOf()===eg.valueOf()&&this.zone.equals(eg.zone)&&this.loc.equals(eg.loc)}toRelative(eg={}){if(!this.isValid)return null;const gg=eg.base||DateTime.fromObject({},{zone:this.zone}),ig=eg.padding?this<gg?-eg.padding:eg.padding:0;let ng=["years","months","days","hours","minutes","seconds"],og=eg.unit;return Array.isArray(eg.unit)&&(ng=eg.unit,og=void 0),diffRelative(gg,this.plus(ig),{...eg,numeric:"always",units:ng,unit:og})}toRelativeCalendar(eg={}){return this.isValid?diffRelative(eg.base||DateTime.fromObject({},{zone:this.zone}),this,{...eg,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...eg){if(!eg.every(DateTime.isDateTime))throw new InvalidArgumentError("min requires all arguments be DateTimes");return bestBy(eg,gg=>gg.valueOf(),Math.min)}static max(...eg){if(!eg.every(DateTime.isDateTime))throw new InvalidArgumentError("max requires all arguments be DateTimes");return bestBy(eg,gg=>gg.valueOf(),Math.max)}static fromFormatExplain(eg,gg,ig={}){const{locale:ng=null,numberingSystem:og=null}=ig,ag=Locale.fromOpts({locale:ng,numberingSystem:og,defaultToEN:!0});return explainFromTokens(ag,eg,gg)}static fromStringExplain(eg,gg,ig={}){return DateTime.fromFormatExplain(eg,gg,ig)}static buildFormatParser(eg,gg={}){const{locale:ig=null,numberingSystem:ng=null}=gg,og=Locale.fromOpts({locale:ig,numberingSystem:ng,defaultToEN:!0});return new TokenParser(og,eg)}static fromFormatParser(eg,gg,ig={}){if(isUndefined$1(eg)||isUndefined$1(gg))throw new InvalidArgumentError("fromFormatParser requires an input string and a format parser");const{locale:ng=null,numberingSystem:og=null}=ig,ag=Locale.fromOpts({locale:ng,numberingSystem:og,defaultToEN:!0});if(!ag.equals(gg.locale))throw new InvalidArgumentError(`fromFormatParser called with a locale of ${ag}, but the format parser was created for ${gg.locale}`);const{result:sg,zone:Ig,specificOffset:Cg,invalidReason:lg}=gg.explainFromTokens(eg);return lg?DateTime.invalid(lg):parseDataToDateTime(sg,Ig,ig,`format ${gg.format}`,eg,Cg)}static get DATE_SHORT(){return DATE_SHORT}static get DATE_MED(){return DATE_MED}static get DATE_MED_WITH_WEEKDAY(){return DATE_MED_WITH_WEEKDAY}static get DATE_FULL(){return DATE_FULL}static get DATE_HUGE(){return DATE_HUGE}static get TIME_SIMPLE(){return TIME_SIMPLE}static get TIME_WITH_SECONDS(){return TIME_WITH_SECONDS}static get TIME_WITH_SHORT_OFFSET(){return TIME_WITH_SHORT_OFFSET}static get TIME_WITH_LONG_OFFSET(){return TIME_WITH_LONG_OFFSET}static get TIME_24_SIMPLE(){return TIME_24_SIMPLE}static get TIME_24_WITH_SECONDS(){return TIME_24_WITH_SECONDS}static get TIME_24_WITH_SHORT_OFFSET(){return TIME_24_WITH_SHORT_OFFSET}static get TIME_24_WITH_LONG_OFFSET(){return TIME_24_WITH_LONG_OFFSET}static get DATETIME_SHORT(){return DATETIME_SHORT}static get DATETIME_SHORT_WITH_SECONDS(){return DATETIME_SHORT_WITH_SECONDS}static get DATETIME_MED(){return DATETIME_MED}static get DATETIME_MED_WITH_SECONDS(){return DATETIME_MED_WITH_SECONDS}static get DATETIME_MED_WITH_WEEKDAY(){return DATETIME_MED_WITH_WEEKDAY}static get DATETIME_FULL(){return DATETIME_FULL}static get DATETIME_FULL_WITH_SECONDS(){return DATETIME_FULL_WITH_SECONDS}static get DATETIME_HUGE(){return DATETIME_HUGE}static get DATETIME_HUGE_WITH_SECONDS(){return DATETIME_HUGE_WITH_SECONDS}}function friendlyDateTime(tg){if(DateTime.isDateTime(tg))return tg;if(tg&&tg.valueOf&&isNumber$1(tg.valueOf()))return DateTime.fromJSDate(tg);if(tg&&typeof tg=="object")return DateTime.fromObject(tg);throw new InvalidArgumentError(`Unknown datetime argument: ${tg}, of type ${typeof tg}`)}const WEEK_ZH=["一","二","三","四","五","六","日"],MONTH_ZH_NUM=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],MONTH_ZH_CN=["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];function formatDate(tg,{years:eg=0,months:gg=0,days:ig=0}={}){const ng=DateTime.now().plus({years:eg,months:gg,days:ig}).setLocale("zh-CN");let og=formatWithZhMonth(ng,tg),ag=ng.toFormat(og);return ag=formatWithZhWeekday(ng,ag),ag}function formatWithZhWeekday(tg,eg){const gg=WEEK_ZH[tg.weekday-1];return eg.replace(/dddd/g,`星期${gg}`).replace(/ddd/g,`周${gg}`)}function formatWithZhMonth(tg,eg){const gg=tg.month-1;return eg.replace(/MMMM/g,MONTH_ZH_CN[gg]).replace(/MMM/g,MONTH_ZH_NUM[gg])}function throttle$1(tg,eg=300){let gg=0;return function(...ig){const ng=Date.now();ng-gg>=eg&&(tg.apply(this,ig),gg=ng)}}function ptToPx$1(tg,eg=o.DPI){return tg*eg/72}function mitt(tg){return{all:tg=tg||new Map,on:function(eg,gg){var ig=tg.get(eg);ig?ig.push(gg):tg.set(eg,[gg])},off:function(eg,gg){var ig=tg.get(eg);ig&&(gg?ig.splice(ig.indexOf(gg)>>>0,1):tg.set(eg,[]))},emit:function(eg,gg){var ig=tg.get(eg);ig&&ig.slice().map(function(ng){ng(gg)}),(ig=tg.get("*"))&&ig.slice().map(function(ng){ng(eg,gg)})}}}const canvasEventBus=mitt();let allObjMap=new Proxy({},{get(tg,eg){return eg in tg?tg[eg]:[]},set(tg,eg,gg){return tg[eg]=gg,!0}});function clearObjectMap(){allObjMap=new Proxy({},{get(tg,eg){return eg in tg?tg[eg]:[]},set(tg,eg,gg){return tg[eg]=gg,!0}})}function updateObjectMap(tg){tg.type!=="group"&&tg.id!=="workspace"?!allObjMap[tg.type]||allObjMap[tg.type]&&allObjMap[tg.type].length===0?allObjMap[tg.type]=[tg]:allObjMap[tg.type].push(tg):tg._objects.forEach(eg=>updateObjectMap(eg))}function getAllObjectMap(tg=null,eg="get"){if(eg==="get"&&Object.keys(allObjMap).length)return allObjMap;{if(!tg)return allObjMap;clearObjectMap();const gg=ig=>{ig.type==="group"&&ig._objects?ig._objects.forEach(ng=>gg(ng)):ig.id!=="workspace"&&(!allObjMap[ig.type]||allObjMap[ig.type]&&allObjMap[ig.type].length===0?allObjMap[ig.type]=[ig]:allObjMap[ig.type].push(ig))};tg==null||tg.getObjects().forEach(ig=>gg(ig))}return allObjMap}function getObjectList(tg,eg){tg.type!=="group"&&tg.type!=="activeselection"?eg&&eg(tg):tg._objects.forEach(gg=>getObjectList(gg,eg))}function getCounterIncrement(tg){const eg=Number(tg.incremental);return Number.isFinite(eg)?Math.trunc(eg):0}function getCounterValueType(tg){return tg.valueType==="letter"?"letter":"number"}function normalizeLetterValue(tg){return String(tg??"").toUpperCase().replace(/[^A-Z]/g,"")||"A"}function letterValueToNumber(tg){return normalizeLetterValue(tg).split("").reduce((eg,gg)=>eg*26+gg.charCodeAt(0)-64,0)}function numberToLetterValue(tg){let eg=Math.max(1,Math.trunc(tg)),gg="";for(;eg>0;)eg--,gg=String.fromCharCode(65+eg%26)+gg,eg=Math.floor(eg/26);return gg}function formatCounterValue(tg){if(getCounterValueType(tg)==="letter"){const ig=normalizeLetterValue(tg.value);return tg.zeroPadding?ig.padStart(Math.max(0,tg.length),"0"):ig}let eg=String(tg.value??"");if(!tg.zeroPadding)return eg;let gg=Number(eg);return gg<0?(gg=Math.abs(gg),`-${gg.toString().padStart(tg.length,"0")}`):eg.padStart(tg.length,"0")}function getNextCounterValue(tg){const eg=getCounterIncrement(tg);if(getCounterValueType(tg)==="letter"){const ng=letterValueToNumber(normalizeLetterValue(tg.value))+eg;if(ng<1)return null;const og=numberToLetterValue(ng);return og.length<=tg.length?og:null}const gg=Number(tg.value);if(!Number.isFinite(gg))return null;const ig=gg+eg;return Math.abs(ig).toString().length<=tg.length?ig:null}const GS1_AI_TABLE={"00":{length:18,desc:"SSCC"},"01":{length:14,desc:"GTIN"},"02":{length:14,desc:"GTIN inside"},11:{length:6,desc:"生产日期"},12:{length:6,desc:"付款截止日"},13:{length:6,desc:"包装日期"},15:{length:6,desc:"最佳保质期"},16:{length:6,desc:"销售截止日"},17:{length:6,desc:"有效期"},18:{length:6,desc:"接收日期"},20:{length:2,desc:"产品变体"},410:{length:13,desc:"收货方GLN"},411:{length:13,desc:"付款方GLN"},412:{length:13,desc:"购方GLN"},413:{length:13,desc:"发货方GLN"},414:{length:13,desc:"交货方GLN"},415:{length:13,desc:"开票方GLN"},416:{length:13,desc:"生产/服务方GLN"},417:{length:13,desc:"参与方GLN"},7001:{length:13,desc:"NHS编号"},10:{variable:!0,max:20,desc:"批号"},21:{variable:!0,max:20,desc:"序列号"},22:{variable:!0,max:20,desc:"次级数据"},30:{variable:!0,max:8,desc:"数量(件)"},37:{variable:!0,max:8,desc:"物流单元数量"},400:{variable:!0,max:30,desc:"客户订单号"},401:{variable:!0,max:30,desc:"货物标识号"},402:{variable:!0,max:20,desc:"GSIN"},403:{variable:!0,max:30,desc:"路线代码"},420:{variable:!0,max:20,desc:"收货方邮编"},421:{variable:!0,max:20,desc:"收货方邮编(含ISO)"},7002:{variable:!0,max:30,desc:"CE标识"},7010:{variable:!0,max:30,desc:"医院编号"},8001:{variable:!0,max:14,desc:"卷材信息"},8002:{variable:!0,max:20,desc:"手机电子序列号"},8003:{variable:!0,max:30,desc:"全球可回收资产标识"},8004:{variable:!0,max:30,desc:"全球单个资产标识"},8005:{variable:!0,max:6,desc:"价格"},8006:{variable:!0,max:18,desc:"组件标识"},8007:{variable:!0,max:34,desc:"IBAN"},8008:{variable:!0,max:12,desc:"生产日期时间"},8010:{variable:!0,max:30,desc:"CPID"},8011:{variable:!0,max:30,desc:"CPID序列号"},8012:{variable:!0,max:20,desc:"软件版本"},8013:{variable:!0,max:30,desc:"型号"},8017:{variable:!0,max:18,desc:"GSRN"},8018:{variable:!0,max:18,desc:"GSRN-Provider"},8020:{variable:!0,max:25,desc:"支付单号"},8110:{variable:!0,max:70,desc:"优惠券扩展"},8200:{variable:!0,max:25,desc:"包裹编号"},90:{variable:!0,max:30,desc:"双方约定"},91:{variable:!0,max:90,desc:"双方约定"},92:{variable:!0,max:90,desc:"双方约定"},93:{variable:!0,max:90,desc:"双方约定"},94:{variable:!0,max:90,desc:"双方约定"},95:{variable:!0,max:90,desc:"双方约定"},96:{variable:!0,max:90,desc:"双方约定"},97:{variable:!0,max:90,desc:"双方约定"},98:{variable:!0,max:90,desc:"双方约定"},99:{variable:!0,max:90,desc:"双方约定"}};for(let tg=310;tg<=369;tg++)GS1_AI_TABLE[String(tg)]={length:6,desc:"量度值"};class GS1Parser{static getAIInfo(eg){return GS1_AI_TABLE[eg]||null}static matchAIPrefix(eg,gg){for(const ig of[4,3,2]){if(gg+ig>eg.length)continue;const ng=eg.slice(gg,gg+ig);if(GS1_AI_TABLE[ng])return{ai:ng,info:GS1_AI_TABLE[ng]}}return null}static parse(eg){const gg=/\((\d{2,4})\)/g;let ig;const ng=[];for(;(ig=gg.exec(eg))!==null;){if(ng.length>0){const og=ng[ng.length-1];og.data=eg.slice(og.dataStart,ig.index)}ng.push({ai:ig[1],dataStart:ig.index+ig[0].length})}return ng.length>0&&(ng[ng.length-1].data=eg.slice(ng[ng.length-1].dataStart)),ng.map(og=>({ai:og.ai,data:og.data??""}))}static calcCheckDigit(eg){const gg=String(eg).split("").map(Number);let ig=0;for(let ng=0;ng<gg.length;ng++){const og=(gg.length-ng)%2===1?3:1;ig+=gg[ng]*og}return(10-ig%10)%10}static normalizeGTIN(eg){let gg=String(eg).replace(/\D/g,"");if(gg.length===14)return gg;gg=gg.padStart(13,"0");const ig=this.calcCheckDigit(gg);return gg+ig}static format(eg){return Array.isArray(eg)?eg.map(({ai:gg,data:ig})=>`(${gg})${ig}`).join(""):eg}static process(eg){const gg=this.parse(eg);if(gg.length===0)throw new Error("GS1-128 data must include an Application Identifier, e.g. (01)...");return gg.map(({ai:ig,data:ng})=>{if(this.getAIInfo(ig),ig==="01"||ig==="02")return{ai:ig,data:this.normalizeGTIN(ng)};if(ig==="00"){const og=String(ng).padStart(17,"0"),ag=this.calcCheckDigit(og);return{ai:ig,data:og+ag}}if(ig>="410"&&ig<="417"){const og=String(ng).padStart(12,"0"),ag=this.calcCheckDigit(og);return{ai:ig,data:og+ag}}return{ai:ig,data:ng}})}}function withObjectStrokeDash(tg,eg,gg){const ig=tg.getLineDash(),ng=tg.lineDashOffset,og=eg.strokeDashArray;tg.setLineDash(Array.isArray(og)&&og.length?og:[]),tg.lineDashOffset=eg.strokeDashOffset||0;try{gg()}finally{tg.setLineDash(ig),tg.lineDashOffset=ng}}function getBarcodeRenderWidth(tg,eg){if(eg>tg)return eg;const gg=Math.round(tg/eg)||1;return eg*gg}const iC=class iC extends ji{constructor(eg,gg){super(gg),this.hasFireChange=!1,this.minScaleLimit=.1,this.orginTextWidth=0,this.orginTextgaps=2,this.orginTextSize=0,this.orginTextHeight=0,this.lockScalingFlip=!0,this.objectCaching=!1,this._scaleAnchor=void 0,this.counterProps=null,this.reviewValueArgs=null,this.barcodeDateFormatType="",this.increaseDate=!1,this.concatTextIdListObj=null,this.connectObjIds=[],this.stretchMode="scale",this.barcodeTextHeight=0,this.barcodeTextGap=5,this._textLayoutInitialized=!1,this._lastTextAreaHeight=0,this._cache={canvas:void 0,error:void 0,update:!0},this.increaseDate=gg&&gg.increaseDate?gg.increaseDate:this.increaseDate,this.barcodeDateFormatType=gg&&gg.barcodeDateFormatType?gg.barcodeDateFormatType:this.barcodeDateFormatType,this.counterProps=gg&&gg.counterProps?gg.counterProps:this.counterProps,this.stretchMode=gg&&gg.stretchMode?gg.stretchMode:this.stretchMode,this.barcodeTextGap=gg&&gg.barcodeTextGap!=null?gg.barcodeTextGap:this.barcodeTextGap,this.barcodeOptions=cloneDeep(eg),this.barcodeOptions.textsize=eg.textsize||14,this.barcodeOptions.textposition=eg.includetext?eg.textposition||"bottom":void 0,this.barcodeOptions.textfontname=eg.textfontname||"Arial",this.set({width:this.width||1,height:this.height||80}),this.barcodeBaseWidth=this.width,this.on("scaling",ig=>{const ng=ig.transform;if(!ng)return;const og=ng.corner,ag=["ml","tl","bl"].includes(og),sg=["mr","tr","br"].includes(og),Ig=["mt","tl","tr"].includes(og),Cg=["mb","bl","br"].includes(og);if(!this._scaleAnchor){const dg=ag?"right":sg?"left":"center",hg=Ig?"bottom":Cg?"top":"center",mg=this.getPointByOrigin(dg,hg);this._scaleAnchor={p:mg,ox:dg,oy:hg}}const lg=Math.max(1,this.width*this.scaleX),Ag=Math.max(1,this.height*this.scaleY);this.width=lg,this.height=Ag,this.scaleX=1,this.scaleY=1,this.barcodeBaseWidth=this.width;const{p:rg,ox:cg,oy:ug}=this._scaleAnchor;if(this.group){const dg=kn.invertTransform(this.group.calcTransformMatrix()),hg=kn.transformPoint(rg,dg);this.setPositionByOrigin(hg,cg,ug)}else this.setPositionByOrigin(rg,cg,ug);this.setCoords()}),this.on("modified",()=>{this._scaleAnchor=void 0}),this.concatTextIdListObj=gg.concatTextIdListObj??this.concatTextIdListObj,this.connectObjIds=gg.connectObjIds??this.connectObjIds,canvasEventBus.off(`update:barcode:${this.id}`),canvasEventBus.on(`update:barcode:${this.id}`,async({list:ig,callback:ng=function(){}}={})=>{let og=await this.updateBarCode2d(ig);ng&&ng(og)})}cropBuiltInText(eg,gg){const ig=eg.getContext("2d");if(!ig)return;const ng=gg.height?Number(gg.height)/25.4:1,og=Number(gg.scale)||2,ag=Math.min(Math.round(ng*72*og)+1,eg.height-1);ag>=eg.height||ig.clearRect(0,ag,eg.width,eg.height-ag)}measureText(eg,gg,ig){if(gg.textposition&&gg.textposition!=="none"&&gg.textsize){eg.font=`${gg.textsize}px ${gg.textfontname}`,gg.textgaps&&(eg.letterSpacing=gg.textgaps+"px");const ng=eg.measureText(gg.text);ig.textWidth=ng.actualBoundingBoxRight-ng.actualBoundingBoxLeft,ig.textHeight=ng.fontBoundingBoxAscent+ng.fontBoundingBoxDescent}}drawText(eg,gg,ig){if(gg.textposition&&gg.textposition!=="none"&&gg.textsize){gg.textcolor&&(eg.fillStyle=gg.textcolor);const ng=(Ig,Cg)=>{let lg=(Ig==null?void 0:Ig.textWidth)||0;return Cg.textxalign==="left"?-this.width/2+this.strokeWidth/2:Cg.textxalign==="center"?-lg/2:Cg.textxalign==="right"&&this._cache.canvas?this.width/2-this.strokeWidth/2-lg:0},og=(Ig,Cg)=>{let lg=(Ig==null?void 0:Ig.textHeight)||0;if(Cg.textposition==="top"){if(this._cache.canvas){const Ag=-this.height/2+lg+this.strokeWidth/2;return Ig.y+=Ig.textHeight,Ag}}else if(Cg.textposition==="bottom"&&this._cache.canvas)return this.height/2-this.strokeWidth/2;return 0},ag=ng(ig,gg),sg=og(ig,gg);eg.save(),eg.fillText(gg.text,ag*this.scaleX,sg*this.scaleY),eg.restore()}}countDate(){if(this.barcodeDateFormatType&&this.increaseDate){const eg=formatDate(this.barcodeDateFormatType);return console.log("formatted",eg),this.dirty=!0,this.setBarcodeOption({bcid:this.barcodeOptions.bcid,text:eg}),eg}}countCurrent(eg){let gg=this.counterProps||eg;if(gg){let ig=gg;if(!ig.value&&ig.value!==0)return"";const ng=formatCounterValue(ig);return(ig.prefix&&ig.prefix.length>0?ig.prefix:"")+ng+(ig.suffix&&ig.suffix.length>0?ig.suffix:"")}return""}countNext(eg="print"){if(this.counterProps){let gg=this.counterProps;if(!gg.value&&gg.value!==0)return;eg==="review"&&!this.reviewValueArgs&&(this.reviewValueArgs={...gg});const ig=formatCounterValue(gg);let ng=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:"");const og=getNextCounterValue(gg);return og!==null&&(gg.value=og,this.counterProps.value=og),this.dirty=!0,this._cache.update=!0,ng}else return""}reviewRecover(){if(this.reviewValueArgs){const eg=this.reviewValueArgs;this.counterProps=eg,this.reviewValueArgs=null;const gg=formatCounterValue(eg);let ig=(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:"");this.setBarcodeOption({bcid:this.barcodeOptions.bcid,text:ig})}}calculateCheckDigit(eg){if(!/^\d{13}$/.test(eg))return"";let gg=0;for(let ig=0;ig<13;ig++){const ng=parseInt(eg[ig]);gg+=ng*(ig%2===0?3:1)}return(10-gg%10)%10}_render(eg){var dg,hg,mg,bg;let gg=cloneDeep(this.barcodeOptions);console.log("_render======",gg),gg.bcid=getEffectiveBarcodeType(gg.bcid,gg.text);let ig=gg.bcid==="ean13",ng=gg.bcid==="upca",og=gg.bcid==="upce",ag=gg.bcid==="ean8";if(this.scaleX!==1&&(this.scaleX=1),this.scaleY!==1&&(this.scaleY=1),this.orginTextgaps>Number(gg.textgaps),this.orginTextSize>Number(gg.textsize),gg.bcid==="gs1-128")try{const pg=GS1Parser.process(gg.text);gg.text=GS1Parser.format(pg)}catch(pg){this._cache.error=pg instanceof Error?pg.message:String(pg),this._cache.canvas=void 0,this._cache.update=!1}gg.textgaps=gg.textgaps||1,this.orginTextgaps=gg.textgaps||1,this.orginTextSize=gg.textsize||0,eg.font=`${gg.textsize}px ${gg.textfontname}`,gg.textgaps&&(eg.letterSpacing=gg.textgaps+"px");const sg=eg.measureText(gg.text);let Ig=sg.width/this.scaleX,Cg=(sg.actualBoundingBoxAscent+sg.actualBoundingBoxDescent)/this.scaleY;this.orginTextWidth=Ig,this.orginTextHeight=Cg,this.height>0||(this.height=Cg+30);const lg=["ean13","upca","upce","ean8"],Ag=!lg.includes(gg.bcid)&&(gg.textposition==="top"||gg.textposition==="bottom"),rg=Ag?Cg+this.barcodeTextGap:0;this._textLayoutInitialized&&(this.height=Math.max(1,this.height+rg-this._lastTextAreaHeight)),this._textLayoutInitialized=!0,this._lastTextAreaHeight=rg,this.barcodeTextHeight=Ag?Cg:0,this._lastTextVisible=Ag;let cg={w:this.width,h:this.height,x:-this.width/2,y:-this.height/2};cg.textWidth=Ig,cg.textHeight=Cg,gg.includetext=!1,gg.scale=1,gg.paddingleft=0,gg.paddingright=0,lg.includes(gg.bcid)&&(gg={...gg,includetext:!0,textyoffset:-10},gg.bcid==="upca"&&(gg.textyoffset=-15),delete gg.paddingtop,delete gg.paddingbottom,delete gg.paddingleft,delete gg.paddingright,delete gg.textposition,delete gg.textxalign);const ug=lg.includes(gg.bcid);if(typeof this.fill=="string"){let pg=rgbaStringToHex8(this.fill);gg.barcolor=hexToHex6_blend(pg)}if(this._cache.update)if(console.log("this._cache.update=====",this._cache.update),/[\u4e00-\u9fff]/.test(gg.text||""))this._cache.error="Not Support zh-CN character",this._cache.canvas=void 0,this._cache.update=!1;else try{this._cache.canvas=generateCanvas(gg),ug&&this.cropBuiltInText(this._cache.canvas,gg);let pg=this._cache.canvas.width;if(!lg.includes(gg.bcid)){let fg=getTargetDpi();this.canvas&&fg===300&&(pg=pg*1.32)}if(this.stretchMode==="free"){if((!this.width||this.width<1)&&(this.width=pg),this.width>pg){let fg=Math.min(32,Math.max(1,Math.ceil(this.width/pg)));fg>1&&(gg.scale=fg,this._cache.canvas=generateCanvas(gg),ug&&this.cropBuiltInText(this._cache.canvas,gg),console.log("barcodeOption=====",gg),pg=this._cache.canvas.width)}}else{const fg=this.barcodeBaseWidth??this.width;this.width=getBarcodeRenderWidth(fg,pg)}cg.w=this.width,cg.x=-this.width/2,this._cache.error&&(this._cache.error=void 0),this.setCoords(),(dg=this.canvas)==null||dg.requestRenderAll(),this._cache.update=!1,(hg=this.canvas)!=null&&hg.getActiveObject&&((mg=this.canvas)==null?void 0:mg.getActiveObject())===this&&((bg=this.canvas)==null||bg.fire("custom:object:changed",{target:this,action:"barcode"}))}catch(pg){console.warn("draw barcode",pg),this.dirty=!0,pg instanceof Error&&(console.log("error",pg.message),this._cache.error="error:"+pg.message),this._cache.canvas=void 0}if(eg.imageSmoothingEnabled=!1,this.strokeWidth>0&&typeof this.stroke=="string"&&(eg.lineWidth=this.strokeWidth,eg.strokeStyle=this.stroke,withObjectStrokeDash(eg,this,()=>eg.strokeRect(cg.x,cg.y,cg.w,cg.h))),cg.barcodeCanvas=this._cache.canvas,!this._cache.error&&cg.barcodeCanvas){this.strokeWidth>0&&(cg.x+=this.strokeWidth/2,cg.y+=this.strokeWidth/2);let pg=cg.h-(cg.textHeight||0)-this.strokeWidth/2,fg=cg.y;gg.textposition==="top"?(pg=pg-this.barcodeTextGap,fg=fg+cg.textHeight/this.scaleY+this.barcodeTextGap):gg.textposition==="bottom"?pg=pg-this.barcodeTextGap/this.scaleY:pg=cg.h-this.strokeWidth/2;let Gg=cg.w-this.strokeWidth/2,Zg=pg;lg.includes(gg.bcid)&&(Zg=cg.h-this.strokeWidth/2),eg.drawImage(cg.barcodeCanvas,0,0,cg.barcodeCanvas.width,cg.barcodeCanvas.height,cg.x,fg,Gg,Zg);let $g=this.barcodeOptions.text;const Bg=this.width;if(ig){let Wg=this.calcEAN13CheckDigit($g);$g=$g+""+Wg,eg.save();const yg=Math.trunc(Bg/95),Ng=-cg.y-Math.trunc(Zg/6);let vg=cg.x+Math.trunc(Gg/13);eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top";let Sg=cg.barcodeCanvas.width;this.width/Sg===1&&(eg.letterSpacing="-2px"),eg.fillText($g[0],-yg*2+vg,Ng),eg.fillText($g.slice(1,7),yg*(3+42/2)+cg.x+Math.trunc(Gg/10),Ng),eg.fillText($g.slice(7),yg*(50+42/2)+cg.x+Math.trunc(Gg/10),Ng),eg.restore()}else if(ag){let Wg=this.calcEAN8CheckDigit($g);$g=$g+""+Wg,eg.save();const yg=Math.trunc(Bg/67),Ng=-cg.y-Math.trunc(Zg/6);cg.x+Math.trunc(Gg/13),eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top";let vg=cg.barcodeCanvas.width;this.width/vg===1&&(eg.letterSpacing="-1px");const Vg=yg*12+cg.x+4,Xg=yg*55+cg.x-4;eg.fillText($g.slice(0,4),Vg,Ng),eg.fillText($g.slice(4),Xg,Ng),eg.restore()}else if(ng){eg.save();const Wg=-cg.y-Math.trunc(Zg/6),yg=cg.x;let Ng=this.calcUPCACheckDigit($g);$g=$g+""+Ng,eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top";let vg=cg.barcodeCanvas.width;this.width/vg===1&&(eg.letterSpacing="-1px"),this.drawUPCAText(eg,$g,Bg,Wg,yg),eg.restore()}else if(og){eg.save();const Wg=-cg.y-Math.trunc(Zg/8),yg=cg.x;let Ng=this.calcUPCECheckDigit($g);$g=$g+""+Ng,console.log("digits========",$g),eg.font=`${gg.textsize}px ${gg.textfontname}`,eg.fillStyle=gg.textcolor||"#000",eg.textAlign="center",eg.textBaseline="top",this.drawUPCEText(eg,$g,Bg,Wg,yg),eg.restore()}else this.drawText(eg,gg,cg)}if(eg.save(),/[\u4e00-\u9fff]/.test(gg.text||"")&&(this._cache.error="Not Support zh-CN character"),this._cache.error){const pg=wrapText(eg,this._cache.error,cg.w),fg=getLineHeight(eg);let wg=cg.y+fg;const Gg=eg.fillStyle;eg.fillStyle="red";for(const Zg of pg)if(eg.fillText(Zg,cg.x,wg),wg+=fg,wg>cg.y+this.height)break;eg.fillStyle=Gg}eg.restore(),console.log("_render barcode")}calcEAN13CheckDigit(eg){if(!/^\d{12}$/.test(eg))return"";let gg=0,ig=0;for(let ag=0;ag<12;ag++){const sg=Number(eg[11-ag]);(ag+1)%2===1?gg+=sg:ig+=sg}const og=(gg+ig*3)%10;return og===0?0:10-og}calcEAN8CheckDigit(eg){if(!/^\d{7}$/.test(eg))return"";let gg=0,ig=0;for(let ag=0;ag<7;ag++){const sg=Number(eg[6-ag]);(ag+1)%2===1?ig+=sg:gg+=sg}const og=(gg*3+ig)%10;return og===0?0:10-og}calcUPCACheckDigit(eg){if(!/^\d{11}$/.test(eg))return"";let gg=0,ig=0;for(let sg=0;sg<11;sg++){const Ig=parseInt(eg[sg],10);(sg+1)%2===1?gg+=Ig:ig+=Ig}const og=(gg*3+ig)%10;return(og===0?0:10-og).toString()}calcUPCECheckDigit(eg){if(!/^\d{7}$/.test(eg))return"";const gg=eg.split("").map(Number),ig=gg[0],[ng,og,ag,sg,Ig,Cg]=gg.slice(1);let lg="";switch(Cg){case 0:case 1:case 2:lg=`${ig}${ng}${og}${Cg}0000${ag}${sg}${Ig}`;break;case 3:lg=`${ig}${ng}${og}${ag}00000${sg}${Ig}`;break;case 4:lg=`${ig}${ng}${og}${ag}${sg}00000${Ig}`;break;default:lg=`${ig}${ng}${og}${ag}${sg}${Ig}0000${Cg}`}const Ag=lg.split("").map(Number);let rg=0;for(let cg=0;cg<Ag.length;cg++)cg%2===0?rg+=Ag[cg]*3:rg+=Ag[cg];return(10-rg%10)%10}drawUPCAText(eg,gg,ig,ng,og){const ag=gg[0],sg=gg.substring(1,6),Ig=gg.substring(6,11),Cg=gg[11],lg=ng,Ag=ig/95;[{text:ag,x:og+Ag*3.5},{text:sg,x:og+Ag*28+10},{text:Ig,x:og+Ag*67},{text:Cg,x:og+Ag*91.5+10}].forEach(cg=>{cg.text&&eg.fillText(cg.text,cg.x,lg)})}drawUPCEText(eg,gg,ig,ng,og){[{i:0,x:og+4},{i:1,x:og+ig*.25},{i:2,x:og+ig*.33},{i:3,x:og+ig*.44},{i:4,x:og+ig*.56},{i:5,x:og+ig*.68},{i:6,x:og+ig*.78},{i:7,x:og+ig+4}].forEach(sg=>{gg[sg.i]&&eg.fillText(gg[sg.i],sg.x,ng)})}set(eg,gg){return this._cache&&(this._cache.update=!0),super.set(eg,gg)}setBarcodeOption(eg){eg.bcid!==this.barcodeOptions.bcid&&(this.barcodeBaseWidth=void 0),merge(this.barcodeOptions,eg),this.dirty=!0,this._cache.update=!0;let gg=this.group;for(;gg;)gg.dirty=!0,gg=gg.group;let ig=getAllObjectMap();this.updateBarCode2d([...ig.text,...ig.counter])}updateInGroup(){this.dirty=!0,this.setCoords();let eg=this.group;for(;eg;)eg.dirty=!0,eg==null||eg.triggerLayout("childUpdate"),eg.setCoords(),eg=eg.group}getBarcodeOption(){return cloneDeep(this.barcodeOptions)}async updateBarCode2d(eg=[],gg=""){var ig;if(this.concatTextIdListObj||this.connectObjIds&&this.connectObjIds.length>0){let ng=!1,og="",ag=[],sg=[];const Ig=lg=>{if(this.connectObjIds){let Ag=0;for(let rg of this.connectObjIds){if(rg.index=Ag,rg.id&&rg.id===lg.id){ng=!0;let cg=lg.text+"";if(lg.type==="counter"&&(lg._props.mode==="1"?cg=lg.countCurrent():lg._props.mode==="2"&&(lg.updateText({isUpdateBarCodeDate:!1}),cg=lg.text+"")),rg.maxEnd=cg.length,rg.isSplit){rg.start=Math.min(rg.start,rg.maxEnd);let ug=cg.slice(rg.start,rg.end);ag[Ag]=ug}else ag[Ag]=cg}Ag++}}},Cg=lg=>{lg.type==="text"&&this.concatTextIdListObj&&this.concatTextIdListObj[lg.id]&&(ng||(lg==null||lg.set("text",this.barcodeOptions.text),lg.updateInGroup()),sg.push(lg))};if(eg.length>0)eg.forEach(lg=>{Ig(lg),Cg(lg)});else{const lg=Ag=>{Ag.type==="group"&&Ag._objects?Ag._objects.forEach(rg=>lg(rg)):(Ig(Ag),Cg(Ag))};(ig=this.canvas)==null||ig.getObjects().forEach(Ag=>lg(Ag))}return ng?(og=ag.join(""),this.barcodeOptions.text=og,this.dirty=!0,this._cache.update=!0,gg&&this.updateInGroup(),sg.forEach(lg=>{lg.updateInGroup(),lg==null||lg.set("text",og)}),setTimeout(()=>{var lg;(lg=this.canvas)==null||lg.requestRenderAll()},0),og):""}else return""}toObject(eg){let gg=["barcodeOptions","connectObjIds","concatTextIdListObj","counterProps","increaseDate","barcodeDateFormatType","stretchMode","barcodeTextHeight","barcodeTextGap"];return super.toObject(eg?[...eg,...gg]:gg)}};iC.type="Barcode";let ABarcode=iC;ABarcode.fromObject=(tg,eg)=>ABarcode._fromObject(tg,{...eg,extraParam:"barcodeOptions"}),tt.setClass(ABarcode),tt.setSVGClass(ABarcode);function getBase64Data({x:tg=0,y:eg=0,Content:gg="",ErrLevel:ig=1,Width:ng=0,Height:og=0,id:ag="",rWidth:sg=0,rHeight:Ig=0,CellSize:Cg="8"}={},lg=""){let Ag=ng/(og||1),rg=`${gg}-${ig}-${ng+og}-${Ag}-${Cg}`;if(lpCodeMap.has(rg)){let cg=lpCodeMap.get(rg);return lg!=="noSaveCache"&&setCacheLpCode({sKey:rg,img:cg,rWidth:sg,rHeight:Ig,x:tg,y:eg}),cg}return new Promise(async(cg,ug)=>{console.log("getLongbeiBase64Data=====");let dg=[JSON.stringify({Content:gg,ErrLevel:ig,Width:ng,Height:og,CellSize:Cg})],hg=await window.dsapi.driverAction.DSLE_Custom_LPCodeCreate(dg);if(hg=JSON.parse(hg),hg.code===0){let mg=hg.payload;if(mg){let bg=await loadBase64ToPic(mg);lpCodeMap.set(rg,bg),lg!=="noSaveCache"&&setCacheLpCode({sKey:rg,img:bg,rWidth:sg,rHeight:Ig,x:tg,y:eg}),cg(bg)}else ug("")}else ug(hg)})}function getMixBase64Data({x:tg=0,y:eg=0,Content:gg="",ErrLevel:ig="",Width:ng=0,Height:og=0,id:ag="",DPI:sg=203,rWidth:Ig=0,rHeight:Cg=0,CellSize:lg="8"}={},Ag=""){let rg=ng/(og||1),cg=`${gg}-${ig}-${ng+og}-${rg}-${lg}`;if(lpCodeMap.has(cg)){let ug=lpCodeMap.get(cg);return Ag!=="noSaveCache"&&setCacheMixLpCode({sKey:cg,img:ug,rWidth:Ig,rHeight:Cg,x:tg,y:eg}),ug}return new Promise(async(ug,dg)=>{console.log("getMixLongbeiBase64Data=====");let hg=ig.split("-"),mg=hg[0]||"0",bg=hg[1]||"0",pg=gg.split("|&&&|"),fg=pg.shift(),wg=pg.join("")||fg,Gg=[JSON.stringify({LPContent:fg||"",LPErrLevel:mg,QRContent:wg,QRErrLevel:bg,Width:ng,Height:og,DPI:sg+"",CellSize:lg})],Zg=await window.dsapi.driverAction.DSLE_Custom_LPMixCreate(Gg);if(Zg=JSON.parse(Zg),Zg.code===0){let $g=Zg.payload;if($g){let Bg=await loadBase64ToPic($g);lpCodeMap.set(cg,Bg),Ag!=="noSaveCache"&&setCacheMixLpCode({sKey:cg,img:Bg,rWidth:Ig,rHeight:Cg,x:tg,y:eg}),ug(Bg)}else dg("")}else dg(Zg)})}function loadBase64ToPic(tg){return new Promise(async(eg,gg)=>{let ig=new Image;ig.onload=()=>{eg(ig)},ig.src=tg})}let maxCacheLength=2e3;function setCacheLpCode({x:tg=0,y:eg=0,id:gg="",sKey:ig="",img:ng=null,rWidth:og=0,rHeight:ag=0}={}){if(!ig||!ng||!gg)return;let sg={sKey:ig,img:ng,rWidth:og,rHeight:ag,x:tg,y:eg};if(!cacheLpCodeMap.has(gg))cacheLpCodeMap.set(gg,[sg]);else{let Ig=cacheLpCodeMap.get(gg);Ig.length>maxCacheLength&&Ig.splice(0,500),Ig.push(sg),cacheLpCodeMap.set(gg,Ig)}}function setCacheMixLpCode({x:tg=0,y:eg=0,id:gg="",sKey:ig="",img:ng=null,rWidth:og=0,rHeight:ag=0}={}){if(!ig||!ng||!gg)return;let sg={sKey:ig,img:ng,rWidth:og,rHeight:ag,x:tg,y:eg};if(!cacheMixLpCodeMap.has(gg))cacheMixLpCodeMap.set(gg,[sg]);else{let Ig=cacheMixLpCodeMap.get(gg);Ig.length>maxCacheLength&&Ig.splice(0,500),Ig.push(sg),cacheMixLpCodeMap.set(gg,Ig)}console.log("cacheMixLpCodeMap========",cacheMixLpCodeMap)}class cappedMap extends Map{constructor(eg=60){super(),this.limit=eg}set(eg,gg){if(!this.has(eg)&&this.size>=this.limit){const ig=this.keys().next().value;this.delete(ig)}return super.set(eg,gg)}}class fastMap extends Map{constructor(eg=60){super(),this.lastKey=null,this.limit=eg}set(eg,gg){if(!this.has(eg)&&this.size>=this.limit){const ig=this.keys().next().value;this.delete(ig)}return this.lastKey=eg,super.set(eg,gg)}getLast(){return super.get(this.lastKey)||null}}let cacheMixLpCodeMap=new fastMap(2e3),cacheLpCodeMap=new fastMap(2e3),errorLpCodeMap=new cappedMap(5555),lpCodeMap=new cappedMap(5555),lpBcid=["LPCode","LPMixQrCode"];function clearLpAndMixCacheById(tg){cacheMixLpCodeMap.has(tg)&&cacheMixLpCodeMap.delete(tg),cacheLpCodeMap.has(tg)&&cacheLpCodeMap.delete(tg)}function getLastCacheLpcode(tg){let eg=cacheLpCodeMap.get(tg);return eg?eg[eg.length-1]:null}function getLastMixCacheLpcode(tg){let eg=cacheMixLpCodeMap.get(tg);return eg?eg[eg.length-1]:null}const isff=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function addEvent(tg,eg,gg,ig){tg.addEventListener?tg.addEventListener(eg,gg,ig):tg.attachEvent&&tg.attachEvent("on".concat(eg),gg)}function removeEvent(tg,eg,gg,ig){tg.removeEventListener?tg.removeEventListener(eg,gg,ig):tg.detachEvent&&tg.detachEvent("on".concat(eg),gg)}function getMods(tg,eg){const gg=eg.slice(0,eg.length-1);for(let ig=0;ig<gg.length;ig++)gg[ig]=tg[gg[ig].toLowerCase()];return gg}function getKeys(tg){typeof tg!="string"&&(tg=""),tg=tg.replace(/\s/g,"");const eg=tg.split(",");let gg=eg.lastIndexOf("");for(;gg>=0;)eg[gg-1]+=",",eg.splice(gg,1),gg=eg.lastIndexOf("");return eg}function compareArray(tg,eg){const gg=tg.length>=eg.length?tg:eg,ig=tg.length>=eg.length?eg:tg;let ng=!0;for(let og=0;og<gg.length;og++)ig.indexOf(gg[og])===-1&&(ng=!1);return ng}const _keyMap={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":isff?173:189,"=":isff?61:187,";":isff?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},_modifier={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},_mods={16:!1,18:!1,17:!1,91:!1},_handlers={};for(let tg=1;tg<20;tg++)_keyMap["f".concat(tg)]=111+tg;let _downKeys=[],winListendFocus=null,_scope="all";const elementEventMap=new Map,code=tg=>_keyMap[tg.toLowerCase()]||_modifier[tg.toLowerCase()]||tg.toUpperCase().charCodeAt(0),getKey=tg=>Object.keys(_keyMap).find(eg=>_keyMap[eg]===tg),getModifier=tg=>Object.keys(_modifier).find(eg=>_modifier[eg]===tg);function setScope(tg){_scope=tg||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(tg=>getKey(tg)||getModifier(tg)||String.fromCharCode(tg))}function getAllKeyCodes(){const tg=[];return Object.keys(_handlers).forEach(eg=>{_handlers[eg].forEach(gg=>{let{key:ig,scope:ng,mods:og,shortcut:ag}=gg;tg.push({scope:ng,shortcut:ag,mods:og,keys:ig.split("+").map(sg=>code(sg))})})}),tg}function filter(tg){const eg=tg.target||tg.srcElement,{tagName:gg}=eg;let ig=!0;const ng=gg==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(eg.type);return(eg.isContentEditable||(ng||gg==="TEXTAREA"||gg==="SELECT")&&!eg.readOnly)&&(ig=!1),ig}function isPressed(tg){return typeof tg=="string"&&(tg=code(tg)),_downKeys.indexOf(tg)!==-1}function deleteScope(tg,eg){let gg,ig;tg||(tg=getScope());for(const ng in _handlers)if(Object.prototype.hasOwnProperty.call(_handlers,ng))for(gg=_handlers[ng],ig=0;ig<gg.length;)gg[ig].scope===tg?gg.splice(ig,1).forEach(ag=>{let{element:sg}=ag;return removeKeyEvent(sg)}):ig++;getScope()===tg&&setScope(eg||"all")}function clearModifier(tg){let eg=tg.keyCode||tg.which||tg.charCode;tg.key&&tg.key.toLowerCase()==="capslock"&&(eg=code(tg.key));const gg=_downKeys.indexOf(eg);if(gg>=0&&_downKeys.splice(gg,1),tg.key&&tg.key.toLowerCase()==="meta"&&_downKeys.splice(0,_downKeys.length),(eg===93||eg===224)&&(eg=91),eg in _mods){_mods[eg]=!1;for(const ig in _modifier)_modifier[ig]===eg&&(hotkeys[ig]=!1)}}function unbind(tg){if(typeof tg>"u")Object.keys(_handlers).forEach(ng=>{Array.isArray(_handlers[ng])&&_handlers[ng].forEach(og=>eachUnbind(og)),delete _handlers[ng]}),removeKeyEvent(null);else if(Array.isArray(tg))tg.forEach(ng=>{ng.key&&eachUnbind(ng)});else if(typeof tg=="object")tg.key&&eachUnbind(tg);else if(typeof tg=="string"){for(var eg=arguments.length,gg=new Array(eg>1?eg-1:0),ig=1;ig<eg;ig++)gg[ig-1]=arguments[ig];let[ng,og]=gg;typeof ng=="function"&&(og=ng,ng=""),eachUnbind({key:tg,scope:ng,method:og,splitKey:"+"})}}const eachUnbind=tg=>{let{key:eg,scope:gg,method:ig,splitKey:ng="+"}=tg;getKeys(eg).forEach(ag=>{const sg=ag.split(ng),Ig=sg.length,Cg=sg[Ig-1],lg=Cg==="*"?"*":code(Cg);if(!_handlers[lg])return;gg||(gg=getScope());const Ag=Ig>1?getMods(_modifier,sg):[],rg=[];_handlers[lg]=_handlers[lg].filter(cg=>{const dg=(ig?cg.method===ig:!0)&&cg.scope===gg&&compareArray(cg.mods,Ag);return dg&&rg.push(cg.element),!dg}),rg.forEach(cg=>removeKeyEvent(cg))})};function eventHandler(tg,eg,gg,ig){if(eg.element!==ig)return;let ng;if(eg.scope===gg||eg.scope==="all"){ng=eg.mods.length>0;for(const og in _mods)Object.prototype.hasOwnProperty.call(_mods,og)&&(!_mods[og]&&eg.mods.indexOf(+og)>-1||_mods[og]&&eg.mods.indexOf(+og)===-1)&&(ng=!1);(eg.mods.length===0&&!_mods[16]&&!_mods[18]&&!_mods[17]&&!_mods[91]||ng||eg.shortcut==="*")&&(eg.keys=[],eg.keys=eg.keys.concat(_downKeys),eg.method(tg,eg)===!1&&(tg.preventDefault?tg.preventDefault():tg.returnValue=!1,tg.stopPropagation&&tg.stopPropagation(),tg.cancelBubble&&(tg.cancelBubble=!0)))}}function dispatch(tg,eg){const gg=_handlers["*"];let ig=tg.keyCode||tg.which||tg.charCode;if(tg.key&&tg.key.toLowerCase()==="capslock"||!hotkeys.filter.call(this,tg))return;if((ig===93||ig===224)&&(ig=91),_downKeys.indexOf(ig)===-1&&ig!==229&&_downKeys.push(ig),["metaKey","ctrlKey","altKey","shiftKey"].forEach(sg=>{const Ig=modifierMap[sg];tg[sg]&&_downKeys.indexOf(Ig)===-1?_downKeys.push(Ig):!tg[sg]&&_downKeys.indexOf(Ig)>-1?_downKeys.splice(_downKeys.indexOf(Ig),1):sg==="metaKey"&&tg[sg]&&(_downKeys=_downKeys.filter(Cg=>Cg in modifierMap||Cg===ig))}),ig in _mods){_mods[ig]=!0;for(const sg in _modifier)if(Object.prototype.hasOwnProperty.call(_modifier,sg)){const Ig=modifierMap[_modifier[sg]];hotkeys[sg]=tg[Ig]}if(!gg)return}for(const sg in _mods)Object.prototype.hasOwnProperty.call(_mods,sg)&&(_mods[sg]=tg[modifierMap[sg]]);tg.getModifierState&&!(tg.altKey&&!tg.ctrlKey)&&tg.getModifierState("AltGraph")&&(_downKeys.indexOf(17)===-1&&_downKeys.push(17),_downKeys.indexOf(18)===-1&&_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);const ng=getScope();if(gg)for(let sg=0;sg<gg.length;sg++)gg[sg].scope===ng&&(tg.type==="keydown"&&gg[sg].keydown||tg.type==="keyup"&&gg[sg].keyup)&&eventHandler(tg,gg[sg],ng,eg);if(!(ig in _handlers))return;const og=_handlers[ig],ag=og.length;for(let sg=0;sg<ag;sg++)if((tg.type==="keydown"&&og[sg].keydown||tg.type==="keyup"&&og[sg].keyup)&&og[sg].key){const Ig=og[sg],{splitKey:Cg}=Ig,lg=Ig.key.split(Cg),Ag=[];for(let rg=0;rg<lg.length;rg++)Ag.push(code(lg[rg]));Ag.sort().join("")===_downKeys.sort().join("")&&eventHandler(tg,Ig,ng,eg)}}function hotkeys(tg,eg,gg){_downKeys=[];const ig=getKeys(tg);let ng=[],og="all",ag=document,sg=0,Ig=!1,Cg=!0,lg="+",Ag=!1,rg=!1;for(gg===void 0&&typeof eg=="function"&&(gg=eg),Object.prototype.toString.call(eg)==="[object Object]"&&(eg.scope&&(og=eg.scope),eg.element&&(ag=eg.element),eg.keyup&&(Ig=eg.keyup),eg.keydown!==void 0&&(Cg=eg.keydown),eg.capture!==void 0&&(Ag=eg.capture),typeof eg.splitKey=="string"&&(lg=eg.splitKey),eg.single===!0&&(rg=!0)),typeof eg=="string"&&(og=eg),rg&&unbind(tg,og);sg<ig.length;sg++)tg=ig[sg].split(lg),ng=[],tg.length>1&&(ng=getMods(_modifier,tg)),tg=tg[tg.length-1],tg=tg==="*"?"*":code(tg),tg in _handlers||(_handlers[tg]=[]),_handlers[tg].push({keyup:Ig,keydown:Cg,scope:og,mods:ng,shortcut:ig[sg],method:gg,key:ig[sg],splitKey:lg,element:ag});if(typeof ag<"u"&&window){if(!elementEventMap.has(ag)){const cg=function(){let dg=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return dispatch(dg,ag)},ug=function(){let dg=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;dispatch(dg,ag),clearModifier(dg)};elementEventMap.set(ag,{keydownListener:cg,keyupListenr:ug,capture:Ag}),addEvent(ag,"keydown",cg,Ag),addEvent(ag,"keyup",ug,Ag)}if(!winListendFocus){const cg=()=>{_downKeys=[]};winListendFocus={listener:cg,capture:Ag},addEvent(window,"focus",cg,Ag)}}}function trigger(tg){let eg=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(_handlers).forEach(gg=>{_handlers[gg].filter(ng=>ng.scope===eg&&ng.shortcut===tg).forEach(ng=>{ng&&ng.method&&ng.method()})})}function removeKeyEvent(tg){const eg=Object.values(_handlers).flat();if(eg.findIndex(ig=>{let{element:ng}=ig;return ng===tg})<0){const{keydownListener:ig,keyupListenr:ng,capture:og}=elementEventMap.get(tg)||{};ig&&ng&&(removeEvent(tg,"keyup",ng,og),removeEvent(tg,"keydown",ig,og),elementEventMap.delete(tg))}if((eg.length<=0||elementEventMap.size<=0)&&(Object.keys(elementEventMap).forEach(ng=>{const{keydownListener:og,keyupListenr:ag,capture:sg}=elementEventMap.get(ng)||{};og&&ag&&(removeEvent(ng,"keyup",ag,sg),removeEvent(ng,"keydown",og,sg),elementEventMap.delete(ng))}),elementEventMap.clear(),Object.keys(_handlers).forEach(ng=>delete _handlers[ng]),winListendFocus)){const{listener:ng,capture:og}=winListendFocus;removeEvent(window,"focus",ng,og),winListendFocus=null}}const _api={getPressedKeyString,setScope,getScope,deleteScope,getPressedKeyCodes,getAllKeyCodes,isPressed,filter,trigger,unbind,keyMap:_keyMap,modifier:_modifier,modifierMap};for(const tg in _api)Object.prototype.hasOwnProperty.call(_api,tg)&&(hotkeys[tg]=_api[tg]);if(typeof window<"u"){const tg=window.hotkeys;hotkeys.noConflict=eg=>(eg&&window.hotkeys===hotkeys&&(window.hotkeys=tg),hotkeys),window.hotkeys=hotkeys}function getSupportDistance(tg,eg){var ng;const gg=(ng=tg==null?void 0:tg.getCenterPoint)==null?void 0:ng.call(tg),ig=getVisibleCoords(tg);return!gg||!Array.isArray(ig)||ig.length===0?0:Math.max(...ig.map(og=>(og.x-gg.x)*eg.x+(og.y-gg.y)*eg.y))}function getVisibleCoords(tg){var ng,og;if(!((ng=tg==null?void 0:tg._textLines)!=null&&ng.length)||typeof tg.getLineWidth!="function"||typeof tg._getLineLeftOffset!="function"||typeof tg.getHeightOfLine!="function"||typeof tg.calcTransformMatrix!="function")return(og=tg==null?void 0:tg.getCoords)==null?void 0:og.call(tg);const eg=tg.calcTransformMatrix(),gg=[];let ig=-tg.height/2;return tg._textLines.forEach((ag,sg)=>{const Ig=-tg.width/2+tg._getLineLeftOffset(sg),Cg=Ig+tg.getLineWidth(sg),lg=ig+tg.getHeightOfLine(sg);gg.push(new ot(Ig,ig).transform(eg),new ot(Cg,ig).transform(eg),new ot(Cg,lg).transform(eg),new ot(Ig,lg).transform(eg)),ig=lg}),gg}function getRelativePositionBounds(tg){const eg=getVisibleCoords(tg);if(eg!=null&&eg.length)return eg.reduce((gg,ig)=>({left:Math.min(gg.left,ig.x),top:Math.min(gg.top,ig.y),right:Math.max(gg.right,ig.x),bottom:Math.max(gg.bottom,ig.y)}),{left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY})}function captureRelativePosition(tg,eg){var Cg,lg;const gg=(Cg=tg==null?void 0:tg.getCenterPoint)==null?void 0:Cg.call(tg),ig=(lg=eg==null?void 0:eg.getCenterPoint)==null?void 0:lg.call(eg);if(!gg||!ig||!(eg!=null&&eg.id))return;const ng=gg.x-ig.x,og=gg.y-ig.y,ag=Math.hypot(ng,og),sg=new ot(ag?ng/ag:1,ag?og/ag:0),Ig=new ot(-sg.x,-sg.y);return{targetId:eg.id,directionX:sg.x,directionY:sg.y,gap:ag-getSupportDistance(eg,sg)-getSupportDistance(tg,Ig)}}function placeRelativeObject(tg,eg,gg){var Ag,rg,cg;const ig=gg||(tg==null?void 0:tg.relativePosition),ng=(Ag=eg==null?void 0:eg.getCenterPoint)==null?void 0:Ag.call(eg);if(!ig||!ng||!(eg!=null&&eg.id))return!1;let og=ig.directionX,ag=ig.directionY,sg=ig.gap;if(!Number.isFinite(og)||!Number.isFinite(ag)){const ug=ig.dx||0,dg=ig.dy||0,hg=Math.hypot(ug,dg);og=hg?ug/hg:1,ag=hg?dg/hg:0;const mg=new ot(og,ag);sg=hg-getSupportDistance(eg,mg)-getSupportDistance(tg,new ot(-og,-ag)),gg||tg.set("relativePosition",{targetId:ig.targetId,directionX:og,directionY:ag,gap:sg})}const Ig=new ot(og,ag),Cg=new ot(-og,-ag),lg=getSupportDistance(eg,Ig)+sg+getSupportDistance(tg,Cg);return(rg=tg.setPositionByOrigin)==null||rg.call(tg,new ot(ng.x+og*lg,ng.y+ag*lg),"center","center"),(cg=tg.setCoords)==null||cg.call(tg),!0}class EditorData{constructor(){this.relativePositionGeometrySnapshots=new Map,this.enabled=!0,this.dirty=!1,this.originState="",this.hasSetActiveSelection=!1,this.relativePositionEditHandle=eg=>{var og;const gg=(eg==null?void 0:eg.target)||(eg==null?void 0:eg.activeObj);if(!(gg!=null&&gg.id)||!this.canvas)return;const ig=this.canvas.getObjects();if((og=gg.getCenterPoint)!=null&&og.call(gg))for(const ag of ig){const sg=ag.relativePosition;if(sg){if(ag.id===gg.id){const Ig=ig.find(lg=>lg.id===sg.targetId),Cg=captureRelativePosition(ag,Ig);Cg&&ag.set("relativePosition",Cg)}else if(sg.targetId===gg.id){const Ig=captureRelativePosition(ag,gg);Ig&&ag.set("relativePosition",Ig)}}}},this.relativePositionPrepareHandle=()=>{if(!this.canvas)return;const eg=this.canvas.getObjects();this.relativePositionGeometrySnapshots.clear();for(const gg of eg){gg.id&&this.relativePositionGeometrySnapshots.set(gg.id,{left:gg.left,top:gg.top,width:gg.width,height:gg.height,scaleX:gg.scaleX,scaleY:gg.scaleY,angle:gg.angle,visibleBounds:getRelativePositionBounds(gg)});const ig=gg.relativePosition;if(!ig||Number.isFinite(ig.directionX)&&Number.isFinite(ig.directionY)&&Number.isFinite(ig.gap))continue;const ng=eg.find(ag=>ag.id===ig.targetId),og=captureRelativePosition(gg,ng);og&&gg.set("relativePosition",og)}},this.relativePositionRenderHandle=eg=>{var Cg;const gg=(eg==null?void 0:eg.target)||(eg==null?void 0:eg.activeObj);if(!(gg!=null&&gg.id)||!this.canvas||!((Cg=gg.getCenterPoint)==null?void 0:Cg.call(gg)))return;const ng=new Set,og=!!(eg!=null&&eg.preserveUnchangedAxes),ag=lg=>{const Ag=lg!=null&&lg.id?this.relativePositionGeometrySnapshots.get(lg.id):void 0;if(!Ag)return;const rg=getRelativePositionBounds(lg),cg=ug=>!!Ag.visibleBounds&&!!rg&&Math.abs(rg[ug]-Ag.visibleBounds[ug])>1e-6;return{x:lg.left!==Ag.left||lg.width!==Ag.width||lg.scaleX!==Ag.scaleX||lg.angle!==Ag.angle||cg("left")||cg("right"),y:lg.top!==Ag.top||lg.height!==Ag.height||lg.scaleY!==Ag.scaleY||lg.angle!==Ag.angle||cg("top")||cg("bottom")}},sg=(lg,Ag,rg)=>{var Wg,yg,Ng,vg,Sg;const cg=(Wg=lg.getCenterPoint)==null?void 0:Wg.call(lg),ug=(yg=Ag.getCenterPoint)==null?void 0:yg.call(Ag),dg=rg||lg.relativePosition,hg=og?ag(lg):void 0,mg=og?ag(Ag):void 0;if(!placeRelativeObject(lg,Ag,rg)||!og||!cg||!ug||!hg&&!mg)return;const bg=!!(hg!=null&&hg.x)||!!(mg!=null&&mg.x),pg=!!(hg!=null&&hg.y)||!!(mg!=null&&mg.y),fg=(Ng=lg.getCenterPoint)==null?void 0:Ng.call(lg),wg=dg==null?void 0:dg.directionX,Gg=dg==null?void 0:dg.directionY;if(!fg||!Number.isFinite(wg)||!Number.isFinite(Gg)||bg&&pg)return;const Zg=(fg.x-ug.x)*wg+(fg.y-ug.y)*Gg;let $g=fg.x,Bg=fg.y;bg&&!pg?(Bg=cg.y,$g=Math.abs(wg)>1e-8?ug.x+(Zg-Gg*(Bg-ug.y))/wg:cg.x):!bg&&pg?($g=cg.x,Bg=Math.abs(Gg)>1e-8?ug.y+(Zg-wg*($g-ug.x))/Gg:cg.y):($g=cg.x,Bg=cg.y),(vg=lg.setPositionByOrigin)==null||vg.call(lg,new ot($g,Bg),"center","center"),(Sg=lg.setCoords)==null||Sg.call(lg)},Ig=(lg,Ag=!1)=>{var cg;if(ng.has(lg.id))return;ng.add(lg.id);const rg=lg.relativePosition;if(Ag&&rg){const ug=this.canvas.getObjects().find(dg=>dg.id===rg.targetId);ug&&sg(ug,lg,{...rg,targetId:ug.id,directionX:-rg.directionX,directionY:-rg.directionY,dx:rg.dx===void 0?void 0:-rg.dx,dy:rg.dy===void 0?void 0:-rg.dy})}for(const ug of this.canvas.getObjects()){const dg=ug.relativePosition;if((dg==null?void 0:dg.targetId)!==lg.id)continue;sg(ug,lg),((cg=ug.getCenterPoint)==null?void 0:cg.call(ug))&&Ig(ug)}};Ig(gg,!0),this.canvas.requestRenderAll()},this.handle={selectionHandles:new Set,modifyHandles:new Set,mouseDownHandles:new Set,mouseUpHandles:new Set,doubleClickHandles:new Set,objectUpdateHandles:new Set,mouseOverHandles:new Set,mouseOutHandles:new Set,checkDirtyHandles:new Set},this.selectHandle=eg=>{if(this.enabled)for(const gg of this.handle.selectionHandles)if(eg.selected){const ig=this.canvas.getActiveObject();gg(eg.e,ig?[ig]:[]),this.canvas&&this.canvas.elements.container.focus({preventScroll:!0})}else gg(eg.e,[])},this.modifyHandle=throttle$3(eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))){if(eg.target)for(const gg of this.handle.modifyHandles)gg(eg.e,eg.target);this.checkDirty(eg)}},200),this.doubleClickHandle=eg=>{var gg,ig;if(!(!this.enabled||this.isWorkspace(eg.target))&&eg.target){eg.target.type==="table"&&eg.scenePoint&&(this.canvas.getActiveObject()!==eg.target&&(this.canvas.setActiveObject(eg.target,eg.e),this.canvas.requestRenderAll()),(ig=(gg=eg.target).handleCellDoubleClick)==null||ig.call(gg,eg.scenePoint));for(const ng of this.handle.doubleClickHandles)ng(eg.e,eg.target)}},this.mouseDownHandle=eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))&&eg.target)for(const gg of this.handle.mouseDownHandles)gg(eg.e,eg.target)},this.mouseUpHandle=eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))&&eg.target)for(const gg of this.handle.mouseUpHandles)gg(eg.e,eg.target)},this.checkDirty=debounce$2(eg=>{if(!this.canvas)return!1;const gg=this.canvas.toJSON(),ig=JSON.stringify(gg);this.originState||(this.originState=ig),this.dirty=this.originState!==ig,eg.isToDirty&&(this.dirty=!0),console.log("this.dirty=========",this.dirty);for(const ng of this.handle.checkDirtyHandles)ng();return this.dirty},100),this.objectUpdateHandle=debounce$2(eg=>{if(!(!this.enabled||this.isWorkspace(eg.target))){for(const gg of this.handle.objectUpdateHandles)gg(eg.target);this.checkDirty(eg)}},100),this.mouseOver=eg=>{for(const gg of this.handle.mouseOverHandles)gg()},this.mouseOut=eg=>{for(const gg of this.handle.mouseOutHandles)gg()}}init(eg){this.editor=eg,this.canvas=eg.getCanvas(),this.bind(),this.originState=JSON.stringify(this.canvas.toJSON())}getActiveObject(){return this.canvas.getActiveObject()}getActiveObjects(){return this.canvas.getActiveObjects()}getObjects(){return this.canvas.getObjects()||[]}getAllObjects(){if(!this.canvas)return[];const eg=[];function gg(ig){ig.type==="group"&&ig._objects?ig._objects.forEach(ng=>gg(ng)):ig.id!=="workspace"&&eg.push(ig)}return this.canvas.getObjects().forEach(ig=>gg(ig)),eg}clearActiveSelection(){this.canvas&&this.hasSetActiveSelection&&(this.canvas.discardActiveObject(),this.canvas.requestRenderAll(),this.hasSetActiveSelection=!1)}setObjectsActive(eg){if(!(!this.canvas||eg.length===0)){if(this.canvas.discardActiveObject(),eg.length===1)this.canvas.setActiveObject(eg[0]);else{this.hasSetActiveSelection=!0;const gg=new Jo(eg,{canvas:this.canvas});this.canvas.setActiveObject(gg)}this.canvas.requestRenderAll()}}getObjectsList(){if(!this.canvas)return[];const eg=this.canvas.getObjects(),gg=[];for(const ig of eg)if(ig.id!=="workspace"&&ig.drawObjectType!=="ignoreObject"){if(ig instanceof Jo)continue;ig.parent?ig.parent instanceof Jo?gg.push(ig):console.log("obj.parent isn't ActiveSelection",ig.parent,ig.parent.type):gg.push(ig)}return gg}setActiveObjectProps(eg,gg=!0){if(this.canvas){const ig=this.canvas.getActiveObject();if(ig){for(const ng in eg)console.log("object set",ng,eg[ng]),ig.type==="text"?(ig.set(ng,eg[ng]),ig.splitByGrapheme&&ig.verticalTypeChange()):ig.set(ng,eg[ng]);return gg&&this.canvas.fire("custom:object:history",{target:ig,action:"history:update"}),!0}}return!1}setActiveObjectPos(eg){var gg;this.setActiveObjectProps(eg)&&((gg=this.canvas)==null||gg.getActiveObject().setCoords())}setActiveObjectPositionByOrigin(eg,gg="left",ig="top"){var og,ag;const ng=(og=this.canvas)==null?void 0:og.getActiveObject();return ng!=null&&ng.setPositionByOrigin?(ng.setPositionByOrigin(eg,gg,ig),ng.setCoords(),(ag=this.canvas)==null||ag.fire("custom:object:history",{target:ng,action:"history:update"}),!0):!1}updateCanvas(){this.canvas.renderAll()}addModifyHandle(eg){this.handle.modifyHandles.add(eg)}addSelectionHandle(eg){this.handle.selectionHandles.add(eg)}addMouseDownHandle(eg){this.handle.mouseDownHandles.add(eg)}addMouseUpHandle(eg){this.handle.mouseUpHandles.add(eg)}addDoubleClickHandle(eg){this.handle.doubleClickHandles.add(eg)}addObjectUpdateHandle(eg){this.handle.objectUpdateHandles.add(eg)}addMouseOverHandle(eg){this.handle.mouseOverHandles.add(eg)}addMouseOutHandle(eg){this.handle.mouseOutHandles.add(eg)}removeMouseOverHandle(eg){this.handle.mouseOverHandles.delete(eg)}removeMouseOutHandle(eg){this.handle.mouseOutHandles.delete(eg)}removeModifyHandle(eg){this.handle.modifyHandles.delete(eg)}removeSelectionHandle(eg){this.handle.selectionHandles.delete(eg)}removeMouseDownHandle(eg){this.handle.mouseDownHandles.delete(eg)}removeMouseUpHandle(eg){this.handle.mouseUpHandles.delete(eg)}removeDoubleClickHandle(eg){this.handle.doubleClickHandles.delete(eg)}remvoeObjectUpdateHandle(eg){this.handle.objectUpdateHandles.delete(eg)}addCheckDirtyHandles(eg){this.handle.checkDirtyHandles.add(eg)}removeCheckDirtyHandles(eg){this.handle.checkDirtyHandles.delete(eg)}setOriginState(){if(!this.canvas)return!1;const eg=this.canvas.toJSON(),gg=JSON.stringify(eg);this.originState=gg}isWorkspace(eg){return eg&&eg.id==="workspace"}setEnabled(eg){this.enabled=eg}bind(){if(!this.canvas)return;const eg=this.canvas,gg=eg.findTarget.bind(eg);eg.findTarget=ig=>{if(ig&&ig.type==="dblclick"){const ng=[],og=[];for(const sg of eg.getObjects())sg.type==="table"&&sg.perPixelTargetFind&&(ng.push(sg),og.push(sg.perPixelTargetFind),sg.perPixelTargetFind=!1);const ag=gg(ig);return ng.forEach((sg,Ig)=>{sg.perPixelTargetFind=og[Ig]}),ag}return gg(ig)},eg.on("selection:created",this.selectHandle),eg.on("selection:updated",this.selectHandle),eg.on("selection:cleared",this.selectHandle),eg.on("object:modified",this.modifyHandle),eg.on("object:scaling",this.modifyHandle),eg.on("object:rotating",this.modifyHandle),eg.on("object:moving",this.modifyHandle),eg.on("object:skewing",this.modifyHandle),eg.on("custom:object:changed",this.modifyHandle),eg.on("custom:object:basechanged",this.modifyHandle),eg.on("object:modified",this.relativePositionEditHandle),eg.on("custom:object:basechanged",this.relativePositionEditHandle),eg.on("custom:object:relativeposition:prepare",this.relativePositionPrepareHandle),eg.on("custom:object:relativeposition:update",this.relativePositionRenderHandle),eg.on("mouse:dblclick",this.doubleClickHandle),eg.on("mouse:down",this.mouseDownHandle),eg.on("mouse:up",this.mouseUpHandle),eg.on("object:added",this.objectUpdateHandle),eg.on("object:removed",this.objectUpdateHandle),eg.on("custom:object:checkdirty",this.checkDirty),this.editor.on("group",this.objectUpdateHandle),this.editor.on("ungroup",this.objectUpdateHandle)}unbind(){if(!this.canvas)return;const eg=this.canvas;eg.off("selection:created",this.selectHandle),eg.off("selection:updated",this.selectHandle),eg.off("selection:cleared",this.selectHandle),eg.off("object:modified",this.modifyHandle),eg.off("object:scaling",this.modifyHandle),eg.off("object:rotating",this.modifyHandle),eg.off("object:moving",this.modifyHandle),eg.off("object:skewing",this.modifyHandle),eg.off("custom:object:changed",this.modifyHandle),eg.off("custom:object:basechanged",this.modifyHandle),eg.off("object:modified",this.relativePositionEditHandle),eg.off("custom:object:basechanged",this.relativePositionEditHandle),eg.off("custom:object:relativeposition:prepare",this.relativePositionPrepareHandle),eg.off("custom:object:relativeposition:update",this.relativePositionRenderHandle),eg.off("mouse:dblclick",this.doubleClickHandle),eg.off("mouse:down",this.mouseDownHandle),eg.off("mouse:up",this.mouseUpHandle),eg.off("object:added",this.objectUpdateHandle),eg.off("object:removed",this.objectUpdateHandle),eg.off("custom:object:checkdirty",this.checkDirty),this.editor.off("group",this.objectUpdateHandle),this.editor.off("ungroup",this.objectUpdateHandle)}}const byteToHex=[];for(let tg=0;tg<256;++tg)byteToHex.push((tg+256).toString(16).slice(1));function unsafeStringify(tg,eg=0){return(byteToHex[tg[eg+0]]+byteToHex[tg[eg+1]]+byteToHex[tg[eg+2]]+byteToHex[tg[eg+3]]+"-"+byteToHex[tg[eg+4]]+byteToHex[tg[eg+5]]+"-"+byteToHex[tg[eg+6]]+byteToHex[tg[eg+7]]+"-"+byteToHex[tg[eg+8]]+byteToHex[tg[eg+9]]+"-"+byteToHex[tg[eg+10]]+byteToHex[tg[eg+11]]+byteToHex[tg[eg+12]]+byteToHex[tg[eg+13]]+byteToHex[tg[eg+14]]+byteToHex[tg[eg+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(tg,eg,gg){var ng;if(native.randomUUID&&!tg)return native.randomUUID();tg=tg||{};const ig=tg.random??((ng=tg.rng)==null?void 0:ng.call(tg))??rng();if(ig.length<16)throw new Error("Random bytes length must be >= 16");return ig[6]=ig[6]&15|64,ig[8]=ig[8]&63|128,unsafeStringify(ig)}function handleConcatBarcode2d(tg,eg,gg=!0,ig=null){if(tg){let ng=[],og=getAllObjectMap(eg);ng=[...og.text,...og.counter];let ag=[...og.barcode2d],sg=[...og.barcode],Ig={};ag.forEach(lg=>{Ig[lg.id]=lg});let Cg={};sg.forEach(lg=>{Cg[lg.id]=lg});for(let lg of Object.keys(tg)){if(ag.length){let Ag=Ig[lg];if(!Ag)return;let rg=!0;if(ig&&ig.type==="counter"&&ig.data==="2"&&(Ag.barcode2dOptions.bcid==="LPCode"?(rg=!Ag.hasLpemit,Ag.hasLpemit=!0):Ag.barcode2dOptions.bcid==="LPMixQrCode"&&(rg=!Ag.hasLpMixemit,Ag.hasLpMixemit=!0)),!rg)return;canvasEventBus.emit(`update:barcode2d:${lg}`,{list:ng,callback:cg=>{Ag.dirty=!0,Ag.barcode2dOptions.text=cg||Ag.barcode2dOptions.text,Ag.updateInGroup(),gg&&setTimeout(()=>{eg==null||eg.requestRenderAll()},30)}})}if(sg.length){let Ag=Cg[lg];if(!Ag)return;canvasEventBus.emit(`update:barcode:${lg}`,{list:ng,callback:rg=>{Ag.dirty=!0,Ag.barcodeOptions.text=rg||Ag.barcodeOptions.text,Ag.updateInGroup(),gg&&setTimeout(()=>{eg==null||eg.requestRenderAll(),Ag.group&&setTimeout(()=>{Ag.updateInGroup(),eg==null||eg.requestRenderAll()},0)},30)}})}}}}function addHandle(tg,eg,gg){if(tg){let ig={},ng=getAllObjectMap(eg);[...ng.barcode2d,...ng.barcode].forEach(ag=>{ig[ag.id]=ag});for(let ag of Object.keys(tg)){let sg=ig[ag];if(sg){let Ig=sg.connectObjIds||[],Cg=cacheObj[gg];Cg&&(Ig.some(lg=>lg.id===Cg.id)||(Ig.splice(Cg.index,0,Cg),sg.set("connectObjIds",Ig)))}}}}let cacheObj={};function deleteHandle(tg,eg,gg){if(tg){let ig={},ng=getAllObjectMap(eg);[...ng.barcode2d,...ng.barcode].forEach(ag=>{ig[ag.id]=ag});for(let ag of Object.keys(tg)){let sg=ig[ag];if(sg){let Ig=sg.connectObjIds||[];Ig=Ig.filter(Cg=>(Cg.id===gg&&(cacheObj[gg]=Cg),Cg.id!==gg)),sg.set("connectObjIds",Ig)}}}}const isAnchorX$1=tg=>tg==="left"||tg==="center"||tg==="right",isAnchorY$1=tg=>tg==="top"||tg==="center"||tg==="bottom";function getTextAnchor(tg){return{x:isAnchorX$1(tg==null?void 0:tg.textAnchorX)?tg.textAnchorX:isAnchorX$1(tg==null?void 0:tg.originX)?tg.originX:"left",y:isAnchorY$1(tg==null?void 0:tg.textAnchorY)?tg.textAnchorY:isAnchorY$1(tg==null?void 0:tg.originY)?tg.originY:"top"}}const isTextAnchorPosition=tg=>Number.isFinite(tg==null?void 0:tg.x)&&Number.isFinite(tg==null?void 0:tg.y);function captureTextAnchorPosition(tg,eg=getTextAnchor(tg)){var ig;const gg=(ig=tg==null?void 0:tg.getPointByOrigin)==null?void 0:ig.call(tg,eg.x,eg.y);if(isTextAnchorPosition(gg))return tg.textAnchorPosition={x:gg.x,y:gg.y},tg.textAnchorPosition}function reflowTextWithAnchor(tg,eg,gg=!1){var ag;const ig=getTextAnchor(tg),ng=gg&&isTextAnchorPosition(tg==null?void 0:tg.textAnchorPosition)?tg.textAnchorPosition:captureTextAnchorPosition(tg,ig),og=eg();return ng&&(tg!=null&&tg.setPositionByOrigin)&&(tg.setPositionByOrigin(ng,ig.x,ig.y),(ag=tg.setCoords)==null||ag.call(tg),captureTextAnchorPosition(tg,ig)),og}function setTextAnchor(tg,eg,gg){var ig;tg.set({textAnchorX:eg,textAnchorY:gg}),captureTextAnchorPosition(tg,{x:eg,y:gg}),(ig=tg.canvas)==null||ig.fire("custom:object:history",{target:tg,action:"history:update"})}const myanmarCharacters=/[\u1000-\u109F\uA9E0-\uA9FF\uAA60-\uAA7F]/,aC=class aC extends No{constructor(eg,gg){const ig=gg.width,ng=gg.height;super(eg,gg),this.hasSetSplit=!1,this.objectCaching=!0,this.hasSetItalic=!1,this.isClearCopyTextStyle=!1,this.propsMinHeight=0,this.strokeUniform=!0,this.isBgBlackColor=!1,this.customExportFields={varnish:"none"},this.backgroundColor="",this.connectBar2dMap=null,this.__canvasRef=null,this.fontFamily="微软雅黑",this.verticalType="top",this.arcEnable=!1,this.arcRadius=100,this.fixedSize=!1,this.verticalLayout=!1,this.fixedHeight=!1,this.extraScale=1,this.textAnchorX="left",this.textAnchorY="top",this.isNormalizingParagraphScale=!1,this.textAnchorReady=!1,this.textAnchorX=gg.textAnchorX??gg.originX??"left",this.textAnchorY=gg.textAnchorY??gg.originY??"top";const og=gg.textAnchorPosition;this.textAnchorPosition=Number.isFinite(og==null?void 0:og.x)&&Number.isFinite(og==null?void 0:og.y)?{x:og.x,y:og.y}:this.getPointByOrigin(this.textAnchorX,this.textAnchorY),this.textAnchorReady=!0,this.fixedHeight=gg.fixedHeight??!1,this.fixedHeight&&this.splitByGrapheme&&ng!==void 0&&reflowTextWithAnchor(this,()=>{this.height=ng},!0),this.customExportFields=gg.customExportFields??this.customExportFields,this._originGetTopOffset=this._getTopOffset?this._getTopOffset.bind(this):()=>0,this.fontFamily=gg.fontFamily??this.fontFamily,gg.hasSetItalic&&gg.fontStyle!=="italic"&&(this.fontStyle="italic",gg.skewX===-15&&(this.skewX=0)),gg.propsMinHeight&&reflowTextWithAnchor(this,()=>{this.propsMinHeight=gg.propsMinHeight,this.fixedHeight||(this.height=Math.max(this.height,this.propsMinHeight))}),gg.verticalType&&(this.verticalType=gg.verticalType),gg.backgroundColor&&(this.backgroundColor=gg.backgroundColor),this.isBgBlackColor=gg.isBgBlackColor??this.isBgBlackColor,this.connectBar2dMap=gg.connectBar2dMap??this.connectBar2dMap,gg.arcEnable!==void 0&&(this.arcEnable=gg.arcEnable),gg.arcRadius!==void 0&&(this.arcRadius=gg.arcRadius),gg.fixedSize!==void 0&&(this.fixedSize=gg.fixedSize),gg.verticalLayout!==void 0&&(this.verticalLayout=gg.verticalLayout),gg.horizontalLayoutWidth!==void 0?this.horizontalLayoutWidth=gg.horizontalLayoutWidth:this.verticalLayout&&(this.horizontalLayoutWidth=ig??this.width),gg.extraScale!==void 0&&(this.extraScale=gg.extraScale),gg.baseFontSize!==void 0&&(this.baseFontSize=gg.baseFontSize),this.fixedSize&&(this.arcEnable=!1,this.baseFontSize??(this.baseFontSize=this.fontSize),ig!==void 0&&reflowTextWithAnchor(this,()=>{this.width=ig})),this.on("removed",ag=>{if(ag.target.type!=="activeselection"){if(this.inGroupRemove){this.inGroupRemove=!1;return}deleteHandle(this.connectBar2dMap,this.__canvasRef,this.id)}}),this.on("added",()=>{this.__canvasRef=this.canvas,addHandle(this.connectBar2dMap,this.__canvasRef,this.id)}),this.on("modified",ag=>{(ag==null?void 0:ag.action)!=="drag"&&this.type==="text"&&(this.verticalTypeChange(),this.tiggerHandleConcatBarcode2d())}),this.on("changed",()=>{this.type==="text"&&this.verticalTypeChange()}),this.on("moving",()=>{captureTextAnchorPosition(this)}),this.on("rotating",()=>{captureTextAnchorPosition(this)}),this.on("scaling",()=>{this.applyFixedSizeScale(),captureTextAnchorPosition(this)}),this.verticalLayout&&this.setVerticalLayout(!0),this.verticalTypeChange()}getExtraScale(){const eg=this.extraScale;return Number.isFinite(eg)&&eg>0?eg:1}shouldPreserveTextAnchor(eg){return!this.textAnchorReady||this.textAnchorX===void 0||this.textAnchorY===void 0||!this.textAnchorPosition?!1:typeof eg=="object"&&eg?"scaleX"in eg||"scaleY"in eg?!1:!("left"in eg)&&!("top"in eg)&&["text","width","height","splitByGrapheme","verticalLayout","propsMinHeight"].some(gg=>gg in eg):["text","width","height","splitByGrapheme","verticalLayout","propsMinHeight"].includes(eg)}tiggerHandleConcatBarcode2d(){this.connectBar2dMap&&handleConcatBarcode2d(this.connectBar2dMap,this.canvas)}_wrapText(eg,gg){return!this.verticalLayout||this.splitByGrapheme?super._wrapText(eg,gg):eg.flatMap(ig=>this.graphemeSplit(ig).map(ng=>[ng]))}setVerticalLayout(eg){var ig;const gg=this.textAnchorPosition??this.getPointByOrigin(this.textAnchorX,this.textAnchorY);eg&&!Number.isFinite(this.horizontalLayoutWidth)&&(this.horizontalLayoutWidth=this.width),this.verticalLayout=eg,!eg&&Number.isFinite(this.horizontalLayoutWidth)&&(this.width=this.horizontalLayoutWidth),this.initDimensions(),eg||(this.horizontalLayoutWidth=void 0),gg&&this.setPositionByOrigin(gg,this.textAnchorX,this.textAnchorY),this.setCoords(),(ig=this.canvas)==null||ig.requestRenderAll()}updateInGroup(){reflowTextWithAnchor(this,()=>{this.dirty=!0,this.setCoords();let eg=this.group;for(;eg;)eg.dirty=!0,eg==null||eg.triggerLayout("childUpdate"),eg.setCoords(),eg=eg.group},this.splitByGrapheme)}_calcTextHeight(){const eg=this._textLines&&this._textLines.length||0,gg=this.fontSize*this.lineHeight,ig=(this.padding||0)*2;return eg*gg+ig}verticalTypeChange(){var eg;this.splitByGrapheme&&this.propsMinHeight&&(reflowTextWithAnchor(this,()=>{const gg=Math.max(this.height,this.propsMinHeight);this.height!==gg&&(this.height=gg),this.verticalType==="top"?this._getTopOffset=this._originGetTopOffset:this.verticalType==="vcenter"?this._getTopOffset=()=>{let ig=this._calcTextHeight();return(this.fontSize*this.lineHeight-this.fontSize)/2-ig/2}:this.verticalType==="bottom"&&(this._getTopOffset=()=>{const ig=this._calcTextHeight(),og=Math.max(ig,this.propsMinHeight)-ig;return this._originGetTopOffset()+og})},!0),this.setCoords(),(eg=this.canvas)==null||eg.requestRenderAll())}set(eg,gg){if(eg==="hasSetItalic")return this.hasSetItalic=!1,gg===!0?super.set("fontStyle","italic"):this;if(typeof eg=="object"&&eg){const ng={...eg};ng.left===null&&(ng.left=0),ng.top===null&&(ng.top=0),ng.scaleX===null&&(ng.scaleX=1),ng.scaleY===null&&(ng.scaleY=1),"hasSetItalic"in ng&&(ng.hasSetItalic===!0&&(ng.fontStyle="italic"),delete ng.hasSetItalic),ng.fixedSize&&(ng.arcEnable=!1,this.baseFontSize??(this.baseFontSize=ng.fontSize??this.fontSize)),this.fixedSize&&ng.fontSize!==void 0&&(this.baseFontSize=ng.fontSize);const og=this.shouldPreserveTextAnchor(ng)?reflowTextWithAnchor(this,()=>super.set(ng),this.splitByGrapheme):super.set(ng);return this.fixedSize&&this.updateFixedSize(),this.textAnchorReady&&("left"in ng||"top"in ng)&&captureTextAnchorPosition(this),og}(eg==="left"||eg==="top")&&gg===null&&(gg=0),(eg==="scaleX"||eg==="scaleY")&&gg===null&&(gg=1),eg==="fixedSize"&&gg&&(this.baseFontSize??(this.baseFontSize=this.fontSize),super.set("arcEnable",!1)),this.fixedSize&&eg==="fontSize"&&gg!==void 0&&(this.baseFontSize=gg),(eg==="fill"||eg==="stroke"||eg==="underline"||eg==="overline"||eg==="linethrough"||eg==="fontWeight"||eg==="fontStyle")&&(this.styles={});const ig=this.shouldPreserveTextAnchor(eg)?reflowTextWithAnchor(this,()=>super.set(eg,gg),this.splitByGrapheme):super.set(eg,gg);return this.fixedSize&&this.updateFixedSize(),this.textAnchorReady&&(eg==="left"||eg==="top")&&captureTextAnchorPosition(this),ig}getFixedTextWidth(eg){const ig=kn.createCanvasElement().getContext("2d");if(!ig)return 0;const ng=this.fontStyle==="italic"?"italic ":"",og=this.fontWeight==="bold"?"bold ":"";ig.font=`${ng}${og}${eg}px ${this.fontFamily}`;const ag=this.text.replace(/\u00A0/g," "),sg=(this.charSpacing||0)/1e3*eg;return ig.measureText(ag).width+Math.max(0,Array.from(ag).length-1)*sg}getFixedTextEllipsisOffset(eg){const gg=4*o.DPI/72;if(!this.fixedSize||this.splitByGrapheme||this.arcEnable||this.fontSize>gg+.01||this.getFixedTextWidth(gg)<=this.width)return null;const ig=this.text.replace(/\u00A0/g," "),ng="…",og=this.width;eg.save();const ag=eg.measureText(ng).width;let sg=0,Ig="";const Cg=(this.charSpacing||0)/1e3*this.fontSize;for(const lg of ig){const Ag=eg.measureText(lg).width+(Ig?Cg:0),rg=Ig||lg?Cg:0;if(sg+Ag+rg+ag>og)break;Ig+=lg,sg+=Ag}return eg.restore(),sg+(Ig?Cg:0)}_renderText(eg){const gg=this.getFixedTextEllipsisOffset(eg);if(gg===null){super._renderText(eg);return}const ig=this._getLeftOffset(),ng=this._getTopOffset(),og=ig+this._getLineLeftOffset(0),ag=this._getTopOffset()+this.getHeightOfLine(0)/this.lineHeight,sg=eg.textAlign,Ig=eg.fillStyle,Cg=eg.strokeStyle,lg=eg.lineWidth;eg.save(),eg.beginPath(),eg.rect(ig,ng,this.width,this.height),eg.clip(),super._renderText(eg),eg.restore(),eg.save(),eg.textAlign="left",eg.textBaseline="alphabetic",eg.fillStyle=Ig,eg.strokeStyle=Cg,eg.lineWidth=lg;const Ag=og+gg,rg=this.getHeightOfLine(0);eg.fillStyle="#fff",eg.fillRect(Ag,ag-rg/this.lineHeight,ig+this.width-Ag+this.fontSize*2,rg),eg.fillStyle=Ig,this.paintFirst==="stroke"&&this.stroke&&eg.strokeText("…",Ag,ag),eg.fillText("…",Ag,ag),this.paintFirst!=="stroke"&&this.stroke&&eg.strokeText("…",Ag,ag),eg.textAlign=sg,eg.restore()}updateFixedSize(){if(!this.fixedSize||this.splitByGrapheme||this.arcEnable||this.text===void 0)return;const eg=4*o.DPI/72,gg=Math.max(this.baseFontSize??this.fontSize,eg);this.baseFontSize=gg;const ig=this.width;let ng=gg;if(this.getFixedTextWidth(gg)>this.width)if(this.getFixedTextWidth(eg)>this.width)ng=eg;else{let og=eg,ag=gg;for(let sg=0;sg<20;sg+=1){const Ig=(og+ag)/2;this.getFixedTextWidth(Ig)<=this.width?og=Ig:ag=Ig}ng=og}this.fontSize!==ng&&super.set("fontSize",ng),this.width=ig,this.dirty=!0,this.verticalTypeChange()}applyFixedSizeScale(){if(!this.fixedSize)return;const eg=this.getExtraScale(),gg=this.scaleX/eg;gg!==1&&(reflowTextWithAnchor(this,()=>{this.width=Math.max(1,this.width*Math.abs(gg)),this.scaleX=eg}),this.updateFixedSize(),this.setCoords())}set locked(eg){super.locked=eg,this.editable=!eg}get locked(){return super.locked}_measureLine(eg){let gg=this._textLines[eg];return Array.isArray(gg)&&(gg=gg.map(ig=>ig.replace(" "," "))),this._textLines[eg]=gg,super._measureLine(eg)}getStandardSpaceWidth(eg=" ",gg="Arial"){const ng=kn.createCanvasElement().getContext("2d");let og=0;return ng&&(ng.font=`${this.fontSize}px ${gg}`,og=ng.measureText(eg).width),og}getTextWidth(eg="",gg=0,ig="Arial"){const og=kn.createCanvasElement().getContext("2d");let ag=0;return og&&(og.font=`${gg}px ${ig}`,ag=og.measureText(eg).width),ag}getTextHeight(eg="测",gg=!0){const ng=kn.createCanvasElement().getContext("2d");let og=0;if(ng){ng.font=`${this.fontSize}px ${this.fontFamily}`;let ag=ng.measureText(eg);og=ag.fontBoundingBoxAscent+ag.fontBoundingBoxDescent+(gg?Math.trunc(this.fontSize/3):0)}return og*this._textLines.length}_renderChars(eg,gg,ig,ng,og,ag){if(!ig.some(Ig=>myanmarCharacters.test(Ig))||this.charSpacing===0||this.path||!this.isEmptyStyles(ag)||!("letterSpacing"in gg)){super._renderChars(eg,gg,ig,ng,og,ag);return}gg.save();try{gg.letterSpacing=`${this._getWidthOfCharSpacing()}px`,this._renderChar(eg,gg,ag,0,ig.join(""),ng,og)}finally{gg.restore()}}_measureChar(eg,gg,ig,ng){if(eg!==" "&&eg!==" ")return super._measureChar(eg,gg,ig,ng);{const og=this.getStandardSpaceWidth(" ",this.fontFamily);return{width:og,kernedWidth:og}}}parseColor(eg){if(!eg)return null;if(eg.startsWith("#")){let ig=eg.slice(1);ig.length===3&&(ig=ig.split("").map(og=>og+og).join(""));const ng=parseInt(ig,16);return{r:ng>>16&255,g:ng>>8&255,b:ng&255,a:1}}const gg=eg.match(/rgba?\(([^)]+)\)/);if(gg){const[ig,ng,og,ag=1]=gg[1].split(",").map(sg=>Number(sg.trim()));return{r:ig,g:ng,b:og,a:ag}}return null}luminance({r:eg,g:gg,b:ig}){return .2126*eg+.7152*gg+.0722*ig}isDark(eg,gg=40){const ig=this.parseColor(eg);return ig?this.luminance(ig)<=gg:!1}_renderArcText(eg){const gg=this.text.replace(/\u00A0/g," "),ig=this.fontSize,ng=Math.abs(this.arcRadius),og=this.arcRadius>=0;eg.save(),eg.font=`${this.fontStyle==="italic"?"italic ":""}${this.fontWeight==="bold"?"bold ":""}${ig}px ${this.fontFamily}`,eg.fillStyle=this.fill||"#000000",eg.textAlign="center",eg.textBaseline="middle";const ag=(this.charSpacing||0)/1e3*ig,sg=[];let Ig=0;for(const ug of gg){const dg=eg.measureText(ug).width+ag;sg.push(dg),Ig+=dg}const Cg=Ig/ng,lg=ng-ng*Math.cos(Cg/2),Ag=og?ng-lg/2:-(ng-lg/2);let cg=(og?-Math.PI/2:Math.PI/2)-Cg/2;for(let ug=0;ug<gg.length;ug++){const dg=gg[ug],hg=sg[ug]/2,mg=cg+hg/ng,bg=Math.cos(mg)*ng,pg=Math.sin(mg)*ng;eg.save(),eg.translate(bg,Ag+pg),og?eg.rotate(mg+Math.PI/2):eg.rotate(mg-Math.PI/2),eg.fillText(dg,0,0),eg.restore(),cg+=sg[ug]/ng}eg.restore()}_getArcParams(){const eg=this.text.replace(/\u00A0/g," "),gg=this.fontSize,ig=Math.abs(this.arcRadius),ng=this.arcRadius>=0,ag=kn.createCanvasElement().getContext("2d");ag.font=`${this.fontStyle==="italic"?"italic ":""}${this.fontWeight==="bold"?"bold ":""}${gg}px ${this.fontFamily}`;const sg=(this.charSpacing||0)/1e3*gg,Ig=[];let Cg=0;for(const ug of eg){const dg=ag.measureText(ug).width+sg;Ig.push(dg),Cg+=dg}const lg=Cg/ig,Ag=ig-ig*Math.cos(lg/2),rg=ng?ig-Ag/2:-(ig-Ag/2),cg=ng?-Math.PI/2:Math.PI/2;return{text:eg,fontSize:gg,r:ig,bendUp:ng,charWidths:Ig,totalWidth:Cg,totalAngle:lg,sagitta:Ag,circleCenterOffsetY:rg,baseAngle:cg}}_getArcCursorInfo(eg){const{text:gg,r:ig,bendUp:ng,charWidths:og,totalAngle:ag,circleCenterOffsetY:sg,baseAngle:Ig}=this._getArcParams();let Cg=0;for(let hg=0;hg<Math.min(eg,gg.length);hg++)Cg+=og[hg]/ig;const lg=Ig-ag/2+Cg,Ag=Math.cos(lg)*ig,rg=Math.sin(lg)*ig,cg=Ag,ug=sg+rg,dg=ng?lg+Math.PI/2:lg-Math.PI/2;return{x:cg,y:ug,angle:dg}}_calcArcBoundingBox(){const{text:eg,r:gg,bendUp:ig,charWidths:ng,totalAngle:og,circleCenterOffsetY:ag,baseAngle:sg}=this._getArcParams(),Ig=this.fontSize,Cg=Ig/2+4;if(!eg.length)return{w:Ig+Cg*2,h:Ig*1.2+Cg*2};let lg=1/0,Ag=-1/0,rg=1/0,cg=-1/0,ug=sg-og/2;for(let mg=0;mg<eg.length;mg++){const bg=ug,pg=ug+ng[mg]/gg,fg=(bg+pg)/2,wg=Math.cos(fg)*gg,Gg=Math.sin(fg)*gg,Zg=wg,$g=ag+Gg,Bg=ig?fg+Math.PI/2:fg-Math.PI/2,Wg=Math.cos(Bg),yg=Math.sin(Bg),Ng=ng[mg]/2+Cg,vg=Ig/2+Cg,Sg=[{dx:-Ng,dy:-vg},{dx:Ng,dy:-vg},{dx:Ng,dy:vg},{dx:-Ng,dy:vg}];for(const{dx:Vg,dy:Xg}of Sg){const Yg=Zg+Vg*Wg-Xg*yg,Hg=$g+Vg*yg+Xg*Wg;Yg<lg&&(lg=Yg),Yg>Ag&&(Ag=Yg),Hg<rg&&(rg=Hg),Hg>cg&&(cg=Hg)}ug=pg}const dg=Ag-lg,hg=cg-rg;return{w:Math.max(dg,1),h:Math.max(hg,1)}}getMyanmarBottomOverflow(){if(this.fixedHeight&&this.splitByGrapheme)return 0;const eg=this._textLines.length-1,gg=this._textLines[eg];if(!(gg!=null&&gg.some(ag=>myanmarCharacters.test(ag))))return 0;const ng=kn.createCanvasElement().getContext("2d");if(!ng)return 0;ng.font=this._getFontDeclaration(this.getCompleteStyleDeclaration(eg,0));const og=ng.measureText(gg.join("")).actualBoundingBoxDescent;return Number.isFinite(og)?Math.max(0,og):0}initDimensions(){const eg=()=>{if(this.arcEnable&&!this.splitByGrapheme){this._splitText(),this._clearCache(),this.dirty=!0;const gg=this._calcArcBoundingBox();this.width=gg.w,this.height=gg.h}else{const gg=this.fixedSize?this.width:void 0,ig=this.fixedHeight&&this.splitByGrapheme?this.height:void 0;super.initDimensions(),gg!==void 0&&(this.width=gg,this.updateFixedSize()),ig!==void 0?this.height=ig:this.splitByGrapheme&&this.propsMinHeight&&(this.height=Math.max(this.height,this.propsMinHeight)),this.verticalLayout&&!this.splitByGrapheme&&(this.width=this.calcTextWidth()||this.width),this.height+=this.getMyanmarBottomOverflow()}};this.textAnchorReady&&this.textAnchorPosition&&!this.isNormalizingParagraphScale?reflowTextWithAnchor(this,eg,this.splitByGrapheme):eg()}_render(eg){this.withFixedHeightClip(eg,()=>{this.arcEnable&&!this.splitByGrapheme?this._renderArcText(eg):super._render(eg)})}__getCursorBoundariesOffsets(eg){if(this.arcEnable&&!this.splitByGrapheme){const{charIndex:gg}=this.get2DCursorLocation(eg),ig=this._getArcCursorInfo(gg);return{left:ig.x+this.width/2,top:ig.y+this.height/2}}return super.__getCursorBoundariesOffsets(eg)}_renderCursor(eg,gg,ig){if(this.arcEnable&&!this.splitByGrapheme){const{charIndex:ng}=this.get2DCursorLocation(ig),og=this._getArcCursorInfo(ng),ag=this.fontSize,sg=this.getObjectScaling().x*this.canvas.getZoom(),Ig=this.cursorWidth/sg;eg.save(),eg.fillStyle=this.cursorColor||this.fill||"#000000",eg.globalAlpha=this._currentCursorOpacity,eg.translate(og.x,og.y),eg.rotate(og.angle),eg.fillRect(-Ig/2,-ag/2,Ig,ag),eg.restore()}else this.withFixedHeightClip(eg,()=>{super._renderCursor(eg,gg,ig)})}withFixedHeightClip(eg,gg){if(!this.fixedHeight||!this.splitByGrapheme){gg();return}const ig=-this.height/2,ng=this.getFixedHeightClipBottom();eg.save();try{eg.beginPath(),eg.rect(-this.width/2,ig,this.width,Math.max(0,ng-ig)),eg.clip(),gg()}finally{eg.restore()}}getFixedHeightClipBottom(){const eg=this.height/2;let gg=this._getTopOffset(),ig=-this.height/2;for(let ng=0;ng<this._textLines.length;ng++){const og=this.getHeightOfLine(ng),ag=gg+og/this.lineHeight;if(ag>eg+.01)break;ig=ag,gg+=og}return Math.max(-this.height/2,ig)}getSelectionStartFromPointer(eg){if(this.arcEnable&&!this.splitByGrapheme){const gg=this.canvas.getScenePoint(eg).transform(kn.invertTransform(this.calcTransformMatrix())),{text:ig,r:ng,bendUp:og,charWidths:ag,totalAngle:sg,circleCenterOffsetY:Ig,baseAngle:Cg}=this._getArcParams();let lg=1/0,Ag=0,rg=Cg-sg/2;for(let cg=0;cg<=ig.length;cg++){const ug=rg,dg=Math.cos(ug)*ng,hg=Math.sin(ug)*ng,mg=dg,bg=Ig+hg,pg=gg.x-mg,fg=gg.y-bg,wg=pg*pg+fg*fg;wg<lg&&(lg=wg,Ag=cg),cg<ig.length&&(rg+=ag[cg]/ng)}return Math.min(Ag,this._text.length)}return super.getSelectionStartFromPointer(eg)}_renderSelection(eg,gg,ig){if(this.arcEnable&&!this.splitByGrapheme){const{text:ng,r:og,bendUp:ag,charWidths:sg,totalAngle:Ig,circleCenterOffsetY:Cg,baseAngle:lg}=this._getArcParams(),Ag=this.fontSize,rg=Math.min(gg.selectionStart,gg.selectionEnd),cg=Math.max(gg.selectionStart,gg.selectionEnd);eg.save(),eg.fillStyle=this.selectionColor||"rgba(0,0,255,0.3)";let ug=lg-Ig/2;for(let dg=0;dg<ng.length;dg++){const hg=ug,mg=ug+sg[dg]/og,bg=(hg+mg)/2;if(dg>=rg&&dg<cg){const pg=Math.cos(bg)*og,fg=Math.sin(bg)*og,wg=pg,Gg=Cg+fg,Zg=ag?bg+Math.PI/2:bg-Math.PI/2;eg.save(),eg.translate(wg,Gg),eg.rotate(Zg),eg.fillRect(-sg[dg]/2,-Ag/2,sg[dg],Ag),eg.restore()}ug=mg}eg.restore()}else this.withFixedHeightClip(eg,()=>{super._renderSelection(eg,gg,ig)})}render(eg){if(eg.shadowBlur=0,eg.shadowColor="transparent",eg.imageSmoothingEnabled=!1,eg.textRendering="geometricPrecision",this.isClearCopyTextStyle&&(this.styles={},this.isClearCopyTextStyle=!1),this.splitByGrapheme){let ig=this.width*this.scaleX,ng=this.height*this.scaleY,og=this.calcTextHeight();if(!this.fixedHeight&&ng<og&&(ng=og),this.hasSetSplit=!0,ig!==this.width||ng!==this.height||this.scaleY!==1){this.isNormalizingParagraphScale=!0;try{this.set({width:ig,height:ng,scaleX:1,scaleY:1})}finally{this.isNormalizingParagraphScale=!1}this.height=ng,this.propsMinHeight=this.height,this.setCoords()}}else if(this.arcEnable){this.propsMinHeight=0,this.hasSetSplit&&(this.hasSetSplit=!1);const ig=this._calcArcBoundingBox();(this.width!==ig.w||this.height!==ig.h||this.scaleX!==1||this.scaleY!==1)&&(reflowTextWithAnchor(this,()=>{this.set({width:ig.w,height:ig.h,scaleX:1,scaleY:1})}),this.setCoords()),this._forceClearCache=!0}else{this.propsMinHeight=0,this.hasSetSplit&&(this.hasSetSplit=!1);const ig=this.text.replace(/ /g," ");if(ig!==this.text&&(this.text=ig),this.fixedSize)this.applyFixedSizeScale(),this.updateFixedSize();else{let ng=eg.measureText(this.text);ng.width!==this.width&&this.set({width:ng.width})}this._forceClearCache=!0}const gg=this.getFixedTextEllipsisOffset(eg);this.objectCaching=gg===null&&this.charSpacing<=1e5&&this.text.length<=800,this.dirty=!0,super.render(eg)}toObject(eg){let gg=["propsMinHeight","verticalType","backgroundColor","isBgBlackColor","fromBarCodeID","fromBarCode2dID","connectBar2dMap","arcEnable","arcRadius","fixedSize","verticalLayout","horizontalLayoutWidth","fixedHeight","baseFontSize","extraScale","textAnchorX","textAnchorY","textAnchorPosition"];return super.toObject(eg?[...eg,...gg]:gg)}};aC.type="Text";let AText=aC;tt.setClass(AText);const AC=class AC extends AText{constructor(eg,gg){super("",gg),this.update=!0,this.reviewValueArgs=null,this.toStopDateUpdateBarcode=!1,this.fontSize=ptToPx$1(12),this.increaseYearVal=0,this.increaseMonthVal=0,this.increaseDayVal=0,this.charSpacing=1,this.fontFamily="微软雅黑",console.log("ACounter",eg),this.props=eg,this._props.mode==="3"&&this.updateText(),AC.isMode1Args(this._props.args)&&(this._props.args.nextValue=void 0),this.fontSize=gg.fontSize??this.fontSize,this.charSpacing=gg.charSpacing??this.charSpacing,this.fontFamily=gg.fontFamily??this.fontFamily,this.increaseYearVal=gg.increaseYearVal??this.increaseYearVal,this.increaseMonthVal=gg.increaseMonthVal??this.increaseMonthVal,this.increaseDayVal=gg.increaseDayVal??this.increaseDayVal}render(eg){console.log("_render======"),this.updateText(),super.render(eg)}reviewRecover(){if(this._props.mode==="1"&&AC.isMode1Args(this._props.args)&&this.reviewValueArgs){this._props.args=this.reviewValueArgs,this.reviewValueArgs=null;const eg=this._props.args,gg=formatCounterValue(eg);this.text=(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:""),this.dirty=!1,this.update=!1,this._forceClearCache=!0}}countCurrent(){if(this._props.mode==="1"){const eg=this._props.args;if(!eg.value&&eg.value!==0)return"";const gg=formatCounterValue(eg);return(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:"")}return""}countNext(eg="print"){if(this._props.mode==="1"&&AC.isMode1Args(this._props.args)){const gg=this._props.args;if(!gg.value&&gg.value!==0)return;eg==="review"&&!this.reviewValueArgs&&(this.reviewValueArgs={...gg});const ig=formatCounterValue(gg);this.text=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:"");const ng=getNextCounterValue(gg);ng!==null&&(gg.value=ng,console.log("update value f",gg.value)),this.update=!0,this.dirty=!0,this._forceClearCache=!0}}updateText({isUpdateBarCodeDate:eg=!0}={}){if(this.update&&this._props.mode==="1")if(AC.isMode1Args(this._props.args)){const gg=this._props.args;if(!gg.value&&gg.value!==0)return;const ig=formatCounterValue(gg);this.text=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:""),this.dirty=!0,this._forceClearCache=!0,console.log("updateText",this.text,gg)}else return;else if(this._props.mode==="2")if(AC.isMode2Args(this._props.args)){if(!this.toStopDateUpdateBarcode){const gg=formatDate(this._props.args.format,{years:this.increaseYearVal,months:this.increaseMonthVal,days:this.increaseDayVal});console.log("formatted",this._props.args.format,gg),this.text=gg,this.dirty=!0,this._forceClearCache=!0,eg&&handleConcatBarcode2d(this.connectBar2dMap,this.canvas,!1,{type:this.type,data:this._props.mode})}}else return;else this.update&&this._props.mode==="3"&&AC.isMode3Args(this._props.args)&&(this.text=this._props.args.text,this.dirty=!0,this._forceClearCache=!0);this.set("dirty",!0),this.update&&(this.initDimensions(),this.setCoords(),this.update=!1,this.canvas&&this._props.mode!=="2"&&(handleConcatBarcode2d(this.connectBar2dMap,this.canvas),this.canvas.fire("custom:object:changed",{target:this})))}set(eg,gg){return super.set(eg,gg)}set props(eg){this.editable=eg.mode==="3",this._props=eg,this.dirty=!0,this.update=!0}get props(){return this._props}static isMode1Args(eg){return"value"in eg}static isMode2Args(eg){return"format"in eg}static isMode3Args(eg){return"text"in eg}toObject(eg){AC.isMode3Args(this._props.args)&&(this._props.args.text=this.text);let gg=["connectBar2dMap","increaseYearVal","increaseMonthVal","increaseDayVal"];return super.toObject(eg?[...eg,"_props",...gg]:["_props",...gg])}};AC.type="Counter";let ACounter=AC;ACounter.fromObject=tg=>ACounter._fromObject(tg,{extraParam:"_props"}),tt.setClass(ACounter),tt.setSVGClass(ACounter);const Yc=class Yc extends na{constructor(eg,gg){super(eg,gg),this.imgScaleType="1",this.originRatio=0,this.setGrayFilter=!1,this.isScaleOtherSidedys=!1,this.isSetSharpen=!1,this.imageAlign="leftTop",this.imageAnchorMode="legacy",this.imageAnchorX="left",this.imageAnchorY="top",this.customExportFields={varnish:"none"},this.prevCoordsPoints=null,this.gasolineLayer="none",this.noSetOtherPrevCoordsPoints=!1,this.imageSource="",this.imageSourceType="unsupported",this.databaseImageEnabled=!1,this.customExportFields=gg.customExportFields??this.customExportFields,gg.imgScaleType&&(this.imgScaleType=gg.imgScaleType),gg.setGrayFilter&&(this.setGrayFilter=gg.setGrayFilter),this.isScaleOtherSidedys=gg.isScaleOtherSidedys??this.isScaleOtherSidedys,this.isSetSharpen=gg.isSetSharpen??this.isSetSharpen,this.imageAlign=gg.imageAlign??this.imageAlign,this.imageAnchorMode=gg.imageAnchorMode??this.imageAnchorMode,this.imageAnchorX=gg.imageAnchorX??this.imageAnchorX,this.imageAnchorY=gg.imageAnchorY??this.imageAnchorY,this.prevCoordsPoints=gg.prevCoordsPoints??this.prevCoordsPoints,this.gasolineLayer=gg.gasolineLayer??this.gasolineLayer,this.imageSource=gg.imageSource??this.imageSource,this.imageSourceType=gg.imageSourceType??this.imageSourceType,this.databaseImageEnabled=gg.databaseImageEnabled??this.databaseImageEnabled}async setSrc(eg,gg){const ig=this.getScaledWidth(),ng=this.getScaledHeight();await super.setSrc(eg,gg),(gg==null?void 0:gg.imageSource)!==void 0&&(this.imageSource=gg.imageSource);const og=this._element,ag=og.naturalWidth||og.width,sg=og.naturalHeight||og.height,Ig=ag/sg;let Cg=this.imgScaleType;(Cg==="2"||Cg==="3")&&(Cg=Ig>1?"3":(Ig<1,"2"));let lg=ig,Ag=ng;return Cg==="2"?lg=ng*Ig:Cg==="3"&&(Ag=ig/Ig),this.set({width:lg,height:Ag,scaleX:1,scaleY:1,imgScaleType:Cg,isScaleOtherSidedys:!1}),this.setCoords(),this}refreshAlignCoords(eg=203){var gg;if(this.prevCoordsPoints){this.setCoords();let ig=o.DPI/eg;const{bl:ng,br:og,tl:ag,tr:sg}=this.aCoords,{bl:Ig,br:Cg,tl:lg,tr:Ag}=this.prevCoordsPoints;Ig.x=Ig.x*ig,Ig.y=Ig.y*ig,Cg.x=Cg.x*ig,Cg.y=Cg.y*ig,lg.x=lg.x*ig,lg.y=lg.y*ig,Ag.x=Ag.x*ig,Ag.y=Ag.y*ig;const rg={x:0,y:0};switch(this.imageAlign){case"leftTop":break;case"leftBottom":rg.x=Ig.x-ng.x,rg.y=Ig.y-ng.y;break;case"leftCenter":let cg={x:ng.x,y:(ng.y-ag.y)/2},ug={x:Ig.x,y:(Ig.y-lg.y)/2};rg.x=ug.x-cg.x,rg.y=ug.y-cg.y;break;case"topCenter":let dg={x:(sg.x-ag.x)/2,y:sg.y},hg={x:(Ag.x-lg.x)/2,y:Ag.y};rg.x=hg.x-dg.x,rg.y=hg.y-dg.y;break;case"rightCenter":let mg={x:sg.x,y:(og.y-sg.y)/2},bg={x:Ag.x,y:(Cg.y-Ag.y)/2};rg.x=bg.x-mg.x,rg.y=bg.y-mg.y;break;case"bottomCenter":let pg={x:(og.x-ng.x)/2,y:og.y},fg={x:(Cg.x-Ig.x)/2,y:Cg.y};rg.x=fg.x-pg.x,rg.y=fg.y-pg.y;break;case"center":let wg={x:(sg.x-ag.x)/2,y:(ng.y-ag.y)/2},Gg={x:(Ag.x-lg.x)/2,y:(Ig.y-lg.y)/2};rg.x=Gg.x-wg.x,rg.y=Gg.y-wg.y;break;case"rightTop":rg.x=Ag.x-sg.x,rg.y=Ag.y-sg.y;break;case"rightBottom":rg.x=Cg.x-og.x,rg.y=Cg.y-og.y;break}this.set({left:this.left+rg.x,top:this.top+rg.y}),this.setCoords(),(gg=this.canvas)==null||gg.requestRenderAll()}}_render(eg){const gg=this._element;if(!gg)return;const ig=this._filterScalingX,ng=this._filterScalingY,og=Math.max(this.cropX,0),ag=Math.max(this.cropY,0),sg=gg.naturalWidth||gg.width,Ig=gg.naturalHeight||gg.height,Cg=og*ig,lg=ag*ng;this.originRatio=sg/Ig,eg.save(),eg.beginPath(),eg.rect(-this.width/2,-this.height/2,this.width,this.height),eg.clip(),this.fill&&(eg.fillStyle=this.fill,eg.fillRect(-this.width/2,-this.height/2,this.width,this.height)),this.stroke&&this.strokeWidth&&(eg.strokeStyle=this.stroke,eg.lineWidth=this.strokeWidth,withObjectStrokeDash(eg,this,()=>eg.strokeRect(-this.width/2,-this.height/2,this.width,this.height))),eg.imageSmoothingEnabled=!0,eg.imageSmoothingQuality="high",eg.drawImage(gg,Cg,lg,sg,Ig,-this.width/2,-this.height/2,this.width,this.height),eg.restore();const Ag=this.filters.findIndex(rg=>rg.type==="Grayscale");if(this.setGrayFilter&&Ag<0){const rg=new bh.Grayscale;this.filters.push(rg)}else!this.setGrayFilter&&Ag>=0&&this.filters.splice(Ag,1);this.applyFilters(),this.canvas.leRenderEnv!=="transform"&&!this.noSetOtherPrevCoordsPoints&&(this.prevCoordsPoints=this.aCoords)}set(eg,gg){return super.set(eg,gg)}toObject(eg){let gg=["imgScaleType","setGrayFilter","isScaleOtherSidedys","isSetSharpen","imageAlign","imageAnchorMode","imageAnchorX","imageAnchorY","prevCoordsPoints","gasolineLayer","imageSource","imageSourceType","databaseImageEnabled","databaseImageFrame","databaseSheet","databaseColumn","databaseIndex"];return super.toObject(eg?[...eg,...gg]:gg)}fromObject(eg){return Yc._fromObject(eg)}};Yc.type="Image";let AImage=Yc;tt.setClass(AImage),tt.setSVGClass(AImage);const LEGACY_IMAGE_ANCHORS={leftTop:{x:"left",y:"top"},topCenter:{x:"center",y:"top"},rightTop:{x:"right",y:"top"},leftCenter:{x:"left",y:"center"},center:{x:"center",y:"center"},rightCenter:{x:"right",y:"center"},leftBottom:{x:"left",y:"bottom"},bottomCenter:{x:"center",y:"bottom"},rightBottom:{x:"right",y:"bottom"}},isAnchorX=tg=>tg==="left"||tg==="center"||tg==="right",isAnchorY=tg=>tg==="top"||tg==="center"||tg==="bottom";function imageAlignToOrigin(tg){return LEGACY_IMAGE_ANCHORS[String(tg)]||LEGACY_IMAGE_ANCHORS.leftTop}function originToImageAlign(tg){const eg=Object.entries(LEGACY_IMAGE_ANCHORS).find(([,gg])=>gg.x===tg.x&&gg.y===tg.y);return(eg==null?void 0:eg[0])||"leftTop"}function isNativeImageAnchor(tg){return((tg==null?void 0:tg.imageAnchorMode)==="origin"||(tg==null?void 0:tg.imageAnchorMode)==="metadata")&&isAnchorX(tg.imageAnchorX)&&isAnchorY(tg.imageAnchorY)}function getImageAnchor(tg){return isNativeImageAnchor(tg)?{x:tg.imageAnchorX,y:tg.imageAnchorY}:imageAlignToOrigin(tg==null?void 0:tg.imageAlign)}function captureObjectAnchor(tg,eg=getImageAnchor(tg)){var gg;return(gg=tg==null?void 0:tg.getPointByOrigin)==null?void 0:gg.call(tg,eg.x,eg.y)}function setObjectAnchor(tg,eg,gg){var ng;const ig=captureObjectAnchor(tg,{x:eg,y:gg});return tg.set({imageAnchorMode:"metadata",imageAnchorX:eg,imageAnchorY:gg,imageAlign:originToImageAlign({x:eg,y:gg})}),(ng=tg.canvas)==null||ng.fire("custom:object:history",{target:tg,action:"history:update"}),ig}const cd=class cd extends ho{constructor(){super(...arguments),this.perPixelTargetFind=!0}_render(eg){eg.beginPath();const{width:gg,height:ig}=this,ng=gg/2,og=ig/2;eg.ellipse(0,0,ng,og,0,0,Math.PI*2),this._renderPaintInOrder(eg)}set(eg,gg){return super.set(eg,gg)}};cd.type="Circle";let ACircle=cd;tt.setClass(ACircle);class ARect extends Er{constructor(eg){super(eg),this.perPixelTargetFind=!0}set(eg,gg){return super.set(eg,gg)}}tt.setClass(ARect);class ATriangle extends vo{constructor(eg={}){super(eg),this.perPixelTargetFind=!0}set(eg,gg){return super.set(eg,gg)}}tt.setClass(ATriangle),tt.setSVGClass(ATriangle);class ALine extends mo{constructor(eg,gg={}){super(eg,gg),this.perPixelTargetFind=!0}set(eg,gg){return super.set(eg,gg)}}tt.setClass(ALine);const su=class su extends na{constructor(){super(...arguments),this.hasControls=!1,this.selectable=!1,this.evented=!0,this.hoverCursor="pointer"}_renderFill(eg){const gg=this._element;if(!gg)return;const ig=this._filterScalingX,ng=this._filterScalingY,og=this.width,ag=this.height,sg=Math.max(this.cropX,0),Ig=Math.max(this.cropY,0),Cg=gg.naturalWidth||gg.width,lg=gg.naturalHeight||gg.height,Ag=sg*ig,rg=Ig*ng,cg=-og/2,ug=-ag/2;gg&&eg.drawImage(gg,Ag,rg,Cg,lg,cg,ug,og,ag)}};su.type="Rfid";let RfidIcon=su;tt.setClass(RfidIcon),tt.setSVGClass(RfidIcon);const Iu=class Iu extends No{constructor(eg,gg){if(super(eg,gg),this.hasSetSplit=!1,this.objectCaching=!0,this.hasSetItalic=!1,this.isClearCopyTextStyle=!1,this.propsMinHeight=0,this.splitByGrapheme=!0,this.customExportFields={varnish:"none"},this.fontFamily="微软雅黑",this._renderTimer=null,this.verticalType="top",this.currentFontLevel=0,this.baseFontSize=118,this.splitByGrapheme=!0,this._originGetTopOffset=this._getTopOffset?this._getTopOffset.bind(this):()=>0,this.fontFamily=gg.fontFamily??this.fontFamily,gg.hasSetItalic&&gg.fontStyle!=="italic"&&(this.fontStyle="italic",gg.skewX===-15&&(this.skewX=0)),gg.propsMinHeight){this.propsMinHeight=gg.propsMinHeight;let ig=Math.max(this.height,this.propsMinHeight);this.height=ig}gg.verticalType&&(this.verticalType=gg.verticalType),this.customExportFields=gg.customExportFields??this.customExportFields,this.on("modified",()=>{this.verticalTypeChange()}),this.on("changed",()=>{this.verticalTypeChange()}),this.verticalTypeChange()}_calcTextHeight(){const eg=this._textLines&&this._textLines.length||0,gg=this.fontSize*this.lineHeight,ig=(this.padding||0)*2;return eg*gg+ig}_handleDotLineBreak(eg,gg){var ig;if(eg.includes("·")){const ng=eg.indexOf("·"),og=/[\u4e00-\u9fa5]/g,ag=((ig=eg.substring(ng+1).match(og))==null?void 0:ig.length)||0;if(this.charSpacing=1,ng==2&&(ag==2||ag==1))return[eg];let sg=0;if(ag>=11||ng>=10?sg=5:ag>=10||ng>=9?sg=4:ag>=9||ng>=8?sg=3:ag>=8||ng>=7?sg=2:ag>=7||ng>=6?sg=1:sg=0,sg!==this.currentFontLevel){switch(sg){case 5:this.fontSize=64;break;case 4:this.fontSize=70;break;case 3:this.fontSize=78;break;case 2:this.fontSize=88;break;case 1:this.fontSize=100;break;case 0:this.fontSize=this.baseFontSize??118;break}this.currentFontLevel=sg}const Ig=eg.substring(0,ng+1),Cg=eg.substring(ng+1).trim();return Cg?[Ig,Cg]:[eg]}else eg.length<=4?(this.fontSize=this.baseFontSize??118,this.currentFontLevel=0,eg.length===2?this.charSpacing=800:eg.length===3?this.charSpacing=300:eg.length===4&&(this.charSpacing=300)):(this.charSpacing=1,this.fontSize=this.baseFontSize,this.currentFontLevel=0);return[...gg]}_wrapText(eg,gg){if(this.isClearCopyTextStyle&&(this.styles={},this.verticalTypeChange()),this.splitByGrapheme){const ig=o.DPI??96,ag=3*.393701*ig,sg=this.text;let Ig=[...eg];return Ig=this._handleDotLineBreak(sg,eg),this.width!==ag&&(this.width=ag,this.setCoords(),this._renderTimer&&clearTimeout(this._renderTimer),this._renderTimer=setTimeout(()=>{var Cg;(Cg=this.canvas)==null||Cg.requestRenderAll()},0)),super._wrapText(Ig,ag)}else return super._wrapText(eg,gg)}verticalTypeChange(){var gg;if(!this.splitByGrapheme||!this.propsMinHeight)return;const eg=Math.max(this._calcTextHeight(),this.propsMinHeight);this.height!==eg&&(this.height=eg),this.verticalType==="top"?this._getTopOffset=this._originGetTopOffset:this.verticalType==="vcenter"?this._getTopOffset=()=>{let ig=this._calcTextHeight();return(this.fontSize*this.lineHeight-this.fontSize)/2-ig/2}:this.verticalType==="bottom"&&(this._getTopOffset=()=>{const ig=this._calcTextHeight(),og=Math.max(ig,this.propsMinHeight)-ig;return this._originGetTopOffset()+og}),this.setCoords(),(gg=this.canvas)==null||gg.requestRenderAll()}set(eg,gg){if(eg==="hasSetItalic")return this.hasSetItalic=!1,gg===!0?super.set("fontStyle","italic"):this;if(typeof eg=="object"&&eg){const ig={...eg};return"hasSetItalic"in ig&&(ig.hasSetItalic===!0&&(ig.fontStyle="italic"),delete ig.hasSetItalic),super.set(ig)}return(eg==="fill"||eg==="stroke"||eg==="underline"||eg==="overline"||eg==="linethrough"||eg==="fontWeight"||eg==="fontStyle")&&(this.styles={}),super.set(eg,gg)}set locked(eg){super.locked=eg,this.editable=!eg}get locked(){return super.locked}_measureLine(eg){let gg=this._textLines[eg];return Array.isArray(gg)&&(gg=gg.map(ig=>ig.replace(" "," "))),this._textLines[eg]=gg,super._measureLine(eg)}getStandardSpaceWidth(eg=" ",gg="Arial"){const ng=kn.createCanvasElement().getContext("2d");let og=0;return ng&&(ng.font=`${this.fontSize}px ${gg}`,og=ng.measureText(eg).width),og}getTextWidth(eg="",gg=0,ig="Arial"){const og=kn.createCanvasElement().getContext("2d");let ag=0;return og&&(og.font=`${gg}px ${ig}`,ag=og.measureText(eg).width),ag}getTextHeight(eg="测",gg=!0){const ng=kn.createCanvasElement().getContext("2d");let og=0;if(ng){ng.font=`${this.fontSize}px ${this.fontFamily}`;let ag=ng.measureText(eg);og=ag.fontBoundingBoxAscent+ag.fontBoundingBoxDescent+(gg?Math.trunc(this.fontSize/3):0)}return og*this._textLines.length}_measureChar(eg,gg,ig,ng){if(eg!==" "&&eg!==" ")return super._measureChar(eg,gg,ig,ng);{const og=this.getStandardSpaceWidth(" ",this.fontFamily);return{width:og,kernedWidth:og}}}render(eg){if(eg.shadowBlur=0,eg.shadowColor="transparent",eg.imageSmoothingEnabled=!1,this.isClearCopyTextStyle&&(this.styles={}),this.splitByGrapheme){let gg=this.width*this.scaleX,ig=this.height*this.scaleY,ng=this.getTextHeight();ig<ng&&(ig=ng),this.hasSetSplit=!0,(gg!==this.width||ig!==this.height||this.scaleY!==1)&&(this.set({width:gg,height:ig,scaleX:1,scaleY:1}),this.height=ig,this.propsMinHeight=this.height,this.setCoords())}else{this.propsMinHeight=0,this.hasSetSplit&&(this.hasSetSplit=!1);const gg=this.text.replace(/ /g," ");gg!==this.text&&(this.text=gg);let ig=eg.measureText(this.text);ig.width!==this.width&&this.set({width:ig.width}),this._forceClearCache=!0}this.charSpacing>1e5?this.objectCaching=!1:this.objectCaching=!0,this.dirty=!0,super.render(eg)}toObject(eg){let gg=["propsMinHeight","verticalType","customExportFields"];return super.toObject(eg?[...eg,...gg]:gg)}};Iu.type="TextName";let ATextName=Iu;tt.setClass(ATextName);const lu=class lu extends Er{constructor(eg={}){const{rows:gg,columns:ig,tableTexts:ng,tableCellStyles:og,tableCellBorders:ag,tableCellSpans:sg,columnWidths:Ig,rowHeights:Cg,fontSize:lg,fontFamily:Ag,fontWeight:rg,fontStyle:cg,underline:ug,linethrough:dg,charSpacing:hg,lineHeight:mg,textAlign:bg,verticalType:pg,...fg}=eg;super({fill:"#000000FF",backgroundColor:"#FFFFFF00",stroke:"#000000",strokeWidth:1,...fg}),this.perPixelTargetFind=!0,this.rows=2,this.columns=2,this.tableTexts=[],this.tableCellStyles=[],this.tableCellBorders=[],this.tableCellSpans=[],this.columnWidths=[],this.rowHeights=[],this.fontSize=24,this.fontFamily="微软雅黑",this.fontWeight="normal",this.fontStyle="normal",this.underline=!1,this.linethrough=!1,this.charSpacing=0,this.lineHeight=1.2,this.textAlign="center",this.verticalType="vcenter",this.strokeUniform=!0,this.selectedCellIndex=null,this.editingTextarea=null,this.keepEditingOnNextBlur=!1,this.editingPointerDownHandler=null,this.editingViewportChangeHandler=null,this.editingResizeObserver=null,this.editingUpdateFrame=0,this.rows=this.normalizeCount(gg,2),this.columns=this.normalizeCount(ig,2),this.tableTexts=[...ng||[]],this.tableCellStyles=[...og||[]],this.tableCellBorders=[...ag||[]],this.tableCellSpans=[...sg||[]],this.columnWidths=[...Ig||[]],this.rowHeights=[...Cg||[]],this.syncTextCount(),this.applyTextOptions({fontSize:lg,fontFamily:Ag,fontWeight:rg,fontStyle:cg,underline:ug,linethrough:dg,charSpacing:hg,lineHeight:mg,textAlign:bg,verticalType:pg}),this.on("scaling",wg=>this.resizeDuringScaling(wg)),this.on("modified",()=>{this.scaleAnchor=void 0}),this.on("removed",()=>{this.removeEditingTextarea(!1)})}get isEditing(){return this.editingTextarea!==null}set(eg,gg){var ng,og,ag,sg,Ig,Cg,lg;if(typeof eg=="object"&&eg)return Object.keys(eg).forEach(Ag=>this.set(Ag,eg[Ag])),this;if(eg==="rows"||eg==="columns"){this.removeEditingTextarea(!0);const Ag=this.normalizeCount(gg,eg==="rows"?this.rows:this.columns),rg=this.rows,cg=this.columns,ug=eg==="rows"?Ag:this.rows,dg=eg==="columns"?Ag:this.columns;return this.resizeByCountChange(eg,Ag),this.remapCellData(rg,cg,ug,dg),this[eg]=Ag,this.syncTextCount(),this.selectedCellIndex!==null&&this.selectedCellIndex>=this.rows*this.columns&&(this.selectedCellIndex=null),this.dirty=!0,this.setCoords(),(ng=this.canvas)==null||ng.requestRenderAll(),this}if(eg==="tableTexts")return this.tableTexts=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(og=this.canvas)==null||og.requestRenderAll(),this;if(eg==="tableCellStyles")return this.tableCellStyles=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(ag=this.canvas)==null||ag.requestRenderAll(),this;if(eg==="tableCellBorders")return this.tableCellBorders=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(sg=this.canvas)==null||sg.requestRenderAll(),this;if(eg==="tableCellSpans")return this.tableCellSpans=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(Ig=this.canvas)==null||Ig.requestRenderAll(),this;if(eg==="columnWidths"||eg==="rowHeights")return this[eg]=Array.isArray(gg)?[...gg]:[],this.syncTextCount(),this.dirty=!0,(Cg=this.canvas)==null||Cg.requestRenderAll(),this;const ig=super.set(eg,gg);return this.isTextStyleKey(eg)&&(this.dirty=!0,(lg=this.canvas)==null||lg.requestRenderAll(),this.updateEditingTextarea()),ig}toObject(eg){const gg=["rows","columns","tableTexts","tableCellStyles","tableCellBorders","tableCellSpans","columnWidths","rowHeights","fontSize","fontFamily","fontWeight","fontStyle","underline","linethrough","charSpacing","lineHeight","textAlign","verticalType","backgroundColor"];return super.toObject(eg?[...eg,...gg]:gg)}normalizeCount(eg,gg){const ig=Math.floor(Number(eg));return Number.isFinite(ig)?Math.min(Math.max(ig,1),50):gg}resizeDuringScaling(eg){const gg=eg==null?void 0:eg.transform;if(!gg)return;const ig=gg.corner,ng=["ml","tl","bl"].includes(ig),og=["mr","tr","br"].includes(ig),ag=["mt","tl","tr"].includes(ig),sg=["mb","bl","br"].includes(ig);if(!this.scaleAnchor){const Ag=ng?"right":og?"left":"center",rg=ag?"bottom":sg?"top":"center";this.scaleAnchor={point:this.getPointByOrigin(Ag,rg),originX:Ag,originY:rg}}this.width=Math.max(1,(this.width||1)*Math.abs(this.scaleX||1)),this.height=Math.max(1,(this.height||1)*Math.abs(this.scaleY||1)),this.scaleX=1,this.scaleY=1;const{point:Ig,originX:Cg,originY:lg}=this.scaleAnchor;if(this.group){const Ag=kn.invertTransform(this.group.calcTransformMatrix()),rg=kn.transformPoint(Ig,Ag);this.setPositionByOrigin(rg,Cg,lg)}else this.setPositionByOrigin(Ig,Cg,lg);this.updateEditingTextarea(),this.dirty=!0,this.setCoords()}resizeByCountChange(eg,gg){if(eg==="columns"){const ig=this.width||0,ng=Array.from({length:this.columns},(Cg,lg)=>(this.columnWidths[lg]||1/this.columns)*ig),og=ng.reduce((Cg,lg)=>Cg+lg,0)/(ng.length||1)||ig/(this.columns||1)||1,ag=Array.from({length:gg},(Cg,lg)=>lg<ng.length?ng[lg]:og),sg=ag.reduce((Cg,lg)=>Cg+lg,0);this.width=sg;const Ig=sg||1;this.columnWidths=ag.map(Cg=>Cg/Ig)}if(eg==="rows"){const ig=this.height||0,ng=Array.from({length:this.rows},(Cg,lg)=>(this.rowHeights[lg]||1/this.rows)*ig),og=ng.reduce((Cg,lg)=>Cg+lg,0)/(ng.length||1)||ig/(this.rows||1)||1,ag=Array.from({length:gg},(Cg,lg)=>lg<ng.length?ng[lg]:og),sg=ag.reduce((Cg,lg)=>Cg+lg,0);this.height=sg;const Ig=sg||1;this.rowHeights=ag.map(Cg=>Cg/Ig)}}remapCellData(eg,gg,ig,ng){if(eg===ig&&gg===ng)return;const og=Array.isArray(this.tableTexts)?[...this.tableTexts]:[],ag=Array.isArray(this.tableCellStyles)?[...this.tableCellStyles]:[],sg=Array.isArray(this.tableCellBorders)?[...this.tableCellBorders]:[],Ig=Array.isArray(this.tableCellSpans)?[...this.tableCellSpans]:[],Cg=ig*ng;this.tableTexts=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;return rg>=eg||cg>=gg?"":og[rg*gg+cg]||""}),this.tableCellStyles=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;return rg>=eg||cg>=gg?{}:{...ag[rg*gg+cg]||{}}}),this.tableCellBorders=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;return rg>=eg||cg>=gg?{}:{...sg[rg*gg+cg]||{}}}),this.tableCellSpans=Array.from({length:Cg},(lg,Ag)=>{const rg=Math.floor(Ag/ng),cg=Ag%ng;if(rg>=eg||cg>=gg)return this.createDefaultCellSpan();const ug=Ig[rg*gg+cg]||{},dg=Number(ug.masterIndex),hg=Number.isFinite(dg)&&dg>=0?this.mapOldCellIndex(dg,gg,ig,ng):null;return{...this.createDefaultCellSpan(),...ug,masterIndex:hg}}),this.selectedCellIndex!==null&&(this.selectedCellIndex=this.mapOldCellIndex(this.selectedCellIndex,gg,ig,ng))}mapOldCellIndex(eg,gg,ig,ng){const og=Math.floor(eg/gg),ag=eg%gg;return og>=ig||ag>=ng?null:og*ng+ag}createDefaultCellSpan(){return{rowSpan:1,colSpan:1,hidden:!1,masterIndex:null}}getCellData(eg){return{text:this.tableTexts[eg]||"",style:{...this.tableCellStyles[eg]||{}},border:{...this.tableCellBorders[eg]||{}},span:{...this.createDefaultCellSpan(),...this.tableCellSpans[eg]||{}}}}applyStructureChange(eg,gg,ig,ng,og,ag,sg,Ig,Cg){var ug,dg;const lg=this.getPointByOrigin(Ig,Cg),Ag=eg*gg,rg=new Map;for(let hg=0;hg<eg;hg++)for(let mg=0;mg<gg;mg++){const bg=ig(hg,mg);bg!==null&&rg.set(bg,hg*gg+mg)}const cg=Array.from({length:Ag},(hg,mg)=>{const bg=Math.floor(mg/gg),pg=mg%gg,fg=ig(bg,pg);if(fg===null)return null;const wg=this.getCellData(fg),Gg=Number(wg.span.masterIndex);return wg.span.masterIndex=Number.isFinite(Gg)&&Gg>=0?rg.get(Gg)??null:null,wg});if(this.rows=eg,this.columns=gg,this.width=ag.reduce((hg,mg)=>hg+mg,0),this.height=sg.reduce((hg,mg)=>hg+mg,0),this.columnWidths=this.normalizeRatios(ag,gg),this.rowHeights=this.normalizeRatios(sg,eg),this.tableTexts=cg.map(hg=>(hg==null?void 0:hg.text)||""),this.tableCellStyles=cg.map(hg=>(hg==null?void 0:hg.style)||{}),this.tableCellBorders=cg.map(hg=>(hg==null?void 0:hg.border)||{}),this.tableCellSpans=cg.map(hg=>(hg==null?void 0:hg.span)||this.createDefaultCellSpan()),this.selectedCellIndex=Math.min(ng,eg-1)*gg+Math.min(og,gg-1),this.group){const hg=kn.invertTransform(this.group.calcTransformMatrix());this.setPositionByOrigin(kn.transformPoint(lg,hg),Ig,Cg)}else this.setPositionByOrigin(lg,Ig,Cg);this.syncTextCount(),this.dirty=!0,this.setCoords(),(ug=this.canvas)==null||ug.requestRenderAll(),(dg=this.canvas)==null||dg.fire("object:modified",{target:this,action:"modifyprops"})}insertColumn(eg,gg="right"){if(this.columns>=50)return;const ig=!!this.editingTextarea,ng=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const og=Math.min(Math.max(eg,0),this.columns),ag=this.columns,sg=this.columnWidths.map(Ag=>Ag*(this.width||0)),Ig=Math.min(og,ag-1),Cg=sg[Ig]||(this.width||1)/Math.max(ag,1);sg.splice(og,0,Cg);const lg=this.rowHeights.map(Ag=>Ag*(this.height||0));this.applyStructureChange(this.rows,ag+1,(Ag,rg)=>{if(rg===og)return null;const cg=rg>og?rg-1:rg;return Ag*ag+cg},Math.floor(ng/ag),ng%ag+(gg==="left"?1:0),sg,lg,gg==="left"?"right":"left","top"),this.restoreEditingTextareaAfterStructureChange(ig)}insertRow(eg,gg="down"){if(this.rows>=50)return;const ig=!!this.editingTextarea,ng=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const og=Math.min(Math.max(eg,0),this.rows),ag=this.rows,sg=this.columns,Ig=this.rowHeights.map(rg=>rg*(this.height||0)),Cg=Math.min(og,ag-1),lg=Ig[Cg]||(this.height||1)/Math.max(ag,1);Ig.splice(og,0,lg);const Ag=this.columnWidths.map(rg=>rg*(this.width||0));this.applyStructureChange(ag+1,sg,(rg,cg)=>rg===og?null:(rg>og?rg-1:rg)*sg+cg,Math.floor(ng/sg)+(gg==="up"?1:0),ng%sg,Ag,Ig,"left",gg==="up"?"bottom":"top"),this.restoreEditingTextareaAfterStructureChange(ig)}deleteColumn(eg){if(this.columns<=1)return;const gg=!!this.editingTextarea,ig=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const ng=Math.min(Math.max(eg,0),this.columns-1),og=this.columns,ag=this.columnWidths.map(Ig=>Ig*(this.width||0));ag.splice(ng,1);const sg=this.rowHeights.map(Ig=>Ig*(this.height||0));this.applyStructureChange(this.rows,og-1,(Ig,Cg)=>{const lg=Cg>=ng?Cg+1:Cg;return Ig*og+lg},Math.floor(ig/og),Math.min(ng,og-2),ag,sg,ng===0?"right":"left","top"),this.restoreEditingTextareaAfterStructureChange(gg)}deleteRow(eg){if(this.rows<=1)return;const gg=!!this.editingTextarea,ig=this.selectedCellIndex||0;this.removeEditingTextarea(!0);const ng=Math.min(Math.max(eg,0),this.rows-1),og=this.rows,ag=this.columns,sg=this.rowHeights.map(Cg=>Cg*(this.height||0));sg.splice(ng,1);const Ig=this.columnWidths.map(Cg=>Cg*(this.width||0));this.applyStructureChange(og-1,ag,(Cg,lg)=>(Cg>=ng?Cg+1:Cg)*ag+lg,Math.min(ng,og-2),ig%ag,Ig,sg,"left",ng===0?"bottom":"top"),this.restoreEditingTextareaAfterStructureChange(gg)}restoreEditingTextareaAfterStructureChange(eg){if(!eg||this.selectedCellIndex===null)return;const gg=this.selectedCellIndex;requestAnimationFrame(()=>{this.selectedCellIndex!==gg||this.editingTextarea||this.startCellEditing(gg)})}syncTextCount(){Array.isArray(this.tableTexts)||(this.tableTexts=[]);const eg=this.rows*this.columns;for(this.tableTexts.length>eg&&(this.tableTexts=this.tableTexts.slice(0,eg));this.tableTexts.length<eg;)this.tableTexts.push("");for(Array.isArray(this.tableCellStyles)||(this.tableCellStyles=[]),this.tableCellStyles.length>eg&&(this.tableCellStyles=this.tableCellStyles.slice(0,eg));this.tableCellStyles.length<eg;)this.tableCellStyles.push({});for(Array.isArray(this.tableCellBorders)||(this.tableCellBorders=[]),this.tableCellBorders.length>eg&&(this.tableCellBorders=this.tableCellBorders.slice(0,eg));this.tableCellBorders.length<eg;)this.tableCellBorders.push({});for(Array.isArray(this.tableCellSpans)||(this.tableCellSpans=[]),this.tableCellSpans.length>eg&&(this.tableCellSpans=this.tableCellSpans.slice(0,eg));this.tableCellSpans.length<eg;)this.tableCellSpans.push(this.createDefaultCellSpan());this.syncDimensionRatios(),this.selectedCellIndex!==null&&this.selectedCellIndex>=eg&&(this.selectedCellIndex=null)}syncDimensionRatios(){this.columnWidths=this.normalizeRatios(this.columnWidths,this.columns),this.rowHeights=this.normalizeRatios(this.rowHeights,this.rows)}normalizeRatios(eg,gg){const ig=Array.from({length:gg},(og,ag)=>{const sg=Number(eg[ag]);return Number.isFinite(sg)&&sg>0?sg:1}),ng=ig.reduce((og,ag)=>og+ag,0)||gg||1;return ig.map(og=>og/ng)}applyTextOptions(eg){["fontSize","fontFamily","fontWeight","fontStyle","underline","linethrough","charSpacing","lineHeight","textAlign","verticalType"].forEach(ig=>{eg[ig]!==void 0&&(this[ig]=eg[ig])})}isTextStyleKey(eg){return["fontSize","fontFamily","fontWeight","fontStyle","underline","linethrough","charSpacing","lineHeight","textAlign","verticalType","fill"].includes(eg)}getTextX(eg,gg,ig){return this.getTextXByAlign(eg,gg,ig,this.textAlign)}getTextXByAlign(eg,gg,ig,ng="center"){return ng==="left"?eg+ig:ng==="right"?eg+gg-ig:eg+gg/2}getTextStartYByVertical(eg,gg,ig,ng,og,ag="vcenter"){return ag==="top"?eg+ig+og/2:ag==="bottom"?eg+gg-ig-ng+og/2:eg+gg/2-ng/2+og/2}getTextareaVerticalPadding(eg,gg,ig){if(eg.verticalType==="top")return{top:0,bottom:0};const ng=Math.max(gg-ig,0);return eg.verticalType==="bottom"?{top:ng,bottom:0}:{top:ng/2,bottom:0}}getDefaultCellStyle(){return{fontSize:Number(this.fontSize)||12,fontFamily:this.fontFamily||"微软雅黑",fill:this.fill||"#000000",fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",underline:!!this.underline,linethrough:!!this.linethrough,charSpacing:Number(this.charSpacing)||0,lineHeight:Number(this.lineHeight)||1.2,textAlign:this.textAlign||"center",verticalType:this.verticalType||"vcenter"}}getCellStyle(eg){return this.syncTextCount(),{...this.getDefaultCellStyle(),...this.tableCellStyles[eg]||{}}}setCellStyle(eg,gg){var ig,ng;this.syncTextCount(),!(eg<0||eg>=this.rows*this.columns)&&(this.tableCellStyles[eg]={...this.tableCellStyles[eg]||{},...gg},this.updateEditingTextarea(eg),this.dirty=!0,(ig=this.canvas)==null||ig.requestRenderAll(),(ng=this.canvas)==null||ng.fire("object:modified",{target:this}))}getCellBorderStyle(eg){return this.syncTextCount(),{top:"solid",right:"solid",bottom:"solid",left:"solid",...this.tableCellBorders[eg]||{}}}setCellBorderStyle(eg,gg){var ig,ng;this.syncTextCount(),!(eg<0||eg>=this.rows*this.columns)&&(this.tableCellBorders[eg]={...this.tableCellBorders[eg]||{},...gg},this.dirty=!0,(ig=this.canvas)==null||ig.requestRenderAll(),(ng=this.canvas)==null||ng.fire("object:modified",{target:this}))}setAllCellBorderStyle(eg){var gg,ig;this.syncTextCount(),this.tableCellBorders=Array.from({length:this.rows*this.columns},()=>({top:eg,right:eg,bottom:eg,left:eg})),this.dirty=!0,(gg=this.canvas)==null||gg.requestRenderAll(),(ig=this.canvas)==null||ig.fire("object:modified",{target:this,action:"modifyprops"})}getCellLayout(eg){return{...this.getCellRect(eg),row:Math.floor(eg/this.columns),col:eg%this.columns}}setColumnWidth(eg,gg){var sg,Ig;const ig=this.width||0;if(eg<0||eg>=this.columns||!ig)return;const ng=Math.max(Number(gg)||0,8),og=Array.from({length:this.columns},(Cg,lg)=>(this.columnWidths[lg]||1/this.columns)*ig);og[eg]=ng;const ag=og.reduce((Cg,lg)=>Cg+lg,0)||ng;this.width=ag,this.columnWidths=og.map(Cg=>Cg/ag),this.setCoords(),this.updateEditingTextarea(),this.dirty=!0,(sg=this.canvas)==null||sg.requestRenderAll(),(Ig=this.canvas)==null||Ig.fire("object:modified",{target:this})}setRowHeight(eg,gg){var sg,Ig;const ig=this.height||0;if(eg<0||eg>=this.rows||!ig)return;const ng=Math.max(Number(gg)||0,8),og=Array.from({length:this.rows},(Cg,lg)=>(this.rowHeights[lg]||1/this.rows)*ig);og[eg]=ng;const ag=og.reduce((Cg,lg)=>Cg+lg,0)||ng;this.height=ag,this.rowHeights=og.map(Cg=>Cg/ag),this.setCoords(),this.updateEditingTextarea(),this.dirty=!0,(sg=this.canvas)==null||sg.requestRenderAll(),(Ig=this.canvas)==null||Ig.fire("object:modified",{target:this})}getColumnOffset(eg){const gg=this.width||0;return-gg/2+this.columnWidths.slice(0,eg).reduce((ig,ng)=>ig+ng*gg,0)}getRowOffset(eg){const gg=this.height||0;return-gg/2+this.rowHeights.slice(0,eg).reduce((ig,ng)=>ig+ng*gg,0)}getCellRect(eg){const gg=this.width||0,ig=this.height||0,ng=Math.floor(eg/this.columns),og=eg%this.columns,ag=(this.columnWidths[og]||0)*gg,sg=(this.rowHeights[ng]||0)*ig;return{left:this.getColumnOffset(og),top:this.getRowOffset(ng),width:ag,height:sg}}getCellIndexByPoint(eg){const gg=this.width||0,ig=this.height||0;if(!gg||!ig||!this.rows||!this.columns)return-1;const ng=kn.invertTransform(this.calcTransformMatrix()),og=kn.transformPoint(new ot(eg.x,eg.y),ng),ag=og.x+gg/2,sg=og.y+ig/2;if(ag<0||sg<0||ag>gg||sg>ig)return-1;let Ig=0,Cg=this.columns-1;for(let rg=0;rg<this.columns;rg++)if(Ig+=this.columnWidths[rg]*gg,ag<=Ig){Cg=rg;break}let lg=0,Ag=this.rows-1;for(let rg=0;rg<this.rows;rg++)if(lg+=this.rowHeights[rg]*ig,sg<=lg){Ag=rg;break}return Ag*this.columns+Cg}getViewportCellTransform(eg){if(!this.canvas)return null;const gg=this.getCellRect(eg),ig=this.calcTransformMatrix(),ng=this.canvas.viewportTransform||[1,0,0,1,0,0],og=kn.multiplyTransformMatrices(ng,ig),ag=Math.hypot(og[0],og[1])||1,sg=Math.hypot(og[2],og[3])||1;return{...gg,matrix:og,scaleX:ag,scaleY:sg}}getCanvasElementRect(){var gg,ig;return this.canvas?(((ig=(gg=this.canvas.elements)==null?void 0:gg.upper)==null?void 0:ig.el)||this.canvas.upperCanvasEl||this.canvas.getElement()).getBoundingClientRect():null}removeEditingTextarea(eg=!0){var ng,og,ag;if(!this.editingTextarea)return;const gg=this.editingTextarea;this.editingTextarea=null;const ig=Number(gg.dataset.cellIndex);this.editingPointerDownHandler&&(document.removeEventListener("pointerdown",this.editingPointerDownHandler,!0),this.editingPointerDownHandler=null),this.unbindEditingViewportChange(),eg&&Number.isFinite(ig)&&(this.tableTexts[ig]=gg.value,this.dirty=!0,(ng=this.canvas)==null||ng.fire("object:modified",{target:this})),(og=gg.parentNode)==null||og.removeChild(gg),this.selectedCellIndex=null,this.dirty=!0,(ag=this.canvas)==null||ag.requestRenderAll()}isEditingAssistantTarget(eg){return!!eg.closest([".right-side-bar",".ant-select-dropdown",".ant-select-item",".ant-select-selector",".ant-select-selection-search-input",".ant-input-number",".ant-input-number-dropdown",".ant-dropdown",".ant-tooltip",".ant-popover",".color-wrap",".color-preview-wrap",".hu-color-picker"].join(","))}bindEditingPointerDown(eg){this.editingPointerDownHandler&&document.removeEventListener("pointerdown",this.editingPointerDownHandler,!0),this.editingPointerDownHandler=gg=>{const ig=gg.target;if(!(!ig||ig===eg||eg.contains(ig))){if(this.isEditingAssistantTarget(ig)){this.keepEditingOnNextBlur=!0;return}this.removeEditingTextarea(!0)}},document.addEventListener("pointerdown",this.editingPointerDownHandler,!0)}scheduleEditingTextareaUpdate(eg){this.editingUpdateFrame&&cancelAnimationFrame(this.editingUpdateFrame),this.editingUpdateFrame=requestAnimationFrame(()=>{this.editingUpdateFrame=0,this.updateEditingTextarea(eg)})}bindEditingViewportChange(eg){var ng,og,ag,sg,Ig,Cg,lg;this.unbindEditingViewportChange(),this.editingViewportChangeHandler=()=>{this.scheduleEditingTextareaUpdate(eg)},window.addEventListener("resize",this.editingViewportChangeHandler),window.addEventListener("scroll",this.editingViewportChangeHandler,!0),(ng=window.visualViewport)==null||ng.addEventListener("resize",this.editingViewportChangeHandler),(og=window.visualViewport)==null||og.addEventListener("scroll",this.editingViewportChangeHandler);const gg=((Ig=(sg=(ag=this.canvas)==null?void 0:ag.elements)==null?void 0:sg.upper)==null?void 0:Ig.el)||((Cg=this.canvas)==null?void 0:Cg.upperCanvasEl)||((lg=this.canvas)==null?void 0:lg.getElement()),ig=(gg==null?void 0:gg.parentElement)||gg;ig&&typeof ResizeObserver<"u"&&(this.editingResizeObserver=new ResizeObserver(()=>{this.scheduleEditingTextareaUpdate(eg)}),this.editingResizeObserver.observe(ig))}unbindEditingViewportChange(){var eg,gg,ig;this.editingUpdateFrame&&(cancelAnimationFrame(this.editingUpdateFrame),this.editingUpdateFrame=0),this.editingViewportChangeHandler&&(window.removeEventListener("resize",this.editingViewportChangeHandler),window.removeEventListener("scroll",this.editingViewportChangeHandler,!0),(eg=window.visualViewport)==null||eg.removeEventListener("resize",this.editingViewportChangeHandler),(gg=window.visualViewport)==null||gg.removeEventListener("scroll",this.editingViewportChangeHandler),this.editingViewportChangeHandler=null),(ig=this.editingResizeObserver)==null||ig.disconnect(),this.editingResizeObserver=null}updateEditingTextarea(eg){if(!this.editingTextarea)return;const gg=this.editingTextarea,ig=Number(gg.dataset.cellIndex);if(!Number.isFinite(ig)||eg!==void 0&&eg!==ig)return;const ng=this.getViewportCellTransform(ig),og=this.getCanvasElementRect();if(!ng||!og)return;const ag=this.getCellStyle(ig),sg=this.getCellEditFontSize(ig,ng.scaleY),Ig=Math.max(Math.min(ng.scaleX,ng.scaleY),.01),Cg=Math.max(2/Ig,Math.min(sg*.18,8)),lg=Math.max(ng.width-Cg*2,12/ng.scaleX),Ag=Math.max(ng.height-Cg*2,12/ng.scaleY),rg=sg*(Number(ag.lineHeight)||1.2),cg=this.getEditingLineCount(gg.value,ag,sg,lg),ug=this.getTextareaVerticalPadding(ag,Ag,rg*cg),dg=kn.transformPoint(new ot(ng.left+Cg,ng.top+Cg),ng.matrix);gg.style.left=`${og.left+dg.x}px`,gg.style.top=`${og.top+dg.y}px`,gg.style.width=`${lg}px`,gg.style.height=`${Ag}px`,gg.style.transform=`matrix(${ng.matrix[0]}, ${ng.matrix[1]}, ${ng.matrix[2]}, ${ng.matrix[3]}, 0, 0)`,gg.style.color=ag.fill,gg.style.font=this.getFont(sg,ag),gg.style.lineHeight=`${rg}px`,gg.style.textAlign=ag.textAlign,gg.style.letterSpacing=`${this.getSpacingPx(ag,sg)}px`,gg.style.padding=`${ug.top}px 0 ${ug.bottom}px 0`}startCellEditing(eg){if(!this.canvas)return;this.removeEditingTextarea(!0),this.selectedCellIndex=eg;const gg=this.getViewportCellTransform(eg);if(!gg)return;const ig=this.getCanvasElementRect();if(!ig)return;const ng=this.getCellEditFontSize(eg,gg.scaleY),og=Math.max(Math.min(gg.scaleX,gg.scaleY),.01),ag=Math.max(2/og,Math.min(ng*.18,8)),sg=kn.transformPoint(new ot(gg.left+ag,gg.top+ag),gg.matrix),Ig=document.createElement("textarea");Ig.value=this.tableTexts[eg]||"",Ig.dataset.cellIndex=`${eg}`,Ig.spellcheck=!1,Ig.style.position="fixed",Ig.style.left=`${ig.left+sg.x}px`,Ig.style.top=`${ig.top+sg.y}px`,Ig.style.width=`${Math.max(gg.width-ag*2,12/gg.scaleX)}px`,Ig.style.height=`${Math.max(gg.height-ag*2,12/gg.scaleY)}px`,Ig.style.zIndex="9999",Ig.style.padding="0",Ig.style.margin="0",Ig.style.border="1px solid #2F54EB",Ig.style.outline="none",Ig.style.resize="none",Ig.style.overflow="hidden",Ig.style.background="rgba(255, 255, 255, 0.92)",Ig.style.whiteSpace="pre-wrap",Ig.style.overflowWrap="break-word";const Cg=this.getCellStyle(eg);Ig.style.color=Cg.fill,Ig.style.font=this.getFont(ng,Cg),Ig.style.lineHeight=`${Cg.lineHeight}`,Ig.style.textAlign=Cg.textAlign,Ig.style.letterSpacing=`${this.getSpacingPx(Cg,ng)}px`,Ig.style.boxSizing="border-box",Ig.style.transformOrigin="left top",Ig.style.transform=`matrix(${gg.matrix[0]}, ${gg.matrix[1]}, ${gg.matrix[2]}, ${gg.matrix[3]}, 0, 0)`;const lg=Ag=>Ag.stopPropagation();Ig.addEventListener("mousedown",lg),Ig.addEventListener("pointerdown",lg),Ig.addEventListener("dblclick",lg),Ig.addEventListener("keydown",Ag=>{Ag.stopPropagation(),Ag.key==="Escape"&&(Ag.preventDefault(),this.removeEditingTextarea(!1))}),Ig.addEventListener("input",()=>this.updateEditingTextarea(eg)),Ig.addEventListener("paste",Ag=>this.handleCellEditPaste(eg,Ag)),Ig.addEventListener("copy",Ag=>this.handleCellEditCopy(eg,Ag)),Ig.addEventListener("cut",Ag=>this.handleCellEditCut(eg,Ag)),Ig.addEventListener("blur",()=>{if(this.keepEditingOnNextBlur){this.keepEditingOnNextBlur=!1;return}this.removeEditingTextarea(!0)}),document.body.appendChild(Ig),this.editingTextarea=Ig,this.bindEditingPointerDown(Ig),this.bindEditingViewportChange(eg),this.updateEditingTextarea(eg),Ig.focus(),Ig.select()}handleCellEditPaste(eg,gg){const ig=gg.clipboardData;if(!ig)return;const ng=ig.getData("text/html");if(!ng)return;const og=this.extractCellStyleFromHtml(ng);og&&Object.keys(og).length>0&&this.setCellStyle(eg,og)}handleCellEditCopy(eg,gg){const ig=gg.clipboardData;if(!ig)return;const ng=this.editingTextarea;if(!ng)return;const og=ng.value.substring(ng.selectionStart,ng.selectionEnd);if(!og)return;const ag=this.getCellStyle(eg),sg=this.buildClipboardHtml(og,ag);gg.preventDefault(),ig.setData("text/plain",og),ig.setData("text/html",sg)}handleCellEditCut(eg,gg){var ag;this.handleCellEditCopy(eg,gg);const ig=this.editingTextarea;if(!ig)return;const ng=ig.selectionStart,og=ig.selectionEnd;ng!==og&&(ig.value=ig.value.slice(0,ng)+ig.value.slice(og),ig.selectionStart=ig.selectionEnd=ng,this.tableTexts[eg]=ig.value,this.updateEditingTextarea(eg),this.dirty=!0,(ag=this.canvas)==null||ag.requestRenderAll())}buildClipboardHtml(eg,gg){const ig=[];gg.fill&&ig.push(`color:${gg.fill}`),gg.fontSize&&ig.push(`font-size:${gg.fontSize}px`),gg.fontFamily&&ig.push(`font-family:${gg.fontFamily}`),gg.fontWeight&&ig.push(`font-weight:${gg.fontWeight}`),gg.fontStyle&&ig.push(`font-style:${gg.fontStyle}`);const ng=[];gg.underline&&ng.push("underline"),gg.linethrough&&ng.push("line-through"),ng.length&&ig.push(`text-decoration:${ng.join(" ")}`),gg.textAlign&&ig.push(`text-align:${gg.textAlign}`),gg.lineHeight&&ig.push(`line-height:${gg.lineHeight}`);const og=eg.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>");return`<span style="${ig.join(";")}">${og}</span>`}extractCellStyleFromHtml(eg){try{const gg=document.createElement("div");gg.style.position="absolute",gg.style.left="-9999px",gg.style.top="-9999px",gg.style.visibility="hidden",gg.innerHTML=eg,document.body.appendChild(gg);let ig=null;const ng=document.createTreeWalker(gg,NodeFilter.SHOW_TEXT);let og;for(;og=ng.nextNode();)if(og.textContent&&og.textContent.trim()){ig=og.parentElement;break}ig||(ig=gg);const ag=window.getComputedStyle(ig),sg={};ag.color&&(sg.fill=ag.color);const Ig=parseFloat(ag.fontSize);if(Number.isFinite(Ig)&&Ig>0&&(sg.fontSize=Ig),ag.fontFamily){const rg=(ag.fontFamily.split(",")[0]||"").trim();sg.fontFamily=rg.replace(/^["']|["']$/g,"")}if(ag.fontWeight&&ag.fontWeight!=="normal"&&ag.fontWeight!=="400"){const rg=Number(ag.fontWeight);sg.fontWeight=ag.fontWeight==="bold"||Number.isFinite(rg)&&rg>=600?"bold":ag.fontWeight}ag.fontStyle&&ag.fontStyle!=="normal"&&(sg.fontStyle=ag.fontStyle);const Cg=ag.textDecorationLine||ag.textDecoration||"";/underline/i.test(Cg)&&(sg.underline=!0),/line-through/i.test(Cg)&&(sg.linethrough=!0);const lg=ag.textAlign;(lg==="left"||lg==="center"||lg==="right")&&(sg.textAlign=lg);const Ag=parseFloat(ag.lineHeight);return Number.isFinite(Ag)&&Ag>=.5&&Ag<=5&&(sg.lineHeight=Ag),document.body.removeChild(gg),sg}catch{return null}}selectCell(eg){var gg;this.selectedCellIndex=eg,this.dirty=!0,(gg=this.canvas)==null||gg.requestRenderAll()}handleCellDoubleClick(eg){const gg=this.getCellIndexByPoint(eg);gg<0||(this.removeEditingTextarea(!0),this.selectCell(gg),this.startCellEditing(gg))}getFont(eg,gg){const ig=gg.fontStyle==="italic"?"italic ":"",ng=Number(gg.fontWeight),ag=gg.fontWeight==="bold"||Number.isFinite(ng)&&ng>=600?"bold ":"";return`${ig}${ag}${eg}px ${gg.fontFamily}`}getCellEditFontSize(eg,gg=1){const ig=this.getCellStyle(eg).fontSize||12;return Math.max(ig,8/Math.max(gg,.01))}getSpacingPx(eg,gg){return(Number(eg.charSpacing)||0)/1e3*gg}getEditingLineCount(eg,gg,ig,ng){const ag=document.createElement("canvas").getContext("2d");return ag?(ag.font=this.getFont(ig,gg),Math.max(this.wrapTextLines(ag,eg,gg,ig,ng).length,1)):Math.max(eg.split(/\r?\n/).length,1)}measureTextWidth(eg,gg,ig,ng){const og=this.getSpacingPx(ig,ng);return!gg||!og?eg.measureText(gg).width:Array.from(gg).reduce((ag,sg)=>ag+eg.measureText(sg).width,0)+Math.max(Array.from(gg).length-1,0)*og}wrapTextLine(eg,gg,ig,ng,og){if(!gg)return[""];if(this.measureTextWidth(eg,gg,ig,ng)<=og)return[gg];const ag=[];let sg="";return Array.from(gg).forEach(Ig=>{const Cg=`${sg}${Ig}`;if(sg&&this.measureTextWidth(eg,Cg,ig,ng)>og){ag.push(sg),sg=Ig;return}sg=Cg}),ag.push(sg),ag}wrapTextLines(eg,gg,ig,ng,og){return String(gg).split(/\r?\n/).flatMap(ag=>this.wrapTextLine(eg,ag,ig,ng,og))}drawTextLine(eg,gg,ig,ng,og,ag){const sg=this.getSpacingPx(ig,ag);if(!sg){eg.fillText(gg,ng,og);return}const Ig=Array.from(gg);let Cg=ng;const lg=this.measureTextWidth(eg,gg,ig,ag);ig.textAlign==="center"&&(Cg=ng-lg/2),ig.textAlign==="right"&&(Cg=ng-lg),eg.textAlign="left",Ig.forEach(Ag=>{eg.fillText(Ag,Cg,og),Cg+=eg.measureText(Ag).width+sg})}drawTextDecoration(eg,gg,ig,ng,og,ag,sg){if(!sg.underline&&!sg.linethrough)return;const Ig=Math.min(this.measureTextWidth(eg,gg,sg,ag),og);let Cg=ig-Ig/2;if(sg.textAlign==="left"&&(Cg=ig),sg.textAlign==="right"&&(Cg=ig-Ig),eg.strokeStyle=sg.fill||"#000000",eg.lineWidth=Math.max(ag/16,1),sg.underline){const lg=ng+ag*.38;eg.beginPath(),eg.moveTo(Cg,lg),eg.lineTo(Cg+Ig,lg),eg.stroke()}sg.linethrough&&(eg.beginPath(),eg.moveTo(Cg,ng),eg.lineTo(Cg+Ig,ng),eg.stroke())}drawCellText(eg,gg,ig,ng,og,ag,sg){if(!gg)return;const Ig=Math.min(4,og/6,ag/6),Cg=Math.max(og-Ig*2,1),lg=this.getCellStyle(sg),Ag=this.getTextXByAlign(ig,og,Ig,lg.textAlign),rg=this.scaleX||1,cg=this.scaleY||1,ug=Math.max(Number(lg.fontSize)||12,1),dg=ug*(Number(lg.lineHeight)||1.2);eg.font=this.getFont(ug,lg);const hg=this.wrapTextLines(eg,gg,lg,ug,Cg*rg),mg=hg.length*dg,bg=this.getTextStartYByVertical(ng,ag,Ig,mg,dg,lg.verticalType);eg.save(),eg.beginPath(),eg.rect(ig+.5,ng+.5,Math.max(og-1,1),Math.max(ag-1,1)),eg.clip(),eg.translate(Ag,bg),eg.scale(1/rg,1/cg),eg.fillStyle=lg.fill||"#000000",eg.font=this.getFont(ug,lg),eg.textAlign=lg.textAlign,eg.textBaseline="middle",hg.forEach((pg,fg)=>{const wg=fg*dg*cg;this.drawTextLine(eg,pg,lg,0,wg,ug),this.drawTextDecoration(eg,pg,0,wg,Cg*rg,ug,lg)}),eg.restore()}drawSelectedCell(eg){if(this.selectedCellIndex===null)return;const gg=this.selectedCellIndex;if(gg<0||gg>=this.rows*this.columns)return;const ig=this.getCellRect(gg);eg.save(),eg.fillStyle="rgba(47, 84, 235, 0.14)",eg.strokeStyle="#2F54EB",eg.lineWidth=1,eg.fillRect(ig.left,ig.top,ig.width,ig.height),eg.strokeRect(ig.left+.5,ig.top+.5,Math.max(ig.width-1,1),Math.max(ig.height-1,1)),eg.restore()}resolveBorderStyle(eg,gg){return eg==="none"||gg==="none"?"none":eg==="dashed"||gg==="dashed"?"dashed":"solid"}getDefaultBorderStyle(){return Array.isArray(this.strokeDashArray)&&this.strokeDashArray.length?"dashed":"solid"}getBorderSideStyle(eg,gg){var ig;return((ig=this.tableCellBorders[eg])==null?void 0:ig[gg])||this.getDefaultBorderStyle()}drawBorderSegment(eg,gg,ig,ng,og,ag){gg!=="none"&&(eg.save(),eg.strokeStyle=this.stroke||"#000000",eg.lineWidth=this.strokeWidth||1,eg.setLineDash(gg==="dashed"&&Array.isArray(this.strokeDashArray)?this.strokeDashArray:gg==="dashed"?[6,4]:[]),eg.beginPath(),eg.moveTo(ig,ng),eg.lineTo(og,ag),eg.stroke(),eg.restore())}drawTableBorders(eg){for(let gg=0;gg<=this.rows;gg++){const ig=this.getRowOffset(gg);for(let ng=0;ng<this.columns;ng++){const og=this.getColumnOffset(ng),ag=this.getColumnOffset(ng+1),sg=gg>0?(gg-1)*this.columns+ng:-1,Ig=gg<this.rows?gg*this.columns+ng:-1,Cg=sg>=0?this.getBorderSideStyle(sg,"bottom"):void 0,lg=Ig>=0?this.getBorderSideStyle(Ig,"top"):void 0,Ag=this.resolveBorderStyle(Cg||lg||"solid",Cg&&lg?lg:void 0);this.drawBorderSegment(eg,Ag,og,ig,ag,ig)}}for(let gg=0;gg<=this.columns;gg++){const ig=this.getColumnOffset(gg);for(let ng=0;ng<this.rows;ng++){const og=this.getRowOffset(ng),ag=this.getRowOffset(ng+1),sg=gg>0?ng*this.columns+gg-1:-1,Ig=gg<this.columns?ng*this.columns+gg:-1,Cg=sg>=0?this.getBorderSideStyle(sg,"right"):void 0,lg=Ig>=0?this.getBorderSideStyle(Ig,"left"):void 0,Ag=this.resolveBorderStyle(Cg||lg||"solid",Cg&&lg?lg:void 0);this.drawBorderSegment(eg,Ag,ig,og,ig,ag)}}}_render(eg){const gg=this.width||0,ig=this.height||0;if(!gg||!ig||!this.rows||!this.columns)return;const ng=-gg/2,og=-ig/2;eg.save(),eg.fillStyle=this.backgroundColor||"#FFFFFF00",eg.fillRect(ng,og,gg,ig),eg.restore(),this.drawSelectedCell(eg),this.drawTableBorders(eg),this.syncTextCount();for(let ag=0;ag<this.rows;ag++)for(let sg=0;sg<this.columns;sg++){const Ig=ag*this.columns+sg,Cg=this.getCellRect(Ig);this.drawCellText(eg,this.tableTexts[Ig]||"",Cg.left,Cg.top,Cg.width,Cg.height,Ig)}}};lu.type="table";let ATable=lu;tt.setClass(ATable);const RIBBON_BORDER_PATTERN_OPTIONS=[{label:"无描边",value:"none",source:{x:57,y:29,width:169,height:169}},{label:"图案 1",value:"ribbon-01",source:{x:293,y:29,width:169,height:169}},{label:"图案 2",value:"ribbon-02",source:{x:546,y:29,width:169,height:169}},{label:"图案 3",value:"ribbon-03",source:{x:781,y:29,width:169,height:169}},{label:"图案 4",value:"ribbon-04",source:{x:1005,y:29,width:169,height:169}},{label:"图案 5",value:"ribbon-05",source:{x:1230,y:29,width:169,height:169}},{label:"图案 6",value:"ribbon-06",source:{x:1436,y:29,width:169,height:169}},{label:"图案 7",value:"ribbon-07",source:{x:1660,y:29,width:169,height:169}},{label:"图案 8",value:"ribbon-08",source:{x:57,y:255,width:169,height:169}},{label:"图案 9",value:"ribbon-09",source:{x:296,y:255,width:169,height:169}},{label:"图案 10",value:"ribbon-10",source:{x:550,y:254,width:168,height:169}},{label:"图案 11",value:"ribbon-11",source:{x:781,y:255,width:169,height:169}},{label:"图案 12",value:"ribbon-12",source:{x:1003,y:254,width:169,height:169}},{label:"图案 13",value:"ribbon-13",source:{x:1230,y:255,width:169,height:169}},{label:"图案 14",value:"ribbon-14",source:{x:1436,y:255,width:169,height:169}},{label:"图案 15",value:"ribbon-15",source:{x:1660,y:254,width:169,height:169}},{label:"图案 16",value:"ribbon-16",source:{x:57,y:629,width:169,height:169}},{label:"图案 17",value:"ribbon-17",source:{x:550,y:480,width:168,height:169}},{label:"图案 18",value:"ribbon-18",source:{x:781,y:483,width:169,height:169}},{label:"图案 19",value:"ribbon-19",source:{x:1003,y:483,width:169,height:169}},{label:"图案 20",value:"ribbon-20",source:{x:1230,y:471,width:169,height:169}},{label:"图案 21",value:"ribbon-21",source:{x:1436,y:473,width:169,height:169}},{label:"图案 22",value:"ribbon-22",source:{x:1660,y:473,width:169,height:169}},{label:"图案 23",value:"ribbon-23",source:{x:781,y:693,width:169,height:169}},{label:"图案 24",value:"ribbon-24",source:{x:1003,y:686,width:169,height:169}},{label:"图案 25",value:"ribbon-25",source:{x:1230,y:683,width:169,height:169}},{label:"图案 26",value:"ribbon-26",source:{x:1436,y:683,width:169,height:169}},{label:"图案 27",value:"ribbon-27",source:{x:1660,y:683,width:169,height:169}}];RIBBON_BORDER_PATTERN_OPTIONS.map(tg=>tg.value);function drawRibbonBorder(tg,eg,gg,ig){if(eg==="none"||!(ig!=null&&ig.left)||!(ig!=null&&ig.right))return;const{width:ng,height:og}=gg,ag=gg.left??0,sg=gg.top??0,Ig=getRibbonBorderBandWidth(ng);drawTextureSide(tg,ig.left,ag,sg,Ig,og,"left"),drawTextureSide(tg,ig.right,ag+ng-Ig,sg,Ig,og,"right")}function getRibbonBorderBandWidth(tg){return Math.max(16,Math.min(56,Math.round(tg*.11)))}function drawTextureSide(tg,eg,gg,ig,ng,og,ag){const sg=getImageSourceWidth(eg),Ig=Number(eg.naturalHeight||eg.height);if(!sg||!Ig)return;const Cg=Math.max(1,Math.min(ng,Math.round(sg))),lg=ag==="right"?gg+ng-Cg:gg,Ag=Math.max(1,Math.round(Ig*(Cg/sg)));let rg=ig;for(;rg<ig+og;){const cg=Math.min(Ag,ig+og-rg),ug=Math.max(1,Math.round(Ig*(cg/Ag)));tg.drawImage(eg,0,0,sg,ug,lg,rg,Cg,cg),rg+=Ag}}function getImageSourceWidth(tg){return tg?Number(tg.naturalWidth||tg.width||0):0}const objectMap={line:(tg,eg)=>new ALine([0,0,0,0],{...tg}),rect:(tg,eg)=>new ARect(tg),triangle:(tg,eg)=>new ATriangle(tg),table:(tg,eg)=>new ATable(tg),circle:(tg,eg)=>new ACircle(tg),barcode:(tg,eg)=>new ABarcode(eg,tg),barcode2d:(tg,eg)=>new ABarcode2D(eg,tg),text:(tg,eg)=>new AText(eg??"",tg),textname:(tg,eg)=>new ATextName(eg??"",tg),counter:(tg,eg)=>new ACounter(eg,tg),image:(tg,eg)=>new AImage(eg,tg),rfid:(tg,eg)=>new RfidIcon(eg,tg)};o.DPI=203;const printRenderMetrics={count:0,textRenderMs:0,imageRenderMs:0,thresholdReadMs:0,thresholdLoopMs:0,thresholdWriteMs:0,cpuCopyMs:0};function isPrintRenderMetricsEnabled(){if(window.__LE_PRINT_RENDER_METRICS__===!0)return!0;try{return localStorage.getItem("le:print-render-metrics")==="1"}catch{return!1}}function reportPrintRenderMetrics(){var eg;if(!isPrintRenderMetricsEnabled()||(printRenderMetrics.count++,printRenderMetrics.count%100!==0))return;const tg=window;tg.__LE_PRINT_RENDER_DETAILS__||(tg.__LE_PRINT_RENDER_DETAILS__={}),(eg=tg.__LE_PRINT_RENDER_DETAILS__).baseEditor||(eg.baseEditor=[]),tg.__LE_PRINT_RENDER_DETAILS__.baseEditor.push({...printRenderMetrics}),printRenderMetrics.count=0,printRenderMetrics.textRenderMs=0,printRenderMetrics.imageRenderMs=0,printRenderMetrics.thresholdReadMs=0,printRenderMetrics.thresholdLoopMs=0,printRenderMetrics.thresholdWriteMs=0,printRenderMetrics.cpuCopyMs=0}class BaseEditor{constructor(){this.bindData=new EditorData,this.ribbonBorderPattern="none",this.ribbonBorderTextures=null}get width(){var eg;return(eg=this.canvas)==null?void 0:eg.elements.lower.el.offsetWidth}get height(){var eg;return(eg=this.canvas)==null?void 0:eg.elements.lower.el.offsetHeight}init(eg,gg){this.canvas=new In(eg,{...gg,imageSmoothingEnabled:!1,fireMiddleClick:!0,fireRightClick:!0,stopContextMenu:!1,controlsAboveOverlay:!0,preserveObjectStacking:!0,selectionKey:"ctrlKey"}),this.bindData.init(this);const ig=ng=>{if(!this.canvas)return;const og=this.canvas.getActiveObject();if(!og||og.type!=="textname")return;const ag=og;ag.isEditing===!0&&(ng.key==="Enter"||ng.keyCode===13||ng.key===" "||ng.key==="Space"||ng.keyCode===32)&&(ng.preventDefault(),ng.stopImmediatePropagation(),ag.selectionStart!==void 0&&(ag.selectionStart=ag.selectionEnd=ag.selectionStart))};document.addEventListener("keydown",ig),this.canvas.on("dispose",()=>{document.removeEventListener("keydown",ig)})}removeObject(eg){var gg;eg&&((gg=this.canvas)==null||gg.remove(eg))}addObject(eg,gg,ig,ng){if(this.canvas)if(eg==="image")kn.loadImage(ig,{crossOrigin:"anonymous"}).then(og=>{let ag=og.width/og.height;const sg=imageAlignToOrigin(gg.imageAlign);gg.imgScaleType=ag>1?"3":ag<1?"2":"1";const Ig=new AImage(og,{...gg,imageAnchorMode:"metadata",imageAnchorX:sg.x,imageAnchorY:sg.y,originX:"left",originY:"top",imageSource:gg.imageSource||ig});Ig.id=v4(),Ig.canvas=this.canvas,addObjName(this.canvas,Ig),this.canvas.add(Ig),this.canvas.setActiveObject(Ig)});else{const og=objectMap[eg](gg,ig);og.id=v4(),og.canvas=this.canvas,og.padding=3,addObjName(this.canvas,og),this.canvas.add(og),this.canvas.setActiveObject(og)}}getActiveObjects(){return this.canvas.getActiveObjects()}getActiveObject(){return this.canvas.getActiveObject()}getObjects(){return this.canvas.getObjects()}getAllObjects(){const eg=this.getCanvas(),gg=[];function ig(ng){ng.type==="group"&&ng._objects?ng._objects.forEach(og=>ig(og)):ng.id!=="workspace"&&gg.push(ng)}return eg.getObjects().forEach(ng=>ig(ng)),gg}getBind(){return this.bindData}setRibbonBorderTextures(eg){var gg;this.ribbonBorderTextures=eg,(gg=this.canvas)==null||gg.requestRenderAll()}_toDataUrl(eg,gg,{exclude:ig=[],targetDPI:ng=203,type:og="",ribbonBorderPattern:ag=this.ribbonBorderPattern}={},sg=null){let Ig=sg;if(gg&&Ig){const{left:$g,top:Bg,right:Wg,bottom:yg}=gg;Ig.width=Ig.width+$g+Wg,Ig.height=Ig.height+Bg+yg}const{left:Cg,top:lg,width:Ag,height:rg}=Ig,cg=eg.viewportTransform,ug=new ot(Cg,lg).transform(cg),dg=new ot(Ag,rg).transform(cg),hg=dg.x-ug.x,mg=dg.y-ug.y;let bg=Ag/hg*(Math.trunc(ng/o.DPI*100)/100);const pg={format:"png",quality:1,width:hg,height:mg,left:ug.x,top:ug.y,multiplier:bg};eg.set("flagToDataURL",!0),(Ig&&Ig.type==="ellipse"||Ig.type==="rect"&&Ig.rx&&Ig.ry)&&(eg.clipPath=Ig);let fg="",wg="",Gg="";const Zg=og==="print"&&isPrintRenderMetricsEnabled();if(og==="print"){let $g=Zg?performance.now():0,Bg=["text","counter","rect","circle","barcode","group","table","triangle"],Wg=["line","ellipse","image","barcode2d"];wg=eg.toCanvasElement(bg,{...pg,filter:Yg=>!ig.includes(Yg.id)&&(Bg.includes(Yg.type)||Yg.id==="workspace")}),Zg&&(printRenderMetrics.textRenderMs+=performance.now()-$g),$g=Zg?performance.now():0,Gg=eg.toCanvasElement(bg,{...pg,filter:Yg=>!ig.includes(Yg.id)&&Yg.id!=="workspace"&&Wg.includes(Yg.type)}),Zg&&(printRenderMetrics.imageRenderMs+=performance.now()-$g);let yg=wg.getContext("2d");$g=Zg?performance.now():0;let Ng=yg.getImageData(0,0,wg.width,wg.height);Zg&&(printRenderMetrics.thresholdReadMs+=performance.now()-$g);let vg=Ng.data;const Sg=vg.length,Vg=Sg-Sg%16;let Xg=window.myThreshold||200;$g=Zg?performance.now():0;for(let Yg=0;Yg<Vg;Yg+=16){let Hg=vg[Yg],kg=vg[Yg+1],Rg=vg[Yg+2],Kg=.299*Hg+.587*kg+.114*Rg;Kg=Kg>Xg?255:0,vg[Yg]=vg[Yg+1]=vg[Yg+2]=Kg,Hg=vg[Yg+4],kg=vg[Yg+5],Rg=vg[Yg+6],Kg=.299*Hg+.587*kg+.114*Rg,Kg=Kg>Xg?255:0,vg[Yg+4]=vg[Yg+5]=vg[Yg+6]=Kg,Hg=vg[Yg+8],kg=vg[Yg+9],Rg=vg[Yg+10],Kg=.299*Hg+.587*kg+.114*Rg,Kg=Kg>Xg?255:0,vg[Yg+8]=vg[Yg+9]=vg[Yg+10]=Kg,Hg=vg[Yg+12],kg=vg[Yg+13],Rg=vg[Yg+14],Kg=.299*Hg+.587*kg+.114*Rg,Kg=Kg>Xg?255:0,vg[Yg+12]=vg[Yg+13]=vg[Yg+14]=Kg}for(let Yg=Vg;Yg<Sg;Yg+=4){const Hg=vg[Yg],kg=vg[Yg+1],Rg=vg[Yg+2];let Kg=.299*Hg+.587*kg+.114*Rg;Kg=Kg>Xg?255:0,vg[Yg]=vg[Yg+1]=vg[Yg+2]=Kg}if(Zg&&(printRenderMetrics.thresholdLoopMs+=performance.now()-$g),$g=Zg?performance.now():0,yg.save(),yg.putImageData(Ng,0,0),yg.globalCompositeOperation="multiply",yg.fillStyle="rgba(255, 255, 255, 1)",yg==null||yg.fillRect(0,0,wg.width,wg.height),yg.drawImage(Gg,0,0,Gg.width,Gg.height),Gg.width=0,Gg.height=0,yg.restore(),Zg&&(printRenderMetrics.thresholdWriteMs+=performance.now()-$g),fg=wg,fg instanceof HTMLCanvasElement){const{width:Yg,height:Hg}=fg;$g=Zg?performance.now():0;const kg=document.createElement("canvas");kg.width=Yg,kg.height=Hg,kg.getContext("2d",{willReadFrequently:!0}).drawImage(fg,0,0),fg.width=0,fg.height=0,fg=kg,Zg&&(printRenderMetrics.cpuCopyMs+=performance.now()-$g)}Zg&&reportPrintRenderMetrics()}else og==="review"?fg=eg.toCanvasElement(bg,{...pg,filter:$g=>!ig.includes($g.id)}):ag!=="none"?fg=eg.toCanvasElement(bg,{...pg,filter:$g=>!ig.includes($g.id)}):fg=eg.toDataURL({...pg,filter:$g=>!ig.includes($g.id)});if(ag!=="none"&&fg instanceof HTMLCanvasElement){const $g=fg.getContext("2d");$g&&drawRibbonBorder($g,ag,{width:fg.width,height:fg.height},this.ribbonBorderTextures),og!=="print"&&og!=="review"&&(fg=fg.toDataURL("image/png",1))}return eg.clipPath&&(eg.clipPath=void 0),eg.set("flagToDataURL",!1),fg}storeStatus(){var eg;this.activeObjects=(eg=this.canvas)==null?void 0:eg.getActiveObject()}restoreStatus(eg=!1){var gg,ig,ng;this.activeObjects?(console.log("restoreStatus"),(gg=this.canvas)==null||gg.setActiveObject(this.activeObjects),(ig=this.canvas)==null||ig.requestRenderAll(),this.activeObjects=void 0):eg&&((ng=this.canvas)==null||ng.requestRenderAll())}getCanvas(){if(!this.canvas)throw new Error("Editor uninit!!!");return this.canvas}static set DPI(eg){o.DPI=eg}static get DPI(){return o.DPI}dispose(){this.canvas&&this.canvas.dispose()}}const printExportMetrics={count:0,methodMs:0,exportMs:0,editorRenderMs:0},EMPTY_IMAGE_DATA_URL="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function isNetworkImageSource(tg){return typeof tg=="string"&&/^(?:https?:)?\/\//i.test(tg)}function canLoadNetworkImage(tg){return new Promise(eg=>{const gg=new Image,ig=window.setTimeout(()=>ng(!1),8e3),ng=og=>{window.clearTimeout(ig),gg.onload=null,gg.onerror=null,eg(og)};gg.crossOrigin="anonymous",gg.onload=()=>ng(!0),gg.onerror=()=>ng(!1),gg.src=tg})}async function prepareCanvasImages(tg,eg=!1){let gg;try{gg=JSON.parse(tg)}catch{return tg}const ig=[],ng=new Set,og=ag=>{!ag||typeof ag!="object"||ng.has(ag)||(ng.add(ag),String(ag.type||"").toLowerCase()==="image"&&ig.push(ag),Array.isArray(ag.objects)&&ag.objects.forEach(og),ag.clipPath&&og(ag.clipPath))};return(Array.isArray(gg)?gg:gg.objects||[]).forEach(og),await Promise.all(ig.map(async ag=>{const sg=isNetworkImageSource(ag.src)?ag.src:ag.src===EMPTY_IMAGE_DATA_URL&&isNetworkImageSource(ag.imageSource)?ag.imageSource:void 0;sg&&(eg||!await canLoadNetworkImage(sg)?(ag.imageSource=ag.imageSource||sg,ag.src=EMPTY_IMAGE_DATA_URL):ag.src===EMPTY_IMAGE_DATA_URL&&(ag.src=sg))})),JSON.stringify(gg)}function isPrintExportMetricsEnabled(){try{return window.__LE_PRINT_RENDER_METRICS__===!0||localStorage.getItem("le:print-render-metrics")==="1"}catch{return!1}}Object.defineProperty(ji.prototype,"locked",{configurable:!0,enumerable:!0,get:function(){return this.lockMovementX&&this.lockMovementY&&this.lockRotation&&this.lockScalingX&&this.lockScalingY&&this.lockSkewingX&&this.lockSkewingY&&this.lockScalingFlip},set:function(tg){this.lockMovementX=this.lockMovementY=this.lockRotation=this.lockScalingX=this.lockScalingY=this.lockSkewingX=this.lockSkewingY=this.lockScalingFlip=tg,this.canvas&&this.canvas.fire("custom:object:locked",{target:this})}});class Editor extends BaseEditor{constructor(){super(...arguments),this.plugins=new Map,this.hooks=new Map,this.events=new Map,this.id=v4(),this._isShown=!1,this._isHasRfid=!1}get filePath(){return this._filePath}set filePath(eg){this._filePath=eg}get labelConfig(){return this._labelConfig}set labelConfig(eg){this._labelConfig=eg}get rfidConfig(){return this._rfidConfig}set rfidConfig(eg){this._rfidConfig=eg}get databaseConfig(){return this._databaseConfig}set databaseConfig(eg){this._databaseConfig=eg}init(eg,gg){super.init(eg,gg),this.canvas&&(this.canvas.on("custom:object:locked",ig=>{this.emit("custom:object:locked",ig)}),this.canvas.on("custom:object:refreshList",ig=>{this.emit("custom:object:refreshList",ig)}))}dispose(){this.canvas&&(this.canvas.off("custom:object:locked"),this.canvas.off("custom:object:refreshList")),this.plugins.forEach(eg=>eg.uninstall&&eg.uninstall()),super.dispose()}addHotKey(eg,gg){hotkeys(eg,{single:!0},(ig,ng)=>{ig.preventDefault(),gg({kbe:ig,hke:ng})})}removeHotKey(eg){hotkeys.unbind(eg)}editActivated(){for(let eg of this.plugins.values())eg.enabled&&eg.enabled()}editDeactivated(){for(let eg of this.plugins.values())eg.disabled&&eg.disabled()}use(eg,gg){const ig=typeof eg=="function"?new eg(gg):eg;return this.checkDependencies(ig),this.runLifecycleHooks(ig,gg),ig.name&&this.plugins.set(ig.name,ig),this}checkDependencies(eg){eg.dependencies&&eg.dependencies.forEach(gg=>{if(!this.plugins.has(gg))throw new Error(`Plugin ${eg.name} requires ${gg} to be installed first`)})}runLifecycleHooks(eg,gg){eg.install&&eg.install(this,gg)}addHook(eg,gg){this.hooks.set(eg,gg)}triggerHook(eg,...gg){const ig=this.hooks.get(eg);if(ig)return ig(...gg)}getPlugin(eg){return this.plugins.get(eg)}on(eg,gg){this.events.has(eg)||this.events.set(eg,[]),this.events.get(eg).push(gg)}emit(eg,...gg){this.events.has(eg)&&this.events.get(eg).forEach(ig=>ig(...gg))}off(eg,gg){this.events.has(eg)&&(gg?this.events.set(eg,this.events.get(eg).filter(ig=>ig!==gg)):this.events.delete(eg))}toDataUrl({padding:eg,type:gg="",exclude:ig=[],targetDPI:ng=203,isJudgeGrid:og=!1,skipCanvasRender:ag=!1,ribbonBorderPattern:sg=this.ribbonBorderPattern}={}){var pg;if(!this.canvas)return;const Ig=gg==="print"&&isPrintExportMetricsEnabled(),Cg=Ig?performance.now():0;this.canvas.discardActiveObject();const lg=this.getPlugin("RulerPlugin"),Ag=this.getPlugin("HistoryPlugin"),rg=this.getPlugin("WorkspacePlugin"),cg=rg.workspace;let ug=!1;og&&(ug=(cg==null?void 0:cg.isHasGrid)||!1,ug&&(rg==null||rg.hideGrid())),lg&&lg.disabled(),Ag&&Ag.disabled();const dg=Ig?performance.now():0,hg=this._toDataUrl(this.canvas,eg,{exclude:ig,targetDPI:ng,type:gg,ribbonBorderPattern:sg},cg),mg=Ig?performance.now():0;ag||this.canvas.renderAll();const bg=Ig?performance.now()-mg:0;if(lg&&lg.enabled(),Ag&&Ag.enabled(),og&&ug&&(rg==null||rg.showGrid()),Ig&&(printExportMetrics.count++,printExportMetrics.methodMs+=performance.now()-Cg,printExportMetrics.exportMs+=mg-dg,printExportMetrics.editorRenderMs+=bg,printExportMetrics.count===100)){const fg=window;fg.__LE_PRINT_RENDER_DETAILS__||(fg.__LE_PRINT_RENDER_DETAILS__={}),(pg=fg.__LE_PRINT_RENDER_DETAILS__).editor||(pg.editor=[]),fg.__LE_PRINT_RENDER_DETAILS__.editor.push({...printExportMetrics,unmeasuredMs:Number((printExportMetrics.methodMs-printExportMetrics.exportMs-printExportMetrics.editorRenderMs).toFixed(1))}),printExportMetrics.count=0,printExportMetrics.methodMs=0,printExportMetrics.exportMs=0,printExportMetrics.editorRenderMs=0}return hg}async toDataUrlOffscreen({padding:eg,type:gg="",exclude:ig=[],targetDPI:ng=203,isJudgeGrid:og=!1,ribbonBorderPattern:ag=this.ribbonBorderPattern,json:sg}={}){if(!this.canvas)return"";const Ig=this.getPlugin("WorkspacePlugin"),Cg=Ig==null?void 0:Ig.workspace;if(!Cg)return"";const lg=sg||this.canvas.toObject(cloneCommonField),Ag=this.canvas.getWidth(),rg=this.canvas.getHeight(),cg=document.createElement("canvas");cg.width=Ag,cg.height=rg;const ug=new In(cg,{enableRetinaScaling:!1,skipOffscreen:!1,selection:!1,preserveObjectStacking:!0});ug.setViewportTransform(this.canvas.viewportTransform?Array.from(this.canvas.viewportTransform):[1,0,0,1,0,0]);let dg=!1;const hg=Cg.width,mg=Cg.height;try{return await ug.loadFromJSON(lg),ug.renderAll(),typeof(Ig==null?void 0:Ig.createExportWorkspace)=="function"&&(Ig.createExportWorkspace(ug),ug.renderAll()),og&&(dg=Cg.isHasGrid||!1),this._toDataUrl(ug,eg,{exclude:ig,targetDPI:ng,type:gg,ribbonBorderPattern:ag},Cg)}finally{Cg.width=hg,Cg.height=mg,ug.dispose(),cg.remove()}}toTemplateJson(){const eg={};eg.Version="1.0.0-alpha.1",refreshObjectCenterProperties(this.canvas.getObjects());let gg=this.canvas.toObject(cloneCommonField);if(eg.canvas=JSON.stringify(gg),this._labelConfig){const ig=this._labelConfig;ig.fileId.length===0&&(ig.fileId=v4()),eg.labelConfig=ig}return this._databaseConfig&&(eg.databaseConfig=this._databaseConfig),this._rfidConfig&&(eg.rfidConfig=this._rfidConfig),this._filePath&&(eg.filePath=this._filePath),JSON.stringify(eg)}toJSON(){return refreshObjectCenterProperties(this.canvas.getObjects()),JSON.stringify(this.canvas.toObject(cloneCommonField))}fromTemplateJson(eg,gg){this.canvas&&(async()=>{const ig=await prepareCanvasImages(eg);try{await this.canvas.loadFromJSON(ig)}catch(og){console.warn("加载网络图片失败,已使用占位图继续打开模板",og),this.canvas.clear();const ag=await prepareCanvasImages(eg,!0);await this.canvas.loadFromJSON(ag)}this.canvas.renderAll(),gg(),this.bindData&&this.canvas&&(this.bindData.originState=JSON.stringify(this.canvas.toJSON()))})()}}const state$2=reactive({barcode2dSizeRatio:""});function getAlignedTextLeft(tg,eg,gg,ig){return ig==="center"?tg+(eg-gg)/2:ig==="right"?tg+eg-gg:tg}function getTextWidth(tg,eg,gg=0){return tg.measureText(eg).width+Math.max(0,Array.from(eg).length-1)*gg}let sRatio=Math.trunc(4/3*100)/100,longbeiClearCode=["10000502","10002500","10000503"];const Cu=class Cu extends ji{constructor(eg,gg){var og,ag;super(gg),this.lastCtx=null,this.lastDrawOption=null,this.hasToDataUrl=!1,this.counterProps=null,this.reviewValueArgs=null,this.barcodeDateFormatType="",this.increaseDate=!1,this.concatTextIdListObj=null,this.connectObjIds=[],this.isFirstLoad=!1,this.canModified=!0,this.useLongbeiCache=!0,this.inWorkerRender=!1,this.workerOtherImgData="",this.barcodeBodyHeight=0,this.textAreaHeight=0,this.isSyncingTextHeight=!1,this.emitErrorMessage=throttle$1(sg=>{canvasEventBus.emit("canvasShowError",sg)},800),this._cache={canvas:void 0,error:void 0},this.counterProps=gg&&gg.counterProps?gg.counterProps:this.counterProps,this.increaseDate=gg&&gg.increaseDate?gg.increaseDate:this.increaseDate,this.barcodeDateFormatType=gg&&gg.barcodeDateFormatType?gg.barcodeDateFormatType:this.barcodeDateFormatType,((og=eg.extra)==null?void 0:og.version)==="0"&&(eg.extra=omit(eg.extra,["version"])),((ag=eg.extra)==null?void 0:ag.eclevel)==="0"&&(eg.extra=omit(eg.extra,["eclevel"])),eg.custom||(eg.custom={}),this.barcode2dOptions=cloneDeep(eg),this.concatTextIdListObj=gg&&gg.concatTextIdListObj?gg.concatTextIdListObj:this.concatTextIdListObj,this.connectObjIds=gg.connectObjIds??this.connectObjIds,this.barcode2dOptions.includetext=eg.includetext??!1,this.barcode2dOptions.textposition=this.barcode2dOptions.includetext?this.barcode2dOptions.textposition||"bottom":"none",this.barcode2dOptions.textsize=this.barcode2dOptions.textsize||14,this.barcode2dOptions.textfontname=this.barcode2dOptions.textfontname||"Arial",this.barcode2dOptions.textxalign=this.barcode2dOptions.textxalign||"center",this.barcode2dOptions.textgaps=this.barcode2dOptions.textgaps||0,this.textAreaHeight=this.measureTextAreaHeight(this.barcode2dOptions),this.barcodeBodyHeight=Math.max(1,(this.height||1)-this.textAreaHeight),this.set({width:this.width,height:this.height}),this.on("modified",sg=>{console.log("eee=======",sg),lpBcid.includes(this.barcode2dOptions.bcid)&&(sg==null?void 0:sg.action)!=="drag"&&(this.canModified=!0,setTimeout(()=>{let Ig=this.barcode2dOptions.custom,Cg=this.width*this.scaleX,lg=this.height*this.scaleY,Ag=Math.max(Cg/lg,lg/Cg);Ag=Math.trunc(Ag*100)/100,[1,2,sRatio].includes(Ag)?(Ig.sizeRatio=Ag===1?"1x1":Ag===2?"2x1":"4x3",state$2.barcode2dSizeRatio=Ig.sizeRatio):(Ig.sizeRatio="auto",state$2.barcode2dSizeRatio=Ig.sizeRatio),console.log("state.barcode2dSizeRatio========",state$2.barcode2dSizeRatio)},30)),lpBcid.includes(this.barcode2dOptions.bcid)&&(sg==null?void 0:sg.action)==="drag"&&this.updateLpCodePosition()}),this.on("scaling",()=>{lpBcid.includes(this.barcode2dOptions.bcid)&&(this.canModified=!1,this.clearErrorLpCodeMap())}),canvasEventBus.off(`update:barcode2d:${this.id}`),canvasEventBus.on(`update:barcode2d:${this.id}`,async({list:sg,callback:Ig=function(){}}={})=>{let Cg=await this.updateBarCode2d(sg);Ig&&Ig(Cg)})}updateLpCodePosition(){let eg=this.getLpCache();eg&&(eg.x=this.left,eg.y=this.top)}clearErrorLpCodeMap(){errorLpCodeMap.delete(this.id)}getLpCache(){let eg="",gg=this.id;return this.barcode2dOptions.bcid==="LPCode"?eg=getLastCacheLpcode(gg):this.barcode2dOptions.bcid==="LPMixQrCode"&&(eg=getLastMixCacheLpcode(gg)),eg}drawLpCode(eg,gg,ig,ng,og,ag="",sg=null){var lg;let Ig=eg||this.lastCtx;if(this._cache.error=void 0,ag==="cache"&&(this.width=ng,this.height=og,this.scaleX=1,this.scaleY=1,sg&&(this.left=sg.x,this.top=sg.y),this.lastDrawOption={w:this.width,h:this.height,x:-this.width/2,y:-this.height/2},ig.w=this.lastDrawOption.w,ig.h=this.lastDrawOption.h,ig.x=this.lastDrawOption.x,ig.y=this.lastDrawOption.y,this.strokeWidth>0&&(ig.x+=this.strokeWidth,ig.y+=this.strokeWidth),this.setCoords()),this.inWorkerRender||(this.workerOtherImgData=gg),Ig.drawImage(gg,ig.x,ig.y,ng,og),this.strokeWidth>0){let Ag=this.stroke||"#fff";Ig.lineWidth=this.strokeWidth,Ig.strokeStyle=Ag,withObjectStrokeDash(Ig,this,()=>Ig.strokeRect(-this.width/2,-this.height/2,ng+this.strokeWidth*2,og+this.strokeWidth*2))}this.dirty=!0;let Cg=this.group;for(;Cg;)Cg.dirty=!0,Cg=Cg.group;this.isFirstLoad||(this.objectCaching=!1,this.isFirstLoad=!0),(lg=this.canvas)==null||lg.requestRenderAll(),this.objectCaching||setTimeout(()=>{this.objectCaching=!0},60)}getTextLayout(eg,gg,ig){if(!this.shouldShowText(gg))return{showText:!1,textGap:0,textLineHeight:0,textAreaHeight:0,barcodeHeight:ig};const{scaleY:og}=this.getRenderScale(),ag=14/og,sg=6/og,Ig=this.measureTextLineHeight(gg,eg),Cg=Math.ceil(Ig/og+ag+sg);return{showText:!0,textGap:ag,textLineHeight:Ig,textAreaHeight:Cg,barcodeHeight:ig}}shouldShowText(eg){return eg.includetext&&eg.textposition!=="none"&&!!eg.text}getMeasureContext(){return typeof document>"u"?null:document.createElement("canvas").getContext("2d")}measureTextLineHeight(eg,gg){const ig=Number(eg.textsize)||14,ng=gg||this.getMeasureContext();if(!ng)return ig*1.2;ng.save(),ng.font=`${ig}px ${eg.textfontname||"Arial"}`;const og=ng.measureText(eg.text||"");return ng.restore(),og.actualBoundingBoxAscent+og.actualBoundingBoxDescent||ig*1.2}measureTextAreaHeight(eg){if(!this.shouldShowText(eg))return 0;const{scaleY:gg}=this.getRenderScale(),ig=14/gg,ng=6/gg;return Math.ceil(this.measureTextLineHeight(eg)/gg+ig+ng)}syncTextHeight(eg){var og;const gg=this.barcodeBodyHeight||Math.max(1,(this.height||1)-this.textAreaHeight),ig=gg+eg;if(this.barcodeBodyHeight=gg,this.textAreaHeight=eg,Math.abs((this.height||0)-ig)<.01)return;this.isSyncingTextHeight=!0,this.set("height",ig),this.isSyncingTextHeight=!1,this.setCoords();let ng=this.group;for(;ng;)ng.dirty=!0,ng==null||ng.triggerLayout("childUpdate"),ng.setCoords(),ng=ng.group;(og=this.canvas)==null||og.requestRenderAll()}getRenderScale(){var ng;const eg=(ng=this.getObjectScaling)==null?void 0:ng.call(this),gg=Math.abs((eg==null?void 0:eg.x)||this.scaleX||1)||1,ig=Math.abs((eg==null?void 0:eg.y)||this.scaleY||1)||1;return{scaleX:gg,scaleY:ig}}renderText(eg,gg,ig,ng,og){if(!gg.includetext||gg.textposition==="none"||!gg.text)return;const ag=gg.textxalign||"center";eg.save();const{scaleX:sg,scaleY:Ig}=this.getRenderScale();eg.scale(1/sg,1/Ig),eg.font=`${gg.textsize||14}px ${gg.textfontname||"Arial"}`,eg.fillStyle=gg.textcolor||"#000";const Cg=Number(gg.textgaps)||0,lg=getTextWidth(eg,gg.text,Cg),Ag=Math.max(0,ig.w-(this.strokeWidth>0?this.strokeWidth*2:0)),rg=getAlignedTextLeft(ig.x,Ag,lg/sg,ag);eg.textAlign="left",eg.textBaseline="top",Cg&&(eg.letterSpacing=Cg+"px"),eg.fillText(gg.text,rg*sg,(ig.y+ng+og)*Ig),eg.restore()}async _render(eg){var og,ag,sg,Ig,Cg;const gg=cloneDeep(this.barcode2dOptions);this.lastCtx=eg;const ig=this.getTextLayout(eg,gg,this.barcodeBodyHeight||this.height),ng={w:this.width,h:this.height,x:-this.width/2,y:-this.height/2};if(eg.save(),eg.imageSmoothingEnabled=!1,this.dirty){if(gg.width=ng.w,gg.height=ig.barcodeHeight,typeof this.fill=="string"){let lg=rgbaStringToHex8(this.fill);gg.barcolor=hexToHex6_blend(lg)}this.strokeWidth>0&&(gg.width-=this.strokeWidth*2,gg.height-=this.strokeWidth*2);try{lpBcid.includes(gg.bcid)||(this._cache.canvas=generateCanvas(gg),this.dirty=!1,this._cache.error&&(this._cache.error=void 0))}catch(lg){this.dirty=!0,lg instanceof Error&&(console.log("error",lg.message),this._cache.error=lg.message),this._cache.canvas=void 0}}if(this.strokeWidth>0&&(ng.x+=this.strokeWidth,ng.y+=this.strokeWidth),this.lastDrawOption=ng,lpBcid.includes(gg.bcid)){let lg=this.lastDrawOption;const Ag=this.strokeWidth>0?lg.w-this.strokeWidth*2:lg.w,rg=Math.max(1,this.strokeWidth>0?ig.barcodeHeight-this.strokeWidth*2:ig.barcodeHeight);let cg=Ag*this.scaleX,ug=rg*this.scaleY,dg=gg.text,hg=Number((og=gg.extra)==null?void 0:og.eclevel)||1;hg=hg+"";let mg=Math.trunc(cg/Editor.DPI*25.4*100)/100,bg=Math.trunc(ug/Editor.DPI*25.4*100)/100,pg=mg/(bg||1),fg=((ag=gg.custom)==null?void 0:ag.CellSize)||"8",wg=`${dg}-${hg}-${mg+bg}-${pg}-${fg}`,Gg=`${this.id}`,Zg=null;if(gg.bcid==="LPMixQrCode"){let $g=((sg=gg.custom)==null?void 0:sg.LPErrLevel)||"0",Bg=((Ig=gg.custom)==null?void 0:Ig.QRErrLevel)||"0";hg=`${$g}-${Bg}`,wg=`${dg}-${hg}-${mg+bg}-${pg}-${fg}`}try{if(errorLpCodeMap.has(Gg)){errorLpCodeMap.set(Gg,this._cache.error||"龙贝码生成错误");let $g=this.getLpCache();if($g&&this.useLongbeiCache){let Bg=$g||{};Zg=Bg.img,this.drawLpCode(eg,Zg,lg,Bg.rWidth,Bg.rHeight,"cache",Bg),this._cache.error=void 0}else this._cache.error=errorLpCodeMap.get(Gg)||"龙贝码生成错误"}else{if(lpCodeMap.has(wg)&&this.useLongbeiCache){Zg=lpCodeMap.get(wg);let $g={id:this.id,sKey:wg,img:Zg,rWidth:cg,rHeight:ug,x:this.left,y:this.top};this.barcode2dOptions.bcid==="LPCode"?setCacheLpCode($g):setCacheMixLpCode($g)}else if(this.canModified){let $g={Content:dg,ErrLevel:hg,Width:mg,Height:bg,id:this.id,rWidth:cg,rHeight:ug,CellSize:fg,x:this.left,y:this.top,DPI:Editor.DPI};this.useLongbeiCache||lpCodeMap.delete(wg),this.barcode2dOptions.bcid==="LPCode"?Zg=await getBase64Data($g):Zg=await getMixBase64Data($g),this.useLongbeiCache=!0}if(lpCodeMap.has(wg)&&this.useLongbeiCache)this._cache.error=void 0,this.drawLpCode(eg,Zg,lg,Ag,rg);else if(this.useLongbeiCache){let $g=this.getLpCache();$g&&(Zg=($g||{}).img,this.drawLpCode(eg,Zg,lg,Ag,rg),this._cache.error=void 0)}}}catch($g){let Bg=$g&&$g.code,Wg=this.getLpCache();if(errorLpCodeMap.set(Gg,this._cache.error||"龙贝码生成错误"),Bg&&(longbeiClearCode.includes(Bg+"")&&(this.useLongbeiCache=!1,clearLpAndMixCacheById(this.id),this._cache.error=`龙贝码: ${$g.payload}`),this.emitErrorMessage($g.payload)),Wg&&this.useLongbeiCache){let yg=Wg||{};Zg=yg.img,this.drawLpCode(eg,Zg,lg,yg.rWidth,yg.rHeight,"cache",yg),this._cache.error=void 0}else Bg&&(this._cache.error=`龙贝码: ${$g.payload}`,this.dirty=!0,(Cg=this.canvas)==null||Cg.requestRenderAll())}}else this.objectCaching=!0;if(!this._cache.error&&!lpBcid.includes(gg.bcid)){if(this._cache.canvas){const lg=this.strokeWidth>0?ng.w-this.strokeWidth*2:ng.w,Ag=Math.max(1,this.strokeWidth>0?ig.barcodeHeight-this.strokeWidth*2:ig.barcodeHeight),rg=this._cache.canvas;if(eg.drawImage(rg,0,0,rg.width,rg.height,ng.x,ng.y,lg,Ag),this.strokeWidth>0){let cg=this.stroke||"#fff";eg.lineWidth=this.strokeWidth,eg.strokeStyle=cg,withObjectStrokeDash(eg,this,()=>eg.strokeRect(-this.width/2,-this.height/2,ng.w,ng.h))}}}if(!this._cache.error&&ig.showText&&this.renderText(eg,gg,ng,ig.barcodeHeight,ig.textGap),eg.translate(.5,.5),this._cache.error){const lg=wrapText(eg,this._cache.error,ng.w,"bold 18px 宋体"),Ag=getLineHeight(eg);let rg=ng.y+Ag;const cg=eg.fillStyle;eg.fillStyle="red";for(const ug of lg)eg.fillText(ug,ng.x,rg),rg+=Ag;eg.fillStyle=cg}eg.restore()}async getLongBeiImg(eg){var dg,hg,mg,bg;if(!lpBcid.includes(eg.bcid))return;let gg=this.lastDrawOption;const ig=this.strokeWidth>0?gg.w-this.strokeWidth*2:gg.w,ng=this.strokeWidth>0?gg.h-this.strokeWidth*2:gg.h;let og=eg.text,ag=Number((dg=eg.extra)==null?void 0:dg.eclevel)||1,sg=ig*this.scaleX,Ig=ng*this.scaleY,Cg=Math.trunc(sg/Editor.DPI*25.4*100)/100,lg=Math.trunc(Ig/Editor.DPI*25.4*100)/100,Ag=Cg/(lg||1),rg=((hg=eg.custom)==null?void 0:hg.CellSize)||"8",cg=`${og}-${ag}-${Cg+lg}-${Ag}-${rg}`,ug=null;if(eg.bcid==="LPMixQrCode"){let pg=((mg=eg.custom)==null?void 0:mg.LPErrLevel)||"0",fg=((bg=eg.custom)==null?void 0:bg.QRErrLevel)||"0";ag=`${pg}-${fg}`,cg=`${og}-${ag}-${Cg+lg}-${Ag}-${rg}`}this.clearErrorLpCodeMap();try{if(lpCodeMap.has(cg)&&this.useLongbeiCache)ug=lpCodeMap.get(cg);else{let pg={Content:og,ErrLevel:ag,Width:Cg,Height:lg,id:this.id,rWidth:sg,rHeight:Ig,CellSize:rg,x:this.left,y:this.top,DPI:Editor.DPI};this.barcode2dOptions.bcid==="LPCode"?ug=await getBase64Data(pg,"noSaveCache"):ug=await getMixBase64Data(pg,"noSaveCache"),this.useLongbeiCache=!0}return this.workerOtherImgData=ug,this._cache.error=void 0,ug}catch(pg){console.error(pg)}}dispose(){super.dispose()}set(eg,gg){return this.isSyncingTextHeight||(typeof eg=="string"?eg==="height"&&typeof gg=="number"&&(this.barcodeBodyHeight=Math.max(1,gg-this.textAreaHeight)):typeof eg.height=="number"&&(this.barcodeBodyHeight=Math.max(1,eg.height-this.textAreaHeight))),super.set(eg,gg)}countDate(eg=""){if(this.barcodeDateFormatType&&this.increaseDate){const gg=formatDate(this.barcodeDateFormatType);return console.log("formatted",gg),this.dirty=!0,eg!=="print"&&this.setBarcode2DOption({bcid:this.barcode2dOptions.bcid,text:gg}),gg}}countCurrent(eg){let gg=this.counterProps||eg;if(gg){let ig=gg;if(!ig.value&&ig.value!==0)return"";const ng=formatCounterValue(ig);return(ig.prefix&&ig.prefix.length>0?ig.prefix:"")+ng+(ig.suffix&&ig.suffix.length>0?ig.suffix:"")}return""}countNext(eg="print"){if(this.counterProps){let gg=this.counterProps;if(!gg.value&&gg.value!==0)return;eg==="review"&&!this.reviewValueArgs&&(this.reviewValueArgs={...gg});const ig=formatCounterValue(gg);let ng=(gg.prefix&&gg.prefix.length>0?gg.prefix:"")+ig+(gg.suffix&&gg.suffix.length>0?gg.suffix:"");const og=getNextCounterValue(gg);return og!==null&&(gg.value=og,this.counterProps.value=og),this.dirty=!0,ng}else return""}reviewRecover(){if(this.reviewValueArgs){const eg=this.reviewValueArgs;this.counterProps=eg,this.reviewValueArgs=null;const gg=formatCounterValue(eg);let ig=(eg.prefix&&eg.prefix.length>0?eg.prefix:"")+gg+(eg.suffix&&eg.suffix.length>0?eg.suffix:"");this.setBarcode2DOption({bcid:this.barcode2dOptions.bcid,text:ig})}}updateInGroup(){this.setCoords(),this.dirty=!0;let eg=this.group;for(;eg;)eg.dirty=!0,eg==null||eg.triggerLayout("childUpdate"),eg.setCoords(),eg=eg.group}async updateBarCode2d(eg=[],gg=""){var ig;if(this.concatTextIdListObj||this.connectObjIds&&this.connectObjIds.length>0){let ng=!1,og="",ag=[],sg=[];const Ig=lg=>{if(this.connectObjIds){let Ag=0;for(let rg of this.connectObjIds){if(rg.index=Ag,rg.id&&rg.id===lg.id){ng=!0;let cg=lg.text+"";if(lg.type==="counter"&&(lg._props.mode==="1"?cg=lg.countCurrent():lg._props.mode==="2"&&(lg.updateText({isUpdateBarCodeDate:!1}),cg=lg.text+"")),rg.maxEnd=cg.length,rg.isSplit){rg.start=Math.min(rg.start,rg.maxEnd);let ug=cg.slice(rg.start,rg.end);ag[Ag]=ug}else ag[Ag]=cg}Ag++}}},Cg=lg=>{lg.type==="text"&&this.concatTextIdListObj&&this.concatTextIdListObj[lg.id]&&(ng||(this.barcode2dOptions.bcid==="LPMixQrCode"?lg==null||lg.set("text",this.barcode2dOptions.text.replace(/\|&&&\|/g,"")):lg==null||lg.set("text",this.barcode2dOptions.text),lg.updateInGroup()),sg.push(lg))};if(eg.length>0)eg.forEach(lg=>{Ig(lg),Cg(lg)});else{const lg=Ag=>{Ag.type==="group"&&Ag._objects?Ag._objects.forEach(rg=>lg(rg)):(Ig(Ag),Cg(Ag))};(ig=this.canvas)==null||ig.getObjects().forEach(Ag=>lg(Ag))}return ng?(og=ag.join(""),this.barcode2dOptions.text=og,lpBcid.includes(this.barcode2dOptions.bcid)&&gg&&await this.getLongBeiImg(this.barcode2dOptions),this.dirty=!0,gg&&this.updateInGroup(),setTimeout(()=>{var lg;(lg=this.canvas)==null||lg.requestRenderAll()},0),sg.forEach(lg=>{lg==null||lg.set("text",og),lg.updateInGroup()}),og):""}else return""}setBarcode2DOption(eg){if(this.barcode2dOptions.bcid!==eg.bcid&&(eg.extra={},this.barcode2dOptions.extra={}),merge(this.barcode2dOptions,eg),eg.extra&&(typeof+eg.extra.version=="number"&&eg.extra.version==="0"&&(this.barcode2dOptions.extra=omit(this.barcode2dOptions.extra,["version"])),eg.extra.eclevel==="0"&&(this.barcode2dOptions.extra=omit(this.barcode2dOptions.extra,["eclevel"]))),this.syncTextHeight(this.measureTextAreaHeight(this.barcode2dOptions)),this.dirty=!0,!lpBcid.includes(this.barcode2dOptions.bcid)){let ig=this.group;for(;ig;)ig.dirty=!0,ig=ig.group}let gg=getAllObjectMap();this.updateBarCode2d([...gg.text,...gg.counter])}getBarcode2DOption(){return cloneDeep(this.barcode2dOptions)}toObject(eg){let gg=["barcode2dOptions","counterProps","concatTextIdListObj","increaseDate","barcodeDateFormatType","connectObjIds"];return super.toObject(eg?[...eg,...gg]:gg)}};Cu.type="Barcode2D";let ABarcode2D=Cu;ABarcode2D.fromObject=(tg,eg)=>ABarcode2D._fromObject(tg,{...eg,extraParam:"barcode2dOptions"}),tt.setClass(ABarcode2D),tt.setSVGClass(ABarcode2D);let contextMenuTextResolver=null;function setContextMenuTextResolver(tg){contextMenuTextResolver=tg}class ContextMenu{constructor(eg,gg){this.container=eg,this.menuItems=gg,this.activeSubmenus=[],this.shown=!1,this.disableTop=!1,this.disableBottom=!1,this.activeSubmenuHandler=this._activeSubmenuHandler.bind(this),this.menuItems=gg,this.menuElement=this.createMenuElement(),eg.appendChild(this.menuElement),this.setupEventListeners()}setTargetObj(eg){this.targetObj=eg}createMenuElement(){const eg=document.createElement("div");return eg.id="custom-context-menu",eg}resolveText(eg){if(eg==null)return"";const gg=eg;return(contextMenuTextResolver==null?void 0:contextMenuTextResolver(gg))??gg}createMenuItemElement(eg){const gg={itemText:eg.text??""};if(eg.isShow&&!eg.isShow(this.targetObj,gg))return document.createElement("div");if(gg.itemText=this.resolveText(gg.itemText),eg.isSeparator){const ag=document.createElement("div");return ag.classList.add("item-separator"),ag}if(eg.isGroupTitle){const ag=document.createElement("div");return ag.textContent=gg.itemText,ag.classList.add("item-group"),ag}const ig=document.createElement("div");ig.className="menu-item",ig.dataset.id=eg.id,eg.disabled&&ig.classList.add("canvas-contextmenu-disabled"),eg.subItems&&eg.subItems.length>0&&ig.classList.add("has-submenu");const ng=document.createElement("div");ng.textContent=gg.itemText;const og=document.createElement("div");if(og.classList.add("menu-item-content"),og.appendChild(ng),!eg.subItems||eg.subItems.length===0){const ag=document.createElement("div");ag.style.marginLeft="20px",ag.style.color="#999",ag.textContent=eg.hotKey||"",og.appendChild(ag)}if(ig.appendChild(og),eg.subItems&&eg.subItems.length>0){const ag=document.createElement("span");ag.className="arrow",ag.textContent="›",ig.appendChild(ag)}if(eg.subItems&&!eg.disabled){if(eg.subItems.length>0){const ag=this.activeSubmenus.length+1,sg=document.createElement("div");sg.className="submenu",sg.style.zIndex=ag+"",eg.subItems.forEach(Ig=>{const Cg=this.createMenuItemElement(Ig);Cg&&sg.appendChild(Cg)}),ig.appendChild(sg),ig.addEventListener("mouseenter",Ig=>{this.activeSubmenuHandler(Ig)||(sg.style.display="block",this.positionSubmenu(ig,sg),this.activeSubmenus.push(ig,sg))})}}else eg.disabled||(ig.addEventListener("click",ag=>{if(eg.handler){const sg=eg.handler(eg,ag);this.canvasContainer&&this.canvasContainer.focus({preventScroll:!0}),sg!==!1&&this.hide()}else this.hide();ag.stopPropagation()}),ig.addEventListener("mouseenter",this.activeSubmenuHandler));return ig}_activeSubmenuHandler(eg){if(this.activeSubmenus.length>0){const gg=eg.target;for(let ig=this.activeSubmenus.length-1;ig>0;ig-=2){const ng=this.activeSubmenus[ig-1],og=this.activeSubmenus[ig];if(ng.parentElement===gg.parentElement){if(ng===gg)return!0;og.style.display="none"}else{if(og.contains(gg))return!1;og.style.display="none"}this.activeSubmenus.pop(),this.activeSubmenus.pop()}}return!1}setupEventListeners(){document.addEventListener("click",eg=>{!this.menuElement.contains(eg.target)&&this.shown&&this.hide()}),document.addEventListener("keydown",eg=>{eg.key==="Escape"&&this.shown&&this.hide()})}positionMenu(eg,gg){const ig=window.innerWidth,ng=window.innerHeight,og=this.menuElement.offsetWidth,ag=this.menuElement.offsetHeight;eg+og>ig&&(eg=ig-og-5),gg+ag>ng&&(gg=ng-ag-5),this.menuElement.style.left=`${eg}px`,this.menuElement.style.top=`${gg}px`}positionSubmenu(eg,gg){const ig=eg.getBoundingClientRect(),ng=gg.offsetWidth,og=window.innerWidth,ag=getComputedStyle(gg);let sg=0,Ig=0;ig.right+ng>og?(sg=-ng-parseInt(ag.paddingLeft),gg.classList.add("left")):sg=ig.width+parseInt(ag.paddingLeft);const Cg=gg.offsetHeight,lg=window.innerHeight;ig.top+Cg>lg?Ig=ig.height-Cg+parseInt(ag.paddingBottom):Ig=-parseInt(ag.paddingTop),gg.style.left=`${sg}px`,gg.style.top=`${Ig}px`}show(eg,gg){console.time("show"),this.shown&&this.hide(),this.menuElement.innerHTML="",this.menuItems.forEach(ig=>{const ng=this.createMenuItemElement(ig);ng&&this.menuElement.appendChild(ng)}),this.menuElement.style.display="block",this.positionMenu(eg,gg),this.shown=!0,console.timeEnd("show")}hide(){this.shown&&(this.menuElement.style.display="none",this.menuElement.innerHTML="",this.shown=!1)}addItems(eg,gg){gg?this.addItemsToSubmenu(eg,gg,this.menuItems):this.menuItems.push(...eg)}addItemsToSubmenu(eg,gg,ig){for(const ng of ig){if(ng.id===gg)return ng.subItems||(ng.subItems=[]),ng.subItems.push(...eg),!0;if(ng.subItems&&this.addItemsToSubmenu(eg,gg,ng.subItems))return!0}return!1}updateItem(eg,gg){return this.updateItemRecursive(eg,gg,this.menuItems)}updateItemRecursive(eg,gg,ig){for(const ng of ig){if(ng.id===eg)return Object.assign(ng,gg),!0;if(ng.subItems&&this.updateItemRecursive(eg,gg,ng.subItems))return!0}return!1}removeItem(eg){return this.removeItemRecursive(eg,this.menuItems)}removeItemRecursive(eg,gg){const ig=gg.findIndex(ng=>ng.id===eg);if(ig!==-1)return gg.splice(ig,1),!0;for(const ng of gg)if(ng.subItems&&this.removeItemRecursive(eg,ng.subItems))return!0;return!1}getItems(){return this.menuItems}setItems(eg){this.menuItems=eg}}class ContextMenuPlugin{constructor(){this.name="ContextMenuPlugin",this.eventHandler={contextmenu:this.contextMenuHandler.bind(this)}}addItem(eg){var ig;const gg=Array.isArray(eg)?eg:[eg];(ig=this.contextMenu)==null||ig.addItems(gg),gg.forEach(ng=>{!ng.isGroupTitle&&!ng.isSeparator&&ng.hotKey&&ng.hotKeyHandler&&this.editor.addHotKey(ng.hotKey,ng.hotKeyHandler)})}removeItem(eg){var gg;(gg=this.contextMenu)==null||gg.removeItem(eg)}updateItem(eg,gg){if(this.contextMenu&&(this.contextMenu.updateItem(eg,gg),gg.hotKey&&gg.hotKeyHandler)){const ig=this.contextMenu.getItems().find(ng=>ng.id===eg);ig&&(ig.hotKey&&this.editor.removeHotKey(ig.hotKey),ig.hotKey=gg.hotKey,ig.hotKeyHandler=gg.hotKeyHandler,this.editor.addHotKey(ig.hotKey,ig.hotKeyHandler))}}disabled(){this.contextMenu&&this.container&&(this.editor.getCanvas().off("contextmenu",this.eventHandler.contextmenu),this.contextMenu.hide(),this.contextMenu.getItems().forEach(eg=>{!eg.isGroupTitle&&!eg.isSeparator&&eg.hotKey&&eg.hotKeyHandler&&this.editor.removeHotKey(eg.hotKey)}))}contextMenuHandler(eg){var gg;if(eg.e){const ig=eg.e;if(ig.button===2&&eg.target&&this.contextMenu){if(eg.target.id==="workspace")return;let ng=((gg=this.canvas)==null?void 0:gg.getObjects())||[];ng=ng.filter(Ig=>Ig.id!=="workspace");let og=ng==null?void 0:ng.indexOf(eg.target);const ag=og===(ng==null?void 0:ng.length)-1,sg=og===0;this.contextMenu.disableTop=ag,this.contextMenu.disableBottom=sg,eg.target.type==="activeselection"?eg.target.getObjects().length>1?(this.contextMenu.updateItem("lock",{disabled:!0}),this.contextMenu.updateItem("layer",{disabled:!0})):(this.contextMenu.updateItem("lock",{disabled:!1}),this.contextMenu.updateItem("layer",{disabled:!1})):(this.contextMenu.updateItem("lock",{disabled:!1}),this.contextMenu.updateItem("layer",{disabled:!1})),this.contextMenu.updateItem("layer-top",{disabled:!1}),this.contextMenu.updateItem("layer-up",{disabled:!1}),this.contextMenu.updateItem("layer-bottom",{disabled:!1}),this.contextMenu.updateItem("layer-down",{disabled:!1}),ag&&(this.contextMenu.updateItem("layer-top",{disabled:!0}),this.contextMenu.updateItem("layer-up",{disabled:!0})),sg&&(this.contextMenu.updateItem("layer-bottom",{disabled:!0}),this.contextMenu.updateItem("layer-down",{disabled:!0})),ig.preventDefault(),this.canvas.setActiveObject(eg.target),this.contextMenu.setTargetObj(eg.target),this.contextMenu.show(ig.clientX,ig.clientY)}}}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.container=document.getElementById("app"),this.contextMenu=new ContextMenu(this.container,[]),this.contextMenu.canvasContainer=this.canvas.elements.container,this.enabled()}enabled(){this.contextMenu&&this.container&&(this.editor.getCanvas().on("contextmenu",this.eventHandler.contextmenu),this.contextMenu.getItems().forEach(eg=>{!eg.isGroupTitle&&!eg.isSeparator&&eg.hotKey&&eg.hotKeyHandler&&this.editor.addHotKey(eg.hotKey,eg.hotKeyHandler)}))}}class Ruler{constructor(eg,gg){this.ctx=eg,this.dpi=96,this.isShown=!1,this.gapValue=0,this.getGapMM=ig=>{const ng=[.02,.05,.1,.2,.5,1,2,5,10],og=[500,200,100,50,25,10,5,2,1];let ag=0;for(;ag<ng.length&&ng[ag]<ig;)ag++;return og[ag-1]||1e3},this.options=gg}show(){this.isShown=!0}hide(){this.isShown=!1}drawLine(eg,gg,ig,ng,og,ag){this.ctx.save(),this.ctx.beginPath(),og&&(this.ctx.strokeStyle=og),this.ctx.lineWidth=ag??1,this.ctx.moveTo(eg+.5,gg+.5),this.ctx.lineTo(eg+ig+.5,gg+ng+.5),this.ctx.stroke(),this.ctx.restore()}drawText({text:eg="",left:gg=0,top:ig=0,fillStyle:ng,align:og,angle:ag,fontSize:sg=this.options.fontSize}){this.ctx.save(),ng&&(this.ctx.fillStyle=ng),this.ctx.textAlign=og??"left",this.ctx.textBaseline="top",this.ctx.font=`${sg??10}px sans-serif, Noto Sans, SourceHanSansCN`,ag&&(this.ctx.translate(gg,ig),this.ctx.rotate(Math.PI/180*ag),this.ctx.translate(-gg,-ig)),this.ctx.fillText(eg,gg,ig),this.ctx.restore()}darwRect({left:eg=0,top:gg=0,width:ig,height:ng,fillStyle:og,stroke:ag,strokeWidth:sg}){this.ctx.save(),this.ctx.beginPath(),og&&(this.ctx.fillStyle=og),this.ctx.rect(eg,gg,ig,ng),this.ctx.fill(),ag&&(this.ctx.strokeStyle=ag,this.ctx.lineWidth=sg??1,this.ctx.stroke()),this.ctx.restore()}drawMask(eg,gg,ig,ng,og,ag){this.ctx.save();const sg=eg?this.ctx.createLinearGradient(gg,og/2,gg+ng,og/2):this.ctx.createLinearGradient(ng/2,ig,ng/2,og+ig),Ig=new Le(ag);Ig.setAlpha(0),sg.addColorStop(0,Ig.toRgba()),sg.addColorStop(.33,ag),sg.addColorStop(.67,ag),sg.addColorStop(1,Ig.toRgba()),this.darwRect({left:gg,top:ig,width:ng,height:og,fillStyle:sg}),this.ctx.restore()}drawBackground(eg,gg,ig){const ng=this.options.rulerSize,og=this.options.canvasWidth,ag=this.options.canvasHeight;eg?this.darwRect({left:0,top:0,width:og,height:ng,fillStyle:this.options.backgroundColor}):this.darwRect({left:0,top:0,width:ng,height:ag,fillStyle:this.options.backgroundColor})}drawMM(eg,gg,ig){const ng=this.options.rulerSize,og=this.options.canvasWidth,ag=this.options.canvasHeight,sg=this.getGapMM(ig);this.gapValue=sg;const Ig=this.dpi/25.4*ig*sg,Cg=ng*.2,lg=ng*.8,Ag=new Le(this.options.textColor).toRgb();eg?(this.drawLine(0,0,og,0,this.options.borderColor),this.drawLine(0,ng,og,0,Ag)):(this.drawLine(0,0,0,ag,this.options.borderColor),this.drawLine(ng,0,0,ag,Ag)),this.ctx.save(),this.ctx.beginPath();let rg=sg>2,cg=sg>10?10:sg>=5?5:1;if(eg){if(this.ctx.rect(ng,0,og-ng,ng),this.ctx.clip(),gg<0){let hg=-gg*ig-Ig,mg=1;for(;hg>ng;){if(rg&&mg===1)for(let wg=1;wg<10;wg++){const Gg=hg+Ig/cg*wg;Gg>ng&&this.drawLine(Gg,Cg+13,0,lg*.3,Ag,1)}if(this.drawLine(hg,Cg+10,0,lg*.6,Ag),rg)for(let wg=1;wg<10;wg++){const Gg=hg-Ig/cg*wg;Gg>ng&&this.drawLine(Gg,Cg+13,0,lg*.3,Ag,1)}const bg=-mg*sg+"",pg=10*bg.length/4,fg=ng-this.options.fontSize-2;this.drawText({text:bg,left:hg-pg,top:fg-7,fillStyle:Ag,align:void 0,angle:0}),hg-=Ig,mg++}}let ug=-gg*ig,dg=0;for(;ug<og;){if(Math.ceil(ug)>=ng){if(this.drawLine(ug,Cg+10,0,lg*.6,Ag),rg)for(let pg=1;pg<10;pg++){const fg=ug+Ig/cg*pg;fg<og&&this.drawLine(fg,Cg+13,0,lg*.3,Ag,1)}const hg=dg*sg+"",mg=10*hg.length/4,bg=ng-this.options.fontSize-2;this.drawText({text:hg,left:ug-mg,top:bg-7,fillStyle:Ag,align:void 0,angle:0})}ug+=Ig,dg++}}else{if(this.ctx.rect(0,ng,ng,ag-ng),this.ctx.clip(),gg<0){let hg=-gg*ig-Ig,mg=1;for(;hg>ng;){if(rg&&mg===1)for(let wg=1;wg<10;wg++){const Gg=hg+Ig/cg*wg;Gg>ng&&this.drawLine(Cg+13,Gg,lg*.3,0,Ag,1)}if(this.drawLine(Cg+10,hg,lg*.6,0,Ag),rg)for(let wg=1;wg<10;wg++){const Gg=hg-Ig/cg*wg;Gg>ng&&this.drawLine(Cg+13,Gg,lg*.3,0,Ag,1)}const bg=-mg*sg+"",pg=10*bg.length/4,fg=ng-this.options.fontSize-2;this.drawText({text:bg,left:fg-7,top:hg+pg,fillStyle:Ag,align:void 0,angle:-90}),hg-=Ig,mg++}}let ug=-gg*ig,dg=0;for(;ug<ag;){if(ug>ng){if(this.drawLine(Cg+10,ug,lg*.6,0,Ag),rg)for(let pg=1;pg<10;pg++){const fg=ug+Ig/cg*pg;fg<ag&&this.drawLine(Cg+13,fg,lg*.3,0,Ag,1)}const hg=dg*sg+"",mg=10*hg.length/4,bg=ng-this.options.fontSize-2;this.drawText({text:hg,left:bg-7,top:ug+mg,fillStyle:Ag,align:void 0,angle:-90})}ug+=Ig,dg++}}this.ctx.restore()}drawActiveLine(eg,gg,ig){if(!this.objectRect)return;const ng=this.options.rulerSize,og=eg?"x":"y",ag=new Le(this.options.maskColor);this.objectRect[og].forEach(sg=>{if(ag.setAlpha(.5),sg.skip===og)return;let Ig=eg?sg.left:sg.top,Cg=eg?sg.width:sg.height,lg=(Ig-gg)*ig,Ag=Cg*ig;const rg={width:eg?Ag:ng-8,height:eg?ng-8:Ag,backgroundColor:this.options.backgroundColor};this.drawMask(eg,eg?lg:0,eg?2:lg,rg.width,rg.height,rg.backgroundColor),this.darwRect({left:eg?lg:ng-8,top:eg?ng-8:lg,width:eg?Ag:8,height:eg?8:Ag,fillStyle:ag.toRgba()});const cg=ng/2-(this.options.fontSize??12)/2-4,ug=pg=>Math.round(pg*(25.4/Editor.DPI)*100)/100+"",dg=ug(Ig),hg=ug(Ig+Cg),mg={fill:ag.toRgba(),angle:eg?0:-90};this.drawText({text:dg,left:eg?lg-2:cg,top:eg?cg:lg-15,fillStyle:mg.fill,align:eg?"right":"center",angle:mg.angle}),dg!==hg&&this.drawText({text:hg,left:eg?lg+Ag+2:cg,top:eg?cg:lg+Ag+17,fillStyle:mg.fill,align:eg?"left":"center",angle:mg.angle});const bg=dg===hg?8:14;ag.setAlpha(1),this.drawLine(eg?lg:ng-bg,eg?ng-bg:lg,eg?0:bg,eg?bg:0,ag.toRgba()),dg!==hg&&this.drawLine(eg?lg+Ag:ng-bg,eg?ng-bg:lg+Ag,eg?0:bg,eg?bg:0,ag.toRgba())})}}class RulerPlugin{constructor(){this.name="RulerPlugin",this.eventHandler={calcObjectRect:throttle$3(this.calcObjectRect.bind(this),15),selectinClear:throttle$3(this.selectionClear.bind(this),15),renderRuler:eg=>{eg.ctx&&this.renderRuler()},canvasMouseDown:throttle$3(this.canvasMouseDown.bind(this),15),canvasMouseMove:throttle$3(this.canvasMouseMove.bind(this),15),canvasMouseUp:throttle$3(this.canvasMouseUp.bind(this),15)}}uninstall(){}install(eg,gg){this.editor=eg;const ig=Object.assign({rulerSize:25,fontSize:12,canvasWidth:this.editor.getCanvas().width,canvasHeight:this.editor.getCanvas().height,backgroundColor:"#fff",borderColor:"#ddd",maskColor:"#007fff",textColor:"#888"},gg);this.ruler=new Ruler(eg.getCanvas().elements.lower.ctx,ig),eg.getPlugin("ContextMenuPlugin")}enabled(){if(this.editor&&this.ruler&&!this.ruler.isShown){const eg=this.editor.getCanvas();eg.on("after:render",this.eventHandler.calcObjectRect),eg.on("after:render",this.eventHandler.renderRuler),eg.on("mouse:down",this.eventHandler.canvasMouseDown),eg.on("mouse:move",this.eventHandler.canvasMouseMove),eg.on("mouse:up",this.eventHandler.canvasMouseUp),eg.on("selection:cleared",this.eventHandler.selectinClear),this.ruler.dpi=Editor.DPI,this.ruler.show(),this.renderRuler()}}disabled(){if(this.editor&&this.ruler&&this.ruler.isShown){this.ruler.hide();const eg=this.editor.getCanvas();eg.off("after:render",this.eventHandler.calcObjectRect),eg.off("after:render",this.eventHandler.renderRuler),eg.off("mouse:down",this.eventHandler.canvasMouseDown),eg.off("mouse:move",this.eventHandler.canvasMouseMove),eg.off("mouse:up",this.eventHandler.canvasMouseUp),eg.off("selection:cleared",this.eventHandler.selectinClear),this.editor.getCanvas().renderAll()}}setCanvasSize(eg,gg){this.ruler&&(this.ruler.options.canvasWidth=eg,this.ruler.options.canvasHeight=gg)}calcObjectRect(){if(!this.editor)return;const gg=this.editor.getCanvas().getActiveObjects();if(gg.length===0)return;const ig=gg.reduce((ng,og)=>{const ag=og.getBoundingRect();return ng.push(ag),ng},[]);ig.length!==0&&(this.ruler.objectRect={x:mergeLines(ig,!0),y:mergeLines(ig,!1)})}renderRuler(){if(!this.editor||!this.ruler||!this.ruler.isShown)return;const eg=this.editor.getCanvas(),gg=eg.viewportTransform;gg&&(this.ruler.drawBackground(!0,-(gg[4]/gg[0]),eg.getZoom()),this.ruler.drawBackground(!1,-(gg[5]/gg[3]),eg.getZoom()),this.ruler.drawMM(!0,-(gg[4]/gg[0]),eg.getZoom()),this.ruler.drawMM(!1,-(gg[5]/gg[3]),eg.getZoom()),this.ruler.drawActiveLine(!0,-(gg[4]/gg[0]),eg.getZoom()),this.ruler.drawActiveLine(!1,-(gg[5]/gg[3]),eg.getZoom()),this.ruler.options.callback&&this.ruler.options.callback(this.ruler.gapValue))}canvasMouseDown(){}canvasMouseUp(){}canvasMouseMove(){}selectionClear(){this.ruler&&(this.ruler.objectRect=void 0)}}const mergeLines=(tg,eg)=>{const gg=eg?"left":"top",ig=eg?"width":"height",ng=1e-6;if(!tg||tg.length===0)return[];if(tg.length===1)return[Object.assign({},tg[0])];tg.sort((sg,Ig)=>sg[gg]-Ig[gg]);const og=[];let ag=Object.assign({},tg[0]);for(let sg=1;sg<tg.length;sg++){const Ig=tg[sg],Cg=ag[gg]+ag[ig],lg=Ig[gg];if(Cg>=lg-ng){const Ag=Math.max(Cg,Ig[gg]+Ig[ig]);ag[ig]=Ag-ag[gg]}else og.push(ag),ag=Object.assign({},Ig)}return og.push(ag),og};class WorkspacePlugin{constructor(){this.name="WorkspacePlugin",this.gapVal=20,this.backgroundColor="#FFFFFFFF",this.backgroundImage="",this.backgroundImageCover=!0,this.backgroundImageElement=null,this.backgroundImageLoadId=0,this.resizeFrame=0,this.resizeTimer=null,this.lastCanvasSize={width:0,height:0},this.resizeObserver=new ResizeObserver(eg=>{!eg.find(ig=>ig.target===this.workspaceEl)||!this.canvas||(cancelAnimationFrame(this.resizeFrame),this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(()=>{this.resizeFrame=requestAnimationFrame(()=>{this.applyCanvasViewportSize()})},80))}),this.initWorkspace=()=>{const eg=this.canvas,gg=this.option.type;let ig;gg==="Rectangle"||gg==="RoundedRectangle"?ig=new Er({fill:this.option.backgroundColor??"yellow",width:this.option.width,height:this.option.height,rx:this.option.rx,ry:this.option.ry,strokeWidth:0}):ig=new _o({fill:this.option.backgroundColor??"yellow",width:this.option.width,height:this.option.height,rx:this.option.rx,ry:this.option.ry,strokeWidth:0}),ig.set("id","workspace"),ig.set("workspaceBackgroundColor",this.backgroundColor),ig.set("workspaceBackgroundImage",this.backgroundImage),ig.set("workspaceBackgroundImageCover",this.backgroundImageCover),this.bindRibbonBorderRender(ig),ig.set("selectable",!1),ig.set("hasControls",!1),ig.excludeFromExport=!0,ig.moveCursor="default",ig.hoverCursor="default",eg.insertAt(0,ig),this.workspace=ig,this.refreshWorkspaceBackground(),eg.renderAll();const{width:ng,height:og}=this.getWorkspaceViewportSize();eg.setDimensions({width:ng,height:og}),this.lastCanvasSize={width:ng,height:og},this.resizeObserver.observe(this.workspaceEl),eg.on("mouse:wheel",this.onWheel);const ag=eg.getWidth()*.7,sg=eg.getHeight()*.7,Ig=ag/this.option.width,Cg=sg/this.option.height;this.setZoomAuto(Math.min(Ig,Cg))},this.onWheel=eg=>{if(!this.canvas)return;const gg=eg.e.deltaY;let ig=this.canvas.getZoom();ig*=.999**gg,ig=this.clampZoom(ig);const ng=this.canvas.getCenter();this.canvas.zoomToPoint(new ot(ng.left,ng.top),ig),eg.e.preventDefault(),eg.e.stopPropagation()}}getWorkspaceViewportSize(){return{width:Math.floor(this.workspaceEl.clientWidth),height:Math.floor(this.workspaceEl.clientHeight)}}applyCanvasViewportSize(){if(!this.canvas)return;const{width:eg,height:gg}=this.getWorkspaceViewportSize();if(!(eg<=0||gg<=0)&&!(eg===this.lastCanvasSize.width&&gg===this.lastCanvasSize.height)){if(this.lastCanvasSize={width:eg,height:gg},this.editor){const ig=this.editor.getPlugin("RulerPlugin");ig&&ig.setCanvasSize(eg,gg)}this.canvas.setDimensions({width:eg,height:gg}),this.workspace&&this.setCenterFromObject(this.workspace)}}findParent(eg){for(;eg;){if(eg.id==="workspace")return eg;eg=eg.parentElement}return null}install(eg,gg){const ig=this.findParent(eg.getCanvas().elements.container);if(!ig)throw new Error("element #workspace is missing, plz check!");this.editor=eg,this.workspaceEl=ig,this.workspace=void 0,this.option=gg,this.backgroundColor=(gg==null?void 0:gg.backgroundColor)||"#FFFFFFFF",this.backgroundImage=(gg==null?void 0:gg.backgroundImage)||"",this.backgroundImageCover=(gg==null?void 0:gg.backgroundImageCover)!==!1,this.loadBackgroundImageElement(this.backgroundImage),this.editor.addHook("setSize",this.initWorkspace);const ng=eg.getCanvas();ng.backgroundImage=void 0,this.canvas=ng,this.initWorkspace()}uninstall(){var eg,gg;cancelAnimationFrame(this.resizeFrame),this.resizeTimer&&(clearTimeout(this.resizeTimer),this.resizeTimer=null),this.resizeObserver.disconnect(),(eg=this.canvas)==null||eg.off("mouse:wheel",this.onWheel),this.workspace&&((gg=this.canvas)==null||gg.remove(this.workspace)),this.workspace=void 0,this.canvas=void 0,this.editor=void 0}bindRibbonBorderRender(eg){const gg=eg._render.bind(eg);eg._render=ig=>{var sg,Ig,Cg;if(gg(ig),this.drawBackgroundImage(ig,eg),this.drawGrid(ig,eg),(sg=this.editor)!=null&&sg.getCanvas().get("flagToDataURL"))return;const ng=(Ig=this.editor)==null?void 0:Ig.ribbonBorderPattern;if(!ng||ng==="none")return;const og=eg.width||this.option.width,ag=eg.height||this.option.height;drawRibbonBorder(ig,ng,{left:-og/2,top:-ag/2,width:og,height:ag},(Cg=this.editor)==null?void 0:Cg.ribbonBorderTextures)}}createWorkspacePath(eg,gg){const ig=gg.width||this.option.width,ng=gg.height||this.option.height,og=-ig/2,ag=-ng/2;if(eg.beginPath(),gg.type==="ellipse"){eg.ellipse(0,0,ig/2,ng/2,0,0,Math.PI*2);return}const sg=Math.min(Math.abs(gg.rx||0),ig/2),Ig=Math.min(Math.abs(gg.ry||0),ng/2);if(!sg&&!Ig){eg.rect(og,ag,ig,ng);return}eg.moveTo(og+sg,ag),eg.lineTo(og+ig-sg,ag),eg.quadraticCurveTo(og+ig,ag,og+ig,ag+Ig),eg.lineTo(og+ig,ag+ng-Ig),eg.quadraticCurveTo(og+ig,ag+ng,og+ig-sg,ag+ng),eg.lineTo(og+sg,ag+ng),eg.quadraticCurveTo(og,ag+ng,og,ag+ng-Ig),eg.lineTo(og,ag+Ig),eg.quadraticCurveTo(og,ag,og+sg,ag)}drawBackgroundImage(eg,gg){const ig=this.backgroundImageElement;if(!ig||!this.backgroundImage)return;const ng=gg.width||this.option.width,og=gg.height||this.option.height,ag=ig.naturalWidth||ig.width,sg=ig.naturalHeight||ig.height;if(!ag||!sg)return;const Ig=this.backgroundImageCover?ng:ag,Cg=this.backgroundImageCover?og:sg,lg=-Ig/2,Ag=-Cg/2;eg.save(),this.createWorkspacePath(eg,gg),eg.clip(),eg.drawImage(ig,lg,Ag,Ig,Cg),eg.restore()}drawGrid(eg,gg){var Ig;if(!gg.isHasGrid||(Ig=this.editor)!=null&&Ig.getCanvas().get("flagToDataURL"))return;const ig=gg.width||this.option.width,ng=gg.height||this.option.height,og=-ig/2,ag=-ng/2,sg=20;eg.save(),this.createWorkspacePath(eg,gg),eg.clip(),eg.strokeStyle="#888",eg.lineWidth=1,eg.globalAlpha=1;for(let Cg=og+sg;Cg<og+ig;Cg+=sg)eg.beginPath(),eg.moveTo(Cg,ag),eg.lineTo(Cg,ag+ng),eg.stroke();for(let Cg=ag+sg;Cg<ag+ng;Cg+=sg)eg.beginPath(),eg.moveTo(og,Cg),eg.lineTo(og+ig,Cg),eg.stroke();eg.restore()}setZoomAuto(eg){if(!this.editor||!this.canvas)return;this.workspaceEl;const gg=this.editor.getCanvas();if(!gg)return;const ig=gg.getCenterPoint();gg.setViewportTransform(T$1),gg.zoomToPoint(new ot(ig.x,ig.y),eg),this.workspace&&this.setCenterFromObject(this.workspace)}setCenterFromObject(eg){if(!this.editor||!this.canvas)return;const gg=this.editor.getCanvas(),ig=eg.getCenterPoint(),ng=gg.viewportTransform;gg.width===void 0||gg.height===void 0||!ng||(ng[4]=gg.width/2-ig.x*ng[0],ng[5]=gg.height/2-ig.y*ng[3],gg.setViewportTransform(ng),gg.renderAll())}showGrid(){this.createGridBackground()}hideGrid(){this.createGridBackground(!1)}async setBackground({color:eg,image:gg,cover:ig}){eg!==void 0&&(this.backgroundColor=eg||"#FFFFFFFF"),gg!==void 0&&(this.backgroundImage=gg||""),ig!==void 0&&(this.backgroundImageCover=ig),this.workspace&&(this.workspace.set("workspaceBackgroundColor",this.backgroundColor),this.workspace.set("workspaceBackgroundImage",this.backgroundImage),this.workspace.set("workspaceBackgroundImageCover",this.backgroundImageCover)),gg!==void 0&&await this.loadBackgroundImageElement(this.backgroundImage),this.refreshWorkspaceBackground()}refreshWorkspaceBackground(){!this.workspace||!this.canvas||(this.workspace.set("fill",this.backgroundColor||"#FFFFFFFF"),this.workspace.dirty=!0,this.canvas.requestRenderAll())}async loadBackgroundImageElement(eg){var ig;const gg=++this.backgroundImageLoadId;if(!eg){this.backgroundImageElement=null;return}try{const ng=await new Promise((og,ag)=>{const sg=new Image;sg.onload=()=>og(sg),sg.onerror=ag,sg.src=eg});if(gg!==this.backgroundImageLoadId)return;this.backgroundImageElement=ng,this.workspace&&(this.workspace.dirty=!0),(ig=this.canvas)==null||ig.requestRenderAll()}catch(ng){if(gg!==this.backgroundImageLoadId)return;this.backgroundImageElement=null,console.log("load background image error",ng)}}createGridBackground(eg=!0){!this.canvas||!this.workspace||(this.workspace.set("isHasGrid",eg),this.workspace.dirty=!0,this.canvas.renderAll())}getFitZoom(){if(!this.canvas||!this.option)return .2;const eg=this.canvas.getWidth()*.7,gg=this.canvas.getHeight()*.7,ig=eg/this.option.width,ng=gg/this.option.height;return Math.min(ig,ng)}getMinZoom(){return Math.max(.005,Math.min(.2,this.getFitZoom()*.5))}getMaxZoom(){return 12}clampZoom(eg){return Math.min(this.getMaxZoom(),Math.max(this.getMinZoom(),eg))}big(){let eg=this.canvas.getZoom();eg+=.05;const gg=this.canvas.getCenter();this.canvas.zoomToPoint(new ot(gg.left,gg.top),this.clampZoom(eg))}small(){let eg=this.canvas.getZoom();eg-=.05;const gg=this.canvas.getCenter();this.canvas.zoomToPoint(new ot(gg.left,gg.top),this.clampZoom(eg))}auto(){this.setZoomAuto(this.getFitZoom())}one(){this.setZoomAuto(1)}createExportWorkspace(eg){if(!this.workspace)return null;const gg=this.workspace,ig=gg.type==="ellipse",ng={fill:this.backgroundColor,width:gg.width,height:gg.height,rx:gg.rx,ry:gg.ry,strokeWidth:0,left:gg.left,top:gg.top};let og;if(ig?og=new _o(ng):og=new Er(ng),og.set("id","workspace"),og.set("selectable",!1),this.backgroundImageElement&&this.backgroundImage){const ag=og._render.bind(og);og._render=sg=>{ag(sg),this.drawBackgroundImage(sg,og)}}return eg.insertAt(0,og),og}enabled(){}disabled(){}}const aligningLineConfig={margin:4,width:1,color:"rgb(255,0,0,0.9)"};function getDistance(tg,eg){return Math.abs(tg-eg)}function setPositionDir(tg,eg,gg){const ig=tg.translateToCenterPoint(eg,"center","center"),ng=tg.translateToOriginPoint(ig,tg.originX,tg.originY);gg=="x"?tg.setX(ng.x):tg.setY(ng.y)}const originXArr=["left","center","right"],originYArr=["top","center","bottom"];function collectVerticalPoint(tg){var eg,gg;const ig=aligningLineConfig.margin,{activeObject:ng,isScale:og,index:ag,point:sg,list:Ig}=tg,{dis:Cg,arr:lg}=getDistanceList(sg,Ig,"x"),Ag=ig/((eg=(gg=ng.canvas)===null||gg===void 0?void 0:gg.getZoom())!==null&&eg!==void 0?eg:1);if(Cg>Ag)return[];let rg=lg[lg.length-1].x-sg.x;const cg=ag==0||ag==3?-1:1;rg*=cg;const{width:ug,scaleX:dg,left:hg}=ng,mg=ng._getTransformedDimensions(),bg=(rg+mg.x)/mg.x;og?ng.set("scaleX",dg*bg):ng.set("width",ug*bg);const pg=[0,rg/2*cg,rg*cg];cg<0&&pg.reverse();const fg=pg[originXArr.indexOf(ng.originX)];return ng.set("left",hg+fg),ng.setCoords(),lg.map(wg=>({x:wg.x,y1:wg.y,y2:sg.y}))}function collectHorizontalPoint(tg){var eg,gg;const ig=aligningLineConfig.margin,{activeObject:ng,isScale:og,index:ag,point:sg,list:Ig}=tg,{dis:Cg,arr:lg}=getDistanceList(sg,Ig,"y"),Ag=ig/((eg=(gg=ng.canvas)===null||gg===void 0?void 0:gg.getZoom())!==null&&eg!==void 0?eg:1);if(Cg>Ag)return[];let rg=lg[lg.length-1].y-sg.y;const cg=ag<2?-1:1;rg*=cg;const{height:ug,scaleY:dg,top:hg}=ng,mg=ng._getTransformedDimensions(),bg=(rg+mg.y)/mg.y;og?ng.set("scaleY",dg*bg):ng.set("height",ug*bg);const pg=[0,rg/2*cg,rg*cg];cg<0&&pg.reverse();const fg=pg[originYArr.indexOf(ng.originY)];return ng.set("top",hg+fg),ng.setCoords(),lg.map(wg=>({y:wg.y,x1:wg.x,x2:sg.x}))}function getDistanceList(tg,eg,gg){let ig=1/0,ng=[];for(const og of eg){const ag=getDistance(tg[gg],og[gg]);ig>ag&&(ng=[],ig=ag),ig==ag&&ng.push(og)}return{dis:ig,arr:ng}}function drawLine(tg,eg,gg){const{width:ig,color:ng}=aligningLineConfig,og=tg.getSelectionContext(),ag=tg.viewportTransform,sg=tg.getZoom();og.save(),og.transform(...ag),og.lineWidth=ig/sg,og.strokeStyle=ng,og.beginPath(),og.moveTo(eg.x,eg.y),og.lineTo(gg.x,gg.y),og.stroke(),drawX(og,sg,eg),drawX(og,sg,gg),og.restore()}const xSize=2.4;function drawX(tg,eg,gg){const ig=xSize/eg;tg.save(),tg.translate(gg.x,gg.y),tg.beginPath(),tg.moveTo(-ig,-ig),tg.lineTo(ig,ig),tg.moveTo(ig,-ig),tg.lineTo(-ig,ig),tg.stroke(),tg.restore()}function drawPoint(tg,eg){const{width:gg,color:ig}=aligningLineConfig,ng=tg.getSelectionContext(),og=tg.viewportTransform,ag=tg.getZoom();ng.save(),ng.transform(...og),ng.lineWidth=gg/ag,ng.strokeStyle=ig;for(const sg of eg)drawX(ng,ag,sg);ng.restore()}function drawPointList(tg,eg){const gg=eg.map(ig=>{const ng="y2"in ig,og=ng?ig.x:ig.x1,ag=ng?ig.y1:ig.y;return new ot(og,ag)});drawPoint(tg,gg)}function drawVerticalLine(tg,eg){const gg=eg.x,ig=new ot(gg,eg.y1),ng=new ot(gg,eg.y2);drawLine(tg,ig,ng)}function drawHorizontalLine(tg,eg){const gg=eg.y,ig=new ot(eg.x1,gg),ng=new ot(eg.x2,gg);drawLine(tg,ig,ng)}function getObjectsByTarget(tg){const eg=new Set,gg=tg.canvas;if(!gg)return eg;const ig=tg instanceof Jo?tg.getObjects():[tg];return gg.forEachObject(ng=>{if(ng.isOnScreen()&&ng.visible){if(ng.constructor==Hr){collectObjectsByGroup(eg,ng);return}eg.add(ng)}}),deleteObjectsByList(eg,ig),eg}function deleteObjectsByList(tg,eg){for(const gg of eg)gg.constructor==Hr?deleteObjectsByList(tg,gg.getObjects()):tg.delete(gg)}function collectObjectsByGroup(tg,eg){const gg=eg.getObjects();for(const ig of gg)if(ig.visible){if(ig.constructor==Hr){collectObjectsByGroup(tg,ig);continue}tg.add(ig)}}function collectLine(tg){var eg,gg;const ig=aligningLineConfig.margin,{activeObject:ng,activeObjectRect:og,objectRect:ag}=tg,sg=makeLineByRect(ag),Ig=makeLineByRect(og),Cg=ig/((eg=(gg=ng.canvas)===null||gg===void 0?void 0:gg.getZoom())!==null&&eg!==void 0?eg:1),lg={target:ng,list:sg,aList:Ig,margin:Cg},Ag=collectVerticalLine(lg),rg=collectHorizontalLine(lg);return{vLines:Ag,hLines:rg}}function collectVerticalLine(tg){const{target:eg,list:gg,aList:ig,margin:ng}=tg,og=ig.map(Ag=>getDistanceLine(Ag,gg,"x")),ag=Math.min(...og.map(Ag=>Ag.dis));if(ag>ng)return[];const sg=[],Ig=ig[0].x2-ig[0].x,Cg=ig[0].y2-ig[0].y;let lg=!1;for(let Ag=0;Ag<og.length;Ag++){const rg=og[Ag];if(ag==rg.dis){const cg=gg[rg.index],ug=ig[rg.index],dg=cg.x,hg=ug.y,mg=Math.min(cg.y,cg.y2,hg,ug.y2),bg=Math.max(cg.y,cg.y2,hg,ug.y2);if(sg.push({x:dg,y1:mg,y2:bg}),lg)continue;lg=!0,setPos({target:eg,x:dg,y:hg,centerX:Ag-1,centerY:rg.index-1,width:Ig,height:Cg,dir:"x"});const pg=ag*rg.dir;ig.forEach(fg=>fg.x-=pg)}}return sg}function collectHorizontalLine(tg){const{target:eg,list:gg,aList:ig,margin:ng}=tg,og=ig.map(Ag=>getDistanceLine(Ag,gg,"y")),ag=Math.min(...og.map(Ag=>Ag.dis));if(ag>ng)return[];const sg=[],Ig=ig[0].x2-ig[0].x,Cg=ig[0].y2-ig[0].y;let lg=!1;for(let Ag=0;Ag<og.length;Ag++){const rg=og[Ag];if(ag==rg.dis){const cg=gg[rg.index],ug=ig[rg.index],dg=cg.y,hg=ug.x,mg=Math.min(cg.x,cg.x2,hg,ug.x2),bg=Math.max(cg.x,cg.x2,hg,ug.x2);if(sg.push({y:dg,x1:mg,x2:bg}),lg)continue;lg=!0,setPos({target:eg,x:hg,y:dg,centerX:rg.index-1,centerY:Ag-1,width:Ig,height:Cg,dir:"y"});const pg=ag*rg.dir;ig.forEach(fg=>fg.y-=pg)}}return sg}function getDistanceLine(tg,eg,gg){let ig=1/0,ng=-1,og=1;for(let ag=0;ag<eg.length;ag++){const sg=getDistance(tg[gg],eg[ag][gg]);ig>sg&&(ng=ag,ig=sg,og=tg[gg]>eg[ag][gg]?1:-1)}return{dis:ig,index:ng,dir:og}}function makeLineByRect(tg){const{left:eg,top:gg,width:ig,height:ng}=tg,og={x:eg,y:gg,x2:eg+ig,y2:gg+ng},ag=eg+ig/2,sg=gg+ng/2,Ig={x:ag,y:sg,x2:ag,y2:sg},Cg={x:eg+ig,x2:eg,y:gg+ng,y2:gg};return[og,Ig,Cg]}function setPos(tg){const{target:eg,centerX:gg,centerY:ig,width:ng,height:og,dir:ag}=tg;let{x:sg,y:Ig}=tg;sg-=gg*ng/2,Ig-=ig*og/2,setPositionDir(eg,new ot(sg,Ig),ag),eg.setCoords()}function initAligningGuidelines(tg){let eg=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(aligningLineConfig,eg);const gg=new Set,ig=new Set;let ng=!1;const og=new Map,ag=rg=>{const cg=[rg.calcTransformMatrix().toString(),rg.width,rg.height].join(),ug=og.get(cg);if(ug)return ug;const dg=rg.getCoords(),mg=[kn.makeBoundingBoxFromPoints(dg),dg];return og.set(cg,mg),mg};function sg(rg){const cg=rg.target;cg.setCoords(),ng=!1,ig.clear(),gg.clear();const ug=getObjectsByTarget(cg),dg=cg.getBoundingRect();for(const hg of ug){const mg=ag(hg)[0],{vLines:bg,hLines:pg}=collectLine({activeObject:cg,activeObjectRect:dg,objectRect:mg});bg.forEach(fg=>{ig.add(JSON.stringify(fg))}),pg.forEach(fg=>{gg.add(JSON.stringify(fg))})}}function Ig(rg){const cg=rg.target;cg.setCoords();const ug=String(rg.transform.action).startsWith("scale");ig.clear(),gg.clear();const dg=getObjectsByTarget(cg);let hg=rg.transform.corner;cg.flipX&&(hg=hg.replace("l","r").replace("r","l")),cg.flipY&&(hg=hg.replace("t","b").replace("b","t"));let mg=["tl","tr","br","bl","mt","mr","mb","ml"].indexOf(hg);if(mg==-1)return;if(ng=mg>3,ng){if(cg.getTotalAngle()%90!=0)return;mg-=4}let bg=cg.getCoords()[mg];for(const pg of dg){const[fg,wg]=ag(pg),Gg=new ot(fg.left+fg.width/2,fg.top+fg.height/2),Zg=[...wg,Gg],$g={activeObject:cg,point:bg,list:Zg,isScale:ug,index:mg},Bg=collectVerticalPoint($g),Wg=collectHorizontalPoint($g);Bg.forEach(yg=>{ig.add(JSON.stringify(yg))}),Wg.forEach(yg=>{gg.add(JSON.stringify(yg))}),(Bg.length||Wg.length)&&(bg=cg.getCoords()[mg])}}function Cg(){tg.clearContext(tg.contextTop)}function lg(){if(ng){const rg=[];for(const cg of ig)rg.push(JSON.parse(cg));for(const cg of gg)rg.push(JSON.parse(cg));drawPointList(tg,rg)}else{for(const rg of ig)drawVerticalLine(tg,JSON.parse(rg));for(const rg of gg)drawHorizontalLine(tg,JSON.parse(rg))}}function Ag(){ig.clear(),gg.clear(),og.clear(),tg.requestRenderAll()}return tg.on("object:resizing",Ig),tg.on("object:scaling",Ig),tg.on("object:moving",sg),tg.on("before:render",Cg),tg.on("after:render",lg),tg.on("mouse:up",Ag),()=>{tg.off("object:resizing",Ig),tg.off("object:scaling",Ig),tg.off("object:moving",sg),tg.off("before:render",Cg),tg.off("after:render",lg),tg.off("mouse:up",Ag)}}class GuidelinesPlugin{constructor(){this.name="GuidelinesPlugin"}install(eg,gg={}){this.editor=eg,this.options=gg,this.enabled()}enabled(){this.editor&&(this.deactivate=initAligningGuidelines(this.editor.getCanvas(),this.options))}disabled(){this.deactivate&&this.deactivate()}}const getEffectiveCanvasTool=(tg,eg)=>eg.size>0?"pan":tg,isEditableShortcutTarget=tg=>{var ig;if(!tg||typeof tg.tagName!="string")return!1;const eg=tg,gg=eg.tagName.toUpperCase();return gg==="INPUT"||gg==="TEXTAREA"||gg==="SELECT"||!!((ig=eg.closest)!=null&&ig.call(eg,'[contenteditable="true"]'))};class DringPlugin{constructor(){this.name="DringPlugin",this.persistentTool="select",this.temporaryPanSources=new Set,this.isDragging=!1,this.isEnabled=!1,this.lastPosX=0,this.lastPosY=0,this.previousCanvasSelection=!0,this.previousSkipTargetFind=!1,this.previousDefaultCursor="default",this.dispose=[],this.mouseDown=eg=>{const gg=eg.e,ig=this.getPointerPanSource(gg);ig&&this.temporaryPanSources.add(ig),!(!(gg.button===0&&this.getEffectiveTool()==="pan")&&!ig)&&(gg.preventDefault(),this.isDragging=!0,this.lastPosX=gg.clientX,this.lastPosY=gg.clientY,this.applyEffectiveTool())},this.mouseMove=eg=>{if(!this.isDragging||!this.canvas.viewportTransform)return;const gg=eg.e,ig=this.canvas.viewportTransform;ig[4]+=gg.clientX-this.lastPosX,ig[5]+=gg.clientY-this.lastPosY,this.lastPosX=gg.clientX,this.lastPosY=gg.clientY,this.canvas.setCursor("grabbing"),this.canvas.requestRenderAll()},this.mouseUp=()=>{this.finishDragging()},this.windowMouseUp=()=>{this.finishDragging()},this.keyDown=eg=>{if(isEditableShortcutTarget(eg.target)||this.isFabricTextEditing())return;if(eg.code==="Space"){eg.preventDefault(),this.temporaryPanSources.add("space"),this.applyEffectiveTool();return}if(eg.repeat)return;const gg=eg.key.toLowerCase();gg==="v"?this.setTool("select"):gg==="h"&&this.setTool("pan")},this.keyUp=eg=>{eg.code==="Space"&&(this.temporaryPanSources.delete("space"),this.applyEffectiveTool())},this.windowBlur=()=>{this.temporaryPanSources.clear(),this.isDragging=!1,this.applyEffectiveTool()}}install(eg){this.editor=eg,this.canvas=eg.getCanvas(),this.previousCanvasSelection=this.canvas.selection,this.previousSkipTargetFind=this.canvas.skipTargetFind,this.previousDefaultCursor=this.canvas.defaultCursor,this.enabled()}uninstall(){this.disabled()}enabled(){this.isEnabled||(this.isEnabled=!0,this.dispose.push(this.canvas.on("mouse:down",this.mouseDown)),this.dispose.push(this.canvas.on("mouse:move",this.mouseMove)),this.dispose.push(this.canvas.on("mouse:up",this.mouseUp)),document.addEventListener("keydown",this.keyDown),document.addEventListener("keyup",this.keyUp),window.addEventListener("mouseup",this.windowMouseUp),window.addEventListener("blur",this.windowBlur),this.applyEffectiveTool())}disabled(){this.isEnabled&&(this.isEnabled=!1,this.dispose.forEach(eg=>eg()),this.dispose.length=0,document.removeEventListener("keydown",this.keyDown),document.removeEventListener("keyup",this.keyUp),window.removeEventListener("mouseup",this.windowMouseUp),window.removeEventListener("blur",this.windowBlur),this.temporaryPanSources.clear(),this.isDragging=!1,this.canvas.selection=this.previousCanvasSelection,this.canvas.skipTargetFind=this.previousSkipTargetFind,this.canvas.defaultCursor=this.previousDefaultCursor,this.canvas.setCursor(this.previousDefaultCursor),this.canvas.requestRenderAll())}getTool(){return this.persistentTool}setTool(eg){this.persistentTool!==eg&&(this.persistentTool=eg,eg==="pan"&&this.canvas.discardActiveObject(),this.applyEffectiveTool(),canvasEventBus.emit("canvasToolChanged",{editor:this.editor,tool:eg}))}getEffectiveTool(){return getEffectiveCanvasTool(this.persistentTool,this.temporaryPanSources)}applyEffectiveTool(){const eg=this.getEffectiveTool()==="pan",gg=this.isDragging?"grabbing":eg?"grab":this.previousDefaultCursor;this.canvas.selection=eg?!1:this.previousCanvasSelection,this.canvas.skipTargetFind=eg?!0:this.previousSkipTargetFind,this.canvas.defaultCursor=gg,this.canvas.setCursor(gg),this.canvas.requestRenderAll()}finishDragging(){!this.isDragging&&!this.hasPointerPanSource()||(this.isDragging=!1,this.temporaryPanSources.delete("alt"),this.applyEffectiveTool())}getPointerPanSource(eg){if(eg.button!==1&&eg.altKey)return"alt"}hasPointerPanSource(){return this.temporaryPanSources.has("alt")}isFabricTextEditing(){const eg=this.canvas.getActiveObject();return!!(eg&&"isEditing"in eg&&eg.isEditing)}}class LockPlugin{constructor(){this.name="LockPlugin"}install(eg,gg){this.editor=eg,this.enabled()}switchLock(){const eg=this.editor;if(eg){const gg=eg.getCanvas(),ig=gg.getActiveObject();ig&&(ig.locked=!ig.locked,gg.fire("custom:object:history",{target:ig,action:"history:update"}))}}enabled(){if(this.editor){const gg=this.editor.getPlugin("ContextMenuPlugin");gg&&gg.addItem([{id:"lock",text:"editor.contextMenu.lock",hotKey:"Ctrl+L",hotKeyHandler:ig=>{this.switchLock()},handler:(ig,ng)=>(this.switchLock(),!0),isShow:(ig,ng)=>(ng&&(ng.itemText=ig!=null&&ig.locked?"editor.contextMenu.unlock":"editor.contextMenu.lock"),!!ig)}])}}disabled(){if(this.editor){const gg=this.editor.getPlugin("ContextMenuPlugin");gg&&gg.removeItem("lock")}}}class LayerPlugin{constructor(){this.name="LayerPlugin"}workspaceSendToBack(){const eg=this.canvas,gg=eg.getObjects().find(ig=>ig.id==="workspace");gg&&eg.sendObjectToBack(gg)}layerChangeRefresh(){this.canvas.fire("custom:object:refreshList")}up(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=eg.getActiveObjects()[0];ig&&eg.bringObjectForward(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}down(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=eg.getActiveObjects()[0];ig&&eg.sendObjectBackwards(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}toFront(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=gg[0];ig&&eg.bringObjectToFront(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}toBack(){const eg=this.canvas,gg=eg.getActiveObjects();if(gg&&gg.length===1){const ig=gg[0];ig&&eg.sendObjectToBack(ig),eg.renderAll(),this.workspaceSendToBack(),this.layerChangeRefresh()}}install(eg,gg){this.editor=eg;const ig=eg.getCanvas();this.canvas=ig;const ng=eg.getPlugin("ContextMenuPlugin");ng&&ng.addItem({id:"layer",text:"editor.contextMenu.layers",subItems:[{id:"layer-up",text:"editor.contextMenu.bringForward",handler:(og,ag)=>(this.up(),!0)},{id:"layer-down",text:"editor.contextMenu.sendBackwards",handler:(og,ag)=>(this.down(),!0)},{id:"layer-top",text:"editor.contextMenu.bringToFront",handler:(og,ag)=>(this.toFront(),!0)},{id:"layer-bottom",text:"editor.contextMenu.sendToBack",handler:(og,ag)=>(this.toBack(),!0)}]})}enabled(){}disabled(){}}class ControlsPlugin{constructor(){this.name="ControlsPlugin",this.controls={}}drawImg(eg,gg,ig,ng,og,ag,sg){sg!==void 0&&(eg.save(),eg.translate(gg,ig),eg.rotate(kn.degreesToRadians(sg)),eg.drawImage(ng,-og/2,-ag/2,og,ag),eg.restore())}intervalControl(){const eg=document.createElement("img");eg.src=this.option.verticalImg;const gg=document.createElement("img");gg.src=this.option.horizontalImg;const ig=(og,ag,sg,Ig,Cg)=>{this.drawImg(og,ag,sg,eg,20,25,Cg.angle)},ng=(og,ag,sg,Ig,Cg)=>{this.drawImg(og,ag,sg,gg,25,20,Cg.angle)};return{ml:new ni({x:-.5,y:0,offsetX:-1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingXOrSkewingY,getActionName:ja.scaleOrSkewActionName,render:ig}),mr:new ni({x:.5,y:0,offsetX:1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingXOrSkewingY,getActionName:ja.scaleOrSkewActionName,render:ig}),mb:new ni({x:0,y:.5,offsetY:1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingYOrSkewingX,getActionName:ja.scaleOrSkewActionName,render:ng}),mt:new ni({x:0,y:-.5,offsetY:-1,cursorStyleHandler:ja.scaleSkewCursorStyleHandler,actionHandler:ja.scalingYOrSkewingX,getActionName:ja.scaleOrSkewActionName,render:ng})}}peakControl(){const eg=document.createElement("img");eg.src=this.option.edgeImg;const gg=(ig,ng,og,ag,sg)=>{this.drawImg(ig,ng,og,eg,25,25,sg.angle)};return{tl:new ni({x:-.5,y:-.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg}),bl:new ni({x:-.5,y:.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg}),tr:new ni({x:.5,y:-.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg}),br:new ni({x:.5,y:.5,cursorStyleHandler:ja.scaleCursorStyleHandler,actionHandler:ja.scalingEqually,render:gg})}}rotationControl(){const eg=document.createElement("img");eg.src=this.option.rotateImg;const gg=(ig,ng,og,ag,sg)=>{this.drawImg(ig,ng,og,eg,40,40,sg.angle)};return{mtr:new ni({x:0,y:.5,cursorStyleHandler:ja.rotationStyleHandler,actionHandler:ja.rotationWithSnapping,offsetY:30,actionName:"rotate",render:gg})}}install(eg,gg){if(!gg||!gg.verticalImg||!gg.horizontalImg||!gg.edgeImg)throw new Error("ControlsPluginOption参数必需");this.option=gg,this.canvas=eg.getCanvas(),this.controls={...this.peakControl(),...this.intervalControl(),...this.rotationControl()},Ei.createControls=()=>({controls:{...this.controls}}),Ei.ownDefaults.controls={...this.controls},Ei.ownDefaults.snapAngle=15,Ei.ownDefaults.snapThreshold=5,this.refreshObjectControls()}refreshObjectControls(){if(!this.canvas)return;const eg=gg=>{gg.id!=="workspace"&&gg.locked!==!0&&gg.set({selectable:!0,evented:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1}),gg.id!=="workspace"&&gg.hasControls!==!1&&(gg.controls={...this.controls},gg.setCoords());const ig=gg._objects;Array.isArray(ig)&&ig.forEach(eg)};this.canvas.getObjects().forEach(eg),this.canvas.requestRenderAll()}enabled(){}disabled(){}}class AlignPlugin{constructor(){this.name="AlignPlugin",this.left=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{left:og=0}=ig;gg.discardActiveObject(),ng.forEach(sg=>{const Ig=sg.getBoundingRect();console.log("getBoundingRect",Ig),console.log("item",sg.left,sg.width),sg.set({left:og-Ig.left+Number(sg.left)}),sg.setCoords()}),console.log("align-left",ng),gg.fire("custom:object:history",{action:"align-left"});const ag=new Jo(ng,{canvas:gg});gg.setActiveObject(ag),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"left")},this.right=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{left:og=0,width:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({left:og+ag-(Cg.left+Cg.width)+Number(Ig.left)})}),gg.fire("custom:object:history",{action:"align-right"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"right")},this.xcenter=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{left:og=0,width:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({left:og+ag/2-(Cg.left+Cg.width/2)+Number(Ig.left)})}),gg.fire("custom:object:history",{action:"align-xcenter"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}},this.ycenter=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{top:og=0,height:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({top:og+ag/2-(Cg.top+Cg.height/2)+Number(Ig.top)})}),gg.fire("custom:object:history",{action:"align-ycenter"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}},this.top=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{top:og=0}=ig;gg.discardActiveObject(),ng.forEach(sg=>{const Ig=sg.getBoundingRect();sg.set({top:og-Ig.top+Number(sg.top)})}),gg.fire("custom:object:history",{action:"align-top"});const ag=new Jo(ng,{canvas:gg});gg.setActiveObject(ag),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"top")},this.bottom=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject(),ng=gg.getActiveObjects();if(ig&&ng.length>1){const{top:og=0,height:ag=0}=ig;gg.discardActiveObject(),ng.forEach(Ig=>{const Cg=Ig.getBoundingRect();Ig.set({top:og+ag-(Cg.top+Cg.height)+Number(Ig.top)})}),gg.fire("custom:object:history",{action:"align-bottom"});const sg=new Jo(ng,{canvas:gg});gg.setActiveObject(sg),gg.requestRenderAll()}else ig&&ng.length===1&&this.alignSingleToWorkspace(ig,"bottom")},this.xequation=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject();function ng(lg){let Ag=1/0,rg=-1/0;for(const cg in lg.aCoords){const ug=cg;lg.aCoords[ug].x<Ag&&(Ag=lg.aCoords[ug].x),lg.aCoords[ug].x>rg&&(rg=lg.aCoords[ug].x)}return rg-Ag}function og(){let lg=0;return ig&&ig.forEachObject(Ag=>{lg+=ng(Ag)}),lg}function ag(){const lg=og();if(ig)return(Number(ig.width)-lg)/(ig._objects.length-1)}function sg(lg){if(lg===0)return 0;let Ag=0;if(ig)for(let rg=0;rg<lg;rg++)Ag+=ng(ig._objects[rg]);return Ag}if(ig&&ig.type==="activeselection"){const lg=ig;if(lg.getObjects().length<2)return;lg._objects.sort((cg,ug)=>cg.left-ug.left);const Ag=ag(),rg=Number(ig.width)/2;ig.forEachObject((cg,ug)=>{const dg=sg(ug),hg=Ag*ug+dg-rg;cg.set("left",hg)})}const Ig=gg.getActiveObjects();if(Ig.length<2)return;gg.discardActiveObject(),Ig.forEach(lg=>{let Ag=1/0;for(const rg in lg.aCoords){const cg=rg;lg.aCoords[cg].x<Ag&&(Ag=lg.aCoords[cg].x)}lg.set("left",2*lg.left-Ag)}),gg.fire("custom:object:history",{action:"align-xequation"});const Cg=new Jo(Ig,{canvas:gg});gg.setActiveObject(Cg),gg.requestRenderAll()},this.yequation=(...eg)=>{if(!this.canvas)return;const gg=this.canvas,ig=gg.getActiveObject()||{top:0,height:0};function ng(lg){let Ag=1/0,rg=-1/0;for(const cg in lg.aCoords){const ug=cg;lg.aCoords[ug].y<Ag&&(Ag=lg.aCoords[ug].y),lg.aCoords[ug].y>rg&&(rg=lg.aCoords[ug].y)}return rg-Ag}function og(){let lg=0;return ig.forEachObject(Ag=>{lg+=ng(Ag)}),lg}function ag(){const lg=og();return(ig.height-lg)/(ig._objects.length-1)}function sg(lg){if(lg===0)return 0;let Ag=0;for(let rg=0;rg<lg;rg++)Ag+=ng(ig._objects[rg]);return Ag}if(console.log("activeObject",ig.type),ig&&ig.type==="activeselection"){const lg=ig;if(lg.getObjects().length<2)return;lg._objects.sort((cg,ug)=>cg.top-ug.top);const Ag=ag(),rg=Number(ig.height)/2;ig.forEachObject((cg,ug)=>{const dg=sg(ug),hg=Ag*ug+dg-rg;cg.set("top",hg)})}const Ig=gg.getActiveObjects();if(Ig.length<2)return;gg.discardActiveObject(),Ig.forEach(lg=>{let Ag=1/0;for(const rg in lg.aCoords){const cg=rg;lg.aCoords[cg].y<Ag&&(Ag=lg.aCoords[cg].y)}lg.set("top",2*lg.top-Ag)}),gg.fire("custom:object:history",{action:"align-yequation"});const Cg=new Jo(Ig,{canvas:gg});gg.setActiveObject(Cg),gg.requestRenderAll()}}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.enabled()}enabled(){this.editor&&(this.editor.addHook("left",this.left),this.editor.addHook("right",this.right),this.editor.addHook("top",this.top),this.editor.addHook("bottom",this.bottom),this.editor.addHook("xcenter",this.xcenter),this.editor.addHook("ycenter",this.ycenter),this.editor.addHook("x-equidistant",this.xequation),this.editor.addHook("y-equidistant",this.yequation))}disabled(){}alignSingleToWorkspace(eg,gg){var Cg;if(!this.canvas)return;const ig=this.canvas.getObjects().find(lg=>lg.id==="workspace");if(!ig)return;const ng=eg.getBoundingRect(),og=ig.getBoundingRect(),ag={};let Ig=((Cg=this.editor)==null?void 0:Cg.ribbonBorderPattern)&&this.editor.ribbonBorderPattern!=="none"?30:0;gg==="left"?ag.left=Number(eg.left||0)+og.left+Ig-ng.left:gg==="right"?ag.left=Number(eg.left||0)+og.left+og.width-Ig-ng.left-ng.width:gg==="top"?ag.top=Number(eg.top||0)+og.top-ng.top:gg==="bottom"&&(ag.top=Number(eg.top||0)+og.top+og.height-ng.top-ng.height),eg.set(ag),eg.setCoords(),this.canvas.fire("custom:object:history",{action:`align-${gg}`}),this.canvas.fire("custom:object:checkdirty",{isToDirty:!0}),this.canvas.requestRenderAll()}}class GroupPlugin{constructor(){this.name="GroupPlugin"}group(){if(!this.editor)return;const eg=this.editor.getCanvas();if(!eg.getActiveObject())return;const gg=this.editor.getPlugin("HistoryPlugin");gg&&(gg.pause=!0);const ig=eg.getActiveObject();console.log("group",ig.type),getObjectList(ig,og=>{(og.type==="text"||og.type==="counter")&&(og.inGroupRemove=!0)});let ng;if(ig.type!=="activeSelection"&&ig.type!=="activeselection"){const og=eg.remove(ig);console.log("rmobj",og),ng=new Hr(og)}else{const og=ig.removeAll();eg.remove(...og),ng=new Hr(og)}console.log("group====1111",ng),ng.id=v4(),addObjName(eg,ng),ng.subTargetCheck=!0,gg&&(gg.pause=!1),eg.add(ng),eg.setActiveObject(ng),eg.requestRenderAll(),this.editor.emit("group",{target:ng}),console.log("group",eg.getObjects())}ungroup(){if(!this.editor)return;const eg=this.editor.getCanvas(),gg=eg.getActiveObject();if(!gg||gg.type!=="group")return;const ig=this.editor.getPlugin("HistoryPlugin");ig&&(ig.pause=!0),eg.remove(gg);const ng=gg.removeAll();eg.add(...ng);var og=new Jo(ng,{canvas:eg});ig&&(ig.pause=!1),eg.setActiveObject(og),eg.requestRenderAll(),this.editor.emit("ungroup",{target:og})}install(eg,gg){this.editor=eg,this.enabled()}enabled(){if(this.editor){const gg=this.editor.getPlugin("ContextMenuPlugin");gg&&gg.addItem([{id:"group1",text:"editor.contextMenu.group",isShow:(ig,ng)=>!ig||ig.type!=="group",handler:(ig,ng)=>(this.group(),!0)},{id:"group2",text:"editor.contextMenu.ungroup",isShow:(ig,ng)=>!!(ig&&ig.type==="group"),handler:(ig,ng)=>(this.ungroup(),!0)}])}}disabled(){if(this.editor){const eg=this.editor.getPlugin("ContextMenuPlugin");eg&&(eg.removeItem("group1"),eg.removeItem("group2"))}}}class HistoryList{constructor(eg){this.canvas=eg,this.history=[],this.historyRedo=[],this.customProp={id:"id",locked:!1,name:"name"},this.isProcess=!1,this.flagClearing=!1,this.undoTimer=void 0,this.extraKeys=Object.keys(this.customProp),this.updateList()}async updateList(){if(this.flagClearing||this.isProcess)return;let eg=null;const gg=this.canvas.getObjects();let ig=[...cloneCommonField,"hasSetHistory"];const ng=gg.filter(ag=>ag.id!=="workspace"&&!ag.parent&&ag.drawObjectType!=="ignoreObject").map(async ag=>{if(ag.group&&ag.group.type==="activeselection"){eg||(eg=cloneDeep(ag.group));const sg=eg._objects.find(Cg=>Cg.id===ag.id);eg.remove(sg);let Ig=await sg.clone(ig);return Ig.set("flagActive",!0),Ig.canvas=void 0,Ig.evented=!0,Ig}else{const sg=await ag.clone(ig);return sg.canvas=void 0,sg.evented=!0,sg}}),og=await Promise.all(ng);this.history.push(og),console.log("history======",this.history),this.historyRedo=[]}clearCanvas(){this.flagClearing=!0;const eg=this.canvas.getObjects().filter(gg=>gg.id!=="workspace");this.canvas.remove(...eg),this.flagClearing=!1}async canvasRestore(eg){this.canvas.discardActiveObject();let gg;clearObjectMap();for(const ig of eg){const ng=await ig.clone([...cloneCommonField,"flagActive"]);this.canvas.add(ng),ng.get("flagActive")&&(gg||(gg=[]),gg.push(ng)),updateObjectMap(ng)}gg&&this.canvas.setActiveObject(new Jo(gg)),this.canvas.requestRenderAll()}undo(){if(this.isProcess||this.history.length<=1)return;clearTimeout(this.undoTimer);let eg=this.history.pop();this.historyRedo.push(eg);const gg=this.history[this.history.length-1];console.log("history========",this.history,gg),this.isProcess=!0,this.clearCanvas(),this.canvasRestore(gg).then(()=>{this.isProcess=!1})}redo(){if(this.isProcess||this.historyRedo.length===0)return;const eg=this.historyRedo.pop();this.history.push(eg),this.isProcess=!0,this.clearCanvas(),this.canvasRestore(eg).then(()=>{this.isProcess=!1})}}class HistoryPlugin{constructor(){this.name="HistoryPlugin",this.historyScopeId="default",this.historyScopeMap=new Map,this.pause=!1,this.isMouseDown=!1,this.isObjectModify=!1,this.objectAddedTimer=null,this.hotKeyHandle=eg=>{this.pause||(eg.hke.key==="ctrl+z"||eg.hke.key==="⌘+z"?this.toUndo():(eg.hke.key==="ctrl+shift+z"||eg.hke.key==="⌘+shift+z")&&this.toRedo())},this.objectAdded=({target:eg})=>{var gg;clearTimeout(this.objectAddedTimer),!(this.pause||this.isMouseDown||(gg=this.historyList)!=null&&gg.isProcess)&&(eg.drawObjectType&&eg.drawObjectType==="ignoreObject"||(this.objectAddedTimer=setTimeout(()=>{var ig;this.pause||(ig=this.historyList)!=null&&ig.isProcess||this.historyList&&this.historyList.updateList()},10)))},this.objectRemoved=({target:eg})=>{var gg;this.pause||(gg=this.historyList)!=null&&gg.isProcess||eg.drawObjectType&&eg.drawObjectType==="ignoreObject"||(this.historyList&&this.historyList.updateList(),this.canvas&&this.canvas.discardActiveObject())},this.objectModified=({})=>{if(!this.pause){if(this.isMouseDown){this.isObjectModify=!0;return}this.historyList&&this.historyList.updateList()}},this.objectSkewing=()=>{if(!this.pause){if(this.isMouseDown){this.isObjectModify=!0;return}this.historyList&&this.historyList.updateList()}},this.historyUpdate=eg=>{if(!this.pause){if(this.isMouseDown){this.isObjectModify=!0;return}this.historyList&&this.historyList.updateList()}},this.mouseDown=()=>{this.isMouseDown=!0},this.mouseUp=eg=>{var gg;this.isObjectModify?(this.isObjectModify=!1,this.isMouseDown=!1,(gg=this.canvas)==null||gg.fire("custom:object:history",{action:"mouse:up:clear"})):this.isMouseDown=!1}}toUndo(){var eg;(eg=this.historyList)==null||eg.undo()}toRedo(){var eg;(eg=this.historyList)==null||eg.redo()}switchScope(eg="default"){if(!this.canvas)return;clearTimeout(this.objectAddedTimer),this.historyScopeId=eg||"default";let gg=this.historyScopeMap.get(this.historyScopeId);gg||(gg=new HistoryList(this.canvas),this.historyScopeMap.set(this.historyScopeId,gg)),this.historyList=gg,this.isMouseDown=!1,this.isObjectModify=!1}clearScope(eg){if(!eg){if(this.historyScopeMap.clear(),this.canvas){const gg=new HistoryList(this.canvas);this.historyScopeMap.set(this.historyScopeId,gg),this.historyList=gg}return}this.historyScopeMap.delete(eg),this.historyScopeId===eg&&this.switchScope("default")}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.historyScopeId=(gg==null?void 0:gg.scopeId)||"default",this.historyList=new HistoryList(this.canvas),this.historyScopeMap.set(this.historyScopeId,this.historyList),this.enabled()}enabled(){this.editor&&(this.editor.addHotKey("ctrl+z",this.hotKeyHandle),this.editor.addHotKey("⌘+z",this.hotKeyHandle),this.editor.addHotKey("ctrl+shift+z",this.hotKeyHandle),this.editor.addHotKey("⌘+shift+z",this.hotKeyHandle)),this.canvas&&(this.canvas.on("mouse:down",this.mouseDown),this.canvas.on("mouse:up",this.mouseUp),this.canvas.on("object:added",this.objectAdded),this.canvas.on("object:removed",this.objectRemoved),this.canvas.on("object:modified",this.objectModified),this.canvas.on("object:skewing",this.objectSkewing),this.canvas.on("custom:object:history",this.historyUpdate))}disabled(){this.editor&&(this.editor.removeHotKey("ctrl+z"),this.editor.removeHotKey("⌘+z"),this.editor.removeHotKey("ctrl+shift+z"),this.editor.removeHotKey("⌘+shift+z")),this.canvas&&(this.canvas.off("mouse:down",this.mouseDown),this.canvas.off("mouse:up",this.mouseUp),this.canvas.off("object:added",this.objectAdded),this.canvas.off("object:removed",this.objectRemoved),this.canvas.off("object:modified",this.objectModified),this.canvas.off("object:skewing",this.objectSkewing),this.canvas.off("custom:object:history",this.historyUpdate))}uninstall(){this.disabled(),clearTimeout(this.objectAddedTimer),this.objectAddedTimer=null,this.historyScopeMap.clear(),this.historyList=void 0,this.editor=void 0,this.canvas=void 0,this.pause=!1,this.isMouseDown=!1,this.isObjectModify=!1}}class MoveHotKeyPlugin{constructor(){this.name="MoveHotKeyPlugin",this.keys={},this.holder=new Map}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.holder.set("keydown",this.keyDown.bind(this)),this.holder.set("keyup",this.keyUp.bind(this)),this.enabled()}move(){const eg=this.canvas.getActiveObject();if(eg!=null&&eg.locked)return;let gg=!0;if(eg&&eg.top!==void 0&&(this.keys.ArrowUp&&(eg.set("top",eg.top-1),gg=!1),this.keys.ArrowDown&&(eg.set("top",eg.top+1),gg=!1),this.keys.ArrowLeft&&(eg.set("left",eg.left-1),gg=!1),this.keys.ArrowRight&&(eg.set("left",eg.left+1),gg=!1),!gg&&(eg.setCoords(),this.canvas))){this.canvas.renderAll(),this.canvas.fire("custom:object:changed",{target:eg});return}this.intervalHolder,clearInterval(this.intervalHolder),this.intervalHolder=void 0,console.log("clearInterval")}keyDown(eg){if(this.keys[eg.code]=!0,["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(eg.code))eg.preventDefault();else return;this.move(),this.intervalHolder===void 0&&(this.intervalHolder=setInterval(this.move.bind(this),96))}keyUp(eg){this.keys[eg.code]=!1}enabled(){var eg;if((eg=this.canvas)!=null&&eg.elements.container){const gg=this.canvas.elements.container;gg.tabIndex=-1,this.holder.forEach((ig,ng)=>{gg.addEventListener(ng,ig)})}}disabled(){var eg;if((eg=this.canvas)!=null&&eg.elements.container){const gg=this.canvas.elements.container;this.holder.forEach((ig,ng)=>{gg.removeEventListener(ng,ig)})}}}class DeletePlugin{constructor(){this.name="DeletePlugin"}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.enabled()}flat(eg,gg){if(gg.push(eg),eg instanceof Hr){const ig=eg.getObjects();if(ig.length>0)for(const ng of ig)ng.locked||(gg.push(ng),ng instanceof Hr&&this.flat(ng,gg))}}enabled(){if(this.editor){const eg=this.editor.getPlugin("ContextMenuPlugin");eg&&eg.addItem({id:"delete",text:"editor.contextMenu.delete",hotKey:"delete,backspace",hotKeyHandler:gg=>this.toDelete(),handler:(gg,ig)=>this.toDelete()})}}toDelete(){var og;const gg=this.editor.getPlugin("HistoryPlugin");gg&&(gg.pause=!0);let ig=this.canvas.getActiveObjects();const ng=[];for(const ag of ig)this.flat(ag,ng);return ng.length>0&&(this.canvas.remove(...ng),this.canvas.requestRenderAll(),ig=ig.filter(ag=>{ng.includes(ag)}),ig.length>0?this.canvas.setActiveObject(new Jo(ig)):this.canvas.discardActiveObject()),gg&&(gg.pause=!1),(og=this.canvas)==null||og.fire("custom:object:history",{target:null,action:"delete"}),!0}disabled(){if(this.editor){const eg=this.editor.getPlugin("ContextMenuPlugin");eg&&eg.removeItem("delete")}}}let isDrawing=!1;class AddObjectPlugin{constructor(){this.name="AddObjectPlugin",this.startPoint={},this.isMoverUp=!1,this.mouseDown=eg=>{if(!this.canvas)return;this.isMoverUp=!1;const gg=this.canvas,ig=eg.scenePoint;this.startPoint=ig,this.canvas.off("mouse:move",this.mouseMove),this.canvas.off("mouse:up",this.mouseUp),gg.on("mouse:move",this.mouseMove),gg.on("mouse:up",this.mouseUp)},this.mouseMove=eg=>{if(!this.canvas||this.isMoverUp)return;const gg=this.canvas,ig=eg.scenePoint;this.object||(this.object=new ALine([this.startPoint.x,this.startPoint.y,ig.x,ig.y],{...this.objectProps,id:v4(),evented:!1,strokeUniform:!0,hasControls:!1}),addObjName(this.canvas,this.object),this.object.strokeWidth=3,gg.add(this.object)),this.object.set({x2:ig.x,y2:ig.y}),this.object.setCoords(),gg.renderAll()},this.mouseUp=eg=>{var gg;!this.canvas||!this.object||(this.isMoverUp=!0,console.log("end",this.object),this.canvas.fire("object:modified",{target:this.object}),(gg=this.canvas)==null||gg.setActiveObject(this.object),this.object=void 0,this.canvas.off("mouse:move",this.mouseMove),this.canvas.off("mouse:up",this.mouseUp),this.end())},this.start=eg=>{if(!this.canvas||isDrawing)return;isDrawing=!0,this.objectProps=eg;const gg=this.canvas;gg.defaultCursor="crosshair",gg.selection=!1,gg.forEachObject(ig=>{ig.set({evented:!1})}),this.canvas.on("mouse:down",this.mouseDown)},this.end=()=>{if(!this.canvas)return;const eg=this.canvas;eg.defaultCursor="default",eg.selection=!0,eg.forEachObject(gg=>{gg.set({evented:!0})}),eg.off("mouse:down",this.mouseDown),isDrawing=!1}}install(eg,gg){this.editor=eg,this.canvas=this.editor.getCanvas(),this.enabled()}enabled(){var eg,gg;this.canvas&&((eg=this.editor)==null||eg.addHook("addLine",this.start),(gg=this.editor)==null||gg.addHook("cancelAdd",this.end))}disabled(){this.canvas&&this.canvas.off("mouse:down",this.mouseDown)}}let _clipboard=null,isInCut=!1;const activePluginStack=[],getClipboard=()=>{if(!(typeof navigator>"u"))return navigator.clipboard},writeClipboardText=async tg=>{const eg=getClipboard();if(!(eg!=null&&eg.writeText))return!1;try{return await eg.writeText(tg),!0}catch{return!1}},readClipboardText=async()=>{const tg=getClipboard();if(!(tg!=null&&tg.readText))return"";try{return await tg.readText()}catch{return""}};class CopyPaste{constructor(eg){this.canvas=eg,this.copyId="",this.pasteId="",this.cloneField=[...cloneCommonField,"hasSetHistory"]}getObjData(eg="copy"){return new Promise(async(gg,ig)=>{let ng=this.canvas.getActiveObject();if(ng){let og=null;if(await writeClipboardText(JSON.stringify({type:"fabric",data:""})),eg==="copy"){let ag=this.cloneField.filter(sg=>sg!=="locked");og=await ng.clone(ag)}else ng instanceof Jo?(og=this.canvas.remove(...ng._objects),og=new Jo(og)):og=this.canvas.remove(ng)[0],this.canvas.discardActiveObject(),this.canvas.requestRenderAll();_clipboard=og,gg(og)}else gg(null)})}async copy(){this.getObjData()}handleObject(eg,gg=!1){var ig;if(!gg){if(eg.relativePosition&&typeof eg.relativePosition=="object"&&eg.set("relativePosition",{...eg.relativePosition}),eg.counterProps&&typeof eg.counterProps=="object"&&(eg.counterProps={...eg.counterProps}),eg._props&&typeof eg._props=="object"&&(eg._props=JSON.parse(JSON.stringify(eg._props))),eg.databaseMixConcat&&typeof eg.databaseMixConcat=="object"&&(eg.databaseMixConcat=JSON.parse(JSON.stringify(eg.databaseMixConcat))),eg.connectObjIds&&typeof eg.connectObjIds=="object"&&(eg.connectObjIds=JSON.parse(JSON.stringify(eg.connectObjIds))),(eg.type==="text"||eg.type==="counter")&&delete eg.connectBar2dMap,eg.type==="barcode2d"||eg.type==="barcode")delete eg.concatTextIdListObj;else if(eg.type==="text"&&eg.fromBarCode2dID){const og=ag=>{if(ag.type==="group"&&ag._objects)return ag._objects.some(sg=>og(sg));if((ag.type==="barcode2d"||ag.type==="barcode")&&ag.id===eg.fromBarCode2dID){let sg=ag.concatTextIdListObj;return sg&&(sg[eg.id]=!0,ag.set("concatTextIdListObj",sg)),!0}};(ig=this.canvas)==null||ig.getObjects().some(ag=>og(ag))}}}async paste(){if(!_clipboard)return"no-data";let eg=this.cloneField;this.copyId!==this.pasteId&&(eg=eg.filter(og=>!["databaseSheet","databaseColumn","databaseTid","outsideInput","outsideInputOrder","increaseCount","fromBarCode2d","fromBarCode2dID","increaseDate","barcodeDateFormatType"].includes(og)));let ig=await _clipboard.clone(eg);if(!ig)return"no-data";let ng=isInCut;if(isInCut?isInCut=!1:(ig.set({left:ig.left+10,top:ig.top+10,evented:!0}),_clipboard&&(_clipboard.left+=10,_clipboard.top+=10)),ig.type==="activeselection")ig.canvas=this.canvas,deepTraverse(ig.getObjects(),(og,ag)=>{addObjName(this.canvas,og),ag&&(ng||(og.id=v4()),this.handleObject(og,ng),this.canvas.add(og))});else if(ig.type==="group"){ig.canvas=this.canvas;const og=new Hr;og.id=v4(),addObjName(this.canvas,og),deepTraverse(ig.getObjects(),(ag,sg)=>{addObjName(this.canvas,ag),sg&&(ng||(ag.id=v4()),this.handleObject(ag,ng),og.add(ag))}),this.canvas.add(og),ig=og}else ng||(ig.id=v4()),this.handleObject(ig,ng),addObjName(this.canvas,ig),this.canvas.add(ig);this.canvas.setActiveObject(ig),this.canvas.requestRenderAll()}async cut(){if(isInCut=!0,!await this.getObjData("cut"))return"no-data"}}class CopyPlugin{constructor(){this.name="CopyPlugin",this.pause=!1,this.shouldHandleClipboardEvent=eg=>{var ng;const gg=eg.target;if(gg instanceof Element&&gg.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'))return!1;const ig=(ng=this.canvas)==null?void 0:ng.getActiveObject();return!!(ig&&!ig.isEditing)},this.setFabricClipboardData=eg=>{eg.clipboardData&&(eg.clipboardData.setData("text/plain",JSON.stringify({type:"fabric",data:""})),eg.preventDefault())},this.copyHandle=eg=>{this.pause||!this.isActivePlugin()||this.shouldHandleClipboardEvent(eg)&&(this.setFabricClipboardData(eg),this.toCopy())},this.cutHandle=eg=>{this.pause||!this.isActivePlugin()||this.shouldHandleClipboardEvent(eg)&&(this.setFabricClipboardData(eg),this.toCut())},this.pasteHandle=eg=>{var sg;if(!this.isActivePlugin())return;const gg=(sg=this.canvas)==null?void 0:sg.getActiveObject(),ig=eg.target,ng=ig instanceof Element&&!!ig.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]');if(gg&&gg.isEditing||ng)return;let og=eg.clipboardData,ag=(og==null?void 0:og.items)||[];for(let Ig of ag){if(Ig.type.startsWith("image")){console.log("粘贴图片");let Cg=Ig.getAsFile();canvasEventBus.emit("copyAddImageObj",Cg),console.log("file=====",Cg)}Ig.type==="text/plain"&&Ig.kind==="string"&&Ig.getAsString(Cg=>{console.log("粘贴文本=====",Cg);let lg=Cg;try{lg=JSON.parse(Cg)}catch{lg=Cg}typeof lg=="string"?canvasEventBus.emit("copyAddTextObj",lg):lg.type&&lg.type==="fabric"&&this.toPaste(lg)})}},this.copyHandleFn=throttle$1(this.copyHandle,80),this.cutHandleFn=throttle$1(this.cutHandle,80),this.pasteHandleFn=throttle$1(this.pasteHandle,80)}isActivePlugin(){return activePluginStack[activePluginStack.length-1]===this}setActivePlugin(eg){const gg=activePluginStack.indexOf(this);gg>-1&&activePluginStack.splice(gg,1),eg&&activePluginStack.push(this)}toCopy(){var gg;const eg=this.editor;this.CopyPaste.copyId=eg.id||"",(gg=this.CopyPaste)==null||gg.copy()}async toPaste(eg=null){var og;const gg=this.editor;this.CopyPaste.pasteId=gg.id||"";const ig=gg.getPlugin("HistoryPlugin");ig&&(ig.pause=!0);let ng={};if(window.isInElectron)try{ng=await window.dsapi.systemApi.readClipboard(),ng=JSON.parse(ng)}catch{}else eg?ng.text=eg:(ng.text=await readClipboardText(),!ng.text&&_clipboard&&(ng.text=JSON.stringify({type:"fabric",data:""})));if(ng.text){let ag=ng.text;try{ag=JSON.parse(ng.text)}catch{ag=ng.text}typeof ag=="string"?(ig&&(ig.pause=!1),canvasEventBus.emit("copyAddTextObj",ag)):ag.type&&ag.type==="fabric"&&((og=this.CopyPaste)==null||og.paste().then(sg=>{var Ig;ig&&(ig.pause=!1),sg!=="no-data"&&((Ig=this.canvas)==null||Ig.fire("custom:object:history",{action:"paste"}))}))}else ng.imageData&&ng.imageData.length?ng.imageData.forEach(ag=>{canvasEventBus.emit("copyAddImageObj",ag)}):ig&&(ig.pause=!1)}toCut(){var ig;const eg=this.editor;this.CopyPaste.copyId=eg.id||"";const gg=eg.getPlugin("HistoryPlugin");gg&&(gg.pause=!0),(ig=this.CopyPaste)==null||ig.cut().then(ng=>{var og;gg&&(gg.pause=!1),ng!=="no-data"&&((og=this.canvas)==null||og.fire("custom:object:history",{target:null,action:"cut"}))})}install(eg,gg){this.editor=eg,this.canvas=eg.getCanvas(),this.CopyPaste=new CopyPaste(this.canvas),this.enabled()}enabled(){this.setActivePlugin(!0),document.removeEventListener("copy",this.copyHandleFn),document.addEventListener("copy",this.copyHandleFn),document.removeEventListener("cut",this.cutHandleFn),document.addEventListener("cut",this.cutHandleFn),document.removeEventListener("paste",this.pasteHandleFn),document.addEventListener("paste",this.pasteHandleFn)}disabled(){this.setActivePlugin(!1),document.removeEventListener("copy",this.copyHandleFn),document.removeEventListener("cut",this.cutHandleFn),document.removeEventListener("paste",this.pasteHandleFn)}uninstall(){this.disabled()}}class SelectPlugin{constructor(){this.name="SelectPlugin",this.selectAll=()=>{if(this.canvas){const eg=this.canvas.getObjects().filter(ig=>ig.id!=="workspace"),gg=new Jo(eg);this.canvas.setActiveObject(gg),this.canvas.requestRenderAll()}}}install(eg,gg){this.canvas=eg.getCanvas(),this.enabled()}uninstall(){this.disabled()}enabled(){hotkeys("ctrl+a",this.selectAll)}disabled(){hotkeys.unbind("ctrl+a",this.selectAll)}}class LineContorlPlugin{constructor(){this.name="LineContorlPlugin",this._lastLeft=0,this._lastTop=0,this.moveTimer=null}install(eg,gg){this.canvas=eg.getCanvas(),this.enabled()}uninstall(){this.disabled()}_createHandle(eg,gg){return new ho({drawObjectType:"ignoreObject",idType:"lineHandle",excludeFromExport:!0,left:eg,top:gg,radius:6,fill:"#fff",stroke:"#1976d2",strokeWidth:2,originX:"center",originY:"center",hasControls:!1,hasBorders:!1,selectable:!0,hoverCursor:"pointer",objectCaching:!1})}_bindEvents(){this.canvas&&(canvasEventBus.off("positionChange"),canvasEventBus.on("positionChange",eg=>{eg.type==="line"&&setTimeout(()=>{this._onSelection({selected:[eg]})},0)}),this.canvas.on("selection:created",eg=>this._onSelection(eg)),this.canvas.on("selection:updated",eg=>this._onSelection(eg)),this.canvas.on("custom:object:basechanged",eg=>{let gg=eg.type,ig=eg.activeObj,ng=eg.val,og=eg.oldVal,ag=ng-og;gg==="x"?(ig.x1=ig.x1+ag,ig.x2=ig.x2+ag):gg==="y"?(ig.y1=ig.y1+ag,ig.y2=ig.y2+ag):gg==="w"?ig.x2>ig.x1?ig.x2=ig.x2+ag:ig.x1=ig.x1+ag:gg==="h"&&(ig.y2>ig.y1?ig.y2=ig.y2+ag:ig.y1=ig.y1+ag),this._onSelection({selected:[ig]})}),this.canvas.on("selection:cleared",()=>this._hideHandles()))}_updateLineFromHandles(){var eg;this.lineObject&&this.handle1&&this.handle2&&(this.lineObject.set({x1:this.handle1.left,y1:this.handle1.top,x2:this.handle2.left,y2:this.handle2.top}),this.lineObject.setCoords(),(eg=this.canvas)==null||eg.requestRenderAll())}_updateHandlesFromLine(){var ig,ng,og;if(!this.lineObject||!this.handle1||!this.handle2)return;const eg=this.lineObject.left-(this._lastLeft??this.lineObject.left),gg=this.lineObject.top-(this._lastTop??this.lineObject.top);(eg!==0||gg!==0)&&((ig=this.handle1)==null||ig.set({left:this.handle1.left+eg,top:this.handle1.top+gg}),(ng=this.handle2)==null||ng.set({left:this.handle2.left+eg,top:this.handle2.top+gg}),this.lineObject.set({x1:this.handle1.left,y1:this.handle1.top,x2:this.handle2.left,y2:this.handle2.top}),this.handle1.setCoords(),this.handle2.setCoords(),this.lineObject.setCoords()),this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top,(og=this.canvas)==null||og.requestRenderAll()}_onSelection(eg){var ig,ng,og,ag,sg,Ig,Cg,lg;let gg=(eg==null?void 0:eg.selected[0])||{};if(eg.selected.length===1&&gg.type==="line"){if(this.lineObject=eg.selected[0],!this.lineObject||(this.handle1&&this.handle2&&((ig=this.canvas)==null||ig.remove(this.handle1,this.handle2)),this.lineObject.group))return;this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top;let Ag=0,rg=0,cg=0,ug=0;this.lineObject.x1<=this.lineObject.x2?(this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top,Ag=this._lastLeft,rg=this._lastLeft+this.lineObject.width):this.lineObject.x1>this.lineObject.x2&&(this._lastLeft=this.lineObject.left+this.lineObject.width,this._lastTop=this.lineObject.top,Ag=this._lastLeft,rg=this._lastLeft-this.lineObject.width),this.lineObject.y1>=this.lineObject.y2?(this._lastLeft=this.lineObject.left,this._lastTop=this.lineObject.top,cg=this._lastTop+this.lineObject.height,ug=this._lastTop):this.lineObject.y1<this.lineObject.y2&&(cg=this._lastTop,ug=this._lastTop+this.lineObject.height),this.handle1=this._createHandle(Ag,cg),this.handle2=this._createHandle(rg,ug),(ng=this.handle1)==null||ng.on("moving",()=>this._updateLineFromHandles()),(og=this.handle2)==null||og.on("moving",()=>this._updateLineFromHandles()),(ag=this.handle2)==null||ag.on("mouseup",()=>{var dg;(dg=this.canvas)==null||dg.discardActiveObject(),setTimeout(()=>{var hg,mg;this.lineObject&&((hg=this.canvas)==null||hg.setActiveObject(this.lineObject)),(mg=this.canvas)==null||mg.requestRenderAll()},220)}),(sg=this.handle1)==null||sg.on("mouseup",()=>{var dg;(dg=this.canvas)==null||dg.discardActiveObject(),setTimeout(()=>{var hg;this.lineObject&&((hg=this.canvas)==null||hg.setActiveObject(this.lineObject))},220)}),(Ig=this.lineObject)==null||Ig.on("moving",()=>this._updateHandlesFromLine()),(Cg=this.canvas)==null||Cg.add(this.handle1,this.handle2),(lg=this.canvas)==null||lg.requestRenderAll()}else gg&&gg.drawObjectType!=="ignoreObject"&&this._hideHandles()}_showHandles(){}_hideHandles(){var eg,gg;this.handle1&&this.handle2&&((eg=this.canvas)==null||eg.remove(this.handle1,this.handle2),(gg=this.canvas)==null||gg.requestRenderAll())}enabled(){this._bindEvents()}disabled(){canvasEventBus.off("positionChange")}}async function applyJsonFieldDiff(tg,eg,gg){const ig={renamedCount:0,unlinkedCount:0,valueUpdatedCount:0,unlinkedIds:[]};if(!(eg!=null&&eg.length))return ig;const ng=collectObjects(eg).filter(sg=>sg.fromJson);for(const{from:sg,to:Ig}of tg.renamed)for(const Cg of ng)Cg.jsonFieldKey===sg&&(Cg.jsonFieldKey=Ig,Cg.dirty=!0,ig.renamedCount++);if(gg!=null&&gg.jsonData)return await reconcileWithJsonData(ng,gg.jsonData,ig,gg),ig;const og=new Set(tg.renamed.map(({to:sg})=>sg));for(const{key:sg,newValue:Ig}of tg.valueChanged){if(og.has(sg)){for(const Cg of ng)Cg.jsonFieldKey===sg&&(await setElementContent(Cg,Ig,gg),Cg.dirty=!0,ig.valueUpdatedCount++);continue}for(const Cg of ng)Cg.jsonFieldKey===sg&&(await setElementContent(Cg,Ig,gg),Cg.dirty=!0,ig.valueUpdatedCount++)}const ag=new Set(tg.removed);for(const sg of ng)sg.jsonFieldKey&&ag.has(sg.jsonFieldKey)&&unlinkObject(sg,ig);return ig}function collectObjects(tg){const eg=[],gg=new Set,ig=ng=>{var ag;if(!ng||gg.has(ng))return;gg.add(ng),eg.push(ng),(((ag=ng.getObjects)==null?void 0:ag.call(ng))??ng._objects??ng.objects??[]).forEach(ig)};return tg.forEach(ig),eg}async function reconcileWithJsonData(tg,eg,gg,ig){for(const ng of tg){const og=ng.jsonFieldKey;if(!og||!Object.prototype.hasOwnProperty.call(eg,og)){unlinkObject(ng,gg);continue}await setElementContent(ng,toElementValue(eg[og]),ig),ng.dirty=!0,gg.valueUpdatedCount++}}function unlinkObject(tg,eg){tg.jsonFieldKey="",tg.fromJson=!1,tg.type==="text"&&(tg.set?tg.set("editable",!0):tg.editable=!0),tg.dirty=!0,tg.id&&eg.unlinkedIds.push(tg.id),eg.unlinkedCount++}function toElementValue(tg){return typeof tg=="object"&&tg!==null?JSON.stringify(tg):String(tg??"")}async function setElementContent(tg,eg,gg){var ig,ng;if(String(tg.type).toLowerCase()==="image"){if(!(gg!=null&&gg.resolveImageSource))return;try{const og=await gg.resolveImageSource(eg);tg.setSrc?await tg.setSrc(og,{imageSource:tg.imageSource}):tg.set?tg.set("src",og):tg.src=og,(ig=tg.updateInGroup)==null||ig.call(tg)}catch(og){const ag=(og==null?void 0:og.message)||"图片加载失败";tg.set?tg.set("databaseImageError",ag):tg.databaseImageError=ag}return}if(tg.type==="barcode"){tg.setBarcodeOption?tg.setBarcodeOption({text:eg}):tg.barcodeOptions&&(tg.barcodeOptions.text=eg);return}if(tg.type==="barcode2d"){tg.setBarcode2DOption?tg.setBarcode2DOption({text:eg}):tg.barcode2dOptions&&(tg.barcode2dOptions.text=eg);return}tg.set?tg.set("text",eg):tg.text=eg,(ng=tg.updateInGroup)==null||ng.call(tg)}ji.customProperties=["customExportFields"];const _hoisted_1$15={class:"nest-menu"},_sfc_main$17=defineComponent({__name:"nest-menu",props:{items:{type:Array,required:!0}},setup(tg){const eg=useSlots(),gg=(ig,ng="")=>ig.map((og,ag)=>{if(og.children&&og.children.length){let sg=(ng?ng+"-":"")+(ag+1);return h$2(Menu.SubMenu,{key:sg,title:og.label,popupClassName:"le-target-menu"},{default:()=>gg(og.children,sg)})}else return h$2(Menu.Item,{key:(ng?ng+"-":"")+(ag+1)},{default:()=>eg.item({data:og})})});return(ig,ng)=>(openBlock(),createElementBlock("div",_hoisted_1$15,[createVNode(unref(Menu),mergeProps({mode:"horizontal"},ig.$attrs),{default:withCtx(()=>[(openBlock(!0),createElementBlock(Fragment,null,renderList(gg(tg.items),og=>(openBlock(),createBlock(resolveDynamicComponent(og),{key:og.key}))),128))]),_:1},16)]))}}),_export_sfc=(tg,eg)=>{const gg=tg.__vccOpts||tg;for(const[ig,ng]of eg)gg[ig]=ng;return gg},nestedMenu=_export_sfc(_sfc_main$17,[["__scopeId","data-v-ebd540f8"]]),emitter=mitt(),IconClose$1="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='21'%20height='20.5078125'%20viewBox='0%200%2021%2020.5078125'%3e%3cg%3e%3cg%3e%3cellipse%20cx='10.5'%20cy='10.25390625'%20rx='10.5'%20ry='10.25390625'%20fill='%23EAEAEA'%20fill-opacity='1'%20/%3e%3c/g%3e%3cg%20transform='matrix(0,1,-1,0,21.315007209777832,-11.299349784851074)'%3e%3cpath%20d='M26.872478497314454,5.368129712463379L26.872478497314454,5.368129712463379Q26.914278497314456,5.410926712463379,26.951778497314454,5.457711712463379Q26.98927849731445,5.504496712463379,27.022078497314453,5.554820712463379Q27.054878497314455,5.605143712463379,27.082778497314454,5.658520712463379Q27.110678497314453,5.7118977124633785,27.133278497314453,5.767813712463379Q27.155878497314454,5.823730712463379,27.173078497314453,5.881647712463379Q27.190178497314452,5.939565712463379,27.201778497314454,5.998925712463379Q27.213278497314455,6.058288712463379,27.219078497314452,6.118518712463379Q27.224878497314453,6.178748712463379,27.224878497314453,6.239278712463379Q27.224878497314453,6.299798712463379,27.219078497314452,6.360028712463379Q27.213278497314455,6.420258712463379,27.201778497314454,6.479618712463379Q27.190178497314452,6.538978712463379,27.173078497314453,6.5968987124633784Q27.155878497314454,6.654818712463379,27.133278497314453,6.7107287124633785Q27.110678497314453,6.766648712463379,27.082778497314454,6.820028712463379Q27.054878497314455,6.8734087124633785,27.022078497314453,6.923728712463379Q26.98927849731445,6.974048712463379,26.951778497314454,7.020838712463378Q26.914278497314456,7.0676187124633785,26.872478497314454,7.110418712463379L18.361158497314452,15.826028712463378Q18.319358497314454,15.86882871246338,18.273668497314453,15.907228712463379Q18.227988497314453,15.945628712463378,18.17883849731445,15.979228712463378Q18.129698497314454,16.01282871246338,18.077568497314452,16.04132871246338Q18.025448497314454,16.06992871246338,17.970838497314453,16.09302871246338Q17.916228497314453,16.11622871246338,17.859668497314452,16.133828712463377Q17.803108497314454,16.15132871246338,17.745148497314453,16.16312871246338Q17.687178497314452,16.174928712463377,17.62835849731445,16.180928712463377Q17.569538497314454,16.18682871246338,17.510428497314454,16.18682871246338Q17.451328497314453,16.18682871246338,17.392508497314452,16.180928712463377Q17.333688497314455,16.174928712463377,17.275714497314453,16.16312871246338Q17.217745497314453,16.15132871246338,17.161185497314452,16.133828712463377Q17.10462549731445,16.11622871246338,17.05001949731445,16.09302871246338Q16.995413497314452,16.06992871246338,16.943287497314454,16.04132871246338Q16.891162497314454,16.01282871246338,16.842018497314452,15.979228712463378Q16.792874497314454,15.945628712463378,16.747185497314454,15.907228712463379Q16.70149649731445,15.86882871246338,16.659703497314453,15.826028712463378L16.659703497314453,15.826028712463378Q16.617909497314454,15.783228712463378,16.580413497314453,15.736428712463379Q16.542918497314453,15.68962871246338,16.510081497314452,15.63932871246338Q16.47724449731445,15.58902871246338,16.449382497314453,15.535628712463378Q16.421520497314454,15.482228712463378,16.398901797314455,15.426328712463379Q16.376283297314455,15.37042871246338,16.359125997314454,15.31252871246338Q16.341968697314453,15.25452871246338,16.330437797314453,15.19522871246338Q16.318906997314453,15.135828712463379,16.313113657314453,15.075628712463379Q16.307320322314453,15.015428712463379,16.307320289314454,14.954858712463379Q16.307320256314455,14.894338712463378,16.313113517314452,14.834098712463378Q16.318906797314455,14.77386871246338,16.330437597314454,14.71450871246338Q16.34196829731445,14.65514871246338,16.359125597314453,14.597228712463378Q16.376282797314452,14.539308712463379,16.398901297314453,14.483398712463378Q16.421519497314453,14.42747871246338,16.44938149731445,14.374098712463379Q16.477243497314454,14.32072871246338,16.510080497314455,14.270398712463379Q16.542917497314452,14.220078712463378,16.580413497314453,14.173298712463378Q16.617908497314453,14.126508712463378,16.659702497314452,14.083708712463379L25.171018497314453,5.368129712463379Q25.212808497314455,5.325333712463379,25.258498497314456,5.286937712463379Q25.304188497314453,5.248541712463379,25.353328497314454,5.214916712463379Q25.40246849731445,5.181291712463379,25.454598497314453,5.152761712463379Q25.506728497314455,5.124230712463379,25.561328497314452,5.101069512463379Q25.615938497314453,5.077908212463379,25.672498497314454,5.060339212463379Q25.729058497314455,5.042770112463379,25.787028497314452,5.030962612463379Q25.844998497314453,5.019155012463379,25.903818497314454,5.013222702463379Q25.96263849731445,5.007290366463379,26.021738497314452,5.007290366463379Q26.080848497314452,5.007290366463379,26.139668497314453,5.013222702463379Q26.198488497314454,5.019155012463379,26.256458497314455,5.030962612463379Q26.31437849731445,5.042770112463379,26.370978497314454,5.060339212463379Q26.427578497314453,5.077908212463379,26.482178497314454,5.101069512463379Q26.53677849731445,5.124230712463379,26.588878497314454,5.152761712463379Q26.640978497314453,5.181291712463379,26.690178497314452,5.214916712463379Q26.73927849731445,5.248541712463379,26.784978497314455,5.286937712463379Q26.83067849731445,5.325333712463379,26.872478497314454,5.368129712463379Z'%20fill='%238C8C8C'%20fill-opacity='1'%20/%3e%3c/g%3e%3cg%20transform='rotate(90%2010.5%2010.5)%20matrix(0,1,-1,0,21.315007209777832,-11.299349784851074)'%3e%3cpath%20d='M26.872478497314454,5.368129712463379L26.872478497314454,5.368129712463379Q26.914278497314456,5.410926712463379,26.951778497314454,5.457711712463379Q26.98927849731445,5.504496712463379,27.022078497314453,5.554820712463379Q27.054878497314455,5.605143712463379,27.082778497314454,5.658520712463379Q27.110678497314453,5.7118977124633785,27.133278497314453,5.767813712463379Q27.155878497314454,5.823730712463379,27.173078497314453,5.881647712463379Q27.190178497314452,5.939565712463379,27.201778497314454,5.998925712463379Q27.213278497314455,6.058288712463379,27.219078497314452,6.118518712463379Q27.224878497314453,6.178748712463379,27.224878497314453,6.239278712463379Q27.224878497314453,6.299798712463379,27.219078497314452,6.360028712463379Q27.213278497314455,6.420258712463379,27.201778497314454,6.479618712463379Q27.190178497314452,6.538978712463379,27.173078497314453,6.5968987124633784Q27.155878497314454,6.654818712463379,27.133278497314453,6.7107287124633785Q27.110678497314453,6.766648712463379,27.082778497314454,6.820028712463379Q27.054878497314455,6.8734087124633785,27.022078497314453,6.923728712463379Q26.98927849731445,6.974048712463379,26.951778497314454,7.020838712463378Q26.914278497314456,7.0676187124633785,26.872478497314454,7.110418712463379L18.361158497314452,15.826028712463378Q18.319358497314454,15.86882871246338,18.273668497314453,15.907228712463379Q18.227988497314453,15.945628712463378,18.17883849731445,15.979228712463378Q18.129698497314454,16.01282871246338,18.077568497314452,16.04132871246338Q18.025448497314454,16.06992871246338,17.970838497314453,16.09302871246338Q17.916228497314453,16.11622871246338,17.859668497314452,16.133828712463377Q17.803108497314454,16.15132871246338,17.745148497314453,16.16312871246338Q17.687178497314452,16.174928712463377,17.62835849731445,16.180928712463377Q17.569538497314454,16.18682871246338,17.510428497314454,16.18682871246338Q17.451328497314453,16.18682871246338,17.392508497314452,16.180928712463377Q17.333688497314455,16.174928712463377,17.275714497314453,16.16312871246338Q17.217745497314453,16.15132871246338,17.161185497314452,16.133828712463377Q17.10462549731445,16.11622871246338,17.05001949731445,16.09302871246338Q16.995413497314452,16.06992871246338,16.943287497314454,16.04132871246338Q16.891162497314454,16.01282871246338,16.842018497314452,15.979228712463378Q16.792874497314454,15.945628712463378,16.747185497314454,15.907228712463379Q16.70149649731445,15.86882871246338,16.659703497314453,15.826028712463378L16.659703497314453,15.826028712463378Q16.617909497314454,15.783228712463378,16.580413497314453,15.736428712463379Q16.542918497314453,15.68962871246338,16.510081497314452,15.63932871246338Q16.47724449731445,15.58902871246338,16.449382497314453,15.535628712463378Q16.421520497314454,15.482228712463378,16.398901797314455,15.426328712463379Q16.376283297314455,15.37042871246338,16.359125997314454,15.31252871246338Q16.341968697314453,15.25452871246338,16.330437797314453,15.19522871246338Q16.318906997314453,15.135828712463379,16.313113657314453,15.075628712463379Q16.307320322314453,15.015428712463379,16.307320289314454,14.954858712463379Q16.307320256314455,14.894338712463378,16.313113517314452,14.834098712463378Q16.318906797314455,14.77386871246338,16.330437597314454,14.71450871246338Q16.34196829731445,14.65514871246338,16.359125597314453,14.597228712463378Q16.376282797314452,14.539308712463379,16.398901297314453,14.483398712463378Q16.421519497314453,14.42747871246338,16.44938149731445,14.374098712463379Q16.477243497314454,14.32072871246338,16.510080497314455,14.270398712463379Q16.542917497314452,14.220078712463378,16.580413497314453,14.173298712463378Q16.617908497314453,14.126508712463378,16.659702497314452,14.083708712463379L25.171018497314453,5.368129712463379Q25.212808497314455,5.325333712463379,25.258498497314456,5.286937712463379Q25.304188497314453,5.248541712463379,25.353328497314454,5.214916712463379Q25.40246849731445,5.181291712463379,25.454598497314453,5.152761712463379Q25.506728497314455,5.124230712463379,25.561328497314452,5.101069512463379Q25.615938497314453,5.077908212463379,25.672498497314454,5.060339212463379Q25.729058497314455,5.042770112463379,25.787028497314452,5.030962612463379Q25.844998497314453,5.019155012463379,25.903818497314454,5.013222702463379Q25.96263849731445,5.007290366463379,26.021738497314452,5.007290366463379Q26.080848497314452,5.007290366463379,26.139668497314453,5.013222702463379Q26.198488497314454,5.019155012463379,26.256458497314455,5.030962612463379Q26.31437849731445,5.042770112463379,26.370978497314454,5.060339212463379Q26.427578497314453,5.077908212463379,26.482178497314454,5.101069512463379Q26.53677849731445,5.124230712463379,26.588878497314454,5.152761712463379Q26.640978497314453,5.181291712463379,26.690178497314452,5.214916712463379Q26.73927849731445,5.248541712463379,26.784978497314455,5.286937712463379Q26.83067849731445,5.325333712463379,26.872478497314454,5.368129712463379Z'%20fill='%238C8C8C'%20fill-opacity='1'%20/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";function useDraggableWithBoundary(tg){const{elRef:eg}=tg,gg=ref(0),ig=ref(0),ng=ref(!1);let og=0,ag=0,sg=0,Ig=0;const Cg=()=>{if(!eg.value)return;const dg=eg.value.getBoundingClientRect();sg=dg.width,Ig=dg.height},lg=(dg,hg)=>Math.min(Math.max(dg,-hg),hg),Ag=dg=>{if(!ng.value)return;let hg=dg.clientX-og,mg=dg.clientY-ag;const bg=(window.innerWidth-sg)/2,pg=(window.innerHeight-Ig)/2;hg=lg(hg,bg),mg=lg(mg,pg),gg.value=hg,ig.value=mg},rg=()=>{ng.value=!1,document.removeEventListener("mousemove",Ag),document.removeEventListener("mouseup",rg)},cg=async dg=>{dg.button===0&&(ng.value=!0,await nextTick(),Cg(),og=dg.clientX-gg.value,ag=dg.clientY-ig.value,document.addEventListener("mousemove",Ag),document.addEventListener("mouseup",rg))},ug=()=>{Cg(),gg.value=lg(gg.value,window.innerWidth-sg),ig.value=lg(ig.value,window.innerHeight-Ig)};return window.addEventListener("resize",ug),onUnmounted(()=>{document.removeEventListener("mousemove",Ag),document.removeEventListener("mouseup",rg),window.removeEventListener("resize",ug)}),{x:gg,y:ig,onMouseDown:cg}}const _hoisted_1$14={class:"d-container"},_hoisted_2$Q={key:0,class:"d-mask"},_hoisted_3$I={class:"d-t-header"},_hoisted_4$C=["src"],_hoisted_5$z={key:0,class:"footer"},_sfc_main$16=defineComponent({__name:"Dialog",props:mergeModels({width:{type:String,default:"40%",required:!1},height:{type:String,default:"50%",required:!1},minHeight:{type:String,default:"300px",required:!1},maxHeight:{type:String,default:"auto",required:!1},minWidth:{type:String,default:void 0,required:!1},title:{type:String,required:!1},okBtnText:{type:String,default:void 0,require:!1},cancelBtnText:{type:String,default:void 0,require:!1},showOkBtn:{type:Boolean,default:!0,require:!1},showCancelBtn:{type:Boolean,default:!0,require:!1},showClose:{type:Boolean,default:!0,require:!1},noFooter:{type:Boolean,default:!1},maskShow:{type:Boolean,default:!1}},{open:{type:Boolean,default:!0},openModifiers:{},enabledOk:{type:Boolean,default:!0},enabledOkModifiers:{}}),emits:mergeModels(["finish"],["update:open","update:enabledOk"]),setup(tg,{emit:eg}){const{t:gg}=useI18n(),ig=ref(),ng=eg,og=useModel(tg,"open"),ag=tg;useModel(tg,"enabledOk");const{x:sg,y:Ig,onMouseDown:Cg}=useDraggableWithBoundary({elRef:ig}),lg=Ag=>{Ag.stopPropagation(),ng("finish","close")};return(Ag,rg)=>{const cg=Button$1;return og.value?(openBlock(),createBlock(Teleport,{key:0,to:"body"},[createBaseVNode("div",_hoisted_1$14,[tg.maskShow?(openBlock(),createElementBlock("div",_hoisted_2$Q)):createCommentVNode("",!0),createBaseVNode("div",{ref_key:"dialogRef",ref:ig,class:"dialog-content",style:normalizeStyle$1({height:ag.height,minHeight:ag.minHeight,width:ag.width,minWidth:ag.minWidth,maxHeight:ag.maxHeight,transform:`translate(${unref(sg)}px, ${unref(Ig)}px)`})},[createBaseVNode("div",_hoisted_3$I,[createBaseVNode("div",{class:"d-t-header-title",onMousedown:rg[0]||(rg[0]=(...ug)=>unref(Cg)&&unref(Cg)(...ug))},toDisplayString$1(ag.title),33),tg.showClose?(openBlock(),createElementBlock("img",{key:0,class:"m-close-icon",src:unref(IconClose$1),onClick:lg},null,8,_hoisted_4$C)):createCommentVNode("",!0)]),createBaseVNode("div",mergeProps({class:"custom-content"},Ag.$attrs),[renderSlot(Ag.$slots,"default",{},void 0)],16),tg.noFooter?createCommentVNode("",!0):(openBlock(),createElementBlock("div",_hoisted_5$z,[renderSlot(Ag.$slots,"ext-button",{},void 0),tg.showOkBtn?(openBlock(),createBlock(cg,{key:0,type:"primary",onClick:rg[1]||(rg[1]=ug=>ng("finish","ok")),disabled:!tg.enabledOk},{default:withCtx(()=>[createTextVNode(toDisplayString$1(ag.okBtnText??unref(gg)("common.actions.confirm")),1)]),_:1},8,["disabled"])):createCommentVNode("",!0),tg.showCancelBtn?(openBlock(),createBlock(cg,{key:1,style:{background:"#ffffff",color:"#828282"},onClick:rg[2]||(rg[2]=ug=>ng("finish","cancel"))},{default:withCtx(()=>[createTextVNode(toDisplayString$1(ag.cancelBtnText??unref(gg)("common.actions.cancel")),1)]),_:1})):createCommentVNode("",!0)]))],4)])])):createCommentVNode("",!0)}}}),__unplugin_components_1$1=_export_sfc(_sfc_main$16,[["__scopeId","data-v-e477a1bc"]]);function formatSafeError(tg){const eg=getActiveEditorLocale(),gg=toSafeError(tg);if(gg.logDetail!==void 0&&console.error("[Service error]",gg.logDetail),eg==="zh-CN"&&gg.key.startsWith("errors.unknown")){const ig=getErrorParts(tg).detail;if(ig)return ig}return translate(gg.key,{code:gg.code??""})}var browser={},canPromise,hasRequiredCanPromise;function requireCanPromise(){return hasRequiredCanPromise||(hasRequiredCanPromise=1,canPromise=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),canPromise}var qrcode$1={},utils$1={},hasRequiredUtils$1;function requireUtils$1(){if(hasRequiredUtils$1)return utils$1;hasRequiredUtils$1=1;let tg;const eg=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return utils$1.getSymbolSize=function(ig){if(!ig)throw new Error('"version" cannot be null or undefined');if(ig<1||ig>40)throw new Error('"version" should be in range from 1 to 40');return ig*4+17},utils$1.getSymbolTotalCodewords=function(ig){return eg[ig]},utils$1.getBCHDigit=function(gg){let ig=0;for(;gg!==0;)ig++,gg>>>=1;return ig},utils$1.setToSJISFunction=function(ig){if(typeof ig!="function")throw new Error('"toSJISFunc" is not a valid function.');tg=ig},utils$1.isKanjiModeEnabled=function(){return typeof tg<"u"},utils$1.toSJIS=function(ig){return tg(ig)},utils$1}var errorCorrectionLevel={},hasRequiredErrorCorrectionLevel;function requireErrorCorrectionLevel(){return hasRequiredErrorCorrectionLevel||(hasRequiredErrorCorrectionLevel=1,(function(tg){tg.L={bit:1},tg.M={bit:0},tg.Q={bit:3},tg.H={bit:2};function eg(gg){if(typeof gg!="string")throw new Error("Param is not a string");switch(gg.toLowerCase()){case"l":case"low":return tg.L;case"m":case"medium":return tg.M;case"q":case"quartile":return tg.Q;case"h":case"high":return tg.H;default:throw new Error("Unknown EC Level: "+gg)}}tg.isValid=function(ig){return ig&&typeof ig.bit<"u"&&ig.bit>=0&&ig.bit<4},tg.from=function(ig,ng){if(tg.isValid(ig))return ig;try{return eg(ig)}catch{return ng}}})(errorCorrectionLevel)),errorCorrectionLevel}var bitBuffer,hasRequiredBitBuffer;function requireBitBuffer(){if(hasRequiredBitBuffer)return bitBuffer;hasRequiredBitBuffer=1;function tg(){this.buffer=[],this.length=0}return tg.prototype={get:function(eg){const gg=Math.floor(eg/8);return(this.buffer[gg]>>>7-eg%8&1)===1},put:function(eg,gg){for(let ig=0;ig<gg;ig++)this.putBit((eg>>>gg-ig-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(eg){const gg=Math.floor(this.length/8);this.buffer.length<=gg&&this.buffer.push(0),eg&&(this.buffer[gg]|=128>>>this.length%8),this.length++}},bitBuffer=tg,bitBuffer}var bitMatrix,hasRequiredBitMatrix;function requireBitMatrix(){if(hasRequiredBitMatrix)return bitMatrix;hasRequiredBitMatrix=1;function tg(eg){if(!eg||eg<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=eg,this.data=new Uint8Array(eg*eg),this.reservedBit=new Uint8Array(eg*eg)}return tg.prototype.set=function(eg,gg,ig,ng){const og=eg*this.size+gg;this.data[og]=ig,ng&&(this.reservedBit[og]=!0)},tg.prototype.get=function(eg,gg){return this.data[eg*this.size+gg]},tg.prototype.xor=function(eg,gg,ig){this.data[eg*this.size+gg]^=ig},tg.prototype.isReserved=function(eg,gg){return this.reservedBit[eg*this.size+gg]},bitMatrix=tg,bitMatrix}var alignmentPattern={},hasRequiredAlignmentPattern;function requireAlignmentPattern(){return hasRequiredAlignmentPattern||(hasRequiredAlignmentPattern=1,(function(tg){const eg=requireUtils$1().getSymbolSize;tg.getRowColCoords=function(ig){if(ig===1)return[];const ng=Math.floor(ig/7)+2,og=eg(ig),ag=og===145?26:Math.ceil((og-13)/(2*ng-2))*2,sg=[og-7];for(let Ig=1;Ig<ng-1;Ig++)sg[Ig]=sg[Ig-1]-ag;return sg.push(6),sg.reverse()},tg.getPositions=function(ig){const ng=[],og=tg.getRowColCoords(ig),ag=og.length;for(let sg=0;sg<ag;sg++)for(let Ig=0;Ig<ag;Ig++)sg===0&&Ig===0||sg===0&&Ig===ag-1||sg===ag-1&&Ig===0||ng.push([og[sg],og[Ig]]);return ng}})(alignmentPattern)),alignmentPattern}var finderPattern={},hasRequiredFinderPattern;function requireFinderPattern(){if(hasRequiredFinderPattern)return finderPattern;hasRequiredFinderPattern=1;const tg=requireUtils$1().getSymbolSize,eg=7;return finderPattern.getPositions=function(ig){const ng=tg(ig);return[[0,0],[ng-eg,0],[0,ng-eg]]},finderPattern}var maskPattern={},hasRequiredMaskPattern;function requireMaskPattern(){return hasRequiredMaskPattern||(hasRequiredMaskPattern=1,(function(tg){tg.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const eg={N1:3,N2:3,N3:40,N4:10};tg.isValid=function(ng){return ng!=null&&ng!==""&&!isNaN(ng)&&ng>=0&&ng<=7},tg.from=function(ng){return tg.isValid(ng)?parseInt(ng,10):void 0},tg.getPenaltyN1=function(ng){const og=ng.size;let ag=0,sg=0,Ig=0,Cg=null,lg=null;for(let Ag=0;Ag<og;Ag++){sg=Ig=0,Cg=lg=null;for(let rg=0;rg<og;rg++){let cg=ng.get(Ag,rg);cg===Cg?sg++:(sg>=5&&(ag+=eg.N1+(sg-5)),Cg=cg,sg=1),cg=ng.get(rg,Ag),cg===lg?Ig++:(Ig>=5&&(ag+=eg.N1+(Ig-5)),lg=cg,Ig=1)}sg>=5&&(ag+=eg.N1+(sg-5)),Ig>=5&&(ag+=eg.N1+(Ig-5))}return ag},tg.getPenaltyN2=function(ng){const og=ng.size;let ag=0;for(let sg=0;sg<og-1;sg++)for(let Ig=0;Ig<og-1;Ig++){const Cg=ng.get(sg,Ig)+ng.get(sg,Ig+1)+ng.get(sg+1,Ig)+ng.get(sg+1,Ig+1);(Cg===4||Cg===0)&&ag++}return ag*eg.N2},tg.getPenaltyN3=function(ng){const og=ng.size;let ag=0,sg=0,Ig=0;for(let Cg=0;Cg<og;Cg++){sg=Ig=0;for(let lg=0;lg<og;lg++)sg=sg<<1&2047|ng.get(Cg,lg),lg>=10&&(sg===1488||sg===93)&&ag++,Ig=Ig<<1&2047|ng.get(lg,Cg),lg>=10&&(Ig===1488||Ig===93)&&ag++}return ag*eg.N3},tg.getPenaltyN4=function(ng){let og=0;const ag=ng.data.length;for(let Ig=0;Ig<ag;Ig++)og+=ng.data[Ig];return Math.abs(Math.ceil(og*100/ag/5)-10)*eg.N4};function gg(ig,ng,og){switch(ig){case tg.Patterns.PATTERN000:return(ng+og)%2===0;case tg.Patterns.PATTERN001:return ng%2===0;case tg.Patterns.PATTERN010:return og%3===0;case tg.Patterns.PATTERN011:return(ng+og)%3===0;case tg.Patterns.PATTERN100:return(Math.floor(ng/2)+Math.floor(og/3))%2===0;case tg.Patterns.PATTERN101:return ng*og%2+ng*og%3===0;case tg.Patterns.PATTERN110:return(ng*og%2+ng*og%3)%2===0;case tg.Patterns.PATTERN111:return(ng*og%3+(ng+og)%2)%2===0;default:throw new Error("bad maskPattern:"+ig)}}tg.applyMask=function(ng,og){const ag=og.size;for(let sg=0;sg<ag;sg++)for(let Ig=0;Ig<ag;Ig++)og.isReserved(Ig,sg)||og.xor(Ig,sg,gg(ng,Ig,sg))},tg.getBestMask=function(ng,og){const ag=Object.keys(tg.Patterns).length;let sg=0,Ig=1/0;for(let Cg=0;Cg<ag;Cg++){og(Cg),tg.applyMask(Cg,ng);const lg=tg.getPenaltyN1(ng)+tg.getPenaltyN2(ng)+tg.getPenaltyN3(ng)+tg.getPenaltyN4(ng);tg.applyMask(Cg,ng),lg<Ig&&(Ig=lg,sg=Cg)}return sg}})(maskPattern)),maskPattern}var errorCorrectionCode={},hasRequiredErrorCorrectionCode;function requireErrorCorrectionCode(){if(hasRequiredErrorCorrectionCode)return errorCorrectionCode;hasRequiredErrorCorrectionCode=1;const tg=requireErrorCorrectionLevel(),eg=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],gg=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return errorCorrectionCode.getBlocksCount=function(ng,og){switch(og){case tg.L:return eg[(ng-1)*4+0];case tg.M:return eg[(ng-1)*4+1];case tg.Q:return eg[(ng-1)*4+2];case tg.H:return eg[(ng-1)*4+3];default:return}},errorCorrectionCode.getTotalCodewordsCount=function(ng,og){switch(og){case tg.L:return gg[(ng-1)*4+0];case tg.M:return gg[(ng-1)*4+1];case tg.Q:return gg[(ng-1)*4+2];case tg.H:return gg[(ng-1)*4+3];default:return}},errorCorrectionCode}var polynomial={},galoisField={},hasRequiredGaloisField;function requireGaloisField(){if(hasRequiredGaloisField)return galoisField;hasRequiredGaloisField=1;const tg=new Uint8Array(512),eg=new Uint8Array(256);return(function(){let ig=1;for(let ng=0;ng<255;ng++)tg[ng]=ig,eg[ig]=ng,ig<<=1,ig&256&&(ig^=285);for(let ng=255;ng<512;ng++)tg[ng]=tg[ng-255]})(),galoisField.log=function(ig){if(ig<1)throw new Error("log("+ig+")");return eg[ig]},galoisField.exp=function(ig){return tg[ig]},galoisField.mul=function(ig,ng){return ig===0||ng===0?0:tg[eg[ig]+eg[ng]]},galoisField}var hasRequiredPolynomial;function requirePolynomial(){return hasRequiredPolynomial||(hasRequiredPolynomial=1,(function(tg){const eg=requireGaloisField();tg.mul=function(ig,ng){const og=new Uint8Array(ig.length+ng.length-1);for(let ag=0;ag<ig.length;ag++)for(let sg=0;sg<ng.length;sg++)og[ag+sg]^=eg.mul(ig[ag],ng[sg]);return og},tg.mod=function(ig,ng){let og=new Uint8Array(ig);for(;og.length-ng.length>=0;){const ag=og[0];for(let Ig=0;Ig<ng.length;Ig++)og[Ig]^=eg.mul(ng[Ig],ag);let sg=0;for(;sg<og.length&&og[sg]===0;)sg++;og=og.slice(sg)}return og},tg.generateECPolynomial=function(ig){let ng=new Uint8Array([1]);for(let og=0;og<ig;og++)ng=tg.mul(ng,new Uint8Array([1,eg.exp(og)]));return ng}})(polynomial)),polynomial}var reedSolomonEncoder,hasRequiredReedSolomonEncoder;function requireReedSolomonEncoder(){if(hasRequiredReedSolomonEncoder)return reedSolomonEncoder;hasRequiredReedSolomonEncoder=1;const tg=requirePolynomial();function eg(gg){this.genPoly=void 0,this.degree=gg,this.degree&&this.initialize(this.degree)}return eg.prototype.initialize=function(ig){this.degree=ig,this.genPoly=tg.generateECPolynomial(this.degree)},eg.prototype.encode=function(ig){if(!this.genPoly)throw new Error("Encoder not initialized");const ng=new Uint8Array(ig.length+this.degree);ng.set(ig);const og=tg.mod(ng,this.genPoly),ag=this.degree-og.length;if(ag>0){const sg=new Uint8Array(this.degree);return sg.set(og,ag),sg}return og},reedSolomonEncoder=eg,reedSolomonEncoder}var version={},mode={},versionCheck={},hasRequiredVersionCheck;function requireVersionCheck(){return hasRequiredVersionCheck||(hasRequiredVersionCheck=1,versionCheck.isValid=function(eg){return!isNaN(eg)&&eg>=1&&eg<=40}),versionCheck}var regex={},hasRequiredRegex;function requireRegex(){if(hasRequiredRegex)return regex;hasRequiredRegex=1;const tg="[0-9]+",eg="[A-Z $%*+\\-./:]+";let gg="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";gg=gg.replace(/u/g,"\\u");const ig="(?:(?![A-Z0-9 $%*+\\-./:]|"+gg+`)(?:.|[\r
|
|
931
931
|
]))+`;regex.KANJI=new RegExp(gg,"g"),regex.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),regex.BYTE=new RegExp(ig,"g"),regex.NUMERIC=new RegExp(tg,"g"),regex.ALPHANUMERIC=new RegExp(eg,"g");const ng=new RegExp("^"+gg+"$"),og=new RegExp("^"+tg+"$"),ag=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return regex.testKanji=function(Ig){return ng.test(Ig)},regex.testNumeric=function(Ig){return og.test(Ig)},regex.testAlphanumeric=function(Ig){return ag.test(Ig)},regex}var hasRequiredMode;function requireMode(){return hasRequiredMode||(hasRequiredMode=1,(function(tg){const eg=requireVersionCheck(),gg=requireRegex();tg.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},tg.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},tg.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},tg.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},tg.MIXED={bit:-1},tg.getCharCountIndicator=function(og,ag){if(!og.ccBits)throw new Error("Invalid mode: "+og);if(!eg.isValid(ag))throw new Error("Invalid version: "+ag);return ag>=1&&ag<10?og.ccBits[0]:ag<27?og.ccBits[1]:og.ccBits[2]},tg.getBestModeForData=function(og){return gg.testNumeric(og)?tg.NUMERIC:gg.testAlphanumeric(og)?tg.ALPHANUMERIC:gg.testKanji(og)?tg.KANJI:tg.BYTE},tg.toString=function(og){if(og&&og.id)return og.id;throw new Error("Invalid mode")},tg.isValid=function(og){return og&&og.bit&&og.ccBits};function ig(ng){if(typeof ng!="string")throw new Error("Param is not a string");switch(ng.toLowerCase()){case"numeric":return tg.NUMERIC;case"alphanumeric":return tg.ALPHANUMERIC;case"kanji":return tg.KANJI;case"byte":return tg.BYTE;default:throw new Error("Unknown mode: "+ng)}}tg.from=function(og,ag){if(tg.isValid(og))return og;try{return ig(og)}catch{return ag}}})(mode)),mode}var hasRequiredVersion;function requireVersion(){return hasRequiredVersion||(hasRequiredVersion=1,(function(tg){const eg=requireUtils$1(),gg=requireErrorCorrectionCode(),ig=requireErrorCorrectionLevel(),ng=requireMode(),og=requireVersionCheck(),ag=7973,sg=eg.getBCHDigit(ag);function Ig(rg,cg,ug){for(let dg=1;dg<=40;dg++)if(cg<=tg.getCapacity(dg,ug,rg))return dg}function Cg(rg,cg){return ng.getCharCountIndicator(rg,cg)+4}function lg(rg,cg){let ug=0;return rg.forEach(function(dg){const hg=Cg(dg.mode,cg);ug+=hg+dg.getBitsLength()}),ug}function Ag(rg,cg){for(let ug=1;ug<=40;ug++)if(lg(rg,ug)<=tg.getCapacity(ug,cg,ng.MIXED))return ug}tg.from=function(cg,ug){return og.isValid(cg)?parseInt(cg,10):ug},tg.getCapacity=function(cg,ug,dg){if(!og.isValid(cg))throw new Error("Invalid QR Code version");typeof dg>"u"&&(dg=ng.BYTE);const hg=eg.getSymbolTotalCodewords(cg),mg=gg.getTotalCodewordsCount(cg,ug),bg=(hg-mg)*8;if(dg===ng.MIXED)return bg;const pg=bg-Cg(dg,cg);switch(dg){case ng.NUMERIC:return Math.floor(pg/10*3);case ng.ALPHANUMERIC:return Math.floor(pg/11*2);case ng.KANJI:return Math.floor(pg/13);case ng.BYTE:default:return Math.floor(pg/8)}},tg.getBestVersionForData=function(cg,ug){let dg;const hg=ig.from(ug,ig.M);if(Array.isArray(cg)){if(cg.length>1)return Ag(cg,hg);if(cg.length===0)return 1;dg=cg[0]}else dg=cg;return Ig(dg.mode,dg.getLength(),hg)},tg.getEncodedBits=function(cg){if(!og.isValid(cg)||cg<7)throw new Error("Invalid QR Code version");let ug=cg<<12;for(;eg.getBCHDigit(ug)-sg>=0;)ug^=ag<<eg.getBCHDigit(ug)-sg;return cg<<12|ug}})(version)),version}var formatInfo={},hasRequiredFormatInfo;function requireFormatInfo(){if(hasRequiredFormatInfo)return formatInfo;hasRequiredFormatInfo=1;const tg=requireUtils$1(),eg=1335,gg=21522,ig=tg.getBCHDigit(eg);return formatInfo.getEncodedBits=function(og,ag){const sg=og.bit<<3|ag;let Ig=sg<<10;for(;tg.getBCHDigit(Ig)-ig>=0;)Ig^=eg<<tg.getBCHDigit(Ig)-ig;return(sg<<10|Ig)^gg},formatInfo}var segments={},numericData,hasRequiredNumericData;function requireNumericData(){if(hasRequiredNumericData)return numericData;hasRequiredNumericData=1;const tg=requireMode();function eg(gg){this.mode=tg.NUMERIC,this.data=gg.toString()}return eg.getBitsLength=function(ig){return 10*Math.floor(ig/3)+(ig%3?ig%3*3+1:0)},eg.prototype.getLength=function(){return this.data.length},eg.prototype.getBitsLength=function(){return eg.getBitsLength(this.data.length)},eg.prototype.write=function(ig){let ng,og,ag;for(ng=0;ng+3<=this.data.length;ng+=3)og=this.data.substr(ng,3),ag=parseInt(og,10),ig.put(ag,10);const sg=this.data.length-ng;sg>0&&(og=this.data.substr(ng),ag=parseInt(og,10),ig.put(ag,sg*3+1))},numericData=eg,numericData}var alphanumericData,hasRequiredAlphanumericData;function requireAlphanumericData(){if(hasRequiredAlphanumericData)return alphanumericData;hasRequiredAlphanumericData=1;const tg=requireMode(),eg=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function gg(ig){this.mode=tg.ALPHANUMERIC,this.data=ig}return gg.getBitsLength=function(ng){return 11*Math.floor(ng/2)+6*(ng%2)},gg.prototype.getLength=function(){return this.data.length},gg.prototype.getBitsLength=function(){return gg.getBitsLength(this.data.length)},gg.prototype.write=function(ng){let og;for(og=0;og+2<=this.data.length;og+=2){let ag=eg.indexOf(this.data[og])*45;ag+=eg.indexOf(this.data[og+1]),ng.put(ag,11)}this.data.length%2&&ng.put(eg.indexOf(this.data[og]),6)},alphanumericData=gg,alphanumericData}var byteData,hasRequiredByteData;function requireByteData(){if(hasRequiredByteData)return byteData;hasRequiredByteData=1;const tg=requireMode();function eg(gg){this.mode=tg.BYTE,typeof gg=="string"?this.data=new TextEncoder().encode(gg):this.data=new Uint8Array(gg)}return eg.getBitsLength=function(ig){return ig*8},eg.prototype.getLength=function(){return this.data.length},eg.prototype.getBitsLength=function(){return eg.getBitsLength(this.data.length)},eg.prototype.write=function(gg){for(let ig=0,ng=this.data.length;ig<ng;ig++)gg.put(this.data[ig],8)},byteData=eg,byteData}var kanjiData,hasRequiredKanjiData;function requireKanjiData(){if(hasRequiredKanjiData)return kanjiData;hasRequiredKanjiData=1;const tg=requireMode(),eg=requireUtils$1();function gg(ig){this.mode=tg.KANJI,this.data=ig}return gg.getBitsLength=function(ng){return ng*13},gg.prototype.getLength=function(){return this.data.length},gg.prototype.getBitsLength=function(){return gg.getBitsLength(this.data.length)},gg.prototype.write=function(ig){let ng;for(ng=0;ng<this.data.length;ng++){let og=eg.toSJIS(this.data[ng]);if(og>=33088&&og<=40956)og-=33088;else if(og>=57408&&og<=60351)og-=49472;else throw new Error("Invalid SJIS character: "+this.data[ng]+`
|
|
932
932
|
Make sure your charset is UTF-8`);og=(og>>>8&255)*192+(og&255),ig.put(og,13)}},kanjiData=gg,kanjiData}var dijkstra={exports:{}},hasRequiredDijkstra;function requireDijkstra(){return hasRequiredDijkstra||(hasRequiredDijkstra=1,(function(tg){var eg={single_source_shortest_paths:function(gg,ig,ng){var og={},ag={};ag[ig]=0;var sg=eg.PriorityQueue.make();sg.push(ig,0);for(var Ig,Cg,lg,Ag,rg,cg,ug,dg,hg;!sg.empty();){Ig=sg.pop(),Cg=Ig.value,Ag=Ig.cost,rg=gg[Cg]||{};for(lg in rg)rg.hasOwnProperty(lg)&&(cg=rg[lg],ug=Ag+cg,dg=ag[lg],hg=typeof ag[lg]>"u",(hg||dg>ug)&&(ag[lg]=ug,sg.push(lg,ug),og[lg]=Cg))}if(typeof ng<"u"&&typeof ag[ng]>"u"){var mg=["Could not find a path from ",ig," to ",ng,"."].join("");throw new Error(mg)}return og},extract_shortest_path_from_predecessor_list:function(gg,ig){for(var ng=[],og=ig;og;)ng.push(og),gg[og],og=gg[og];return ng.reverse(),ng},find_path:function(gg,ig,ng){var og=eg.single_source_shortest_paths(gg,ig,ng);return eg.extract_shortest_path_from_predecessor_list(og,ng)},PriorityQueue:{make:function(gg){var ig=eg.PriorityQueue,ng={},og;gg=gg||{};for(og in ig)ig.hasOwnProperty(og)&&(ng[og]=ig[og]);return ng.queue=[],ng.sorter=gg.sorter||ig.default_sorter,ng},default_sorter:function(gg,ig){return gg.cost-ig.cost},push:function(gg,ig){var ng={value:gg,cost:ig};this.queue.push(ng),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};tg.exports=eg})(dijkstra)),dijkstra.exports}var hasRequiredSegments;function requireSegments(){return hasRequiredSegments||(hasRequiredSegments=1,(function(tg){const eg=requireMode(),gg=requireNumericData(),ig=requireAlphanumericData(),ng=requireByteData(),og=requireKanjiData(),ag=requireRegex(),sg=requireUtils$1(),Ig=requireDijkstra();function Cg(mg){return unescape(encodeURIComponent(mg)).length}function lg(mg,bg,pg){const fg=[];let wg;for(;(wg=mg.exec(pg))!==null;)fg.push({data:wg[0],index:wg.index,mode:bg,length:wg[0].length});return fg}function Ag(mg){const bg=lg(ag.NUMERIC,eg.NUMERIC,mg),pg=lg(ag.ALPHANUMERIC,eg.ALPHANUMERIC,mg);let fg,wg;return sg.isKanjiModeEnabled()?(fg=lg(ag.BYTE,eg.BYTE,mg),wg=lg(ag.KANJI,eg.KANJI,mg)):(fg=lg(ag.BYTE_KANJI,eg.BYTE,mg),wg=[]),bg.concat(pg,fg,wg).sort(function(Zg,$g){return Zg.index-$g.index}).map(function(Zg){return{data:Zg.data,mode:Zg.mode,length:Zg.length}})}function rg(mg,bg){switch(bg){case eg.NUMERIC:return gg.getBitsLength(mg);case eg.ALPHANUMERIC:return ig.getBitsLength(mg);case eg.KANJI:return og.getBitsLength(mg);case eg.BYTE:return ng.getBitsLength(mg)}}function cg(mg){return mg.reduce(function(bg,pg){const fg=bg.length-1>=0?bg[bg.length-1]:null;return fg&&fg.mode===pg.mode?(bg[bg.length-1].data+=pg.data,bg):(bg.push(pg),bg)},[])}function ug(mg){const bg=[];for(let pg=0;pg<mg.length;pg++){const fg=mg[pg];switch(fg.mode){case eg.NUMERIC:bg.push([fg,{data:fg.data,mode:eg.ALPHANUMERIC,length:fg.length},{data:fg.data,mode:eg.BYTE,length:fg.length}]);break;case eg.ALPHANUMERIC:bg.push([fg,{data:fg.data,mode:eg.BYTE,length:fg.length}]);break;case eg.KANJI:bg.push([fg,{data:fg.data,mode:eg.BYTE,length:Cg(fg.data)}]);break;case eg.BYTE:bg.push([{data:fg.data,mode:eg.BYTE,length:Cg(fg.data)}])}}return bg}function dg(mg,bg){const pg={},fg={start:{}};let wg=["start"];for(let Gg=0;Gg<mg.length;Gg++){const Zg=mg[Gg],$g=[];for(let Bg=0;Bg<Zg.length;Bg++){const Wg=Zg[Bg],yg=""+Gg+Bg;$g.push(yg),pg[yg]={node:Wg,lastCount:0},fg[yg]={};for(let Ng=0;Ng<wg.length;Ng++){const vg=wg[Ng];pg[vg]&&pg[vg].node.mode===Wg.mode?(fg[vg][yg]=rg(pg[vg].lastCount+Wg.length,Wg.mode)-rg(pg[vg].lastCount,Wg.mode),pg[vg].lastCount+=Wg.length):(pg[vg]&&(pg[vg].lastCount=Wg.length),fg[vg][yg]=rg(Wg.length,Wg.mode)+4+eg.getCharCountIndicator(Wg.mode,bg))}}wg=$g}for(let Gg=0;Gg<wg.length;Gg++)fg[wg[Gg]].end=0;return{map:fg,table:pg}}function hg(mg,bg){let pg;const fg=eg.getBestModeForData(mg);if(pg=eg.from(bg,fg),pg!==eg.BYTE&&pg.bit<fg.bit)throw new Error('"'+mg+'" cannot be encoded with mode '+eg.toString(pg)+`.
|
|
933
933
|
Suggested mode is: `+eg.toString(fg));switch(pg===eg.KANJI&&!sg.isKanjiModeEnabled()&&(pg=eg.BYTE),pg){case eg.NUMERIC:return new gg(mg);case eg.ALPHANUMERIC:return new ig(mg);case eg.KANJI:return new og(mg);case eg.BYTE:return new ng(mg)}}tg.fromArray=function(bg){return bg.reduce(function(pg,fg){return typeof fg=="string"?pg.push(hg(fg,null)):fg.data&&pg.push(hg(fg.data,fg.mode)),pg},[])},tg.fromString=function(bg,pg){const fg=Ag(bg,sg.isKanjiModeEnabled()),wg=ug(fg),Gg=dg(wg,pg),Zg=Ig.find_path(Gg.map,"start","end"),$g=[];for(let Bg=1;Bg<Zg.length-1;Bg++)$g.push(Gg.table[Zg[Bg]].node);return tg.fromArray(cg($g))},tg.rawSplit=function(bg){return tg.fromArray(Ag(bg,sg.isKanjiModeEnabled()))}})(segments)),segments}var hasRequiredQrcode;function requireQrcode(){if(hasRequiredQrcode)return qrcode$1;hasRequiredQrcode=1;const tg=requireUtils$1(),eg=requireErrorCorrectionLevel(),gg=requireBitBuffer(),ig=requireBitMatrix(),ng=requireAlignmentPattern(),og=requireFinderPattern(),ag=requireMaskPattern(),sg=requireErrorCorrectionCode(),Ig=requireReedSolomonEncoder(),Cg=requireVersion(),lg=requireFormatInfo(),Ag=requireMode(),rg=requireSegments();function cg(Gg,Zg){const $g=Gg.size,Bg=og.getPositions(Zg);for(let Wg=0;Wg<Bg.length;Wg++){const yg=Bg[Wg][0],Ng=Bg[Wg][1];for(let vg=-1;vg<=7;vg++)if(!(yg+vg<=-1||$g<=yg+vg))for(let Sg=-1;Sg<=7;Sg++)Ng+Sg<=-1||$g<=Ng+Sg||(vg>=0&&vg<=6&&(Sg===0||Sg===6)||Sg>=0&&Sg<=6&&(vg===0||vg===6)||vg>=2&&vg<=4&&Sg>=2&&Sg<=4?Gg.set(yg+vg,Ng+Sg,!0,!0):Gg.set(yg+vg,Ng+Sg,!1,!0))}}function ug(Gg){const Zg=Gg.size;for(let $g=8;$g<Zg-8;$g++){const Bg=$g%2===0;Gg.set($g,6,Bg,!0),Gg.set(6,$g,Bg,!0)}}function dg(Gg,Zg){const $g=ng.getPositions(Zg);for(let Bg=0;Bg<$g.length;Bg++){const Wg=$g[Bg][0],yg=$g[Bg][1];for(let Ng=-2;Ng<=2;Ng++)for(let vg=-2;vg<=2;vg++)Ng===-2||Ng===2||vg===-2||vg===2||Ng===0&&vg===0?Gg.set(Wg+Ng,yg+vg,!0,!0):Gg.set(Wg+Ng,yg+vg,!1,!0)}}function hg(Gg,Zg){const $g=Gg.size,Bg=Cg.getEncodedBits(Zg);let Wg,yg,Ng;for(let vg=0;vg<18;vg++)Wg=Math.floor(vg/3),yg=vg%3+$g-8-3,Ng=(Bg>>vg&1)===1,Gg.set(Wg,yg,Ng,!0),Gg.set(yg,Wg,Ng,!0)}function mg(Gg,Zg,$g){const Bg=Gg.size,Wg=lg.getEncodedBits(Zg,$g);let yg,Ng;for(yg=0;yg<15;yg++)Ng=(Wg>>yg&1)===1,yg<6?Gg.set(yg,8,Ng,!0):yg<8?Gg.set(yg+1,8,Ng,!0):Gg.set(Bg-15+yg,8,Ng,!0),yg<8?Gg.set(8,Bg-yg-1,Ng,!0):yg<9?Gg.set(8,15-yg-1+1,Ng,!0):Gg.set(8,15-yg-1,Ng,!0);Gg.set(Bg-8,8,1,!0)}function bg(Gg,Zg){const $g=Gg.size;let Bg=-1,Wg=$g-1,yg=7,Ng=0;for(let vg=$g-1;vg>0;vg-=2)for(vg===6&&vg--;;){for(let Sg=0;Sg<2;Sg++)if(!Gg.isReserved(Wg,vg-Sg)){let Vg=!1;Ng<Zg.length&&(Vg=(Zg[Ng]>>>yg&1)===1),Gg.set(Wg,vg-Sg,Vg),yg--,yg===-1&&(Ng++,yg=7)}if(Wg+=Bg,Wg<0||$g<=Wg){Wg-=Bg,Bg=-Bg;break}}}function pg(Gg,Zg,$g){const Bg=new gg;$g.forEach(function(Sg){Bg.put(Sg.mode.bit,4),Bg.put(Sg.getLength(),Ag.getCharCountIndicator(Sg.mode,Gg)),Sg.write(Bg)});const Wg=tg.getSymbolTotalCodewords(Gg),yg=sg.getTotalCodewordsCount(Gg,Zg),Ng=(Wg-yg)*8;for(Bg.getLengthInBits()+4<=Ng&&Bg.put(0,4);Bg.getLengthInBits()%8!==0;)Bg.putBit(0);const vg=(Ng-Bg.getLengthInBits())/8;for(let Sg=0;Sg<vg;Sg++)Bg.put(Sg%2?17:236,8);return fg(Bg,Gg,Zg)}function fg(Gg,Zg,$g){const Bg=tg.getSymbolTotalCodewords(Zg),Wg=sg.getTotalCodewordsCount(Zg,$g),yg=Bg-Wg,Ng=sg.getBlocksCount(Zg,$g),vg=Bg%Ng,Sg=Ng-vg,Vg=Math.floor(Bg/Ng),Xg=Math.floor(yg/Ng),Yg=Xg+1,Hg=Vg-Xg,kg=new Ig(Hg);let Rg=0;const Kg=new Array(Ng),jg=new Array(Ng);let Dg=0;const zg=new Uint8Array(Gg.buffer);for(let ca=0;ca<Ng;ca++){const ua=ca<Sg?Xg:Yg;Kg[ca]=zg.slice(Rg,Rg+ua),jg[ca]=kg.encode(Kg[ca]),Rg+=ua,Dg=Math.max(Dg,ua)}const Og=new Uint8Array(Bg);let Jg=0,Qg,eo;for(Qg=0;Qg<Dg;Qg++)for(eo=0;eo<Ng;eo++)Qg<Kg[eo].length&&(Og[Jg++]=Kg[eo][Qg]);for(Qg=0;Qg<Hg;Qg++)for(eo=0;eo<Ng;eo++)Og[Jg++]=jg[eo][Qg];return Og}function wg(Gg,Zg,$g,Bg){let Wg;if(Array.isArray(Gg))Wg=rg.fromArray(Gg);else if(typeof Gg=="string"){let Vg=Zg;if(!Vg){const Xg=rg.rawSplit(Gg);Vg=Cg.getBestVersionForData(Xg,$g)}Wg=rg.fromString(Gg,Vg||40)}else throw new Error("Invalid data");const yg=Cg.getBestVersionForData(Wg,$g);if(!yg)throw new Error("The amount of data is too big to be stored in a QR Code");if(!Zg)Zg=yg;else if(Zg<yg)throw new Error(`
|
|
@@ -956,7 +956,7 @@ This will fail in production.`);ag=activePinia,ag._s.has(tg)||(ng?createSetupSto
|
|
|
956
956
|
* Vue-Lazyload.js v3.0.0
|
|
957
957
|
* (c) 2023 Awe <hilongjw@gmail.com>
|
|
958
958
|
* Released under the MIT License.
|
|
959
|
-
*/function createCommonjsModule(tg,eg){return eg={exports:{}},tg(eg,eg.exports),eg.exports}var assignSymbols$1=createCommonjsModule(function(tg){const eg=Object.prototype.toString,gg=Object.prototype.propertyIsEnumerable,ig=Object.getOwnPropertySymbols;tg.exports=(og,...ag)=>{if(!ng(og))throw new TypeError("expected the first argument to be an object");if(ag.length===0||typeof Symbol!="function"||typeof ig!="function")return og;for(let sg of ag){let Ig=ig(sg);for(let Cg of Ig)gg.call(sg,Cg)&&(og[Cg]=sg[Cg])}return og};function ng(og){return typeof og=="function"||eg.call(og)==="[object Object]"||Array.isArray(og)}}),assignSymbols$2=Object.freeze({__proto__:null,default:assignSymbols$1,__moduleExports:assignSymbols$1}),assignSymbols=assignSymbols$2&&assignSymbols$1||assignSymbols$2,assignDeep=createCommonjsModule(function(tg){const eg=Object.prototype.toString,gg=ag=>ag!=="__proto__"&&ag!=="constructor"&&ag!=="prototype",ig=tg.exports=(ag,...sg)=>{let Ig=0;for(og(ag)&&(ag=sg[Ig++]),ag||(ag={});Ig<sg.length;Ig++)if(ng(sg[Ig])){for(const Cg of Object.keys(sg[Ig]))gg(Cg)&&(ng(ag[Cg])&&ng(sg[Ig][Cg])?ig(ag[Cg],sg[Ig][Cg]):ag[Cg]=sg[Ig][Cg]);assignSymbols(ag,sg[Ig])}return ag};function ng(ag){return typeof ag=="function"||eg.call(ag)==="[object Object]"}function og(ag){return typeof ag=="object"?ag===null:typeof ag!="function"}});const inBrowser=typeof window<"u"&&window!==null,hasIntersectionObserver=checkIntersectionObserver();function checkIntersectionObserver(){return inBrowser&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype?("isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}}),!0):!1}const modeType={event:"event",observer:"observer"};function remove(tg,eg){if(!tg.length)return;const gg=tg.indexOf(eg);if(gg>-1)return tg.splice(gg,1)}function getBestSelectionFromSrcset(tg,eg){if(tg.tagName!=="IMG"||!tg.getAttribute("data-srcset"))return"";let gg=tg.getAttribute("data-srcset").trim().split(",");const ig=[],og=tg.parentNode.offsetWidth*eg;let ag,sg,Ig;gg.forEach(Ag=>{Ag=Ag.trim(),ag=Ag.lastIndexOf(" "),ag===-1?(sg=Ag,Ig=99999):(sg=Ag.substr(0,ag),Ig=parseInt(Ag.substr(ag+1,Ag.length-ag-2),10)),ig.push([Ig,sg])}),ig.sort((Ag,rg)=>{if(Ag[0]<rg[0])return 1;if(Ag[0]>rg[0])return-1;if(Ag[0]===rg[0]){if(rg[1].indexOf(".webp",rg[1].length-5)!==-1)return 1;if(Ag[1].indexOf(".webp",Ag[1].length-5)!==-1)return-1}return 0});let Cg="",lg;for(let Ag=0;Ag<ig.length;Ag++){lg=ig[Ag],Cg=lg[1];const rg=ig[Ag+1];if(rg&&rg[0]<og){Cg=lg[1];break}else if(!rg){Cg=lg[1];break}}return Cg}const getDPR=(tg=1)=>inBrowser&&window.devicePixelRatio||tg;function supportWebp(){if(!inBrowser)return!1;let tg=!0;function eg(gg,ig){const ng={lossy:"UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",lossless:"UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==",alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"},og=new Image;og.onload=function(){const ag=og.width>0&&og.height>0;ig(ag)},og.onerror=function(){ig(!1)},og.src="data:image/webp;base64,"+ng[gg]}return eg("lossy",gg=>{tg=gg}),eg("lossless",gg=>{tg=gg}),eg("alpha",gg=>{tg=gg}),eg("animation",gg=>{tg=gg}),tg}function throttle(tg,eg){let gg=null,ig=0;return function(){if(gg)return;const ng=Date.now()-ig,og=this,ag=arguments,sg=function(){ig=Date.now(),gg=!1,tg.apply(og,ag)};ng>=eg?sg():gg=setTimeout(sg,eg)}}function testSupportsPassive(){if(!inBrowser)return!1;let tg=!1;try{const eg=Object.defineProperty({},"passive",{get:function(){tg=!0}});window.addEventListener("test",noop,eg)}catch{}return tg}const supportsPassive=testSupportsPassive(),_={on(tg,eg,gg,ig=!1){supportsPassive?tg.addEventListener(eg,gg,{capture:ig,passive:!0}):tg.addEventListener(eg,gg,ig)},off(tg,eg,gg,ig=!1){tg.removeEventListener(eg,gg,ig)}},loadImageAsync=(tg,eg,gg)=>{let ig=new Image;if(!tg||!tg.src){const ng=new Error("image src is required");return gg(ng)}tg.cors&&(ig.crossOrigin=tg.cors),ig.src=tg.src,ig.onload=function(){eg({naturalHeight:ig.naturalHeight,naturalWidth:ig.naturalWidth,src:ig.src}),ig=null},ig.onerror=function(ng){gg(ng)}},style=(tg,eg)=>typeof getComputedStyle<"u"?getComputedStyle(tg,null).getPropertyValue(eg):tg.style[eg],overflow=tg=>style(tg,"overflow")+style(tg,"overflowY")+style(tg,"overflowX"),scrollParent=tg=>{if(!inBrowser)return;if(!(tg instanceof Element))return window;let eg=tg;for(;eg&&!(eg===document.body||eg===document.documentElement||!eg.parentNode);){if(/(scroll|auto)/.test(overflow(eg)))return eg;eg=eg.parentNode}return window};function isObject(tg){return tg!==null&&typeof tg=="object"}function noop(){}class ImageCache{constructor(eg){this.max=eg||100,this._caches=[]}has(eg){return this._caches.indexOf(eg)>-1}add(eg){this.has(eg)||(this._caches.push(eg),this._caches.length>this.max&&this.free())}free(){this._caches.shift()}}class ReactiveListener{constructor(eg,gg,ig,ng,og,ag,sg,Ig,Cg,lg){this.el=eg,this.src=gg,this.error=ig,this.loading=ng,this.bindType=og,this.attempt=0,this.cors=Ig,this.naturalHeight=0,this.naturalWidth=0,this.options=sg,this.rect={},this.$parent=ag,this.elRenderer=Cg,this._imageCache=lg,this.performanceData={init:Date.now(),loadStart:0,loadEnd:0},this.filter(),this.initState(),this.render("loading",!1)}initState(){"dataset"in this.el?this.el.dataset.src=this.src:this.el.setAttribute("data-src",this.src),this.state={loading:!1,error:!1,loaded:!1,rendered:!1}}record(eg){this.performanceData[eg]=Date.now()}update(eg){const gg=this.src;this.src=eg.src,this.loading=eg.loading,this.error=eg.error,this.filter(),gg!==this.src&&(this.attempt=0,this.initState())}getRect(){this.rect=this.el.getBoundingClientRect()}checkInView(){return this.getRect(),this.rect.top<window.innerHeight*this.options.preLoad&&this.rect.bottom>this.options.preLoadTop&&this.rect.left<window.innerWidth*this.options.preLoad&&this.rect.right>0}filter(){for(const eg in this.options.filter)this.options.filter[eg](this,this.options)}renderLoading(eg){this.state.loading=!0,loadImageAsync({src:this.loading,cors:this.cors},()=>{this.render("loading",!1),this.state.loading=!1,eg()},()=>{eg(),this.state.loading=!1,this.options.silent||console.warn(`VueLazyload log: load failed with loading image(${this.loading})`)})}load(eg=noop){if(this.attempt>this.options.attempt-1&&this.state.error){this.options.silent||console.log(`VueLazyload log: ${this.src} tried too more than ${this.options.attempt} times`),eg();return}if(!(this.state.rendered&&this.state.loaded)){if(this._imageCache.has(this.src))return this.state.loaded=!0,this.render("loaded",!0),this.state.rendered=!0,eg();this.renderLoading(()=>{this.attempt++,this.options.adapter.beforeLoad&&this.options.adapter.beforeLoad(this,this.options),this.record("loadStart"),loadImageAsync({src:this.src,cors:this.cors},gg=>{this.naturalHeight=gg.naturalHeight,this.naturalWidth=gg.naturalWidth,this.state.loaded=!0,this.state.error=!1,this.record("loadEnd"),this.render("loaded",!1),this.state.rendered=!0,this._imageCache.add(this.src),eg()},gg=>{!this.options.silent&&console.error(gg),this.state.error=!0,this.state.loaded=!1,this.render("error",!1)})})}}render(eg,gg){this.elRenderer(this,eg,gg)}performance(){let eg="loading",gg=0;return this.state.loaded&&(eg="loaded",gg=(this.performanceData.loadEnd-this.performanceData.loadStart)/1e3),this.state.error&&(eg="error"),{src:this.src,state:eg,time:gg}}$destroy(){this.el=null,this.src="",this.error=null,this.loading="",this.bindType=null,this.attempt=0}}const DEFAULT_URL="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",DEFAULT_EVENTS=["scroll","wheel","mousewheel","resize","animationend","transitionend","touchmove"],DEFAULT_OBSERVER_OPTIONS={rootMargin:"0px",threshold:0};class Lazy{constructor({preLoad:eg,error:gg,throttleWait:ig,preLoadTop:ng,dispatchEvent:og,loading:ag,attempt:sg,silent:Ig=!0,scale:Cg,listenEvents:lg,filter:Ag,adapter:rg,observer:cg,observerOptions:ug}){this.version='"3.0.0"',this.lazyContainerMananger=null,this.mode=modeType.event,this.ListenerQueue=[],this.TargetIndex=0,this.TargetQueue=[],this.options={silent:Ig,dispatchEvent:!!og,throttleWait:ig||200,preLoad:eg||1.3,preLoadTop:ng||0,error:gg||DEFAULT_URL,loading:ag||DEFAULT_URL,attempt:sg||3,scale:Cg||getDPR(Cg),listenEvents:lg||DEFAULT_EVENTS,supportWebp:supportWebp(),filter:Ag||{},adapter:rg||{},observer:!!cg,observerOptions:ug||DEFAULT_OBSERVER_OPTIONS},this._initEvent(),this._imageCache=new ImageCache(200),this.lazyLoadHandler=throttle(this._lazyLoadHandler.bind(this),this.options.throttleWait),this.setMode(this.options.observer?modeType.observer:modeType.event)}performance(){const eg=[];return this.ListenerQueue.map(gg=>eg.push(gg.performance())),eg}addLazyBox(eg){this.ListenerQueue.push(eg),inBrowser&&(this._addListenerTarget(window),this._observer&&this._observer.observe(eg.el),eg.$el&&eg.$el.parentNode&&this._addListenerTarget(eg.$el.parentNode))}add(eg,gg,ig){if(this.ListenerQueue.some(Ig=>Ig.el===eg))return this.update(eg,gg),nextTick(this.lazyLoadHandler);let{src:ng,loading:og,error:ag,cors:sg}=this._valueFormatter(gg.value);nextTick(()=>{ng=getBestSelectionFromSrcset(eg,this.options.scale)||ng,this._observer&&this._observer.observe(eg);const Ig=Object.keys(gg.modifiers)[0];let Cg;Ig&&(Cg=gg.instance.$refs[Ig],Cg=Cg?Cg.el||Cg:document.getElementById(Ig)),Cg||(Cg=scrollParent(eg));const lg=new ReactiveListener(eg,ng,ag,og,gg.arg,Cg,this.options,sg,this._elRenderer.bind(this),this._imageCache);this.ListenerQueue.push(lg),inBrowser&&(this._addListenerTarget(window),this._addListenerTarget(Cg)),nextTick(this.lazyLoadHandler)})}update(eg,gg,ig){let{src:ng,loading:og,error:ag}=this._valueFormatter(gg.value);ng=getBestSelectionFromSrcset(eg,this.options.scale)||ng;const sg=this.ListenerQueue.find(Ig=>Ig.el===eg);sg?sg.update({src:ng,loading:og,error:ag}):(eg.getAttribute("lazy")!=="loaded"||eg.dataset.src!==ng)&&this.add(eg,gg,ig),this._observer&&(this._observer.unobserve(eg),this._observer.observe(eg)),nextTick(this.lazyLoadHandler)}remove(eg){if(!eg)return;this._observer&&this._observer.unobserve(eg);const gg=this.ListenerQueue.find(ig=>ig.el===eg);gg&&(this._removeListenerTarget(gg.$parent),this._removeListenerTarget(window),remove(this.ListenerQueue,gg),gg.$destroy&&gg.$destroy())}removeComponent(eg){eg&&(remove(this.ListenerQueue,eg),this._observer&&this._observer.unobserve(eg.el),eg.$parent&&eg.$el.parentNode&&this._removeListenerTarget(eg.$el.parentNode),this._removeListenerTarget(window))}setMode(eg){!hasIntersectionObserver&&eg===modeType.observer&&(eg=modeType.event),this.mode=eg,eg===modeType.event?(this._observer&&(this.ListenerQueue.forEach(gg=>{this._observer.unobserve(gg.el)}),this._observer=null),this.TargetQueue.forEach(gg=>{this._initListen(gg.el,!0)})):(this.TargetQueue.forEach(gg=>{this._initListen(gg.el,!1)}),this._initIntersectionObserver())}_addListenerTarget(eg){if(!eg)return;let gg=this.TargetQueue.find(ig=>ig.el===eg);return gg?gg.childrenCount++:(gg={el:eg,id:++this.TargetIndex,childrenCount:1,listened:!0},this.mode===modeType.event&&this._initListen(gg.el,!0),this.TargetQueue.push(gg)),this.TargetIndex}_removeListenerTarget(eg){this.TargetQueue.forEach((gg,ig)=>{gg.el===eg&&(gg.childrenCount--,gg.childrenCount||(this._initListen(gg.el,!1),this.TargetQueue.splice(ig,1),gg=null))})}_initListen(eg,gg){this.options.listenEvents.forEach(ig=>_[gg?"on":"off"](eg,ig,this.lazyLoadHandler))}_initEvent(){this.Event={listeners:{loading:[],loaded:[],error:[]}},this.$on=(eg,gg)=>{this.Event.listeners[eg]||(this.Event.listeners[eg]=[]),this.Event.listeners[eg].push(gg)},this.$once=(eg,gg)=>{const ig=this;function ng(){ig.$off(eg,ng),gg.apply(ig,arguments)}this.$on(eg,ng)},this.$off=(eg,gg)=>{if(!gg){if(!this.Event.listeners[eg])return;this.Event.listeners[eg].length=0;return}remove(this.Event.listeners[eg],gg)},this.$emit=(eg,gg,ig)=>{this.Event.listeners[eg]&&this.Event.listeners[eg].forEach(ng=>ng(gg,ig))}}_lazyLoadHandler(){const eg=[];this.ListenerQueue.forEach((gg,ig)=>{(!gg.el||!gg.el.parentNode||gg.state.loaded)&&eg.push(gg),gg.checkInView()&&(gg.state.loaded||gg.load())}),eg.forEach(gg=>{remove(this.ListenerQueue,gg),gg.$destroy&&gg.$destroy()})}_initIntersectionObserver(){hasIntersectionObserver&&(this._observer=new IntersectionObserver(this._observerHandler.bind(this),this.options.observerOptions),this.ListenerQueue.length&&this.ListenerQueue.forEach(eg=>{this._observer.observe(eg.el)}))}_observerHandler(eg){eg.forEach(gg=>{gg.isIntersecting&&this.ListenerQueue.forEach(ig=>{if(ig.el===gg.target){if(ig.state.loaded)return this._observer.unobserve(ig.el);ig.load()}})})}_elRenderer(eg,gg,ig){if(!eg.el)return;const{el:ng,bindType:og}=eg;let ag;switch(gg){case"loading":ag=eg.loading;break;case"error":ag=eg.error;break;default:ag=eg.src;break}if(og?ng.style[og]='url("'+ag+'")':ng.getAttribute("src")!==ag&&ng.setAttribute("src",ag),ng.setAttribute("lazy",gg),this.$emit(gg,eg,ig),this.options.adapter[gg]&&this.options.adapter[gg](eg,this.options),this.options.dispatchEvent){const sg=new CustomEvent(gg,{detail:eg});ng.dispatchEvent(sg)}}_valueFormatter(eg){return isObject(eg)?(!eg.src&&!this.options.silent&&console.error("Vue Lazyload warning: miss src with "+eg),{src:eg.src,loading:eg.loading||this.options.loading,error:eg.error||this.options.error,cors:this.options.cors}):{src:eg,loading:this.options.loading,error:this.options.error,cors:this.options.cors}}}const useCheckInView=(tg,eg)=>{let gg=reactive({});const ig=()=>{gg=tg.value.getBoundingClientRect()};return{rect:gg,checkInView:()=>(ig(),inBrowser&&gg.top<window.innerHeight*eg&&gg.bottom>0&&gg.left<window.innerWidth*eg&&gg.right>0)}};var LazyComponent=(tg=>defineComponent({props:{tag:{type:String,default:"div"}},emits:["show"],setup(eg,{emit:gg,slots:ig}){const ng=ref(),og=reactive({loaded:!1,error:!1,attempt:0}),ag=ref(!1),{rect:sg,checkInView:Ig}=useCheckInView(ng,tg.options.preLoad),Cg=()=>{ag.value=!0,og.loaded=!0,gg("show",ag.value)},lg=computed(()=>({el:ng.value,rect:sg,checkInView:Ig,load:Cg,state:og}));return onMounted(()=>{tg.addLazyBox(lg.value),tg.lazyLoadHandler()}),onUnmounted(()=>{tg.removeComponent(lg.value)}),()=>{var Ag;return createVNode(eg.tag,{ref:ng},[ag.value&&((Ag=ig.default)===null||Ag===void 0?void 0:Ag.call(ig))])}}}));class LazyContainerMananger{constructor(eg){this.lazy=eg,eg.lazyContainerMananger=this,this._queue=[]}bind(eg,gg,ig){const ng=new LazyContainer(eg,gg,ig,this.lazy);this._queue.push(ng)}update(eg,gg,ig){const ng=this._queue.find(og=>og.el===eg);ng&&ng.update(eg,gg)}unbind(eg,gg,ig){const ng=this._queue.find(og=>og.el===eg);ng&&(ng.clear(),remove(this._queue,ng))}}const defaultOptions={selector:"img",error:"",loading:""};class LazyContainer{constructor(eg,gg,ig,ng){this.el=eg,this.vnode=ig,this.binding=gg,this.options={},this.lazy=ng,this._queue=[],this.update(eg,gg)}update(eg,gg){this.el=eg,this.options=assignDeep({},defaultOptions,gg.value),this.getImgs().forEach(ng=>{this.lazy.add(ng,assignDeep({},this.binding,{value:{src:ng.getAttribute("data-src")||ng.dataset.src,error:ng.getAttribute("data-error")||ng.dataset.error||this.options.error,loading:ng.getAttribute("data-loading")||ng.dataset.loading||this.options.loading}}),this.vnode)})}getImgs(){return Array.from(this.el.querySelectorAll(this.options.selector))}clear(){this.getImgs().forEach(gg=>this.lazy.remove(gg)),this.vnode=null,this.binding=null,this.lazy=null}}var LazyImage=(tg=>defineComponent({setup(eg,{slots:gg}){const ig=ref(),ng=reactive({src:"",error:"",loading:"",attempt:tg.options.attempt}),og=reactive({loaded:!1,error:!1,attempt:0}),{rect:ag,checkInView:sg}=useCheckInView(ig,tg.options.preLoad),Ig=ref(""),Cg=(rg=noop)=>{if(og.attempt>ng.attempt-1&&og.error)return tg.options.silent||console.log(`VueLazyload log: ${ng.src} tried too more than ${ng.attempt} times`),rg();const cg=ng.src;loadImageAsync({src:cg},({src:ug})=>{Ig.value=ug,og.loaded=!0},()=>{og.attempt++,Ig.value=ng.error,og.error=!0})},lg=computed(()=>({el:ig.value,rect:ag,checkInView:sg,load:Cg,state:og}));onMounted(()=>{tg.addLazyBox(lg.value),tg.lazyLoadHandler()}),onUnmounted(()=>{tg.removeComponent(lg.value)});const Ag=()=>{const{src:rg,loading:cg,error:ug}=tg._valueFormatter(eg.src);og.loaded=!1,ng.src=rg,ng.error=ug,ng.loading=cg,Ig.value=ng.loading};return watch(()=>eg.src,()=>{Ag(),tg.addLazyBox(lg.value),tg.lazyLoadHandler()},{immediate:!0}),()=>{var rg;return createVNode(eg.tag||"img",{src:Ig.value,ref:ig},[(rg=gg.default)===null||rg===void 0?void 0:rg.call(gg)])}}})),index={install(tg,eg={}){const gg=new Lazy(eg),ig=new LazyContainerMananger(gg);if(Number(tg.version.split(".")[0])<3)return new Error("Vue version at least 3.0");tg.config.globalProperties.$Lazyload=gg,tg.provide("Lazyload",gg),eg.lazyComponent&&tg.component("lazy-component",LazyComponent(gg)),eg.lazyImage&&tg.component("lazy-image",LazyImage(gg)),tg.directive("lazy",{beforeMount:gg.add.bind(gg),beforeUpdate:gg.update.bind(gg),updated:gg.lazyLoadHandler.bind(gg),unmounted:gg.remove.bind(gg)}),tg.directive("lazy-container",{beforeMount:ig.bind.bind(ig),updated:ig.update.bind(ig),unmounted:ig.unbind.bind(ig)})}};function createPiniaInstance(){return createPinia()}createPiniaInstance();const DEFAULT_USE_STATE={isShowEditTabs:!0,isMultiLayerEnabled:!0,isSeparateLayerMode:!1,separateLayerCount:2,separateLayerNames:[]},DEFAULT_SETTING_STATE={isShowRuler:!0,isShowGrid:!1},DEFAULT_SYS_CONFIG={config:{layerMaxCount:1}},DEFAULT_EDITOR_CONFIG={width:85.6,height:53.98,dpi:203,showVarnish:!1,showLaser:0,layerMaxCount:1,separateLayerMode:!1,layerStyleIndependent:!1,separateLayerCount:2,separateLayerNames:[],enabledTools:null,disabledTools:[],visibleMenus:null,enabledMenuItems:null,disabledMenuItems:[],cloudMaterialTypes:null,onCloudMaterialCategorySelect:null};function resetAllModuleState(){Object.assign(state$1,DEFAULT_USE_STATE),state$1.separateLayerNames=[],Object.assign(getSettingState(),DEFAULT_SETTING_STATE),Object.assign(getSysState(),DEFAULT_SYS_CONFIG),getSysState().config.layerMaxCount=1;const tg=dirtyState();Object.keys(tg).forEach(gg=>delete tg[gg]),Object.assign(getEditorConfig(),DEFAULT_EDITOR_CONFIG),getEditorConfig().separateLayerNames=[],getLaserPresets().value=[],getExternalLaserList().value=[];const eg=getLastSyncResult();eg&&(eg.value=null),resetEditorStack();try{resetDatabaseRuntimeState()}catch{}try{resetBarcodeMap()}catch{}try{hotkeys.unbind()}catch{}}const CMD_LIST=["ReplaceContent","AddPositionOffset","RecoverOriginalHSpacings","RemoveIndexs","RemoveNames","OnlyNames"],DEFAULT_LABEL_CONFIG={pageWidth:85.6,pageHeight:54,DPI:203,backgroundColor:"white",pageShape:"Rectangle",rows:1,columns:1,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,horizontalSpacing:0,verticalSpacing:0,orderStartAngle:"LeftTop",orderDirection:"Horizontal"};function parseJsonData(tg){return typeof tg=="string"?JSON.parse(tg):tg}function parseCanvasJson(tg){return typeof tg=="string"?JSON.parse(tg):tg}function normalizeCanvasJsonList(tg){const eg=parseCanvasJson(tg);return(Array.isArray(eg)?eg:[eg]).filter(Boolean).map(ig=>parseCanvasJson(ig))}function getCanvasLayerId(tg){var eg;try{return(eg=parseCanvasJson(tg))==null?void 0:eg.id}catch{return}}function resolveLayerRenderConfig(tg,eg,gg){const ig=(tg==null?void 0:tg.labelConfig)||{};if(ig.layerStyleIndependent!==!0)return{...ig};const ng=Array.isArray(tg==null?void 0:tg.layers)?tg.layers:[],og=getCanvasLayerId(eg),ag=og&&ng.find(sg=>(sg==null?void 0:sg.id)===og)||ng[gg];return{...ig,...(ag==null?void 0:ag.style)||{}}}function shouldIncludeLayerWorkspace(tg,eg,gg="merged"){var ig;return((ig=tg==null?void 0:tg.labelConfig)==null?void 0:ig.layerStyleIndependent)===!0||gg==="separate"||eg===0}function cloneJsonData(tg){return JSON.parse(JSON.stringify(tg))}function stringifyCanvasLikeSource(tg,eg){return typeof tg=="string"?JSON.stringify(eg):eg}function detectImageMimeFromBase64(tg){try{const eg=tg.replace(/^data:image\/\w+;base64,/,""),gg=atob(eg.slice(0,24)),ig=Array.from(gg).map(og=>og.charCodeAt(0)),ng=og=>og.every((ag,sg)=>ig[sg]===ag);if(ng([137,80,78,71]))return"png";if(ng([255,216,255]))return"jpeg";if(ng([71,73,70,56]))return"gif";if(ng([82,73,70,70])&&ig[8]===87&&ig[9]===69&&ig[10]===66&&ig[11]===80)return"webp";if(ng([66,77]))return"bmp"}catch{}return""}function getCmdObjectKey(tg){return tg!=null&&tg.fromJson?tg.jsonFieldKey||tg.name:tg==null?void 0:tg.name}function isCmdMatchObject(tg,eg,gg){const ig=String((tg==null?void 0:tg.type)||"").toLowerCase(),ng=getCmdObjectKey(tg);return gg.name!=null?ng===gg.name:gg.index!=null?eg===Number(gg.index):gg.type!=null?ig===String(gg.type).toLowerCase():!1}function setImageReplaceContent(tg,eg,gg){const ig=eg.content;if(tg.imgScaleType="1",console.log("cmdObj.scale========",eg.scale),eg.scale||eg.scale===0)switch(Number(eg.scale)){case 0:tg.imgScaleType="1";break;case 1:tg.imgScaleType="3";break;case 2:tg.imgScaleType="2";break;case 3:tg.imgScaleType="4";break}else eg.isScaleToPreviousWidth&&eg.isScaleToPreviousHeight?tg.imgScaleType="1":eg.isScaleToPreviousWidth?tg.imgScaleType="3":eg.isScaleToPreviousHeight&&(tg.imgScaleType="2");if(!ig||typeof ig!="string")return;const ng=ig.match(/url:/i),og=ig.match(/data:image/);if(ng&&ng.index===0){const ag=ig.replace(/url:/i,"");tg.src=gg?gg(ag):ag}else if(og&&og.index===0)tg.src=ig;else{const ag=detectImageMimeFromBase64(ig);ag&&(tg.src=`data:image/${ag};base64,${ig}`)}}function replaceCmdData(tg=[],eg=[],gg="",ig){const ng=[];let og=0;for(const ag of tg){const sg=String((ag==null?void 0:ag.type)||"").toLowerCase(),Ig=(ag==null?void 0:ag.objects)||(ag==null?void 0:ag._objects);if(sg==="group"&&Array.isArray(Ig)){const Ag=replaceCmdData(Ig,eg,"inGroup",ig);ag.objects&&(ag.objects=Ag),ag._objects&&(ag._objects=Ag)}let Cg=!1;const lg=getCmdObjectKey(ag);for(const Ag of eg){if(!Ag||!CMD_LIST.includes(Ag.cmd))continue;const rg=Ag.content;switch(Ag.cmd){case"ReplaceContent":if(!isCmdMatchObject(ag,og,Ag))break;switch(sg){case"text":case"textname":ag.text=rg;break;case"barcode":ag.barcodeOptions&&(ag.barcodeOptions.text=rg);break;case"barcode2d":ag.barcode2dOptions&&(ag.barcode2dOptions.text=rg);break;case"image":setImageReplaceContent(ag,Ag,ig);break}break;case"AddPositionOffset":Number(Ag.x)&&(ag.left+=Number(Ag.x)),Number(Ag.y)&&(ag.top+=Number(Ag.y));break;case"RecoverOriginalHSpacings":break;case"RemoveIndexs":gg!=="inGroup"&&(Ag.indexs||[]).map(ug=>Number(ug)).includes(og)&&(Cg=!0);break;case"RemoveNames":{(Ag.names||[]).includes(lg)&&(Cg=!0),sg==="group"&&Array.isArray(ag.objects)&&ag.objects.length===0&&(Cg=!0);break}case"OnlyNames":{const cg=Ag.names;Array.isArray(cg)&&!cg.includes(lg)&&(Cg=!0),sg==="group"&&Array.isArray(ag.objects)&&ag.objects.length>0&&(Cg=!1);break}}}og++,Cg||ng.push(ag)}return ng}function replaceCanvasCmdData(tg,eg=[],gg){if(!eg.length)return tg;const ig=cloneJsonData(tg),ng=og=>{if(!og)return og;const sg=(Array.isArray(og)?og:[og]).map(Ig=>{const Cg=parseCanvasJson(Ig);return Cg.objects=replaceCmdData(Cg.objects||[],eg,"",gg),stringifyCanvasLikeSource(Ig,Cg)});return Array.isArray(og)?sg:sg[0]};return ig.canvas=ng(ig.canvas),Array.isArray(ig.layers)&&(ig.layers=ig.layers.map(og=>({...og,canvas:ng(og==null?void 0:og.canvas)}))),ig}function loadImage(tg){return tg?new Promise(eg=>{const gg=new Image;gg.onload=()=>eg(gg),gg.onerror=()=>eg(null),gg.src=tg}):Promise.resolve(null)}function getAllCanvasObjects(tg){const eg=[],gg=ig=>{ig.type==="group"&&ig._objects?ig._objects.forEach(ng=>gg(ng)):ig.id!=="workspace"&&eg.push(ig)};return tg.getObjects().forEach(ig=>gg(ig)),eg}function getImageNaturalRatio(tg){const eg=typeof tg.getElement=="function"&&tg.getElement()||tg._element||null,gg=(eg==null?void 0:eg.naturalWidth)||(eg==null?void 0:eg.width)||0,ig=(eg==null?void 0:eg.naturalHeight)||(eg==null?void 0:eg.height)||0;return!gg||!ig?1:gg/ig}async function createExportWorkspace({labelConfig:tg,width:eg,height:gg}){const ig=(tg==null?void 0:tg.backgroundColor)||"white",ng=(tg==null?void 0:tg.backgroundImage)||"",og=(tg==null?void 0:tg.backgroundImageCover)!==!1,ag=(tg==null?void 0:tg.ribbonBorder)||null,sg=(tg==null?void 0:tg.pageShape)||"Rectangle",Ig=ng?await loadImage(ng):null;let Cg=null,lg=null;ag!=null&&ag.pattern&&ag.pattern!=="none"&&([Cg,lg]=await Promise.all([loadImage(ag.left||""),loadImage(ag.right||"")]));const Ag=sg==="Ellipse"?new _o({fill:ig,width:eg,height:gg,rx:eg/2,ry:gg/2,strokeWidth:0}):new Er({fill:ig,width:eg,height:gg,rx:sg==="RoundedRectangle"&&(tg==null?void 0:tg.rx)||0,ry:sg==="RoundedRectangle"&&(tg==null?void 0:tg.ry)||0,strokeWidth:0});if(Ag.set("id","workspace"),Ag.set("selectable",!1),Ag.set("hasControls",!1),Ag.excludeFromExport=!1,Ig||Cg&&lg){const rg=Ag._render.bind(Ag);Ag._render=cg=>{if(rg(cg),Ig){const ug=Ig.naturalWidth||Ig.width,dg=Ig.naturalHeight||Ig.height;if(ug&&dg){const hg=og?eg:ug,mg=og?gg:dg;cg.save(),cg.beginPath(),cg.rect(-eg/2,-gg/2,eg,gg),cg.clip(),cg.drawImage(Ig,-hg/2,-mg/2,hg,mg),cg.restore()}}ag!=null&&ag.pattern&&ag.pattern!=="none"&&Cg&&lg&&drawRibbonBorder(cg,ag.pattern,{left:-eg/2,top:-gg/2,width:eg,height:gg},{left:Cg,right:lg})}}return Ag}async function renderCanvasLayer({canvasJson:tg,includeWorkspace:eg,includeFullDataUrl:gg=!1,width:ig,height:ng,labelDPI:og,multiplier:ag,scaleList:sg=[],resTarget:Ig="img",labelConfig:Cg}){let lg=document.createElement("canvas"),Ag=new se(lg,{width:ig,height:ng,imageSmoothingEnabled:!1,fireMiddleClick:!0,fireRightClick:!0,stopContextMenu:!1,controlsAboveOverlay:!0,preserveObjectStacking:!0,selectionKey:"ctrlKey"});try{Ag.leRenderEnv="transform";const rg=await Ag.loadFromJSON(tg);if(eg){const mg=await createExportWorkspace({labelConfig:Cg,width:ig,height:ng});rg.insertAt(0,mg)}const cg=getAllCanvasObjects(rg),ug=[];let dg=!1;cg.forEach(mg=>{var bg,pg;if(mg.type==="text"&&(mg.set({left:Math.trunc(mg.left),top:Math.trunc(mg.top)}),mg.width=Math.trunc(mg.width),mg.height=Math.trunc(mg.height),mg.fontFamily&&mg.fontFamily.indexOf("宋体")>-1&&!mg.strokeWidth&&mg.set({strokeWidth:.3})),mg.type==="image"){const fg=isNativeImageAnchor(mg)?getImageAnchor(mg):void 0,wg=fg?captureObjectAnchor(mg,fg):void 0;let Gg=!1;if(sg&&sg.length){for(const Zg of sg)if(Zg.name===mg.name){Gg=!0;break}}if(Gg||(mg.imgScaleType=mg.imgScaleType||"1"),String(mg.imgScaleType)==="4"&&(mg.imgScaleType=getImageNaturalRatio(mg)>1?"3":"2"),Number(mg.imgScaleType)>1){mg.isScaleOtherSidedys=!0;let Zg=mg.getScaledHeight(),$g=mg.getScaledWidth();const Bg=getImageNaturalRatio(mg);if(Bg>0){if(String(mg.imgScaleType)==="2"){mg.height=Zg;const Wg=mg.height*Bg;mg.width!==Wg&&(mg.set({width:Wg,scaleX:1,scaleY:1}),mg.setCoords())}else if(String(mg.imgScaleType)==="3"){mg.width=$g;const Wg=mg.width/Bg;mg.height!==Wg&&(mg.set({height:Wg,scaleX:1,scaleY:1}),mg.setCoords())}}}wg&&fg&&((bg=mg.setPositionByOrigin)==null||bg.call(mg,wg,fg.x,fg.y),(pg=mg.setCoords)==null||pg.call(mg)),!fg&&mg.imageAlign&&mg.imageAlign!=="leftTop"&&ug.push(mg),mg.isSetSharpen&&(dg=!0)}}),rg.renderAll(),ug.forEach(mg=>{typeof mg.refreshAlignCoords=="function"&&mg.refreshAlignCoords(og)}),rg.renderAll();const hg={};if(Ig==="img"||Ig==="all"){if(gg)return{fullDataUrl:Ag.toDataURL({format:"png",quality:1,multiplier:ag})};const mg=["text","counter","textname","group","table"];hg.textDataUrl=Ag.toDataURL({multiplier:ag,filter:pg=>mg.includes(pg.type)&&pg.id!=="workspace"});const bg=["image","barcode","barcode2d","rect","circle","line","triangle"];hg.imgDataUrl=Ag.toDataURL({multiplier:ag,filter:pg=>(bg.includes(pg.type)||pg.id==="workspace")&&!pg.isSetSharpen}),hg.sharpenDataUrl="",dg&&(hg.sharpenDataUrl=Ag.toDataURL({multiplier:ag,filter:pg=>pg.type==="image"&&pg.isSetSharpen}))}return(Ig==="json"||Ig==="all")&&(hg.dataJson=Ag.toJSON()),hg}finally{Ag==null||Ag.dispose(),Ag=null,lg=null}}async function composeDataUrlsToPng(tg,eg,gg){const ig=tg.filter(Boolean);if(!ig.length)return"";if(ig.length===1)return ig[0];const ng=document.createElement("canvas");ng.width=Math.max(1,Math.round(eg)),ng.height=Math.max(1,Math.round(gg));const og=ng.getContext("2d");if(!og)return ig[0];for(const ag of ig){const sg=await loadImage(ag);sg&&og.drawImage(sg,0,0,ng.width,ng.height)}return ng.toDataURL("image/png",1)}async function composeDataUrlsHorizontally(tg,eg,gg,ig=130){const ng=tg.filter(Boolean);if(!ng.length)return"";if(ng.length===1)return ng[0];const og=document.createElement("canvas");og.width=Math.max(1,Math.round(ng.length*eg+(ng.length-1)*ig)),og.height=Math.max(1,Math.round(gg));const ag=og.getContext("2d");if(!ag)return ng[0];ag.imageSmoothingEnabled=!1;for(let sg=0;sg<ng.length;sg++){const Ig=await loadImage(ng[sg]);Ig&&ag.drawImage(Ig,sg*(eg+ig),0,eg,gg)}return og.toDataURL("image/png",1)}function getRenderMetrics(tg,eg={}){const gg={...DEFAULT_LABEL_CONFIG,...tg.labelConfig||{}},ig=Number(gg.DPI||eg.dpi)||203,ng=Number(eg.width||gg.pageWidth)||85.6,og=Number(eg.height||gg.pageHeight)||54,ag=ng*ig/25.4,sg=og*ig/25.4;return{labelConfig:gg,labelDPI:ig,width:ag,height:sg}}async function withTimeout(tg,eg=5e3,gg="加载 json 图片超时"){return new Promise((ig,ng)=>{const og=window.setTimeout(()=>{ng(new Error(gg))},eg);tg.then(ag=>ig(ag)).catch(ag=>ng(ag)).finally(()=>window.clearTimeout(og))})}function hasCounterInCanvas(tg){var ig,ng;if(!tg)return!1;const eg=typeof tg=="string"?JSON.parse(tg):tg,gg=(eg==null?void 0:eg.objects)||[];for(const og of gg){if(String((og==null?void 0:og.type)||"").toLowerCase()==="counter"&&((ig=og==null?void 0:og._props)==null?void 0:ig.mode)==="1"||og!=null&&og.counterProps&&(og.counterProps.value||og.counterProps.value===0))return!0;const sg=(og==null?void 0:og.objects)||(og==null?void 0:og._objects);if(Array.isArray(sg)){for(const Ig of sg)if(String((Ig==null?void 0:Ig.type)||"").toLowerCase()==="counter"&&((ng=Ig==null?void 0:Ig._props)==null?void 0:ng.mode)==="1"||Ig!=null&&Ig.counterProps&&(Ig.counterProps.value||Ig.counterProps.value===0))return!0}}return!1}function hasCounterObjects(tg){return tg.some(eg=>hasCounterInCanvas(eg))}function computeCounterValueAt(tg,eg){if(eg<=0)return tg.value;const gg=tg.valueType==="letter"?"letter":"number",ng=(Math.trunc(Number(tg.incremental))||0)*eg;if(gg==="letter"){const ag=Cg=>String(Cg??"").toUpperCase().replace(/[^A-Z]/g,"").split("").reduce((lg,Ag)=>lg*26+Ag.charCodeAt(0)-64,0)||1,sg=Cg=>{let lg=Math.max(1,Math.trunc(Cg)),Ag="";for(;lg>0;)lg--,Ag=String.fromCharCode(65+lg%26)+Ag,lg=Math.floor(lg/26);return Ag||"A"},Ig=ag(String(tg.value));return sg(Ig+ng)}const og=Number(tg.value);return Number.isFinite(og)?og+ng:tg.value}function applyCounterOffsetToObjects(tg,eg){var gg,ig;for(const ng of tg){const og=String((ng==null?void 0:ng.type)||"").toLowerCase(),ag=(ng==null?void 0:ng.objects)||(ng==null?void 0:ng._objects);if(og==="group"&&Array.isArray(ag)&&applyCounterOffsetToObjects(ag,eg),og==="counter"&&((gg=ng==null?void 0:ng._props)==null?void 0:gg.mode)==="1"&&((ig=ng==null?void 0:ng._props)!=null&&ig.args)){const sg=ng._props.args;if(sg.value||sg.value===0){const Ig={value:sg.value,incremental:sg.incremental,length:sg.length,zeroPadding:sg.zeroPadding,valueType:sg.valueType},Cg=computeCounterValueAt(Ig,eg);sg.value=Cg}}if(ng!=null&&ng.counterProps&&(ng.counterProps.value||ng.counterProps.value===0)){const sg={value:ng.counterProps.value,incremental:ng.counterProps.incremental,length:ng.counterProps.length,zeroPadding:ng.counterProps.zeroPadding,valueType:ng.counterProps.valueType},Ig=computeCounterValueAt(sg,eg);ng.counterProps.value=Ig}}}function cloneCanvasWithCounterOffset(tg,eg){return eg<=0?tg:tg.map(gg=>{const ig=typeof gg=="string"?JSON.parse(gg):gg,ng=JSON.parse(JSON.stringify(ig));return ng!=null&&ng.objects&&applyCounterOffsetToObjects(ng.objects,eg),typeof gg=="string"?JSON.stringify(ng):ng})}async function composeMultiTagsImageWithCounters(tg,eg,gg,ig,ng,og,ag,sg,Ig,Cg){const{rows:lg,columns:Ag,count:rg}=getMultiTagCount(eg);if(rg<=1)return"";const cg=ag/25.4,ug=Math.round(ng),dg=Math.round(og),hg=Math.round((Number(eg.paddingLeft)||0)*cg),mg=Math.round((Number(eg.paddingTop)||0)*cg),bg=Math.round((Number(eg.horizontalSpacing)||0)*cg),pg=Math.round((Number(eg.verticalSpacing)||0)*cg),fg=getOrderTable(lg,Ag,eg.orderStartAngle||"LeftTop",eg.orderDirection||"Horizontal"),wg=document.createElement("canvas");wg.width=Math.max(1,Math.round(gg)),wg.height=Math.max(1,Math.round(ig));const Gg=wg.getContext("2d");if(!Gg)return"";Gg.imageSmoothingEnabled=!1;const Zg=o.DPI;try{o.DPI=ag;for(let $g=0;$g<rg;$g++){const Bg=cloneCanvasWithCounterOffset(tg,$g),Wg=[];for(let Yg=0;Yg<Bg.length;Yg++){const Hg={...Ig,labelConfig:sg},kg=await renderCanvasLayer({canvasJson:Bg[Yg],includeWorkspace:shouldIncludeLayerWorkspace(Hg,Yg,Cg),includeFullDataUrl:!0,width:ng,height:og,labelDPI:ag,multiplier:1,scaleList:[],resTarget:"img",labelConfig:resolveLayerRenderConfig(Hg,Bg[Yg],Yg)});Wg.push(kg.fullDataUrl||"")}const yg=await composeDataUrlsToPng(Wg,ng,og),Ng=await loadImage(yg);if(!Ng)continue;const[vg,Sg]=fg[$g]||[Math.floor($g/Ag),$g%Ag],Vg=hg+Sg*(ug+bg),Xg=mg+vg*(dg+pg);Gg.drawImage(Ng,Vg,Xg,ug,dg)}}finally{o.DPI=Zg}return wg.toDataURL("image/png",1)}function getMultiTagCount(tg){const eg=Math.max(1,Math.floor(Number(tg==null?void 0:tg.rows)||1)),gg=Math.max(1,Math.floor(Number(tg==null?void 0:tg.columns)||1));return{rows:eg,columns:gg,count:eg*gg}}function getTagSizeMM(tg){const eg=Number(tg==null?void 0:tg.pageWidth)||0,gg=Number(tg==null?void 0:tg.pageHeight)||0;let ig=Number(tg==null?void 0:tg.tagWidth)||0,ng=Number(tg==null?void 0:tg.tagHeight)||0;if(!ig||!ng||ig===eg&&ng===gg){const og=Number(tg==null?void 0:tg.columns)||1,ag=Number(tg==null?void 0:tg.rows)||1;ig=Math.floor((eg-Number((tg==null?void 0:tg.paddingLeft)||0)-Number((tg==null?void 0:tg.paddingRight)||0)-Number((tg==null?void 0:tg.horizontalSpacing)||0)*(og-1))/og*100)/100,ng=Math.floor((gg-Number((tg==null?void 0:tg.paddingTop)||0)-Number((tg==null?void 0:tg.paddingBottom)||0)-Number((tg==null?void 0:tg.verticalSpacing)||0)*(ag-1))/ag*100)/100}return{width:ig,height:ng}}function getOrderTable(tg,eg,gg="LeftTop",ig="Horizontal"){const ng=[];if(ig==="Horizontal"){const og=gg==="LeftTop"||gg==="RightTop"?[...Array(tg).keys()]:[...Array(tg).keys()].reverse(),ag=gg==="LeftTop"||gg==="LeftBottom"?[...Array(eg).keys()]:[...Array(eg).keys()].reverse();for(const sg of og)for(const Ig of ag)ng.push([sg,Ig])}else{const og=gg==="LeftTop"||gg==="LeftBottom"?[...Array(eg).keys()]:[...Array(eg).keys()].reverse(),ag=gg==="LeftTop"||gg==="RightTop"?[...Array(tg).keys()]:[...Array(tg).keys()].reverse();for(const sg of og)for(const Ig of ag)ng.push([Ig,sg])}return ng}async function composeMultiTagsImage(tg,eg,gg,ig,ng,og,ag){if(!tg)return"";const{rows:sg,columns:Ig,count:Cg}=getMultiTagCount(eg);if(Cg<=1)return tg;const lg=await loadImage(tg);if(!lg)return tg;const Ag=ag/25.4,rg=Math.round(ng),cg=Math.round(og),ug=Math.round((Number(eg.paddingLeft)||0)*Ag),dg=Math.round((Number(eg.paddingTop)||0)*Ag),hg=Math.round((Number(eg.horizontalSpacing)||0)*Ag),mg=Math.round((Number(eg.verticalSpacing)||0)*Ag),bg=getOrderTable(sg,Ig,eg.orderStartAngle||"LeftTop",eg.orderDirection||"Horizontal"),pg=document.createElement("canvas");pg.width=Math.max(1,Math.round(gg)),pg.height=Math.max(1,Math.round(ig));const fg=pg.getContext("2d");if(!fg)return tg;fg.imageSmoothingEnabled=!1;for(let wg=0;wg<Cg;wg++){const[Gg,Zg]=bg[wg]||[Math.floor(wg/Ig),wg%Ig],$g=ug+Zg*(rg+hg),Bg=dg+Gg*(cg+mg);fg.drawImage(lg,$g,Bg,rg,cg)}return pg.toDataURL("image/png",1)}async function loadJsonToImageBase64(tg,eg={}){const{cmds:gg=[],timeout:ig=5e3,returnDataUrl:ng=!0,imageUrlResolver:og,mode:ag="merged",gap:sg=50}=eg,Ig=replaceCanvasCmdData(parseJsonData(tg),gg,og),{labelConfig:Cg,labelDPI:lg,width:Ag,height:rg}=getRenderMetrics(Ig,{dpi:eg.dpi,width:eg.width,height:eg.height}),{count:cg}=getMultiTagCount(Cg),ug=cg>1;let dg=Ag,hg=rg;if(ug){const Wg=getTagSizeMM(Cg);dg=Wg.width*lg/25.4,hg=Wg.height*lg/25.4}const mg=o.DPI,bg=normalizeCanvasJsonList(Ig.canvas),pg={...Ig,labelConfig:Cg},fg=[],wg=ug&&hasCounterObjects(bg),Gg=(async()=>{try{if(o.DPI=lg,wg)return composeMultiTagsImageWithCounters(bg,Cg,Ag,rg,dg,hg,lg,Cg,pg,ag);for(let yg=0;yg<bg.length;yg++){const Ng=await renderCanvasLayer({canvasJson:bg[yg],includeWorkspace:shouldIncludeLayerWorkspace(pg,yg,ag),includeFullDataUrl:!0,width:dg,height:hg,labelDPI:lg,multiplier:1,scaleList:[],resTarget:"img",labelConfig:resolveLayerRenderConfig(pg,bg[yg],yg)});fg.push(Ng.fullDataUrl||"")}if(ag==="separate"){const yg=await composeDataUrlsHorizontally(fg,dg,hg,sg);return{images:fg,composedImage:yg}}const Wg=await composeDataUrlsToPng(fg,dg,hg);return ug?composeMultiTagsImage(Wg,Cg,Ag,rg,dg,hg,lg):Wg}finally{o.DPI=mg}})(),Zg=wg?Math.max(ig,ig*cg):ig,$g=await withTimeout(Gg,Zg),Bg=Wg=>ng?Wg:Wg.replace(/^data:image\/\w+;base64,/,"");return typeof $g=="string"?Bg($g):{images:$g.images.map(Bg),composedImage:Bg($g.composedImage)}}let _activeInstance=null,_laserWarnShown=!1;function normalizeFileFieldJson(tg){let eg;if(typeof tg=="string"){const gg=tg.trim();if(!gg)return"";eg=JSON.parse(gg)}else{const gg=JSON.stringify(tg,null,2);if(gg===void 0)throw new Error("Invalid fileFieldJson");eg=JSON.parse(gg)}return JSON.stringify(normalizeJsonVariableRecord(eg),null,2)}function countSize(tg,eg="MB"){const gg=new TextEncoder().encode(tg).length;return eg==="KB"?gg/1024:gg/(1024*1024)}class LabelEditor{constructor(eg,gg){UI(this,"_autoSaveTimer",null);UI(this,"_insertFileFieldJsonTimer",null);UI(this,"_pendingFileFieldJson",null);UI(this,"_fileFieldJsonLabelReadyHandler",null);UI(this,"_app",null);UI(this,"_el",null);UI(this,"_initialLang",null);UI(this,"_localeController");UI(this,"_releaseActiveI18n",null);UI(this,"_stopLocaleWatch",null);UI(this,"_destroyed",!1);UI(this,"_isReplaceFont",!1);UI(this,"_defaultBuiltinFontPromise",Promise.resolve(!1));UI(this,"_maxSize",0);UI(this,"_laserWarnInstance",null);const ig=gg||{},ng=!!ig.__offscreenRender;if(!ng&&_activeInstance&&!_activeInstance._destroyed&&_activeInstance._el===eg)return console.warn("[LabelEditor] 同一容器已有活跃实例,复用现有实例"),ig.messages&&_activeInstance.setMessages(ig.messages),reuseEditorWithLocale(_activeInstance,ig.locale);if(!ng&&_activeInstance&&!_activeInstance._destroyed&&(console.warn("[LabelEditor] 检测到其他容器上的活跃实例,先销毁旧实例"),_activeInstance.destroy()),gg!=null&&gg.maxSize&&(this._maxSize=gg==null?void 0:gg.maxSize),gg&&!ng){const Cg={...gg};delete Cg.__offscreenRender,delete Cg.locale,delete Cg.messages,Cg.separateLayerMode=Cg.separateLayerMode===!0,Object.keys(Cg).length&&setEditorConfig(Cg),this.setSeparateLayerMode(!!getEditorConfig().separateLayerMode),getEditorConfig().separateLayerMode?this.setLayerMaxCount(getEditorConfig().separateLayerCount):this.setLayerMaxCount(Cg.layerMaxCount??1)}resetFontState(),this._defaultBuiltinFontPromise=loadDefaultBuiltinFont();const og=ng?LabelEditor._pauseVueDevtoolsForOffscreenRender():()=>{},ag=createApp(_sfc_main),sg=createEditorI18n(ig.locale,ig.messages),{i18n:Ig}=sg;this._localeController=sg,this._initialLang=eg.getAttribute("lang"),ng&&(ag.config.devtools=!1),ag.config.errorHandler=(Cg,lg,Ag)=>{console.error("全局错误:",Cg,lg,Ag)};try{const Cg=createPiniaInstance();this._stopLocaleWatch=mountEditorApplication(ag,eg,sg,()=>{ag.use(Ig),ag.use(Cg).use(index,{}).use(modalInstall).use(loadingInstall)})}finally{og()}this._app=ag,this._el=eg,ng||(this._releaseActiveI18n=activateEditorI18n(sg),_activeInstance=this)}static _pauseVueDevtoolsForOffscreenRender(){const eg=window,gg="__VUE_DEVTOOLS_GLOBAL_HOOK__",ig=Object.prototype.hasOwnProperty.call(eg,gg),ng=eg[gg];if(!ng)return()=>{};try{return eg[gg]=void 0,()=>{ig?eg[gg]=ng:delete eg[gg]}}catch{const og=ng.enabled;return ng.enabled=!1,()=>{ng.enabled=og}}}static async loadJsonToImageBase64(eg,gg={}){return LabelEditor.exportImage({...gg,data:eg})}static async exportImage(eg){const{data:gg,...ig}=eg;return loadJsonToImageBase64(gg,ig)}get loadedFonts(){return loadedFonts}ready(){return this._defaultBuiltinFontPromise}loadBuiltinFont(eg){return loadBuiltinFont(eg)}loadBuiltinFonts(eg){return loadBuiltinFonts(eg)}loadAllDefaultFonts(){return loadBuiltinFonts(["LXGW WenKai","Liberation Sans","Source Han Serif SC","Caladea"])}setLocale(eg){return this._localeController.setLocale(eg)}getLocale(){return this._localeController.locale.value}destroy(){var eg,gg,ig;if(!this._destroyed){if(this._destroyed=!0,_laserWarnShown=!1,clearInterval(this._autoSaveTimer),this._autoSaveTimer=null,clearTimeout(this._insertFileFieldJsonTimer),this._insertFileFieldJsonTimer=null,this._pendingFileFieldJson=null,this._fileFieldJsonLabelReadyHandler&&(emitter.off("label-ready",this._fileFieldJsonLabelReadyHandler),this._fileFieldJsonLabelReadyHandler=null),(eg=this._stopLocaleWatch)==null||eg.call(this),this._stopLocaleWatch=null,(gg=this._releaseActiveI18n)==null||gg.call(this),this._releaseActiveI18n=null,this._app&&(this._app.unmount(),this._app=null),this._laserWarnInstance){try{this._laserWarnInstance.destroy()}catch{}this._laserWarnInstance=null}try{setActivePinia(this._pinia);const ng=useTabsStore();(ig=ng.$reset)==null||ig.call(ng)}catch{}try{getActivePinia()===this._pinia&&setActivePinia(null)}catch{}this._pinia=null,resetDatabaseRuntimeState(),emitter.all.clear(),canvasEventBus.all.clear();try{resetFontState()}catch{}try{resetAllModuleState()}catch{}this._el&&(this._initialLang==null?this._el.removeAttribute("lang"):this._el.setAttribute("lang",this._initialLang),this._el.innerHTML="",this._el=null),this._initialLang=null,_activeInstance===this&&(_activeInstance=null)}}filterLoadFontByName(eg){let gg=Array.from(this.loadedFonts);return eg.filter(ng=>{let og=!gg.includes(ng);if(!this._isReplaceFont){for(let ag of fontListDefault)if(ag.value===ng&&ag.value==="Source Han Sans SC"){og=!1;break}}return og})}loadJson(eg,{newFile:gg=!1}={}){let ng=typeof eg=="string"?JSON.parse(eg):eg;const og=new Set(extractFontNames(ng.canvas));if(Array.isArray(ng.layers)&&ng.layers.forEach(Ig=>{Ig!=null&&Ig.canvas&&extractFontNames(Ig.canvas).forEach(Cg=>og.add(Cg))}),og.size){let Ig=Array.from(og);emitter.emit("selectFontCallback",Ig)}gg?resetLaserPresetsFromExternal():ng.laserConfigList&&Array.isArray(ng.laserConfigList)?setLaserPresets(ng.laserConfigList):resetLaserPresetsFromExternal();const ag=ng.labelConfig||getTempLabelConfig();ag.layerStyleIndependent==null&&(ag.layerStyleIndependent=getEditorConfig().layerStyleIndependent),emitter.emit("label-config",{labelConfig:ag,canvas:ng.canvas,layers:ng.layers,activeLayerId:ng.activeLayerId,newFile:gg});const sg=syncExternalPresets();this.notifyLaserSyncWarning(sg,ng)}notifyLaserSyncWarning(eg,gg){const ig=[];eg.deletedNames.length>0&&ig.push(translate("editor.specialist.laser.deletedWarning",{deletedNames:eg.deletedNames.join('"、"')}));const ng=getLaserMaxPresets(),og=this.countUsedLaserPresets(gg);if(ng>0&&og>ng&&ig.push(translate("editor.specialist.laser.limitWarning",{maxPresets:ng,usedCount:og})),ig.length===0)return;const ag=ig.join(`
|
|
959
|
+
*/function createCommonjsModule(tg,eg){return eg={exports:{}},tg(eg,eg.exports),eg.exports}var assignSymbols$1=createCommonjsModule(function(tg){const eg=Object.prototype.toString,gg=Object.prototype.propertyIsEnumerable,ig=Object.getOwnPropertySymbols;tg.exports=(og,...ag)=>{if(!ng(og))throw new TypeError("expected the first argument to be an object");if(ag.length===0||typeof Symbol!="function"||typeof ig!="function")return og;for(let sg of ag){let Ig=ig(sg);for(let Cg of Ig)gg.call(sg,Cg)&&(og[Cg]=sg[Cg])}return og};function ng(og){return typeof og=="function"||eg.call(og)==="[object Object]"||Array.isArray(og)}}),assignSymbols$2=Object.freeze({__proto__:null,default:assignSymbols$1,__moduleExports:assignSymbols$1}),assignSymbols=assignSymbols$2&&assignSymbols$1||assignSymbols$2,assignDeep=createCommonjsModule(function(tg){const eg=Object.prototype.toString,gg=ag=>ag!=="__proto__"&&ag!=="constructor"&&ag!=="prototype",ig=tg.exports=(ag,...sg)=>{let Ig=0;for(og(ag)&&(ag=sg[Ig++]),ag||(ag={});Ig<sg.length;Ig++)if(ng(sg[Ig])){for(const Cg of Object.keys(sg[Ig]))gg(Cg)&&(ng(ag[Cg])&&ng(sg[Ig][Cg])?ig(ag[Cg],sg[Ig][Cg]):ag[Cg]=sg[Ig][Cg]);assignSymbols(ag,sg[Ig])}return ag};function ng(ag){return typeof ag=="function"||eg.call(ag)==="[object Object]"}function og(ag){return typeof ag=="object"?ag===null:typeof ag!="function"}});const inBrowser=typeof window<"u"&&window!==null,hasIntersectionObserver=checkIntersectionObserver();function checkIntersectionObserver(){return inBrowser&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype?("isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}}),!0):!1}const modeType={event:"event",observer:"observer"};function remove(tg,eg){if(!tg.length)return;const gg=tg.indexOf(eg);if(gg>-1)return tg.splice(gg,1)}function getBestSelectionFromSrcset(tg,eg){if(tg.tagName!=="IMG"||!tg.getAttribute("data-srcset"))return"";let gg=tg.getAttribute("data-srcset").trim().split(",");const ig=[],og=tg.parentNode.offsetWidth*eg;let ag,sg,Ig;gg.forEach(Ag=>{Ag=Ag.trim(),ag=Ag.lastIndexOf(" "),ag===-1?(sg=Ag,Ig=99999):(sg=Ag.substr(0,ag),Ig=parseInt(Ag.substr(ag+1,Ag.length-ag-2),10)),ig.push([Ig,sg])}),ig.sort((Ag,rg)=>{if(Ag[0]<rg[0])return 1;if(Ag[0]>rg[0])return-1;if(Ag[0]===rg[0]){if(rg[1].indexOf(".webp",rg[1].length-5)!==-1)return 1;if(Ag[1].indexOf(".webp",Ag[1].length-5)!==-1)return-1}return 0});let Cg="",lg;for(let Ag=0;Ag<ig.length;Ag++){lg=ig[Ag],Cg=lg[1];const rg=ig[Ag+1];if(rg&&rg[0]<og){Cg=lg[1];break}else if(!rg){Cg=lg[1];break}}return Cg}const getDPR=(tg=1)=>inBrowser&&window.devicePixelRatio||tg;function supportWebp(){if(!inBrowser)return!1;let tg=!0;function eg(gg,ig){const ng={lossy:"UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",lossless:"UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==",alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"},og=new Image;og.onload=function(){const ag=og.width>0&&og.height>0;ig(ag)},og.onerror=function(){ig(!1)},og.src="data:image/webp;base64,"+ng[gg]}return eg("lossy",gg=>{tg=gg}),eg("lossless",gg=>{tg=gg}),eg("alpha",gg=>{tg=gg}),eg("animation",gg=>{tg=gg}),tg}function throttle(tg,eg){let gg=null,ig=0;return function(){if(gg)return;const ng=Date.now()-ig,og=this,ag=arguments,sg=function(){ig=Date.now(),gg=!1,tg.apply(og,ag)};ng>=eg?sg():gg=setTimeout(sg,eg)}}function testSupportsPassive(){if(!inBrowser)return!1;let tg=!1;try{const eg=Object.defineProperty({},"passive",{get:function(){tg=!0}});window.addEventListener("test",noop,eg)}catch{}return tg}const supportsPassive=testSupportsPassive(),_={on(tg,eg,gg,ig=!1){supportsPassive?tg.addEventListener(eg,gg,{capture:ig,passive:!0}):tg.addEventListener(eg,gg,ig)},off(tg,eg,gg,ig=!1){tg.removeEventListener(eg,gg,ig)}},loadImageAsync=(tg,eg,gg)=>{let ig=new Image;if(!tg||!tg.src){const ng=new Error("image src is required");return gg(ng)}tg.cors&&(ig.crossOrigin=tg.cors),ig.src=tg.src,ig.onload=function(){eg({naturalHeight:ig.naturalHeight,naturalWidth:ig.naturalWidth,src:ig.src}),ig=null},ig.onerror=function(ng){gg(ng)}},style=(tg,eg)=>typeof getComputedStyle<"u"?getComputedStyle(tg,null).getPropertyValue(eg):tg.style[eg],overflow=tg=>style(tg,"overflow")+style(tg,"overflowY")+style(tg,"overflowX"),scrollParent=tg=>{if(!inBrowser)return;if(!(tg instanceof Element))return window;let eg=tg;for(;eg&&!(eg===document.body||eg===document.documentElement||!eg.parentNode);){if(/(scroll|auto)/.test(overflow(eg)))return eg;eg=eg.parentNode}return window};function isObject(tg){return tg!==null&&typeof tg=="object"}function noop(){}class ImageCache{constructor(eg){this.max=eg||100,this._caches=[]}has(eg){return this._caches.indexOf(eg)>-1}add(eg){this.has(eg)||(this._caches.push(eg),this._caches.length>this.max&&this.free())}free(){this._caches.shift()}}class ReactiveListener{constructor(eg,gg,ig,ng,og,ag,sg,Ig,Cg,lg){this.el=eg,this.src=gg,this.error=ig,this.loading=ng,this.bindType=og,this.attempt=0,this.cors=Ig,this.naturalHeight=0,this.naturalWidth=0,this.options=sg,this.rect={},this.$parent=ag,this.elRenderer=Cg,this._imageCache=lg,this.performanceData={init:Date.now(),loadStart:0,loadEnd:0},this.filter(),this.initState(),this.render("loading",!1)}initState(){"dataset"in this.el?this.el.dataset.src=this.src:this.el.setAttribute("data-src",this.src),this.state={loading:!1,error:!1,loaded:!1,rendered:!1}}record(eg){this.performanceData[eg]=Date.now()}update(eg){const gg=this.src;this.src=eg.src,this.loading=eg.loading,this.error=eg.error,this.filter(),gg!==this.src&&(this.attempt=0,this.initState())}getRect(){this.rect=this.el.getBoundingClientRect()}checkInView(){return this.getRect(),this.rect.top<window.innerHeight*this.options.preLoad&&this.rect.bottom>this.options.preLoadTop&&this.rect.left<window.innerWidth*this.options.preLoad&&this.rect.right>0}filter(){for(const eg in this.options.filter)this.options.filter[eg](this,this.options)}renderLoading(eg){this.state.loading=!0,loadImageAsync({src:this.loading,cors:this.cors},()=>{this.render("loading",!1),this.state.loading=!1,eg()},()=>{eg(),this.state.loading=!1,this.options.silent||console.warn(`VueLazyload log: load failed with loading image(${this.loading})`)})}load(eg=noop){if(this.attempt>this.options.attempt-1&&this.state.error){this.options.silent||console.log(`VueLazyload log: ${this.src} tried too more than ${this.options.attempt} times`),eg();return}if(!(this.state.rendered&&this.state.loaded)){if(this._imageCache.has(this.src))return this.state.loaded=!0,this.render("loaded",!0),this.state.rendered=!0,eg();this.renderLoading(()=>{this.attempt++,this.options.adapter.beforeLoad&&this.options.adapter.beforeLoad(this,this.options),this.record("loadStart"),loadImageAsync({src:this.src,cors:this.cors},gg=>{this.naturalHeight=gg.naturalHeight,this.naturalWidth=gg.naturalWidth,this.state.loaded=!0,this.state.error=!1,this.record("loadEnd"),this.render("loaded",!1),this.state.rendered=!0,this._imageCache.add(this.src),eg()},gg=>{!this.options.silent&&console.error(gg),this.state.error=!0,this.state.loaded=!1,this.render("error",!1)})})}}render(eg,gg){this.elRenderer(this,eg,gg)}performance(){let eg="loading",gg=0;return this.state.loaded&&(eg="loaded",gg=(this.performanceData.loadEnd-this.performanceData.loadStart)/1e3),this.state.error&&(eg="error"),{src:this.src,state:eg,time:gg}}$destroy(){this.el=null,this.src="",this.error=null,this.loading="",this.bindType=null,this.attempt=0}}const DEFAULT_URL="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",DEFAULT_EVENTS=["scroll","wheel","mousewheel","resize","animationend","transitionend","touchmove"],DEFAULT_OBSERVER_OPTIONS={rootMargin:"0px",threshold:0};class Lazy{constructor({preLoad:eg,error:gg,throttleWait:ig,preLoadTop:ng,dispatchEvent:og,loading:ag,attempt:sg,silent:Ig=!0,scale:Cg,listenEvents:lg,filter:Ag,adapter:rg,observer:cg,observerOptions:ug}){this.version='"3.0.0"',this.lazyContainerMananger=null,this.mode=modeType.event,this.ListenerQueue=[],this.TargetIndex=0,this.TargetQueue=[],this.options={silent:Ig,dispatchEvent:!!og,throttleWait:ig||200,preLoad:eg||1.3,preLoadTop:ng||0,error:gg||DEFAULT_URL,loading:ag||DEFAULT_URL,attempt:sg||3,scale:Cg||getDPR(Cg),listenEvents:lg||DEFAULT_EVENTS,supportWebp:supportWebp(),filter:Ag||{},adapter:rg||{},observer:!!cg,observerOptions:ug||DEFAULT_OBSERVER_OPTIONS},this._initEvent(),this._imageCache=new ImageCache(200),this.lazyLoadHandler=throttle(this._lazyLoadHandler.bind(this),this.options.throttleWait),this.setMode(this.options.observer?modeType.observer:modeType.event)}performance(){const eg=[];return this.ListenerQueue.map(gg=>eg.push(gg.performance())),eg}addLazyBox(eg){this.ListenerQueue.push(eg),inBrowser&&(this._addListenerTarget(window),this._observer&&this._observer.observe(eg.el),eg.$el&&eg.$el.parentNode&&this._addListenerTarget(eg.$el.parentNode))}add(eg,gg,ig){if(this.ListenerQueue.some(Ig=>Ig.el===eg))return this.update(eg,gg),nextTick(this.lazyLoadHandler);let{src:ng,loading:og,error:ag,cors:sg}=this._valueFormatter(gg.value);nextTick(()=>{ng=getBestSelectionFromSrcset(eg,this.options.scale)||ng,this._observer&&this._observer.observe(eg);const Ig=Object.keys(gg.modifiers)[0];let Cg;Ig&&(Cg=gg.instance.$refs[Ig],Cg=Cg?Cg.el||Cg:document.getElementById(Ig)),Cg||(Cg=scrollParent(eg));const lg=new ReactiveListener(eg,ng,ag,og,gg.arg,Cg,this.options,sg,this._elRenderer.bind(this),this._imageCache);this.ListenerQueue.push(lg),inBrowser&&(this._addListenerTarget(window),this._addListenerTarget(Cg)),nextTick(this.lazyLoadHandler)})}update(eg,gg,ig){let{src:ng,loading:og,error:ag}=this._valueFormatter(gg.value);ng=getBestSelectionFromSrcset(eg,this.options.scale)||ng;const sg=this.ListenerQueue.find(Ig=>Ig.el===eg);sg?sg.update({src:ng,loading:og,error:ag}):(eg.getAttribute("lazy")!=="loaded"||eg.dataset.src!==ng)&&this.add(eg,gg,ig),this._observer&&(this._observer.unobserve(eg),this._observer.observe(eg)),nextTick(this.lazyLoadHandler)}remove(eg){if(!eg)return;this._observer&&this._observer.unobserve(eg);const gg=this.ListenerQueue.find(ig=>ig.el===eg);gg&&(this._removeListenerTarget(gg.$parent),this._removeListenerTarget(window),remove(this.ListenerQueue,gg),gg.$destroy&&gg.$destroy())}removeComponent(eg){eg&&(remove(this.ListenerQueue,eg),this._observer&&this._observer.unobserve(eg.el),eg.$parent&&eg.$el.parentNode&&this._removeListenerTarget(eg.$el.parentNode),this._removeListenerTarget(window))}setMode(eg){!hasIntersectionObserver&&eg===modeType.observer&&(eg=modeType.event),this.mode=eg,eg===modeType.event?(this._observer&&(this.ListenerQueue.forEach(gg=>{this._observer.unobserve(gg.el)}),this._observer=null),this.TargetQueue.forEach(gg=>{this._initListen(gg.el,!0)})):(this.TargetQueue.forEach(gg=>{this._initListen(gg.el,!1)}),this._initIntersectionObserver())}_addListenerTarget(eg){if(!eg)return;let gg=this.TargetQueue.find(ig=>ig.el===eg);return gg?gg.childrenCount++:(gg={el:eg,id:++this.TargetIndex,childrenCount:1,listened:!0},this.mode===modeType.event&&this._initListen(gg.el,!0),this.TargetQueue.push(gg)),this.TargetIndex}_removeListenerTarget(eg){this.TargetQueue.forEach((gg,ig)=>{gg.el===eg&&(gg.childrenCount--,gg.childrenCount||(this._initListen(gg.el,!1),this.TargetQueue.splice(ig,1),gg=null))})}_initListen(eg,gg){this.options.listenEvents.forEach(ig=>_[gg?"on":"off"](eg,ig,this.lazyLoadHandler))}_initEvent(){this.Event={listeners:{loading:[],loaded:[],error:[]}},this.$on=(eg,gg)=>{this.Event.listeners[eg]||(this.Event.listeners[eg]=[]),this.Event.listeners[eg].push(gg)},this.$once=(eg,gg)=>{const ig=this;function ng(){ig.$off(eg,ng),gg.apply(ig,arguments)}this.$on(eg,ng)},this.$off=(eg,gg)=>{if(!gg){if(!this.Event.listeners[eg])return;this.Event.listeners[eg].length=0;return}remove(this.Event.listeners[eg],gg)},this.$emit=(eg,gg,ig)=>{this.Event.listeners[eg]&&this.Event.listeners[eg].forEach(ng=>ng(gg,ig))}}_lazyLoadHandler(){const eg=[];this.ListenerQueue.forEach((gg,ig)=>{(!gg.el||!gg.el.parentNode||gg.state.loaded)&&eg.push(gg),gg.checkInView()&&(gg.state.loaded||gg.load())}),eg.forEach(gg=>{remove(this.ListenerQueue,gg),gg.$destroy&&gg.$destroy()})}_initIntersectionObserver(){hasIntersectionObserver&&(this._observer=new IntersectionObserver(this._observerHandler.bind(this),this.options.observerOptions),this.ListenerQueue.length&&this.ListenerQueue.forEach(eg=>{this._observer.observe(eg.el)}))}_observerHandler(eg){eg.forEach(gg=>{gg.isIntersecting&&this.ListenerQueue.forEach(ig=>{if(ig.el===gg.target){if(ig.state.loaded)return this._observer.unobserve(ig.el);ig.load()}})})}_elRenderer(eg,gg,ig){if(!eg.el)return;const{el:ng,bindType:og}=eg;let ag;switch(gg){case"loading":ag=eg.loading;break;case"error":ag=eg.error;break;default:ag=eg.src;break}if(og?ng.style[og]='url("'+ag+'")':ng.getAttribute("src")!==ag&&ng.setAttribute("src",ag),ng.setAttribute("lazy",gg),this.$emit(gg,eg,ig),this.options.adapter[gg]&&this.options.adapter[gg](eg,this.options),this.options.dispatchEvent){const sg=new CustomEvent(gg,{detail:eg});ng.dispatchEvent(sg)}}_valueFormatter(eg){return isObject(eg)?(!eg.src&&!this.options.silent&&console.error("Vue Lazyload warning: miss src with "+eg),{src:eg.src,loading:eg.loading||this.options.loading,error:eg.error||this.options.error,cors:this.options.cors}):{src:eg,loading:this.options.loading,error:this.options.error,cors:this.options.cors}}}const useCheckInView=(tg,eg)=>{let gg=reactive({});const ig=()=>{gg=tg.value.getBoundingClientRect()};return{rect:gg,checkInView:()=>(ig(),inBrowser&&gg.top<window.innerHeight*eg&&gg.bottom>0&&gg.left<window.innerWidth*eg&&gg.right>0)}};var LazyComponent=(tg=>defineComponent({props:{tag:{type:String,default:"div"}},emits:["show"],setup(eg,{emit:gg,slots:ig}){const ng=ref(),og=reactive({loaded:!1,error:!1,attempt:0}),ag=ref(!1),{rect:sg,checkInView:Ig}=useCheckInView(ng,tg.options.preLoad),Cg=()=>{ag.value=!0,og.loaded=!0,gg("show",ag.value)},lg=computed(()=>({el:ng.value,rect:sg,checkInView:Ig,load:Cg,state:og}));return onMounted(()=>{tg.addLazyBox(lg.value),tg.lazyLoadHandler()}),onUnmounted(()=>{tg.removeComponent(lg.value)}),()=>{var Ag;return createVNode(eg.tag,{ref:ng},[ag.value&&((Ag=ig.default)===null||Ag===void 0?void 0:Ag.call(ig))])}}}));class LazyContainerMananger{constructor(eg){this.lazy=eg,eg.lazyContainerMananger=this,this._queue=[]}bind(eg,gg,ig){const ng=new LazyContainer(eg,gg,ig,this.lazy);this._queue.push(ng)}update(eg,gg,ig){const ng=this._queue.find(og=>og.el===eg);ng&&ng.update(eg,gg)}unbind(eg,gg,ig){const ng=this._queue.find(og=>og.el===eg);ng&&(ng.clear(),remove(this._queue,ng))}}const defaultOptions={selector:"img",error:"",loading:""};class LazyContainer{constructor(eg,gg,ig,ng){this.el=eg,this.vnode=ig,this.binding=gg,this.options={},this.lazy=ng,this._queue=[],this.update(eg,gg)}update(eg,gg){this.el=eg,this.options=assignDeep({},defaultOptions,gg.value),this.getImgs().forEach(ng=>{this.lazy.add(ng,assignDeep({},this.binding,{value:{src:ng.getAttribute("data-src")||ng.dataset.src,error:ng.getAttribute("data-error")||ng.dataset.error||this.options.error,loading:ng.getAttribute("data-loading")||ng.dataset.loading||this.options.loading}}),this.vnode)})}getImgs(){return Array.from(this.el.querySelectorAll(this.options.selector))}clear(){this.getImgs().forEach(gg=>this.lazy.remove(gg)),this.vnode=null,this.binding=null,this.lazy=null}}var LazyImage=(tg=>defineComponent({setup(eg,{slots:gg}){const ig=ref(),ng=reactive({src:"",error:"",loading:"",attempt:tg.options.attempt}),og=reactive({loaded:!1,error:!1,attempt:0}),{rect:ag,checkInView:sg}=useCheckInView(ig,tg.options.preLoad),Ig=ref(""),Cg=(rg=noop)=>{if(og.attempt>ng.attempt-1&&og.error)return tg.options.silent||console.log(`VueLazyload log: ${ng.src} tried too more than ${ng.attempt} times`),rg();const cg=ng.src;loadImageAsync({src:cg},({src:ug})=>{Ig.value=ug,og.loaded=!0},()=>{og.attempt++,Ig.value=ng.error,og.error=!0})},lg=computed(()=>({el:ig.value,rect:ag,checkInView:sg,load:Cg,state:og}));onMounted(()=>{tg.addLazyBox(lg.value),tg.lazyLoadHandler()}),onUnmounted(()=>{tg.removeComponent(lg.value)});const Ag=()=>{const{src:rg,loading:cg,error:ug}=tg._valueFormatter(eg.src);og.loaded=!1,ng.src=rg,ng.error=ug,ng.loading=cg,Ig.value=ng.loading};return watch(()=>eg.src,()=>{Ag(),tg.addLazyBox(lg.value),tg.lazyLoadHandler()},{immediate:!0}),()=>{var rg;return createVNode(eg.tag||"img",{src:Ig.value,ref:ig},[(rg=gg.default)===null||rg===void 0?void 0:rg.call(gg)])}}})),index={install(tg,eg={}){const gg=new Lazy(eg),ig=new LazyContainerMananger(gg);if(Number(tg.version.split(".")[0])<3)return new Error("Vue version at least 3.0");tg.config.globalProperties.$Lazyload=gg,tg.provide("Lazyload",gg),eg.lazyComponent&&tg.component("lazy-component",LazyComponent(gg)),eg.lazyImage&&tg.component("lazy-image",LazyImage(gg)),tg.directive("lazy",{beforeMount:gg.add.bind(gg),beforeUpdate:gg.update.bind(gg),updated:gg.lazyLoadHandler.bind(gg),unmounted:gg.remove.bind(gg)}),tg.directive("lazy-container",{beforeMount:ig.bind.bind(ig),updated:ig.update.bind(ig),unmounted:ig.unbind.bind(ig)})}};function createPiniaInstance(){return createPinia()}createPiniaInstance();const DEFAULT_USE_STATE={isShowEditTabs:!0,isMultiLayerEnabled:!0,isSeparateLayerMode:!1,separateLayerCount:2,separateLayerNames:[]},DEFAULT_SETTING_STATE={isShowRuler:!0,isShowGrid:!1},DEFAULT_SYS_CONFIG={config:{layerMaxCount:1}},DEFAULT_EDITOR_CONFIG={width:85.6,height:53.98,dpi:203,showVarnish:!1,showLaser:0,layerMaxCount:1,separateLayerMode:!1,layerStyleIndependent:!1,separateLayerCount:2,separateLayerNames:[],enabledTools:null,disabledTools:[],visibleMenus:null,enabledMenuItems:null,disabledMenuItems:[],cloudMaterialTypes:null,onCloudMaterialCategorySelect:null};function resetAllModuleState(){Object.assign(state$1,DEFAULT_USE_STATE),state$1.separateLayerNames=[],Object.assign(getSettingState(),DEFAULT_SETTING_STATE),Object.assign(getSysState(),DEFAULT_SYS_CONFIG),getSysState().config.layerMaxCount=1;const tg=dirtyState();Object.keys(tg).forEach(gg=>delete tg[gg]),Object.assign(getEditorConfig(),DEFAULT_EDITOR_CONFIG),getEditorConfig().separateLayerNames=[],getLaserPresets().value=[],getExternalLaserList().value=[];const eg=getLastSyncResult();eg&&(eg.value=null),resetEditorStack();try{resetDatabaseRuntimeState()}catch{}try{resetBarcodeMap()}catch{}try{hotkeys.unbind()}catch{}}const CMD_LIST=["ReplaceContent","AddPositionOffset","RecoverOriginalHSpacings","RemoveIndexs","RemoveNames","OnlyNames"],DEFAULT_LABEL_CONFIG={pageWidth:85.6,pageHeight:54,DPI:203,backgroundColor:"white",pageShape:"Rectangle",rows:1,columns:1,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,horizontalSpacing:0,verticalSpacing:0,orderStartAngle:"LeftTop",orderDirection:"Horizontal"};function parseJsonData(tg){return typeof tg=="string"?JSON.parse(tg):tg}function parseCanvasJson(tg){return typeof tg=="string"?JSON.parse(tg):tg}function normalizeCanvasJsonList(tg){const eg=parseCanvasJson(tg);return(Array.isArray(eg)?eg:[eg]).filter(Boolean).map(ig=>parseCanvasJson(ig))}function getCanvasLayerId(tg){var eg;try{return(eg=parseCanvasJson(tg))==null?void 0:eg.id}catch{return}}function resolveLayerRenderConfig(tg,eg,gg){const ig=(tg==null?void 0:tg.labelConfig)||{};if(ig.layerStyleIndependent!==!0)return{...ig};const ng=Array.isArray(tg==null?void 0:tg.layers)?tg.layers:[],og=getCanvasLayerId(eg),ag=og&&ng.find(sg=>(sg==null?void 0:sg.id)===og)||ng[gg];return{...ig,...(ag==null?void 0:ag.style)||{}}}function shouldIncludeLayerWorkspace(tg,eg,gg="merged"){var ig;return((ig=tg==null?void 0:tg.labelConfig)==null?void 0:ig.layerStyleIndependent)===!0||gg==="separate"||eg===0}function cloneJsonData(tg){return JSON.parse(JSON.stringify(tg))}function stringifyCanvasLikeSource(tg,eg){return typeof tg=="string"?JSON.stringify(eg):eg}function detectImageMimeFromBase64(tg){try{const eg=tg.replace(/^data:image\/\w+;base64,/,""),gg=atob(eg.slice(0,24)),ig=Array.from(gg).map(og=>og.charCodeAt(0)),ng=og=>og.every((ag,sg)=>ig[sg]===ag);if(ng([137,80,78,71]))return"png";if(ng([255,216,255]))return"jpeg";if(ng([71,73,70,56]))return"gif";if(ng([82,73,70,70])&&ig[8]===87&&ig[9]===69&&ig[10]===66&&ig[11]===80)return"webp";if(ng([66,77]))return"bmp"}catch{}return""}function getCmdObjectKey(tg){return tg!=null&&tg.fromJson?tg.jsonFieldKey||tg.name:tg==null?void 0:tg.name}function isCmdMatchObject(tg,eg,gg){const ig=String((tg==null?void 0:tg.type)||"").toLowerCase(),ng=getCmdObjectKey(tg);return gg.name!=null?ng===gg.name:gg.index!=null?eg===Number(gg.index):gg.type!=null?ig===String(gg.type).toLowerCase():!1}function setImageReplaceContent(tg,eg,gg){const ig=eg.content;if(tg.imgScaleType="1",console.log("cmdObj.scale========",eg.scale),eg.scale||eg.scale===0)switch(Number(eg.scale)){case 0:tg.imgScaleType="1";break;case 1:tg.imgScaleType="3";break;case 2:tg.imgScaleType="2";break;case 3:tg.imgScaleType="4";break}else eg.isScaleToPreviousWidth&&eg.isScaleToPreviousHeight?tg.imgScaleType="1":eg.isScaleToPreviousWidth?tg.imgScaleType="3":eg.isScaleToPreviousHeight&&(tg.imgScaleType="2");if(!ig||typeof ig!="string")return;const ng=ig.match(/url:/i),og=ig.match(/data:image/);if(ng&&ng.index===0){const ag=ig.replace(/url:/i,"");tg.src=gg?gg(ag):ag}else if(og&&og.index===0)tg.src=ig;else{const ag=detectImageMimeFromBase64(ig);ag&&(tg.src=`data:image/${ag};base64,${ig}`)}}function replaceCmdData(tg=[],eg=[],gg="",ig){const ng=[];let og=0;for(const ag of tg){const sg=String((ag==null?void 0:ag.type)||"").toLowerCase(),Ig=(ag==null?void 0:ag.objects)||(ag==null?void 0:ag._objects);if(sg==="group"&&Array.isArray(Ig)){const Ag=replaceCmdData(Ig,eg,"inGroup",ig);ag.objects&&(ag.objects=Ag),ag._objects&&(ag._objects=Ag)}let Cg=!1;const lg=getCmdObjectKey(ag);for(const Ag of eg){if(!Ag||!CMD_LIST.includes(Ag.cmd))continue;const rg=Ag.content;switch(Ag.cmd){case"ReplaceContent":if(!isCmdMatchObject(ag,og,Ag))break;switch(sg){case"text":case"textname":ag.text=rg;break;case"barcode":ag.barcodeOptions&&(ag.barcodeOptions.text=rg);break;case"barcode2d":ag.barcode2dOptions&&(ag.barcode2dOptions.text=rg);break;case"image":setImageReplaceContent(ag,Ag,ig);break}break;case"AddPositionOffset":Number(Ag.x)&&(ag.left+=Number(Ag.x)),Number(Ag.y)&&(ag.top+=Number(Ag.y));break;case"RecoverOriginalHSpacings":break;case"RemoveIndexs":gg!=="inGroup"&&(Ag.indexs||[]).map(ug=>Number(ug)).includes(og)&&(Cg=!0);break;case"RemoveNames":{(Ag.names||[]).includes(lg)&&(Cg=!0),sg==="group"&&Array.isArray(ag.objects)&&ag.objects.length===0&&(Cg=!0);break}case"OnlyNames":{const cg=Ag.names;Array.isArray(cg)&&!cg.includes(lg)&&(Cg=!0),sg==="group"&&Array.isArray(ag.objects)&&ag.objects.length>0&&(Cg=!1);break}}}og++,Cg||ng.push(ag)}return ng}function replaceCanvasCmdData(tg,eg=[],gg){if(!eg.length)return tg;const ig=cloneJsonData(tg),ng=og=>{if(!og)return og;const sg=(Array.isArray(og)?og:[og]).map(Ig=>{const Cg=parseCanvasJson(Ig);return Cg.objects=replaceCmdData(Cg.objects||[],eg,"",gg),stringifyCanvasLikeSource(Ig,Cg)});return Array.isArray(og)?sg:sg[0]};return ig.canvas=ng(ig.canvas),Array.isArray(ig.layers)&&(ig.layers=ig.layers.map(og=>({...og,canvas:ng(og==null?void 0:og.canvas)}))),ig}function loadImage(tg){return tg?new Promise(eg=>{const gg=new Image;gg.onload=()=>eg(gg),gg.onerror=()=>eg(null),gg.src=tg}):Promise.resolve(null)}function getAllCanvasObjects(tg){const eg=[],gg=ig=>{ig.type==="group"&&ig._objects?ig._objects.forEach(ng=>gg(ng)):ig.id!=="workspace"&&eg.push(ig)};return tg.getObjects().forEach(ig=>gg(ig)),eg}function getImageNaturalRatio(tg){const eg=typeof tg.getElement=="function"&&tg.getElement()||tg._element||null,gg=(eg==null?void 0:eg.naturalWidth)||(eg==null?void 0:eg.width)||0,ig=(eg==null?void 0:eg.naturalHeight)||(eg==null?void 0:eg.height)||0;return!gg||!ig?1:gg/ig}async function createExportWorkspace({labelConfig:tg,width:eg,height:gg}){const ig=(tg==null?void 0:tg.backgroundColor)||"white",ng=(tg==null?void 0:tg.backgroundImage)||"",og=(tg==null?void 0:tg.backgroundImageCover)!==!1,ag=(tg==null?void 0:tg.ribbonBorder)||null,sg=(tg==null?void 0:tg.pageShape)||"Rectangle",Ig=ng?await loadImage(ng):null;let Cg=null,lg=null;ag!=null&&ag.pattern&&ag.pattern!=="none"&&([Cg,lg]=await Promise.all([loadImage(ag.left||""),loadImage(ag.right||"")]));const Ag=sg==="Ellipse"?new _o({fill:ig,width:eg,height:gg,rx:eg/2,ry:gg/2,strokeWidth:0}):new Er({fill:ig,width:eg,height:gg,rx:sg==="RoundedRectangle"&&(tg==null?void 0:tg.rx)||0,ry:sg==="RoundedRectangle"&&(tg==null?void 0:tg.ry)||0,strokeWidth:0});if(Ag.set("id","workspace"),Ag.set("selectable",!1),Ag.set("hasControls",!1),Ag.excludeFromExport=!1,Ig||Cg&&lg){const rg=Ag._render.bind(Ag);Ag._render=cg=>{if(rg(cg),Ig){const ug=Ig.naturalWidth||Ig.width,dg=Ig.naturalHeight||Ig.height;if(ug&&dg){const hg=og?eg:ug,mg=og?gg:dg;cg.save(),cg.beginPath(),cg.rect(-eg/2,-gg/2,eg,gg),cg.clip(),cg.drawImage(Ig,-hg/2,-mg/2,hg,mg),cg.restore()}}ag!=null&&ag.pattern&&ag.pattern!=="none"&&Cg&&lg&&drawRibbonBorder(cg,ag.pattern,{left:-eg/2,top:-gg/2,width:eg,height:gg},{left:Cg,right:lg})}}return Ag}async function renderCanvasLayer({canvasJson:tg,includeWorkspace:eg,includeFullDataUrl:gg=!1,width:ig,height:ng,labelDPI:og,multiplier:ag,scaleList:sg=[],resTarget:Ig="img",labelConfig:Cg}){let lg=document.createElement("canvas"),Ag=new se(lg,{width:ig,height:ng,imageSmoothingEnabled:!1,fireMiddleClick:!0,fireRightClick:!0,stopContextMenu:!1,controlsAboveOverlay:!0,preserveObjectStacking:!0,selectionKey:"ctrlKey"});try{Ag.leRenderEnv="transform";const rg=await Ag.loadFromJSON(tg);if(eg){const mg=await createExportWorkspace({labelConfig:Cg,width:ig,height:ng});rg.insertAt(0,mg)}const cg=getAllCanvasObjects(rg),ug=[];let dg=!1;cg.forEach(mg=>{var bg,pg;if(mg.type==="text"&&(mg.set({left:Math.trunc(mg.left),top:Math.trunc(mg.top)}),mg.width=Math.trunc(mg.width),mg.height=Math.trunc(mg.height),mg.fontFamily&&mg.fontFamily.indexOf("宋体")>-1&&!mg.strokeWidth&&mg.set({strokeWidth:.3})),mg.type==="image"){const fg=isNativeImageAnchor(mg)?getImageAnchor(mg):void 0,wg=fg?captureObjectAnchor(mg,fg):void 0;let Gg=!1;if(sg&&sg.length){for(const Zg of sg)if(Zg.name===mg.name){Gg=!0;break}}if(Gg||(mg.imgScaleType=mg.imgScaleType||"1"),String(mg.imgScaleType)==="4"&&(mg.imgScaleType=getImageNaturalRatio(mg)>1?"3":"2"),Number(mg.imgScaleType)>1){mg.isScaleOtherSidedys=!0;let Zg=mg.getScaledHeight(),$g=mg.getScaledWidth();const Bg=getImageNaturalRatio(mg);if(Bg>0){if(String(mg.imgScaleType)==="2"){mg.height=Zg;const Wg=mg.height*Bg;mg.width!==Wg&&(mg.set({width:Wg,scaleX:1,scaleY:1}),mg.setCoords())}else if(String(mg.imgScaleType)==="3"){mg.width=$g;const Wg=mg.width/Bg;mg.height!==Wg&&(mg.set({height:Wg,scaleX:1,scaleY:1}),mg.setCoords())}}}wg&&fg&&((bg=mg.setPositionByOrigin)==null||bg.call(mg,wg,fg.x,fg.y),(pg=mg.setCoords)==null||pg.call(mg)),!fg&&mg.imageAlign&&mg.imageAlign!=="leftTop"&&ug.push(mg),mg.isSetSharpen&&(dg=!0)}}),rg.renderAll(),ug.forEach(mg=>{typeof mg.refreshAlignCoords=="function"&&mg.refreshAlignCoords(og)}),rg.renderAll();const hg={};if(Ig==="img"||Ig==="all"){if(gg)return{fullDataUrl:Ag.toDataURL({format:"png",quality:1,multiplier:ag})};const mg=["text","counter","textname","group","table"];hg.textDataUrl=Ag.toDataURL({multiplier:ag,filter:pg=>mg.includes(pg.type)&&pg.id!=="workspace"});const bg=["image","barcode","barcode2d","rect","circle","line","triangle"];hg.imgDataUrl=Ag.toDataURL({multiplier:ag,filter:pg=>(bg.includes(pg.type)||pg.id==="workspace")&&!pg.isSetSharpen}),hg.sharpenDataUrl="",dg&&(hg.sharpenDataUrl=Ag.toDataURL({multiplier:ag,filter:pg=>pg.type==="image"&&pg.isSetSharpen}))}return(Ig==="json"||Ig==="all")&&(hg.dataJson=Ag.toJSON()),hg}finally{Ag==null||Ag.dispose(),Ag=null,lg=null}}async function composeDataUrlsToPng(tg,eg,gg){const ig=tg.filter(Boolean);if(!ig.length)return"";if(ig.length===1)return ig[0];const ng=document.createElement("canvas");ng.width=Math.max(1,Math.round(eg)),ng.height=Math.max(1,Math.round(gg));const og=ng.getContext("2d");if(!og)return ig[0];for(const ag of ig){const sg=await loadImage(ag);sg&&og.drawImage(sg,0,0,ng.width,ng.height)}return ng.toDataURL("image/png",1)}async function composeDataUrlsHorizontally(tg,eg,gg,ig=130){const ng=tg.filter(Boolean);if(!ng.length)return"";if(ng.length===1)return ng[0];const og=document.createElement("canvas");og.width=Math.max(1,Math.round(ng.length*eg+(ng.length-1)*ig)),og.height=Math.max(1,Math.round(gg));const ag=og.getContext("2d");if(!ag)return ng[0];ag.imageSmoothingEnabled=!1;for(let sg=0;sg<ng.length;sg++){const Ig=await loadImage(ng[sg]);Ig&&ag.drawImage(Ig,sg*(eg+ig),0,eg,gg)}return og.toDataURL("image/png",1)}function getRenderMetrics(tg,eg={}){const gg={...DEFAULT_LABEL_CONFIG,...tg.labelConfig||{}},ig=Number(gg.DPI||eg.dpi)||203,ng=Number(eg.width||gg.pageWidth)||85.6,og=Number(eg.height||gg.pageHeight)||54,ag=ng*ig/25.4,sg=og*ig/25.4;return{labelConfig:gg,labelDPI:ig,width:ag,height:sg}}async function withTimeout(tg,eg=5e3,gg="加载 json 图片超时"){return new Promise((ig,ng)=>{const og=window.setTimeout(()=>{ng(new Error(gg))},eg);tg.then(ag=>ig(ag)).catch(ag=>ng(ag)).finally(()=>window.clearTimeout(og))})}function hasCounterInCanvas(tg){var ig,ng;if(!tg)return!1;const eg=typeof tg=="string"?JSON.parse(tg):tg,gg=(eg==null?void 0:eg.objects)||[];for(const og of gg){if(String((og==null?void 0:og.type)||"").toLowerCase()==="counter"&&((ig=og==null?void 0:og._props)==null?void 0:ig.mode)==="1"||og!=null&&og.counterProps&&(og.counterProps.value||og.counterProps.value===0))return!0;const sg=(og==null?void 0:og.objects)||(og==null?void 0:og._objects);if(Array.isArray(sg)){for(const Ig of sg)if(String((Ig==null?void 0:Ig.type)||"").toLowerCase()==="counter"&&((ng=Ig==null?void 0:Ig._props)==null?void 0:ng.mode)==="1"||Ig!=null&&Ig.counterProps&&(Ig.counterProps.value||Ig.counterProps.value===0))return!0}}return!1}function hasCounterObjects(tg){return tg.some(eg=>hasCounterInCanvas(eg))}function computeCounterValueAt(tg,eg){if(eg<=0)return tg.value;const gg=tg.valueType==="letter"?"letter":"number",ng=(Math.trunc(Number(tg.incremental))||0)*eg;if(gg==="letter"){const ag=Cg=>String(Cg??"").toUpperCase().replace(/[^A-Z]/g,"").split("").reduce((lg,Ag)=>lg*26+Ag.charCodeAt(0)-64,0)||1,sg=Cg=>{let lg=Math.max(1,Math.trunc(Cg)),Ag="";for(;lg>0;)lg--,Ag=String.fromCharCode(65+lg%26)+Ag,lg=Math.floor(lg/26);return Ag||"A"},Ig=ag(String(tg.value));return sg(Ig+ng)}const og=Number(tg.value);return Number.isFinite(og)?og+ng:tg.value}function applyCounterOffsetToObjects(tg,eg){var gg,ig;for(const ng of tg){const og=String((ng==null?void 0:ng.type)||"").toLowerCase(),ag=(ng==null?void 0:ng.objects)||(ng==null?void 0:ng._objects);if(og==="group"&&Array.isArray(ag)&&applyCounterOffsetToObjects(ag,eg),og==="counter"&&((gg=ng==null?void 0:ng._props)==null?void 0:gg.mode)==="1"&&((ig=ng==null?void 0:ng._props)!=null&&ig.args)){const sg=ng._props.args;if(sg.value||sg.value===0){const Ig={value:sg.value,incremental:sg.incremental,length:sg.length,zeroPadding:sg.zeroPadding,valueType:sg.valueType},Cg=computeCounterValueAt(Ig,eg);sg.value=Cg}}if(ng!=null&&ng.counterProps&&(ng.counterProps.value||ng.counterProps.value===0)){const sg={value:ng.counterProps.value,incremental:ng.counterProps.incremental,length:ng.counterProps.length,zeroPadding:ng.counterProps.zeroPadding,valueType:ng.counterProps.valueType},Ig=computeCounterValueAt(sg,eg);ng.counterProps.value=Ig}}}function cloneCanvasWithCounterOffset(tg,eg){return eg<=0?tg:tg.map(gg=>{const ig=typeof gg=="string"?JSON.parse(gg):gg,ng=JSON.parse(JSON.stringify(ig));return ng!=null&&ng.objects&&applyCounterOffsetToObjects(ng.objects,eg),typeof gg=="string"?JSON.stringify(ng):ng})}async function composeMultiTagsImageWithCounters(tg,eg,gg,ig,ng,og,ag,sg,Ig,Cg){const{rows:lg,columns:Ag,count:rg}=getMultiTagCount(eg);if(rg<=1)return"";const cg=ag/25.4,ug=Math.round(ng),dg=Math.round(og),hg=Math.round((Number(eg.paddingLeft)||0)*cg),mg=Math.round((Number(eg.paddingTop)||0)*cg),bg=Math.round((Number(eg.horizontalSpacing)||0)*cg),pg=Math.round((Number(eg.verticalSpacing)||0)*cg),fg=getOrderTable(lg,Ag,eg.orderStartAngle||"LeftTop",eg.orderDirection||"Horizontal"),wg=document.createElement("canvas");wg.width=Math.max(1,Math.round(gg)),wg.height=Math.max(1,Math.round(ig));const Gg=wg.getContext("2d");if(!Gg)return"";Gg.imageSmoothingEnabled=!1;const Zg=o.DPI;try{o.DPI=ag;for(let $g=0;$g<rg;$g++){const Bg=cloneCanvasWithCounterOffset(tg,$g),Wg=[];for(let Yg=0;Yg<Bg.length;Yg++){const Hg={...Ig,labelConfig:sg},kg=await renderCanvasLayer({canvasJson:Bg[Yg],includeWorkspace:shouldIncludeLayerWorkspace(Hg,Yg,Cg),includeFullDataUrl:!0,width:ng,height:og,labelDPI:ag,multiplier:1,scaleList:[],resTarget:"img",labelConfig:resolveLayerRenderConfig(Hg,Bg[Yg],Yg)});Wg.push(kg.fullDataUrl||"")}const yg=await composeDataUrlsToPng(Wg,ng,og),Ng=await loadImage(yg);if(!Ng)continue;const[vg,Sg]=fg[$g]||[Math.floor($g/Ag),$g%Ag],Vg=hg+Sg*(ug+bg),Xg=mg+vg*(dg+pg);Gg.drawImage(Ng,Vg,Xg,ug,dg)}}finally{o.DPI=Zg}return wg.toDataURL("image/png",1)}function getMultiTagCount(tg){const eg=Math.max(1,Math.floor(Number(tg==null?void 0:tg.rows)||1)),gg=Math.max(1,Math.floor(Number(tg==null?void 0:tg.columns)||1));return{rows:eg,columns:gg,count:eg*gg}}function getTagSizeMM(tg){const eg=Number(tg==null?void 0:tg.pageWidth)||0,gg=Number(tg==null?void 0:tg.pageHeight)||0;let ig=Number(tg==null?void 0:tg.tagWidth)||0,ng=Number(tg==null?void 0:tg.tagHeight)||0;if(!ig||!ng||ig===eg&&ng===gg){const og=Number(tg==null?void 0:tg.columns)||1,ag=Number(tg==null?void 0:tg.rows)||1;ig=Math.floor((eg-Number((tg==null?void 0:tg.paddingLeft)||0)-Number((tg==null?void 0:tg.paddingRight)||0)-Number((tg==null?void 0:tg.horizontalSpacing)||0)*(og-1))/og*100)/100,ng=Math.floor((gg-Number((tg==null?void 0:tg.paddingTop)||0)-Number((tg==null?void 0:tg.paddingBottom)||0)-Number((tg==null?void 0:tg.verticalSpacing)||0)*(ag-1))/ag*100)/100}return{width:ig,height:ng}}function getOrderTable(tg,eg,gg="LeftTop",ig="Horizontal"){const ng=[];if(ig==="Horizontal"){const og=gg==="LeftTop"||gg==="RightTop"?[...Array(tg).keys()]:[...Array(tg).keys()].reverse(),ag=gg==="LeftTop"||gg==="LeftBottom"?[...Array(eg).keys()]:[...Array(eg).keys()].reverse();for(const sg of og)for(const Ig of ag)ng.push([sg,Ig])}else{const og=gg==="LeftTop"||gg==="LeftBottom"?[...Array(eg).keys()]:[...Array(eg).keys()].reverse(),ag=gg==="LeftTop"||gg==="RightTop"?[...Array(tg).keys()]:[...Array(tg).keys()].reverse();for(const sg of og)for(const Ig of ag)ng.push([Ig,sg])}return ng}async function composeMultiTagsImage(tg,eg,gg,ig,ng,og,ag){if(!tg)return"";const{rows:sg,columns:Ig,count:Cg}=getMultiTagCount(eg);if(Cg<=1)return tg;const lg=await loadImage(tg);if(!lg)return tg;const Ag=ag/25.4,rg=Math.round(ng),cg=Math.round(og),ug=Math.round((Number(eg.paddingLeft)||0)*Ag),dg=Math.round((Number(eg.paddingTop)||0)*Ag),hg=Math.round((Number(eg.horizontalSpacing)||0)*Ag),mg=Math.round((Number(eg.verticalSpacing)||0)*Ag),bg=getOrderTable(sg,Ig,eg.orderStartAngle||"LeftTop",eg.orderDirection||"Horizontal"),pg=document.createElement("canvas");pg.width=Math.max(1,Math.round(gg)),pg.height=Math.max(1,Math.round(ig));const fg=pg.getContext("2d");if(!fg)return tg;fg.imageSmoothingEnabled=!1;for(let wg=0;wg<Cg;wg++){const[Gg,Zg]=bg[wg]||[Math.floor(wg/Ig),wg%Ig],$g=ug+Zg*(rg+hg),Bg=dg+Gg*(cg+mg);fg.drawImage(lg,$g,Bg,rg,cg)}return pg.toDataURL("image/png",1)}async function loadJsonToImageBase64(tg,eg={}){const{cmds:gg=[],timeout:ig=5e3,returnDataUrl:ng=!0,imageUrlResolver:og,mode:ag="merged",gap:sg=50}=eg,Ig=replaceCanvasCmdData(parseJsonData(tg),gg,og),{labelConfig:Cg,labelDPI:lg,width:Ag,height:rg}=getRenderMetrics(Ig,{dpi:eg.dpi,width:eg.width,height:eg.height}),{count:cg}=getMultiTagCount(Cg),ug=cg>1;let dg=Ag,hg=rg;if(ug){const Wg=getTagSizeMM(Cg);dg=Wg.width*lg/25.4,hg=Wg.height*lg/25.4}const mg=o.DPI,bg=normalizeCanvasJsonList(Ig.canvas),pg={...Ig,labelConfig:Cg},fg=[],wg=ug&&hasCounterObjects(bg),Gg=(async()=>{try{if(o.DPI=lg,wg)return composeMultiTagsImageWithCounters(bg,Cg,Ag,rg,dg,hg,lg,Cg,pg,ag);for(let yg=0;yg<bg.length;yg++){const Ng=await renderCanvasLayer({canvasJson:bg[yg],includeWorkspace:shouldIncludeLayerWorkspace(pg,yg,ag),includeFullDataUrl:!0,width:dg,height:hg,labelDPI:lg,multiplier:1,scaleList:[],resTarget:"img",labelConfig:resolveLayerRenderConfig(pg,bg[yg],yg)});fg.push(Ng.fullDataUrl||"")}if(ag==="separate"){const yg=await composeDataUrlsHorizontally(fg,dg,hg,sg);return{images:fg,composedImage:yg}}const Wg=await composeDataUrlsToPng(fg,dg,hg);return ug?composeMultiTagsImage(Wg,Cg,Ag,rg,dg,hg,lg):Wg}finally{o.DPI=mg}})(),Zg=wg?Math.max(ig,ig*cg):ig,$g=await withTimeout(Gg,Zg),Bg=Wg=>ng?Wg:Wg.replace(/^data:image\/\w+;base64,/,"");return typeof $g=="string"?Bg($g):{images:$g.images.map(Bg),composedImage:Bg($g.composedImage)}}let _activeInstance=null,_laserWarnShown=!1;function normalizeFileFieldJson(tg){let eg;if(typeof tg=="string"){const gg=tg.trim();if(!gg)return"";eg=JSON.parse(gg)}else{const gg=JSON.stringify(tg,null,2);if(gg===void 0)throw new Error("Invalid fileFieldJson");eg=JSON.parse(gg)}return JSON.stringify(normalizeJsonVariableRecord(eg),null,2)}function countSize(tg,eg="MB"){const gg=new TextEncoder().encode(tg).length;return eg==="KB"?gg/1024:gg/(1024*1024)}class LabelEditor{constructor(eg,gg){UI(this,"_autoSaveTimer",null);UI(this,"_insertFileFieldJsonTimer",null);UI(this,"_pendingFileFieldJson",null);UI(this,"_fileFieldJsonLabelReadyHandler",null);UI(this,"_app",null);UI(this,"_el",null);UI(this,"_initialLang",null);UI(this,"_localeController");UI(this,"_releaseActiveI18n",null);UI(this,"_stopLocaleWatch",null);UI(this,"_destroyed",!1);UI(this,"_isReplaceFont",!1);UI(this,"_defaultBuiltinFontPromise",Promise.resolve(!1));UI(this,"_maxSize",0);UI(this,"_laserWarnInstance",null);const ig=gg||{},ng=!!ig.__offscreenRender;if(!ng&&_activeInstance&&!_activeInstance._destroyed&&_activeInstance._el===eg)return console.warn("[LabelEditor] 同一容器已有活跃实例,复用现有实例"),ig.messages&&_activeInstance.setMessages(ig.messages),reuseEditorWithLocale(_activeInstance,ig.locale);if(!ng&&_activeInstance&&!_activeInstance._destroyed&&(console.warn("[LabelEditor] 检测到其他容器上的活跃实例,先销毁旧实例"),_activeInstance.destroy()),gg!=null&&gg.maxSize&&(this._maxSize=gg==null?void 0:gg.maxSize),gg&&!ng){const Cg={...gg};delete Cg.__offscreenRender,delete Cg.locale,delete Cg.messages,Cg.separateLayerMode=Cg.separateLayerMode===!0,Object.keys(Cg).length&&setEditorConfig(Cg),this.setSeparateLayerMode(!!getEditorConfig().separateLayerMode),getEditorConfig().separateLayerMode?this.setLayerMaxCount(getEditorConfig().separateLayerCount):this.setLayerMaxCount(Cg.layerMaxCount??1)}resetFontState(),this._defaultBuiltinFontPromise=loadDefaultBuiltinFont();const og=ng?LabelEditor._pauseVueDevtoolsForOffscreenRender():()=>{},ag=createApp(_sfc_main),sg=createEditorI18n(ig.locale,ig.messages),{i18n:Ig}=sg;this._localeController=sg,this._initialLang=eg.getAttribute("lang"),ng&&(ag.config.devtools=!1),ag.config.errorHandler=(Cg,lg,Ag)=>{console.error("全局错误:",Cg,lg,Ag)};try{const Cg=createPiniaInstance();this._stopLocaleWatch=mountEditorApplication(ag,eg,sg,()=>{ag.use(Ig),ag.use(Cg).use(index,{}).use(modalInstall).use(loadingInstall)})}finally{og()}this._app=ag,this._el=eg,ng||(this._releaseActiveI18n=activateEditorI18n(sg),_activeInstance=this)}static _pauseVueDevtoolsForOffscreenRender(){const eg=window,gg="__VUE_DEVTOOLS_GLOBAL_HOOK__",ig=Object.prototype.hasOwnProperty.call(eg,gg),ng=eg[gg];if(!ng)return()=>{};try{return eg[gg]=void 0,()=>{ig?eg[gg]=ng:delete eg[gg]}}catch{const og=ng.enabled;return ng.enabled=!1,()=>{ng.enabled=og}}}static async loadJsonToImageBase64(eg,gg={}){return LabelEditor.exportImage({...gg,data:eg})}static async exportImage(eg){const{data:gg,...ig}=eg;return loadJsonToImageBase64(gg,ig)}get loadedFonts(){return loadedFonts}ready(){return this._defaultBuiltinFontPromise}loadBuiltinFont(eg){return loadBuiltinFont(eg)}loadBuiltinFonts(eg){return loadBuiltinFonts(eg)}loadAllDefaultFonts(){return loadBuiltinFonts(fontListDefault.map(({value:eg})=>eg))}setLocale(eg){return this._localeController.setLocale(eg)}getLocale(){return this._localeController.locale.value}destroy(){var eg,gg,ig;if(!this._destroyed){if(this._destroyed=!0,_laserWarnShown=!1,clearInterval(this._autoSaveTimer),this._autoSaveTimer=null,clearTimeout(this._insertFileFieldJsonTimer),this._insertFileFieldJsonTimer=null,this._pendingFileFieldJson=null,this._fileFieldJsonLabelReadyHandler&&(emitter.off("label-ready",this._fileFieldJsonLabelReadyHandler),this._fileFieldJsonLabelReadyHandler=null),(eg=this._stopLocaleWatch)==null||eg.call(this),this._stopLocaleWatch=null,(gg=this._releaseActiveI18n)==null||gg.call(this),this._releaseActiveI18n=null,this._app&&(this._app.unmount(),this._app=null),this._laserWarnInstance){try{this._laserWarnInstance.destroy()}catch{}this._laserWarnInstance=null}try{setActivePinia(this._pinia);const ng=useTabsStore();(ig=ng.$reset)==null||ig.call(ng)}catch{}try{getActivePinia()===this._pinia&&setActivePinia(null)}catch{}this._pinia=null,resetDatabaseRuntimeState(),emitter.all.clear(),canvasEventBus.all.clear();try{resetFontState()}catch{}try{resetAllModuleState()}catch{}this._el&&(this._initialLang==null?this._el.removeAttribute("lang"):this._el.setAttribute("lang",this._initialLang),this._el.innerHTML="",this._el=null),this._initialLang=null,_activeInstance===this&&(_activeInstance=null)}}filterLoadFontByName(eg){let gg=Array.from(this.loadedFonts);return eg.filter(ng=>{let og=!gg.includes(ng);if(!this._isReplaceFont){for(let ag of fontListDefault)if(ag.value===ng&&ag.value==="Source Han Sans SC"){og=!1;break}}return og})}loadJson(eg,{newFile:gg=!1}={}){let ng=typeof eg=="string"?JSON.parse(eg):eg;const og=new Set(extractFontNames(ng.canvas));if(Array.isArray(ng.layers)&&ng.layers.forEach(Ig=>{Ig!=null&&Ig.canvas&&extractFontNames(Ig.canvas).forEach(Cg=>og.add(Cg))}),og.size){let Ig=Array.from(og);emitter.emit("selectFontCallback",Ig)}gg?resetLaserPresetsFromExternal():ng.laserConfigList&&Array.isArray(ng.laserConfigList)?setLaserPresets(ng.laserConfigList):resetLaserPresetsFromExternal();const ag=ng.labelConfig||getTempLabelConfig();ag.layerStyleIndependent==null&&(ag.layerStyleIndependent=getEditorConfig().layerStyleIndependent),emitter.emit("label-config",{labelConfig:ag,canvas:ng.canvas,layers:ng.layers,activeLayerId:ng.activeLayerId,newFile:gg});const sg=syncExternalPresets();this.notifyLaserSyncWarning(sg,ng)}notifyLaserSyncWarning(eg,gg){const ig=[];eg.deletedNames.length>0&&ig.push(translate("editor.specialist.laser.deletedWarning",{deletedNames:eg.deletedNames.join('"、"')}));const ng=getLaserMaxPresets(),og=this.countUsedLaserPresets(gg);if(ng>0&&og>ng&&ig.push(translate("editor.specialist.laser.limitWarning",{maxPresets:ng,usedCount:og})),ig.length===0)return;const ag=ig.join(`
|
|
960
960
|
`);_laserWarnShown||(_laserWarnShown=!0,setTimeout(()=>{this._destroyed||(this._laserWarnInstance=Modal$1.warning({title:translate("editor.specialist.laser.title"),content:ag,okText:translate("common.actions.confirm"),centered:!0}))},0))}countUsedLaserPresets(eg){if(!eg)return 0;const gg=new Set,ig=ng=>{try{const og=JSON.parse(ng);collectLaserConfigIds(og.objects).forEach(ag=>gg.add(ag))}catch{}};return typeof eg.canvas=="string"?ig(eg.canvas):Array.isArray(eg.canvas)&&eg.canvas.forEach(ng=>ig(ng)),gg.size}exportJson(eg="checkFile"){return new Promise((gg,ig)=>{emitter.emit("toTemplateJson",ng=>{try{const og=JSON.parse(ng||"{}"),ag=extractFontNames(og.canvas),sg=getCustomFonts(ag);sg.length&&(og.labelConfig.customFonts=sg);const Ig=new Set,Cg=rg=>{try{const cg=JSON.parse(rg);collectLaserConfigIds(cg.objects).forEach(ug=>Ig.add(ug))}catch{}};typeof og.canvas=="string"?Cg(og.canvas):Array.isArray(og.canvas)&&og.canvas.forEach(rg=>Cg(rg));const lg=getLaserPresets();lg.value.length>0&&(og.laserConfigList=lg.value.filter(rg=>Ig.has(rg.configId)),og.laserConfigList.length===0&&delete og.laserConfigList);let Ag=JSON.stringify(og);if(eg==="checkFile"&&this._maxSize&&countSize(Ag)>this._maxSize){ig(`画布大于${this._maxSize}MB, 不能保存`);return}gg(Ag)}catch(og){ig(og)}})})}async getFileJsonSize(){let eg=await this.exportJson("noCheck"),gg=countSize(eg,"KB");return gg=Number(gg.toFixed(2)),gg}addCustomFontList(eg){emitter.emit("addCustomFontList",eg)}replaceFontList(eg){this._isReplaceFont=!0,emitter.emit("replaceFontList",eg)}setLaserConfigList(eg){getLaserPresets().value.length===0&&setLaserPresets(eg);const gg=setLaserConfigList(eg);gg&&this.notifyLaserSyncWarning(gg)}selectFontCallback(eg){emitter.off("selectFontCallback"),emitter.on("selectFontCallback",gg=>{let ig=this.filterLoadFontByName(gg)||[];eg&&ig.length&&eg(ig)})}async loadFontFile(eg){const{fontName:gg,blob:ig}=eg;return!gg||!ig?!1:loadFontFromBlob(gg,ig)}exportImage(eg={}){return new Promise(gg=>{emitter.emit("exportImage",{options:eg,callback:ig=>{gg(ig)}})})}toggleMultiLayer(eg=!0){state$1.isMultiLayerEnabled=!!eg}setMultiLayerEnabled(eg=!0){this.toggleMultiLayer(eg)}setMessages(eg){this._localeController.setMessages(eg)}async setLayerStyleIndependent(eg=!0){const gg=async()=>{var ag;const ig=useTabsStore(),ng=(ag=ig.getActiveTab)==null?void 0:ag.call(ig);if(!(ng!=null&&ng.config))return!1;applyLayerStyleIndependent(ng,eg),ig.storeTabs(ig.tabs),setFileDirty(ng.id);const og=emitter.all.get("layer-style-independent-change");return og!=null&&og.length&&await new Promise(sg=>{let Ig=!1;const Cg=()=>{Ig||(Ig=!0,sg())};emitter.emit("layer-style-independent-change",{done:Cg})}),!0};if(!await gg())return new Promise(ig=>{const ng=setTimeout(()=>{emitter.off("label-ready",og),gg(),ig()},3e3),og=()=>{clearTimeout(ng),emitter.off("label-ready",og),gg().finally(ig)};emitter.on("label-ready",og)})}setLayerMaxCount(eg=1){setSysConfigState({...getSysConfigState(),layerMaxCount:state$1.isSeparateLayerMode?state$1.separateLayerCount:getLayerMaxCount(eg)})}_applyFileFieldJson(eg){const gg=useTabsStore(),ig=gg.getActiveTab();if(!(ig!=null&&ig.config))return!1;const ng=ig.config.fileFieldJson||"",og=this._computeFileFieldJsonDiff(ng,eg);return ig.config.fileFieldJson=eg,gg.storeTabs(gg.tabs),setFileDirty(ig.id),og&&emitter.emit("file-field-json-changed",og),!0}_computeFileFieldJsonDiff(eg,gg){if(!eg&&!gg)return null;let ig={},ng={};try{ig=JSON.parse(eg||"{}")}catch{}try{ng=JSON.parse(gg||"{}")}catch{}(typeof ig!="object"||ig===null||Array.isArray(ig))&&(ig={}),(typeof ng!="object"||ng===null||Array.isArray(ng))&&(ng={});const og={renamed:[],removed:[],added:[],valueChanged:[]},ag=Object.keys(ig),sg=Object.keys(ng),Ig=new Set(ag),Cg=new Set(sg);for(const lg of ag)Cg.has(lg)?String(ig[lg])!==String(ng[lg])&&og.valueChanged.push({key:lg,oldValue:String(ig[lg]??""),newValue:String(ng[lg]??"")}):og.removed.push(lg);for(const lg of sg)Ig.has(lg)||og.added.push(lg);return!og.renamed.length&&!og.removed.length&&!og.added.length&&!og.valueChanged.length?null:og}insertFileFieldJson(eg){try{const gg=normalizeFileFieldJson(eg);if(!gg)return!1;if(this._applyFileFieldJson(gg))return!0;this._cleanupFileFieldJsonPending(),this._pendingFileFieldJson=gg;const ig=()=>{this._destroyed||this._applyFileFieldJson(gg)&&this._cleanupFileFieldJsonPending()};return this._fileFieldJsonLabelReadyHandler=ig,emitter.on("label-ready",ig),this._insertFileFieldJsonTimer=setTimeout(()=>{this._destroyed||(this._applyFileFieldJson(gg),this._cleanupFileFieldJsonPending())},3e3),!0}catch(gg){return console.error("[LabelEditor] insertFileFieldJson failed:",gg),!1}}_cleanupFileFieldJsonPending(){this._fileFieldJsonLabelReadyHandler&&(emitter.off("label-ready",this._fileFieldJsonLabelReadyHandler),this._fileFieldJsonLabelReadyHandler=null),clearTimeout(this._insertFileFieldJsonTimer),this._insertFileFieldJsonTimer=null,this._pendingFileFieldJson=null}setSeparateLayerMode(eg=!0){state$1.isSeparateLayerMode=!!eg,state$1.isSeparateLayerMode&&(state$1.isMultiLayerEnabled=!0,state$1.separateLayerCount=getEditorConfig().separateLayerCount,state$1.separateLayerNames=[...getEditorConfig().separateLayerNames],this.setLayerMaxCount(state$1.separateLayerCount))}setShowRibbonPattern(eg=!0){setEditorConfig({showRibbonPattern:!!eg})}async getThumbnailImage(eg={}){const ig=useTabsStore().getActiveTab();if(!(ig!=null&&ig.config))return"";let og=ig==null?void 0:ig.config,ag="";og.separateLayerMode?ag=await this.getDoubleRibbonsImage(eg):ag=await this.getImage(eg);let sg=document.createElement("canvas"),Ig=sg.getContext("2d"),Cg=og.pageWidth,Ag=og.pageHeight/Cg,rg=300,cg=rg*Ag;sg.width=rg,sg.height=cg;let ug=await this.loadImage(ag);return Ig==null||Ig.drawImage(ug,0,0,rg,cg),sg.toDataURL()}loadImage(eg){return new Promise((gg,ig)=>{const ng=new Image;ng.onload=()=>gg(ng),ng.onerror=ig,ng.src=eg,ng.complete&&gg(ng)})}getImage(eg={}){return this.exportImage(eg)}getDoubleRibbonsImage(eg={}){return new Promise(gg=>{this.exportImage({...eg,mode:"separate",layout:"doubleRibbons"}).then(ig=>{gg((ig==null?void 0:ig.composedImage)||ig)})})}enterDoubleRibbons(){state$1.isSeparateLayerMode=!0,state$1.isMultiLayerEnabled=!0,state$1.separateLayerCount=2,state$1.separateLayerNames=[this._localeController.translate("editor.remaining.upperLayer"),this._localeController.translate("editor.remaining.lowerLayer")],this.setLayerMaxCount(state$1.separateLayerCount),emitter.emit("separate-layer-config-change",{count:state$1.separateLayerCount,names:[...state$1.separateLayerNames]})}setSeparateLayerConfig(eg={}){eg.count!=null&&(state$1.separateLayerCount=getLayerMaxCount(eg.count)),eg.names!=null&&(state$1.separateLayerNames=Array.isArray(eg.names)?eg.names.map(gg=>String(gg||"").trim()).filter(Boolean):[]),state$1.isSeparateLayerMode&&(this.setLayerMaxCount(state$1.separateLayerCount),emitter.emit("separate-layer-config-change",{count:state$1.separateLayerCount,names:[...state$1.separateLayerNames]}))}toggleEditTabs(eg=!0){state$1.isShowEditTabs=!!eg}checkFileSave(){return new Promise(eg=>{emitter.emit("checkFileSave",gg=>{eg(gg)})})}openAutoSave(eg,gg=5e3){clearInterval(this._autoSaveTimer),this._autoSaveTimer=setInterval(async()=>{if(!await this.checkFileSave()){let ng=await this.exportJson();eg&&eg(ng)}},gg)}}function commonjsRequire(tg){throw new Error('Could not dynamically require "'+tg+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pdf$2={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$5=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredPdf;function requirePdf(){return hasRequiredPdf||(hasRequiredPdf=1,(function(module,exports){(function(eg,gg){module.exports=eg.pdfjsLib=gg()})(globalThis,()=>(()=>{var __webpack_modules__=[,((tg,eg)=>{var sI;Object.defineProperty(eg,"__esModule",{value:!0}),eg.VerbosityLevel=eg.Util=eg.UnknownErrorException=eg.UnexpectedResponseException=eg.TextRenderingMode=eg.RenderingIntentFlag=eg.PromiseCapability=eg.PermissionFlag=eg.PasswordResponses=eg.PasswordException=eg.PageActionEventType=eg.OPS=eg.MissingPDFException=eg.MAX_IMAGE_SIZE_TO_CACHE=eg.LINE_FACTOR=eg.LINE_DESCENT_FACTOR=eg.InvalidPDFException=eg.ImageKind=eg.IDENTITY_MATRIX=eg.FormatError=eg.FeatureTest=eg.FONT_IDENTITY_MATRIX=eg.DocumentActionEventType=eg.CMapCompressionType=eg.BaseException=eg.BASELINE_FACTOR=eg.AnnotationType=eg.AnnotationReplyType=eg.AnnotationPrefix=eg.AnnotationMode=eg.AnnotationFlag=eg.AnnotationFieldFlag=eg.AnnotationEditorType=eg.AnnotationEditorPrefix=eg.AnnotationEditorParamsType=eg.AnnotationBorderStyleType=eg.AnnotationActionEventType=eg.AbortException=void 0,eg.assert=kg,eg.bytesToString=pa,eg.createValidAbsoluteUrl=Kg,eg.getModificationDate=tI,eg.getUuid=xa,eg.getVerbosityLevel=Vg,eg.info=Xg,eg.isArrayBuffer=uo,eg.isArrayEqual=ha,eg.isNodeJS=void 0,eg.normalizeUnicode=qg,eg.objectFromMap=ma,eg.objectSize=la,eg.setVerbosityLevel=Sg,eg.shadow=jg,eg.string32=Pg,eg.stringToBytes=is,eg.stringToPDFString=ya,eg.stringToUTF8String=eI,eg.unreachable=Hg,eg.utf8StringToString=us,eg.warn=Yg;const gg=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser");eg.isNodeJS=gg;const ig=[1,0,0,1,0,0];eg.IDENTITY_MATRIX=ig;const ng=[.001,0,0,.001,0,0];eg.FONT_IDENTITY_MATRIX=ng;const og=1e7;eg.MAX_IMAGE_SIZE_TO_CACHE=og;const ag=1.35;eg.LINE_FACTOR=ag;const sg=.35;eg.LINE_DESCENT_FACTOR=sg;const Ig=sg/ag;eg.BASELINE_FACTOR=Ig;const Cg={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};eg.RenderingIntentFlag=Cg;const lg={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};eg.AnnotationMode=lg;const Ag="pdfjs_internal_editor_";eg.AnnotationEditorPrefix=Ag;const rg={DISABLE:-1,NONE:0,FREETEXT:3,STAMP:13,INK:15};eg.AnnotationEditorType=rg;const cg={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23};eg.AnnotationEditorParamsType=cg;const ug={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};eg.PermissionFlag=ug;const dg={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};eg.TextRenderingMode=dg;const hg={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};eg.ImageKind=hg;const mg={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};eg.AnnotationType=mg;const bg={GROUP:"Group",REPLY:"R"};eg.AnnotationReplyType=bg;const pg={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};eg.AnnotationFlag=pg;const fg={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};eg.AnnotationFieldFlag=fg;const wg={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};eg.AnnotationBorderStyleType=wg;const Gg={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};eg.AnnotationActionEventType=Gg;const Zg={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};eg.DocumentActionEventType=Zg;const $g={O:"PageOpen",C:"PageClose"};eg.PageActionEventType=$g;const Bg={ERRORS:0,WARNINGS:1,INFOS:5};eg.VerbosityLevel=Bg;const Wg={NONE:0,BINARY:1};eg.CMapCompressionType=Wg;const yg={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};eg.OPS=yg;const Ng={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};eg.PasswordResponses=Ng;let vg=Bg.WARNINGS;function Sg(fa){Number.isInteger(fa)&&(vg=fa)}function Vg(){return vg}function Xg(fa){vg>=Bg.INFOS&&console.log(`Info: ${fa}`)}function Yg(fa){vg>=Bg.WARNINGS&&console.log(`Warning: ${fa}`)}function Hg(fa){throw new Error(fa)}function kg(fa,Lg){fa||Hg(Lg)}function Rg(fa){switch(fa==null?void 0:fa.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Kg(fa,Lg=null,Fg=null){if(!fa)return null;try{if(Fg&&typeof fa=="string"){if(Fg.addDefaultProtocol&&fa.startsWith("www.")){const cs=fa.match(/\./g);(cs==null?void 0:cs.length)>=2&&(fa=`http://${fa}`)}if(Fg.tryConvertEncoding)try{fa=eI(fa)}catch{}}const sa=Lg?new URL(fa,Lg):new URL(fa);if(Rg(sa))return sa}catch{}return null}function jg(fa,Lg,Fg,sa=!1){return Object.defineProperty(fa,Lg,{value:Fg,enumerable:!sa,configurable:!0,writable:!1}),Fg}const Dg=(function(){function Lg(Fg,sa){this.constructor===Lg&&Hg("Cannot initialize BaseException."),this.message=Fg,this.name=sa}return Lg.prototype=new Error,Lg.constructor=Lg,Lg})();eg.BaseException=Dg;class zg extends Dg{constructor(Lg,Fg){super(Lg,"PasswordException"),this.code=Fg}}eg.PasswordException=zg;class Og extends Dg{constructor(Lg,Fg){super(Lg,"UnknownErrorException"),this.details=Fg}}eg.UnknownErrorException=Og;class Jg extends Dg{constructor(Lg){super(Lg,"InvalidPDFException")}}eg.InvalidPDFException=Jg;class Qg extends Dg{constructor(Lg){super(Lg,"MissingPDFException")}}eg.MissingPDFException=Qg;class eo extends Dg{constructor(Lg,Fg){super(Lg,"UnexpectedResponseException"),this.status=Fg}}eg.UnexpectedResponseException=eo;class ca extends Dg{constructor(Lg){super(Lg,"FormatError")}}eg.FormatError=ca;class ua extends Dg{constructor(Lg){super(Lg,"AbortException")}}eg.AbortException=ua;function pa(fa){(typeof fa!="object"||(fa==null?void 0:fa.length)===void 0)&&Hg("Invalid argument for bytesToString");const Lg=fa.length,Fg=8192;if(Lg<Fg)return String.fromCharCode.apply(null,fa);const sa=[];for(let cs=0;cs<Lg;cs+=Fg){const xg=Math.min(cs+Fg,Lg),lo=fa.subarray(cs,xg);sa.push(String.fromCharCode.apply(null,lo))}return sa.join("")}function is(fa){typeof fa!="string"&&Hg("Invalid argument for stringToBytes");const Lg=fa.length,Fg=new Uint8Array(Lg);for(let sa=0;sa<Lg;++sa)Fg[sa]=fa.charCodeAt(sa)&255;return Fg}function Pg(fa){return String.fromCharCode(fa>>24&255,fa>>16&255,fa>>8&255,fa&255)}function la(fa){return Object.keys(fa).length}function ma(fa){const Lg=Object.create(null);for(const[Fg,sa]of fa)Lg[Fg]=sa;return Lg}function Ca(){const fa=new Uint8Array(4);return fa[0]=1,new Uint32Array(fa.buffer,0,1)[0]===1}function Eg(){try{return new Function(""),!0}catch{return!1}}class Mg{static get isLittleEndian(){return jg(this,"isLittleEndian",Ca())}static get isEvalSupported(){return jg(this,"isEvalSupported",Eg())}static get isOffscreenCanvasSupported(){return jg(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator>"u"?jg(this,"platform",{isWin:!1,isMac:!1}):jg(this,"platform",{isWin:navigator.platform.includes("Win"),isMac:navigator.platform.includes("Mac")})}static get isCSSRoundSupported(){var Lg,Fg;return jg(this,"isCSSRoundSupported",(Fg=(Lg=globalThis.CSS)==null?void 0:Lg.supports)==null?void 0:Fg.call(Lg,"width: round(1.5px, 1px)"))}}eg.FeatureTest=Mg;const Tg=[...Array(256).keys()].map(fa=>fa.toString(16).padStart(2,"0"));class Ug{static makeHexColor(Lg,Fg,sa){return`#${Tg[Lg]}${Tg[Fg]}${Tg[sa]}`}static scaleMinMax(Lg,Fg){let sa;Lg[0]?(Lg[0]<0&&(sa=Fg[0],Fg[0]=Fg[1],Fg[1]=sa),Fg[0]*=Lg[0],Fg[1]*=Lg[0],Lg[3]<0&&(sa=Fg[2],Fg[2]=Fg[3],Fg[3]=sa),Fg[2]*=Lg[3],Fg[3]*=Lg[3]):(sa=Fg[0],Fg[0]=Fg[2],Fg[2]=sa,sa=Fg[1],Fg[1]=Fg[3],Fg[3]=sa,Lg[1]<0&&(sa=Fg[2],Fg[2]=Fg[3],Fg[3]=sa),Fg[2]*=Lg[1],Fg[3]*=Lg[1],Lg[2]<0&&(sa=Fg[0],Fg[0]=Fg[1],Fg[1]=sa),Fg[0]*=Lg[2],Fg[1]*=Lg[2]),Fg[0]+=Lg[4],Fg[1]+=Lg[4],Fg[2]+=Lg[5],Fg[3]+=Lg[5]}static transform(Lg,Fg){return[Lg[0]*Fg[0]+Lg[2]*Fg[1],Lg[1]*Fg[0]+Lg[3]*Fg[1],Lg[0]*Fg[2]+Lg[2]*Fg[3],Lg[1]*Fg[2]+Lg[3]*Fg[3],Lg[0]*Fg[4]+Lg[2]*Fg[5]+Lg[4],Lg[1]*Fg[4]+Lg[3]*Fg[5]+Lg[5]]}static applyTransform(Lg,Fg){const sa=Lg[0]*Fg[0]+Lg[1]*Fg[2]+Fg[4],cs=Lg[0]*Fg[1]+Lg[1]*Fg[3]+Fg[5];return[sa,cs]}static applyInverseTransform(Lg,Fg){const sa=Fg[0]*Fg[3]-Fg[1]*Fg[2],cs=(Lg[0]*Fg[3]-Lg[1]*Fg[2]+Fg[2]*Fg[5]-Fg[4]*Fg[3])/sa,xg=(-Lg[0]*Fg[1]+Lg[1]*Fg[0]+Fg[4]*Fg[1]-Fg[5]*Fg[0])/sa;return[cs,xg]}static getAxialAlignedBoundingBox(Lg,Fg){const sa=this.applyTransform(Lg,Fg),cs=this.applyTransform(Lg.slice(2,4),Fg),xg=this.applyTransform([Lg[0],Lg[3]],Fg),lo=this.applyTransform([Lg[2],Lg[1]],Fg);return[Math.min(sa[0],cs[0],xg[0],lo[0]),Math.min(sa[1],cs[1],xg[1],lo[1]),Math.max(sa[0],cs[0],xg[0],lo[0]),Math.max(sa[1],cs[1],xg[1],lo[1])]}static inverseTransform(Lg){const Fg=Lg[0]*Lg[3]-Lg[1]*Lg[2];return[Lg[3]/Fg,-Lg[1]/Fg,-Lg[2]/Fg,Lg[0]/Fg,(Lg[2]*Lg[5]-Lg[4]*Lg[3])/Fg,(Lg[4]*Lg[1]-Lg[5]*Lg[0])/Fg]}static singularValueDecompose2dScale(Lg){const Fg=[Lg[0],Lg[2],Lg[1],Lg[3]],sa=Lg[0]*Fg[0]+Lg[1]*Fg[2],cs=Lg[0]*Fg[1]+Lg[1]*Fg[3],xg=Lg[2]*Fg[0]+Lg[3]*Fg[2],lo=Lg[2]*Fg[1]+Lg[3]*Fg[3],oa=(sa+lo)/2,no=Math.sqrt((sa+lo)**2-4*(sa*lo-xg*cs))/2,co=oa+no||1,va=oa-no||1;return[Math.sqrt(co),Math.sqrt(va)]}static normalizeRect(Lg){const Fg=Lg.slice(0);return Lg[0]>Lg[2]&&(Fg[0]=Lg[2],Fg[2]=Lg[0]),Lg[1]>Lg[3]&&(Fg[1]=Lg[3],Fg[3]=Lg[1]),Fg}static intersect(Lg,Fg){const sa=Math.max(Math.min(Lg[0],Lg[2]),Math.min(Fg[0],Fg[2])),cs=Math.min(Math.max(Lg[0],Lg[2]),Math.max(Fg[0],Fg[2]));if(sa>cs)return null;const xg=Math.max(Math.min(Lg[1],Lg[3]),Math.min(Fg[1],Fg[3])),lo=Math.min(Math.max(Lg[1],Lg[3]),Math.max(Fg[1],Fg[3]));return xg>lo?null:[sa,xg,cs,lo]}static bezierBoundingBox(Lg,Fg,sa,cs,xg,lo,oa,no){const co=[],va=[[],[]];let nI,ga,_g,La,aI,hs,oI,II;for(let GI=0;GI<2;++GI){if(GI===0?(ga=6*Lg-12*sa+6*xg,nI=-3*Lg+9*sa-9*xg+3*oa,_g=3*sa-3*Lg):(ga=6*Fg-12*cs+6*lo,nI=-3*Fg+9*cs-9*lo+3*no,_g=3*cs-3*Fg),Math.abs(nI)<1e-12){if(Math.abs(ga)<1e-12)continue;La=-_g/ga,0<La&&La<1&&co.push(La);continue}oI=ga*ga-4*_g*nI,II=Math.sqrt(oI),!(oI<0)&&(aI=(-ga+II)/(2*nI),0<aI&&aI<1&&co.push(aI),hs=(-ga-II)/(2*nI),0<hs&&hs<1&&co.push(hs))}let cI=co.length,dI;const uI=cI;for(;cI--;)La=co[cI],dI=1-La,va[0][cI]=dI*dI*dI*Lg+3*dI*dI*La*sa+3*dI*La*La*xg+La*La*La*oa,va[1][cI]=dI*dI*dI*Fg+3*dI*dI*La*cs+3*dI*La*La*lo+La*La*La*no;return va[0][uI]=Lg,va[1][uI]=Fg,va[0][uI+1]=oa,va[1][uI+1]=no,va[0].length=va[1].length=uI+2,[Math.min(...va[0]),Math.min(...va[1]),Math.max(...va[0]),Math.max(...va[1])]}}eg.Util=Ug;const da=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function ya(fa){if(fa[0]>="ï"){let Fg;if(fa[0]==="þ"&&fa[1]==="ÿ"?Fg="utf-16be":fa[0]==="ÿ"&&fa[1]==="þ"?Fg="utf-16le":fa[0]==="ï"&&fa[1]==="»"&&fa[2]==="¿"&&(Fg="utf-8"),Fg)try{const sa=new TextDecoder(Fg,{fatal:!0}),cs=is(fa);return sa.decode(cs)}catch(sa){Yg(`stringToPDFString: "${sa}".`)}}const Lg=[];for(let Fg=0,sa=fa.length;Fg<sa;Fg++){const cs=da[fa.charCodeAt(Fg)];Lg.push(cs?String.fromCharCode(cs):fa.charAt(Fg))}return Lg.join("")}function eI(fa){return decodeURIComponent(escape(fa))}function us(fa){return unescape(encodeURIComponent(fa))}function uo(fa){return typeof fa=="object"&&(fa==null?void 0:fa.byteLength)!==void 0}function ha(fa,Lg){if(fa.length!==Lg.length)return!1;for(let Fg=0,sa=fa.length;Fg<sa;Fg++)if(fa[Fg]!==Lg[Fg])return!1;return!0}function tI(fa=new Date){return[fa.getUTCFullYear().toString(),(fa.getUTCMonth()+1).toString().padStart(2,"0"),fa.getUTCDate().toString().padStart(2,"0"),fa.getUTCHours().toString().padStart(2,"0"),fa.getUTCMinutes().toString().padStart(2,"0"),fa.getUTCSeconds().toString().padStart(2,"0")].join("")}class AI{constructor(){ZI(this,sI,!1);this.promise=new Promise((Lg,Fg)=>{this.resolve=sa=>{fI(this,sI,!0),Lg(sa)},this.reject=sa=>{fI(this,sI,!0),Fg(sa)}})}get settled(){return aa(this,sI)}}sI=new WeakMap,eg.PromiseCapability=AI;let rI=null,gI=null;function qg(fa){return rI||(rI=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,gI=new Map([["ſt","ſt"]])),fa.replaceAll(rI,(Lg,Fg,sa)=>Fg?Fg.normalize("NFKC"):gI.get(sa))}function xa(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const fa=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(fa);else for(let Lg=0;Lg<32;Lg++)fa[Lg]=Math.floor(Math.random()*255);return pa(fa)}const iI="pdfjs_internal_id_";eg.AnnotationPrefix=iI}),((__unused_webpack_module,exports,__w_pdfjs_require__)=>{var tg,gg,ig,ng,Id,Jd,sg,Ig,Cg,lg,Ag,rg,cg,ug,dg,Ed,mg,bg,r0,fg,wg;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,Object.defineProperty(exports,"SVGGraphics",{enumerable:!0,get:function(){return _displaySvg.SVGGraphics}}),exports.build=void 0,exports.getDocument=getDocument,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_displayNode_utils=__w_pdfjs_require__(10),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_displayFetch_stream=__w_pdfjs_require__(19),_displayNetwork=__w_pdfjs_require__(22),_displayNode_stream=__w_pdfjs_require__(23),_displaySvg=__w_pdfjs_require__(24),_xfa_text=__w_pdfjs_require__(25);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_util.isNodeJS?_displayNode_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_util.isNodeJS?_displayNode_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultFilterFactory=_util.isNodeJS?_displayNode_utils.NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;const DefaultStandardFontDataFactory=_util.isNodeJS?_displayNode_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;function getDocument(Zg){if(typeof Zg=="string"||Zg instanceof URL?Zg={url:Zg}:(0,_util.isArrayBuffer)(Zg)&&(Zg={data:Zg}),typeof Zg!="object")throw new Error("Invalid parameter in getDocument, need parameter object.");if(!Zg.url&&!Zg.data&&!Zg.range)throw new Error("Invalid parameter object: need either .data, .range or .url");const $g=new PDFDocumentLoadingTask,{docId:Bg}=$g,Wg=Zg.url?getUrlProp(Zg.url):null,yg=Zg.data?getDataProp(Zg.data):null,Ng=Zg.httpHeaders||null,vg=Zg.withCredentials===!0,Sg=Zg.password??null,Vg=Zg.range instanceof PDFDataRangeTransport?Zg.range:null,Xg=Number.isInteger(Zg.rangeChunkSize)&&Zg.rangeChunkSize>0?Zg.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE;let Yg=Zg.worker instanceof PDFWorker?Zg.worker:null;const Hg=Zg.verbosity,kg=typeof Zg.docBaseUrl=="string"&&!(0,_display_utils.isDataScheme)(Zg.docBaseUrl)?Zg.docBaseUrl:null,Rg=typeof Zg.cMapUrl=="string"?Zg.cMapUrl:null,Kg=Zg.cMapPacked!==!1,jg=Zg.CMapReaderFactory||DefaultCMapReaderFactory,Dg=typeof Zg.standardFontDataUrl=="string"?Zg.standardFontDataUrl:null,zg=Zg.StandardFontDataFactory||DefaultStandardFontDataFactory,Og=Zg.stopAtErrors!==!0,Jg=Number.isInteger(Zg.maxImageSize)&&Zg.maxImageSize>-1?Zg.maxImageSize:-1,Qg=Zg.isEvalSupported!==!1,eo=typeof Zg.isOffscreenCanvasSupported=="boolean"?Zg.isOffscreenCanvasSupported:!_util.isNodeJS,ca=Number.isInteger(Zg.canvasMaxAreaInBytes)?Zg.canvasMaxAreaInBytes:-1,ua=typeof Zg.disableFontFace=="boolean"?Zg.disableFontFace:_util.isNodeJS,pa=Zg.fontExtraProperties===!0,is=Zg.enableXfa===!0,Pg=Zg.ownerDocument||globalThis.document,la=Zg.disableRange===!0,ma=Zg.disableStream===!0,Ca=Zg.disableAutoFetch===!0,Eg=Zg.pdfBug===!0,Mg=Vg?Vg.length:Zg.length??NaN,Tg=typeof Zg.useSystemFonts=="boolean"?Zg.useSystemFonts:!_util.isNodeJS&&!ua,Ug=typeof Zg.useWorkerFetch=="boolean"?Zg.useWorkerFetch:jg===_display_utils.DOMCMapReaderFactory&&zg===_display_utils.DOMStandardFontDataFactory&&Rg&&Dg&&(0,_display_utils.isValidFetchUrl)(Rg,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(Dg,document.baseURI),da=Zg.canvasFactory||new DefaultCanvasFactory({ownerDocument:Pg}),ya=Zg.filterFactory||new DefaultFilterFactory({docId:Bg,ownerDocument:Pg}),eI=null;(0,_util.setVerbosityLevel)(Hg);const us={canvasFactory:da,filterFactory:ya};if(Ug||(us.cMapReaderFactory=new jg({baseUrl:Rg,isCompressed:Kg}),us.standardFontDataFactory=new zg({baseUrl:Dg})),!Yg){const tI={verbosity:Hg,port:_worker_options.GlobalWorkerOptions.workerPort};Yg=tI.port?PDFWorker.fromPort(tI):new PDFWorker(tI),$g._worker=Yg}const uo={docId:Bg,apiVersion:"3.11.174",data:yg,password:Sg,disableAutoFetch:Ca,rangeChunkSize:Xg,length:Mg,docBaseUrl:kg,enableXfa:is,evaluatorOptions:{maxImageSize:Jg,disableFontFace:ua,ignoreErrors:Og,isEvalSupported:Qg,isOffscreenCanvasSupported:eo,canvasMaxAreaInBytes:ca,fontExtraProperties:pa,useSystemFonts:Tg,cMapUrl:Ug?Rg:null,standardFontDataUrl:Ug?Dg:null}},ha={ignoreErrors:Og,isEvalSupported:Qg,disableFontFace:ua,fontExtraProperties:pa,enableXfa:is,ownerDocument:Pg,disableAutoFetch:Ca,pdfBug:Eg,styleElement:eI};return Yg.promise.then(function(){if($g.destroyed)throw new Error("Loading aborted");const tI=_fetchDocument(Yg,uo),AI=new Promise(function(rI){let gI;Vg?gI=new _transport_stream.PDFDataTransportStream({length:Mg,initialData:Vg.initialData,progressiveDone:Vg.progressiveDone,contentDispositionFilename:Vg.contentDispositionFilename,disableRange:la,disableStream:ma},Vg):yg||(gI=(xa=>_util.isNodeJS?new _displayNode_stream.PDFNodeStream(xa):(0,_display_utils.isValidFetchUrl)(xa.url)?new _displayFetch_stream.PDFFetchStream(xa):new _displayNetwork.PDFNetworkStream(xa))({url:Wg,length:Mg,httpHeaders:Ng,withCredentials:vg,rangeChunkSize:Xg,disableRange:la,disableStream:ma})),rI(gI)});return Promise.all([tI,AI]).then(function([rI,gI]){if($g.destroyed)throw new Error("Loading aborted");const qg=new _message_handler.MessageHandler(Bg,rI,Yg.port),xa=new WorkerTransport(qg,$g,gI,ha,us);$g._transport=xa,qg.send("Ready",null)})}).catch($g._capability.reject),$g}async function _fetchDocument(Zg,$g){if(Zg.destroyed)throw new Error("Worker was destroyed");const Bg=await Zg.messageHandler.sendWithPromise("GetDocRequest",$g,$g.data?[$g.data.buffer]:null);if(Zg.destroyed)throw new Error("Worker was destroyed");return Bg}function getUrlProp(Zg){if(Zg instanceof URL)return Zg.href;try{return new URL(Zg,window.location).href}catch{if(_util.isNodeJS&&typeof Zg=="string")return Zg}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(Zg){if(_util.isNodeJS&&typeof Buffer<"u"&&Zg instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(Zg instanceof Uint8Array&&Zg.byteLength===Zg.buffer.byteLength)return Zg;if(typeof Zg=="string")return(0,_util.stringToBytes)(Zg);if(typeof Zg=="object"&&!isNaN(Zg==null?void 0:Zg.length)||(0,_util.isArrayBuffer)(Zg))return new Uint8Array(Zg);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}const eg=class eg{constructor(){this._capability=new _util.PromiseCapability,this._transport=null,this._worker=null,this.docId=`d${Wd(eg,tg)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var $g,Bg,Wg;this.destroyed=!0;try{($g=this._worker)!=null&&$g.port&&(this._worker._pendingDestroy=!0),await((Bg=this._transport)==null?void 0:Bg.destroy())}catch(yg){throw(Wg=this._worker)!=null&&Wg.port&&delete this._worker._pendingDestroy,yg}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};tg=new WeakMap,ZI(eg,tg,0);let PDFDocumentLoadingTask=eg;exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor($g,Bg,Wg=!1,yg=null){this.length=$g,this.initialData=Bg,this.progressiveDone=Wg,this.contentDispositionFilename=yg,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=new _util.PromiseCapability}addRangeListener($g){this._rangeListeners.push($g)}addProgressListener($g){this._progressListeners.push($g)}addProgressiveReadListener($g){this._progressiveReadListeners.push($g)}addProgressiveDoneListener($g){this._progressiveDoneListeners.push($g)}onDataRange($g,Bg){for(const Wg of this._rangeListeners)Wg($g,Bg)}onDataProgress($g,Bg){this._readyCapability.promise.then(()=>{for(const Wg of this._progressListeners)Wg($g,Bg)})}onDataProgressiveRead($g){this._readyCapability.promise.then(()=>{for(const Bg of this._progressiveReadListeners)Bg($g)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const $g of this._progressiveDoneListeners)$g()})}transportReady(){this._readyCapability.resolve()}requestDataRange($g,Bg){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor($g,Bg){this._pdfInfo=$g,this._transport=Bg,Object.defineProperty(this,"getJavaScript",{value:()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getJavaScript`, please use `PDFDocumentProxy.getJSActions` instead."),this.getJSActions().then(Wg=>{if(!Wg)return Wg;const yg=[];for(const Ng in Wg)yg.push(...Wg[Ng]);return yg}))})}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage($g){return this._transport.getPage($g)}getPageIndex($g){return this._transport.getPageIndex($g)}getDestinations(){return this._transport.getDestinations()}getDestination($g){return this._transport.getDestination($g)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup($g=!1){return this._transport.startCleanup($g||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor($g,Bg,Wg,yg=!1){ZI(this,ng);ZI(this,gg,null);ZI(this,ig,!1);this._pageIndex=$g,this._pageInfo=Bg,this._transport=Wg,this._stats=yg?new _display_utils.StatTimer:null,this._pdfBug=yg,this.commonObjs=Wg.commonObjs,this.objs=new PDFObjects,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:$g,rotation:Bg=this.rotate,offsetX:Wg=0,offsetY:yg=0,dontFlip:Ng=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:$g,rotation:Bg,offsetX:Wg,offsetY:yg,dontFlip:Ng})}getAnnotations({intent:$g="display"}={}){const Bg=this._transport.getRenderingIntent($g);return this._transport.getAnnotations(this._pageIndex,Bg.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var $g;return(($g=this._transport._htmlForXfa)==null?void 0:$g.children[this._pageIndex])||null}render({canvasContext:$g,viewport:Bg,intent:Wg="display",annotationMode:yg=_util.AnnotationMode.ENABLE,transform:Ng=null,background:vg=null,optionalContentConfigPromise:Sg=null,annotationCanvasMap:Vg=null,pageColors:Xg=null,printAnnotationStorage:Yg=null}){var zg,Og;(zg=this._stats)==null||zg.time("Overall");const Hg=this._transport.getRenderingIntent(Wg,yg,Yg);fI(this,ig,!1),hI(this,ng,Jd).call(this),Sg||(Sg=this._transport.getOptionalContentConfig());let kg=this._intentStates.get(Hg.cacheKey);kg||(kg=Object.create(null),this._intentStates.set(Hg.cacheKey,kg)),kg.streamReaderCancelTimeout&&(clearTimeout(kg.streamReaderCancelTimeout),kg.streamReaderCancelTimeout=null);const Rg=!!(Hg.renderingIntent&_util.RenderingIntentFlag.PRINT);kg.displayReadyCapability||(kg.displayReadyCapability=new _util.PromiseCapability,kg.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(Og=this._stats)==null||Og.time("Page Request"),this._pumpOperatorList(Hg));const Kg=Jg=>{var Qg,eo;kg.renderTasks.delete(jg),(this._maybeCleanupAfterRender||Rg)&&fI(this,ig,!0),hI(this,ng,Id).call(this,!Rg),Jg?(jg.capability.reject(Jg),this._abortOperatorList({intentState:kg,reason:Jg instanceof Error?Jg:new Error(Jg)})):jg.capability.resolve(),(Qg=this._stats)==null||Qg.timeEnd("Rendering"),(eo=this._stats)==null||eo.timeEnd("Overall")},jg=new InternalRenderTask({callback:Kg,params:{canvasContext:$g,viewport:Bg,transform:Ng,background:vg},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:Vg,operatorList:kg.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!Rg,pdfBug:this._pdfBug,pageColors:Xg});(kg.renderTasks||(kg.renderTasks=new Set)).add(jg);const Dg=jg.task;return Promise.all([kg.displayReadyCapability.promise,Sg]).then(([Jg,Qg])=>{var eo;if(this.destroyed){Kg();return}(eo=this._stats)==null||eo.time("Rendering"),jg.initializeGraphics({transparency:Jg,optionalContentConfig:Qg}),jg.operatorListChanged()}).catch(Kg),Dg}getOperatorList({intent:$g="display",annotationMode:Bg=_util.AnnotationMode.ENABLE,printAnnotationStorage:Wg=null}={}){var Vg;function yg(){vg.operatorList.lastChunk&&(vg.opListReadCapability.resolve(vg.operatorList),vg.renderTasks.delete(Sg))}const Ng=this._transport.getRenderingIntent($g,Bg,Wg,!0);let vg=this._intentStates.get(Ng.cacheKey);vg||(vg=Object.create(null),this._intentStates.set(Ng.cacheKey,vg));let Sg;return vg.opListReadCapability||(Sg=Object.create(null),Sg.operatorListChanged=yg,vg.opListReadCapability=new _util.PromiseCapability,(vg.renderTasks||(vg.renderTasks=new Set)).add(Sg),vg.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(Vg=this._stats)==null||Vg.time("Page Request"),this._pumpOperatorList(Ng)),vg.opListReadCapability.promise}streamTextContent({includeMarkedContent:$g=!1,disableNormalization:Bg=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:$g===!0,disableNormalization:Bg===!0},{highWaterMark:100,size(yg){return yg.items.length}})}getTextContent($g={}){if(this._transport._htmlForXfa)return this.getXfa().then(Wg=>_xfa_text.XfaText.textContent(Wg));const Bg=this.streamTextContent($g);return new Promise(function(Wg,yg){function Ng(){vg.read().then(function({value:Vg,done:Xg}){if(Xg){Wg(Sg);return}Object.assign(Sg.styles,Vg.styles),Sg.items.push(...Vg.items),Ng()},yg)}const vg=Bg.getReader(),Sg={items:[],styles:Object.create(null)};Ng()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const $g=[];for(const Bg of this._intentStates.values())if(this._abortOperatorList({intentState:Bg,reason:new Error("Page was destroyed."),force:!0}),!Bg.opListReadCapability)for(const Wg of Bg.renderTasks)$g.push(Wg.completed),Wg.cancel();return this.objs.clear(),fI(this,ig,!1),hI(this,ng,Jd).call(this),Promise.all($g)}cleanup($g=!1){fI(this,ig,!0);const Bg=hI(this,ng,Id).call(this,!1);return $g&&Bg&&this._stats&&(this._stats=new _display_utils.StatTimer),Bg}_startRenderPage($g,Bg){var yg,Ng;const Wg=this._intentStates.get(Bg);Wg&&((yg=this._stats)==null||yg.timeEnd("Page Request"),(Ng=Wg.displayReadyCapability)==null||Ng.resolve($g))}_renderPageChunk($g,Bg){for(let Wg=0,yg=$g.length;Wg<yg;Wg++)Bg.operatorList.fnArray.push($g.fnArray[Wg]),Bg.operatorList.argsArray.push($g.argsArray[Wg]);Bg.operatorList.lastChunk=$g.lastChunk,Bg.operatorList.separateAnnots=$g.separateAnnots;for(const Wg of Bg.renderTasks)Wg.operatorListChanged();$g.lastChunk&&hI(this,ng,Id).call(this,!0)}_pumpOperatorList({renderingIntent:$g,cacheKey:Bg,annotationStorageSerializable:Wg}){const{map:yg,transfers:Ng}=Wg,Sg=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:$g,cacheKey:Bg,annotationStorage:yg},Ng).getReader(),Vg=this._intentStates.get(Bg);Vg.streamReader=Sg;const Xg=()=>{Sg.read().then(({value:Yg,done:Hg})=>{if(Hg){Vg.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(Yg,Vg),Xg())},Yg=>{if(Vg.streamReader=null,!this._transport.destroyed){if(Vg.operatorList){Vg.operatorList.lastChunk=!0;for(const Hg of Vg.renderTasks)Hg.operatorListChanged();hI(this,ng,Id).call(this,!0)}if(Vg.displayReadyCapability)Vg.displayReadyCapability.reject(Yg);else if(Vg.opListReadCapability)Vg.opListReadCapability.reject(Yg);else throw Yg}})};Xg()}_abortOperatorList({intentState:$g,reason:Bg,force:Wg=!1}){if($g.streamReader){if($g.streamReaderCancelTimeout&&(clearTimeout($g.streamReaderCancelTimeout),$g.streamReaderCancelTimeout=null),!Wg){if($g.renderTasks.size>0)return;if(Bg instanceof _display_utils.RenderingCancelledException){let yg=RENDERING_CANCELLED_TIMEOUT;Bg.extraDelay>0&&Bg.extraDelay<1e3&&(yg+=Bg.extraDelay),$g.streamReaderCancelTimeout=setTimeout(()=>{$g.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:$g,reason:Bg,force:!0})},yg);return}}if($g.streamReader.cancel(new _util.AbortException(Bg.message)).catch(()=>{}),$g.streamReader=null,!this._transport.destroyed){for(const[yg,Ng]of this._intentStates)if(Ng===$g){this._intentStates.delete(yg);break}this.cleanup()}}}get stats(){return this._stats}}gg=new WeakMap,ig=new WeakMap,ng=new WeakSet,Id=function($g=!1){if(hI(this,ng,Jd).call(this),!aa(this,ig)||this.destroyed)return!1;if($g)return fI(this,gg,setTimeout(()=>{fI(this,gg,null),hI(this,ng,Id).call(this,!1)},DELAYED_CLEANUP_TIMEOUT)),!1;for(const{renderTasks:Bg,operatorList:Wg}of this._intentStates.values())if(Bg.size>0||!Wg.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),fI(this,ig,!1),!0},Jd=function(){aa(this,gg)&&(clearTimeout(aa(this,gg)),fI(this,gg,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){ZI(this,sg,new Set);ZI(this,Ig,Promise.resolve())}postMessage($g,Bg){const Wg={data:structuredClone($g,Bg?{transfer:Bg}:null)};aa(this,Ig).then(()=>{for(const yg of aa(this,sg))yg.call(this,Wg)})}addEventListener($g,Bg){aa(this,sg).add(Bg)}removeEventListener($g,Bg){aa(this,sg).delete(Bg)}terminate(){aa(this,sg).clear()}}sg=new WeakMap,Ig=new WeakMap,exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;{if(_util.isNodeJS&&typeof commonjsRequire=="function")PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if(typeof document=="object"){const Zg=(Cg=document==null?void 0:document.currentScript)==null?void 0:Cg.src;Zg&&(PDFWorkerUtil.fallbackWorkerSrc=Zg.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(Zg,$g){let Bg;try{if(Bg=new URL(Zg),!Bg.origin||Bg.origin==="null")return!1}catch{return!1}const Wg=new URL($g,Bg);return Bg.origin===Wg.origin},PDFWorkerUtil.createCDNWrapper=function(Zg){const $g=`importScripts("${Zg}");`;return URL.createObjectURL(new Blob([$g]))}}const _PDFWorker=class _PDFWorker{constructor({name:Zg=null,port:$g=null,verbosity:Bg=(0,_util.getVerbosityLevel)()}={}){var Wg;if(this.name=Zg,this.destroyed=!1,this.verbosity=Bg,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,$g){if((Wg=aa(_PDFWorker,lg))!=null&&Wg.has($g))throw new Error("Cannot use more than one PDFWorker per port.");(aa(_PDFWorker,lg)||fI(_PDFWorker,lg,new WeakMap)).set($g,this),this._initializeFromPort($g);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(Zg){this._port=Zg,this._messageHandler=new _message_handler.MessageHandler("main","worker",Zg),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:Zg}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,Zg)||(Zg=PDFWorkerUtil.createCDNWrapper(new URL(Zg,window.location).href));const $g=new Worker(Zg),Bg=new _message_handler.MessageHandler("main","worker",$g),Wg=()=>{$g.removeEventListener("error",yg),Bg.destroy(),$g.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},yg=()=>{this._webWorker||Wg()};$g.addEventListener("error",yg),Bg.on("test",vg=>{if($g.removeEventListener("error",yg),this.destroyed){Wg();return}vg?(this._messageHandler=Bg,this._port=$g,this._webWorker=$g,this._readyCapability.resolve(),Bg.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),Bg.destroy(),$g.terminate())}),Bg.on("ready",vg=>{if($g.removeEventListener("error",yg),this.destroyed){Wg();return}try{Ng()}catch{this._setupFakeWorker()}});const Ng=()=>{const vg=new Uint8Array;Bg.send("test",vg,[vg.buffer])};Ng();return}catch{(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then(Zg=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const $g=new LoopbackPort;this._port=$g;const Bg=`fake${PDFWorkerUtil.fakeWorkerId++}`,Wg=new _message_handler.MessageHandler(Bg+"_worker",Bg,$g);Zg.setup(Wg,$g);const yg=new _message_handler.MessageHandler(Bg,Bg+"_worker",$g);this._messageHandler=yg,this._readyCapability.resolve(),yg.send("configure",{verbosity:this.verbosity})}).catch(Zg=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${Zg.message}".`))})}destroy(){var Zg;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(Zg=aa(_PDFWorker,lg))==null||Zg.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(Zg){var Bg;if(!(Zg!=null&&Zg.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const $g=(Bg=aa(this,lg))==null?void 0:Bg.get(Zg.port);if($g){if($g._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return $g}return new _PDFWorker(Zg)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(PDFWorkerUtil.fallbackWorkerSrc!==null)return _util.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var Zg;try{return((Zg=globalThis.pdfjsWorker)==null?void 0:Zg.WorkerMessageHandler)||null}catch{return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_util.isNodeJS&&typeof commonjsRequire=="function"){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}};lg=new WeakMap,ZI(_PDFWorker,lg);let PDFWorker=_PDFWorker;exports.PDFWorker=PDFWorker;class WorkerTransport{constructor($g,Bg,Wg,yg,Ng){ZI(this,dg);ZI(this,Ag,new Map);ZI(this,rg,new Map);ZI(this,cg,new Map);ZI(this,ug,null);this.messageHandler=$g,this.loadingTask=Bg,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({ownerDocument:yg.ownerDocument,styleElement:yg.styleElement}),this._params=yg,this.canvasFactory=Ng.canvasFactory,this.filterFactory=Ng.filterFactory,this.cMapReaderFactory=Ng.cMapReaderFactory,this.standardFontDataFactory=Ng.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=Wg,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=new _util.PromiseCapability,this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent($g,Bg=_util.AnnotationMode.ENABLE,Wg=null,yg=!1){let Ng=_util.RenderingIntentFlag.DISPLAY,vg=_annotation_storage.SerializableEmpty;switch($g){case"any":Ng=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":Ng=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${$g}`)}switch(Bg){case _util.AnnotationMode.DISABLE:Ng+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:Ng+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:Ng+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,vg=(Ng&_util.RenderingIntentFlag.PRINT&&Wg instanceof _annotation_storage.PrintAnnotationStorage?Wg:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${Bg}`)}return yg&&(Ng+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:Ng,cacheKey:`${Ng}_${vg.hash}`,annotationStorageSerializable:vg}}destroy(){var Wg;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=new _util.PromiseCapability,(Wg=aa(this,ug))==null||Wg.reject(new Error("Worker was destroyed during onPassword callback"));const $g=[];for(const yg of aa(this,rg).values())$g.push(yg._destroy());aa(this,rg).clear(),aa(this,cg).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const Bg=this.messageHandler.sendWithPromise("Terminate",null);return $g.push(Bg),Promise.all($g).then(()=>{var yg;this.commonObjs.clear(),this.fontLoader.clear(),aa(this,Ag).clear(),this.filterFactory.destroy(),(yg=this._networkStream)==null||yg.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:$g,loadingTask:Bg}=this;$g.on("GetReader",(Wg,yg)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=Ng=>{this._lastProgress={loaded:Ng.loaded,total:Ng.total}},yg.onPull=()=>{this._fullReader.read().then(function({value:Ng,done:vg}){if(vg){yg.close();return}(0,_util.assert)(Ng instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),yg.enqueue(new Uint8Array(Ng),1,[Ng])}).catch(Ng=>{yg.error(Ng)})},yg.onCancel=Ng=>{this._fullReader.cancel(Ng),yg.ready.catch(vg=>{if(!this.destroyed)throw vg})}}),$g.on("ReaderHeadersReady",Wg=>{const yg=new _util.PromiseCapability,Ng=this._fullReader;return Ng.headersReady.then(()=>{var vg;(!Ng.isStreamingSupported||!Ng.isRangeSupported)&&(this._lastProgress&&((vg=Bg.onProgress)==null||vg.call(Bg,this._lastProgress)),Ng.onProgress=Sg=>{var Vg;(Vg=Bg.onProgress)==null||Vg.call(Bg,{loaded:Sg.loaded,total:Sg.total})}),yg.resolve({isStreamingSupported:Ng.isStreamingSupported,isRangeSupported:Ng.isRangeSupported,contentLength:Ng.contentLength})},yg.reject),yg.promise}),$g.on("GetRangeReader",(Wg,yg)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const Ng=this._networkStream.getRangeReader(Wg.begin,Wg.end);if(!Ng){yg.close();return}yg.onPull=()=>{Ng.read().then(function({value:vg,done:Sg}){if(Sg){yg.close();return}(0,_util.assert)(vg instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),yg.enqueue(new Uint8Array(vg),1,[vg])}).catch(vg=>{yg.error(vg)})},yg.onCancel=vg=>{Ng.cancel(vg),yg.ready.catch(Sg=>{if(!this.destroyed)throw Sg})}}),$g.on("GetDoc",({pdfInfo:Wg})=>{this._numPages=Wg.numPages,this._htmlForXfa=Wg.htmlForXfa,delete Wg.htmlForXfa,Bg._capability.resolve(new PDFDocumentProxy(Wg,this))}),$g.on("DocException",function(Wg){let yg;switch(Wg.name){case"PasswordException":yg=new _util.PasswordException(Wg.message,Wg.code);break;case"InvalidPDFException":yg=new _util.InvalidPDFException(Wg.message);break;case"MissingPDFException":yg=new _util.MissingPDFException(Wg.message);break;case"UnexpectedResponseException":yg=new _util.UnexpectedResponseException(Wg.message,Wg.status);break;case"UnknownErrorException":yg=new _util.UnknownErrorException(Wg.message,Wg.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}Bg._capability.reject(yg)}),$g.on("PasswordRequest",Wg=>{if(fI(this,ug,new _util.PromiseCapability),Bg.onPassword){const yg=Ng=>{Ng instanceof Error?aa(this,ug).reject(Ng):aa(this,ug).resolve({password:Ng})};try{Bg.onPassword(yg,Wg.code)}catch(Ng){aa(this,ug).reject(Ng)}}else aa(this,ug).reject(new _util.PasswordException(Wg.message,Wg.code));return aa(this,ug).promise}),$g.on("DataLoaded",Wg=>{var yg;(yg=Bg.onProgress)==null||yg.call(Bg,{loaded:Wg.length,total:Wg.length}),this.downloadInfoCapability.resolve(Wg)}),$g.on("StartRenderPage",Wg=>{if(this.destroyed)return;aa(this,rg).get(Wg.pageIndex)._startRenderPage(Wg.transparency,Wg.cacheKey)}),$g.on("commonobj",([Wg,yg,Ng])=>{var vg;if(!this.destroyed&&!this.commonObjs.has(Wg))switch(yg){case"Font":const Sg=this._params;if("error"in Ng){const Yg=Ng.error;(0,_util.warn)(`Error during font loading: ${Yg}`),this.commonObjs.resolve(Wg,Yg);break}const Vg=Sg.pdfBug&&((vg=globalThis.FontInspector)!=null&&vg.enabled)?(Yg,Hg)=>globalThis.FontInspector.fontAdded(Yg,Hg):null,Xg=new _font_loader.FontFaceObject(Ng,{isEvalSupported:Sg.isEvalSupported,disableFontFace:Sg.disableFontFace,ignoreErrors:Sg.ignoreErrors,inspectFont:Vg});this.fontLoader.bind(Xg).catch(Yg=>$g.sendWithPromise("FontFallback",{id:Wg})).finally(()=>{!Sg.fontExtraProperties&&Xg.data&&(Xg.data=null),this.commonObjs.resolve(Wg,Xg)});break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(Wg,Ng);break;default:throw new Error(`Got unknown common object type ${yg}`)}}),$g.on("obj",([Wg,yg,Ng,vg])=>{var Vg;if(this.destroyed)return;const Sg=aa(this,rg).get(yg);if(!Sg.objs.has(Wg))switch(Ng){case"Image":if(Sg.objs.resolve(Wg,vg),vg){let Xg;if(vg.bitmap){const{width:Yg,height:Hg}=vg;Xg=Yg*Hg*4}else Xg=((Vg=vg.data)==null?void 0:Vg.length)||0;Xg>_util.MAX_IMAGE_SIZE_TO_CACHE&&(Sg._maybeCleanupAfterRender=!0)}break;case"Pattern":Sg.objs.resolve(Wg,vg);break;default:throw new Error(`Got unknown object type ${Ng}`)}}),$g.on("DocProgress",Wg=>{var yg;this.destroyed||(yg=Bg.onProgress)==null||yg.call(Bg,{loaded:Wg.loaded,total:Wg.total})}),$g.on("FetchBuiltInCMap",Wg=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(Wg):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),$g.on("FetchStandardFontData",Wg=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(Wg):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var Wg;this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:$g,transfers:Bg}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:$g,filename:((Wg=this._fullReader)==null?void 0:Wg.filename)??null},Bg).finally(()=>{this.annotationStorage.resetModified()})}getPage($g){if(!Number.isInteger($g)||$g<=0||$g>this._numPages)return Promise.reject(new Error("Invalid page request."));const Bg=$g-1,Wg=aa(this,cg).get(Bg);if(Wg)return Wg;const yg=this.messageHandler.sendWithPromise("GetPage",{pageIndex:Bg}).then(Ng=>{if(this.destroyed)throw new Error("Transport destroyed");const vg=new PDFPageProxy(Bg,Ng,this,this._params.pdfBug);return aa(this,rg).set(Bg,vg),vg});return aa(this,cg).set(Bg,yg),yg}getPageIndex($g){return typeof $g!="object"||$g===null||!Number.isInteger($g.num)||$g.num<0||!Number.isInteger($g.gen)||$g.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:$g.num,gen:$g.gen})}getAnnotations($g,Bg){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:$g,intent:Bg})}getFieldObjects(){return hI(this,dg,Ed).call(this,"GetFieldObjects")}hasJSActions(){return hI(this,dg,Ed).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination($g){return typeof $g!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:$g})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return hI(this,dg,Ed).call(this,"GetDocJSActions")}getPageJSActions($g){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:$g})}getStructTree($g){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:$g})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then($g=>new _optional_content_config.OptionalContentConfig($g))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const $g="GetMetadata",Bg=aa(this,Ag).get($g);if(Bg)return Bg;const Wg=this.messageHandler.sendWithPromise($g,null).then(yg=>{var Ng,vg;return{info:yg[0],metadata:yg[1]?new _metadata.Metadata(yg[1]):null,contentDispositionFilename:((Ng=this._fullReader)==null?void 0:Ng.filename)??null,contentLength:((vg=this._fullReader)==null?void 0:vg.contentLength)??null}});return aa(this,Ag).set($g,Wg),Wg}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup($g=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const Bg of aa(this,rg).values())if(!Bg.cleanup())throw new Error(`startCleanup: Page ${Bg.pageNumber} is currently rendering.`);this.commonObjs.clear(),$g||this.fontLoader.clear(),aa(this,Ag).clear(),this.filterFactory.destroy(!0)}}get loadingParams(){const{disableAutoFetch:$g,enableXfa:Bg}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:$g,enableXfa:Bg})}}Ag=new WeakMap,rg=new WeakMap,cg=new WeakMap,ug=new WeakMap,dg=new WeakSet,Ed=function($g,Bg=null){const Wg=aa(this,Ag).get($g);if(Wg)return Wg;const yg=this.messageHandler.sendWithPromise($g,Bg);return aa(this,Ag).set($g,yg),yg};class PDFObjects{constructor(){ZI(this,bg);ZI(this,mg,Object.create(null))}get($g,Bg=null){if(Bg){const yg=hI(this,bg,r0).call(this,$g);return yg.capability.promise.then(()=>Bg(yg.data)),null}const Wg=aa(this,mg)[$g];if(!(Wg!=null&&Wg.capability.settled))throw new Error(`Requesting object that isn't resolved yet ${$g}.`);return Wg.data}has($g){const Bg=aa(this,mg)[$g];return(Bg==null?void 0:Bg.capability.settled)||!1}resolve($g,Bg=null){const Wg=hI(this,bg,r0).call(this,$g);Wg.data=Bg,Wg.capability.resolve()}clear(){var $g;for(const Bg in aa(this,mg)){const{data:Wg}=aa(this,mg)[Bg];($g=Wg==null?void 0:Wg.bitmap)==null||$g.close()}fI(this,mg,Object.create(null))}}mg=new WeakMap,bg=new WeakSet,r0=function($g){var Bg;return(Bg=aa(this,mg))[$g]||(Bg[$g]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor($g){ZI(this,fg,null);fI(this,fg,$g),this.onContinue=null}get promise(){return aa(this,fg).capability.promise}cancel($g=0){aa(this,fg).cancel(null,$g)}get separateAnnots(){const{separateAnnots:$g}=aa(this,fg).operatorList;if(!$g)return!1;const{annotationCanvasMap:Bg}=aa(this,fg);return $g.form||$g.canvas&&(Bg==null?void 0:Bg.size)>0}}fg=new WeakMap,exports.RenderTask=RenderTask;const Gg=class Gg{constructor({callback:$g,params:Bg,objs:Wg,commonObjs:yg,annotationCanvasMap:Ng,operatorList:vg,pageIndex:Sg,canvasFactory:Vg,filterFactory:Xg,useRequestAnimationFrame:Yg=!1,pdfBug:Hg=!1,pageColors:kg=null}){this.callback=$g,this.params=Bg,this.objs=Wg,this.commonObjs=yg,this.annotationCanvasMap=Ng,this.operatorListIdx=null,this.operatorList=vg,this._pageIndex=Sg,this.canvasFactory=Vg,this.filterFactory=Xg,this._pdfBug=Hg,this.pageColors=kg,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=Yg===!0&&typeof window<"u",this.cancelled=!1,this.capability=new _util.PromiseCapability,this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=Bg.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:$g=!1,optionalContentConfig:Bg}){var Sg,Vg;if(this.cancelled)return;if(this._canvas){if(aa(Gg,wg).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");aa(Gg,wg).add(this._canvas)}this._pdfBug&&((Sg=globalThis.StepperManager)!=null&&Sg.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:Wg,viewport:yg,transform:Ng,background:vg}=this.params;this.gfx=new _canvas.CanvasGraphics(Wg,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:Bg},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:Ng,viewport:yg,transparency:$g,background:vg}),this.operatorListIdx=0,this.graphicsReady=!0,(Vg=this.graphicsReadyCallback)==null||Vg.call(this)}cancel($g=null,Bg=0){var Wg;this.running=!1,this.cancelled=!0,(Wg=this.gfx)==null||Wg.endDrawing(),aa(Gg,wg).delete(this._canvas),this.callback($g||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,Bg))}operatorListChanged(){var $g;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}($g=this.stepper)==null||$g.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame(()=>{this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),aa(Gg,wg).delete(this._canvas),this.callback())))}};wg=new WeakMap,ZI(Gg,wg,new WeakSet);let InternalRenderTask=Gg;const version="3.11.174";exports.version=version;const build="ce8716743";exports.build=build}),((tg,eg,gg)=>{var Cg,lg,Ag,ib,cg;Object.defineProperty(eg,"__esModule",{value:!0}),eg.SerializableEmpty=eg.PrintAnnotationStorage=eg.AnnotationStorage=void 0;var ig=gg(1),ng=gg(4),og=gg(8);const ag=Object.freeze({map:null,hash:"",transfers:void 0});eg.SerializableEmpty=ag;class sg{constructor(){ZI(this,Ag);ZI(this,Cg,!1);ZI(this,lg,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(dg,hg){const mg=aa(this,lg).get(dg);return mg===void 0?hg:Object.assign(hg,mg)}getRawValue(dg){return aa(this,lg).get(dg)}remove(dg){if(aa(this,lg).delete(dg),aa(this,lg).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const hg of aa(this,lg).values())if(hg instanceof ng.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(dg,hg){const mg=aa(this,lg).get(dg);let bg=!1;if(mg!==void 0)for(const[pg,fg]of Object.entries(hg))mg[pg]!==fg&&(bg=!0,mg[pg]=fg);else bg=!0,aa(this,lg).set(dg,hg);bg&&hI(this,Ag,ib).call(this),hg instanceof ng.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(hg.constructor._type)}has(dg){return aa(this,lg).has(dg)}getAll(){return aa(this,lg).size>0?(0,ig.objectFromMap)(aa(this,lg)):null}setAll(dg){for(const[hg,mg]of Object.entries(dg))this.setValue(hg,mg)}get size(){return aa(this,lg).size}resetModified(){aa(this,Cg)&&(fI(this,Cg,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Ig(this)}get serializable(){if(aa(this,lg).size===0)return ag;const dg=new Map,hg=new og.MurmurHash3_64,mg=[],bg=Object.create(null);let pg=!1;for(const[fg,wg]of aa(this,lg)){const Gg=wg instanceof ng.AnnotationEditor?wg.serialize(!1,bg):wg;Gg&&(dg.set(fg,Gg),hg.update(`${fg}:${JSON.stringify(Gg)}`),pg||(pg=!!Gg.bitmap))}if(pg)for(const fg of dg.values())fg.bitmap&&mg.push(fg.bitmap);return dg.size>0?{map:dg,hash:hg.hexdigest(),transfers:mg}:ag}}Cg=new WeakMap,lg=new WeakMap,Ag=new WeakSet,ib=function(){aa(this,Cg)||(fI(this,Cg,!0),typeof this.onSetModified=="function"&&this.onSetModified())},eg.AnnotationStorage=sg;class Ig extends sg{constructor(hg){super();ZI(this,cg);const{map:mg,hash:bg,transfers:pg}=hg.serializable,fg=structuredClone(mg,pg?{transfer:pg}:null);fI(this,cg,{map:fg,hash:bg,transfers:pg})}get print(){(0,ig.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return aa(this,cg)}}cg=new WeakMap,eg.PrintAnnotationStorage=Ig}),((tg,eg,gg)=>{var Ig,Cg,lg,Ag,rg,cg,ug,dg,hg,mg,bg,pg,fg,wg,Gg,c0,d0,Bg,u0,m0,nb,ob,ab,h0,sb;Object.defineProperty(eg,"__esModule",{value:!0}),eg.AnnotationEditor=void 0;var ig=gg(5),ng=gg(1),og=gg(6);const Yg=class Yg{constructor(kg){ZI(this,Gg);ZI(this,Ig,"");ZI(this,Cg,!1);ZI(this,lg,null);ZI(this,Ag,null);ZI(this,rg,null);ZI(this,cg,!1);ZI(this,ug,null);ZI(this,dg,this.focusin.bind(this));ZI(this,hg,this.focusout.bind(this));ZI(this,mg,!1);ZI(this,bg,!1);ZI(this,pg,!1);UI(this,"_initialOptions",Object.create(null));UI(this,"_uiManager",null);UI(this,"_focusEventsAllowed",!0);UI(this,"_l10nPromise",null);ZI(this,fg,!1);ZI(this,wg,Yg._zIndex++);this.constructor===Yg&&(0,ng.unreachable)("Cannot initialize AnnotationEditor."),this.parent=kg.parent,this.id=kg.id,this.width=this.height=null,this.pageIndex=kg.parent.pageIndex,this.name=kg.name,this.div=null,this._uiManager=kg.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=kg.isCentered,this._structTreeParentId=null;const{rotation:Rg,rawDims:{pageWidth:Kg,pageHeight:jg,pageX:Dg,pageY:zg}}=this.parent.viewport;this.rotation=Rg,this.pageRotation=(360+Rg-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[Kg,jg],this.pageTranslation=[Dg,zg];const[Og,Jg]=this.parentDimensions;this.x=kg.x/Og,this.y=kg.y/Jg,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return(0,ng.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(kg){const Rg=new sg({id:kg.parent.getNextId(),parent:kg.parent,uiManager:kg._uiManager});Rg.annotationElementId=kg.annotationElementId,Rg.deleted=!0,Rg._uiManager.addToAnnotationStorage(Rg)}static initialize(kg,Rg=null){if(Yg._l10nPromise||(Yg._l10nPromise=new Map(["editor_alt_text_button_label","editor_alt_text_edit_button_label","editor_alt_text_decorative_tooltip"].map(jg=>[jg,kg.get(jg)]))),Rg!=null&&Rg.strings)for(const jg of Rg.strings)Yg._l10nPromise.set(jg,kg.get(jg));if(Yg._borderLineWidth!==-1)return;const Kg=getComputedStyle(document.documentElement);Yg._borderLineWidth=parseFloat(Kg.getPropertyValue("--outline-width"))||0}static updateDefaultParams(kg,Rg){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(kg){return!1}static paste(kg,Rg){(0,ng.unreachable)("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return aa(this,fg)}set _isDraggable(kg){var Rg;fI(this,fg,kg),(Rg=this.div)==null||Rg.classList.toggle("draggable",kg)}center(){const[kg,Rg]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*Rg/(kg*2),this.y+=this.width*kg/(Rg*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*Rg/(kg*2),this.y-=this.width*kg/(Rg*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(kg){this._uiManager.addCommands(kg)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=aa(this,wg)}setParent(kg){kg!==null&&(this.pageIndex=kg.pageIndex,this.pageDimensions=kg.pageDimensions),this.parent=kg}focusin(kg){this._focusEventsAllowed&&(aa(this,mg)?fI(this,mg,!1):this.parent.setSelected(this))}focusout(kg){var Kg;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const Rg=kg.relatedTarget;Rg!=null&&Rg.closest(`#${this.id}`)||(kg.preventDefault(),(Kg=this.parent)!=null&&Kg.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(kg,Rg,Kg,jg){const[Dg,zg]=this.parentDimensions;[Kg,jg]=this.screenToPageTranslation(Kg,jg),this.x=(kg+Kg)/Dg,this.y=(Rg+jg)/zg,this.fixAndSetPosition()}translate(kg,Rg){hI(this,Gg,c0).call(this,this.parentDimensions,kg,Rg)}translateInPage(kg,Rg){hI(this,Gg,c0).call(this,this.pageDimensions,kg,Rg),this.div.scrollIntoView({block:"nearest"})}drag(kg,Rg){const[Kg,jg]=this.parentDimensions;if(this.x+=kg/Kg,this.y+=Rg/jg,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:Qg,y:eo}=this.div.getBoundingClientRect();this.parent.findNewParent(this,Qg,eo)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:Dg,y:zg}=this;const[Og,Jg]=hI(this,Gg,d0).call(this);Dg+=Og,zg+=Jg,this.div.style.left=`${(100*Dg).toFixed(2)}%`,this.div.style.top=`${(100*zg).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}fixAndSetPosition(){const[kg,Rg]=this.pageDimensions;let{x:Kg,y:jg,width:Dg,height:zg}=this;switch(Dg*=kg,zg*=Rg,Kg*=kg,jg*=Rg,this.rotation){case 0:Kg=Math.max(0,Math.min(kg-Dg,Kg)),jg=Math.max(0,Math.min(Rg-zg,jg));break;case 90:Kg=Math.max(0,Math.min(kg-zg,Kg)),jg=Math.min(Rg,Math.max(Dg,jg));break;case 180:Kg=Math.min(kg,Math.max(Dg,Kg)),jg=Math.min(Rg,Math.max(zg,jg));break;case 270:Kg=Math.min(kg,Math.max(zg,Kg)),jg=Math.max(0,Math.min(Rg-Dg,jg));break}this.x=Kg/=kg,this.y=jg/=Rg;const[Og,Jg]=hI(this,Gg,d0).call(this);Kg+=Og,jg+=Jg;const{style:Qg}=this.div;Qg.left=`${(100*Kg).toFixed(2)}%`,Qg.top=`${(100*jg).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(kg,Rg){var Kg;return hI(Kg=Yg,Bg,u0).call(Kg,kg,Rg,this.parentRotation)}pageTranslationToScreen(kg,Rg){var Kg;return hI(Kg=Yg,Bg,u0).call(Kg,kg,Rg,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:kg,pageDimensions:[Rg,Kg]}=this,jg=Rg*kg,Dg=Kg*kg;return ng.FeatureTest.isCSSRoundSupported?[Math.round(jg),Math.round(Dg)]:[jg,Dg]}setDims(kg,Rg){var Dg;const[Kg,jg]=this.parentDimensions;this.div.style.width=`${(100*kg/Kg).toFixed(2)}%`,aa(this,cg)||(this.div.style.height=`${(100*Rg/jg).toFixed(2)}%`),(Dg=aa(this,lg))==null||Dg.classList.toggle("small",kg<Yg.SMALL_EDITOR_SIZE||Rg<Yg.SMALL_EDITOR_SIZE)}fixDims(){const{style:kg}=this.div,{height:Rg,width:Kg}=kg,jg=Kg.endsWith("%"),Dg=!aa(this,cg)&&Rg.endsWith("%");if(jg&&Dg)return;const[zg,Og]=this.parentDimensions;jg||(kg.width=`${(100*parseFloat(Kg)/zg).toFixed(2)}%`),!aa(this,cg)&&!Dg&&(kg.height=`${(100*parseFloat(Rg)/Og).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}async addAltTextButton(){if(aa(this,lg))return;const kg=fI(this,lg,document.createElement("button"));kg.className="altText";const Rg=await Yg._l10nPromise.get("editor_alt_text_button_label");kg.textContent=Rg,kg.setAttribute("aria-label",Rg),kg.tabIndex="0",kg.addEventListener("contextmenu",og.noContextMenu),kg.addEventListener("pointerdown",Kg=>Kg.stopPropagation()),kg.addEventListener("click",Kg=>{Kg.preventDefault(),this._uiManager.editAltText(this)},{capture:!0}),kg.addEventListener("keydown",Kg=>{Kg.target===kg&&Kg.key==="Enter"&&(Kg.preventDefault(),this._uiManager.editAltText(this))}),hI(this,Gg,h0).call(this),this.div.append(kg),Yg.SMALL_EDITOR_SIZE||(Yg.SMALL_EDITOR_SIZE=Math.min(128,Math.round(kg.getBoundingClientRect().width*1.4)))}getClientDimensions(){return this.div.getBoundingClientRect()}get altTextData(){return{altText:aa(this,Ig),decorative:aa(this,Cg)}}set altTextData({altText:kg,decorative:Rg}){aa(this,Ig)===kg&&aa(this,Cg)===Rg||(fI(this,Ig,kg),fI(this,Cg,Rg),hI(this,Gg,h0).call(this))}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",aa(this,dg)),this.div.addEventListener("focusout",aa(this,hg));const[kg,Rg]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*Rg/kg).toFixed(2)}%`,this.div.style.maxHeight=`${(100*kg/Rg).toFixed(2)}%`);const[Kg,jg]=this.getInitialTranslation();return this.translate(Kg,jg),(0,ig.bindEvents)(this,this.div,["pointerdown"]),this.div}pointerdown(kg){const{isMac:Rg}=ng.FeatureTest.platform;if(kg.button!==0||kg.ctrlKey&&Rg){kg.preventDefault();return}fI(this,mg,!0),hI(this,Gg,sb).call(this,kg)}moveInDOM(){var kg;(kg=this.parent)==null||kg.moveEditorInDOM(this)}_setParentAndPosition(kg,Rg,Kg){kg.changeParent(this),this.x=Rg,this.y=Kg,this.fixAndSetPosition()}getRect(kg,Rg){const Kg=this.parentScale,[jg,Dg]=this.pageDimensions,[zg,Og]=this.pageTranslation,Jg=kg/Kg,Qg=Rg/Kg,eo=this.x*jg,ca=this.y*Dg,ua=this.width*jg,pa=this.height*Dg;switch(this.rotation){case 0:return[eo+Jg+zg,Dg-ca-Qg-pa+Og,eo+Jg+ua+zg,Dg-ca-Qg+Og];case 90:return[eo+Qg+zg,Dg-ca+Jg+Og,eo+Qg+pa+zg,Dg-ca+Jg+ua+Og];case 180:return[eo-Jg-ua+zg,Dg-ca+Qg+Og,eo-Jg+zg,Dg-ca+Qg+pa+Og];case 270:return[eo-Qg-pa+zg,Dg-ca-Jg-ua+Og,eo-Qg+zg,Dg-ca-Jg+Og];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(kg,Rg){const[Kg,jg,Dg,zg]=kg,Og=Dg-Kg,Jg=zg-jg;switch(this.rotation){case 0:return[Kg,Rg-zg,Og,Jg];case 90:return[Kg,Rg-jg,Jg,Og];case 180:return[Dg,Rg-jg,Og,Jg];case 270:return[Dg,Rg-zg,Jg,Og];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){fI(this,pg,!0)}disableEditMode(){fI(this,pg,!1)}isInEditMode(){return aa(this,pg)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var kg,Rg;(kg=this.div)==null||kg.addEventListener("focusin",aa(this,dg)),(Rg=this.div)==null||Rg.addEventListener("focusout",aa(this,hg))}serialize(kg=!1,Rg=null){(0,ng.unreachable)("An editor must be serializable")}static deserialize(kg,Rg,Kg){const jg=new this.prototype.constructor({parent:Rg,id:Rg.getNextId(),uiManager:Kg});jg.rotation=kg.rotation;const[Dg,zg]=jg.pageDimensions,[Og,Jg,Qg,eo]=jg.getRectInCurrentCoords(kg.rect,zg);return jg.x=Og/Dg,jg.y=Jg/zg,jg.width=Qg/Dg,jg.height=eo/zg,jg}remove(){var kg;this.div.removeEventListener("focusin",aa(this,dg)),this.div.removeEventListener("focusout",aa(this,hg)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),(kg=aa(this,lg))==null||kg.remove(),fI(this,lg,null),fI(this,Ag,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(hI(this,Gg,nb).call(this),aa(this,ug).classList.remove("hidden"))}select(){var kg;this.makeResizable(),(kg=this.div)==null||kg.classList.add("selectedEditor")}unselect(){var kg,Rg,Kg;(kg=aa(this,ug))==null||kg.classList.add("hidden"),(Rg=this.div)==null||Rg.classList.remove("selectedEditor"),(Kg=this.div)!=null&&Kg.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus()}updateParams(kg,Rg){}disableEditing(){aa(this,lg)&&(aa(this,lg).hidden=!0)}enableEditing(){aa(this,lg)&&(aa(this,lg).hidden=!1)}enterInEditMode(){}get contentDiv(){return this.div}get isEditing(){return aa(this,bg)}set isEditing(kg){fI(this,bg,kg),this.parent&&(kg?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(kg,Rg){fI(this,cg,!0);const Kg=kg/Rg,{style:jg}=this.div;jg.aspectRatio=Kg,jg.height="auto"}static get MIN_SIZE(){return 16}};Ig=new WeakMap,Cg=new WeakMap,lg=new WeakMap,Ag=new WeakMap,rg=new WeakMap,cg=new WeakMap,ug=new WeakMap,dg=new WeakMap,hg=new WeakMap,mg=new WeakMap,bg=new WeakMap,pg=new WeakMap,fg=new WeakMap,wg=new WeakMap,Gg=new WeakSet,c0=function([kg,Rg],Kg,jg){[Kg,jg]=this.screenToPageTranslation(Kg,jg),this.x+=Kg/kg,this.y+=jg/Rg,this.fixAndSetPosition()},d0=function(){const[kg,Rg]=this.parentDimensions,{_borderLineWidth:Kg}=Yg,jg=Kg/kg,Dg=Kg/Rg;switch(this.rotation){case 90:return[-jg,Dg];case 180:return[jg,Dg];case 270:return[jg,-Dg];default:return[-jg,-Dg]}},Bg=new WeakSet,u0=function(kg,Rg,Kg){switch(Kg){case 90:return[Rg,-kg];case 180:return[-kg,-Rg];case 270:return[-Rg,kg];default:return[kg,Rg]}},m0=function(kg){switch(kg){case 90:{const[Rg,Kg]=this.pageDimensions;return[0,-Rg/Kg,Kg/Rg,0]}case 180:return[-1,0,0,-1];case 270:{const[Rg,Kg]=this.pageDimensions;return[0,Rg/Kg,-Kg/Rg,0]}default:return[1,0,0,1]}},nb=function(){if(aa(this,ug))return;fI(this,ug,document.createElement("div")),aa(this,ug).classList.add("resizers");const kg=["topLeft","topRight","bottomRight","bottomLeft"];this._willKeepAspectRatio||kg.push("topMiddle","middleRight","bottomMiddle","middleLeft");for(const Rg of kg){const Kg=document.createElement("div");aa(this,ug).append(Kg),Kg.classList.add("resizer",Rg),Kg.addEventListener("pointerdown",hI(this,Gg,ob).bind(this,Rg)),Kg.addEventListener("contextmenu",og.noContextMenu)}this.div.prepend(aa(this,ug))},ob=function(kg,Rg){Rg.preventDefault();const{isMac:Kg}=ng.FeatureTest.platform;if(Rg.button!==0||Rg.ctrlKey&&Kg)return;const jg=hI(this,Gg,ab).bind(this,kg),Dg=this._isDraggable;this._isDraggable=!1;const zg={passive:!0,capture:!0};window.addEventListener("pointermove",jg,zg);const Og=this.x,Jg=this.y,Qg=this.width,eo=this.height,ca=this.parent.div.style.cursor,ua=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(Rg.target).cursor;const pa=()=>{this._isDraggable=Dg,window.removeEventListener("pointerup",pa),window.removeEventListener("blur",pa),window.removeEventListener("pointermove",jg,zg),this.parent.div.style.cursor=ca,this.div.style.cursor=ua;const is=this.x,Pg=this.y,la=this.width,ma=this.height;is===Og&&Pg===Jg&&la===Qg&&ma===eo||this.addCommands({cmd:()=>{this.width=la,this.height=ma,this.x=is,this.y=Pg;const[Ca,Eg]=this.parentDimensions;this.setDims(Ca*la,Eg*ma),this.fixAndSetPosition()},undo:()=>{this.width=Qg,this.height=eo,this.x=Og,this.y=Jg;const[Ca,Eg]=this.parentDimensions;this.setDims(Ca*Qg,Eg*eo),this.fixAndSetPosition()},mustExec:!0})};window.addEventListener("pointerup",pa),window.addEventListener("blur",pa)},ab=function(kg,Rg){const[Kg,jg]=this.parentDimensions,Dg=this.x,zg=this.y,Og=this.width,Jg=this.height,Qg=Yg.MIN_SIZE/Kg,eo=Yg.MIN_SIZE/jg,ca=qg=>Math.round(qg*1e4)/1e4,ua=hI(this,Gg,m0).call(this,this.rotation),pa=(qg,xa)=>[ua[0]*qg+ua[2]*xa,ua[1]*qg+ua[3]*xa],is=hI(this,Gg,m0).call(this,360-this.rotation),Pg=(qg,xa)=>[is[0]*qg+is[2]*xa,is[1]*qg+is[3]*xa];let la,ma,Ca=!1,Eg=!1;switch(kg){case"topLeft":Ca=!0,la=(qg,xa)=>[0,0],ma=(qg,xa)=>[qg,xa];break;case"topMiddle":la=(qg,xa)=>[qg/2,0],ma=(qg,xa)=>[qg/2,xa];break;case"topRight":Ca=!0,la=(qg,xa)=>[qg,0],ma=(qg,xa)=>[0,xa];break;case"middleRight":Eg=!0,la=(qg,xa)=>[qg,xa/2],ma=(qg,xa)=>[0,xa/2];break;case"bottomRight":Ca=!0,la=(qg,xa)=>[qg,xa],ma=(qg,xa)=>[0,0];break;case"bottomMiddle":la=(qg,xa)=>[qg/2,xa],ma=(qg,xa)=>[qg/2,0];break;case"bottomLeft":Ca=!0,la=(qg,xa)=>[0,xa],ma=(qg,xa)=>[qg,0];break;case"middleLeft":Eg=!0,la=(qg,xa)=>[0,xa/2],ma=(qg,xa)=>[qg,xa/2];break}const Mg=la(Og,Jg),Tg=ma(Og,Jg);let Ug=pa(...Tg);const da=ca(Dg+Ug[0]),ya=ca(zg+Ug[1]);let eI=1,us=1,[uo,ha]=this.screenToPageTranslation(Rg.movementX,Rg.movementY);if([uo,ha]=Pg(uo/Kg,ha/jg),Ca){const qg=Math.hypot(Og,Jg);eI=us=Math.max(Math.min(Math.hypot(Tg[0]-Mg[0]-uo,Tg[1]-Mg[1]-ha)/qg,1/Og,1/Jg),Qg/Og,eo/Jg)}else Eg?eI=Math.max(Qg,Math.min(1,Math.abs(Tg[0]-Mg[0]-uo)))/Og:us=Math.max(eo,Math.min(1,Math.abs(Tg[1]-Mg[1]-ha)))/Jg;const tI=ca(Og*eI),AI=ca(Jg*us);Ug=pa(...ma(tI,AI));const rI=da-Ug[0],gI=ya-Ug[1];this.width=tI,this.height=AI,this.x=rI,this.y=gI,this.setDims(Kg*tI,jg*AI),this.fixAndSetPosition()},h0=async function(){var Kg;const kg=aa(this,lg);if(!kg)return;if(!aa(this,Ig)&&!aa(this,Cg)){kg.classList.remove("done"),(Kg=aa(this,Ag))==null||Kg.remove();return}Yg._l10nPromise.get("editor_alt_text_edit_button_label").then(jg=>{kg.setAttribute("aria-label",jg)});let Rg=aa(this,Ag);if(!Rg){fI(this,Ag,Rg=document.createElement("span")),Rg.className="tooltip",Rg.setAttribute("role","tooltip");const jg=Rg.id=`alt-text-tooltip-${this.id}`;kg.setAttribute("aria-describedby",jg);const Dg=100;kg.addEventListener("mouseenter",()=>{fI(this,rg,setTimeout(()=>{fI(this,rg,null),aa(this,Ag).classList.add("show"),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"alt_text_tooltip"}}})},Dg))}),kg.addEventListener("mouseleave",()=>{var zg;clearTimeout(aa(this,rg)),fI(this,rg,null),(zg=aa(this,Ag))==null||zg.classList.remove("show")})}kg.classList.add("done"),Rg.innerText=aa(this,Cg)?await Yg._l10nPromise.get("editor_alt_text_decorative_tooltip"):aa(this,Ig),Rg.parentNode||kg.append(Rg)},sb=function(kg){if(!this._isDraggable)return;const Rg=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let Kg,jg;Rg&&(Kg={passive:!0,capture:!0},jg=zg=>{const[Og,Jg]=this.screenToPageTranslation(zg.movementX,zg.movementY);this._uiManager.dragSelectedEditors(Og,Jg)},window.addEventListener("pointermove",jg,Kg));const Dg=()=>{if(window.removeEventListener("pointerup",Dg),window.removeEventListener("blur",Dg),Rg&&window.removeEventListener("pointermove",jg,Kg),fI(this,mg,!1),!this._uiManager.endDragSession()){const{isMac:zg}=ng.FeatureTest.platform;kg.ctrlKey&&!zg||kg.shiftKey||kg.metaKey&&zg?this.parent.toggleSelected(this):this.parent.setSelected(this)}};window.addEventListener("pointerup",Dg),window.addEventListener("blur",Dg)},ZI(Yg,Bg),UI(Yg,"_borderLineWidth",-1),UI(Yg,"_colorManager",new ig.ColorManager),UI(Yg,"_zIndex",1),UI(Yg,"SMALL_EDITOR_SIZE",0);let ag=Yg;eg.AnnotationEditor=ag;class sg extends ag{constructor(kg){super(kg),this.annotationElementId=kg.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}}),((tg,eg,gg)=>{var cg,ug,dg,hg,mg,b0,fg,wg,Gg,Zg,$g,Ib,yg,Ng,vg,Sg,Vg,Xg,Yg,Hg,kg,Rg,Kg,jg,Dg,zg,Og,Jg,Qg,eo,ca,ua,pa,is,Pg,la,ma,Ca,Eg,Mg,Tg,Ug,da,ya,eI,us,uo,lb,p0,w0,_d,Z0,f0,uc,Nd,Cb,Ab,G0,vd,y0;Object.defineProperty(eg,"__esModule",{value:!0}),eg.KeyboardManager=eg.CommandManager=eg.ColorManager=eg.AnnotationEditorUIManager=void 0,eg.bindEvents=og,eg.opacityToHex=ag;var ig=gg(1),ng=gg(6);function og(xg,lo,oa){for(const no of oa)lo.addEventListener(no,xg[no].bind(xg))}function ag(xg){return Math.round(Math.min(255,Math.max(1,255*xg))).toString(16).padStart(2,"0")}class sg{constructor(){ZI(this,cg,0)}getId(){return`${ig.AnnotationEditorPrefix}${Wd(this,cg)._++}`}}cg=new WeakMap;const pg=class pg{constructor(){ZI(this,mg);ZI(this,ug,(0,ig.getUuid)());ZI(this,dg,0);ZI(this,hg,null)}static get _isSVGFittingCanvas(){const lo='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',no=new OffscreenCanvas(1,3).getContext("2d"),co=new Image;co.src=lo;const va=co.decode().then(()=>(no.drawImage(co,0,0,1,1,0,0,1,3),new Uint32Array(no.getImageData(0,0,1,1).data.buffer)[0]===0));return(0,ig.shadow)(this,"_isSVGFittingCanvas",va)}async getFromFile(lo){const{lastModified:oa,name:no,size:co,type:va}=lo;return hI(this,mg,b0).call(this,`${oa}_${no}_${co}_${va}`,lo)}async getFromUrl(lo){return hI(this,mg,b0).call(this,lo,lo)}async getFromId(lo){aa(this,hg)||fI(this,hg,new Map);const oa=aa(this,hg).get(lo);return oa?oa.bitmap?(oa.refCounter+=1,oa):oa.file?this.getFromFile(oa.file):this.getFromUrl(oa.url):null}getSvgUrl(lo){const oa=aa(this,hg).get(lo);return oa!=null&&oa.isSvg?oa.svgUrl:null}deleteId(lo){aa(this,hg)||fI(this,hg,new Map);const oa=aa(this,hg).get(lo);oa&&(oa.refCounter-=1,oa.refCounter===0&&(oa.bitmap=null))}isValidId(lo){return lo.startsWith(`image_${aa(this,ug)}_`)}};ug=new WeakMap,dg=new WeakMap,hg=new WeakMap,mg=new WeakSet,b0=async function(lo,oa){aa(this,hg)||fI(this,hg,new Map);let no=aa(this,hg).get(lo);if(no===null)return null;if(no!=null&&no.bitmap)return no.refCounter+=1,no;try{no||(no={bitmap:null,id:`image_${aa(this,ug)}_${Wd(this,dg)._++}`,refCounter:0,isSvg:!1});let co;if(typeof oa=="string"){no.url=oa;const va=await fetch(oa);if(!va.ok)throw new Error(va.statusText);co=await va.blob()}else co=no.file=oa;if(co.type==="image/svg+xml"){const va=pg._isSVGFittingCanvas,nI=new FileReader,ga=new Image,_g=new Promise((La,aI)=>{ga.onload=()=>{no.bitmap=ga,no.isSvg=!0,La()},nI.onload=async()=>{const hs=no.svgUrl=nI.result;ga.src=await va?`${hs}#svgView(preserveAspectRatio(none))`:hs},ga.onerror=nI.onerror=aI});nI.readAsDataURL(co),await _g}else no.bitmap=await createImageBitmap(co);no.refCounter=1}catch(co){console.error(co),no=null}return aa(this,hg).set(lo,no),no&&aa(this,hg).set(no.id,no),no};let Ig=pg;class Cg{constructor(lo=128){ZI(this,fg,[]);ZI(this,wg,!1);ZI(this,Gg);ZI(this,Zg,-1);fI(this,Gg,lo)}add({cmd:lo,undo:oa,mustExec:no,type:co=NaN,overwriteIfSameType:va=!1,keepUndo:nI=!1}){if(no&&lo(),aa(this,wg))return;const ga={cmd:lo,undo:oa,type:co};if(aa(this,Zg)===-1){aa(this,fg).length>0&&(aa(this,fg).length=0),fI(this,Zg,0),aa(this,fg).push(ga);return}if(va&&aa(this,fg)[aa(this,Zg)].type===co){nI&&(ga.undo=aa(this,fg)[aa(this,Zg)].undo),aa(this,fg)[aa(this,Zg)]=ga;return}const _g=aa(this,Zg)+1;_g===aa(this,Gg)?aa(this,fg).splice(0,1):(fI(this,Zg,_g),_g<aa(this,fg).length&&aa(this,fg).splice(_g)),aa(this,fg).push(ga)}undo(){aa(this,Zg)!==-1&&(fI(this,wg,!0),aa(this,fg)[aa(this,Zg)].undo(),fI(this,wg,!1),fI(this,Zg,aa(this,Zg)-1))}redo(){aa(this,Zg)<aa(this,fg).length-1&&(fI(this,Zg,aa(this,Zg)+1),fI(this,wg,!0),aa(this,fg)[aa(this,Zg)].cmd(),fI(this,wg,!1))}hasSomethingToUndo(){return aa(this,Zg)!==-1}hasSomethingToRedo(){return aa(this,Zg)<aa(this,fg).length-1}destroy(){fI(this,fg,null)}}fg=new WeakMap,wg=new WeakMap,Gg=new WeakMap,Zg=new WeakMap,eg.CommandManager=Cg;class lg{constructor(lo){ZI(this,$g);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:oa}=ig.FeatureTest.platform;for(const[no,co,va={}]of lo)for(const nI of no){const ga=nI.startsWith("mac+");oa&&ga?(this.callbacks.set(nI.slice(4),{callback:co,options:va}),this.allKeys.add(nI.split("+").at(-1))):!oa&&!ga&&(this.callbacks.set(nI,{callback:co,options:va}),this.allKeys.add(nI.split("+").at(-1)))}}exec(lo,oa){if(!this.allKeys.has(oa.key))return;const no=this.callbacks.get(hI(this,$g,Ib).call(this,oa));if(!no)return;const{callback:co,options:{bubbles:va=!1,args:nI=[],checker:ga=null}}=no;ga&&!ga(lo,oa)||(co.bind(lo,...nI)(),va||(oa.stopPropagation(),oa.preventDefault()))}}$g=new WeakSet,Ib=function(lo){lo.altKey&&this.buffer.push("alt"),lo.ctrlKey&&this.buffer.push("ctrl"),lo.metaKey&&this.buffer.push("meta"),lo.shiftKey&&this.buffer.push("shift"),this.buffer.push(lo.key);const oa=this.buffer.join("+");return this.buffer.length=0,oa},eg.KeyboardManager=lg;const Wg=class Wg{get _colors(){const lo=new Map([["CanvasText",null],["Canvas",null]]);return(0,ng.getColorValues)(lo),(0,ig.shadow)(this,"_colors",lo)}convert(lo){const oa=(0,ng.getRGB)(lo);if(!window.matchMedia("(forced-colors: active)").matches)return oa;for(const[no,co]of this._colors)if(co.every((va,nI)=>va===oa[nI]))return Wg._colorsMapping.get(no);return oa}getHexCode(lo){const oa=this._colors.get(lo);return oa?ig.Util.makeHexColor(...oa):lo}};UI(Wg,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Ag=Wg;eg.ColorManager=Ag;const cs=class cs{constructor(lo,oa,no,co,va,nI){ZI(this,uo);ZI(this,yg,null);ZI(this,Ng,new Map);ZI(this,vg,new Map);ZI(this,Sg,null);ZI(this,Vg,null);ZI(this,Xg,new Cg);ZI(this,Yg,0);ZI(this,Hg,new Set);ZI(this,kg,null);ZI(this,Rg,null);ZI(this,Kg,new Set);ZI(this,jg,null);ZI(this,Dg,new sg);ZI(this,zg,!1);ZI(this,Og,!1);ZI(this,Jg,null);ZI(this,Qg,ig.AnnotationEditorType.NONE);ZI(this,eo,new Set);ZI(this,ca,null);ZI(this,ua,this.blur.bind(this));ZI(this,pa,this.focus.bind(this));ZI(this,is,this.copy.bind(this));ZI(this,Pg,this.cut.bind(this));ZI(this,la,this.paste.bind(this));ZI(this,ma,this.keydown.bind(this));ZI(this,Ca,this.onEditingAction.bind(this));ZI(this,Eg,this.onPageChanging.bind(this));ZI(this,Mg,this.onScaleChanging.bind(this));ZI(this,Tg,this.onRotationChanging.bind(this));ZI(this,Ug,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1});ZI(this,da,[0,0]);ZI(this,ya,null);ZI(this,eI,null);ZI(this,us,null);fI(this,eI,lo),fI(this,us,oa),fI(this,Sg,no),this._eventBus=co,this._eventBus._on("editingaction",aa(this,Ca)),this._eventBus._on("pagechanging",aa(this,Eg)),this._eventBus._on("scalechanging",aa(this,Mg)),this._eventBus._on("rotationchanging",aa(this,Tg)),fI(this,Vg,va.annotationStorage),fI(this,jg,va.filterFactory),fI(this,ca,nI),this.viewParameters={realScale:ng.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){const lo=cs.prototype,oa=va=>{const{activeElement:nI}=document;return nI&&aa(va,eI).contains(nI)&&va.hasSomethingToControl()},no=this.TRANSLATE_SMALL,co=this.TRANSLATE_BIG;return(0,ig.shadow)(this,"_keyboardManager",new lg([[["ctrl+a","mac+meta+a"],lo.selectAll],[["ctrl+z","mac+meta+z"],lo.undo],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],lo.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],lo.delete],[["Escape","mac+Escape"],lo.unselectAll],[["ArrowLeft","mac+ArrowLeft"],lo.translateSelectedEditors,{args:[-no,0],checker:oa}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],lo.translateSelectedEditors,{args:[-co,0],checker:oa}],[["ArrowRight","mac+ArrowRight"],lo.translateSelectedEditors,{args:[no,0],checker:oa}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],lo.translateSelectedEditors,{args:[co,0],checker:oa}],[["ArrowUp","mac+ArrowUp"],lo.translateSelectedEditors,{args:[0,-no],checker:oa}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],lo.translateSelectedEditors,{args:[0,-co],checker:oa}],[["ArrowDown","mac+ArrowDown"],lo.translateSelectedEditors,{args:[0,no],checker:oa}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],lo.translateSelectedEditors,{args:[0,co],checker:oa}]]))}destroy(){hI(this,uo,_d).call(this),hI(this,uo,p0).call(this),this._eventBus._off("editingaction",aa(this,Ca)),this._eventBus._off("pagechanging",aa(this,Eg)),this._eventBus._off("scalechanging",aa(this,Mg)),this._eventBus._off("rotationchanging",aa(this,Tg));for(const lo of aa(this,vg).values())lo.destroy();aa(this,vg).clear(),aa(this,Ng).clear(),aa(this,Kg).clear(),fI(this,yg,null),aa(this,eo).clear(),aa(this,Xg).destroy(),aa(this,Sg).destroy()}get hcmFilter(){return(0,ig.shadow)(this,"hcmFilter",aa(this,ca)?aa(this,jg).addHCMFilter(aa(this,ca).foreground,aa(this,ca).background):"none")}get direction(){return(0,ig.shadow)(this,"direction",getComputedStyle(aa(this,eI)).direction)}editAltText(lo){var oa;(oa=aa(this,Sg))==null||oa.editAltText(this,lo)}onPageChanging({pageNumber:lo}){fI(this,Yg,lo-1)}focusMainContainer(){aa(this,eI).focus()}findParent(lo,oa){for(const no of aa(this,vg).values()){const{x:co,y:va,width:nI,height:ga}=no.div.getBoundingClientRect();if(lo>=co&&lo<=co+nI&&oa>=va&&oa<=va+ga)return no}return null}disableUserSelect(lo=!1){aa(this,us).classList.toggle("noUserSelect",lo)}addShouldRescale(lo){aa(this,Kg).add(lo)}removeShouldRescale(lo){aa(this,Kg).delete(lo)}onScaleChanging({scale:lo}){this.commitOrRemove(),this.viewParameters.realScale=lo*ng.PixelsPerInch.PDF_TO_CSS_UNITS;for(const oa of aa(this,Kg))oa.onScaleChanging()}onRotationChanging({pagesRotation:lo}){this.commitOrRemove(),this.viewParameters.rotation=lo}addToAnnotationStorage(lo){!lo.isEmpty()&&aa(this,Vg)&&!aa(this,Vg).has(lo.id)&&aa(this,Vg).setValue(lo.id,lo)}blur(){if(!this.hasSelection)return;const{activeElement:lo}=document;for(const oa of aa(this,eo))if(oa.div.contains(lo)){fI(this,Jg,[oa,lo]),oa._focusEventsAllowed=!1;break}}focus(){if(!aa(this,Jg))return;const[lo,oa]=aa(this,Jg);fI(this,Jg,null),oa.addEventListener("focusin",()=>{lo._focusEventsAllowed=!0},{once:!0}),oa.focus()}addEditListeners(){hI(this,uo,w0).call(this),hI(this,uo,Z0).call(this)}removeEditListeners(){hI(this,uo,_d).call(this),hI(this,uo,f0).call(this)}copy(lo){var no;if(lo.preventDefault(),(no=aa(this,yg))==null||no.commitOrRemove(),!this.hasSelection)return;const oa=[];for(const co of aa(this,eo)){const va=co.serialize(!0);va&&oa.push(va)}oa.length!==0&&lo.clipboardData.setData("application/pdfjs",JSON.stringify(oa))}cut(lo){this.copy(lo),this.delete()}paste(lo){lo.preventDefault();const{clipboardData:oa}=lo;for(const va of oa.items)for(const nI of aa(this,Rg))if(nI.isHandlingMimeForPasting(va.type)){nI.paste(va,this.currentLayer);return}let no=oa.getData("application/pdfjs");if(!no)return;try{no=JSON.parse(no)}catch(va){(0,ig.warn)(`paste: "${va.message}".`);return}if(!Array.isArray(no))return;this.unselectAll();const co=this.currentLayer;try{const va=[];for(const _g of no){const La=co.deserialize(_g);if(!La)return;va.push(La)}const nI=()=>{for(const _g of va)hI(this,uo,G0).call(this,_g);hI(this,uo,y0).call(this,va)},ga=()=>{for(const _g of va)_g.remove()};this.addCommands({cmd:nI,undo:ga,mustExec:!0})}catch(va){(0,ig.warn)(`paste: "${va.message}".`)}}keydown(lo){var oa;(oa=this.getActive())!=null&&oa.shouldGetKeyboardEvents()||cs._keyboardManager.exec(this,lo)}onEditingAction(lo){["undo","redo","delete","selectAll"].includes(lo.name)&&this[lo.name]()}setEditingState(lo){lo?(hI(this,uo,lb).call(this),hI(this,uo,w0).call(this),hI(this,uo,Z0).call(this),hI(this,uo,uc).call(this,{isEditing:aa(this,Qg)!==ig.AnnotationEditorType.NONE,isEmpty:hI(this,uo,vd).call(this),hasSomethingToUndo:aa(this,Xg).hasSomethingToUndo(),hasSomethingToRedo:aa(this,Xg).hasSomethingToRedo(),hasSelectedEditor:!1})):(hI(this,uo,p0).call(this),hI(this,uo,_d).call(this),hI(this,uo,f0).call(this),hI(this,uo,uc).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(lo){if(!aa(this,Rg)){fI(this,Rg,lo);for(const oa of aa(this,Rg))hI(this,uo,Nd).call(this,oa.defaultPropertiesToUpdate)}}getId(){return aa(this,Dg).getId()}get currentLayer(){return aa(this,vg).get(aa(this,Yg))}getLayer(lo){return aa(this,vg).get(lo)}get currentPageIndex(){return aa(this,Yg)}addLayer(lo){aa(this,vg).set(lo.pageIndex,lo),aa(this,zg)?lo.enable():lo.disable()}removeLayer(lo){aa(this,vg).delete(lo.pageIndex)}updateMode(lo,oa=null){if(aa(this,Qg)!==lo){if(fI(this,Qg,lo),lo===ig.AnnotationEditorType.NONE){this.setEditingState(!1),hI(this,uo,Ab).call(this);return}this.setEditingState(!0),hI(this,uo,Cb).call(this),this.unselectAll();for(const no of aa(this,vg).values())no.updateMode(lo);if(oa){for(const no of aa(this,Ng).values())if(no.annotationElementId===oa){this.setSelected(no),no.enterInEditMode();break}}}}updateToolbar(lo){lo!==aa(this,Qg)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:lo})}updateParams(lo,oa){if(aa(this,Rg)){if(lo===ig.AnnotationEditorParamsType.CREATE){this.currentLayer.addNewEditor(lo);return}for(const no of aa(this,eo))no.updateParams(lo,oa);for(const no of aa(this,Rg))no.updateDefaultParams(lo,oa)}}enableWaiting(lo=!1){if(aa(this,Og)!==lo){fI(this,Og,lo);for(const oa of aa(this,vg).values())lo?oa.disableClick():oa.enableClick(),oa.div.classList.toggle("waiting",lo)}}getEditors(lo){const oa=[];for(const no of aa(this,Ng).values())no.pageIndex===lo&&oa.push(no);return oa}getEditor(lo){return aa(this,Ng).get(lo)}addEditor(lo){aa(this,Ng).set(lo.id,lo)}removeEditor(lo){var oa;aa(this,Ng).delete(lo.id),this.unselect(lo),(!lo.annotationElementId||!aa(this,Hg).has(lo.annotationElementId))&&((oa=aa(this,Vg))==null||oa.remove(lo.id))}addDeletedAnnotationElement(lo){aa(this,Hg).add(lo.annotationElementId),lo.deleted=!0}isDeletedAnnotationElement(lo){return aa(this,Hg).has(lo)}removeDeletedAnnotationElement(lo){aa(this,Hg).delete(lo.annotationElementId),lo.deleted=!1}setActiveEditor(lo){aa(this,yg)!==lo&&(fI(this,yg,lo),lo&&hI(this,uo,Nd).call(this,lo.propertiesToUpdate))}toggleSelected(lo){if(aa(this,eo).has(lo)){aa(this,eo).delete(lo),lo.unselect(),hI(this,uo,uc).call(this,{hasSelectedEditor:this.hasSelection});return}aa(this,eo).add(lo),lo.select(),hI(this,uo,Nd).call(this,lo.propertiesToUpdate),hI(this,uo,uc).call(this,{hasSelectedEditor:!0})}setSelected(lo){for(const oa of aa(this,eo))oa!==lo&&oa.unselect();aa(this,eo).clear(),aa(this,eo).add(lo),lo.select(),hI(this,uo,Nd).call(this,lo.propertiesToUpdate),hI(this,uo,uc).call(this,{hasSelectedEditor:!0})}isSelected(lo){return aa(this,eo).has(lo)}unselect(lo){lo.unselect(),aa(this,eo).delete(lo),hI(this,uo,uc).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return aa(this,eo).size!==0}undo(){aa(this,Xg).undo(),hI(this,uo,uc).call(this,{hasSomethingToUndo:aa(this,Xg).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:hI(this,uo,vd).call(this)})}redo(){aa(this,Xg).redo(),hI(this,uo,uc).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:aa(this,Xg).hasSomethingToRedo(),isEmpty:hI(this,uo,vd).call(this)})}addCommands(lo){aa(this,Xg).add(lo),hI(this,uo,uc).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:hI(this,uo,vd).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const lo=[...aa(this,eo)],oa=()=>{for(const co of lo)co.remove()},no=()=>{for(const co of lo)hI(this,uo,G0).call(this,co)};this.addCommands({cmd:oa,undo:no,mustExec:!0})}commitOrRemove(){var lo;(lo=aa(this,yg))==null||lo.commitOrRemove()}hasSomethingToControl(){return aa(this,yg)||this.hasSelection}selectAll(){for(const lo of aa(this,eo))lo.commit();hI(this,uo,y0).call(this,aa(this,Ng).values())}unselectAll(){if(aa(this,yg)){aa(this,yg).commitOrRemove();return}if(this.hasSelection){for(const lo of aa(this,eo))lo.unselect();aa(this,eo).clear(),hI(this,uo,uc).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(lo,oa,no=!1){if(no||this.commitOrRemove(),!this.hasSelection)return;aa(this,da)[0]+=lo,aa(this,da)[1]+=oa;const[co,va]=aa(this,da),nI=[...aa(this,eo)],ga=1e3;aa(this,ya)&&clearTimeout(aa(this,ya)),fI(this,ya,setTimeout(()=>{fI(this,ya,null),aa(this,da)[0]=aa(this,da)[1]=0,this.addCommands({cmd:()=>{for(const _g of nI)aa(this,Ng).has(_g.id)&&_g.translateInPage(co,va)},undo:()=>{for(const _g of nI)aa(this,Ng).has(_g.id)&&_g.translateInPage(-co,-va)},mustExec:!1})},ga));for(const _g of nI)_g.translateInPage(lo,oa)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),fI(this,kg,new Map);for(const lo of aa(this,eo))aa(this,kg).set(lo,{savedX:lo.x,savedY:lo.y,savedPageIndex:lo.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!aa(this,kg))return!1;this.disableUserSelect(!1);const lo=aa(this,kg);fI(this,kg,null);let oa=!1;for(const[{x:co,y:va,pageIndex:nI},ga]of lo)ga.newX=co,ga.newY=va,ga.newPageIndex=nI,oa||(oa=co!==ga.savedX||va!==ga.savedY||nI!==ga.savedPageIndex);if(!oa)return!1;const no=(co,va,nI,ga)=>{if(aa(this,Ng).has(co.id)){const _g=aa(this,vg).get(ga);_g?co._setParentAndPosition(_g,va,nI):(co.pageIndex=ga,co.x=va,co.y=nI)}};return this.addCommands({cmd:()=>{for(const[co,{newX:va,newY:nI,newPageIndex:ga}]of lo)no(co,va,nI,ga)},undo:()=>{for(const[co,{savedX:va,savedY:nI,savedPageIndex:ga}]of lo)no(co,va,nI,ga)},mustExec:!0}),!0}dragSelectedEditors(lo,oa){if(aa(this,kg))for(const no of aa(this,kg).keys())no.drag(lo,oa)}rebuild(lo){if(lo.parent===null){const oa=this.getLayer(lo.pageIndex);oa?(oa.changeParent(lo),oa.addOrRebuild(lo)):(this.addEditor(lo),this.addToAnnotationStorage(lo),lo.rebuild())}else lo.parent.addOrRebuild(lo)}isActive(lo){return aa(this,yg)===lo}getActive(){return aa(this,yg)}getMode(){return aa(this,Qg)}get imageManager(){return(0,ig.shadow)(this,"imageManager",new Ig)}};yg=new WeakMap,Ng=new WeakMap,vg=new WeakMap,Sg=new WeakMap,Vg=new WeakMap,Xg=new WeakMap,Yg=new WeakMap,Hg=new WeakMap,kg=new WeakMap,Rg=new WeakMap,Kg=new WeakMap,jg=new WeakMap,Dg=new WeakMap,zg=new WeakMap,Og=new WeakMap,Jg=new WeakMap,Qg=new WeakMap,eo=new WeakMap,ca=new WeakMap,ua=new WeakMap,pa=new WeakMap,is=new WeakMap,Pg=new WeakMap,la=new WeakMap,ma=new WeakMap,Ca=new WeakMap,Eg=new WeakMap,Mg=new WeakMap,Tg=new WeakMap,Ug=new WeakMap,da=new WeakMap,ya=new WeakMap,eI=new WeakMap,us=new WeakMap,uo=new WeakSet,lb=function(){window.addEventListener("focus",aa(this,pa)),window.addEventListener("blur",aa(this,ua))},p0=function(){window.removeEventListener("focus",aa(this,pa)),window.removeEventListener("blur",aa(this,ua))},w0=function(){window.addEventListener("keydown",aa(this,ma),{capture:!0})},_d=function(){window.removeEventListener("keydown",aa(this,ma),{capture:!0})},Z0=function(){document.addEventListener("copy",aa(this,is)),document.addEventListener("cut",aa(this,Pg)),document.addEventListener("paste",aa(this,la))},f0=function(){document.removeEventListener("copy",aa(this,is)),document.removeEventListener("cut",aa(this,Pg)),document.removeEventListener("paste",aa(this,la))},uc=function(lo){Object.entries(lo).some(([no,co])=>aa(this,Ug)[no]!==co)&&this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(aa(this,Ug),lo)})},Nd=function(lo){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:lo})},Cb=function(){if(!aa(this,zg)){fI(this,zg,!0);for(const lo of aa(this,vg).values())lo.enable()}},Ab=function(){if(this.unselectAll(),aa(this,zg)){fI(this,zg,!1);for(const lo of aa(this,vg).values())lo.disable()}},G0=function(lo){const oa=aa(this,vg).get(lo.pageIndex);oa?oa.addOrRebuild(lo):this.addEditor(lo)},vd=function(){if(aa(this,Ng).size===0)return!0;if(aa(this,Ng).size===1)for(const lo of aa(this,Ng).values())return lo.isEmpty();return!1},y0=function(lo){aa(this,eo).clear();for(const oa of lo)oa.isEmpty()||(aa(this,eo).add(oa),oa.select());hI(this,uo,uc).call(this,{hasSelectedEditor:!0})},UI(cs,"TRANSLATE_SMALL",1),UI(cs,"TRANSLATE_BIG",10);let rg=cs;eg.AnnotationEditorUIManager=rg}),((tg,eg,gg)=>{var Yg,Hg,kg,Rg,Kg,jg,Dg,zg,Og,Jg,Qg,eo,ld,Cd,$0,Qd,Ud,Vd,Yd;Object.defineProperty(eg,"__esModule",{value:!0}),eg.StatTimer=eg.RenderingCancelledException=eg.PixelsPerInch=eg.PageViewport=eg.PDFDateString=eg.DOMStandardFontDataFactory=eg.DOMSVGFactory=eg.DOMFilterFactory=eg.DOMCanvasFactory=eg.DOMCMapReaderFactory=void 0,eg.deprecated=Zg,eg.getColorValues=Ng,eg.getCurrentTransform=vg,eg.getCurrentTransformInverse=Sg,eg.getFilenameFromUrl=mg,eg.getPdfFilenameFromUrl=bg,eg.getRGB=yg,eg.getXfaPageViewport=Wg,eg.isDataScheme=dg,eg.isPdfFile=hg,eg.isValidFetchUrl=fg,eg.loadScript=Gg,eg.noContextMenu=wg,eg.setLayerDimensions=Vg;var ig=gg(7),ng=gg(1);const og="http://www.w3.org/2000/svg",Xg=class Xg{};UI(Xg,"CSS",96),UI(Xg,"PDF",72),UI(Xg,"PDF_TO_CSS_UNITS",Xg.CSS/Xg.PDF);let ag=Xg;eg.PixelsPerInch=ag;class sg extends ig.BaseFilterFactory{constructor({docId:Mg,ownerDocument:Tg=globalThis.document}={}){super();ZI(this,eo);ZI(this,Yg);ZI(this,Hg);ZI(this,kg);ZI(this,Rg);ZI(this,Kg);ZI(this,jg);ZI(this,Dg);ZI(this,zg);ZI(this,Og);ZI(this,Jg);ZI(this,Qg,0);fI(this,kg,Mg),fI(this,Rg,Tg)}addFilter(Mg){if(!Mg)return"none";let Tg=aa(this,eo,ld).get(Mg);if(Tg)return Tg;let Ug,da,ya,eI;if(Mg.length===1){const tI=Mg[0],AI=new Array(256);for(let rI=0;rI<256;rI++)AI[rI]=tI[rI]/255;eI=Ug=da=ya=AI.join(",")}else{const[tI,AI,rI]=Mg,gI=new Array(256),qg=new Array(256),xa=new Array(256);for(let iI=0;iI<256;iI++)gI[iI]=tI[iI]/255,qg[iI]=AI[iI]/255,xa[iI]=rI[iI]/255;Ug=gI.join(","),da=qg.join(","),ya=xa.join(","),eI=`${Ug}${da}${ya}`}if(Tg=aa(this,eo,ld).get(eI),Tg)return aa(this,eo,ld).set(Mg,Tg),Tg;const us=`g_${aa(this,kg)}_transfer_map_${Wd(this,Qg)._++}`,uo=`url(#${us})`;aa(this,eo,ld).set(Mg,uo),aa(this,eo,ld).set(eI,uo);const ha=hI(this,eo,Qd).call(this,us);return hI(this,eo,Vd).call(this,Ug,da,ya,ha),uo}addHCMFilter(Mg,Tg){var AI;const Ug=`${Mg}-${Tg}`;if(aa(this,jg)===Ug)return aa(this,Dg);if(fI(this,jg,Ug),fI(this,Dg,"none"),(AI=aa(this,Kg))==null||AI.remove(),!Mg||!Tg)return aa(this,Dg);const da=hI(this,eo,Yd).call(this,Mg);Mg=ng.Util.makeHexColor(...da);const ya=hI(this,eo,Yd).call(this,Tg);if(Tg=ng.Util.makeHexColor(...ya),aa(this,eo,Cd).style.color="",Mg==="#000000"&&Tg==="#ffffff"||Mg===Tg)return aa(this,Dg);const eI=new Array(256);for(let rI=0;rI<=255;rI++){const gI=rI/255;eI[rI]=gI<=.03928?gI/12.92:((gI+.055)/1.055)**2.4}const us=eI.join(","),uo=`g_${aa(this,kg)}_hcm_filter`,ha=fI(this,zg,hI(this,eo,Qd).call(this,uo));hI(this,eo,Vd).call(this,us,us,us,ha),hI(this,eo,$0).call(this,ha);const tI=(rI,gI)=>{const qg=da[rI]/255,xa=ya[rI]/255,iI=new Array(gI+1);for(let sI=0;sI<=gI;sI++)iI[sI]=qg+sI/gI*(xa-qg);return iI.join(",")};return hI(this,eo,Vd).call(this,tI(0,5),tI(1,5),tI(2,5),ha),fI(this,Dg,`url(#${uo})`),aa(this,Dg)}addHighlightHCMFilter(Mg,Tg,Ug,da){var xa;const ya=`${Mg}-${Tg}-${Ug}-${da}`;if(aa(this,Og)===ya)return aa(this,Jg);if(fI(this,Og,ya),fI(this,Jg,"none"),(xa=aa(this,zg))==null||xa.remove(),!Mg||!Tg)return aa(this,Jg);const[eI,us]=[Mg,Tg].map(hI(this,eo,Yd).bind(this));let uo=Math.round(.2126*eI[0]+.7152*eI[1]+.0722*eI[2]),ha=Math.round(.2126*us[0]+.7152*us[1]+.0722*us[2]),[tI,AI]=[Ug,da].map(hI(this,eo,Yd).bind(this));ha<uo&&([uo,ha,tI,AI]=[ha,uo,AI,tI]),aa(this,eo,Cd).style.color="";const rI=(iI,sI,fa)=>{const Lg=new Array(256),Fg=(ha-uo)/fa,sa=iI/255,cs=(sI-iI)/(255*fa);let xg=0;for(let lo=0;lo<=fa;lo++){const oa=Math.round(uo+lo*Fg),no=sa+lo*cs;for(let co=xg;co<=oa;co++)Lg[co]=no;xg=oa+1}for(let lo=xg;lo<256;lo++)Lg[lo]=Lg[xg-1];return Lg.join(",")},gI=`g_${aa(this,kg)}_hcm_highlight_filter`,qg=fI(this,zg,hI(this,eo,Qd).call(this,gI));return hI(this,eo,$0).call(this,qg),hI(this,eo,Vd).call(this,rI(tI[0],AI[0],5),rI(tI[1],AI[1],5),rI(tI[2],AI[2],5),qg),fI(this,Jg,`url(#${gI})`),aa(this,Jg)}destroy(Mg=!1){Mg&&(aa(this,Dg)||aa(this,Jg))||(aa(this,Hg)&&(aa(this,Hg).parentNode.parentNode.remove(),fI(this,Hg,null)),aa(this,Yg)&&(aa(this,Yg).clear(),fI(this,Yg,null)),fI(this,Qg,0))}}Yg=new WeakMap,Hg=new WeakMap,kg=new WeakMap,Rg=new WeakMap,Kg=new WeakMap,jg=new WeakMap,Dg=new WeakMap,zg=new WeakMap,Og=new WeakMap,Jg=new WeakMap,Qg=new WeakMap,eo=new WeakSet,ld=function(){return aa(this,Yg)||fI(this,Yg,new Map)},Cd=function(){if(!aa(this,Hg)){const Mg=aa(this,Rg).createElement("div"),{style:Tg}=Mg;Tg.visibility="hidden",Tg.contain="strict",Tg.width=Tg.height=0,Tg.position="absolute",Tg.top=Tg.left=0,Tg.zIndex=-1;const Ug=aa(this,Rg).createElementNS(og,"svg");Ug.setAttribute("width",0),Ug.setAttribute("height",0),fI(this,Hg,aa(this,Rg).createElementNS(og,"defs")),Mg.append(Ug),Ug.append(aa(this,Hg)),aa(this,Rg).body.append(Mg)}return aa(this,Hg)},$0=function(Mg){const Tg=aa(this,Rg).createElementNS(og,"feColorMatrix");Tg.setAttribute("type","matrix"),Tg.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),Mg.append(Tg)},Qd=function(Mg){const Tg=aa(this,Rg).createElementNS(og,"filter");return Tg.setAttribute("color-interpolation-filters","sRGB"),Tg.setAttribute("id",Mg),aa(this,eo,Cd).append(Tg),Tg},Ud=function(Mg,Tg,Ug){const da=aa(this,Rg).createElementNS(og,Tg);da.setAttribute("type","discrete"),da.setAttribute("tableValues",Ug),Mg.append(da)},Vd=function(Mg,Tg,Ug,da){const ya=aa(this,Rg).createElementNS(og,"feComponentTransfer");da.append(ya),hI(this,eo,Ud).call(this,ya,"feFuncR",Mg),hI(this,eo,Ud).call(this,ya,"feFuncG",Tg),hI(this,eo,Ud).call(this,ya,"feFuncB",Ug)},Yd=function(Mg){return aa(this,eo,Cd).style.color=Mg,yg(getComputedStyle(aa(this,eo,Cd)).getPropertyValue("color"))},eg.DOMFilterFactory=sg;class Ig extends ig.BaseCanvasFactory{constructor({ownerDocument:Eg=globalThis.document}={}){super(),this._document=Eg}_createCanvas(Eg,Mg){const Tg=this._document.createElement("canvas");return Tg.width=Eg,Tg.height=Mg,Tg}}eg.DOMCanvasFactory=Ig;async function Cg(Ca,Eg=!1){if(fg(Ca,document.baseURI)){const Mg=await fetch(Ca);if(!Mg.ok)throw new Error(Mg.statusText);return Eg?new Uint8Array(await Mg.arrayBuffer()):(0,ng.stringToBytes)(await Mg.text())}return new Promise((Mg,Tg)=>{const Ug=new XMLHttpRequest;Ug.open("GET",Ca,!0),Eg&&(Ug.responseType="arraybuffer"),Ug.onreadystatechange=()=>{if(Ug.readyState===XMLHttpRequest.DONE){if(Ug.status===200||Ug.status===0){let da;if(Eg&&Ug.response?da=new Uint8Array(Ug.response):!Eg&&Ug.responseText&&(da=(0,ng.stringToBytes)(Ug.responseText)),da){Mg(da);return}}Tg(new Error(Ug.statusText))}},Ug.send(null)})}class lg extends ig.BaseCMapReaderFactory{_fetchData(Eg,Mg){return Cg(Eg,this.isCompressed).then(Tg=>({cMapData:Tg,compressionType:Mg}))}}eg.DOMCMapReaderFactory=lg;class Ag extends ig.BaseStandardFontDataFactory{_fetchData(Eg){return Cg(Eg,!0)}}eg.DOMStandardFontDataFactory=Ag;class rg extends ig.BaseSVGFactory{_createSVG(Eg){return document.createElementNS(og,Eg)}}eg.DOMSVGFactory=rg;class cg{constructor({viewBox:Eg,scale:Mg,rotation:Tg,offsetX:Ug=0,offsetY:da=0,dontFlip:ya=!1}){this.viewBox=Eg,this.scale=Mg,this.rotation=Tg,this.offsetX=Ug,this.offsetY=da;const eI=(Eg[2]+Eg[0])/2,us=(Eg[3]+Eg[1])/2;let uo,ha,tI,AI;switch(Tg%=360,Tg<0&&(Tg+=360),Tg){case 180:uo=-1,ha=0,tI=0,AI=1;break;case 90:uo=0,ha=1,tI=1,AI=0;break;case 270:uo=0,ha=-1,tI=-1,AI=0;break;case 0:uo=1,ha=0,tI=0,AI=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}ya&&(tI=-tI,AI=-AI);let rI,gI,qg,xa;uo===0?(rI=Math.abs(us-Eg[1])*Mg+Ug,gI=Math.abs(eI-Eg[0])*Mg+da,qg=(Eg[3]-Eg[1])*Mg,xa=(Eg[2]-Eg[0])*Mg):(rI=Math.abs(eI-Eg[0])*Mg+Ug,gI=Math.abs(us-Eg[1])*Mg+da,qg=(Eg[2]-Eg[0])*Mg,xa=(Eg[3]-Eg[1])*Mg),this.transform=[uo*Mg,ha*Mg,tI*Mg,AI*Mg,rI-uo*Mg*eI-tI*Mg*us,gI-ha*Mg*eI-AI*Mg*us],this.width=qg,this.height=xa}get rawDims(){const{viewBox:Eg}=this;return(0,ng.shadow)(this,"rawDims",{pageWidth:Eg[2]-Eg[0],pageHeight:Eg[3]-Eg[1],pageX:Eg[0],pageY:Eg[1]})}clone({scale:Eg=this.scale,rotation:Mg=this.rotation,offsetX:Tg=this.offsetX,offsetY:Ug=this.offsetY,dontFlip:da=!1}={}){return new cg({viewBox:this.viewBox.slice(),scale:Eg,rotation:Mg,offsetX:Tg,offsetY:Ug,dontFlip:da})}convertToViewportPoint(Eg,Mg){return ng.Util.applyTransform([Eg,Mg],this.transform)}convertToViewportRectangle(Eg){const Mg=ng.Util.applyTransform([Eg[0],Eg[1]],this.transform),Tg=ng.Util.applyTransform([Eg[2],Eg[3]],this.transform);return[Mg[0],Mg[1],Tg[0],Tg[1]]}convertToPdfPoint(Eg,Mg){return ng.Util.applyInverseTransform([Eg,Mg],this.transform)}}eg.PageViewport=cg;class ug extends ng.BaseException{constructor(Eg,Mg=0){super(Eg,"RenderingCancelledException"),this.extraDelay=Mg}}eg.RenderingCancelledException=ug;function dg(Ca){const Eg=Ca.length;let Mg=0;for(;Mg<Eg&&Ca[Mg].trim()==="";)Mg++;return Ca.substring(Mg,Mg+5).toLowerCase()==="data:"}function hg(Ca){return typeof Ca=="string"&&/\.pdf$/i.test(Ca)}function mg(Ca,Eg=!1){return Eg||([Ca]=Ca.split(/[#?]/,1)),Ca.substring(Ca.lastIndexOf("/")+1)}function bg(Ca,Eg="document.pdf"){if(typeof Ca!="string")return Eg;if(dg(Ca))return(0,ng.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),Eg;const Mg=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,Tg=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,Ug=Mg.exec(Ca);let da=Tg.exec(Ug[1])||Tg.exec(Ug[2])||Tg.exec(Ug[3]);if(da&&(da=da[0],da.includes("%")))try{da=Tg.exec(decodeURIComponent(da))[0]}catch{}return da||Eg}class pg{constructor(){UI(this,"started",Object.create(null));UI(this,"times",[])}time(Eg){Eg in this.started&&(0,ng.warn)(`Timer is already running for ${Eg}`),this.started[Eg]=Date.now()}timeEnd(Eg){Eg in this.started||(0,ng.warn)(`Timer has not been started for ${Eg}`),this.times.push({name:Eg,start:this.started[Eg],end:Date.now()}),delete this.started[Eg]}toString(){const Eg=[];let Mg=0;for(const{name:Tg}of this.times)Mg=Math.max(Tg.length,Mg);for(const{name:Tg,start:Ug,end:da}of this.times)Eg.push(`${Tg.padEnd(Mg)} ${da-Ug}ms
|
|
961
961
|
`);return Eg.join("")}}eg.StatTimer=pg;function fg(Ca,Eg){try{const{protocol:Mg}=Eg?new URL(Ca,Eg):new URL(Ca);return Mg==="http:"||Mg==="https:"}catch{return!1}}function wg(Ca){Ca.preventDefault()}function Gg(Ca,Eg=!1){return new Promise((Mg,Tg)=>{const Ug=document.createElement("script");Ug.src=Ca,Ug.onload=function(da){Eg&&Ug.remove(),Mg(da)},Ug.onerror=function(){Tg(new Error(`Cannot load script at: ${Ug.src}`))},(document.head||document.documentElement).append(Ug)})}function Zg(Ca){console.log("Deprecated API usage: "+Ca)}let $g;class Bg{static toDateObject(Eg){if(!Eg||typeof Eg!="string")return null;$g||($g=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const Mg=$g.exec(Eg);if(!Mg)return null;const Tg=parseInt(Mg[1],10);let Ug=parseInt(Mg[2],10);Ug=Ug>=1&&Ug<=12?Ug-1:0;let da=parseInt(Mg[3],10);da=da>=1&&da<=31?da:1;let ya=parseInt(Mg[4],10);ya=ya>=0&&ya<=23?ya:0;let eI=parseInt(Mg[5],10);eI=eI>=0&&eI<=59?eI:0;let us=parseInt(Mg[6],10);us=us>=0&&us<=59?us:0;const uo=Mg[7]||"Z";let ha=parseInt(Mg[8],10);ha=ha>=0&&ha<=23?ha:0;let tI=parseInt(Mg[9],10)||0;return tI=tI>=0&&tI<=59?tI:0,uo==="-"?(ya+=ha,eI+=tI):uo==="+"&&(ya-=ha,eI-=tI),new Date(Date.UTC(Tg,Ug,da,ya,eI,us))}}eg.PDFDateString=Bg;function Wg(Ca,{scale:Eg=1,rotation:Mg=0}){const{width:Tg,height:Ug}=Ca.attributes.style,da=[0,0,parseInt(Tg),parseInt(Ug)];return new cg({viewBox:da,scale:Eg,rotation:Mg})}function yg(Ca){if(Ca.startsWith("#")){const Eg=parseInt(Ca.slice(1),16);return[(Eg&16711680)>>16,(Eg&65280)>>8,Eg&255]}return Ca.startsWith("rgb(")?Ca.slice(4,-1).split(",").map(Eg=>parseInt(Eg)):Ca.startsWith("rgba(")?Ca.slice(5,-1).split(",").map(Eg=>parseInt(Eg)).slice(0,3):((0,ng.warn)(`Not a valid color format: "${Ca}"`),[0,0,0])}function Ng(Ca){const Eg=document.createElement("span");Eg.style.visibility="hidden",document.body.append(Eg);for(const Mg of Ca.keys()){Eg.style.color=Mg;const Tg=window.getComputedStyle(Eg).color;Ca.set(Mg,yg(Tg))}Eg.remove()}function vg(Ca){const{a:Eg,b:Mg,c:Tg,d:Ug,e:da,f:ya}=Ca.getTransform();return[Eg,Mg,Tg,Ug,da,ya]}function Sg(Ca){const{a:Eg,b:Mg,c:Tg,d:Ug,e:da,f:ya}=Ca.getTransform().invertSelf();return[Eg,Mg,Tg,Ug,da,ya]}function Vg(Ca,Eg,Mg=!1,Tg=!0){if(Eg instanceof cg){const{pageWidth:Ug,pageHeight:da}=Eg.rawDims,{style:ya}=Ca,eI=ng.FeatureTest.isCSSRoundSupported,us=`var(--scale-factor) * ${Ug}px`,uo=`var(--scale-factor) * ${da}px`,ha=eI?`round(${us}, 1px)`:`calc(${us})`,tI=eI?`round(${uo}, 1px)`:`calc(${uo})`;!Mg||Eg.rotation%180===0?(ya.width=ha,ya.height=tI):(ya.width=tI,ya.height=ha)}Tg&&Ca.setAttribute("data-main-rotation",Eg.rotation)}}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.BaseStandardFontDataFactory=eg.BaseSVGFactory=eg.BaseFilterFactory=eg.BaseCanvasFactory=eg.BaseCMapReaderFactory=void 0;var ig=gg(1);class ng{constructor(){this.constructor===ng&&(0,ig.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(lg){return"none"}addHCMFilter(lg,Ag){return"none"}addHighlightHCMFilter(lg,Ag,rg,cg){return"none"}destroy(lg=!1){}}eg.BaseFilterFactory=ng;class og{constructor(){this.constructor===og&&(0,ig.unreachable)("Cannot initialize BaseCanvasFactory.")}create(lg,Ag){if(lg<=0||Ag<=0)throw new Error("Invalid canvas size");const rg=this._createCanvas(lg,Ag);return{canvas:rg,context:rg.getContext("2d")}}reset(lg,Ag,rg){if(!lg.canvas)throw new Error("Canvas is not specified");if(Ag<=0||rg<=0)throw new Error("Invalid canvas size");lg.canvas.width=Ag,lg.canvas.height=rg}destroy(lg){if(!lg.canvas)throw new Error("Canvas is not specified");lg.canvas.width=0,lg.canvas.height=0,lg.canvas=null,lg.context=null}_createCanvas(lg,Ag){(0,ig.unreachable)("Abstract method `_createCanvas` called.")}}eg.BaseCanvasFactory=og;class ag{constructor({baseUrl:lg=null,isCompressed:Ag=!0}){this.constructor===ag&&(0,ig.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=lg,this.isCompressed=Ag}async fetch({name:lg}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!lg)throw new Error("CMap name must be specified.");const Ag=this.baseUrl+lg+(this.isCompressed?".bcmap":""),rg=this.isCompressed?ig.CMapCompressionType.BINARY:ig.CMapCompressionType.NONE;return this._fetchData(Ag,rg).catch(cg=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${Ag}`)})}_fetchData(lg,Ag){(0,ig.unreachable)("Abstract method `_fetchData` called.")}}eg.BaseCMapReaderFactory=ag;class sg{constructor({baseUrl:lg=null}){this.constructor===sg&&(0,ig.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=lg}async fetch({filename:lg}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!lg)throw new Error("Font filename must be specified.");const Ag=`${this.baseUrl}${lg}`;return this._fetchData(Ag).catch(rg=>{throw new Error(`Unable to load font data at: ${Ag}`)})}_fetchData(lg){(0,ig.unreachable)("Abstract method `_fetchData` called.")}}eg.BaseStandardFontDataFactory=sg;class Ig{constructor(){this.constructor===Ig&&(0,ig.unreachable)("Cannot initialize BaseSVGFactory.")}create(lg,Ag,rg=!1){if(lg<=0||Ag<=0)throw new Error("Invalid SVG dimensions");const cg=this._createSVG("svg:svg");return cg.setAttribute("version","1.1"),rg||(cg.setAttribute("width",`${lg}px`),cg.setAttribute("height",`${Ag}px`)),cg.setAttribute("preserveAspectRatio","none"),cg.setAttribute("viewBox",`0 0 ${lg} ${Ag}`),cg}createElement(lg){if(typeof lg!="string")throw new Error("Invalid SVG element type");return this._createSVG(lg)}_createSVG(lg){(0,ig.unreachable)("Abstract method `_createSVG` called.")}}eg.BaseSVGFactory=Ig}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.MurmurHash3_64=void 0;var ig=gg(1);const ng=3285377520,og=4294901760,ag=65535;class sg{constructor(Cg){this.h1=Cg?Cg&4294967295:ng,this.h2=Cg?Cg&4294967295:ng}update(Cg){let lg,Ag;if(typeof Cg=="string"){lg=new Uint8Array(Cg.length*2),Ag=0;for(let Zg=0,$g=Cg.length;Zg<$g;Zg++){const Bg=Cg.charCodeAt(Zg);Bg<=255?lg[Ag++]=Bg:(lg[Ag++]=Bg>>>8,lg[Ag++]=Bg&255)}}else if((0,ig.isArrayBuffer)(Cg))lg=Cg.slice(),Ag=lg.byteLength;else throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");const rg=Ag>>2,cg=Ag-rg*4,ug=new Uint32Array(lg.buffer,0,rg);let dg=0,hg=0,mg=this.h1,bg=this.h2;const pg=3432918353,fg=461845907,wg=pg&ag,Gg=fg&ag;for(let Zg=0;Zg<rg;Zg++)Zg&1?(dg=ug[Zg],dg=dg*pg&og|dg*wg&ag,dg=dg<<15|dg>>>17,dg=dg*fg&og|dg*Gg&ag,mg^=dg,mg=mg<<13|mg>>>19,mg=mg*5+3864292196):(hg=ug[Zg],hg=hg*pg&og|hg*wg&ag,hg=hg<<15|hg>>>17,hg=hg*fg&og|hg*Gg&ag,bg^=hg,bg=bg<<13|bg>>>19,bg=bg*5+3864292196);switch(dg=0,cg){case 3:dg^=lg[rg*4+2]<<16;case 2:dg^=lg[rg*4+1]<<8;case 1:dg^=lg[rg*4],dg=dg*pg&og|dg*wg&ag,dg=dg<<15|dg>>>17,dg=dg*fg&og|dg*Gg&ag,rg&1?mg^=dg:bg^=dg}this.h1=mg,this.h2=bg}hexdigest(){let Cg=this.h1,lg=this.h2;return Cg^=lg>>>1,Cg=Cg*3981806797&og|Cg*36045&ag,lg=lg*4283543511&og|((lg<<16|Cg>>>16)*2950163797&og)>>>16,Cg^=lg>>>1,Cg=Cg*444984403&og|Cg*60499&ag,lg=lg*3301882366&og|((lg<<16|Cg>>>16)*3120437893&og)>>>16,Cg^=lg>>>1,(Cg>>>0).toString(16).padStart(8,"0")+(lg>>>0).toString(16).padStart(8,"0")}}eg.MurmurHash3_64=sg}),((tg,eg,gg)=>{var ag;Object.defineProperty(eg,"__esModule",{value:!0}),eg.FontLoader=eg.FontFaceObject=void 0;var ig=gg(1);class ng{constructor({ownerDocument:Ig=globalThis.document,styleElement:Cg=null}){ZI(this,ag,new Set);this._document=Ig,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(Ig){this.nativeFontFaces.add(Ig),this._document.fonts.add(Ig)}removeNativeFontFace(Ig){this.nativeFontFaces.delete(Ig),this._document.fonts.delete(Ig)}insertRule(Ig){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const Cg=this.styleElement.sheet;Cg.insertRule(Ig,Cg.cssRules.length)}clear(){for(const Ig of this.nativeFontFaces)this._document.fonts.delete(Ig);this.nativeFontFaces.clear(),aa(this,ag).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont(Ig){if(!(!Ig||aa(this,ag).has(Ig.loadedName))){if((0,ig.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:Cg,src:lg,style:Ag}=Ig,rg=new FontFace(Cg,lg,Ag);this.addNativeFontFace(rg);try{await rg.load(),aa(this,ag).add(Cg)}catch{(0,ig.warn)(`Cannot load system font: ${Ig.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(rg)}return}(0,ig.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(Ig){if(Ig.attached||Ig.missingFile&&!Ig.systemFontInfo)return;if(Ig.attached=!0,Ig.systemFontInfo){await this.loadSystemFont(Ig.systemFontInfo);return}if(this.isFontLoadingAPISupported){const lg=Ig.createNativeFontFace();if(lg){this.addNativeFontFace(lg);try{await lg.loaded}catch(Ag){throw(0,ig.warn)(`Failed to load font '${lg.family}': '${Ag}'.`),Ig.disableFontFace=!0,Ag}}return}const Cg=Ig.createFontFaceRule();if(Cg){if(this.insertRule(Cg),this.isSyncFontLoadingSupported)return;await new Promise(lg=>{const Ag=this._queueLoadingCallback(lg);this._prepareFontLoadEvent(Ig,Ag)})}}get isFontLoadingAPISupported(){var Cg;const Ig=!!((Cg=this._document)!=null&&Cg.fonts);return(0,ig.shadow)(this,"isFontLoadingAPISupported",Ig)}get isSyncFontLoadingSupported(){let Ig=!1;return(ig.isNodeJS||typeof navigator<"u"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(Ig=!0),(0,ig.shadow)(this,"isSyncFontLoadingSupported",Ig)}_queueLoadingCallback(Ig){function Cg(){for((0,ig.assert)(!Ag.done,"completeRequest() cannot be called twice."),Ag.done=!0;lg.length>0&&lg[0].done;){const rg=lg.shift();setTimeout(rg.callback,0)}}const{loadingRequests:lg}=this,Ag={done:!1,complete:Cg,callback:Ig};return lg.push(Ag),Ag}get _loadTestFont(){const Ig=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,ig.shadow)(this,"_loadTestFont",Ig)}_prepareFontLoadEvent(Ig,Cg){function lg(yg,Ng){return yg.charCodeAt(Ng)<<24|yg.charCodeAt(Ng+1)<<16|yg.charCodeAt(Ng+2)<<8|yg.charCodeAt(Ng+3)&255}function Ag(yg,Ng,vg,Sg){const Vg=yg.substring(0,Ng),Xg=yg.substring(Ng+vg);return Vg+Sg+Xg}let rg,cg;const ug=this._document.createElement("canvas");ug.width=1,ug.height=1;const dg=ug.getContext("2d");let hg=0;function mg(yg,Ng){if(++hg>30){(0,ig.warn)("Load test font never loaded."),Ng();return}if(dg.font="30px "+yg,dg.fillText(".",0,20),dg.getImageData(0,0,1,1).data[3]>0){Ng();return}setTimeout(mg.bind(null,yg,Ng))}const bg=`lt${Date.now()}${this.loadTestFontId++}`;let pg=this._loadTestFont;pg=Ag(pg,976,bg.length,bg);const wg=16,Gg=1482184792;let Zg=lg(pg,wg);for(rg=0,cg=bg.length-3;rg<cg;rg+=4)Zg=Zg-Gg+lg(bg,rg)|0;rg<bg.length&&(Zg=Zg-Gg+lg(bg+"XXX",rg)|0),pg=Ag(pg,wg,4,(0,ig.string32)(Zg));const $g=`url(data:font/opentype;base64,${btoa(pg)});`,Bg=`@font-face {font-family:"${bg}";src:${$g}}`;this.insertRule(Bg);const Wg=this._document.createElement("div");Wg.style.visibility="hidden",Wg.style.width=Wg.style.height="10px",Wg.style.position="absolute",Wg.style.top=Wg.style.left="0px";for(const yg of[Ig.loadedName,bg]){const Ng=this._document.createElement("span");Ng.textContent="Hi",Ng.style.fontFamily=yg,Wg.append(Ng)}this._document.body.append(Wg),mg(bg,()=>{Wg.remove(),Cg.complete()})}}ag=new WeakMap,eg.FontLoader=ng;class og{constructor(Ig,{isEvalSupported:Cg=!0,disableFontFace:lg=!1,ignoreErrors:Ag=!1,inspectFont:rg=null}){this.compiledGlyphs=Object.create(null);for(const cg in Ig)this[cg]=Ig[cg];this.isEvalSupported=Cg!==!1,this.disableFontFace=lg===!0,this.ignoreErrors=Ag===!0,this._inspectFont=rg}createNativeFontFace(){var Cg;if(!this.data||this.disableFontFace)return null;let Ig;if(!this.cssFontInfo)Ig=new FontFace(this.loadedName,this.data,{});else{const lg={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(lg.style=`oblique ${this.cssFontInfo.italicAngle}deg`),Ig=new FontFace(this.cssFontInfo.fontFamily,this.data,lg)}return(Cg=this._inspectFont)==null||Cg.call(this,this),Ig}createFontFaceRule(){var Ag;if(!this.data||this.disableFontFace)return null;const Ig=(0,ig.bytesToString)(this.data),Cg=`url(data:${this.mimetype};base64,${btoa(Ig)});`;let lg;if(!this.cssFontInfo)lg=`@font-face {font-family:"${this.loadedName}";src:${Cg}}`;else{let rg=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(rg+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),lg=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${rg}src:${Cg}}`}return(Ag=this._inspectFont)==null||Ag.call(this,this,Cg),lg}getPathGenerator(Ig,Cg){if(this.compiledGlyphs[Cg]!==void 0)return this.compiledGlyphs[Cg];let lg;try{lg=Ig.get(this.loadedName+"_path_"+Cg)}catch(Ag){if(!this.ignoreErrors)throw Ag;return(0,ig.warn)(`getPathGenerator - ignoring character: "${Ag}".`),this.compiledGlyphs[Cg]=function(rg,cg){}}if(this.isEvalSupported&&ig.FeatureTest.isEvalSupported){const Ag=[];for(const rg of lg){const cg=rg.args!==void 0?rg.args.join(","):"";Ag.push("c.",rg.cmd,"(",cg,`);
|
|
962
962
|
`)}return this.compiledGlyphs[Cg]=new Function("c","size",Ag.join(""))}return this.compiledGlyphs[Cg]=function(Ag,rg){for(const cg of lg)cg.cmd==="scale"&&(cg.args=[rg,-rg]),Ag[cg.cmd].apply(Ag,cg.args)}}}eg.FontFaceObject=og}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.NodeStandardFontDataFactory=eg.NodeFilterFactory=eg.NodeCanvasFactory=eg.NodeCMapReaderFactory=void 0;var ig=gg(7);gg(1);const ng=function(Cg){return new Promise((lg,Ag)=>{require$$5.readFile(Cg,(cg,ug)=>{if(cg||!ug){Ag(new Error(cg));return}lg(new Uint8Array(ug))})})};class og extends ig.BaseFilterFactory{}eg.NodeFilterFactory=og;class ag extends ig.BaseCanvasFactory{_createCanvas(lg,Ag){return require$$5.createCanvas(lg,Ag)}}eg.NodeCanvasFactory=ag;class sg extends ig.BaseCMapReaderFactory{_fetchData(lg,Ag){return ng(lg).then(rg=>({cMapData:rg,compressionType:Ag}))}}eg.NodeCMapReaderFactory=sg;class Ig extends ig.BaseStandardFontDataFactory{_fetchData(lg){return ng(lg)}}eg.NodeStandardFontDataFactory=Ig}),((tg,eg,gg)=>{var Hg,B0,W0;Object.defineProperty(eg,"__esModule",{value:!0}),eg.CanvasGraphics=void 0;var ig=gg(1),ng=gg(6),og=gg(12),ag=gg(13);const sg=16,Ig=100,Cg=4096,lg=15,Ag=10,rg=1e3,cg=16;function ug(jg,Dg){if(jg._removeMirroring)throw new Error("Context is already forwarding operations.");jg.__originalSave=jg.save,jg.__originalRestore=jg.restore,jg.__originalRotate=jg.rotate,jg.__originalScale=jg.scale,jg.__originalTranslate=jg.translate,jg.__originalTransform=jg.transform,jg.__originalSetTransform=jg.setTransform,jg.__originalResetTransform=jg.resetTransform,jg.__originalClip=jg.clip,jg.__originalMoveTo=jg.moveTo,jg.__originalLineTo=jg.lineTo,jg.__originalBezierCurveTo=jg.bezierCurveTo,jg.__originalRect=jg.rect,jg.__originalClosePath=jg.closePath,jg.__originalBeginPath=jg.beginPath,jg._removeMirroring=()=>{jg.save=jg.__originalSave,jg.restore=jg.__originalRestore,jg.rotate=jg.__originalRotate,jg.scale=jg.__originalScale,jg.translate=jg.__originalTranslate,jg.transform=jg.__originalTransform,jg.setTransform=jg.__originalSetTransform,jg.resetTransform=jg.__originalResetTransform,jg.clip=jg.__originalClip,jg.moveTo=jg.__originalMoveTo,jg.lineTo=jg.__originalLineTo,jg.bezierCurveTo=jg.__originalBezierCurveTo,jg.rect=jg.__originalRect,jg.closePath=jg.__originalClosePath,jg.beginPath=jg.__originalBeginPath,delete jg._removeMirroring},jg.save=function(){Dg.save(),this.__originalSave()},jg.restore=function(){Dg.restore(),this.__originalRestore()},jg.translate=function(Og,Jg){Dg.translate(Og,Jg),this.__originalTranslate(Og,Jg)},jg.scale=function(Og,Jg){Dg.scale(Og,Jg),this.__originalScale(Og,Jg)},jg.transform=function(Og,Jg,Qg,eo,ca,ua){Dg.transform(Og,Jg,Qg,eo,ca,ua),this.__originalTransform(Og,Jg,Qg,eo,ca,ua)},jg.setTransform=function(Og,Jg,Qg,eo,ca,ua){Dg.setTransform(Og,Jg,Qg,eo,ca,ua),this.__originalSetTransform(Og,Jg,Qg,eo,ca,ua)},jg.resetTransform=function(){Dg.resetTransform(),this.__originalResetTransform()},jg.rotate=function(Og){Dg.rotate(Og),this.__originalRotate(Og)},jg.clip=function(Og){Dg.clip(Og),this.__originalClip(Og)},jg.moveTo=function(zg,Og){Dg.moveTo(zg,Og),this.__originalMoveTo(zg,Og)},jg.lineTo=function(zg,Og){Dg.lineTo(zg,Og),this.__originalLineTo(zg,Og)},jg.bezierCurveTo=function(zg,Og,Jg,Qg,eo,ca){Dg.bezierCurveTo(zg,Og,Jg,Qg,eo,ca),this.__originalBezierCurveTo(zg,Og,Jg,Qg,eo,ca)},jg.rect=function(zg,Og,Jg,Qg){Dg.rect(zg,Og,Jg,Qg),this.__originalRect(zg,Og,Jg,Qg)},jg.closePath=function(){Dg.closePath(),this.__originalClosePath()},jg.beginPath=function(){Dg.beginPath(),this.__originalBeginPath()}}class dg{constructor(Dg){this.canvasFactory=Dg,this.cache=Object.create(null)}getCanvas(Dg,zg,Og){let Jg;return this.cache[Dg]!==void 0?(Jg=this.cache[Dg],this.canvasFactory.reset(Jg,zg,Og)):(Jg=this.canvasFactory.create(zg,Og),this.cache[Dg]=Jg),Jg}delete(Dg){delete this.cache[Dg]}clear(){for(const Dg in this.cache){const zg=this.cache[Dg];this.canvasFactory.destroy(zg),delete this.cache[Dg]}}}function hg(jg,Dg,zg,Og,Jg,Qg,eo,ca,ua,pa){const[is,Pg,la,ma,Ca,Eg]=(0,ng.getCurrentTransform)(jg);if(Pg===0&&la===0){const Ug=eo*is+Ca,da=Math.round(Ug),ya=ca*ma+Eg,eI=Math.round(ya),us=(eo+ua)*is+Ca,uo=Math.abs(Math.round(us)-da)||1,ha=(ca+pa)*ma+Eg,tI=Math.abs(Math.round(ha)-eI)||1;return jg.setTransform(Math.sign(is),0,0,Math.sign(ma),da,eI),jg.drawImage(Dg,zg,Og,Jg,Qg,0,0,uo,tI),jg.setTransform(is,Pg,la,ma,Ca,Eg),[uo,tI]}if(is===0&&ma===0){const Ug=ca*la+Ca,da=Math.round(Ug),ya=eo*Pg+Eg,eI=Math.round(ya),us=(ca+pa)*la+Ca,uo=Math.abs(Math.round(us)-da)||1,ha=(eo+ua)*Pg+Eg,tI=Math.abs(Math.round(ha)-eI)||1;return jg.setTransform(0,Math.sign(Pg),Math.sign(la),0,da,eI),jg.drawImage(Dg,zg,Og,Jg,Qg,0,0,tI,uo),jg.setTransform(is,Pg,la,ma,Ca,Eg),[tI,uo]}jg.drawImage(Dg,zg,Og,Jg,Qg,eo,ca,ua,pa);const Mg=Math.hypot(is,Pg),Tg=Math.hypot(la,ma);return[Mg*ua,Tg*pa]}function mg(jg){const{width:Dg,height:zg}=jg;if(Dg>rg||zg>rg)return null;const Og=1e3,Jg=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),Qg=Dg+1;let eo=new Uint8Array(Qg*(zg+1)),ca,ua,pa;const is=Dg+7&-8;let Pg=new Uint8Array(is*zg),la=0;for(const Tg of jg.data){let Ug=128;for(;Ug>0;)Pg[la++]=Tg&Ug?0:255,Ug>>=1}let ma=0;for(la=0,Pg[la]!==0&&(eo[0]=1,++ma),ua=1;ua<Dg;ua++)Pg[la]!==Pg[la+1]&&(eo[ua]=Pg[la]?2:1,++ma),la++;for(Pg[la]!==0&&(eo[ua]=2,++ma),ca=1;ca<zg;ca++){la=ca*is,pa=ca*Qg,Pg[la-is]!==Pg[la]&&(eo[pa]=Pg[la]?1:8,++ma);let Tg=(Pg[la]?4:0)+(Pg[la-is]?8:0);for(ua=1;ua<Dg;ua++)Tg=(Tg>>2)+(Pg[la+1]?4:0)+(Pg[la-is+1]?8:0),Jg[Tg]&&(eo[pa+ua]=Jg[Tg],++ma),la++;if(Pg[la-is]!==Pg[la]&&(eo[pa+ua]=Pg[la]?2:4,++ma),ma>Og)return null}for(la=is*(zg-1),pa=ca*Qg,Pg[la]!==0&&(eo[pa]=8,++ma),ua=1;ua<Dg;ua++)Pg[la]!==Pg[la+1]&&(eo[pa+ua]=Pg[la]?4:8,++ma),la++;if(Pg[la]!==0&&(eo[pa+ua]=4,++ma),ma>Og)return null;const Ca=new Int32Array([0,Qg,-1,0,-Qg,0,0,0,1]),Eg=new Path2D;for(ca=0;ma&&ca<=zg;ca++){let Tg=ca*Qg;const Ug=Tg+Dg;for(;Tg<Ug&&!eo[Tg];)Tg++;if(Tg===Ug)continue;Eg.moveTo(Tg%Qg,ca);const da=Tg;let ya=eo[Tg];do{const eI=Ca[ya];do Tg+=eI;while(!eo[Tg]);const us=eo[Tg];us!==5&&us!==10?(ya=us,eo[Tg]=0):(ya=us&51*ya>>4,eo[Tg]&=ya>>2|ya<<2),Eg.lineTo(Tg%Qg,Tg/Qg|0),eo[Tg]||--ma}while(da!==Tg);--ca}return Pg=null,eo=null,function(Tg){Tg.save(),Tg.scale(1/Dg,-1/zg),Tg.translate(0,-zg),Tg.fill(Eg),Tg.beginPath(),Tg.restore()}}class bg{constructor(Dg,zg){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=ig.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=ig.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=ig.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,Dg,zg])}clone(){const Dg=Object.create(this);return Dg.clipBox=this.clipBox.slice(),Dg}setCurrentPoint(Dg,zg){this.x=Dg,this.y=zg}updatePathMinMax(Dg,zg,Og){[zg,Og]=ig.Util.applyTransform([zg,Og],Dg),this.minX=Math.min(this.minX,zg),this.minY=Math.min(this.minY,Og),this.maxX=Math.max(this.maxX,zg),this.maxY=Math.max(this.maxY,Og)}updateRectMinMax(Dg,zg){const Og=ig.Util.applyTransform(zg,Dg),Jg=ig.Util.applyTransform(zg.slice(2),Dg);this.minX=Math.min(this.minX,Og[0],Jg[0]),this.minY=Math.min(this.minY,Og[1],Jg[1]),this.maxX=Math.max(this.maxX,Og[0],Jg[0]),this.maxY=Math.max(this.maxY,Og[1],Jg[1])}updateScalingPathMinMax(Dg,zg){ig.Util.scaleMinMax(Dg,zg),this.minX=Math.min(this.minX,zg[0]),this.maxX=Math.max(this.maxX,zg[1]),this.minY=Math.min(this.minY,zg[2]),this.maxY=Math.max(this.maxY,zg[3])}updateCurvePathMinMax(Dg,zg,Og,Jg,Qg,eo,ca,ua,pa,is){const Pg=ig.Util.bezierBoundingBox(zg,Og,Jg,Qg,eo,ca,ua,pa);if(is){is[0]=Math.min(is[0],Pg[0],Pg[2]),is[1]=Math.max(is[1],Pg[0],Pg[2]),is[2]=Math.min(is[2],Pg[1],Pg[3]),is[3]=Math.max(is[3],Pg[1],Pg[3]);return}this.updateRectMinMax(Dg,Pg)}getPathBoundingBox(Dg=og.PathType.FILL,zg=null){const Og=[this.minX,this.minY,this.maxX,this.maxY];if(Dg===og.PathType.STROKE){zg||(0,ig.unreachable)("Stroke bounding box must include transform.");const Jg=ig.Util.singularValueDecompose2dScale(zg),Qg=Jg[0]*this.lineWidth/2,eo=Jg[1]*this.lineWidth/2;Og[0]-=Qg,Og[1]-=eo,Og[2]+=Qg,Og[3]+=eo}return Og}updateClipFromPath(){const Dg=ig.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(Dg||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(Dg){this.clipBox=Dg,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(Dg=og.PathType.FILL,zg=null){return ig.Util.intersect(this.clipBox,this.getPathBoundingBox(Dg,zg))}}function pg(jg,Dg){if(typeof ImageData<"u"&&Dg instanceof ImageData){jg.putImageData(Dg,0,0);return}const zg=Dg.height,Og=Dg.width,Jg=zg%cg,Qg=(zg-Jg)/cg,eo=Jg===0?Qg:Qg+1,ca=jg.createImageData(Og,cg);let ua=0,pa;const is=Dg.data,Pg=ca.data;let la,ma,Ca,Eg;if(Dg.kind===ig.ImageKind.GRAYSCALE_1BPP){const Mg=is.byteLength,Tg=new Uint32Array(Pg.buffer,0,Pg.byteLength>>2),Ug=Tg.length,da=Og+7>>3,ya=4294967295,eI=ig.FeatureTest.isLittleEndian?4278190080:255;for(la=0;la<eo;la++){for(Ca=la<Qg?cg:Jg,pa=0,ma=0;ma<Ca;ma++){const us=Mg-ua;let uo=0;const ha=us>da?Og:us*8-7,tI=ha&-8;let AI=0,rI=0;for(;uo<tI;uo+=8)rI=is[ua++],Tg[pa++]=rI&128?ya:eI,Tg[pa++]=rI&64?ya:eI,Tg[pa++]=rI&32?ya:eI,Tg[pa++]=rI&16?ya:eI,Tg[pa++]=rI&8?ya:eI,Tg[pa++]=rI&4?ya:eI,Tg[pa++]=rI&2?ya:eI,Tg[pa++]=rI&1?ya:eI;for(;uo<ha;uo++)AI===0&&(rI=is[ua++],AI=128),Tg[pa++]=rI&AI?ya:eI,AI>>=1}for(;pa<Ug;)Tg[pa++]=0;jg.putImageData(ca,0,la*cg)}}else if(Dg.kind===ig.ImageKind.RGBA_32BPP){for(ma=0,Eg=Og*cg*4,la=0;la<Qg;la++)Pg.set(is.subarray(ua,ua+Eg)),ua+=Eg,jg.putImageData(ca,0,ma),ma+=cg;la<eo&&(Eg=Og*Jg*4,Pg.set(is.subarray(ua,ua+Eg)),jg.putImageData(ca,0,ma))}else if(Dg.kind===ig.ImageKind.RGB_24BPP)for(Ca=cg,Eg=Og*Ca,la=0;la<eo;la++){for(la>=Qg&&(Ca=Jg,Eg=Og*Ca),pa=0,ma=Eg;ma--;)Pg[pa++]=is[ua++],Pg[pa++]=is[ua++],Pg[pa++]=is[ua++],Pg[pa++]=255;jg.putImageData(ca,0,la*cg)}else throw new Error(`bad image kind: ${Dg.kind}`)}function fg(jg,Dg){if(Dg.bitmap){jg.drawImage(Dg.bitmap,0,0);return}const zg=Dg.height,Og=Dg.width,Jg=zg%cg,Qg=(zg-Jg)/cg,eo=Jg===0?Qg:Qg+1,ca=jg.createImageData(Og,cg);let ua=0;const pa=Dg.data,is=ca.data;for(let Pg=0;Pg<eo;Pg++){const la=Pg<Qg?cg:Jg;({srcPos:ua}=(0,ag.convertBlackAndWhiteToRGBA)({src:pa,srcPos:ua,dest:is,width:Og,height:la,nonBlackColor:0})),jg.putImageData(ca,0,Pg*cg)}}function wg(jg,Dg){const zg=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const Og of zg)jg[Og]!==void 0&&(Dg[Og]=jg[Og]);jg.setLineDash!==void 0&&(Dg.setLineDash(jg.getLineDash()),Dg.lineDashOffset=jg.lineDashOffset)}function Gg(jg){if(jg.strokeStyle=jg.fillStyle="#000000",jg.fillRule="nonzero",jg.globalAlpha=1,jg.lineWidth=1,jg.lineCap="butt",jg.lineJoin="miter",jg.miterLimit=10,jg.globalCompositeOperation="source-over",jg.font="10px sans-serif",jg.setLineDash!==void 0&&(jg.setLineDash([]),jg.lineDashOffset=0),!ig.isNodeJS){const{filter:Dg}=jg;Dg!=="none"&&Dg!==""&&(jg.filter="none")}}function Zg(jg,Dg,zg,Og){const Jg=jg.length;for(let Qg=3;Qg<Jg;Qg+=4){const eo=jg[Qg];if(eo===0)jg[Qg-3]=Dg,jg[Qg-2]=zg,jg[Qg-1]=Og;else if(eo<255){const ca=255-eo;jg[Qg-3]=jg[Qg-3]*eo+Dg*ca>>8,jg[Qg-2]=jg[Qg-2]*eo+zg*ca>>8,jg[Qg-1]=jg[Qg-1]*eo+Og*ca>>8}}}function $g(jg,Dg,zg){const Og=jg.length,Jg=1/255;for(let Qg=3;Qg<Og;Qg+=4){const eo=zg?zg[jg[Qg]]:jg[Qg];Dg[Qg]=Dg[Qg]*eo*Jg|0}}function Bg(jg,Dg,zg){const Og=jg.length;for(let Jg=3;Jg<Og;Jg+=4){const Qg=jg[Jg-3]*77+jg[Jg-2]*152+jg[Jg-1]*28;Dg[Jg]=zg?Dg[Jg]*zg[Qg>>8]>>8:Dg[Jg]*Qg>>16}}function Wg(jg,Dg,zg,Og,Jg,Qg,eo,ca,ua,pa,is){const Pg=!!Qg,la=Pg?Qg[0]:0,ma=Pg?Qg[1]:0,Ca=Pg?Qg[2]:0,Eg=Jg==="Luminosity"?Bg:$g,Tg=Math.min(Og,Math.ceil(1048576/zg));for(let Ug=0;Ug<Og;Ug+=Tg){const da=Math.min(Tg,Og-Ug),ya=jg.getImageData(ca-pa,Ug+(ua-is),zg,da),eI=Dg.getImageData(ca,Ug+ua,zg,da);Pg&&Zg(ya.data,la,ma,Ca),Eg(ya.data,eI.data,eo),Dg.putImageData(eI,ca,Ug+ua)}}function yg(jg,Dg,zg,Og){const Jg=Og[0],Qg=Og[1],eo=Og[2]-Jg,ca=Og[3]-Qg;eo===0||ca===0||(Wg(Dg.context,zg,eo,ca,Dg.subtype,Dg.backdrop,Dg.transferMap,Jg,Qg,Dg.offsetX,Dg.offsetY),jg.save(),jg.globalAlpha=1,jg.globalCompositeOperation="source-over",jg.setTransform(1,0,0,1,0,0),jg.drawImage(zg.canvas,0,0),jg.restore())}function Ng(jg,Dg){const zg=ig.Util.singularValueDecompose2dScale(jg);zg[0]=Math.fround(zg[0]),zg[1]=Math.fround(zg[1]);const Og=Math.fround((globalThis.devicePixelRatio||1)*ng.PixelsPerInch.PDF_TO_CSS_UNITS);return Dg!==void 0?Dg:zg[0]<=Og||zg[1]<=Og}const vg=["butt","round","square"],Sg=["miter","round","bevel"],Vg={},Xg={},Kg=class Kg{constructor(Dg,zg,Og,Jg,Qg,{optionalContentConfig:eo,markedContentStack:ca=null},ua,pa){ZI(this,Hg);this.ctx=Dg,this.current=new bg(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=zg,this.objs=Og,this.canvasFactory=Jg,this.filterFactory=Qg,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=ca||[],this.optionalContentConfig=eo,this.cachedCanvases=new dg(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=ua,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=pa,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(Dg,zg=null){return typeof Dg=="string"?Dg.startsWith("g_")?this.commonObjs.get(Dg):this.objs.get(Dg):zg}beginDrawing({transform:Dg,viewport:zg,transparency:Og=!1,background:Jg=null}){const Qg=this.ctx.canvas.width,eo=this.ctx.canvas.height,ca=this.ctx.fillStyle;if(this.ctx.fillStyle=Jg||"#ffffff",this.ctx.fillRect(0,0,Qg,eo),this.ctx.fillStyle=ca,Og){const ua=this.cachedCanvases.getCanvas("transparent",Qg,eo);this.compositeCtx=this.ctx,this.transparentCanvas=ua.canvas,this.ctx=ua.context,this.ctx.save(),this.ctx.transform(...(0,ng.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),Gg(this.ctx),Dg&&(this.ctx.transform(...Dg),this.outputScaleX=Dg[0],this.outputScaleY=Dg[0]),this.ctx.transform(...zg.transform),this.viewportScale=zg.scale,this.baseTransform=(0,ng.getCurrentTransform)(this.ctx)}executeOperatorList(Dg,zg,Og,Jg){const Qg=Dg.argsArray,eo=Dg.fnArray;let ca=zg||0;const ua=Qg.length;if(ua===ca)return ca;const pa=ua-ca>Ag&&typeof Og=="function",is=pa?Date.now()+lg:0;let Pg=0;const la=this.commonObjs,ma=this.objs;let Ca;for(;;){if(Jg!==void 0&&ca===Jg.nextBreakPoint)return Jg.breakIt(ca,Og),ca;if(Ca=eo[ca],Ca!==ig.OPS.dependency)this[Ca].apply(this,Qg[ca]);else for(const Eg of Qg[ca]){const Mg=Eg.startsWith("g_")?la:ma;if(!Mg.has(Eg))return Mg.get(Eg,Og),ca}if(ca++,ca===ua)return ca;if(pa&&++Pg>Ag){if(Date.now()>is)return Og(),ca;Pg=0}}}endDrawing(){hI(this,Hg,B0).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const Dg of this._cachedBitmapsMap.values()){for(const zg of Dg.values())typeof HTMLCanvasElement<"u"&&zg instanceof HTMLCanvasElement&&(zg.width=zg.height=0);Dg.clear()}this._cachedBitmapsMap.clear(),hI(this,Hg,W0).call(this)}_scaleImage(Dg,zg){const Og=Dg.width,Jg=Dg.height;let Qg=Math.max(Math.hypot(zg[0],zg[1]),1),eo=Math.max(Math.hypot(zg[2],zg[3]),1),ca=Og,ua=Jg,pa="prescale1",is,Pg;for(;Qg>2&&ca>1||eo>2&&ua>1;){let la=ca,ma=ua;Qg>2&&ca>1&&(la=ca>=16384?Math.floor(ca/2)-1||1:Math.ceil(ca/2),Qg/=ca/la),eo>2&&ua>1&&(ma=ua>=16384?Math.floor(ua/2)-1||1:Math.ceil(ua)/2,eo/=ua/ma),is=this.cachedCanvases.getCanvas(pa,la,ma),Pg=is.context,Pg.clearRect(0,0,la,ma),Pg.drawImage(Dg,0,0,ca,ua,0,0,la,ma),Dg=is.canvas,ca=la,ua=ma,pa=pa==="prescale1"?"prescale2":"prescale1"}return{img:Dg,paintWidth:ca,paintHeight:ua}}_createMaskCanvas(Dg){const zg=this.ctx,{width:Og,height:Jg}=Dg,Qg=this.current.fillColor,eo=this.current.patternFill,ca=(0,ng.getCurrentTransform)(zg);let ua,pa,is,Pg;if((Dg.bitmap||Dg.data)&&Dg.count>1){const uo=Dg.bitmap||Dg.data.buffer;pa=JSON.stringify(eo?ca:[ca.slice(0,4),Qg]),ua=this._cachedBitmapsMap.get(uo),ua||(ua=new Map,this._cachedBitmapsMap.set(uo,ua));const ha=ua.get(pa);if(ha&&!eo){const tI=Math.round(Math.min(ca[0],ca[2])+ca[4]),AI=Math.round(Math.min(ca[1],ca[3])+ca[5]);return{canvas:ha,offsetX:tI,offsetY:AI}}is=ha}is||(Pg=this.cachedCanvases.getCanvas("maskCanvas",Og,Jg),fg(Pg.context,Dg));let la=ig.Util.transform(ca,[1/Og,0,0,-1/Jg,0,0]);la=ig.Util.transform(la,[1,0,0,1,0,-Jg]);const ma=ig.Util.applyTransform([0,0],la),Ca=ig.Util.applyTransform([Og,Jg],la),Eg=ig.Util.normalizeRect([ma[0],ma[1],Ca[0],Ca[1]]),Mg=Math.round(Eg[2]-Eg[0])||1,Tg=Math.round(Eg[3]-Eg[1])||1,Ug=this.cachedCanvases.getCanvas("fillCanvas",Mg,Tg),da=Ug.context,ya=Math.min(ma[0],Ca[0]),eI=Math.min(ma[1],Ca[1]);da.translate(-ya,-eI),da.transform(...la),is||(is=this._scaleImage(Pg.canvas,(0,ng.getCurrentTransformInverse)(da)),is=is.img,ua&&eo&&ua.set(pa,is)),da.imageSmoothingEnabled=Ng((0,ng.getCurrentTransform)(da),Dg.interpolate),hg(da,is,0,0,is.width,is.height,0,0,Og,Jg),da.globalCompositeOperation="source-in";const us=ig.Util.transform((0,ng.getCurrentTransformInverse)(da),[1,0,0,1,-ya,-eI]);return da.fillStyle=eo?Qg.getPattern(zg,this,us,og.PathType.FILL):Qg,da.fillRect(0,0,Og,Jg),ua&&!eo&&(this.cachedCanvases.delete("fillCanvas"),ua.set(pa,Ug.canvas)),{canvas:Ug.canvas,offsetX:Math.round(ya),offsetY:Math.round(eI)}}setLineWidth(Dg){Dg!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=Dg,this.ctx.lineWidth=Dg}setLineCap(Dg){this.ctx.lineCap=vg[Dg]}setLineJoin(Dg){this.ctx.lineJoin=Sg[Dg]}setMiterLimit(Dg){this.ctx.miterLimit=Dg}setDash(Dg,zg){const Og=this.ctx;Og.setLineDash!==void 0&&(Og.setLineDash(Dg),Og.lineDashOffset=zg)}setRenderingIntent(Dg){}setFlatness(Dg){}setGState(Dg){for(const[zg,Og]of Dg)switch(zg){case"LW":this.setLineWidth(Og);break;case"LC":this.setLineCap(Og);break;case"LJ":this.setLineJoin(Og);break;case"ML":this.setMiterLimit(Og);break;case"D":this.setDash(Og[0],Og[1]);break;case"RI":this.setRenderingIntent(Og);break;case"FL":this.setFlatness(Og);break;case"Font":this.setFont(Og[0],Og[1]);break;case"CA":this.current.strokeAlpha=Og;break;case"ca":this.current.fillAlpha=Og,this.ctx.globalAlpha=Og;break;case"BM":this.ctx.globalCompositeOperation=Og;break;case"SMask":this.current.activeSMask=Og?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(Og);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const Dg=this.inSMaskMode;this.current.activeSMask&&!Dg?this.beginSMaskMode():!this.current.activeSMask&&Dg&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const Dg=this.ctx.canvas.width,zg=this.ctx.canvas.height,Og="smaskGroupAt"+this.groupLevel,Jg=this.cachedCanvases.getCanvas(Og,Dg,zg);this.suspendedCtx=this.ctx,this.ctx=Jg.context;const Qg=this.ctx;Qg.setTransform(...(0,ng.getCurrentTransform)(this.suspendedCtx)),wg(this.suspendedCtx,Qg),ug(Qg,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),wg(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(Dg){if(!this.current.activeSMask)return;Dg?(Dg[0]=Math.floor(Dg[0]),Dg[1]=Math.floor(Dg[1]),Dg[2]=Math.ceil(Dg[2]),Dg[3]=Math.ceil(Dg[3])):Dg=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const zg=this.current.activeSMask,Og=this.suspendedCtx;yg(Og,zg,this.ctx,Dg),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}save(){this.inSMaskMode?(wg(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const Dg=this.current;this.stateStack.push(Dg),this.current=Dg.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),wg(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(Dg,zg,Og,Jg,Qg,eo){this.ctx.transform(Dg,zg,Og,Jg,Qg,eo),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(Dg,zg,Og){const Jg=this.ctx,Qg=this.current;let eo=Qg.x,ca=Qg.y,ua,pa;const is=(0,ng.getCurrentTransform)(Jg),Pg=is[0]===0&&is[3]===0||is[1]===0&&is[2]===0,la=Pg?Og.slice(0):null;for(let ma=0,Ca=0,Eg=Dg.length;ma<Eg;ma++)switch(Dg[ma]|0){case ig.OPS.rectangle:eo=zg[Ca++],ca=zg[Ca++];const Mg=zg[Ca++],Tg=zg[Ca++],Ug=eo+Mg,da=ca+Tg;Jg.moveTo(eo,ca),Mg===0||Tg===0?Jg.lineTo(Ug,da):(Jg.lineTo(Ug,ca),Jg.lineTo(Ug,da),Jg.lineTo(eo,da)),Pg||Qg.updateRectMinMax(is,[eo,ca,Ug,da]),Jg.closePath();break;case ig.OPS.moveTo:eo=zg[Ca++],ca=zg[Ca++],Jg.moveTo(eo,ca),Pg||Qg.updatePathMinMax(is,eo,ca);break;case ig.OPS.lineTo:eo=zg[Ca++],ca=zg[Ca++],Jg.lineTo(eo,ca),Pg||Qg.updatePathMinMax(is,eo,ca);break;case ig.OPS.curveTo:ua=eo,pa=ca,eo=zg[Ca+4],ca=zg[Ca+5],Jg.bezierCurveTo(zg[Ca],zg[Ca+1],zg[Ca+2],zg[Ca+3],eo,ca),Qg.updateCurvePathMinMax(is,ua,pa,zg[Ca],zg[Ca+1],zg[Ca+2],zg[Ca+3],eo,ca,la),Ca+=6;break;case ig.OPS.curveTo2:ua=eo,pa=ca,Jg.bezierCurveTo(eo,ca,zg[Ca],zg[Ca+1],zg[Ca+2],zg[Ca+3]),Qg.updateCurvePathMinMax(is,ua,pa,eo,ca,zg[Ca],zg[Ca+1],zg[Ca+2],zg[Ca+3],la),eo=zg[Ca+2],ca=zg[Ca+3],Ca+=4;break;case ig.OPS.curveTo3:ua=eo,pa=ca,eo=zg[Ca+2],ca=zg[Ca+3],Jg.bezierCurveTo(zg[Ca],zg[Ca+1],eo,ca,eo,ca),Qg.updateCurvePathMinMax(is,ua,pa,zg[Ca],zg[Ca+1],eo,ca,eo,ca,la),Ca+=4;break;case ig.OPS.closePath:Jg.closePath();break}Pg&&Qg.updateScalingPathMinMax(is,la),Qg.setCurrentPoint(eo,ca)}closePath(){this.ctx.closePath()}stroke(Dg=!0){const zg=this.ctx,Og=this.current.strokeColor;zg.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof Og=="object"&&(Og!=null&&Og.getPattern)?(zg.save(),zg.strokeStyle=Og.getPattern(zg,this,(0,ng.getCurrentTransformInverse)(zg),og.PathType.STROKE),this.rescaleAndStroke(!1),zg.restore()):this.rescaleAndStroke(!0)),Dg&&this.consumePath(this.current.getClippedPathBoundingBox()),zg.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(Dg=!0){const zg=this.ctx,Og=this.current.fillColor,Jg=this.current.patternFill;let Qg=!1;Jg&&(zg.save(),zg.fillStyle=Og.getPattern(zg,this,(0,ng.getCurrentTransformInverse)(zg),og.PathType.FILL),Qg=!0);const eo=this.current.getClippedPathBoundingBox();this.contentVisible&&eo!==null&&(this.pendingEOFill?(zg.fill("evenodd"),this.pendingEOFill=!1):zg.fill()),Qg&&zg.restore(),Dg&&this.consumePath(eo)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Vg}eoClip(){this.pendingClip=Xg}beginText(){this.current.textMatrix=ig.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const Dg=this.pendingTextPaths,zg=this.ctx;if(Dg===void 0){zg.beginPath();return}zg.save(),zg.beginPath();for(const Og of Dg)zg.setTransform(...Og.transform),zg.translate(Og.x,Og.y),Og.addToPath(zg,Og.fontSize);zg.restore(),zg.clip(),zg.beginPath(),delete this.pendingTextPaths}setCharSpacing(Dg){this.current.charSpacing=Dg}setWordSpacing(Dg){this.current.wordSpacing=Dg}setHScale(Dg){this.current.textHScale=Dg/100}setLeading(Dg){this.current.leading=-Dg}setFont(Dg,zg){var is;const Og=this.commonObjs.get(Dg),Jg=this.current;if(!Og)throw new Error(`Can't find font for ${Dg}`);if(Jg.fontMatrix=Og.fontMatrix||ig.FONT_IDENTITY_MATRIX,(Jg.fontMatrix[0]===0||Jg.fontMatrix[3]===0)&&(0,ig.warn)("Invalid font matrix for font "+Dg),zg<0?(zg=-zg,Jg.fontDirection=-1):Jg.fontDirection=1,this.current.font=Og,this.current.fontSize=zg,Og.isType3Font)return;const Qg=Og.loadedName||"sans-serif",eo=((is=Og.systemFontInfo)==null?void 0:is.css)||`"${Qg}", ${Og.fallbackName}`;let ca="normal";Og.black?ca="900":Og.bold&&(ca="bold");const ua=Og.italic?"italic":"normal";let pa=zg;zg<sg?pa=sg:zg>Ig&&(pa=Ig),this.current.fontSizeScale=zg/pa,this.ctx.font=`${ua} ${ca} ${pa}px ${eo}`}setTextRenderingMode(Dg){this.current.textRenderingMode=Dg}setTextRise(Dg){this.current.textRise=Dg}moveText(Dg,zg){this.current.x=this.current.lineX+=Dg,this.current.y=this.current.lineY+=zg}setLeadingMoveText(Dg,zg){this.setLeading(-zg),this.moveText(Dg,zg)}setTextMatrix(Dg,zg,Og,Jg,Qg,eo){this.current.textMatrix=[Dg,zg,Og,Jg,Qg,eo],this.current.textMatrixScale=Math.hypot(Dg,zg),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(Dg,zg,Og,Jg){const Qg=this.ctx,eo=this.current,ca=eo.font,ua=eo.textRenderingMode,pa=eo.fontSize/eo.fontSizeScale,is=ua&ig.TextRenderingMode.FILL_STROKE_MASK,Pg=!!(ua&ig.TextRenderingMode.ADD_TO_PATH_FLAG),la=eo.patternFill&&!ca.missingFile;let ma;(ca.disableFontFace||Pg||la)&&(ma=ca.getPathGenerator(this.commonObjs,Dg)),ca.disableFontFace||la?(Qg.save(),Qg.translate(zg,Og),Qg.beginPath(),ma(Qg,pa),Jg&&Qg.setTransform(...Jg),(is===ig.TextRenderingMode.FILL||is===ig.TextRenderingMode.FILL_STROKE)&&Qg.fill(),(is===ig.TextRenderingMode.STROKE||is===ig.TextRenderingMode.FILL_STROKE)&&Qg.stroke(),Qg.restore()):((is===ig.TextRenderingMode.FILL||is===ig.TextRenderingMode.FILL_STROKE)&&Qg.fillText(Dg,zg,Og),(is===ig.TextRenderingMode.STROKE||is===ig.TextRenderingMode.FILL_STROKE)&&Qg.strokeText(Dg,zg,Og)),Pg&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,ng.getCurrentTransform)(Qg),x:zg,y:Og,fontSize:pa,addToPath:ma})}get isFontSubpixelAAEnabled(){const{context:Dg}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);Dg.scale(1.5,1),Dg.fillText("I",0,10);const zg=Dg.getImageData(0,0,10,10).data;let Og=!1;for(let Jg=3;Jg<zg.length;Jg+=4)if(zg[Jg]>0&&zg[Jg]<255){Og=!0;break}return(0,ig.shadow)(this,"isFontSubpixelAAEnabled",Og)}showText(Dg){const zg=this.current,Og=zg.font;if(Og.isType3Font)return this.showType3Text(Dg);const Jg=zg.fontSize;if(Jg===0)return;const Qg=this.ctx,eo=zg.fontSizeScale,ca=zg.charSpacing,ua=zg.wordSpacing,pa=zg.fontDirection,is=zg.textHScale*pa,Pg=Dg.length,la=Og.vertical,ma=la?1:-1,Ca=Og.defaultVMetrics,Eg=Jg*zg.fontMatrix[0],Mg=zg.textRenderingMode===ig.TextRenderingMode.FILL&&!Og.disableFontFace&&!zg.patternFill;Qg.save(),Qg.transform(...zg.textMatrix),Qg.translate(zg.x,zg.y+zg.textRise),pa>0?Qg.scale(is,-1):Qg.scale(is,1);let Tg;if(zg.patternFill){Qg.save();const us=zg.fillColor.getPattern(Qg,this,(0,ng.getCurrentTransformInverse)(Qg),og.PathType.FILL);Tg=(0,ng.getCurrentTransform)(Qg),Qg.restore(),Qg.fillStyle=us}let Ug=zg.lineWidth;const da=zg.textMatrixScale;if(da===0||Ug===0){const us=zg.textRenderingMode&ig.TextRenderingMode.FILL_STROKE_MASK;(us===ig.TextRenderingMode.STROKE||us===ig.TextRenderingMode.FILL_STROKE)&&(Ug=this.getSinglePixelWidth())}else Ug/=da;if(eo!==1&&(Qg.scale(eo,eo),Ug/=eo),Qg.lineWidth=Ug,Og.isInvalidPDFjsFont){const us=[];let uo=0;for(const ha of Dg)us.push(ha.unicode),uo+=ha.width;Qg.fillText(us.join(""),0,0),zg.x+=uo*Eg*is,Qg.restore(),this.compose();return}let ya=0,eI;for(eI=0;eI<Pg;++eI){const us=Dg[eI];if(typeof us=="number"){ya+=ma*us*Jg/1e3;continue}let uo=!1;const ha=(us.isSpace?ua:0)+ca,tI=us.fontChar,AI=us.accent;let rI,gI,qg=us.width;if(la){const iI=us.vmetric||Ca,sI=-(us.vmetric?iI[1]:qg*.5)*Eg,fa=iI[2]*Eg;qg=iI?-iI[0]:qg,rI=sI/eo,gI=(ya+fa)/eo}else rI=ya/eo,gI=0;if(Og.remeasure&&qg>0){const iI=Qg.measureText(tI).width*1e3/Jg*eo;if(qg<iI&&this.isFontSubpixelAAEnabled){const sI=qg/iI;uo=!0,Qg.save(),Qg.scale(sI,1),rI/=sI}else qg!==iI&&(rI+=(qg-iI)/2e3*Jg/eo)}if(this.contentVisible&&(us.isInFont||Og.missingFile)){if(Mg&&!AI)Qg.fillText(tI,rI,gI);else if(this.paintChar(tI,rI,gI,Tg),AI){const iI=rI+Jg*AI.offset.x/eo,sI=gI-Jg*AI.offset.y/eo;this.paintChar(AI.fontChar,iI,sI,Tg)}}const xa=la?qg*Eg-ha*pa:qg*Eg+ha*pa;ya+=xa,uo&&Qg.restore()}la?zg.y-=ya:zg.x+=ya*is,Qg.restore(),this.compose()}showType3Text(Dg){const zg=this.ctx,Og=this.current,Jg=Og.font,Qg=Og.fontSize,eo=Og.fontDirection,ca=Jg.vertical?1:-1,ua=Og.charSpacing,pa=Og.wordSpacing,is=Og.textHScale*eo,Pg=Og.fontMatrix||ig.FONT_IDENTITY_MATRIX,la=Dg.length,ma=Og.textRenderingMode===ig.TextRenderingMode.INVISIBLE;let Ca,Eg,Mg,Tg;if(!(ma||Qg===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,zg.save(),zg.transform(...Og.textMatrix),zg.translate(Og.x,Og.y),zg.scale(is,eo),Ca=0;Ca<la;++Ca){if(Eg=Dg[Ca],typeof Eg=="number"){Tg=ca*Eg*Qg/1e3,this.ctx.translate(Tg,0),Og.x+=Tg*is;continue}const Ug=(Eg.isSpace?pa:0)+ua,da=Jg.charProcOperatorList[Eg.operatorListId];if(!da){(0,ig.warn)(`Type3 character "${Eg.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=Eg,this.save(),zg.scale(Qg,Qg),zg.transform(...Pg),this.executeOperatorList(da),this.restore()),Mg=ig.Util.applyTransform([Eg.width,0],Pg)[0]*Qg+Ug,zg.translate(Mg,0),Og.x+=Mg*is}zg.restore(),this.processingType3=null}}setCharWidth(Dg,zg){}setCharWidthAndBounds(Dg,zg,Og,Jg,Qg,eo){this.ctx.rect(Og,Jg,Qg-Og,eo-Jg),this.ctx.clip(),this.endPath()}getColorN_Pattern(Dg){let zg;if(Dg[0]==="TilingPattern"){const Og=Dg[1],Jg=this.baseTransform||(0,ng.getCurrentTransform)(this.ctx),Qg={createCanvasGraphics:eo=>new Kg(eo,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};zg=new og.TilingPattern(Dg,Og,this.ctx,Qg,Jg)}else zg=this._getPattern(Dg[1],Dg[2]);return zg}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(Dg,zg,Og){const Jg=ig.Util.makeHexColor(Dg,zg,Og);this.ctx.strokeStyle=Jg,this.current.strokeColor=Jg}setFillRGBColor(Dg,zg,Og){const Jg=ig.Util.makeHexColor(Dg,zg,Og);this.ctx.fillStyle=Jg,this.current.fillColor=Jg,this.current.patternFill=!1}_getPattern(Dg,zg=null){let Og;return this.cachedPatterns.has(Dg)?Og=this.cachedPatterns.get(Dg):(Og=(0,og.getShadingPattern)(this.getObject(Dg)),this.cachedPatterns.set(Dg,Og)),zg&&(Og.matrix=zg),Og}shadingFill(Dg){if(!this.contentVisible)return;const zg=this.ctx;this.save();const Og=this._getPattern(Dg);zg.fillStyle=Og.getPattern(zg,this,(0,ng.getCurrentTransformInverse)(zg),og.PathType.SHADING);const Jg=(0,ng.getCurrentTransformInverse)(zg);if(Jg){const{width:Qg,height:eo}=zg.canvas,[ca,ua,pa,is]=ig.Util.getAxialAlignedBoundingBox([0,0,Qg,eo],Jg);this.ctx.fillRect(ca,ua,pa-ca,is-ua)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,ig.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,ig.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(Dg,zg){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(Dg)&&Dg.length===6&&this.transform(...Dg),this.baseTransform=(0,ng.getCurrentTransform)(this.ctx),zg)){const Og=zg[2]-zg[0],Jg=zg[3]-zg[1];this.ctx.rect(zg[0],zg[1],Og,Jg),this.current.updateRectMinMax((0,ng.getCurrentTransform)(this.ctx),zg),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(Dg){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const zg=this.ctx;Dg.isolated||(0,ig.info)("TODO: Support non-isolated groups."),Dg.knockout&&(0,ig.warn)("Knockout groups not supported.");const Og=(0,ng.getCurrentTransform)(zg);if(Dg.matrix&&zg.transform(...Dg.matrix),!Dg.bbox)throw new Error("Bounding box is required.");let Jg=ig.Util.getAxialAlignedBoundingBox(Dg.bbox,(0,ng.getCurrentTransform)(zg));const Qg=[0,0,zg.canvas.width,zg.canvas.height];Jg=ig.Util.intersect(Jg,Qg)||[0,0,0,0];const eo=Math.floor(Jg[0]),ca=Math.floor(Jg[1]);let ua=Math.max(Math.ceil(Jg[2])-eo,1),pa=Math.max(Math.ceil(Jg[3])-ca,1),is=1,Pg=1;ua>Cg&&(is=ua/Cg,ua=Cg),pa>Cg&&(Pg=pa/Cg,pa=Cg),this.current.startNewPathAndClipBox([0,0,ua,pa]);let la="groupAt"+this.groupLevel;Dg.smask&&(la+="_smask_"+this.smaskCounter++%2);const ma=this.cachedCanvases.getCanvas(la,ua,pa),Ca=ma.context;Ca.scale(1/is,1/Pg),Ca.translate(-eo,-ca),Ca.transform(...Og),Dg.smask?this.smaskStack.push({canvas:ma.canvas,context:Ca,offsetX:eo,offsetY:ca,scaleX:is,scaleY:Pg,subtype:Dg.smask.subtype,backdrop:Dg.smask.backdrop,transferMap:Dg.smask.transferMap||null,startTransformInverse:null}):(zg.setTransform(1,0,0,1,0,0),zg.translate(eo,ca),zg.scale(is,Pg),zg.save()),wg(zg,Ca),this.ctx=Ca,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(zg),this.groupLevel++}endGroup(Dg){if(!this.contentVisible)return;this.groupLevel--;const zg=this.ctx,Og=this.groupStack.pop();if(this.ctx=Og,this.ctx.imageSmoothingEnabled=!1,Dg.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const Jg=(0,ng.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...Jg);const Qg=ig.Util.getAxialAlignedBoundingBox([0,0,zg.canvas.width,zg.canvas.height],Jg);this.ctx.drawImage(zg.canvas,0,0),this.ctx.restore(),this.compose(Qg)}}beginAnnotation(Dg,zg,Og,Jg,Qg){if(hI(this,Hg,B0).call(this),Gg(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(zg)&&zg.length===4){const eo=zg[2]-zg[0],ca=zg[3]-zg[1];if(Qg&&this.annotationCanvasMap){Og=Og.slice(),Og[4]-=zg[0],Og[5]-=zg[1],zg=zg.slice(),zg[0]=zg[1]=0,zg[2]=eo,zg[3]=ca;const[ua,pa]=ig.Util.singularValueDecompose2dScale((0,ng.getCurrentTransform)(this.ctx)),{viewportScale:is}=this,Pg=Math.ceil(eo*this.outputScaleX*is),la=Math.ceil(ca*this.outputScaleY*is);this.annotationCanvas=this.canvasFactory.create(Pg,la);const{canvas:ma,context:Ca}=this.annotationCanvas;this.annotationCanvasMap.set(Dg,ma),this.annotationCanvas.savedCtx=this.ctx,this.ctx=Ca,this.ctx.save(),this.ctx.setTransform(ua,0,0,-pa,0,ca*pa),Gg(this.ctx)}else Gg(this.ctx),this.ctx.rect(zg[0],zg[1],eo,ca),this.ctx.clip(),this.endPath()}this.current=new bg(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...Og),this.transform(...Jg)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),hI(this,Hg,W0).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(Dg){if(!this.contentVisible)return;const zg=Dg.count;Dg=this.getObject(Dg.data,Dg),Dg.count=zg;const Og=this.ctx,Jg=this.processingType3;if(Jg&&(Jg.compiled===void 0&&(Jg.compiled=mg(Dg)),Jg.compiled)){Jg.compiled(Og);return}const Qg=this._createMaskCanvas(Dg),eo=Qg.canvas;Og.save(),Og.setTransform(1,0,0,1,0,0),Og.drawImage(eo,Qg.offsetX,Qg.offsetY),Og.restore(),this.compose()}paintImageMaskXObjectRepeat(Dg,zg,Og=0,Jg=0,Qg,eo){if(!this.contentVisible)return;Dg=this.getObject(Dg.data,Dg);const ca=this.ctx;ca.save();const ua=(0,ng.getCurrentTransform)(ca);ca.transform(zg,Og,Jg,Qg,0,0);const pa=this._createMaskCanvas(Dg);ca.setTransform(1,0,0,1,pa.offsetX-ua[4],pa.offsetY-ua[5]);for(let is=0,Pg=eo.length;is<Pg;is+=2){const la=ig.Util.transform(ua,[zg,Og,Jg,Qg,eo[is],eo[is+1]]),[ma,Ca]=ig.Util.applyTransform([0,0],la);ca.drawImage(pa.canvas,ma,Ca)}ca.restore(),this.compose()}paintImageMaskXObjectGroup(Dg){if(!this.contentVisible)return;const zg=this.ctx,Og=this.current.fillColor,Jg=this.current.patternFill;for(const Qg of Dg){const{data:eo,width:ca,height:ua,transform:pa}=Qg,is=this.cachedCanvases.getCanvas("maskCanvas",ca,ua),Pg=is.context;Pg.save();const la=this.getObject(eo,Qg);fg(Pg,la),Pg.globalCompositeOperation="source-in",Pg.fillStyle=Jg?Og.getPattern(Pg,this,(0,ng.getCurrentTransformInverse)(zg),og.PathType.FILL):Og,Pg.fillRect(0,0,ca,ua),Pg.restore(),zg.save(),zg.transform(...pa),zg.scale(1,-1),hg(zg,is.canvas,0,0,ca,ua,0,-1,1,1),zg.restore()}this.compose()}paintImageXObject(Dg){if(!this.contentVisible)return;const zg=this.getObject(Dg);if(!zg){(0,ig.warn)("Dependent image isn't ready yet");return}this.paintInlineImageXObject(zg)}paintImageXObjectRepeat(Dg,zg,Og,Jg){if(!this.contentVisible)return;const Qg=this.getObject(Dg);if(!Qg){(0,ig.warn)("Dependent image isn't ready yet");return}const eo=Qg.width,ca=Qg.height,ua=[];for(let pa=0,is=Jg.length;pa<is;pa+=2)ua.push({transform:[zg,0,0,Og,Jg[pa],Jg[pa+1]],x:0,y:0,w:eo,h:ca});this.paintInlineImageXObjectGroup(Qg,ua)}applyTransferMapsToCanvas(Dg){return this.current.transferMaps!=="none"&&(Dg.filter=this.current.transferMaps,Dg.drawImage(Dg.canvas,0,0),Dg.filter="none"),Dg.canvas}applyTransferMapsToBitmap(Dg){if(this.current.transferMaps==="none")return Dg.bitmap;const{bitmap:zg,width:Og,height:Jg}=Dg,Qg=this.cachedCanvases.getCanvas("inlineImage",Og,Jg),eo=Qg.context;return eo.filter=this.current.transferMaps,eo.drawImage(zg,0,0),eo.filter="none",Qg.canvas}paintInlineImageXObject(Dg){if(!this.contentVisible)return;const zg=Dg.width,Og=Dg.height,Jg=this.ctx;if(this.save(),!ig.isNodeJS){const{filter:ca}=Jg;ca!=="none"&&ca!==""&&(Jg.filter="none")}Jg.scale(1/zg,-1/Og);let Qg;if(Dg.bitmap)Qg=this.applyTransferMapsToBitmap(Dg);else if(typeof HTMLElement=="function"&&Dg instanceof HTMLElement||!Dg.data)Qg=Dg;else{const ua=this.cachedCanvases.getCanvas("inlineImage",zg,Og).context;pg(ua,Dg),Qg=this.applyTransferMapsToCanvas(ua)}const eo=this._scaleImage(Qg,(0,ng.getCurrentTransformInverse)(Jg));Jg.imageSmoothingEnabled=Ng((0,ng.getCurrentTransform)(Jg),Dg.interpolate),hg(Jg,eo.img,0,0,eo.paintWidth,eo.paintHeight,0,-Og,zg,Og),this.compose(),this.restore()}paintInlineImageXObjectGroup(Dg,zg){if(!this.contentVisible)return;const Og=this.ctx;let Jg;if(Dg.bitmap)Jg=Dg.bitmap;else{const Qg=Dg.width,eo=Dg.height,ua=this.cachedCanvases.getCanvas("inlineImage",Qg,eo).context;pg(ua,Dg),Jg=this.applyTransferMapsToCanvas(ua)}for(const Qg of zg)Og.save(),Og.transform(...Qg.transform),Og.scale(1,-1),hg(Og,Jg,Qg.x,Qg.y,Qg.w,Qg.h,0,-1,1,1),Og.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(Dg){}markPointProps(Dg,zg){}beginMarkedContent(Dg){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(Dg,zg){Dg==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(zg)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(Dg){const zg=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(Dg);const Og=this.ctx;this.pendingClip&&(zg||(this.pendingClip===Xg?Og.clip("evenodd"):Og.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),Og.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const Dg=(0,ng.getCurrentTransform)(this.ctx);if(Dg[1]===0&&Dg[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(Dg[0]),Math.abs(Dg[3]));else{const zg=Math.abs(Dg[0]*Dg[3]-Dg[2]*Dg[1]),Og=Math.hypot(Dg[0],Dg[2]),Jg=Math.hypot(Dg[1],Dg[3]);this._cachedGetSinglePixelWidth=Math.max(Og,Jg)/zg}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:Dg}=this.current,{a:zg,b:Og,c:Jg,d:Qg}=this.ctx.getTransform();let eo,ca;if(Og===0&&Jg===0){const ua=Math.abs(zg),pa=Math.abs(Qg);if(ua===pa)if(Dg===0)eo=ca=1/ua;else{const is=ua*Dg;eo=ca=is<1?1/is:1}else if(Dg===0)eo=1/ua,ca=1/pa;else{const is=ua*Dg,Pg=pa*Dg;eo=is<1?1/is:1,ca=Pg<1?1/Pg:1}}else{const ua=Math.abs(zg*Qg-Og*Jg),pa=Math.hypot(zg,Og),is=Math.hypot(Jg,Qg);if(Dg===0)eo=is/ua,ca=pa/ua;else{const Pg=Dg*ua;eo=is>Pg?is/Pg:1,ca=pa>Pg?pa/Pg:1}}this._cachedScaleForStroking[0]=eo,this._cachedScaleForStroking[1]=ca}return this._cachedScaleForStroking}rescaleAndStroke(Dg){const{ctx:zg}=this,{lineWidth:Og}=this.current,[Jg,Qg]=this.getScaleForStroking();if(zg.lineWidth=Og||1,Jg===1&&Qg===1){zg.stroke();return}const eo=zg.getLineDash();if(Dg&&zg.save(),zg.scale(Jg,Qg),eo.length>0){const ca=Math.max(Jg,Qg);zg.setLineDash(eo.map(ua=>ua/ca)),zg.lineDashOffset/=ca}zg.stroke(),Dg&&zg.restore()}isContentVisible(){for(let Dg=this.markedContentStack.length-1;Dg>=0;Dg--)if(!this.markedContentStack[Dg].visible)return!1;return!0}};Hg=new WeakSet,B0=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},W0=function(){if(this.pageColors){const Dg=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(Dg!=="none"){const zg=this.ctx.filter;this.ctx.filter=Dg,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=zg}}};let Yg=Kg;eg.CanvasGraphics=Yg;for(const jg in ig.OPS)Yg.prototype[jg]!==void 0&&(Yg.prototype[ig.OPS[jg]]=Yg.prototype[jg])}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.TilingPattern=eg.PathType=void 0,eg.getShadingPattern=cg;var ig=gg(1),ng=gg(6);const og={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};eg.PathType=og;function ag(mg,bg){if(!bg)return;const pg=bg[2]-bg[0],fg=bg[3]-bg[1],wg=new Path2D;wg.rect(bg[0],bg[1],pg,fg),mg.clip(wg)}class sg{constructor(){this.constructor===sg&&(0,ig.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,ig.unreachable)("Abstract method `getPattern` called.")}}class Ig extends sg{constructor(bg){super(),this._type=bg[1],this._bbox=bg[2],this._colorStops=bg[3],this._p0=bg[4],this._p1=bg[5],this._r0=bg[6],this._r1=bg[7],this.matrix=null}_createGradient(bg){let pg;this._type==="axial"?pg=bg.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(pg=bg.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const fg of this._colorStops)pg.addColorStop(fg[0],fg[1]);return pg}getPattern(bg,pg,fg,wg){let Gg;if(wg===og.STROKE||wg===og.FILL){const Zg=pg.current.getClippedPathBoundingBox(wg,(0,ng.getCurrentTransform)(bg))||[0,0,0,0],$g=Math.ceil(Zg[2]-Zg[0])||1,Bg=Math.ceil(Zg[3]-Zg[1])||1,Wg=pg.cachedCanvases.getCanvas("pattern",$g,Bg,!0),yg=Wg.context;yg.clearRect(0,0,yg.canvas.width,yg.canvas.height),yg.beginPath(),yg.rect(0,0,yg.canvas.width,yg.canvas.height),yg.translate(-Zg[0],-Zg[1]),fg=ig.Util.transform(fg,[1,0,0,1,Zg[0],Zg[1]]),yg.transform(...pg.baseTransform),this.matrix&&yg.transform(...this.matrix),ag(yg,this._bbox),yg.fillStyle=this._createGradient(yg),yg.fill(),Gg=bg.createPattern(Wg.canvas,"no-repeat");const Ng=new DOMMatrix(fg);Gg.setTransform(Ng)}else ag(bg,this._bbox),Gg=this._createGradient(bg);return Gg}}function Cg(mg,bg,pg,fg,wg,Gg,Zg,$g){const Bg=bg.coords,Wg=bg.colors,yg=mg.data,Ng=mg.width*4;let vg;Bg[pg+1]>Bg[fg+1]&&(vg=pg,pg=fg,fg=vg,vg=Gg,Gg=Zg,Zg=vg),Bg[fg+1]>Bg[wg+1]&&(vg=fg,fg=wg,wg=vg,vg=Zg,Zg=$g,$g=vg),Bg[pg+1]>Bg[fg+1]&&(vg=pg,pg=fg,fg=vg,vg=Gg,Gg=Zg,Zg=vg);const Sg=(Bg[pg]+bg.offsetX)*bg.scaleX,Vg=(Bg[pg+1]+bg.offsetY)*bg.scaleY,Xg=(Bg[fg]+bg.offsetX)*bg.scaleX,Yg=(Bg[fg+1]+bg.offsetY)*bg.scaleY,Hg=(Bg[wg]+bg.offsetX)*bg.scaleX,kg=(Bg[wg+1]+bg.offsetY)*bg.scaleY;if(Vg>=kg)return;const Rg=Wg[Gg],Kg=Wg[Gg+1],jg=Wg[Gg+2],Dg=Wg[Zg],zg=Wg[Zg+1],Og=Wg[Zg+2],Jg=Wg[$g],Qg=Wg[$g+1],eo=Wg[$g+2],ca=Math.round(Vg),ua=Math.round(kg);let pa,is,Pg,la,ma,Ca,Eg,Mg;for(let Tg=ca;Tg<=ua;Tg++){if(Tg<Yg){const us=Tg<Vg?0:(Vg-Tg)/(Vg-Yg);pa=Sg-(Sg-Xg)*us,is=Rg-(Rg-Dg)*us,Pg=Kg-(Kg-zg)*us,la=jg-(jg-Og)*us}else{let us;Tg>kg?us=1:Yg===kg?us=0:us=(Yg-Tg)/(Yg-kg),pa=Xg-(Xg-Hg)*us,is=Dg-(Dg-Jg)*us,Pg=zg-(zg-Qg)*us,la=Og-(Og-eo)*us}let Ug;Tg<Vg?Ug=0:Tg>kg?Ug=1:Ug=(Vg-Tg)/(Vg-kg),ma=Sg-(Sg-Hg)*Ug,Ca=Rg-(Rg-Jg)*Ug,Eg=Kg-(Kg-Qg)*Ug,Mg=jg-(jg-eo)*Ug;const da=Math.round(Math.min(pa,ma)),ya=Math.round(Math.max(pa,ma));let eI=Ng*Tg+da*4;for(let us=da;us<=ya;us++)Ug=(pa-us)/(pa-ma),Ug<0?Ug=0:Ug>1&&(Ug=1),yg[eI++]=is-(is-Ca)*Ug|0,yg[eI++]=Pg-(Pg-Eg)*Ug|0,yg[eI++]=la-(la-Mg)*Ug|0,yg[eI++]=255}}function lg(mg,bg,pg){const fg=bg.coords,wg=bg.colors;let Gg,Zg;switch(bg.type){case"lattice":const $g=bg.verticesPerRow,Bg=Math.floor(fg.length/$g)-1,Wg=$g-1;for(Gg=0;Gg<Bg;Gg++){let yg=Gg*$g;for(let Ng=0;Ng<Wg;Ng++,yg++)Cg(mg,pg,fg[yg],fg[yg+1],fg[yg+$g],wg[yg],wg[yg+1],wg[yg+$g]),Cg(mg,pg,fg[yg+$g+1],fg[yg+1],fg[yg+$g],wg[yg+$g+1],wg[yg+1],wg[yg+$g])}break;case"triangles":for(Gg=0,Zg=fg.length;Gg<Zg;Gg+=3)Cg(mg,pg,fg[Gg],fg[Gg+1],fg[Gg+2],wg[Gg],wg[Gg+1],wg[Gg+2]);break;default:throw new Error("illegal figure")}}class Ag extends sg{constructor(bg){super(),this._coords=bg[2],this._colors=bg[3],this._figures=bg[4],this._bounds=bg[5],this._bbox=bg[7],this._background=bg[8],this.matrix=null}_createMeshCanvas(bg,pg,fg){const $g=Math.floor(this._bounds[0]),Bg=Math.floor(this._bounds[1]),Wg=Math.ceil(this._bounds[2])-$g,yg=Math.ceil(this._bounds[3])-Bg,Ng=Math.min(Math.ceil(Math.abs(Wg*bg[0]*1.1)),3e3),vg=Math.min(Math.ceil(Math.abs(yg*bg[1]*1.1)),3e3),Sg=Wg/Ng,Vg=yg/vg,Xg={coords:this._coords,colors:this._colors,offsetX:-$g,offsetY:-Bg,scaleX:1/Sg,scaleY:1/Vg},Yg=Ng+4,Hg=vg+4,kg=fg.getCanvas("mesh",Yg,Hg,!1),Rg=kg.context,Kg=Rg.createImageData(Ng,vg);if(pg){const Dg=Kg.data;for(let zg=0,Og=Dg.length;zg<Og;zg+=4)Dg[zg]=pg[0],Dg[zg+1]=pg[1],Dg[zg+2]=pg[2],Dg[zg+3]=255}for(const Dg of this._figures)lg(Kg,Dg,Xg);return Rg.putImageData(Kg,2,2),{canvas:kg.canvas,offsetX:$g-2*Sg,offsetY:Bg-2*Vg,scaleX:Sg,scaleY:Vg}}getPattern(bg,pg,fg,wg){ag(bg,this._bbox);let Gg;if(wg===og.SHADING)Gg=ig.Util.singularValueDecompose2dScale((0,ng.getCurrentTransform)(bg));else if(Gg=ig.Util.singularValueDecompose2dScale(pg.baseTransform),this.matrix){const $g=ig.Util.singularValueDecompose2dScale(this.matrix);Gg=[Gg[0]*$g[0],Gg[1]*$g[1]]}const Zg=this._createMeshCanvas(Gg,wg===og.SHADING?null:this._background,pg.cachedCanvases);return wg!==og.SHADING&&(bg.setTransform(...pg.baseTransform),this.matrix&&bg.transform(...this.matrix)),bg.translate(Zg.offsetX,Zg.offsetY),bg.scale(Zg.scaleX,Zg.scaleY),bg.createPattern(Zg.canvas,"no-repeat")}}class rg extends sg{getPattern(){return"hotpink"}}function cg(mg){switch(mg[0]){case"RadialAxial":return new Ig(mg);case"Mesh":return new Ag(mg);case"Dummy":return new rg}throw new Error(`Unknown IR type: ${mg[0]}`)}const ug={COLORED:1,UNCOLORED:2},hg=class hg{constructor(bg,pg,fg,wg,Gg){this.operatorList=bg[2],this.matrix=bg[3]||[1,0,0,1,0,0],this.bbox=bg[4],this.xstep=bg[5],this.ystep=bg[6],this.paintType=bg[7],this.tilingType=bg[8],this.color=pg,this.ctx=fg,this.canvasGraphicsFactory=wg,this.baseTransform=Gg}createPatternCanvas(bg){const pg=this.operatorList,fg=this.bbox,wg=this.xstep,Gg=this.ystep,Zg=this.paintType,$g=this.tilingType,Bg=this.color,Wg=this.canvasGraphicsFactory;(0,ig.info)("TilingType: "+$g);const yg=fg[0],Ng=fg[1],vg=fg[2],Sg=fg[3],Vg=ig.Util.singularValueDecompose2dScale(this.matrix),Xg=ig.Util.singularValueDecompose2dScale(this.baseTransform),Yg=[Vg[0]*Xg[0],Vg[1]*Xg[1]],Hg=this.getSizeAndScale(wg,this.ctx.canvas.width,Yg[0]),kg=this.getSizeAndScale(Gg,this.ctx.canvas.height,Yg[1]),Rg=bg.cachedCanvases.getCanvas("pattern",Hg.size,kg.size,!0),Kg=Rg.context,jg=Wg.createCanvasGraphics(Kg);jg.groupLevel=bg.groupLevel,this.setFillAndStrokeStyleToContext(jg,Zg,Bg);let Dg=yg,zg=Ng,Og=vg,Jg=Sg;return yg<0&&(Dg=0,Og+=Math.abs(yg)),Ng<0&&(zg=0,Jg+=Math.abs(Ng)),Kg.translate(-(Hg.scale*Dg),-(kg.scale*zg)),jg.transform(Hg.scale,0,0,kg.scale,0,0),Kg.save(),this.clipBbox(jg,Dg,zg,Og,Jg),jg.baseTransform=(0,ng.getCurrentTransform)(jg.ctx),jg.executeOperatorList(pg),jg.endDrawing(),{canvas:Rg.canvas,scaleX:Hg.scale,scaleY:kg.scale,offsetX:Dg,offsetY:zg}}getSizeAndScale(bg,pg,fg){bg=Math.abs(bg);const wg=Math.max(hg.MAX_PATTERN_SIZE,pg);let Gg=Math.ceil(bg*fg);return Gg>=wg?Gg=wg:fg=Gg/bg,{scale:fg,size:Gg}}clipBbox(bg,pg,fg,wg,Gg){const Zg=wg-pg,$g=Gg-fg;bg.ctx.rect(pg,fg,Zg,$g),bg.current.updateRectMinMax((0,ng.getCurrentTransform)(bg.ctx),[pg,fg,wg,Gg]),bg.clip(),bg.endPath()}setFillAndStrokeStyleToContext(bg,pg,fg){const wg=bg.ctx,Gg=bg.current;switch(pg){case ug.COLORED:const Zg=this.ctx;wg.fillStyle=Zg.fillStyle,wg.strokeStyle=Zg.strokeStyle,Gg.fillColor=Zg.fillStyle,Gg.strokeColor=Zg.strokeStyle;break;case ug.UNCOLORED:const $g=ig.Util.makeHexColor(fg[0],fg[1],fg[2]);wg.fillStyle=$g,wg.strokeStyle=$g,Gg.fillColor=$g,Gg.strokeColor=$g;break;default:throw new ig.FormatError(`Unsupported paint type: ${pg}`)}}getPattern(bg,pg,fg,wg){let Gg=fg;wg!==og.SHADING&&(Gg=ig.Util.transform(Gg,pg.baseTransform),this.matrix&&(Gg=ig.Util.transform(Gg,this.matrix)));const Zg=this.createPatternCanvas(pg);let $g=new DOMMatrix(Gg);$g=$g.translate(Zg.offsetX,Zg.offsetY),$g=$g.scale(1/Zg.scaleX,1/Zg.scaleY);const Bg=bg.createPattern(Zg.canvas,"repeat");return Bg.setTransform($g),Bg}};UI(hg,"MAX_PATTERN_SIZE",3e3);let dg=hg;eg.TilingPattern=dg}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.convertBlackAndWhiteToRGBA=og,eg.convertToRGBA=ng,eg.grayToRGBA=sg;var ig=gg(1);function ng(Ig){switch(Ig.kind){case ig.ImageKind.GRAYSCALE_1BPP:return og(Ig);case ig.ImageKind.RGB_24BPP:return ag(Ig)}return null}function og({src:Ig,srcPos:Cg=0,dest:lg,width:Ag,height:rg,nonBlackColor:cg=4294967295,inverseDecode:ug=!1}){const dg=ig.FeatureTest.isLittleEndian?4278190080:255,[hg,mg]=ug?[cg,dg]:[dg,cg],bg=Ag>>3,pg=Ag&7,fg=Ig.length;lg=new Uint32Array(lg.buffer);let wg=0;for(let Gg=0;Gg<rg;Gg++){for(const $g=Cg+bg;Cg<$g;Cg++){const Bg=Cg<fg?Ig[Cg]:255;lg[wg++]=Bg&128?mg:hg,lg[wg++]=Bg&64?mg:hg,lg[wg++]=Bg&32?mg:hg,lg[wg++]=Bg&16?mg:hg,lg[wg++]=Bg&8?mg:hg,lg[wg++]=Bg&4?mg:hg,lg[wg++]=Bg&2?mg:hg,lg[wg++]=Bg&1?mg:hg}if(pg===0)continue;const Zg=Cg<fg?Ig[Cg++]:255;for(let $g=0;$g<pg;$g++)lg[wg++]=Zg&1<<7-$g?mg:hg}return{srcPos:Cg,destPos:wg}}function ag({src:Ig,srcPos:Cg=0,dest:lg,destPos:Ag=0,width:rg,height:cg}){let ug=0;const dg=Ig.length>>2,hg=new Uint32Array(Ig.buffer,Cg,dg);if(ig.FeatureTest.isLittleEndian){for(;ug<dg-2;ug+=3,Ag+=4){const mg=hg[ug],bg=hg[ug+1],pg=hg[ug+2];lg[Ag]=mg|4278190080,lg[Ag+1]=mg>>>24|bg<<8|4278190080,lg[Ag+2]=bg>>>16|pg<<16|4278190080,lg[Ag+3]=pg>>>8|4278190080}for(let mg=ug*4,bg=Ig.length;mg<bg;mg+=3)lg[Ag++]=Ig[mg]|Ig[mg+1]<<8|Ig[mg+2]<<16|4278190080}else{for(;ug<dg-2;ug+=3,Ag+=4){const mg=hg[ug],bg=hg[ug+1],pg=hg[ug+2];lg[Ag]=mg|255,lg[Ag+1]=mg<<24|bg>>>8|255,lg[Ag+2]=bg<<16|pg>>>16|255,lg[Ag+3]=pg<<8|255}for(let mg=ug*4,bg=Ig.length;mg<bg;mg+=3)lg[Ag++]=Ig[mg]<<24|Ig[mg+1]<<16|Ig[mg+2]<<8|255}return{srcPos:Cg,destPos:Ag}}function sg(Ig,Cg){if(ig.FeatureTest.isLittleEndian)for(let lg=0,Ag=Ig.length;lg<Ag;lg++)Cg[lg]=Ig[lg]*65793|4278190080;else for(let lg=0,Ag=Ig.length;lg<Ag;lg++)Cg[lg]=Ig[lg]*16843008|255}}),((tg,eg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.GlobalWorkerOptions=void 0;const gg=Object.create(null);eg.GlobalWorkerOptions=gg,gg.workerPort=null,gg.workerSrc=""}),((tg,eg,gg)=>{var Ig,rb,cb,Pd;Object.defineProperty(eg,"__esModule",{value:!0}),eg.MessageHandler=void 0;var ig=gg(1);const ng={DATA:1,ERROR:2},og={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function ag(rg){switch(rg instanceof Error||typeof rg=="object"&&rg!==null||(0,ig.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),rg.name){case"AbortException":return new ig.AbortException(rg.message);case"MissingPDFException":return new ig.MissingPDFException(rg.message);case"PasswordException":return new ig.PasswordException(rg.message,rg.code);case"UnexpectedResponseException":return new ig.UnexpectedResponseException(rg.message,rg.status);case"UnknownErrorException":return new ig.UnknownErrorException(rg.message,rg.details);default:return new ig.UnknownErrorException(rg.message,rg.toString())}}class sg{constructor(cg,ug,dg){ZI(this,Ig);this.sourceName=cg,this.targetName=ug,this.comObj=dg,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=hg=>{const mg=hg.data;if(mg.targetName!==this.sourceName)return;if(mg.stream){hI(this,Ig,cb).call(this,mg);return}if(mg.callback){const pg=mg.callbackId,fg=this.callbackCapabilities[pg];if(!fg)throw new Error(`Cannot resolve callback ${pg}`);if(delete this.callbackCapabilities[pg],mg.callback===ng.DATA)fg.resolve(mg.data);else if(mg.callback===ng.ERROR)fg.reject(ag(mg.reason));else throw new Error("Unexpected callback case");return}const bg=this.actionHandler[mg.action];if(!bg)throw new Error(`Unknown action from worker: ${mg.action}`);if(mg.callbackId){const pg=this.sourceName,fg=mg.sourceName;new Promise(function(wg){wg(bg(mg.data))}).then(function(wg){dg.postMessage({sourceName:pg,targetName:fg,callback:ng.DATA,callbackId:mg.callbackId,data:wg})},function(wg){dg.postMessage({sourceName:pg,targetName:fg,callback:ng.ERROR,callbackId:mg.callbackId,reason:ag(wg)})});return}if(mg.streamId){hI(this,Ig,rb).call(this,mg);return}bg(mg.data)},dg.addEventListener("message",this._onComObjOnMessage)}on(cg,ug){const dg=this.actionHandler;if(dg[cg])throw new Error(`There is already an actionName called "${cg}"`);dg[cg]=ug}send(cg,ug,dg){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:cg,data:ug},dg)}sendWithPromise(cg,ug,dg){const hg=this.callbackId++,mg=new ig.PromiseCapability;this.callbackCapabilities[hg]=mg;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:cg,callbackId:hg,data:ug},dg)}catch(bg){mg.reject(bg)}return mg.promise}sendWithStream(cg,ug,dg,hg){const mg=this.streamId++,bg=this.sourceName,pg=this.targetName,fg=this.comObj;return new ReadableStream({start:wg=>{const Gg=new ig.PromiseCapability;return this.streamControllers[mg]={controller:wg,startCall:Gg,pullCall:null,cancelCall:null,isClosed:!1},fg.postMessage({sourceName:bg,targetName:pg,action:cg,streamId:mg,data:ug,desiredSize:wg.desiredSize},hg),Gg.promise},pull:wg=>{const Gg=new ig.PromiseCapability;return this.streamControllers[mg].pullCall=Gg,fg.postMessage({sourceName:bg,targetName:pg,stream:og.PULL,streamId:mg,desiredSize:wg.desiredSize}),Gg.promise},cancel:wg=>{(0,ig.assert)(wg instanceof Error,"cancel must have a valid reason");const Gg=new ig.PromiseCapability;return this.streamControllers[mg].cancelCall=Gg,this.streamControllers[mg].isClosed=!0,fg.postMessage({sourceName:bg,targetName:pg,stream:og.CANCEL,streamId:mg,reason:ag(wg)}),Gg.promise}},dg)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}Ig=new WeakSet,rb=function(cg){const ug=cg.streamId,dg=this.sourceName,hg=cg.sourceName,mg=this.comObj,bg=this,pg=this.actionHandler[cg.action],fg={enqueue(wg,Gg=1,Zg){if(this.isCancelled)return;const $g=this.desiredSize;this.desiredSize-=Gg,$g>0&&this.desiredSize<=0&&(this.sinkCapability=new ig.PromiseCapability,this.ready=this.sinkCapability.promise),mg.postMessage({sourceName:dg,targetName:hg,stream:og.ENQUEUE,streamId:ug,chunk:wg},Zg)},close(){this.isCancelled||(this.isCancelled=!0,mg.postMessage({sourceName:dg,targetName:hg,stream:og.CLOSE,streamId:ug}),delete bg.streamSinks[ug])},error(wg){(0,ig.assert)(wg instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,mg.postMessage({sourceName:dg,targetName:hg,stream:og.ERROR,streamId:ug,reason:ag(wg)}))},sinkCapability:new ig.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:cg.desiredSize,ready:null};fg.sinkCapability.resolve(),fg.ready=fg.sinkCapability.promise,this.streamSinks[ug]=fg,new Promise(function(wg){wg(pg(cg.data,fg))}).then(function(){mg.postMessage({sourceName:dg,targetName:hg,stream:og.START_COMPLETE,streamId:ug,success:!0})},function(wg){mg.postMessage({sourceName:dg,targetName:hg,stream:og.START_COMPLETE,streamId:ug,reason:ag(wg)})})},cb=function(cg){const ug=cg.streamId,dg=this.sourceName,hg=cg.sourceName,mg=this.comObj,bg=this.streamControllers[ug],pg=this.streamSinks[ug];switch(cg.stream){case og.START_COMPLETE:cg.success?bg.startCall.resolve():bg.startCall.reject(ag(cg.reason));break;case og.PULL_COMPLETE:cg.success?bg.pullCall.resolve():bg.pullCall.reject(ag(cg.reason));break;case og.PULL:if(!pg){mg.postMessage({sourceName:dg,targetName:hg,stream:og.PULL_COMPLETE,streamId:ug,success:!0});break}pg.desiredSize<=0&&cg.desiredSize>0&&pg.sinkCapability.resolve(),pg.desiredSize=cg.desiredSize,new Promise(function(fg){var wg;fg((wg=pg.onPull)==null?void 0:wg.call(pg))}).then(function(){mg.postMessage({sourceName:dg,targetName:hg,stream:og.PULL_COMPLETE,streamId:ug,success:!0})},function(fg){mg.postMessage({sourceName:dg,targetName:hg,stream:og.PULL_COMPLETE,streamId:ug,reason:ag(fg)})});break;case og.ENQUEUE:if((0,ig.assert)(bg,"enqueue should have stream controller"),bg.isClosed)break;bg.controller.enqueue(cg.chunk);break;case og.CLOSE:if((0,ig.assert)(bg,"close should have stream controller"),bg.isClosed)break;bg.isClosed=!0,bg.controller.close(),hI(this,Ig,Pd).call(this,bg,ug);break;case og.ERROR:(0,ig.assert)(bg,"error should have stream controller"),bg.controller.error(ag(cg.reason)),hI(this,Ig,Pd).call(this,bg,ug);break;case og.CANCEL_COMPLETE:cg.success?bg.cancelCall.resolve():bg.cancelCall.reject(ag(cg.reason)),hI(this,Ig,Pd).call(this,bg,ug);break;case og.CANCEL:if(!pg)break;new Promise(function(fg){var wg;fg((wg=pg.onCancel)==null?void 0:wg.call(pg,ag(cg.reason)))}).then(function(){mg.postMessage({sourceName:dg,targetName:hg,stream:og.CANCEL_COMPLETE,streamId:ug,success:!0})},function(fg){mg.postMessage({sourceName:dg,targetName:hg,stream:og.CANCEL_COMPLETE,streamId:ug,reason:ag(fg)})}),pg.sinkCapability.reject(ag(cg.reason)),pg.isCancelled=!0,delete this.streamSinks[ug];break;default:throw new Error("Unexpected stream case")}},Pd=async function(cg,ug){var dg,hg,mg;await Promise.allSettled([(dg=cg.startCall)==null?void 0:dg.promise,(hg=cg.pullCall)==null?void 0:hg.promise,(mg=cg.cancelCall)==null?void 0:mg.promise]),delete this.streamControllers[ug]},eg.MessageHandler=sg}),((tg,eg,gg)=>{var og,ag;Object.defineProperty(eg,"__esModule",{value:!0}),eg.Metadata=void 0;var ig=gg(1);class ng{constructor({parsedData:Ig,rawData:Cg}){ZI(this,og);ZI(this,ag);fI(this,og,Ig),fI(this,ag,Cg)}getRaw(){return aa(this,ag)}get(Ig){return aa(this,og).get(Ig)??null}getAll(){return(0,ig.objectFromMap)(aa(this,og))}has(Ig){return aa(this,og).has(Ig)}}og=new WeakMap,ag=new WeakMap,eg.Metadata=ng}),((tg,eg,gg)=>{var Ig,Cg,lg,Ag,rg,cg,N0;Object.defineProperty(eg,"__esModule",{value:!0}),eg.OptionalContentConfig=void 0;var ig=gg(1),ng=gg(8);const og=Symbol("INTERNAL");class ag{constructor(hg,mg){ZI(this,Ig,!0);this.name=hg,this.intent=mg}get visible(){return aa(this,Ig)}_setVisible(hg,mg){hg!==og&&(0,ig.unreachable)("Internal method `_setVisible` called."),fI(this,Ig,mg)}}Ig=new WeakMap;class sg{constructor(hg){ZI(this,cg);ZI(this,Cg,null);ZI(this,lg,new Map);ZI(this,Ag,null);ZI(this,rg,null);if(this.name=null,this.creator=null,hg!==null){this.name=hg.name,this.creator=hg.creator,fI(this,rg,hg.order);for(const mg of hg.groups)aa(this,lg).set(mg.id,new ag(mg.name,mg.intent));if(hg.baseState==="OFF")for(const mg of aa(this,lg).values())mg._setVisible(og,!1);for(const mg of hg.on)aa(this,lg).get(mg)._setVisible(og,!0);for(const mg of hg.off)aa(this,lg).get(mg)._setVisible(og,!1);fI(this,Ag,this.getHash())}}isVisible(hg){if(aa(this,lg).size===0)return!0;if(!hg)return(0,ig.warn)("Optional content group not defined."),!0;if(hg.type==="OCG")return aa(this,lg).has(hg.id)?aa(this,lg).get(hg.id).visible:((0,ig.warn)(`Optional content group not found: ${hg.id}`),!0);if(hg.type==="OCMD"){if(hg.expression)return hI(this,cg,N0).call(this,hg.expression);if(!hg.policy||hg.policy==="AnyOn"){for(const mg of hg.ids){if(!aa(this,lg).has(mg))return(0,ig.warn)(`Optional content group not found: ${mg}`),!0;if(aa(this,lg).get(mg).visible)return!0}return!1}else if(hg.policy==="AllOn"){for(const mg of hg.ids){if(!aa(this,lg).has(mg))return(0,ig.warn)(`Optional content group not found: ${mg}`),!0;if(!aa(this,lg).get(mg).visible)return!1}return!0}else if(hg.policy==="AnyOff"){for(const mg of hg.ids){if(!aa(this,lg).has(mg))return(0,ig.warn)(`Optional content group not found: ${mg}`),!0;if(!aa(this,lg).get(mg).visible)return!0}return!1}else if(hg.policy==="AllOff"){for(const mg of hg.ids){if(!aa(this,lg).has(mg))return(0,ig.warn)(`Optional content group not found: ${mg}`),!0;if(aa(this,lg).get(mg).visible)return!1}return!0}return(0,ig.warn)(`Unknown optional content policy ${hg.policy}.`),!0}return(0,ig.warn)(`Unknown group type ${hg.type}.`),!0}setVisibility(hg,mg=!0){if(!aa(this,lg).has(hg)){(0,ig.warn)(`Optional content group not found: ${hg}`);return}aa(this,lg).get(hg)._setVisible(og,!!mg),fI(this,Cg,null)}get hasInitialVisibility(){return aa(this,Ag)===null||this.getHash()===aa(this,Ag)}getOrder(){return aa(this,lg).size?aa(this,rg)?aa(this,rg).slice():[...aa(this,lg).keys()]:null}getGroups(){return aa(this,lg).size>0?(0,ig.objectFromMap)(aa(this,lg)):null}getGroup(hg){return aa(this,lg).get(hg)||null}getHash(){if(aa(this,Cg)!==null)return aa(this,Cg);const hg=new ng.MurmurHash3_64;for(const[mg,bg]of aa(this,lg))hg.update(`${mg}:${bg.visible}`);return fI(this,Cg,hg.hexdigest())}}Cg=new WeakMap,lg=new WeakMap,Ag=new WeakMap,rg=new WeakMap,cg=new WeakSet,N0=function(hg){const mg=hg.length;if(mg<2)return!0;const bg=hg[0];for(let pg=1;pg<mg;pg++){const fg=hg[pg];let wg;if(Array.isArray(fg))wg=hI(this,cg,N0).call(this,fg);else if(aa(this,lg).has(fg))wg=aa(this,lg).get(fg).visible;else return(0,ig.warn)(`Optional content group not found: ${fg}`),!0;switch(bg){case"And":if(!wg)return!1;break;case"Or":if(wg)return!0;break;case"Not":return!wg;default:return!0}}return bg==="And"},eg.OptionalContentConfig=sg}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.PDFDataTransportStream=void 0;var ig=gg(1),ng=gg(6);class og{constructor({length:Cg,initialData:lg,progressiveDone:Ag=!1,contentDispositionFilename:rg=null,disableRange:cg=!1,disableStream:ug=!1},dg){if((0,ig.assert)(dg,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=Ag,this._contentDispositionFilename=rg,(lg==null?void 0:lg.length)>0){const hg=lg instanceof Uint8Array&&lg.byteLength===lg.buffer.byteLength?lg.buffer:new Uint8Array(lg).buffer;this._queuedChunks.push(hg)}this._pdfDataRangeTransport=dg,this._isStreamingSupported=!ug,this._isRangeSupported=!cg,this._contentLength=Cg,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener((hg,mg)=>{this._onReceiveData({begin:hg,chunk:mg})}),this._pdfDataRangeTransport.addProgressListener((hg,mg)=>{this._onProgress({loaded:hg,total:mg})}),this._pdfDataRangeTransport.addProgressiveReadListener(hg=>{this._onReceiveData({chunk:hg})}),this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),this._pdfDataRangeTransport.transportReady()}_onReceiveData({begin:Cg,chunk:lg}){const Ag=lg instanceof Uint8Array&&lg.byteLength===lg.buffer.byteLength?lg.buffer:new Uint8Array(lg).buffer;if(Cg===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(Ag):this._queuedChunks.push(Ag);else{const rg=this._rangeReaders.some(function(cg){return cg._begin!==Cg?!1:(cg._enqueue(Ag),!0)});(0,ig.assert)(rg,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var Cg;return((Cg=this._fullRequestReader)==null?void 0:Cg._loaded)??0}_onProgress(Cg){var lg,Ag,rg,cg;Cg.total===void 0?(Ag=(lg=this._rangeReaders[0])==null?void 0:lg.onProgress)==null||Ag.call(lg,{loaded:Cg.loaded}):(cg=(rg=this._fullRequestReader)==null?void 0:rg.onProgress)==null||cg.call(rg,{loaded:Cg.loaded,total:Cg.total})}_onProgressiveDone(){var Cg;(Cg=this._fullRequestReader)==null||Cg.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(Cg){const lg=this._rangeReaders.indexOf(Cg);lg>=0&&this._rangeReaders.splice(lg,1)}getFullReader(){(0,ig.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const Cg=this._queuedChunks;return this._queuedChunks=null,new ag(this,Cg,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(Cg,lg){if(lg<=this._progressiveDataLength)return null;const Ag=new sg(this,Cg,lg);return this._pdfDataRangeTransport.requestDataRange(Cg,lg),this._rangeReaders.push(Ag),Ag}cancelAllRequests(Cg){var lg;(lg=this._fullRequestReader)==null||lg.cancel(Cg);for(const Ag of this._rangeReaders.slice(0))Ag.cancel(Cg);this._pdfDataRangeTransport.abort()}}eg.PDFDataTransportStream=og;class ag{constructor(Cg,lg,Ag=!1,rg=null){this._stream=Cg,this._done=Ag||!1,this._filename=(0,ng.isPdfFile)(rg)?rg:null,this._queuedChunks=lg||[],this._loaded=0;for(const cg of this._queuedChunks)this._loaded+=cg.byteLength;this._requests=[],this._headersReady=Promise.resolve(),Cg._fullRequestReader=this,this.onProgress=null}_enqueue(Cg){this._done||(this._requests.length>0?this._requests.shift().resolve({value:Cg,done:!1}):this._queuedChunks.push(Cg),this._loaded+=Cg.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const Cg=new ig.PromiseCapability;return this._requests.push(Cg),Cg.promise}cancel(Cg){this._done=!0;for(const lg of this._requests)lg.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class sg{constructor(Cg,lg,Ag){this._stream=Cg,this._begin=lg,this._end=Ag,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(Cg){if(!this._done){if(this._requests.length===0)this._queuedChunk=Cg;else{this._requests.shift().resolve({value:Cg,done:!1});for(const Ag of this._requests)Ag.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const lg=this._queuedChunk;return this._queuedChunk=null,{value:lg,done:!1}}if(this._done)return{value:void 0,done:!0};const Cg=new ig.PromiseCapability;return this._requests.push(Cg),Cg.promise}cancel(Cg){this._done=!0;for(const lg of this._requests)lg.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.PDFFetchStream=void 0;var ig=gg(1),ng=gg(20);function og(Ag,rg,cg){return{method:"GET",headers:Ag,signal:cg.signal,mode:"cors",credentials:rg?"include":"same-origin",redirect:"follow"}}function ag(Ag){const rg=new Headers;for(const cg in Ag){const ug=Ag[cg];ug!==void 0&&rg.append(cg,ug)}return rg}function sg(Ag){return Ag instanceof Uint8Array?Ag.buffer:Ag instanceof ArrayBuffer?Ag:((0,ig.warn)(`getArrayBuffer - unexpected data format: ${Ag}`),new Uint8Array(Ag).buffer)}class Ig{constructor(rg){this.source=rg,this.isHttp=/^https?:/i.test(rg.url),this.httpHeaders=this.isHttp&&rg.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var rg;return((rg=this._fullRequestReader)==null?void 0:rg._loaded)??0}getFullReader(){return(0,ig.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Cg(this),this._fullRequestReader}getRangeReader(rg,cg){if(cg<=this._progressiveDataLength)return null;const ug=new lg(this,rg,cg);return this._rangeRequestReaders.push(ug),ug}cancelAllRequests(rg){var cg;(cg=this._fullRequestReader)==null||cg.cancel(rg);for(const ug of this._rangeRequestReaders.slice(0))ug.cancel(rg)}}eg.PDFFetchStream=Ig;class Cg{constructor(rg){this._stream=rg,this._reader=null,this._loaded=0,this._filename=null;const cg=rg.source;this._withCredentials=cg.withCredentials||!1,this._contentLength=cg.length,this._headersCapability=new ig.PromiseCapability,this._disableRange=cg.disableRange||!1,this._rangeChunkSize=cg.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!cg.disableStream,this._isRangeSupported=!cg.disableRange,this._headers=ag(this._stream.httpHeaders);const ug=cg.url;fetch(ug,og(this._headers,this._withCredentials,this._abortController)).then(dg=>{if(!(0,ng.validateResponseStatus)(dg.status))throw(0,ng.createResponseStatusError)(dg.status,ug);this._reader=dg.body.getReader(),this._headersCapability.resolve();const hg=pg=>dg.headers.get(pg),{allowRangeRequests:mg,suggestedLength:bg}=(0,ng.validateRangeRequestCapabilities)({getResponseHeader:hg,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=mg,this._contentLength=bg||this._contentLength,this._filename=(0,ng.extractFilenameFromHeader)(hg),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ig.AbortException("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var ug;await this._headersCapability.promise;const{value:rg,done:cg}=await this._reader.read();return cg?{value:rg,done:cg}:(this._loaded+=rg.byteLength,(ug=this.onProgress)==null||ug.call(this,{loaded:this._loaded,total:this._contentLength}),{value:sg(rg),done:!1})}cancel(rg){var cg;(cg=this._reader)==null||cg.cancel(rg),this._abortController.abort()}}class lg{constructor(rg,cg,ug){this._stream=rg,this._reader=null,this._loaded=0;const dg=rg.source;this._withCredentials=dg.withCredentials||!1,this._readCapability=new ig.PromiseCapability,this._isStreamingSupported=!dg.disableStream,this._abortController=new AbortController,this._headers=ag(this._stream.httpHeaders),this._headers.append("Range",`bytes=${cg}-${ug-1}`);const hg=dg.url;fetch(hg,og(this._headers,this._withCredentials,this._abortController)).then(mg=>{if(!(0,ng.validateResponseStatus)(mg.status))throw(0,ng.createResponseStatusError)(mg.status,hg);this._readCapability.resolve(),this._reader=mg.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var ug;await this._readCapability.promise;const{value:rg,done:cg}=await this._reader.read();return cg?{value:rg,done:cg}:(this._loaded+=rg.byteLength,(ug=this.onProgress)==null||ug.call(this,{loaded:this._loaded}),{value:sg(rg),done:!1})}cancel(rg){var cg;(cg=this._reader)==null||cg.cancel(rg),this._abortController.abort()}}}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.createResponseStatusError=Ig,eg.extractFilenameFromHeader=sg,eg.validateRangeRequestCapabilities=ag,eg.validateResponseStatus=Cg;var ig=gg(1),ng=gg(21),og=gg(6);function ag({getResponseHeader:lg,isHttp:Ag,rangeChunkSize:rg,disableRange:cg}){const ug={allowRangeRequests:!1,suggestedLength:void 0},dg=parseInt(lg("Content-Length"),10);return!Number.isInteger(dg)||(ug.suggestedLength=dg,dg<=2*rg)||cg||!Ag||lg("Accept-Ranges")!=="bytes"||(lg("Content-Encoding")||"identity")!=="identity"||(ug.allowRangeRequests=!0),ug}function sg(lg){const Ag=lg("Content-Disposition");if(Ag){let rg=(0,ng.getFilenameFromContentDispositionHeader)(Ag);if(rg.includes("%"))try{rg=decodeURIComponent(rg)}catch{}if((0,og.isPdfFile)(rg))return rg}return null}function Ig(lg,Ag){return lg===404||lg===0&&Ag.startsWith("file:")?new ig.MissingPDFException('Missing PDF "'+Ag+'".'):new ig.UnexpectedResponseException(`Unexpected server response (${lg}) while retrieving PDF "${Ag}".`,lg)}function Cg(lg){return lg===200||lg===206}}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.getFilenameFromContentDispositionHeader=ng;var ig=gg(1);function ng(og){let ag=!0,sg=Ig("filename\\*","i").exec(og);if(sg){sg=sg[1];let dg=rg(sg);return dg=unescape(dg),dg=cg(dg),dg=ug(dg),lg(dg)}if(sg=Ag(og),sg){const dg=ug(sg);return lg(dg)}if(sg=Ig("filename","i").exec(og),sg){sg=sg[1];let dg=rg(sg);return dg=ug(dg),lg(dg)}function Ig(dg,hg){return new RegExp("(?:^|;)\\s*"+dg+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',hg)}function Cg(dg,hg){if(dg){if(!/^[\x00-\xFF]+$/.test(hg))return hg;try{const mg=new TextDecoder(dg,{fatal:!0}),bg=(0,ig.stringToBytes)(hg);hg=mg.decode(bg),ag=!1}catch{}}return hg}function lg(dg){return ag&&/[\x80-\xff]/.test(dg)&&(dg=Cg("utf-8",dg),ag&&(dg=Cg("iso-8859-1",dg))),dg}function Ag(dg){const hg=[];let mg;const bg=Ig("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(mg=bg.exec(dg))!==null;){let[,fg,wg,Gg]=mg;if(fg=parseInt(fg,10),fg in hg){if(fg===0)break;continue}hg[fg]=[wg,Gg]}const pg=[];for(let fg=0;fg<hg.length&&fg in hg;++fg){let[wg,Gg]=hg[fg];Gg=rg(Gg),wg&&(Gg=unescape(Gg),fg===0&&(Gg=cg(Gg))),pg.push(Gg)}return pg.join("")}function rg(dg){if(dg.startsWith('"')){const hg=dg.slice(1).split('\\"');for(let mg=0;mg<hg.length;++mg){const bg=hg[mg].indexOf('"');bg!==-1&&(hg[mg]=hg[mg].slice(0,bg),hg.length=mg+1),hg[mg]=hg[mg].replaceAll(/\\(.)/g,"$1")}dg=hg.join('"')}return dg}function cg(dg){const hg=dg.indexOf("'");if(hg===-1)return dg;const mg=dg.slice(0,hg),pg=dg.slice(hg+1).replace(/^[^']*'/,"");return Cg(mg,pg)}function ug(dg){return!dg.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(dg)?dg:dg.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(hg,mg,bg,pg){if(bg==="q"||bg==="Q")return pg=pg.replaceAll("_"," "),pg=pg.replaceAll(/=([0-9a-fA-F]{2})/g,function(fg,wg){return String.fromCharCode(parseInt(wg,16))}),Cg(mg,pg);try{pg=atob(pg)}catch{}return Cg(mg,pg)})}return""}}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.PDFNetworkStream=void 0;var ig=gg(1),ng=gg(20);const og=200,ag=206;function sg(rg){const cg=rg.response;return typeof cg!="string"?cg:(0,ig.stringToBytes)(cg).buffer}class Ig{constructor(cg,ug={}){this.url=cg,this.isHttp=/^https?:/i.test(cg),this.httpHeaders=this.isHttp&&ug.httpHeaders||Object.create(null),this.withCredentials=ug.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(cg,ug,dg){const hg={begin:cg,end:ug};for(const mg in dg)hg[mg]=dg[mg];return this.request(hg)}requestFull(cg){return this.request(cg)}request(cg){const ug=new XMLHttpRequest,dg=this.currXhrId++,hg=this.pendingRequests[dg]={xhr:ug};ug.open("GET",this.url),ug.withCredentials=this.withCredentials;for(const mg in this.httpHeaders){const bg=this.httpHeaders[mg];bg!==void 0&&ug.setRequestHeader(mg,bg)}return this.isHttp&&"begin"in cg&&"end"in cg?(ug.setRequestHeader("Range",`bytes=${cg.begin}-${cg.end-1}`),hg.expectedStatus=ag):hg.expectedStatus=og,ug.responseType="arraybuffer",cg.onError&&(ug.onerror=function(mg){cg.onError(ug.status)}),ug.onreadystatechange=this.onStateChange.bind(this,dg),ug.onprogress=this.onProgress.bind(this,dg),hg.onHeadersReceived=cg.onHeadersReceived,hg.onDone=cg.onDone,hg.onError=cg.onError,hg.onProgress=cg.onProgress,ug.send(null),dg}onProgress(cg,ug){var hg;const dg=this.pendingRequests[cg];dg&&((hg=dg.onProgress)==null||hg.call(dg,ug))}onStateChange(cg,ug){var fg,wg,Gg;const dg=this.pendingRequests[cg];if(!dg)return;const hg=dg.xhr;if(hg.readyState>=2&&dg.onHeadersReceived&&(dg.onHeadersReceived(),delete dg.onHeadersReceived),hg.readyState!==4||!(cg in this.pendingRequests))return;if(delete this.pendingRequests[cg],hg.status===0&&this.isHttp){(fg=dg.onError)==null||fg.call(dg,hg.status);return}const mg=hg.status||og;if(!(mg===og&&dg.expectedStatus===ag)&&mg!==dg.expectedStatus){(wg=dg.onError)==null||wg.call(dg,hg.status);return}const pg=sg(hg);if(mg===ag){const Zg=hg.getResponseHeader("Content-Range"),$g=/bytes (\d+)-(\d+)\/(\d+)/.exec(Zg);dg.onDone({begin:parseInt($g[1],10),chunk:pg})}else pg?dg.onDone({begin:0,chunk:pg}):(Gg=dg.onError)==null||Gg.call(dg,hg.status)}getRequestXhr(cg){return this.pendingRequests[cg].xhr}isPendingRequest(cg){return cg in this.pendingRequests}abortRequest(cg){const ug=this.pendingRequests[cg].xhr;delete this.pendingRequests[cg],ug.abort()}}class Cg{constructor(cg){this._source=cg,this._manager=new Ig(cg.url,{httpHeaders:cg.httpHeaders,withCredentials:cg.withCredentials}),this._rangeChunkSize=cg.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(cg){const ug=this._rangeRequestReaders.indexOf(cg);ug>=0&&this._rangeRequestReaders.splice(ug,1)}getFullReader(){return(0,ig.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new lg(this._manager,this._source),this._fullRequestReader}getRangeReader(cg,ug){const dg=new Ag(this._manager,cg,ug);return dg.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(dg),dg}cancelAllRequests(cg){var ug;(ug=this._fullRequestReader)==null||ug.cancel(cg);for(const dg of this._rangeRequestReaders.slice(0))dg.cancel(cg)}}eg.PDFNetworkStream=Cg;class lg{constructor(cg,ug){this._manager=cg;const dg={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=ug.url,this._fullRequestId=cg.requestFull(dg),this._headersReceivedCapability=new ig.PromiseCapability,this._disableRange=ug.disableRange||!1,this._contentLength=ug.length,this._rangeChunkSize=ug.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const cg=this._fullRequestId,ug=this._manager.getRequestXhr(cg),dg=bg=>ug.getResponseHeader(bg),{allowRangeRequests:hg,suggestedLength:mg}=(0,ng.validateRangeRequestCapabilities)({getResponseHeader:dg,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});hg&&(this._isRangeSupported=!0),this._contentLength=mg||this._contentLength,this._filename=(0,ng.extractFilenameFromHeader)(dg),this._isRangeSupported&&this._manager.abortRequest(cg),this._headersReceivedCapability.resolve()}_onDone(cg){if(cg&&(this._requests.length>0?this._requests.shift().resolve({value:cg.chunk,done:!1}):this._cachedChunks.push(cg.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const ug of this._requests)ug.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(cg){this._storedError=(0,ng.createResponseStatusError)(cg,this._url),this._headersReceivedCapability.reject(this._storedError);for(const ug of this._requests)ug.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(cg){var ug;(ug=this.onProgress)==null||ug.call(this,{loaded:cg.loaded,total:cg.lengthComputable?cg.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const cg=new ig.PromiseCapability;return this._requests.push(cg),cg.promise}cancel(cg){this._done=!0,this._headersReceivedCapability.reject(cg);for(const ug of this._requests)ug.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Ag{constructor(cg,ug,dg){this._manager=cg;const hg={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=cg.url,this._requestId=cg.requestRange(ug,dg,hg),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var cg;(cg=this.onClosed)==null||cg.call(this,this)}_onDone(cg){const ug=cg.chunk;this._requests.length>0?this._requests.shift().resolve({value:ug,done:!1}):this._queuedChunk=ug,this._done=!0;for(const dg of this._requests)dg.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(cg){this._storedError=(0,ng.createResponseStatusError)(cg,this._url);for(const ug of this._requests)ug.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(cg){var ug;this.isStreamingSupported||(ug=this.onProgress)==null||ug.call(this,{loaded:cg.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const ug=this._queuedChunk;return this._queuedChunk=null,{value:ug,done:!1}}if(this._done)return{value:void 0,done:!0};const cg=new ig.PromiseCapability;return this._requests.push(cg),cg.promise}cancel(cg){this._done=!0;for(const ug of this._requests)ug.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.PDFNodeStream=void 0;var ig=gg(1),ng=gg(20);const og=/^file:\/\/\/[a-zA-Z]:\//;function ag(dg){const hg=require$$5,mg=hg.parse(dg);return mg.protocol==="file:"||mg.host?mg:/^[a-z]:[/\\]/i.test(dg)?hg.parse(`file:///${dg}`):(mg.host||(mg.protocol="file:"),mg)}class sg{constructor(hg){this.source=hg,this.url=ag(hg.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&hg.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var hg;return((hg=this._fullRequestReader)==null?void 0:hg._loaded)??0}getFullReader(){return(0,ig.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new cg(this):new Ag(this),this._fullRequestReader}getRangeReader(hg,mg){if(mg<=this._progressiveDataLength)return null;const bg=this.isFsUrl?new ug(this,hg,mg):new rg(this,hg,mg);return this._rangeRequestReaders.push(bg),bg}cancelAllRequests(hg){var mg;(mg=this._fullRequestReader)==null||mg.cancel(hg);for(const bg of this._rangeRequestReaders.slice(0))bg.cancel(hg)}}eg.PDFNodeStream=sg;class Ig{constructor(hg){this._url=hg.url,this._done=!1,this._storedError=null,this.onProgress=null;const mg=hg.source;this._contentLength=mg.length,this._loaded=0,this._filename=null,this._disableRange=mg.disableRange||!1,this._rangeChunkSize=mg.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!mg.disableStream,this._isRangeSupported=!mg.disableRange,this._readableStream=null,this._readCapability=new ig.PromiseCapability,this._headersCapability=new ig.PromiseCapability}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var bg;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const hg=this._readableStream.read();return hg===null?(this._readCapability=new ig.PromiseCapability,this.read()):(this._loaded+=hg.length,(bg=this.onProgress)==null||bg.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(hg).buffer,done:!1})}cancel(hg){if(!this._readableStream){this._error(hg);return}this._readableStream.destroy(hg)}_error(hg){this._storedError=hg,this._readCapability.resolve()}_setReadableStream(hg){this._readableStream=hg,hg.on("readable",()=>{this._readCapability.resolve()}),hg.on("end",()=>{hg.destroy(),this._done=!0,this._readCapability.resolve()}),hg.on("error",mg=>{this._error(mg)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new ig.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Cg{constructor(hg){this._url=hg.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=new ig.PromiseCapability;const mg=hg.source;this._isStreamingSupported=!mg.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var bg;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const hg=this._readableStream.read();return hg===null?(this._readCapability=new ig.PromiseCapability,this.read()):(this._loaded+=hg.length,(bg=this.onProgress)==null||bg.call(this,{loaded:this._loaded}),{value:new Uint8Array(hg).buffer,done:!1})}cancel(hg){if(!this._readableStream){this._error(hg);return}this._readableStream.destroy(hg)}_error(hg){this._storedError=hg,this._readCapability.resolve()}_setReadableStream(hg){this._readableStream=hg,hg.on("readable",()=>{this._readCapability.resolve()}),hg.on("end",()=>{hg.destroy(),this._done=!0,this._readCapability.resolve()}),hg.on("error",mg=>{this._error(mg)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function lg(dg,hg){return{protocol:dg.protocol,auth:dg.auth,host:dg.hostname,port:dg.port,path:dg.path,method:"GET",headers:hg}}class Ag extends Ig{constructor(hg){super(hg);const mg=bg=>{if(bg.statusCode===404){const Gg=new ig.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=Gg,this._headersCapability.reject(Gg);return}this._headersCapability.resolve(),this._setReadableStream(bg);const pg=Gg=>this._readableStream.headers[Gg.toLowerCase()],{allowRangeRequests:fg,suggestedLength:wg}=(0,ng.validateRangeRequestCapabilities)({getResponseHeader:pg,isHttp:hg.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=fg,this._contentLength=wg||this._contentLength,this._filename=(0,ng.extractFilenameFromHeader)(pg)};if(this._request=null,this._url.protocol==="http:"){const bg=require$$5;this._request=bg.request(lg(this._url,hg.httpHeaders),mg)}else{const bg=require$$5;this._request=bg.request(lg(this._url,hg.httpHeaders),mg)}this._request.on("error",bg=>{this._storedError=bg,this._headersCapability.reject(bg)}),this._request.end()}}class rg extends Cg{constructor(hg,mg,bg){super(hg),this._httpHeaders={};for(const fg in hg.httpHeaders){const wg=hg.httpHeaders[fg];wg!==void 0&&(this._httpHeaders[fg]=wg)}this._httpHeaders.Range=`bytes=${mg}-${bg-1}`;const pg=fg=>{if(fg.statusCode===404){const wg=new ig.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=wg;return}this._setReadableStream(fg)};if(this._request=null,this._url.protocol==="http:"){const fg=require$$5;this._request=fg.request(lg(this._url,this._httpHeaders),pg)}else{const fg=require$$5;this._request=fg.request(lg(this._url,this._httpHeaders),pg)}this._request.on("error",fg=>{this._storedError=fg}),this._request.end()}}class cg extends Ig{constructor(hg){super(hg);let mg=decodeURIComponent(this._url.path);og.test(this._url.href)&&(mg=mg.replace(/^\//,""));const bg=require$$5;bg.lstat(mg,(pg,fg)=>{if(pg){pg.code==="ENOENT"&&(pg=new ig.MissingPDFException(`Missing PDF "${mg}".`)),this._storedError=pg,this._headersCapability.reject(pg);return}this._contentLength=fg.size,this._setReadableStream(bg.createReadStream(mg)),this._headersCapability.resolve()})}}class ug extends Cg{constructor(hg,mg,bg){super(hg);let pg=decodeURIComponent(this._url.path);og.test(this._url.href)&&(pg=pg.replace(/^\//,""));const fg=require$$5;this._setReadableStream(fg.createReadStream(pg,{start:mg,end:bg-1}))}}}),((tg,eg,gg)=>{Object.defineProperty(eg,"__esModule",{value:!0}),eg.SVGGraphics=void 0;var ig=gg(6),ng=gg(1);const og={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},ag="http://www.w3.org/XML/1998/namespace",sg="http://www.w3.org/1999/xlink",Ig=["butt","round","square"],Cg=["miter","round","bevel"],lg=function(fg,wg="",Gg=!1){if(URL.createObjectURL&&typeof Blob<"u"&&!Gg)return URL.createObjectURL(new Blob([fg],{type:wg}));const Zg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let $g=`data:${wg};base64,`;for(let Bg=0,Wg=fg.length;Bg<Wg;Bg+=3){const yg=fg[Bg]&255,Ng=fg[Bg+1]&255,vg=fg[Bg+2]&255,Sg=yg>>2,Vg=(yg&3)<<4|Ng>>4,Xg=Bg+1<Wg?(Ng&15)<<2|vg>>6:64,Yg=Bg+2<Wg?vg&63:64;$g+=Zg[Sg]+Zg[Vg]+Zg[Xg]+Zg[Yg]}return $g},Ag=(function(){const fg=new Uint8Array([137,80,78,71,13,10,26,10]),wg=12,Gg=new Int32Array(256);for(let vg=0;vg<256;vg++){let Sg=vg;for(let Vg=0;Vg<8;Vg++)Sg=Sg&1?3988292384^Sg>>1&2147483647:Sg>>1&2147483647;Gg[vg]=Sg}function Zg(vg,Sg,Vg){let Xg=-1;for(let Yg=Sg;Yg<Vg;Yg++){const Hg=(Xg^vg[Yg])&255,kg=Gg[Hg];Xg=Xg>>>8^kg}return Xg^-1}function $g(vg,Sg,Vg,Xg){let Yg=Xg;const Hg=Sg.length;Vg[Yg]=Hg>>24&255,Vg[Yg+1]=Hg>>16&255,Vg[Yg+2]=Hg>>8&255,Vg[Yg+3]=Hg&255,Yg+=4,Vg[Yg]=vg.charCodeAt(0)&255,Vg[Yg+1]=vg.charCodeAt(1)&255,Vg[Yg+2]=vg.charCodeAt(2)&255,Vg[Yg+3]=vg.charCodeAt(3)&255,Yg+=4,Vg.set(Sg,Yg),Yg+=Sg.length;const kg=Zg(Vg,Xg+4,Yg);Vg[Yg]=kg>>24&255,Vg[Yg+1]=kg>>16&255,Vg[Yg+2]=kg>>8&255,Vg[Yg+3]=kg&255}function Bg(vg,Sg,Vg){let Xg=1,Yg=0;for(let Hg=Sg;Hg<Vg;++Hg)Xg=(Xg+(vg[Hg]&255))%65521,Yg=(Yg+Xg)%65521;return Yg<<16|Xg}function Wg(vg){if(!ng.isNodeJS)return yg(vg);try{const Sg=parseInt(process.versions.node)>=8?vg:Buffer.from(vg),Vg=require$$5.deflateSync(Sg,{level:9});return Vg instanceof Uint8Array?Vg:new Uint8Array(Vg)}catch(Sg){(0,ng.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+Sg)}return yg(vg)}function yg(vg){let Sg=vg.length;const Vg=65535,Xg=Math.ceil(Sg/Vg),Yg=new Uint8Array(2+Sg+Xg*5+4);let Hg=0;Yg[Hg++]=120,Yg[Hg++]=156;let kg=0;for(;Sg>Vg;)Yg[Hg++]=0,Yg[Hg++]=255,Yg[Hg++]=255,Yg[Hg++]=0,Yg[Hg++]=0,Yg.set(vg.subarray(kg,kg+Vg),Hg),Hg+=Vg,kg+=Vg,Sg-=Vg;Yg[Hg++]=1,Yg[Hg++]=Sg&255,Yg[Hg++]=Sg>>8&255,Yg[Hg++]=~Sg&65535&255,Yg[Hg++]=(~Sg&65535)>>8&255,Yg.set(vg.subarray(kg),Hg),Hg+=vg.length-kg;const Rg=Bg(vg,0,vg.length);return Yg[Hg++]=Rg>>24&255,Yg[Hg++]=Rg>>16&255,Yg[Hg++]=Rg>>8&255,Yg[Hg++]=Rg&255,Yg}function Ng(vg,Sg,Vg,Xg){const Yg=vg.width,Hg=vg.height;let kg,Rg,Kg;const jg=vg.data;switch(Sg){case ng.ImageKind.GRAYSCALE_1BPP:Rg=0,kg=1,Kg=Yg+7>>3;break;case ng.ImageKind.RGB_24BPP:Rg=2,kg=8,Kg=Yg*3;break;case ng.ImageKind.RGBA_32BPP:Rg=6,kg=8,Kg=Yg*4;break;default:throw new Error("invalid format")}const Dg=new Uint8Array((1+Kg)*Hg);let zg=0,Og=0;for(let pa=0;pa<Hg;++pa)Dg[zg++]=0,Dg.set(jg.subarray(Og,Og+Kg),zg),Og+=Kg,zg+=Kg;if(Sg===ng.ImageKind.GRAYSCALE_1BPP&&Xg){zg=0;for(let pa=0;pa<Hg;pa++){zg++;for(let is=0;is<Kg;is++)Dg[zg++]^=255}}const Jg=new Uint8Array([Yg>>24&255,Yg>>16&255,Yg>>8&255,Yg&255,Hg>>24&255,Hg>>16&255,Hg>>8&255,Hg&255,kg,Rg,0,0,0]),Qg=Wg(Dg),eo=fg.length+wg*3+Jg.length+Qg.length,ca=new Uint8Array(eo);let ua=0;return ca.set(fg,ua),ua+=fg.length,$g("IHDR",Jg,ca,ua),ua+=wg+Jg.length,$g("IDATA",Qg,ca,ua),ua+=wg+Qg.length,$g("IEND",new Uint8Array(0),ca,ua),lg(ca,"image/png",Vg)}return function(Sg,Vg,Xg){const Yg=Sg.kind===void 0?ng.ImageKind.GRAYSCALE_1BPP:Sg.kind;return Ng(Sg,Yg,Vg,Xg)}})();class rg{constructor(){this.fontSizeScale=1,this.fontWeight=og.fontWeight,this.fontSize=0,this.textMatrix=ng.IDENTITY_MATRIX,this.fontMatrix=ng.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=ng.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=og.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(wg,Gg){this.x=wg,this.y=Gg}}function cg(fg){let wg=[];const Gg=[];for(const Zg of fg){if(Zg.fn==="save"){wg.push({fnId:92,fn:"group",items:[]}),Gg.push(wg),wg=wg.at(-1).items;continue}Zg.fn==="restore"?wg=Gg.pop():wg.push(Zg)}return wg}function ug(fg){if(Number.isInteger(fg))return fg.toString();const wg=fg.toFixed(10);let Gg=wg.length-1;if(wg[Gg]!=="0")return wg;do Gg--;while(wg[Gg]==="0");return wg.substring(0,wg[Gg]==="."?Gg:Gg+1)}function dg(fg){if(fg[4]===0&&fg[5]===0){if(fg[1]===0&&fg[2]===0)return fg[0]===1&&fg[3]===1?"":`scale(${ug(fg[0])} ${ug(fg[3])})`;if(fg[0]===fg[3]&&fg[1]===-fg[2]){const wg=Math.acos(fg[0])*180/Math.PI;return`rotate(${ug(wg)})`}}else if(fg[0]===1&&fg[1]===0&&fg[2]===0&&fg[3]===1)return`translate(${ug(fg[4])} ${ug(fg[5])})`;return`matrix(${ug(fg[0])} ${ug(fg[1])} ${ug(fg[2])} ${ug(fg[3])} ${ug(fg[4])} ${ug(fg[5])})`}let hg=0,mg=0,bg=0;class pg{constructor(wg,Gg,Zg=!1){(0,ig.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new ig.DOMSVGFactory,this.current=new rg,this.transformMatrix=ng.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=wg,this.objs=Gg,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!Zg,this._operatorIdMapping=[];for(const $g in ng.OPS)this._operatorIdMapping[ng.OPS[$g]]=$g}getObject(wg,Gg=null){return typeof wg=="string"?wg.startsWith("g_")?this.commonObjs.get(wg):this.objs.get(wg):Gg}save(){this.transformStack.push(this.transformMatrix);const wg=this.current;this.extraStack.push(wg),this.current=wg.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(wg){this.save(),this.executeOpTree(wg),this.restore()}loadDependencies(wg){const Gg=wg.fnArray,Zg=wg.argsArray;for(let $g=0,Bg=Gg.length;$g<Bg;$g++)if(Gg[$g]===ng.OPS.dependency)for(const Wg of Zg[$g]){const yg=Wg.startsWith("g_")?this.commonObjs:this.objs,Ng=new Promise(vg=>{yg.get(Wg,vg)});this.current.dependencies.push(Ng)}return Promise.all(this.current.dependencies)}transform(wg,Gg,Zg,$g,Bg,Wg){const yg=[wg,Gg,Zg,$g,Bg,Wg];this.transformMatrix=ng.Util.transform(this.transformMatrix,yg),this.tgrp=null}getSVG(wg,Gg){this.viewport=Gg;const Zg=this._initialize(Gg);return this.loadDependencies(wg).then(()=>(this.transformMatrix=ng.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(wg)),Zg))}convertOpList(wg){const Gg=this._operatorIdMapping,Zg=wg.argsArray,$g=wg.fnArray,Bg=[];for(let Wg=0,yg=$g.length;Wg<yg;Wg++){const Ng=$g[Wg];Bg.push({fnId:Ng,fn:Gg[Ng],args:Zg[Wg]})}return cg(Bg)}executeOpTree(wg){for(const Gg of wg){const Zg=Gg.fn,$g=Gg.fnId,Bg=Gg.args;switch($g|0){case ng.OPS.beginText:this.beginText();break;case ng.OPS.dependency:break;case ng.OPS.setLeading:this.setLeading(Bg);break;case ng.OPS.setLeadingMoveText:this.setLeadingMoveText(Bg[0],Bg[1]);break;case ng.OPS.setFont:this.setFont(Bg);break;case ng.OPS.showText:this.showText(Bg[0]);break;case ng.OPS.showSpacedText:this.showText(Bg[0]);break;case ng.OPS.endText:this.endText();break;case ng.OPS.moveText:this.moveText(Bg[0],Bg[1]);break;case ng.OPS.setCharSpacing:this.setCharSpacing(Bg[0]);break;case ng.OPS.setWordSpacing:this.setWordSpacing(Bg[0]);break;case ng.OPS.setHScale:this.setHScale(Bg[0]);break;case ng.OPS.setTextMatrix:this.setTextMatrix(Bg[0],Bg[1],Bg[2],Bg[3],Bg[4],Bg[5]);break;case ng.OPS.setTextRise:this.setTextRise(Bg[0]);break;case ng.OPS.setTextRenderingMode:this.setTextRenderingMode(Bg[0]);break;case ng.OPS.setLineWidth:this.setLineWidth(Bg[0]);break;case ng.OPS.setLineJoin:this.setLineJoin(Bg[0]);break;case ng.OPS.setLineCap:this.setLineCap(Bg[0]);break;case ng.OPS.setMiterLimit:this.setMiterLimit(Bg[0]);break;case ng.OPS.setFillRGBColor:this.setFillRGBColor(Bg[0],Bg[1],Bg[2]);break;case ng.OPS.setStrokeRGBColor:this.setStrokeRGBColor(Bg[0],Bg[1],Bg[2]);break;case ng.OPS.setStrokeColorN:this.setStrokeColorN(Bg);break;case ng.OPS.setFillColorN:this.setFillColorN(Bg);break;case ng.OPS.shadingFill:this.shadingFill(Bg[0]);break;case ng.OPS.setDash:this.setDash(Bg[0],Bg[1]);break;case ng.OPS.setRenderingIntent:this.setRenderingIntent(Bg[0]);break;case ng.OPS.setFlatness:this.setFlatness(Bg[0]);break;case ng.OPS.setGState:this.setGState(Bg[0]);break;case ng.OPS.fill:this.fill();break;case ng.OPS.eoFill:this.eoFill();break;case ng.OPS.stroke:this.stroke();break;case ng.OPS.fillStroke:this.fillStroke();break;case ng.OPS.eoFillStroke:this.eoFillStroke();break;case ng.OPS.clip:this.clip("nonzero");break;case ng.OPS.eoClip:this.clip("evenodd");break;case ng.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case ng.OPS.paintImageXObject:this.paintImageXObject(Bg[0]);break;case ng.OPS.paintInlineImageXObject:this.paintInlineImageXObject(Bg[0]);break;case ng.OPS.paintImageMaskXObject:this.paintImageMaskXObject(Bg[0]);break;case ng.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(Bg[0],Bg[1]);break;case ng.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case ng.OPS.closePath:this.closePath();break;case ng.OPS.closeStroke:this.closeStroke();break;case ng.OPS.closeFillStroke:this.closeFillStroke();break;case ng.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case ng.OPS.nextLine:this.nextLine();break;case ng.OPS.transform:this.transform(Bg[0],Bg[1],Bg[2],Bg[3],Bg[4],Bg[5]);break;case ng.OPS.constructPath:this.constructPath(Bg[0],Bg[1]);break;case ng.OPS.endPath:this.endPath();break;case 92:this.group(Gg.items);break;default:(0,ng.warn)(`Unimplemented operator ${Zg}`);break}}}setWordSpacing(wg){this.current.wordSpacing=wg}setCharSpacing(wg){this.current.charSpacing=wg}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(wg,Gg,Zg,$g,Bg,Wg){const yg=this.current;yg.textMatrix=yg.lineMatrix=[wg,Gg,Zg,$g,Bg,Wg],yg.textMatrixScale=Math.hypot(wg,Gg),yg.x=yg.lineX=0,yg.y=yg.lineY=0,yg.xcoords=[],yg.ycoords=[],yg.tspan=this.svgFactory.createElement("svg:tspan"),yg.tspan.setAttributeNS(null,"font-family",yg.fontFamily),yg.tspan.setAttributeNS(null,"font-size",`${ug(yg.fontSize)}px`),yg.tspan.setAttributeNS(null,"y",ug(-yg.y)),yg.txtElement=this.svgFactory.createElement("svg:text"),yg.txtElement.append(yg.tspan)}beginText(){const wg=this.current;wg.x=wg.lineX=0,wg.y=wg.lineY=0,wg.textMatrix=ng.IDENTITY_MATRIX,wg.lineMatrix=ng.IDENTITY_MATRIX,wg.textMatrixScale=1,wg.tspan=this.svgFactory.createElement("svg:tspan"),wg.txtElement=this.svgFactory.createElement("svg:text"),wg.txtgrp=this.svgFactory.createElement("svg:g"),wg.xcoords=[],wg.ycoords=[]}moveText(wg,Gg){const Zg=this.current;Zg.x=Zg.lineX+=wg,Zg.y=Zg.lineY+=Gg,Zg.xcoords=[],Zg.ycoords=[],Zg.tspan=this.svgFactory.createElement("svg:tspan"),Zg.tspan.setAttributeNS(null,"font-family",Zg.fontFamily),Zg.tspan.setAttributeNS(null,"font-size",`${ug(Zg.fontSize)}px`),Zg.tspan.setAttributeNS(null,"y",ug(-Zg.y))}showText(wg){const Gg=this.current,Zg=Gg.font,$g=Gg.fontSize;if($g===0)return;const Bg=Gg.fontSizeScale,Wg=Gg.charSpacing,yg=Gg.wordSpacing,Ng=Gg.fontDirection,vg=Gg.textHScale*Ng,Sg=Zg.vertical,Vg=Sg?1:-1,Xg=Zg.defaultVMetrics,Yg=$g*Gg.fontMatrix[0];let Hg=0;for(const Kg of wg){if(Kg===null){Hg+=Ng*yg;continue}else if(typeof Kg=="number"){Hg+=Vg*Kg*$g/1e3;continue}const jg=(Kg.isSpace?yg:0)+Wg,Dg=Kg.fontChar;let zg,Og,Jg=Kg.width;if(Sg){let eo;const ca=Kg.vmetric||Xg;eo=Kg.vmetric?ca[1]:Jg*.5,eo=-eo*Yg;const ua=ca[2]*Yg;Jg=ca?-ca[0]:Jg,zg=eo/Bg,Og=(Hg+ua)/Bg}else zg=Hg/Bg,Og=0;(Kg.isInFont||Zg.missingFile)&&(Gg.xcoords.push(Gg.x+zg),Sg&&Gg.ycoords.push(-Gg.y+Og),Gg.tspan.textContent+=Dg);const Qg=Sg?Jg*Yg-jg*Ng:Jg*Yg+jg*Ng;Hg+=Qg}Gg.tspan.setAttributeNS(null,"x",Gg.xcoords.map(ug).join(" ")),Sg?Gg.tspan.setAttributeNS(null,"y",Gg.ycoords.map(ug).join(" ")):Gg.tspan.setAttributeNS(null,"y",ug(-Gg.y)),Sg?Gg.y-=Hg:Gg.x+=Hg*vg,Gg.tspan.setAttributeNS(null,"font-family",Gg.fontFamily),Gg.tspan.setAttributeNS(null,"font-size",`${ug(Gg.fontSize)}px`),Gg.fontStyle!==og.fontStyle&&Gg.tspan.setAttributeNS(null,"font-style",Gg.fontStyle),Gg.fontWeight!==og.fontWeight&&Gg.tspan.setAttributeNS(null,"font-weight",Gg.fontWeight);const kg=Gg.textRenderingMode&ng.TextRenderingMode.FILL_STROKE_MASK;if(kg===ng.TextRenderingMode.FILL||kg===ng.TextRenderingMode.FILL_STROKE?(Gg.fillColor!==og.fillColor&&Gg.tspan.setAttributeNS(null,"fill",Gg.fillColor),Gg.fillAlpha<1&&Gg.tspan.setAttributeNS(null,"fill-opacity",Gg.fillAlpha)):Gg.textRenderingMode===ng.TextRenderingMode.ADD_TO_PATH?Gg.tspan.setAttributeNS(null,"fill","transparent"):Gg.tspan.setAttributeNS(null,"fill","none"),kg===ng.TextRenderingMode.STROKE||kg===ng.TextRenderingMode.FILL_STROKE){const Kg=1/(Gg.textMatrixScale||1);this._setStrokeAttributes(Gg.tspan,Kg)}let Rg=Gg.textMatrix;Gg.textRise!==0&&(Rg=Rg.slice(),Rg[5]+=Gg.textRise),Gg.txtElement.setAttributeNS(null,"transform",`${dg(Rg)} scale(${ug(vg)}, -1)`),Gg.txtElement.setAttributeNS(ag,"xml:space","preserve"),Gg.txtElement.append(Gg.tspan),Gg.txtgrp.append(Gg.txtElement),this._ensureTransformGroup().append(Gg.txtElement)}setLeadingMoveText(wg,Gg){this.setLeading(-Gg),this.moveText(wg,Gg)}addFontStyle(wg){if(!wg.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.append(this.cssStyle));const Gg=lg(wg.data,wg.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${wg.loadedName}"; src: url(${Gg}); }
|