@pairbo/ui-kit 0.4.12 → 0.4.13

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.
@@ -414,7 +414,7 @@
414
414
  justify-content: center;
415
415
  align-items: center;
416
416
  }
417
- `,Gh=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";function wo(r){return typeof r=="number"}function Gn(r){return typeof r=="string"}function Qr(r){return typeof r=="boolean"}function fa(r){return Object.prototype.toString.call(r)==="[object Object]"}function ct(r){return Math.abs(r)}function Co(r){return Math.sign(r)}function Ps(r,t){return ct(r-t)}function Xh(r,t){if(r===0||t===0||ct(r)<=ct(t))return 0;const e=Ps(ct(r),ct(t));return ct(e/r)}function Kh(r){return Math.round(r*100)/100}function $s(r){return Rs(r).map(Number)}function Te(r){return r[Gs(r)]}function Gs(r){return Math.max(0,r.length-1)}function So(r,t){return t===Gs(r)}function ma(r,t=0){return Array.from(Array(r),(e,i)=>t+i)}function Rs(r){return Object.keys(r)}function Hl(r,t){return[r,t].reduce((e,i)=>(Rs(i).forEach(s=>{const n=e[s],o=i[s],a=fa(n)&&fa(o);e[s]=a?Hl(n,o):o}),e),{})}function Xn(r,t){return typeof t.MouseEvent<"u"&&r instanceof t.MouseEvent}function qh(r,t){const e={start:i,center:s,end:n};function i(){return 0}function s(l){return n(l)/2}function n(l){return t-l}function o(l,c){return Gn(r)?e[r](l):r(t,l,c)}return{measure:o}}function Bs(){let r=[];function t(s,n,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(n,o,a),l=()=>s.removeEventListener(n,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return r.push(l),i}function e(){r=r.filter(s=>s())}const i={add:t,clear:e};return i}function Zh(r,t,e,i){const s=Bs(),n=1e3/60;let o=null,a=0,l=0;function c(){s.add(r,"visibilitychange",()=>{r.hidden&&g()})}function h(){p(),s.clear()}function d(b){if(!l)return;o||(o=b,e(),e());const m=b-o;for(o=b,a+=m;a>=n;)e(),a-=n;const y=a/n;i(y),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function p(){t.cancelAnimationFrame(l),o=null,a=0,l=0}function g(){o=null,a=0}return{init:c,destroy:h,start:u,stop:p,update:e,render:i}}function Jh(r,t){const e=t==="rtl",i=r==="y",s=i?"y":"x",n=i?"x":"y",o=!i&&e?-1:1,a=h(),l=d();function c(g){const{height:f,width:b}=g;return i?f:b}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(g){return g*o}return{scroll:s,cross:n,startEdge:a,endEdge:l,measureSize:c,direction:u}}function Fi(r=0,t=0){const e=ct(r-t);function i(c){return c<r}function s(c){return c>t}function n(c){return i(c)||s(c)}function o(c){return n(c)?i(c)?r:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:r,constrain:o,reachedAny:n,reachedMax:s,reachedMin:i,removeOffset:a}}function Vl(r,t,e){const{constrain:i}=Fi(0,r),s=r+1;let n=o(t);function o(u){return e?ct((s+u)%s):i(u)}function a(){return n}function l(u){return n=o(u),d}function c(u){return h().set(a()+u)}function h(){return Vl(r,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function Qh(r,t,e,i,s,n,o,a,l,c,h,d,u,p,g,f,b,m,y){const{cross:w,direction:S}=r,T=["INPUT","SELECT","TEXTAREA"],O={passive:!1},k=Bs(),E=Bs(),P=Fi(50,225).constrain(p.measure(20)),R={mouse:300,touch:400},L={mouse:500,touch:600},F=g?43:25;let H=!1,M=0,U=0,X=!1,Q=!1,N=!1,Ct=!1;function Ut(D){if(!y)return;function tt(Yt){(Qr(y)||y(D,Yt))&&ae(Yt)}const St=t;k.add(St,"dragstart",Yt=>Yt.preventDefault(),O).add(St,"touchmove",()=>{},O).add(St,"touchend",()=>{}).add(St,"touchstart",tt).add(St,"mousedown",tt).add(St,"touchcancel",jt).add(St,"contextmenu",jt).add(St,"click",le,!0)}function Wt(){k.clear(),E.clear()}function Pe(){const D=Ct?e:t;E.add(D,"touchmove",At,O).add(D,"touchend",jt).add(D,"mousemove",At,O).add(D,"mouseup",jt)}function de(D){const tt=D.nodeName||"";return T.includes(tt)}function Ft(){return(g?L:R)[Ct?"mouse":"touch"]}function Ae(D,tt){const St=d.add(Co(D)*-1),Yt=h.byDistance(D,!g).distance;return g||ct(D)<P?Yt:b&&tt?Yt*.5:h.byIndex(St.get(),0).distance}function ae(D){const tt=Xn(D,i);Ct=tt,N=g&&tt&&!D.buttons&&H,H=Ps(s.get(),o.get())>=2,!(tt&&D.button!==0)&&(de(D.target)||(X=!0,n.pointerDown(D),c.useFriction(0).useDuration(0),s.set(o),Pe(),M=n.readPoint(D),U=n.readPoint(D,w),u.emit("pointerDown")))}function At(D){if(!Xn(D,i)&&D.touches.length>=2)return jt(D);const St=n.readPoint(D),Yt=n.readPoint(D,w),De=Ps(St,M),Ve=Ps(Yt,U);if(!Q&&!Ct&&(!D.cancelable||(Q=De>Ve,!Q)))return jt(D);const xi=n.pointerMove(D);De>f&&(N=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(S(xi)),D.preventDefault()}function jt(D){const St=h.byDistance(0,!1).index!==d.get(),Yt=n.pointerUp(D)*Ft(),De=Ae(S(Yt),St),Ve=Xh(Yt,De),xi=F-10*Ve,oi=m+Ve/50;Q=!1,X=!1,E.clear(),c.useDuration(xi).useFriction(oi),l.distance(De,!g),Ct=!1,u.emit("pointerUp")}function le(D){N&&(D.stopPropagation(),D.preventDefault(),N=!1)}function vt(){return X}return{init:Ut,destroy:Wt,pointerDown:vt}}function td(r,t){let i,s;function n(d){return d.timeStamp}function o(d,u){const g=`client${(u||r.scroll)==="x"?"X":"Y"}`;return(Xn(d,t)?d:d.touches[0])[g]}function a(d){return i=d,s=d,o(d)}function l(d){const u=o(d)-o(s),p=n(d)-n(i)>170;return s=d,p&&(i=d),u}function c(d){if(!i||!s)return 0;const u=o(s)-o(i),p=n(d)-n(i),g=n(d)-n(s)>170,f=u/p;return p&&!g&&ct(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function ed(){function r(e){const{offsetTop:i,offsetLeft:s,offsetWidth:n,offsetHeight:o}=e;return{top:i,right:s+n,bottom:i+o,left:s,width:n,height:o}}return{measure:r}}function id(r){function t(i){return r*(i/100)}return{measure:t}}function sd(r,t,e,i,s,n,o){const a=[r].concat(i);let l,c,h=[],d=!1;function u(b){return s.measureSize(o.measure(b))}function p(b){if(!n)return;c=u(r),h=i.map(u);function m(y){for(const w of y){if(d)return;const S=w.target===r,T=i.indexOf(w.target),O=S?c:h[T],k=u(S?r:i[T]);if(ct(k-O)>=.5){b.reInit(),t.emit("resize");break}}}l=new ResizeObserver(y=>{(Qr(n)||n(b,y))&&m(y)}),e.requestAnimationFrame(()=>{a.forEach(y=>l.observe(y))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function rd(r,t,e,i,s,n){let o=0,a=0,l=s,c=n,h=r.get(),d=0;function u(){const O=i.get()-r.get(),k=!l;let E=0;return k?(o=0,e.set(i),r.set(i),E=O):(e.set(r),o+=O/l,o*=c,h+=o,r.add(o),E=h-d),a=Co(E),d=h,T}function p(){const O=i.get()-t.get();return ct(O)<.001}function g(){return l}function f(){return a}function b(){return o}function m(){return w(s)}function y(){return S(n)}function w(O){return l=O,T}function S(O){return c=O,T}const T={direction:f,duration:g,velocity:b,seek:u,settled:p,useBaseFriction:y,useBaseDuration:m,useFriction:S,useDuration:w};return T}function nd(r,t,e,i,s){const n=s.measure(10),o=s.measure(50),a=Fi(.1,.99);let l=!1;function c(){return!(l||!r.reachedAny(e.get())||!r.reachedAny(t.get()))}function h(p){if(!c())return;const g=r.reachedMin(t.get())?"min":"max",f=ct(r[g]-t.get()),b=e.get()-t.get(),m=a.constrain(f/o);e.subtract(b*m),!p&&ct(b)<n&&(e.set(r.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(p){l=!p}return{shouldConstrain:c,constrain:h,toggleActive:d}}function od(r,t,e,i,s){const n=Fi(-t+r,0),o=d(),a=h(),l=u();function c(g,f){return Ps(g,f)<=1}function h(){const g=o[0],f=Te(o),b=o.lastIndexOf(g),m=o.indexOf(f)+1;return Fi(b,m)}function d(){return e.map((g,f)=>{const{min:b,max:m}=n,y=n.constrain(g),w=!f,S=So(e,f);return w?m:S||c(b,y)?b:c(m,y)?m:y}).map(g=>parseFloat(g.toFixed(3)))}function u(){if(t<=r+s)return[n.max];if(i==="keepSnaps")return o;const{min:g,max:f}=a;return o.slice(g,f)}return{snapsContained:l,scrollContainLimit:a}}function ad(r,t,e){const i=t[0],s=e?i-r:Te(t);return{limit:Fi(s,i)}}function ld(r,t,e,i){const n=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=Fi(n,o);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const p=r*(u*-1);i.forEach(g=>g.add(p))}return{loop:h}}function cd(r){const{max:t,length:e}=r;function i(n){const o=n-t;return e?o/-e:0}return{get:i}}function hd(r,t,e,i,s){const{startEdge:n,endEdge:o}=r,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=p();function d(){return a(i).map(f=>Te(f)[o]-f[0][n]).map(ct)}function u(){return i.map(f=>e[n]-f[n]).map(f=>-ct(f))}function p(){return a(c).map(f=>f[0]).map((f,b)=>f+l[b])}return{snaps:c,snapsAligned:h}}function dd(r,t,e,i,s,n){const{groupSlides:o}=s,{min:a,max:l}=i,c=h();function h(){const u=o(n),p=!r||t==="keepSnaps";return e.length===1?[n]:p?u:u.slice(a,l).map((g,f,b)=>{const m=!f,y=So(b,f);if(m){const w=Te(b[0])+1;return ma(w)}if(y){const w=Gs(n)-Te(b)[0]+1;return ma(w,Te(b)[0])}return g})}return{slideRegistry:c}}function ud(r,t,e,i,s){const{reachedAny:n,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,b)=>ct(f)-ct(b))[0]}function c(g){const f=r?o(g):a(g),b=t.map((y,w)=>({diff:h(y-f,0),index:w})).sort((y,w)=>ct(y.diff)-ct(w.diff)),{index:m}=b[0];return{index:m,distance:f}}function h(g,f){const b=[g,g+e,g-e];if(!r)return g;if(!f)return l(b);const m=b.filter(y=>Co(y)===f);return m.length?l(m):Te(b)-e}function d(g,f){const b=t[g]-s.get(),m=h(b,f);return{index:g,distance:m}}function u(g,f){const b=s.get()+g,{index:m,distance:y}=c(b),w=!r&&n(b);if(!f||w)return{index:m,distance:g};const S=t[m]-y,T=g+h(S,0);return{index:m,distance:T}}return{byDistance:u,byIndex:d,shortcut:h}}function pd(r,t,e,i,s,n,o){function a(d){const u=d.distance,p=d.index!==t.get();n.add(u),u&&(i.duration()?r.start():(r.update(),r.render(1),r.update())),p&&(e.set(t.get()),t.set(d.index),o.emit("select"))}function l(d,u){const p=s.byDistance(d,u);a(p)}function c(d,u){const p=t.clone().set(d),g=s.byIndex(p.get(),u);a(g)}return{distance:l,index:c}}function gd(r,t,e,i,s,n,o,a){const l={passive:!0,capture:!0};let c=0;function h(p){if(!a)return;function g(f){if(new Date().getTime()-c>10)return;o.emit("slideFocusStart"),r.scrollLeft=0;const y=e.findIndex(w=>w.includes(f));wo(y)&&(s.useDuration(0),i.index(y,0),o.emit("slideFocus"))}n.add(document,"keydown",d,!1),t.forEach((f,b)=>{n.add(f,"focus",m=>{(Qr(a)||a(p,m))&&g(b)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Cs(r){let t=r;function e(){return t}function i(l){t=o(l)}function s(l){t+=o(l)}function n(l){t-=o(l)}function o(l){return wo(l)?l:l.get()}return{get:e,set:i,add:s,subtract:n}}function Nl(r,t){const e=r.scroll==="x"?o:a,i=t.style;let s=null,n=!1;function o(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(n)return;const p=Kh(r.direction(u));p!==s&&(i.transform=e(p),s=p)}function c(u){n=!u}function h(){n||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function fd(r,t,e,i,s,n,o,a,l){const h=$s(s),d=$s(s).reverse(),u=m().concat(y());function p(k,E){return k.reduce((P,R)=>P-s[R],E)}function g(k,E){return k.reduce((P,R)=>p(P,E)>0?P.concat([R]):P,[])}function f(k){return n.map((E,P)=>({start:E-i[P]+.5+k,end:E+t-.5+k}))}function b(k,E,P){const R=f(E);return k.map(L=>{const F=P?0:-e,H=P?e:0,M=P?"end":"start",U=R[L][M];return{index:L,loopPoint:U,slideLocation:Cs(-1),translate:Nl(r,l[L]),target:()=>a.get()>U?F:H}})}function m(){const k=o[0],E=g(d,k);return b(E,e,!1)}function y(){const k=t-o[0]-1,E=g(h,k);return b(E,-e,!0)}function w(){return u.every(({index:k})=>{const E=h.filter(P=>P!==k);return p(E,t)<=.1})}function S(){u.forEach(k=>{const{target:E,translate:P,slideLocation:R}=k,L=E();L!==R.get()&&(P.to(L),R.set(L))})}function T(){u.forEach(k=>k.translate.clear())}return{canLoop:w,clear:T,loop:S,loopPoints:u}}function md(r,t,e){let i,s=!1;function n(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(Qr(e)||e(l,h))&&c(h)}),i.observe(r,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:n,destroy:o}}function bd(r,t,e,i){const s={};let n=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(g=>{l||(g.forEach(f=>{const b=t.indexOf(f.target);s[b]=f}),n=null,o=null,e.emit("slidesInView"))},{root:r.parentElement,threshold:i}),t.forEach(g=>a.observe(g))}function h(){a&&a.disconnect(),l=!0}function d(g){return Rs(s).reduce((f,b)=>{const m=parseInt(b),{isIntersecting:y}=s[m];return(g&&y||!g&&!y)&&f.push(m),f},[])}function u(g=!0){if(g&&n)return n;if(!g&&o)return o;const f=d(g);return g&&(n=f),g||(o=f),f}return{init:c,destroy:h,get:u}}function vd(r,t,e,i,s,n){const{measureSize:o,startEdge:a,endEdge:l}=r,c=e[0]&&s,h=g(),d=f(),u=e.map(o),p=b();function g(){if(!c)return 0;const y=e[0];return ct(t[a]-y[a])}function f(){if(!c)return 0;const y=n.getComputedStyle(Te(i));return parseFloat(y.getPropertyValue(`margin-${l}`))}function b(){return e.map((y,w,S)=>{const T=!w,O=So(S,w);return T?u[w]+h:O?u[w]+d:S[w+1][a]-y[a]}).map(ct)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function yd(r,t,e,i,s,n,o,a,l){const{startEdge:c,endEdge:h,direction:d}=r,u=wo(e);function p(m,y){return $s(m).filter(w=>w%y===0).map(w=>m.slice(w,w+y))}function g(m){return m.length?$s(m).reduce((y,w,S)=>{const T=Te(y)||0,O=T===0,k=w===Gs(m),E=s[c]-n[T][c],P=s[c]-n[w][h],R=!i&&O?d(o):0,L=!i&&k?d(a):0,F=ct(P-L-(E+R));return S&&F>t+l&&y.push(w),k&&y.push(m.length),y},[]).map((y,w,S)=>{const T=Math.max(S[w-1]||0);return m.slice(T,y)}):[]}function f(m){return u?p(m,e):g(m)}return{groupSlides:f}}function _d(r,t,e,i,s,n,o){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:p,dragThreshold:g,inViewThreshold:f,slidesToScroll:b,skipSnaps:m,containScroll:y,watchResize:w,watchSlides:S,watchDrag:T,watchFocus:O}=n,k=2,E=ed(),P=E.measure(t),R=e.map(E.measure),L=Jh(l,c),F=L.measureSize(P),H=id(F),M=qh(a,F),U=!d&&!!y,X=d||!!y,{slideSizes:Q,slideSizesWithGaps:N,startGap:Ct,endGap:Ut}=vd(L,P,R,e,X,s),Wt=yd(L,F,b,d,P,R,Ct,Ut,k),{snaps:Pe,snapsAligned:de}=hd(L,M,P,R,Wt),Ft=-Te(Pe)+Te(N),{snapsContained:Ae,scrollContainLimit:ae}=od(F,Ft,de,y,k),At=U?Ae:de,{limit:jt}=ad(Ft,At,d),le=Vl(Gs(At),h,d),vt=le.clone(),at=$s(e),D=({dragHandler:Vi,scrollBody:xn,scrollBounds:wn,options:{loop:tr}})=>{tr||wn.constrain(Vi.pointerDown()),xn.seek()},tt=({scrollBody:Vi,translate:xn,location:wn,offsetLocation:tr,previousLocation:fh,scrollLooper:mh,slideLooper:bh,dragHandler:vh,animation:yh,eventHandler:Jo,scrollBounds:_h,options:{loop:Qo}},ta)=>{const ea=Vi.settled(),xh=!_h.shouldConstrain(),ia=Qo?ea:ea&&xh,sa=ia&&!vh.pointerDown();sa&&yh.stop();const wh=wn.get()*ta+fh.get()*(1-ta);tr.set(wh),Qo&&(mh.loop(Vi.direction()),bh.loop()),xn.to(tr.get()),sa&&Jo.emit("settle"),ia||Jo.emit("scroll")},St=Zh(i,s,()=>D(_n),Vi=>tt(_n,Vi)),Yt=.68,De=At[le.get()],Ve=Cs(De),xi=Cs(De),oi=Cs(De),wi=Cs(De),ds=rd(Ve,oi,xi,wi,u,Yt),vn=ud(d,At,Ft,jt,wi),yn=pd(St,le,vt,ds,vn,wi,o),Ko=cd(jt),qo=Bs(),ph=bd(t,e,o,f),{slideRegistry:Zo}=dd(U,y,At,ae,Wt,at),gh=gd(r,e,Zo,yn,ds,qo,o,O),_n={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:St,axis:L,dragHandler:Qh(L,r,i,s,wi,td(L,s),Ve,St,yn,ds,vn,le,o,H,p,g,m,Yt,T),eventStore:qo,percentOfView:H,index:le,indexPrevious:vt,limit:jt,location:Ve,offsetLocation:oi,previousLocation:xi,options:n,resizeHandler:sd(t,o,s,e,L,w,E),scrollBody:ds,scrollBounds:nd(jt,oi,wi,ds,H),scrollLooper:ld(Ft,jt,oi,[Ve,oi,xi,wi]),scrollProgress:Ko,scrollSnapList:At.map(Ko.get),scrollSnaps:At,scrollTarget:vn,scrollTo:yn,slideLooper:fd(L,F,Ft,Q,N,Pe,At,oi,e),slideFocus:gh,slidesHandler:md(t,o,S),slidesInView:ph,slideIndexes:at,slideRegistry:Zo,slidesToScroll:Wt,target:wi,translate:Nl(L,t)};return _n}function xd(){let r={},t;function e(c){t=c}function i(c){return r[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function n(c,h){return r[c]=i(c).concat([h]),l}function o(c,h){return r[c]=i(c).filter(d=>d!==h),l}function a(){r={}}const l={init:e,emit:s,off:o,on:n,clear:a};return l}const wd={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Cd(r){function t(n,o){return Hl(n,o||{})}function e(n){const o=n.breakpoints||{},a=Rs(o).filter(l=>r.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>t(l,c),{});return t(n,a)}function i(n){return n.map(o=>Rs(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(r.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function Sd(r){let t=[];function e(n,o){return t=o.filter(({options:a})=>r.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(n,r)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(n=>n.destroy())}return{init:e,destroy:i}}function To(r,t,e){const i=r.ownerDocument,s=i.defaultView,n=Cd(s),o=Sd(n),a=Bs(),l=xd(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=n,{on:u,off:p,emit:g}=l,f=L;let b=!1,m,y=c(wd,To.globalOptions),w=c(y),S=[],T,O,k;function E(){const{container:at,slides:D}=w;O=(Gn(at)?r.querySelector(at):at)||r.children[0];const St=Gn(D)?O.querySelectorAll(D):D;k=[].slice.call(St||O.children)}function P(at){const D=_d(r,O,k,i,s,at,l);if(at.loop&&!D.slideLooper.canLoop()){const tt=Object.assign({},at,{loop:!1});return P(tt)}return D}function R(at,D){b||(y=c(y,at),w=h(y),S=D||S,E(),m=P(w),d([y,...S.map(({options:tt})=>tt)]).forEach(tt=>a.add(tt,"change",L)),w.active&&(m.translate.to(m.location.get()),m.animation.init(),m.slidesInView.init(),m.slideFocus.init(vt),m.eventHandler.init(vt),m.resizeHandler.init(vt),m.slidesHandler.init(vt),m.options.loop&&m.slideLooper.loop(),O.offsetParent&&k.length&&m.dragHandler.init(vt),T=o.init(vt,S)))}function L(at,D){const tt=Wt();F(),R(c({startIndex:tt},at),D),l.emit("reInit")}function F(){m.dragHandler.destroy(),m.eventStore.clear(),m.translate.clear(),m.slideLooper.clear(),m.resizeHandler.destroy(),m.slidesHandler.destroy(),m.slidesInView.destroy(),m.animation.destroy(),o.destroy(),a.clear()}function H(){b||(b=!0,a.clear(),F(),l.emit("destroy"),l.clear())}function M(at,D,tt){!w.active||b||(m.scrollBody.useBaseFriction().useDuration(D===!0?0:w.duration),m.scrollTo.index(at,tt||0))}function U(at){const D=m.index.add(1).get();M(D,at,-1)}function X(at){const D=m.index.add(-1).get();M(D,at,1)}function Q(){return m.index.add(1).get()!==Wt()}function N(){return m.index.add(-1).get()!==Wt()}function Ct(){return m.scrollSnapList}function Ut(){return m.scrollProgress.get(m.offsetLocation.get())}function Wt(){return m.index.get()}function Pe(){return m.indexPrevious.get()}function de(){return m.slidesInView.get()}function Ft(){return m.slidesInView.get(!1)}function Ae(){return T}function ae(){return m}function At(){return r}function jt(){return O}function le(){return k}const vt={canScrollNext:Q,canScrollPrev:N,containerNode:jt,internalEngine:ae,destroy:H,off:p,on:u,emit:g,plugins:Ae,previousScrollSnap:Pe,reInit:f,rootNode:At,scrollNext:U,scrollPrev:X,scrollProgress:Ut,scrollSnapList:Ct,scrollTo:M,selectedScrollSnap:Wt,slideNodes:le,slidesInView:de,slidesNotInView:Ft};return R(t,e),setTimeout(()=>l.emit("init"),0),vt}To.globalOptions=void 0;const Td=ft`
417
+ `,Gh=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";function wo(r){return typeof r=="number"}function Gn(r){return typeof r=="string"}function Qr(r){return typeof r=="boolean"}function fa(r){return Object.prototype.toString.call(r)==="[object Object]"}function ct(r){return Math.abs(r)}function Co(r){return Math.sign(r)}function Ps(r,t){return ct(r-t)}function Xh(r,t){if(r===0||t===0||ct(r)<=ct(t))return 0;const e=Ps(ct(r),ct(t));return ct(e/r)}function Kh(r){return Math.round(r*100)/100}function $s(r){return Rs(r).map(Number)}function Te(r){return r[Gs(r)]}function Gs(r){return Math.max(0,r.length-1)}function So(r,t){return t===Gs(r)}function ma(r,t=0){return Array.from(Array(r),(e,i)=>t+i)}function Rs(r){return Object.keys(r)}function Hl(r,t){return[r,t].reduce((e,i)=>(Rs(i).forEach(s=>{const n=e[s],o=i[s],a=fa(n)&&fa(o);e[s]=a?Hl(n,o):o}),e),{})}function Xn(r,t){return typeof t.MouseEvent<"u"&&r instanceof t.MouseEvent}function qh(r,t){const e={start:i,center:s,end:n};function i(){return 0}function s(l){return n(l)/2}function n(l){return t-l}function o(l,c){return Gn(r)?e[r](l):r(t,l,c)}return{measure:o}}function Bs(){let r=[];function t(s,n,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(n,o,a),l=()=>s.removeEventListener(n,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return r.push(l),i}function e(){r=r.filter(s=>s())}const i={add:t,clear:e};return i}function Zh(r,t,e,i){const s=Bs(),n=1e3/60;let o=null,a=0,l=0;function c(){s.add(r,"visibilitychange",()=>{r.hidden&&g()})}function h(){p(),s.clear()}function d(m){if(!l)return;o||(o=m,e(),e());const b=m-o;for(o=m,a+=b;a>=n;)e(),a-=n;const _=a/n;i(_),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function p(){t.cancelAnimationFrame(l),o=null,a=0,l=0}function g(){o=null,a=0}return{init:c,destroy:h,start:u,stop:p,update:e,render:i}}function Jh(r,t){const e=t==="rtl",i=r==="y",s=i?"y":"x",n=i?"x":"y",o=!i&&e?-1:1,a=h(),l=d();function c(g){const{height:f,width:m}=g;return i?f:m}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(g){return g*o}return{scroll:s,cross:n,startEdge:a,endEdge:l,measureSize:c,direction:u}}function Fi(r=0,t=0){const e=ct(r-t);function i(c){return c<r}function s(c){return c>t}function n(c){return i(c)||s(c)}function o(c){return n(c)?i(c)?r:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:r,constrain:o,reachedAny:n,reachedMax:s,reachedMin:i,removeOffset:a}}function Vl(r,t,e){const{constrain:i}=Fi(0,r),s=r+1;let n=o(t);function o(u){return e?ct((s+u)%s):i(u)}function a(){return n}function l(u){return n=o(u),d}function c(u){return h().set(a()+u)}function h(){return Vl(r,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function Qh(r,t,e,i,s,n,o,a,l,c,h,d,u,p,g,f,m,b,_){const{cross:w,direction:S}=r,T=["INPUT","SELECT","TEXTAREA"],k={passive:!1},O=Bs(),E=Bs(),P=Fi(50,225).constrain(p.measure(20)),R={mouse:300,touch:400},L={mouse:500,touch:600},F=g?43:25;let H=!1,M=0,U=0,X=!1,Q=!1,N=!1,Ct=!1;function Ut(D){if(!_)return;function tt(Yt){(Qr(_)||_(D,Yt))&&ae(Yt)}const St=t;O.add(St,"dragstart",Yt=>Yt.preventDefault(),k).add(St,"touchmove",()=>{},k).add(St,"touchend",()=>{}).add(St,"touchstart",tt).add(St,"mousedown",tt).add(St,"touchcancel",jt).add(St,"contextmenu",jt).add(St,"click",le,!0)}function Wt(){O.clear(),E.clear()}function Pe(){const D=Ct?e:t;E.add(D,"touchmove",At,k).add(D,"touchend",jt).add(D,"mousemove",At,k).add(D,"mouseup",jt)}function de(D){const tt=D.nodeName||"";return T.includes(tt)}function Ft(){return(g?L:R)[Ct?"mouse":"touch"]}function Ae(D,tt){const St=d.add(Co(D)*-1),Yt=h.byDistance(D,!g).distance;return g||ct(D)<P?Yt:m&&tt?Yt*.5:h.byIndex(St.get(),0).distance}function ae(D){const tt=Xn(D,i);Ct=tt,N=g&&tt&&!D.buttons&&H,H=Ps(s.get(),o.get())>=2,!(tt&&D.button!==0)&&(de(D.target)||(X=!0,n.pointerDown(D),c.useFriction(0).useDuration(0),s.set(o),Pe(),M=n.readPoint(D),U=n.readPoint(D,w),u.emit("pointerDown")))}function At(D){if(!Xn(D,i)&&D.touches.length>=2)return jt(D);const St=n.readPoint(D),Yt=n.readPoint(D,w),De=Ps(St,M),Ve=Ps(Yt,U);if(!Q&&!Ct&&(!D.cancelable||(Q=De>Ve,!Q)))return jt(D);const xi=n.pointerMove(D);De>f&&(N=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(S(xi)),D.preventDefault()}function jt(D){const St=h.byDistance(0,!1).index!==d.get(),Yt=n.pointerUp(D)*Ft(),De=Ae(S(Yt),St),Ve=Xh(Yt,De),xi=F-10*Ve,oi=b+Ve/50;Q=!1,X=!1,E.clear(),c.useDuration(xi).useFriction(oi),l.distance(De,!g),Ct=!1,u.emit("pointerUp")}function le(D){N&&(D.stopPropagation(),D.preventDefault(),N=!1)}function vt(){return X}return{init:Ut,destroy:Wt,pointerDown:vt}}function td(r,t){let i,s;function n(d){return d.timeStamp}function o(d,u){const g=`client${(u||r.scroll)==="x"?"X":"Y"}`;return(Xn(d,t)?d:d.touches[0])[g]}function a(d){return i=d,s=d,o(d)}function l(d){const u=o(d)-o(s),p=n(d)-n(i)>170;return s=d,p&&(i=d),u}function c(d){if(!i||!s)return 0;const u=o(s)-o(i),p=n(d)-n(i),g=n(d)-n(s)>170,f=u/p;return p&&!g&&ct(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function ed(){function r(e){const{offsetTop:i,offsetLeft:s,offsetWidth:n,offsetHeight:o}=e;return{top:i,right:s+n,bottom:i+o,left:s,width:n,height:o}}return{measure:r}}function id(r){function t(i){return r*(i/100)}return{measure:t}}function sd(r,t,e,i,s,n,o){const a=[r].concat(i);let l,c,h=[],d=!1;function u(m){return s.measureSize(o.measure(m))}function p(m){if(!n)return;c=u(r),h=i.map(u);function b(_){for(const w of _){if(d)return;const S=w.target===r,T=i.indexOf(w.target),k=S?c:h[T],O=u(S?r:i[T]);if(ct(O-k)>=.5){m.reInit(),t.emit("resize");break}}}l=new ResizeObserver(_=>{(Qr(n)||n(m,_))&&b(_)}),e.requestAnimationFrame(()=>{a.forEach(_=>l.observe(_))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function rd(r,t,e,i,s,n){let o=0,a=0,l=s,c=n,h=r.get(),d=0;function u(){const k=i.get()-r.get(),O=!l;let E=0;return O?(o=0,e.set(i),r.set(i),E=k):(e.set(r),o+=k/l,o*=c,h+=o,r.add(o),E=h-d),a=Co(E),d=h,T}function p(){const k=i.get()-t.get();return ct(k)<.001}function g(){return l}function f(){return a}function m(){return o}function b(){return w(s)}function _(){return S(n)}function w(k){return l=k,T}function S(k){return c=k,T}const T={direction:f,duration:g,velocity:m,seek:u,settled:p,useBaseFriction:_,useBaseDuration:b,useFriction:S,useDuration:w};return T}function nd(r,t,e,i,s){const n=s.measure(10),o=s.measure(50),a=Fi(.1,.99);let l=!1;function c(){return!(l||!r.reachedAny(e.get())||!r.reachedAny(t.get()))}function h(p){if(!c())return;const g=r.reachedMin(t.get())?"min":"max",f=ct(r[g]-t.get()),m=e.get()-t.get(),b=a.constrain(f/o);e.subtract(m*b),!p&&ct(m)<n&&(e.set(r.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(p){l=!p}return{shouldConstrain:c,constrain:h,toggleActive:d}}function od(r,t,e,i,s){const n=Fi(-t+r,0),o=d(),a=h(),l=u();function c(g,f){return Ps(g,f)<=1}function h(){const g=o[0],f=Te(o),m=o.lastIndexOf(g),b=o.indexOf(f)+1;return Fi(m,b)}function d(){return e.map((g,f)=>{const{min:m,max:b}=n,_=n.constrain(g),w=!f,S=So(e,f);return w?b:S||c(m,_)?m:c(b,_)?b:_}).map(g=>parseFloat(g.toFixed(3)))}function u(){if(t<=r+s)return[n.max];if(i==="keepSnaps")return o;const{min:g,max:f}=a;return o.slice(g,f)}return{snapsContained:l,scrollContainLimit:a}}function ad(r,t,e){const i=t[0],s=e?i-r:Te(t);return{limit:Fi(s,i)}}function ld(r,t,e,i){const n=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=Fi(n,o);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const p=r*(u*-1);i.forEach(g=>g.add(p))}return{loop:h}}function cd(r){const{max:t,length:e}=r;function i(n){const o=n-t;return e?o/-e:0}return{get:i}}function hd(r,t,e,i,s){const{startEdge:n,endEdge:o}=r,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=p();function d(){return a(i).map(f=>Te(f)[o]-f[0][n]).map(ct)}function u(){return i.map(f=>e[n]-f[n]).map(f=>-ct(f))}function p(){return a(c).map(f=>f[0]).map((f,m)=>f+l[m])}return{snaps:c,snapsAligned:h}}function dd(r,t,e,i,s,n){const{groupSlides:o}=s,{min:a,max:l}=i,c=h();function h(){const u=o(n),p=!r||t==="keepSnaps";return e.length===1?[n]:p?u:u.slice(a,l).map((g,f,m)=>{const b=!f,_=So(m,f);if(b){const w=Te(m[0])+1;return ma(w)}if(_){const w=Gs(n)-Te(m)[0]+1;return ma(w,Te(m)[0])}return g})}return{slideRegistry:c}}function ud(r,t,e,i,s){const{reachedAny:n,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,m)=>ct(f)-ct(m))[0]}function c(g){const f=r?o(g):a(g),m=t.map((_,w)=>({diff:h(_-f,0),index:w})).sort((_,w)=>ct(_.diff)-ct(w.diff)),{index:b}=m[0];return{index:b,distance:f}}function h(g,f){const m=[g,g+e,g-e];if(!r)return g;if(!f)return l(m);const b=m.filter(_=>Co(_)===f);return b.length?l(b):Te(m)-e}function d(g,f){const m=t[g]-s.get(),b=h(m,f);return{index:g,distance:b}}function u(g,f){const m=s.get()+g,{index:b,distance:_}=c(m),w=!r&&n(m);if(!f||w)return{index:b,distance:g};const S=t[b]-_,T=g+h(S,0);return{index:b,distance:T}}return{byDistance:u,byIndex:d,shortcut:h}}function pd(r,t,e,i,s,n,o){function a(d){const u=d.distance,p=d.index!==t.get();n.add(u),u&&(i.duration()?r.start():(r.update(),r.render(1),r.update())),p&&(e.set(t.get()),t.set(d.index),o.emit("select"))}function l(d,u){const p=s.byDistance(d,u);a(p)}function c(d,u){const p=t.clone().set(d),g=s.byIndex(p.get(),u);a(g)}return{distance:l,index:c}}function gd(r,t,e,i,s,n,o,a){const l={passive:!0,capture:!0};let c=0;function h(p){if(!a)return;function g(f){if(new Date().getTime()-c>10)return;o.emit("slideFocusStart"),r.scrollLeft=0;const _=e.findIndex(w=>w.includes(f));wo(_)&&(s.useDuration(0),i.index(_,0),o.emit("slideFocus"))}n.add(document,"keydown",d,!1),t.forEach((f,m)=>{n.add(f,"focus",b=>{(Qr(a)||a(p,b))&&g(m)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Cs(r){let t=r;function e(){return t}function i(l){t=o(l)}function s(l){t+=o(l)}function n(l){t-=o(l)}function o(l){return wo(l)?l:l.get()}return{get:e,set:i,add:s,subtract:n}}function Nl(r,t){const e=r.scroll==="x"?o:a,i=t.style;let s=null,n=!1;function o(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(n)return;const p=Kh(r.direction(u));p!==s&&(i.transform=e(p),s=p)}function c(u){n=!u}function h(){n||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function fd(r,t,e,i,s,n,o,a,l){const h=$s(s),d=$s(s).reverse(),u=b().concat(_());function p(O,E){return O.reduce((P,R)=>P-s[R],E)}function g(O,E){return O.reduce((P,R)=>p(P,E)>0?P.concat([R]):P,[])}function f(O){return n.map((E,P)=>({start:E-i[P]+.5+O,end:E+t-.5+O}))}function m(O,E,P){const R=f(E);return O.map(L=>{const F=P?0:-e,H=P?e:0,M=P?"end":"start",U=R[L][M];return{index:L,loopPoint:U,slideLocation:Cs(-1),translate:Nl(r,l[L]),target:()=>a.get()>U?F:H}})}function b(){const O=o[0],E=g(d,O);return m(E,e,!1)}function _(){const O=t-o[0]-1,E=g(h,O);return m(E,-e,!0)}function w(){return u.every(({index:O})=>{const E=h.filter(P=>P!==O);return p(E,t)<=.1})}function S(){u.forEach(O=>{const{target:E,translate:P,slideLocation:R}=O,L=E();L!==R.get()&&(P.to(L),R.set(L))})}function T(){u.forEach(O=>O.translate.clear())}return{canLoop:w,clear:T,loop:S,loopPoints:u}}function md(r,t,e){let i,s=!1;function n(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(Qr(e)||e(l,h))&&c(h)}),i.observe(r,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:n,destroy:o}}function bd(r,t,e,i){const s={};let n=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(g=>{l||(g.forEach(f=>{const m=t.indexOf(f.target);s[m]=f}),n=null,o=null,e.emit("slidesInView"))},{root:r.parentElement,threshold:i}),t.forEach(g=>a.observe(g))}function h(){a&&a.disconnect(),l=!0}function d(g){return Rs(s).reduce((f,m)=>{const b=parseInt(m),{isIntersecting:_}=s[b];return(g&&_||!g&&!_)&&f.push(b),f},[])}function u(g=!0){if(g&&n)return n;if(!g&&o)return o;const f=d(g);return g&&(n=f),g||(o=f),f}return{init:c,destroy:h,get:u}}function vd(r,t,e,i,s,n){const{measureSize:o,startEdge:a,endEdge:l}=r,c=e[0]&&s,h=g(),d=f(),u=e.map(o),p=m();function g(){if(!c)return 0;const _=e[0];return ct(t[a]-_[a])}function f(){if(!c)return 0;const _=n.getComputedStyle(Te(i));return parseFloat(_.getPropertyValue(`margin-${l}`))}function m(){return e.map((_,w,S)=>{const T=!w,k=So(S,w);return T?u[w]+h:k?u[w]+d:S[w+1][a]-_[a]}).map(ct)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function yd(r,t,e,i,s,n,o,a,l){const{startEdge:c,endEdge:h,direction:d}=r,u=wo(e);function p(b,_){return $s(b).filter(w=>w%_===0).map(w=>b.slice(w,w+_))}function g(b){return b.length?$s(b).reduce((_,w,S)=>{const T=Te(_)||0,k=T===0,O=w===Gs(b),E=s[c]-n[T][c],P=s[c]-n[w][h],R=!i&&k?d(o):0,L=!i&&O?d(a):0,F=ct(P-L-(E+R));return S&&F>t+l&&_.push(w),O&&_.push(b.length),_},[]).map((_,w,S)=>{const T=Math.max(S[w-1]||0);return b.slice(T,_)}):[]}function f(b){return u?p(b,e):g(b)}return{groupSlides:f}}function _d(r,t,e,i,s,n,o){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:p,dragThreshold:g,inViewThreshold:f,slidesToScroll:m,skipSnaps:b,containScroll:_,watchResize:w,watchSlides:S,watchDrag:T,watchFocus:k}=n,O=2,E=ed(),P=E.measure(t),R=e.map(E.measure),L=Jh(l,c),F=L.measureSize(P),H=id(F),M=qh(a,F),U=!d&&!!_,X=d||!!_,{slideSizes:Q,slideSizesWithGaps:N,startGap:Ct,endGap:Ut}=vd(L,P,R,e,X,s),Wt=yd(L,F,m,d,P,R,Ct,Ut,O),{snaps:Pe,snapsAligned:de}=hd(L,M,P,R,Wt),Ft=-Te(Pe)+Te(N),{snapsContained:Ae,scrollContainLimit:ae}=od(F,Ft,de,_,O),At=U?Ae:de,{limit:jt}=ad(Ft,At,d),le=Vl(Gs(At),h,d),vt=le.clone(),at=$s(e),D=({dragHandler:Vi,scrollBody:xn,scrollBounds:wn,options:{loop:tr}})=>{tr||wn.constrain(Vi.pointerDown()),xn.seek()},tt=({scrollBody:Vi,translate:xn,location:wn,offsetLocation:tr,previousLocation:fh,scrollLooper:mh,slideLooper:bh,dragHandler:vh,animation:yh,eventHandler:Jo,scrollBounds:_h,options:{loop:Qo}},ta)=>{const ea=Vi.settled(),xh=!_h.shouldConstrain(),ia=Qo?ea:ea&&xh,sa=ia&&!vh.pointerDown();sa&&yh.stop();const wh=wn.get()*ta+fh.get()*(1-ta);tr.set(wh),Qo&&(mh.loop(Vi.direction()),bh.loop()),xn.to(tr.get()),sa&&Jo.emit("settle"),ia||Jo.emit("scroll")},St=Zh(i,s,()=>D(_n),Vi=>tt(_n,Vi)),Yt=.68,De=At[le.get()],Ve=Cs(De),xi=Cs(De),oi=Cs(De),wi=Cs(De),ds=rd(Ve,oi,xi,wi,u,Yt),vn=ud(d,At,Ft,jt,wi),yn=pd(St,le,vt,ds,vn,wi,o),Ko=cd(jt),qo=Bs(),ph=bd(t,e,o,f),{slideRegistry:Zo}=dd(U,_,At,ae,Wt,at),gh=gd(r,e,Zo,yn,ds,qo,o,k),_n={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:St,axis:L,dragHandler:Qh(L,r,i,s,wi,td(L,s),Ve,St,yn,ds,vn,le,o,H,p,g,b,Yt,T),eventStore:qo,percentOfView:H,index:le,indexPrevious:vt,limit:jt,location:Ve,offsetLocation:oi,previousLocation:xi,options:n,resizeHandler:sd(t,o,s,e,L,w,E),scrollBody:ds,scrollBounds:nd(jt,oi,wi,ds,H),scrollLooper:ld(Ft,jt,oi,[Ve,oi,xi,wi]),scrollProgress:Ko,scrollSnapList:At.map(Ko.get),scrollSnaps:At,scrollTarget:vn,scrollTo:yn,slideLooper:fd(L,F,Ft,Q,N,Pe,At,oi,e),slideFocus:gh,slidesHandler:md(t,o,S),slidesInView:ph,slideIndexes:at,slideRegistry:Zo,slidesToScroll:Wt,target:wi,translate:Nl(L,t)};return _n}function xd(){let r={},t;function e(c){t=c}function i(c){return r[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function n(c,h){return r[c]=i(c).concat([h]),l}function o(c,h){return r[c]=i(c).filter(d=>d!==h),l}function a(){r={}}const l={init:e,emit:s,off:o,on:n,clear:a};return l}const wd={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Cd(r){function t(n,o){return Hl(n,o||{})}function e(n){const o=n.breakpoints||{},a=Rs(o).filter(l=>r.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>t(l,c),{});return t(n,a)}function i(n){return n.map(o=>Rs(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(r.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function Sd(r){let t=[];function e(n,o){return t=o.filter(({options:a})=>r.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(n,r)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(n=>n.destroy())}return{init:e,destroy:i}}function To(r,t,e){const i=r.ownerDocument,s=i.defaultView,n=Cd(s),o=Sd(n),a=Bs(),l=xd(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=n,{on:u,off:p,emit:g}=l,f=L;let m=!1,b,_=c(wd,To.globalOptions),w=c(_),S=[],T,k,O;function E(){const{container:at,slides:D}=w;k=(Gn(at)?r.querySelector(at):at)||r.children[0];const St=Gn(D)?k.querySelectorAll(D):D;O=[].slice.call(St||k.children)}function P(at){const D=_d(r,k,O,i,s,at,l);if(at.loop&&!D.slideLooper.canLoop()){const tt=Object.assign({},at,{loop:!1});return P(tt)}return D}function R(at,D){m||(_=c(_,at),w=h(_),S=D||S,E(),b=P(w),d([_,...S.map(({options:tt})=>tt)]).forEach(tt=>a.add(tt,"change",L)),w.active&&(b.translate.to(b.location.get()),b.animation.init(),b.slidesInView.init(),b.slideFocus.init(vt),b.eventHandler.init(vt),b.resizeHandler.init(vt),b.slidesHandler.init(vt),b.options.loop&&b.slideLooper.loop(),k.offsetParent&&O.length&&b.dragHandler.init(vt),T=o.init(vt,S)))}function L(at,D){const tt=Wt();F(),R(c({startIndex:tt},at),D),l.emit("reInit")}function F(){b.dragHandler.destroy(),b.eventStore.clear(),b.translate.clear(),b.slideLooper.clear(),b.resizeHandler.destroy(),b.slidesHandler.destroy(),b.slidesInView.destroy(),b.animation.destroy(),o.destroy(),a.clear()}function H(){m||(m=!0,a.clear(),F(),l.emit("destroy"),l.clear())}function M(at,D,tt){!w.active||m||(b.scrollBody.useBaseFriction().useDuration(D===!0?0:w.duration),b.scrollTo.index(at,tt||0))}function U(at){const D=b.index.add(1).get();M(D,at,-1)}function X(at){const D=b.index.add(-1).get();M(D,at,1)}function Q(){return b.index.add(1).get()!==Wt()}function N(){return b.index.add(-1).get()!==Wt()}function Ct(){return b.scrollSnapList}function Ut(){return b.scrollProgress.get(b.offsetLocation.get())}function Wt(){return b.index.get()}function Pe(){return b.indexPrevious.get()}function de(){return b.slidesInView.get()}function Ft(){return b.slidesInView.get(!1)}function Ae(){return T}function ae(){return b}function At(){return r}function jt(){return k}function le(){return O}const vt={canScrollNext:Q,canScrollPrev:N,containerNode:jt,internalEngine:ae,destroy:H,off:p,on:u,emit:g,plugins:Ae,previousScrollSnap:Pe,reInit:f,rootNode:At,scrollNext:U,scrollPrev:X,scrollProgress:Ut,scrollSnapList:Ct,scrollTo:M,selectedScrollSnap:Wt,slideNodes:le,slidesInView:de,slidesNotInView:Ft};return R(t,e),setTimeout(()=>l.emit("init"),0),vt}To.globalOptions=void 0;const Td=ft`
418
418
  :host,
419
419
  :host * {
420
420
  max-height: 100%;
@@ -1448,7 +1448,7 @@
1448
1448
  .form-control__label > slot {
1449
1449
  font-size: 16.5px;
1450
1450
  }
1451
- `;/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Kn=function(r,t){return Kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Kn(r,t)};function Wl(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Kn(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Jt=function(){return Jt=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},Jt.apply(this,arguments)};function Wd(r,t,e){for(var i=0,s=t.length,n;i<s;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return r.concat(n||Array.prototype.slice.call(t))}var yt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Zt={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Ht={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},Yd=["fuseOptions","classNames"],di={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},_a=function(r){return{type:yt.ADD_CHOICE,choice:r}},Gd=function(r){return{type:yt.REMOVE_CHOICE,choice:r}},Xd=function(r){return{type:yt.FILTER_CHOICES,results:r}},Kd=function(r){return{type:yt.ACTIVATE_CHOICES,active:r}},qd=function(r){return{type:yt.ADD_GROUP,group:r}},xa=function(r){return{type:yt.ADD_ITEM,item:r}},wa=function(r){return{type:yt.REMOVE_ITEM,item:r}},ir=function(r,t){return{type:yt.HIGHLIGHT_ITEM,item:r,highlighted:t}},Zd=function(r,t){return Math.floor(Math.random()*(t-r)+r)},Ca=function(r){return Array.from({length:r},function(){return Zd(0,36).toString(36)}).join("")},Jd=function(r,t){var e=r.id||r.name&&"".concat(r.name,"-").concat(Ca(2))||Ca(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Qd=function(r,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=r[i];s;){if(s.matches(t))return s;s=s[i]}return null},tu=function(r,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=r.offsetTop+r.offsetHeight:i=r.offsetTop>=t.scrollTop,i},rn=function(r){if(typeof r!="string"){if(r==null)return"";if(typeof r=="object"){if("raw"in r)return rn(r.raw);if("trusted"in r)return r.trusted}return r}return r.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},eu=(function(){var r=document.createElement("div");return function(t){r.innerHTML=t.trim();for(var e=r.children[0];r.firstChild;)r.removeChild(r.firstChild);return e}})(),As=function(r,t){return typeof r=="function"?r(rn(t),t):r},Sa=function(r){return typeof r=="function"?r():r},Ai=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("trusted"in r)return r.trusted;if("raw"in r)return r.raw}return""},Yl=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("escaped"in r)return r.escaped;if("trusted"in r)return r.trusted}return""},ko=function(r,t){return r?Yl(t):rn(t)},Ne=function(r,t,e){r.innerHTML=ko(t,e)},iu=function(r,t){var e=r.value,i=r.label,s=i===void 0?e:i,n=t.value,o=t.label,a=o===void 0?n:o;return Ai(s).localeCompare(Ai(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},su=function(r,t){return r.rank-t.rank},ru=function(r,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return r.dispatchEvent(i)},nu=function(r,t){var e=Object.keys(r).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},nn=function(r){return Array.isArray(r)?r:[r]},ms=function(r){return r&&Array.isArray(r)?r.map(function(t){return".".concat(t)}).join(""):".".concat(r)},B=function(r,t){var e;(e=r.classList).add.apply(e,nn(t))},Ie=function(r,t){var e;(e=r.classList).remove.apply(e,nn(t))},ou=function(r){if(typeof r<"u")try{return JSON.parse(r)}catch{return r}return{}},au=function(r,t,e){var i=r.itemEl;i&&(Ie(i,e),B(i,t))},lu=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return r.prototype.show=function(){return B(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},r.prototype.hide=function(){return Ie(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},r})(),Ta=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.position;this.element=e,this.classNames=s,this.type=i,this.position=n,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return r.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype.open=function(t,e){B(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(B(this.element,this.classNames.flippedState),this.isFlipped=!0)},r.prototype.close=function(){Ie(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Ie(this.element,this.classNames.flippedState),this.isFlipped=!1)},r.prototype.addFocusState=function(){B(this.element,this.classNames.focusState)},r.prototype.removeFocusState=function(){Ie(this.element,this.classNames.focusState)},r.prototype.enable=function(){Ie(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},r.prototype.disable=function(){B(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},r.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},r.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},r.prototype.addLoadingState=function(){B(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},r.prototype.removeLoadingState=function(){Ie(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},r})(),cu=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=n,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(r.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},r.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},r.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},r.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},r.prototype.focus=function(){this.isFocussed||this.element.focus()},r.prototype.blur=function(){this.isFocussed&&this.element.blur()},r.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},r.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype._onInput=function(){this.type!==di.SelectOne&&this.setWidth()},r.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},r.prototype._onFocus=function(){this.isFocussed=!0},r.prototype._onBlur=function(){this.isFocussed=!1},r})(),hu=4,Ea=(function(){function r(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return r.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},r.prototype.scrollToTop=function(){this.element.scrollTop=0},r.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,n=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-n:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},r.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,n=s>1?s:1;this.element.scrollTop=t+n},r.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,n=s>1?s:1;this.element.scrollTop=t-n},r.prototype._animateScroll=function(t,e){var i=this,s=hu,n=this.element.scrollTop,o=!1;e>0?(this._scrollDown(n,s,t),n<t&&(o=!0)):(this._scrollUp(n,s,t),n>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},r})(),Gl=(function(){function r(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(r.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.conceal=function(){var t=this.element;B(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},r.prototype.reveal=function(){var t=this.element;Ie(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},r.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},r.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},r.prototype.triggerEvent=function(t,e){ru(this.element,t,e||{})},r})(),du=(function(r){Wl(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(Gl),Ss=function(r,t){return t===void 0&&(t=!0),typeof r>"u"?t:!!r},Xl=function(r){if(typeof r=="string"&&(r=r.split(" ").filter(function(t){return t.length})),Array.isArray(r)&&r.length)return r},Me=function(r,t,e){if(e===void 0&&(e=!0),typeof r=="string"){var i=rn(r),s=e||i===r?r:{escaped:i,raw:r},n=Me({value:r,label:s,selected:!0},!1);return n}var o=r;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(u){return Me(u,!1)}),c={id:0,label:Ai(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ss(h.active),selected:Ss(h.selected,!1),disabled:Ss(h.disabled,!1),placeholder:Ss(h.placeholder,!1),highlighted:!1,labelClass:Xl(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},uu=function(r){return r.tagName==="INPUT"},Kl=function(r){return r.tagName==="SELECT"},pu=function(r){return r.tagName==="OPTION"},gu=function(r){return r.tagName==="OPTGROUP"},fu=(function(r){Wl(t,r);function t(e){var i=e.element,s=e.classNames,n=e.template,o=e.extractPlaceholder,a=r.call(this,{element:i,classNames:s})||this;return a.template=n,a.extractPlaceholder=o,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(n){var o=n;if(!o.element){var a=i.template(o);s.appendChild(a),o.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){pu(s)?i.push(e._optionToChoice(s)):gu(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Xl(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:ou(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),n=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},t})(Gl),mu={containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},Oa={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(r){return!!r&&r!==""},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:iu,shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(r){return'Press Enter to add <b>"'.concat(r,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(r){return"Remove item: ".concat(r)},maxItemText:function(r){return"Only ".concat(r," values can be added")},valueComparer:function(r,t){return r===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:mu,appendGroupInSearch:!1},ka=function(r){var t=r.itemEl;t&&(t.remove(),r.itemEl=void 0)};function bu(r,t,e){var i=r,s=!0;switch(t.type){case yt.ADD_ITEM:{t.item.selected=!0;var n=t.item.element;n&&(n.selected=!0,n.setAttribute("selected","")),i.push(t.item);break}case yt.REMOVE_ITEM:{t.item.selected=!1;var n=t.item.element;if(n){n.selected=!1,n.removeAttribute("selected");var o=n.parentElement;o&&Kl(o)&&o.type===di.SelectOne&&(o.value="")}ka(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case yt.REMOVE_CHOICE:{ka(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case yt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&au(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function vu(r,t){var e=r,i=!0;switch(t.type){case yt.ADD_GROUP:{e.push(t.group);break}case yt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function yu(r,t,e){var i=r,s=!0;switch(t.type){case yt.ADD_CHOICE:{i.push(t.choice);break}case yt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case yt.ADD_ITEM:case yt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case yt.FILTER_CHOICES:{var n=[];t.results.forEach(function(o){n[o.item.id]=o}),i.forEach(function(o){var a=n[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case yt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case yt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Pa={groups:vu,items:bu,choices:yu},_u=(function(){function r(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(r.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),r.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},r.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach(function(e){return e(t)})},r.prototype.subscribe=function(t){return this._listeners.push(t),this},r.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,n=this._changeSet||this.changeSet(!1);Object.keys(Pa).forEach(function(o){var a=Pa[o](i[o],t,e._context);a.update&&(s=!0,n[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=n:this._listeners.forEach(function(o){return o(n)}))},r.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach(function(i){return i(e)}))}}},Object.defineProperty(r.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,s=t.state.choices.some(function(n){return n.active&&!n.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),r.prototype.inTxn=function(){return this._txn>0},r.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},r.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},r})(),$t={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function xu(r,t,e){return(t=Cu(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Aa(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),e.push.apply(e,i)}return e}function Gi(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Aa(Object(e),!0).forEach(function(i){xu(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Aa(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function wu(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var i=e.call(r,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Cu(r){var t=wu(r,"string");return typeof t=="symbol"?t:t+""}function Ze(r){return Array.isArray?Array.isArray(r):Jl(r)==="[object Array]"}function Su(r){if(typeof r=="string")return r;let t=r+"";return t=="0"&&1/r==-1/0?"-0":t}function Tu(r){return r==null?"":Su(r)}function Fe(r){return typeof r=="string"}function ql(r){return typeof r=="number"}function Eu(r){return r===!0||r===!1||Ou(r)&&Jl(r)=="[object Boolean]"}function Zl(r){return typeof r=="object"}function Ou(r){return Zl(r)&&r!==null}function he(r){return r!=null}function kn(r){return!r.trim().length}function Jl(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}const ku="Incorrect 'index' type",Pu=r=>`Invalid value for key ${r}`,Au=r=>`Pattern length exceeds max of ${r}.`,Du=r=>`Missing ${r} property in key`,Mu=r=>`Property 'weight' in key '${r}' must be a positive integer`,Da=Object.prototype.hasOwnProperty;class Iu{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Ql(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ql(r){let t=null,e=null,i=null,s=1,n=null;if(Fe(r)||Ze(r))i=r,t=Ma(r),e=qn(r);else{if(!Da.call(r,"name"))throw new Error(Du("name"));const o=r.name;if(i=o,Da.call(r,"weight")&&(s=r.weight,s<=0))throw new Error(Mu(o));t=Ma(o),e=qn(o),n=r.getFn}return{path:t,id:e,weight:s,src:i,getFn:n}}function Ma(r){return Ze(r)?r:r.split(".")}function qn(r){return Ze(r)?r.join("."):r}function Lu(r,t){let e=[],i=!1;const s=(n,o,a)=>{if(he(n))if(!o[a])e.push(n);else{let l=o[a];const c=n[l];if(!he(c))return;if(a===o.length-1&&(Fe(c)||ql(c)||Eu(c)))e.push(Tu(c));else if(Ze(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(r,Fe(t)?t.split("."):t,0),i?e:e[0]}const Fu={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ju={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(r,t)=>r.score===t.score?r.idx<t.idx?-1:1:r.score<t.score?-1:1},$u={location:0,threshold:.6,distance:100},Ru={useExtendedSearch:!1,getFn:Lu,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var $=Gi(Gi(Gi(Gi({},ju),Fu),$u),Ru);const Bu=/[^ ]+/g;function zu(r=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const n=s.match(Bu).length;if(e.has(n))return e.get(n);const o=1/Math.pow(n,.5*r),a=parseFloat(Math.round(o*i)/i);return e.set(n,a),a},clear(){e.clear()}}}class Po{constructor({getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){this.norm=zu(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Fe(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();Fe(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!he(t)||kn(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach((s,n)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(he(o)){if(Ze(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(he(h))if(Fe(h)&&!kn(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else Ze(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[n]=a}else if(Fe(o)&&!kn(o)){let a={v:o,n:this.norm.get(o)};i.$[n]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function tc(r,t,{getFn:e=$.getFn,fieldNormWeight:i=$.fieldNormWeight}={}){const s=new Po({getFn:e,fieldNormWeight:i});return s.setKeys(r.map(Ql)),s.setSources(t),s.create(),s}function Hu(r,{getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){const{keys:i,records:s}=r,n=new Po({getFn:t,fieldNormWeight:e});return n.setKeys(i),n.setIndexRecords(s),n}function sr(r,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=$.distance,ignoreLocation:n=$.ignoreLocation}={}){const o=t/r.length;if(n)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function Vu(r=[],t=$.minMatchCharLength){let e=[],i=-1,s=-1,n=0;for(let o=r.length;n<o;n+=1){let a=r[n];a&&i===-1?i=n:!a&&i!==-1&&(s=n-1,s-i+1>=t&&e.push([i,s]),i=-1)}return r[n-1]&&n-i>=t&&e.push([i,n-1]),e}const Ti=32;function Nu(r,t,e,{location:i=$.location,distance:s=$.distance,threshold:n=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,includeMatches:l=$.includeMatches,ignoreLocation:c=$.ignoreLocation}={}){if(t.length>Ti)throw new Error(Au(Ti));const h=t.length,d=r.length,u=Math.max(0,Math.min(i,d));let p=n,g=u;const f=a>1||l,b=f?Array(d):[];let m;for(;(m=r.indexOf(t,g))>-1;){let k=sr(t,{currentLocation:m,expectedLocation:u,distance:s,ignoreLocation:c});if(p=Math.min(k,p),g=m+h,f){let E=0;for(;E<h;)b[m+E]=1,E+=1}}g=-1;let y=[],w=1,S=h+d;const T=1<<h-1;for(let k=0;k<h;k+=1){let E=0,P=S;for(;E<P;)sr(t,{errors:k,currentLocation:u+P,expectedLocation:u,distance:s,ignoreLocation:c})<=p?E=P:S=P,P=Math.floor((S-E)/2+E);S=P;let R=Math.max(1,u-P+1),L=o?d:Math.min(u+P,d)+h,F=Array(L+2);F[L+1]=(1<<k)-1;for(let M=L;M>=R;M-=1){let U=M-1,X=e[r.charAt(U)];if(f&&(b[U]=+!!X),F[M]=(F[M+1]<<1|1)&X,k&&(F[M]|=(y[M+1]|y[M])<<1|1|y[M+1]),F[M]&T&&(w=sr(t,{errors:k,currentLocation:U,expectedLocation:u,distance:s,ignoreLocation:c}),w<=p)){if(p=w,g=U,g<=u)break;R=Math.max(1,2*u-g)}}if(sr(t,{errors:k+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>p)break;y=F}const O={isMatch:g>=0,score:Math.max(.001,w)};if(f){const k=Vu(b,a);k.length?l&&(O.indices=k):O.isMatch=!1}return O}function Uu(r){let t={};for(let e=0,i=r.length;e<i;e+=1){const s=r.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class ec{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,p)=>{this.chunks.push({pattern:u,alphabet:Uu(u),startIndex:p})},d=this.pattern.length;if(d>Ti){let u=0;const p=d%Ti,g=d-p;for(;u<g;)h(this.pattern.substr(u,Ti),u),u+=Ti;if(p){const f=d-Ti;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return i&&(g.indices=[[0,t.length-1]]),g}const{location:s,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:b})=>{const{isMatch:m,score:y,indices:w}=Nu(t,g,f,{location:s+b,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});m&&(u=!0),d+=y,m&&w&&(h=[...h,...w])});let p={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(p.indices=h),p}}class vi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ia(t,this.multiRegex)}static isSingleMatch(t){return Ia(t,this.singleRegex)}search(){}}function Ia(r,t){const e=r.match(t);return e?e[1]:null}class Wu extends vi{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Yu extends vi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class Gu extends vi{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Xu extends vi{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class Ku extends vi{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class qu extends vi{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ic extends vi{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){super(t),this._bitapSearch=new ec(t,{location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class sc extends vi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],n=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+n,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const Zn=[Wu,sc,Gu,Xu,qu,Ku,Yu,ic],La=Zn.length,Zu=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ju="|";function Qu(r,t={}){return r.split(Ju).map(e=>{let i=e.trim().split(Zu).filter(n=>n&&!!n.trim()),s=[];for(let n=0,o=i.length;n<o;n+=1){const a=i[n];let l=!1,c=-1;for(;!l&&++c<La;){const h=Zn[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<La;){const h=Zn[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const tp=new Set([ic.type,sc.type]);class ep{constructor(t,{isCaseSensitive:e=$.isCaseSensitive,includeMatches:i=$.includeMatches,minMatchCharLength:s=$.minMatchCharLength,ignoreLocation:n=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:a=$.location,threshold:l=$.threshold,distance:c=$.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:n,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=Qu(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let n=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,n=0;for(let d=0,u=h.length;d<u;d+=1){const p=h[d],{isMatch:g,indices:f,score:b}=p.search(t);if(g){if(n+=1,a+=b,i){const m=p.constructor.type;tp.has(m)?o=[...o,...f]:o.push(f)}}else{a=0,n=0,o.length=0;break}}if(n){let d={isMatch:!0,score:a/n};return i&&(d.indices=o),d}}return{isMatch:!1,score:1}}}const Jn=[];function ip(...r){Jn.push(...r)}function Qn(r,t){for(let e=0,i=Jn.length;e<i;e+=1){let s=Jn[e];if(s.condition(r,t))return new s(r,t)}return new ec(r,t)}const $r={AND:"$and",OR:"$or"},to={PATH:"$path",PATTERN:"$val"},eo=r=>!!(r[$r.AND]||r[$r.OR]),sp=r=>!!r[to.PATH],rp=r=>!Ze(r)&&Zl(r)&&!eo(r),Fa=r=>({[$r.AND]:Object.keys(r).map(t=>({[t]:r[t]}))});function rc(r,t,{auto:e=!0}={}){const i=s=>{let n=Object.keys(s);const o=sp(s);if(!o&&n.length>1&&!eo(s))return i(Fa(s));if(rp(s)){const l=o?s[to.PATH]:n[0],c=o?s[to.PATTERN]:s[l];if(!Fe(c))throw new Error(Pu(l));const h={keyId:qn(l),pattern:c};return e&&(h.searcher=Qn(c,t)),h}let a={children:[],operator:n[0]};return n.forEach(l=>{const c=s[l];Ze(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return eo(r)||(r=Fa(r)),i(r)}function np(r,{ignoreFieldNorm:t=$.ignoreFieldNorm}){r.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:n,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:n))}),e.score=i})}function op(r,t){const e=r.matches;t.matches=[],he(e)&&e.forEach(i=>{if(!he(i.indices)||!i.indices.length)return;const{indices:s,value:n}=i;let o={indices:s,value:n};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function ap(r,t){t.score=r.score}function lp(r,t,{includeMatches:e=$.includeMatches,includeScore:i=$.includeScore}={}){const s=[];return e&&s.push(op),i&&s.push(ap),r.map(n=>{const{idx:o}=n,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(n,a)}),a})}class is{constructor(t,e={},i){this.options=Gi(Gi({},$),e),this.options.useExtendedSearch,this._keyStore=new Iu(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Po))throw new Error(ku);this._myIndex=e||tc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){he(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const n=this._docs[i];t(n,i)&&(this.removeAt(i),i-=1,s-=1,e.push(n))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:n,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Fe(t)?Fe(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return np(l,{ignoreFieldNorm:a}),n&&l.sort(o),ql(e)&&e>-1&&(l=l.slice(0,e)),lp(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=Qn(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=e.searchIn(n);l&&s.push({item:n,idx:o,matches:[{score:c,value:n,norm:a,indices:h}]})}),s}_searchLogical(t){const e=rc(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const p=a.children[d],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===$r.AND)return[]}return h},s=this._myIndex.records,n={},o=[];return s.forEach(({$:a,i:l})=>{if(he(a)){let c=i(e,a,l);c.length&&(n[l]||(n[l]={idx:l,item:a,matches:[]},o.push(n[l])),c.forEach(({matches:h})=>{n[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=Qn(t,this.options),{keys:i,records:s}=this._myIndex,n=[];return s.forEach(({$:o,i:a})=>{if(!he(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&n.push({idx:a,item:o,matches:l})}),n}_findMatches({key:t,value:e,searcher:i}){if(!he(e))return[];let s=[];if(Ze(e))e.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=i.searchIn(n);l&&s.push({score:c,key:t,value:n,idx:o,norm:a,indices:h})});else{const{v:n,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(n);a&&s.push({score:l,key:t,value:n,norm:o,indices:c})}return s}}is.version="7.0.0";is.createIndex=tc;is.parseIndex=Hu;is.config=$;is.parseQuery=rc;ip(ep);var cp=(function(){function r(t){this._haystack=[],this._fuseOptions=Jt(Jt({},t.fuseOptions),{keys:Wd([],t.searchFields),includeMatches:!0})}return r.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},r.prototype.reset=function(){this._haystack=[],this._fuse=void 0},r.prototype.isEmptyIndex=function(){return!this._haystack.length},r.prototype.search=function(t){this._fuse||(this._fuse=new is(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},r})();function hp(r){return new cp(r)}var dp=function(r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0},Pn=function(r,t,e){var i=r.dataset,s=t.customProperties,n=t.labelClass,o=t.labelDescription;n&&(i.labelClass=nn(n).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!dp(s)&&(i.customProperties=JSON.stringify(s)))},ja=function(r,t,e){var i=t&&r.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},up={containerOuter:function(r,t,e,i,s,n,o){var a=r.classNames.containerOuter,l=document.createElement("div");return B(l,a),l.dataset.type=n,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||ja(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(r){var t=r.classNames.containerInner,e=document.createElement("div");return B(e,t),e},itemList:function(r,t){var e=r.searchEnabled,i=r.classNames,s=i.list,n=i.listSingle,o=i.listItems,a=document.createElement("div");return B(a,s),B(a,t?n:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(r,t){var e=r.allowHTML,i=r.classNames.placeholder,s=document.createElement("div");return B(s,i),Ne(s,e,t),s},item:function(r,t,e){var i=r.allowHTML,s=r.removeItemButtonAlignLeft,n=r.removeItemIconText,o=r.removeItemLabelText,a=r.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=Ai(t.value),g=document.createElement("div");if(B(g,l),t.labelClass){var f=document.createElement("span");Ne(f,i,t.label),B(f,t.labelClass),g.appendChild(f)}else Ne(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,Pn(g,t,!0),(t.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),t.placeholder&&(B(g,u),g.dataset.placeholder=""),B(g,t.highlighted?h:d),e){t.disabled&&Ie(g,d),g.dataset.deletable="";var b=document.createElement("button");b.type="button",B(b,c),Ne(b,!0,As(n,t.value));var m=As(o,t.value);m&&b.setAttribute("aria-label",m),b.dataset.button="",s?g.insertAdjacentElement("afterbegin",b):g.appendChild(b)}return g},choiceList:function(r,t){var e=r.classNames.list,i=document.createElement("div");return B(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(r,t){var e=r.allowHTML,i=r.classNames,s=i.group,n=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Ai(l),d=document.createElement("div");B(d,s),c&&B(d,o),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return B(u,n),Ne(u,e,l||""),d.appendChild(u),d},choice:function(r,t,e,i){var s=r.allowHTML,n=r.classNames,o=n.item,a=n.itemChoice,l=n.itemSelectable,c=n.selectedState,h=n.itemDisabled,d=n.description,u=n.placeholder,p=t.label,g=Ai(t.value),f=document.createElement("div");f.id=t.elementId,B(f,o),B(f,a),i&&typeof p=="string"&&(p=ko(s,p),p+=" (".concat(i,")"),p={trusted:p});var b=f;if(t.labelClass){var m=document.createElement("span");Ne(m,s,p),B(m,t.labelClass),b=m,f.appendChild(m)}else Ne(f,s,p);if(t.labelDescription){var y="".concat(t.elementId,"-description");b.setAttribute("aria-describedby",y);var w=document.createElement("span");Ne(w,s,t.labelDescription),w.id=y,B(w,d),f.appendChild(w)}return t.selected&&B(f,c),t.placeholder&&B(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=g,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),Pn(f,t,!1),t.disabled?(B(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(B(f,l),f.dataset.choiceSelectable=""),f},input:function(r,t){var e=r.classNames,i=e.input,s=e.inputCloned,n=r.labelId,o=document.createElement("input");return o.type="search",B(o,i),B(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):n||ja(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(r){var t=r.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return B(s,e),B(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(r,t,e){var i=r.classNames,s=i.item,n=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=$t.generic);var h=document.createElement("div");switch(Ne(h,!0,t),B(h,s),B(h,n),B(h,c),e){case $t.addChoice:B(h,o);break;case $t.noResults:B(h,a);break;case $t.noChoices:B(h,l);break}return e===$t.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(r){var t=Ai(r.label),e=new Option(t,r.value,!1,r.selected);return Pn(e,r,!0),e.disabled=r.disabled,r.selected&&e.setAttribute("selected",""),e}},pp="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,gp={},An=function(r){if(r)return r.dataset.id?parseInt(r.dataset.id,10):void 0},bs="[data-choice-selectable]",nc=(function(){function r(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=r.defaults;this.config=Jt(Jt(Jt({},s.allOptions),s.options),e),Yd.forEach(function(m){i.config[m]=Jt(Jt(Jt({},s.allOptions[m]),s.options[m]),e[m])});var n=this.config;n.silent||this._validateConfig();var o=n.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(uu(a)||Kl(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===di.Text;(c||n.maxItemCount!==1)&&(n.singleModeForMultiSelect=!1),n.singleModeForMultiSelect&&(l=di.SelectMultiple);var h=l===di.SelectOne,d=l===di.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&n.addItems||u&&n.addChoices,typeof n.renderSelectedChoices!="boolean"&&(n.renderSelectedChoices=n.renderSelectedChoices==="always"||h),n.closeDropdownOnSelect==="auto"?n.closeDropdownOnSelect=c||h||n.singleModeForMultiSelect:n.closeDropdownOnSelect=Ss(n.closeDropdownOnSelect),n.placeholder&&(n.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,n.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);n.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new du({element:a,classNames:n.classNames});else{var g=a;this.passedElement=new fu({element:g,classNames:n.classNames,template:function(m){return i._templates.option(m)},extractPlaceholder:n.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new _u(n),this._currentValue="",n.searchEnabled=!c&&n.searchEnabled||d,this._canSearch=n.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Jd(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,b=window.getComputedStyle(document.documentElement).direction;f!==b&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){n.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(m){return m.value})}return Object.defineProperty(r,"defaults",{get:function(){return Object.preventExtensions({get options(){return gp},get allOptions(){return Oa},get templates(){return up}})},enumerable:!1,configurable:!0}),r.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=hp(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},r.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=r.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},r.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},r.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},r.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(ir(i,!0)),e&&this.passedElement.triggerEvent(Zt.highlightItem,this._getChoiceForOutput(i)),this)},r.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(ir(i,!1)),e&&this.passedElement.triggerEvent(Zt.unhighlightItem,this._getChoiceForOutput(i)),this)},r.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(ir(e,!0)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(ir(e,!1)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},r.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(t=!this._canSearch),requestAnimationFrame(function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(Zt.showDropdown)}),this)},r.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame(function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(Zt.hideDropdown)}),this):this},r.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},r.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Me(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},r.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},r.prototype.setChoices=function(t,e,i,s,n,o){var a=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),n===void 0&&(n=!0),o===void 0&&(o=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(typeof t=="function"){var l=t(this);if(typeof Promise=="function"&&l instanceof Promise)return new Promise(function(c){return requestAnimationFrame(c)}).then(function(){return a._handleLoadingState(!0)}).then(function(){return l}).then(function(c){return a.setChoices(c,e,i,s,n,o)}).catch(function(c){a.config.silent||console.error(c)}).then(function(){return a._handleLoadingState(!1)}).then(function(){return a});if(!Array.isArray(l))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof l));return this.setChoices(l,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn(function(){n&&(a._isSearching=!1),s&&a.clearChoices(!0,o);var c=e==="value",h=i==="label";t.forEach(function(d){if("choices"in d){var u=d;h||(u=Jt(Jt({},u),{label:u[i]})),a._addGroup(Me(u,!0))}else{var p=d;(!h||!c)&&(p=Jt(Jt({},p),{value:p[e],label:p[i]}));var g=Me(p,!1);a._addChoice(g),g.placeholder&&!a._hasNonChoicePlaceholder&&(a._placeholderValue=Yl(g.label))}}),a.unhighlightAll()}),this._searcher.reset(),this},r.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var n=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(wa(l)):o[l.value]&&(l.selected=!0)};n.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(n,e,t),s._isSearching&&s._searchChoices(s.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},r.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(Gd(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(e)),this):this},r.prototype.clearChoices=function(t,e){var i=this;return t===void 0&&(t=!0),e===void 0&&(e=!1),t&&(e?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach(function(s){s.remove()})),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn(function(){var s=e?[]:i._store.items;i._store.reset(),s.forEach(function(n){i._store.dispatch(_a(n)),i._store.dispatch(xa(n))})}),this._searcher.reset(),this},r.prototype.clearStore=function(t){return t===void 0&&(t=!0),this.clearChoices(t,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},r.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},r.prototype._validateConfig=function(){var t=this.config,e=nu(t,Oa);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},r.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},r.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,n=this._store,o=n.activeGroups,a=n.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(g){return!g.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(g){return g.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,p=function(g,f,b){s?g.sort(su):i.shouldSort&&g.sort(i.sorter);var m=g.length;m=!f&&l&&m>l?l:m,m--,g.every(function(y,w){var S=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,b);return y.choiceEl=S,h.appendChild(S),(s||!y.selected)&&(u=!0),w<m})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&p(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(g){return!g.placeholder&&!g.group}),!1,void 0),o.forEach(function(g){var f=d(g.choices);if(f.length){if(g.label){var b=g.groupEl||t._templates.choiceGroup(t.config,g);g.groupEl=b,b.remove(),h.appendChild(b)}p(f,!0,i.appendGroupInSearch&&s?g.label:void 0)}})):p(d(a),!1,void 0)),!u&&(s||!h.children.length||!i.renderSelectedChoices)&&(this._notice||(this._notice={text:Sa(s?i.noResultsText:i.noChoicesText),type:s?$t.noResults:$t.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},r.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,n=document.createDocumentFragment(),o=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=o(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,n.appendChild(u))};e.forEach(a);var l=!!n.childNodes.length;if(this._isSelectOneElement){var c=i.children.length;if(l||c>1){var h=i.querySelector(ms(s.classNames.placeholder));h&&h.remove()}else!l&&!c&&this._placeholderValue&&(l=!0,a(Me({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}l&&(i.append(n),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=o(d);u&&(u.remove(),n.append(u))}),i.append(n))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},r.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===$t.addChoice&&(e===$t.noResults||e===$t.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},r.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(ms(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},r.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},r.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},r.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Zt.change,{value:t})},r.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&An(t.parentElement),n=s&&i.find(function(o){return o.id===s});n&&this._store.withTxn(function(){if(e._removeItem(n),e._triggerChange(n.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=(e.config.shouldSort?e._store.choices.reverse():e._store.choices).find(function(a){return a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},r.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var n=An(t);n&&(s.forEach(function(o){o.id===n&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},r.prototype._handleChoiceAction=function(t){var e=this,i=An(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var n=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(s.value)}return n&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},r.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(n){return n.highlighted});e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},r.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Me(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return Me(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Me(o,!0)});var n=this.passedElement.optionsAsChoices();n&&(t=this._presetChoices).push.apply(t,n)}},r.prototype._handleLoadingState=function(t){t===void 0&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},r.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Zt.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},r.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice(typeof i=="function"?i(e):i,$t.addChoice),!1):(this._notice&&this._notice.type===$t.addChoice&&this._clearNotice(),!0)},r.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=As(e.customAddItemText,t)),i){var n=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(n){if(this._isSelectElement)return this._displayNotice("",$t.addChoice),!1;e.duplicateItemsAllowed||(i=!1,s=As(e.uniqueItemText,t))}}return i&&(s=As(e.addItemText,t)),s&&this._displayNotice(s,$t.addChoice),i},r.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var n=this._notice,o=n&&n.type;return o!==$t.addChoice&&(s.length?this._clearNotice():this._displayNotice(Sa(this.config.noResultsText),$t.noResults)),this._store.dispatch(Xd(s)),s.length},r.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Kd(!0)),this.passedElement.triggerEvent(Zt.search,{value:"",resultCount:0}))},r.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},r.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},r.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Ht.ESC_KEY&&e!==Ht.TAB_KEY&&e!==Ht.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Ht.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Ht.ENTER_KEY:return this._onEnterKey(t,i);case Ht.ESC_KEY:return this._onEscapeKey(t,i);case Ht.UP_KEY:case Ht.PAGE_UP_KEY:case Ht.DOWN_KEY:case Ht.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Ht.DELETE_KEY:case Ht.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},r.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},r.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},r.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},r.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,n=t.target;if(t.preventDefault(),n&&n.hasAttribute("data-button")){this._handleButtonAction(n);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!n||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(Me(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},r.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},r.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===Ht.DOWN_KEY||i===Ht.PAGE_DOWN_KEY?1:-1,n=t.metaKey||i===Ht.PAGE_DOWN_KEY||i===Ht.PAGE_UP_KEY,o=void 0;if(n)s>0?o=this.dropdown.element.querySelector("".concat(bs,":last-of-type")):o=this.dropdown.element.querySelector(bs);else{var a=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));a?o=Qd(a,bs,s):o=this.dropdown.element.querySelector(bs)}o&&(tu(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},r.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},r.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},r.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},r.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(pp&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},r.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},r.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},r.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var n=e===this.input.element;this._isTextElement?n&&i.addFocusState():this._isSelectMultipleElement?n&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),n&&this.showDropdown(!0))}},r.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&(i.removeFocusState(),this._canSearch||this.hideDropdown(!0)):(this._isScrollingOnIe=!1,this.input.element.focus())},r.prototype._onFormReset=function(){var t=this;this._store.withTxn(function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)})},r.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(bs));if(e.length){var i=t,s=this.config.classNames.highlightedState,n=Array.from(this.dropdown.element.querySelectorAll(ms(s)));n.forEach(function(o){Ie(o,s),o.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),B(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Zt.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},r.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(xa(t)),e&&(this.passedElement.triggerEvent(Zt.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Zt.choice,this._getChoiceForOutput(t)))},r.prototype._removeItem=function(t){if(t.id){this._store.dispatch(wa(t));var e=this._notice;e&&e.type===$t.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(t))}},r.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!(!s.duplicateItemsAllowed&&this._store.choices.find(function(a){return s.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var n=s.prependValue,o=s.appendValue;n&&(t.value=n+t.value),o&&(t.value+=o.toString()),(n||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(_a(t)),t.selected&&this._addItem(t,e,i)}},r.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(qd(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)}))},r.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,eu,ko,nn));var s={};Object.keys(this._templates).forEach(function(n){n in i?s[n]=i[n].bind(t):s[n]=t._templates[n].bind(t)}),this._templates=s},r.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,n=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Ta({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:n}),this.containerInner=new Ta({element:t.containerInner(i),classNames:o,type:a,position:n}),this.input=new cu({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Ea({element:t.choiceList(i,s)}),this.itemList=new Ea({element:t.itemList(i,s)}),this.dropdown=new lu({element:t.dropdown(i),classNames:o,type:a})},r.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,n=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(n),e.element.appendChild(this.itemList.element),n.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&n.insertBefore(this.input.element,n.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},r.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn(function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)}),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},r.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var n=t.findIndex(function(o){return o.selected})===-1;n&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?s._isSelectElement&&s._addGroup(o,i):s._addChoice(o,i)})},r.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(n){return i.config.valueComparer(n.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},r.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},r.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},r.version="11.1.0",r})();const oc='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media(min-width:640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}',Ks=ft`
1451
+ `;/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Kn=function(r,t){return Kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Kn(r,t)};function Wl(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Kn(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Jt=function(){return Jt=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},Jt.apply(this,arguments)};function Wd(r,t,e){for(var i=0,s=t.length,n;i<s;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return r.concat(n||Array.prototype.slice.call(t))}var yt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Zt={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Ht={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},Yd=["fuseOptions","classNames"],di={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},_a=function(r){return{type:yt.ADD_CHOICE,choice:r}},Gd=function(r){return{type:yt.REMOVE_CHOICE,choice:r}},Xd=function(r){return{type:yt.FILTER_CHOICES,results:r}},Kd=function(r){return{type:yt.ACTIVATE_CHOICES,active:r}},qd=function(r){return{type:yt.ADD_GROUP,group:r}},xa=function(r){return{type:yt.ADD_ITEM,item:r}},wa=function(r){return{type:yt.REMOVE_ITEM,item:r}},ir=function(r,t){return{type:yt.HIGHLIGHT_ITEM,item:r,highlighted:t}},Zd=function(r,t){return Math.floor(Math.random()*(t-r)+r)},Ca=function(r){return Array.from({length:r},function(){return Zd(0,36).toString(36)}).join("")},Jd=function(r,t){var e=r.id||r.name&&"".concat(r.name,"-").concat(Ca(2))||Ca(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Qd=function(r,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=r[i];s;){if(s.matches(t))return s;s=s[i]}return null},tu=function(r,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=r.offsetTop+r.offsetHeight:i=r.offsetTop>=t.scrollTop,i},rn=function(r){if(typeof r!="string"){if(r==null)return"";if(typeof r=="object"){if("raw"in r)return rn(r.raw);if("trusted"in r)return r.trusted}return r}return r.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},eu=(function(){var r=document.createElement("div");return function(t){r.innerHTML=t.trim();for(var e=r.children[0];r.firstChild;)r.removeChild(r.firstChild);return e}})(),As=function(r,t){return typeof r=="function"?r(rn(t),t):r},Sa=function(r){return typeof r=="function"?r():r},Ai=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("trusted"in r)return r.trusted;if("raw"in r)return r.raw}return""},Yl=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("escaped"in r)return r.escaped;if("trusted"in r)return r.trusted}return""},ko=function(r,t){return r?Yl(t):rn(t)},Ne=function(r,t,e){r.innerHTML=ko(t,e)},iu=function(r,t){var e=r.value,i=r.label,s=i===void 0?e:i,n=t.value,o=t.label,a=o===void 0?n:o;return Ai(s).localeCompare(Ai(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},su=function(r,t){return r.rank-t.rank},ru=function(r,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return r.dispatchEvent(i)},nu=function(r,t){var e=Object.keys(r).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},nn=function(r){return Array.isArray(r)?r:[r]},ms=function(r){return r&&Array.isArray(r)?r.map(function(t){return".".concat(t)}).join(""):".".concat(r)},B=function(r,t){var e;(e=r.classList).add.apply(e,nn(t))},Ie=function(r,t){var e;(e=r.classList).remove.apply(e,nn(t))},ou=function(r){if(typeof r<"u")try{return JSON.parse(r)}catch{return r}return{}},au=function(r,t,e){var i=r.itemEl;i&&(Ie(i,e),B(i,t))},lu=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return r.prototype.show=function(){return B(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},r.prototype.hide=function(){return Ie(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},r})(),Ta=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.position;this.element=e,this.classNames=s,this.type=i,this.position=n,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return r.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype.open=function(t,e){B(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(B(this.element,this.classNames.flippedState),this.isFlipped=!0)},r.prototype.close=function(){Ie(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Ie(this.element,this.classNames.flippedState),this.isFlipped=!1)},r.prototype.addFocusState=function(){B(this.element,this.classNames.focusState)},r.prototype.removeFocusState=function(){Ie(this.element,this.classNames.focusState)},r.prototype.enable=function(){Ie(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},r.prototype.disable=function(){B(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},r.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},r.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},r.prototype.addLoadingState=function(){B(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},r.prototype.removeLoadingState=function(){Ie(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},r})(),cu=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=n,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(r.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},r.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},r.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},r.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},r.prototype.focus=function(){this.isFocussed||this.element.focus()},r.prototype.blur=function(){this.isFocussed&&this.element.blur()},r.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},r.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype._onInput=function(){this.type!==di.SelectOne&&this.setWidth()},r.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},r.prototype._onFocus=function(){this.isFocussed=!0},r.prototype._onBlur=function(){this.isFocussed=!1},r})(),hu=4,Ea=(function(){function r(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return r.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},r.prototype.scrollToTop=function(){this.element.scrollTop=0},r.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,n=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-n:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},r.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,n=s>1?s:1;this.element.scrollTop=t+n},r.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,n=s>1?s:1;this.element.scrollTop=t-n},r.prototype._animateScroll=function(t,e){var i=this,s=hu,n=this.element.scrollTop,o=!1;e>0?(this._scrollDown(n,s,t),n<t&&(o=!0)):(this._scrollUp(n,s,t),n>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},r})(),Gl=(function(){function r(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(r.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.conceal=function(){var t=this.element;B(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},r.prototype.reveal=function(){var t=this.element;Ie(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},r.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},r.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},r.prototype.triggerEvent=function(t,e){ru(this.element,t,e||{})},r})(),du=(function(r){Wl(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(Gl),Ss=function(r,t){return t===void 0&&(t=!0),typeof r>"u"?t:!!r},Xl=function(r){if(typeof r=="string"&&(r=r.split(" ").filter(function(t){return t.length})),Array.isArray(r)&&r.length)return r},Me=function(r,t,e){if(e===void 0&&(e=!0),typeof r=="string"){var i=rn(r),s=e||i===r?r:{escaped:i,raw:r},n=Me({value:r,label:s,selected:!0},!1);return n}var o=r;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(u){return Me(u,!1)}),c={id:0,label:Ai(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ss(h.active),selected:Ss(h.selected,!1),disabled:Ss(h.disabled,!1),placeholder:Ss(h.placeholder,!1),highlighted:!1,labelClass:Xl(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},uu=function(r){return r.tagName==="INPUT"},Kl=function(r){return r.tagName==="SELECT"},pu=function(r){return r.tagName==="OPTION"},gu=function(r){return r.tagName==="OPTGROUP"},fu=(function(r){Wl(t,r);function t(e){var i=e.element,s=e.classNames,n=e.template,o=e.extractPlaceholder,a=r.call(this,{element:i,classNames:s})||this;return a.template=n,a.extractPlaceholder=o,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(n){var o=n;if(!o.element){var a=i.template(o);s.appendChild(a),o.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){pu(s)?i.push(e._optionToChoice(s)):gu(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Xl(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:ou(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),n=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},t})(Gl),mu={containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},Oa={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(r){return!!r&&r!==""},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:iu,shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(r){return'Press Enter to add <b>"'.concat(r,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(r){return"Remove item: ".concat(r)},maxItemText:function(r){return"Only ".concat(r," values can be added")},valueComparer:function(r,t){return r===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:mu,appendGroupInSearch:!1},ka=function(r){var t=r.itemEl;t&&(t.remove(),r.itemEl=void 0)};function bu(r,t,e){var i=r,s=!0;switch(t.type){case yt.ADD_ITEM:{t.item.selected=!0;var n=t.item.element;n&&(n.selected=!0,n.setAttribute("selected","")),i.push(t.item);break}case yt.REMOVE_ITEM:{t.item.selected=!1;var n=t.item.element;if(n){n.selected=!1,n.removeAttribute("selected");var o=n.parentElement;o&&Kl(o)&&o.type===di.SelectOne&&(o.value="")}ka(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case yt.REMOVE_CHOICE:{ka(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case yt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&au(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function vu(r,t){var e=r,i=!0;switch(t.type){case yt.ADD_GROUP:{e.push(t.group);break}case yt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function yu(r,t,e){var i=r,s=!0;switch(t.type){case yt.ADD_CHOICE:{i.push(t.choice);break}case yt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case yt.ADD_ITEM:case yt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case yt.FILTER_CHOICES:{var n=[];t.results.forEach(function(o){n[o.item.id]=o}),i.forEach(function(o){var a=n[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case yt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case yt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Pa={groups:vu,items:bu,choices:yu},_u=(function(){function r(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(r.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),r.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},r.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach(function(e){return e(t)})},r.prototype.subscribe=function(t){return this._listeners.push(t),this},r.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,n=this._changeSet||this.changeSet(!1);Object.keys(Pa).forEach(function(o){var a=Pa[o](i[o],t,e._context);a.update&&(s=!0,n[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=n:this._listeners.forEach(function(o){return o(n)}))},r.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach(function(i){return i(e)}))}}},Object.defineProperty(r.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,s=t.state.choices.some(function(n){return n.active&&!n.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),r.prototype.inTxn=function(){return this._txn>0},r.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},r.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},r})(),$t={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function xu(r,t,e){return(t=Cu(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Aa(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),e.push.apply(e,i)}return e}function Gi(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Aa(Object(e),!0).forEach(function(i){xu(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Aa(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function wu(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var i=e.call(r,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Cu(r){var t=wu(r,"string");return typeof t=="symbol"?t:t+""}function Ze(r){return Array.isArray?Array.isArray(r):Jl(r)==="[object Array]"}function Su(r){if(typeof r=="string")return r;let t=r+"";return t=="0"&&1/r==-1/0?"-0":t}function Tu(r){return r==null?"":Su(r)}function Fe(r){return typeof r=="string"}function ql(r){return typeof r=="number"}function Eu(r){return r===!0||r===!1||Ou(r)&&Jl(r)=="[object Boolean]"}function Zl(r){return typeof r=="object"}function Ou(r){return Zl(r)&&r!==null}function he(r){return r!=null}function kn(r){return!r.trim().length}function Jl(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}const ku="Incorrect 'index' type",Pu=r=>`Invalid value for key ${r}`,Au=r=>`Pattern length exceeds max of ${r}.`,Du=r=>`Missing ${r} property in key`,Mu=r=>`Property 'weight' in key '${r}' must be a positive integer`,Da=Object.prototype.hasOwnProperty;class Iu{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Ql(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ql(r){let t=null,e=null,i=null,s=1,n=null;if(Fe(r)||Ze(r))i=r,t=Ma(r),e=qn(r);else{if(!Da.call(r,"name"))throw new Error(Du("name"));const o=r.name;if(i=o,Da.call(r,"weight")&&(s=r.weight,s<=0))throw new Error(Mu(o));t=Ma(o),e=qn(o),n=r.getFn}return{path:t,id:e,weight:s,src:i,getFn:n}}function Ma(r){return Ze(r)?r:r.split(".")}function qn(r){return Ze(r)?r.join("."):r}function Lu(r,t){let e=[],i=!1;const s=(n,o,a)=>{if(he(n))if(!o[a])e.push(n);else{let l=o[a];const c=n[l];if(!he(c))return;if(a===o.length-1&&(Fe(c)||ql(c)||Eu(c)))e.push(Tu(c));else if(Ze(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(r,Fe(t)?t.split("."):t,0),i?e:e[0]}const Fu={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ju={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(r,t)=>r.score===t.score?r.idx<t.idx?-1:1:r.score<t.score?-1:1},$u={location:0,threshold:.6,distance:100},Ru={useExtendedSearch:!1,getFn:Lu,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var $=Gi(Gi(Gi(Gi({},ju),Fu),$u),Ru);const Bu=/[^ ]+/g;function zu(r=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const n=s.match(Bu).length;if(e.has(n))return e.get(n);const o=1/Math.pow(n,.5*r),a=parseFloat(Math.round(o*i)/i);return e.set(n,a),a},clear(){e.clear()}}}class Po{constructor({getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){this.norm=zu(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Fe(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();Fe(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!he(t)||kn(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach((s,n)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(he(o)){if(Ze(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(he(h))if(Fe(h)&&!kn(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else Ze(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[n]=a}else if(Fe(o)&&!kn(o)){let a={v:o,n:this.norm.get(o)};i.$[n]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function tc(r,t,{getFn:e=$.getFn,fieldNormWeight:i=$.fieldNormWeight}={}){const s=new Po({getFn:e,fieldNormWeight:i});return s.setKeys(r.map(Ql)),s.setSources(t),s.create(),s}function Hu(r,{getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){const{keys:i,records:s}=r,n=new Po({getFn:t,fieldNormWeight:e});return n.setKeys(i),n.setIndexRecords(s),n}function sr(r,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=$.distance,ignoreLocation:n=$.ignoreLocation}={}){const o=t/r.length;if(n)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function Vu(r=[],t=$.minMatchCharLength){let e=[],i=-1,s=-1,n=0;for(let o=r.length;n<o;n+=1){let a=r[n];a&&i===-1?i=n:!a&&i!==-1&&(s=n-1,s-i+1>=t&&e.push([i,s]),i=-1)}return r[n-1]&&n-i>=t&&e.push([i,n-1]),e}const Ti=32;function Nu(r,t,e,{location:i=$.location,distance:s=$.distance,threshold:n=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,includeMatches:l=$.includeMatches,ignoreLocation:c=$.ignoreLocation}={}){if(t.length>Ti)throw new Error(Au(Ti));const h=t.length,d=r.length,u=Math.max(0,Math.min(i,d));let p=n,g=u;const f=a>1||l,m=f?Array(d):[];let b;for(;(b=r.indexOf(t,g))>-1;){let O=sr(t,{currentLocation:b,expectedLocation:u,distance:s,ignoreLocation:c});if(p=Math.min(O,p),g=b+h,f){let E=0;for(;E<h;)m[b+E]=1,E+=1}}g=-1;let _=[],w=1,S=h+d;const T=1<<h-1;for(let O=0;O<h;O+=1){let E=0,P=S;for(;E<P;)sr(t,{errors:O,currentLocation:u+P,expectedLocation:u,distance:s,ignoreLocation:c})<=p?E=P:S=P,P=Math.floor((S-E)/2+E);S=P;let R=Math.max(1,u-P+1),L=o?d:Math.min(u+P,d)+h,F=Array(L+2);F[L+1]=(1<<O)-1;for(let M=L;M>=R;M-=1){let U=M-1,X=e[r.charAt(U)];if(f&&(m[U]=+!!X),F[M]=(F[M+1]<<1|1)&X,O&&(F[M]|=(_[M+1]|_[M])<<1|1|_[M+1]),F[M]&T&&(w=sr(t,{errors:O,currentLocation:U,expectedLocation:u,distance:s,ignoreLocation:c}),w<=p)){if(p=w,g=U,g<=u)break;R=Math.max(1,2*u-g)}}if(sr(t,{errors:O+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>p)break;_=F}const k={isMatch:g>=0,score:Math.max(.001,w)};if(f){const O=Vu(m,a);O.length?l&&(k.indices=O):k.isMatch=!1}return k}function Uu(r){let t={};for(let e=0,i=r.length;e<i;e+=1){const s=r.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class ec{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,p)=>{this.chunks.push({pattern:u,alphabet:Uu(u),startIndex:p})},d=this.pattern.length;if(d>Ti){let u=0;const p=d%Ti,g=d-p;for(;u<g;)h(this.pattern.substr(u,Ti),u),u+=Ti;if(p){const f=d-Ti;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return i&&(g.indices=[[0,t.length-1]]),g}const{location:s,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:m})=>{const{isMatch:b,score:_,indices:w}=Nu(t,g,f,{location:s+m,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});b&&(u=!0),d+=_,b&&w&&(h=[...h,...w])});let p={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(p.indices=h),p}}class vi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ia(t,this.multiRegex)}static isSingleMatch(t){return Ia(t,this.singleRegex)}search(){}}function Ia(r,t){const e=r.match(t);return e?e[1]:null}class Wu extends vi{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Yu extends vi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class Gu extends vi{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Xu extends vi{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class Ku extends vi{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class qu extends vi{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ic extends vi{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){super(t),this._bitapSearch=new ec(t,{location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class sc extends vi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],n=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+n,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const Zn=[Wu,sc,Gu,Xu,qu,Ku,Yu,ic],La=Zn.length,Zu=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ju="|";function Qu(r,t={}){return r.split(Ju).map(e=>{let i=e.trim().split(Zu).filter(n=>n&&!!n.trim()),s=[];for(let n=0,o=i.length;n<o;n+=1){const a=i[n];let l=!1,c=-1;for(;!l&&++c<La;){const h=Zn[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<La;){const h=Zn[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const tp=new Set([ic.type,sc.type]);class ep{constructor(t,{isCaseSensitive:e=$.isCaseSensitive,includeMatches:i=$.includeMatches,minMatchCharLength:s=$.minMatchCharLength,ignoreLocation:n=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:a=$.location,threshold:l=$.threshold,distance:c=$.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:n,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=Qu(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let n=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,n=0;for(let d=0,u=h.length;d<u;d+=1){const p=h[d],{isMatch:g,indices:f,score:m}=p.search(t);if(g){if(n+=1,a+=m,i){const b=p.constructor.type;tp.has(b)?o=[...o,...f]:o.push(f)}}else{a=0,n=0,o.length=0;break}}if(n){let d={isMatch:!0,score:a/n};return i&&(d.indices=o),d}}return{isMatch:!1,score:1}}}const Jn=[];function ip(...r){Jn.push(...r)}function Qn(r,t){for(let e=0,i=Jn.length;e<i;e+=1){let s=Jn[e];if(s.condition(r,t))return new s(r,t)}return new ec(r,t)}const $r={AND:"$and",OR:"$or"},to={PATH:"$path",PATTERN:"$val"},eo=r=>!!(r[$r.AND]||r[$r.OR]),sp=r=>!!r[to.PATH],rp=r=>!Ze(r)&&Zl(r)&&!eo(r),Fa=r=>({[$r.AND]:Object.keys(r).map(t=>({[t]:r[t]}))});function rc(r,t,{auto:e=!0}={}){const i=s=>{let n=Object.keys(s);const o=sp(s);if(!o&&n.length>1&&!eo(s))return i(Fa(s));if(rp(s)){const l=o?s[to.PATH]:n[0],c=o?s[to.PATTERN]:s[l];if(!Fe(c))throw new Error(Pu(l));const h={keyId:qn(l),pattern:c};return e&&(h.searcher=Qn(c,t)),h}let a={children:[],operator:n[0]};return n.forEach(l=>{const c=s[l];Ze(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return eo(r)||(r=Fa(r)),i(r)}function np(r,{ignoreFieldNorm:t=$.ignoreFieldNorm}){r.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:n,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:n))}),e.score=i})}function op(r,t){const e=r.matches;t.matches=[],he(e)&&e.forEach(i=>{if(!he(i.indices)||!i.indices.length)return;const{indices:s,value:n}=i;let o={indices:s,value:n};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function ap(r,t){t.score=r.score}function lp(r,t,{includeMatches:e=$.includeMatches,includeScore:i=$.includeScore}={}){const s=[];return e&&s.push(op),i&&s.push(ap),r.map(n=>{const{idx:o}=n,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(n,a)}),a})}class is{constructor(t,e={},i){this.options=Gi(Gi({},$),e),this.options.useExtendedSearch,this._keyStore=new Iu(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Po))throw new Error(ku);this._myIndex=e||tc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){he(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const n=this._docs[i];t(n,i)&&(this.removeAt(i),i-=1,s-=1,e.push(n))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:n,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Fe(t)?Fe(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return np(l,{ignoreFieldNorm:a}),n&&l.sort(o),ql(e)&&e>-1&&(l=l.slice(0,e)),lp(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=Qn(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=e.searchIn(n);l&&s.push({item:n,idx:o,matches:[{score:c,value:n,norm:a,indices:h}]})}),s}_searchLogical(t){const e=rc(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const p=a.children[d],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===$r.AND)return[]}return h},s=this._myIndex.records,n={},o=[];return s.forEach(({$:a,i:l})=>{if(he(a)){let c=i(e,a,l);c.length&&(n[l]||(n[l]={idx:l,item:a,matches:[]},o.push(n[l])),c.forEach(({matches:h})=>{n[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=Qn(t,this.options),{keys:i,records:s}=this._myIndex,n=[];return s.forEach(({$:o,i:a})=>{if(!he(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&n.push({idx:a,item:o,matches:l})}),n}_findMatches({key:t,value:e,searcher:i}){if(!he(e))return[];let s=[];if(Ze(e))e.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=i.searchIn(n);l&&s.push({score:c,key:t,value:n,idx:o,norm:a,indices:h})});else{const{v:n,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(n);a&&s.push({score:l,key:t,value:n,norm:o,indices:c})}return s}}is.version="7.0.0";is.createIndex=tc;is.parseIndex=Hu;is.config=$;is.parseQuery=rc;ip(ep);var cp=(function(){function r(t){this._haystack=[],this._fuseOptions=Jt(Jt({},t.fuseOptions),{keys:Wd([],t.searchFields),includeMatches:!0})}return r.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},r.prototype.reset=function(){this._haystack=[],this._fuse=void 0},r.prototype.isEmptyIndex=function(){return!this._haystack.length},r.prototype.search=function(t){this._fuse||(this._fuse=new is(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},r})();function hp(r){return new cp(r)}var dp=function(r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0},Pn=function(r,t,e){var i=r.dataset,s=t.customProperties,n=t.labelClass,o=t.labelDescription;n&&(i.labelClass=nn(n).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!dp(s)&&(i.customProperties=JSON.stringify(s)))},ja=function(r,t,e){var i=t&&r.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},up={containerOuter:function(r,t,e,i,s,n,o){var a=r.classNames.containerOuter,l=document.createElement("div");return B(l,a),l.dataset.type=n,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||ja(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(r){var t=r.classNames.containerInner,e=document.createElement("div");return B(e,t),e},itemList:function(r,t){var e=r.searchEnabled,i=r.classNames,s=i.list,n=i.listSingle,o=i.listItems,a=document.createElement("div");return B(a,s),B(a,t?n:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(r,t){var e=r.allowHTML,i=r.classNames.placeholder,s=document.createElement("div");return B(s,i),Ne(s,e,t),s},item:function(r,t,e){var i=r.allowHTML,s=r.removeItemButtonAlignLeft,n=r.removeItemIconText,o=r.removeItemLabelText,a=r.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=Ai(t.value),g=document.createElement("div");if(B(g,l),t.labelClass){var f=document.createElement("span");Ne(f,i,t.label),B(f,t.labelClass),g.appendChild(f)}else Ne(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,Pn(g,t,!0),(t.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),t.placeholder&&(B(g,u),g.dataset.placeholder=""),B(g,t.highlighted?h:d),e){t.disabled&&Ie(g,d),g.dataset.deletable="";var m=document.createElement("button");m.type="button",B(m,c),Ne(m,!0,As(n,t.value));var b=As(o,t.value);b&&m.setAttribute("aria-label",b),m.dataset.button="",s?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(r,t){var e=r.classNames.list,i=document.createElement("div");return B(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(r,t){var e=r.allowHTML,i=r.classNames,s=i.group,n=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Ai(l),d=document.createElement("div");B(d,s),c&&B(d,o),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return B(u,n),Ne(u,e,l||""),d.appendChild(u),d},choice:function(r,t,e,i){var s=r.allowHTML,n=r.classNames,o=n.item,a=n.itemChoice,l=n.itemSelectable,c=n.selectedState,h=n.itemDisabled,d=n.description,u=n.placeholder,p=t.label,g=Ai(t.value),f=document.createElement("div");f.id=t.elementId,B(f,o),B(f,a),i&&typeof p=="string"&&(p=ko(s,p),p+=" (".concat(i,")"),p={trusted:p});var m=f;if(t.labelClass){var b=document.createElement("span");Ne(b,s,p),B(b,t.labelClass),m=b,f.appendChild(b)}else Ne(f,s,p);if(t.labelDescription){var _="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",_);var w=document.createElement("span");Ne(w,s,t.labelDescription),w.id=_,B(w,d),f.appendChild(w)}return t.selected&&B(f,c),t.placeholder&&B(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=g,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),Pn(f,t,!1),t.disabled?(B(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(B(f,l),f.dataset.choiceSelectable=""),f},input:function(r,t){var e=r.classNames,i=e.input,s=e.inputCloned,n=r.labelId,o=document.createElement("input");return o.type="search",B(o,i),B(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):n||ja(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(r){var t=r.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return B(s,e),B(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(r,t,e){var i=r.classNames,s=i.item,n=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=$t.generic);var h=document.createElement("div");switch(Ne(h,!0,t),B(h,s),B(h,n),B(h,c),e){case $t.addChoice:B(h,o);break;case $t.noResults:B(h,a);break;case $t.noChoices:B(h,l);break}return e===$t.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(r){var t=Ai(r.label),e=new Option(t,r.value,!1,r.selected);return Pn(e,r,!0),e.disabled=r.disabled,r.selected&&e.setAttribute("selected",""),e}},pp="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,gp={},An=function(r){if(r)return r.dataset.id?parseInt(r.dataset.id,10):void 0},bs="[data-choice-selectable]",nc=(function(){function r(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=r.defaults;this.config=Jt(Jt(Jt({},s.allOptions),s.options),e),Yd.forEach(function(b){i.config[b]=Jt(Jt(Jt({},s.allOptions[b]),s.options[b]),e[b])});var n=this.config;n.silent||this._validateConfig();var o=n.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(uu(a)||Kl(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===di.Text;(c||n.maxItemCount!==1)&&(n.singleModeForMultiSelect=!1),n.singleModeForMultiSelect&&(l=di.SelectMultiple);var h=l===di.SelectOne,d=l===di.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&n.addItems||u&&n.addChoices,typeof n.renderSelectedChoices!="boolean"&&(n.renderSelectedChoices=n.renderSelectedChoices==="always"||h),n.closeDropdownOnSelect==="auto"?n.closeDropdownOnSelect=c||h||n.singleModeForMultiSelect:n.closeDropdownOnSelect=Ss(n.closeDropdownOnSelect),n.placeholder&&(n.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,n.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);n.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new du({element:a,classNames:n.classNames});else{var g=a;this.passedElement=new fu({element:g,classNames:n.classNames,template:function(b){return i._templates.option(b)},extractPlaceholder:n.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new _u(n),this._currentValue="",n.searchEnabled=!c&&n.searchEnabled||d,this._canSearch=n.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Jd(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,m=window.getComputedStyle(document.documentElement).direction;f!==m&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){n.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(b){return b.value})}return Object.defineProperty(r,"defaults",{get:function(){return Object.preventExtensions({get options(){return gp},get allOptions(){return Oa},get templates(){return up}})},enumerable:!1,configurable:!0}),r.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=hp(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},r.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=r.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},r.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},r.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},r.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(ir(i,!0)),e&&this.passedElement.triggerEvent(Zt.highlightItem,this._getChoiceForOutput(i)),this)},r.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(ir(i,!1)),e&&this.passedElement.triggerEvent(Zt.unhighlightItem,this._getChoiceForOutput(i)),this)},r.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(ir(e,!0)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(ir(e,!1)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},r.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(t=!this._canSearch),requestAnimationFrame(function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(Zt.showDropdown)}),this)},r.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame(function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(Zt.hideDropdown)}),this):this},r.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},r.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Me(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},r.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},r.prototype.setChoices=function(t,e,i,s,n,o){var a=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),n===void 0&&(n=!0),o===void 0&&(o=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(typeof t=="function"){var l=t(this);if(typeof Promise=="function"&&l instanceof Promise)return new Promise(function(c){return requestAnimationFrame(c)}).then(function(){return a._handleLoadingState(!0)}).then(function(){return l}).then(function(c){return a.setChoices(c,e,i,s,n,o)}).catch(function(c){a.config.silent||console.error(c)}).then(function(){return a._handleLoadingState(!1)}).then(function(){return a});if(!Array.isArray(l))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof l));return this.setChoices(l,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn(function(){n&&(a._isSearching=!1),s&&a.clearChoices(!0,o);var c=e==="value",h=i==="label";t.forEach(function(d){if("choices"in d){var u=d;h||(u=Jt(Jt({},u),{label:u[i]})),a._addGroup(Me(u,!0))}else{var p=d;(!h||!c)&&(p=Jt(Jt({},p),{value:p[e],label:p[i]}));var g=Me(p,!1);a._addChoice(g),g.placeholder&&!a._hasNonChoicePlaceholder&&(a._placeholderValue=Yl(g.label))}}),a.unhighlightAll()}),this._searcher.reset(),this},r.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var n=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(wa(l)):o[l.value]&&(l.selected=!0)};n.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(n,e,t),s._isSearching&&s._searchChoices(s.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},r.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(Gd(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(e)),this):this},r.prototype.clearChoices=function(t,e){var i=this;return t===void 0&&(t=!0),e===void 0&&(e=!1),t&&(e?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach(function(s){s.remove()})),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn(function(){var s=e?[]:i._store.items;i._store.reset(),s.forEach(function(n){i._store.dispatch(_a(n)),i._store.dispatch(xa(n))})}),this._searcher.reset(),this},r.prototype.clearStore=function(t){return t===void 0&&(t=!0),this.clearChoices(t,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},r.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},r.prototype._validateConfig=function(){var t=this.config,e=nu(t,Oa);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},r.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},r.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,n=this._store,o=n.activeGroups,a=n.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(g){return!g.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(g){return g.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,p=function(g,f,m){s?g.sort(su):i.shouldSort&&g.sort(i.sorter);var b=g.length;b=!f&&l&&b>l?l:b,b--,g.every(function(_,w){var S=_.choiceEl||t._templates.choice(i,_,i.itemSelectText,m);return _.choiceEl=S,h.appendChild(S),(s||!_.selected)&&(u=!0),w<b})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&p(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(g){return!g.placeholder&&!g.group}),!1,void 0),o.forEach(function(g){var f=d(g.choices);if(f.length){if(g.label){var m=g.groupEl||t._templates.choiceGroup(t.config,g);g.groupEl=m,m.remove(),h.appendChild(m)}p(f,!0,i.appendGroupInSearch&&s?g.label:void 0)}})):p(d(a),!1,void 0)),!u&&(s||!h.children.length||!i.renderSelectedChoices)&&(this._notice||(this._notice={text:Sa(s?i.noResultsText:i.noChoicesText),type:s?$t.noResults:$t.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},r.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,n=document.createDocumentFragment(),o=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=o(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,n.appendChild(u))};e.forEach(a);var l=!!n.childNodes.length;if(this._isSelectOneElement){var c=i.children.length;if(l||c>1){var h=i.querySelector(ms(s.classNames.placeholder));h&&h.remove()}else!l&&!c&&this._placeholderValue&&(l=!0,a(Me({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}l&&(i.append(n),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=o(d);u&&(u.remove(),n.append(u))}),i.append(n))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},r.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===$t.addChoice&&(e===$t.noResults||e===$t.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},r.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(ms(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},r.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},r.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},r.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Zt.change,{value:t})},r.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&An(t.parentElement),n=s&&i.find(function(o){return o.id===s});n&&this._store.withTxn(function(){if(e._removeItem(n),e._triggerChange(n.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=(e.config.shouldSort?e._store.choices.reverse():e._store.choices).find(function(a){return a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},r.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var n=An(t);n&&(s.forEach(function(o){o.id===n&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},r.prototype._handleChoiceAction=function(t){var e=this,i=An(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var n=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(s.value)}return n&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},r.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(n){return n.highlighted});e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},r.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Me(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return Me(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Me(o,!0)});var n=this.passedElement.optionsAsChoices();n&&(t=this._presetChoices).push.apply(t,n)}},r.prototype._handleLoadingState=function(t){t===void 0&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},r.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Zt.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},r.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice(typeof i=="function"?i(e):i,$t.addChoice),!1):(this._notice&&this._notice.type===$t.addChoice&&this._clearNotice(),!0)},r.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=As(e.customAddItemText,t)),i){var n=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(n){if(this._isSelectElement)return this._displayNotice("",$t.addChoice),!1;e.duplicateItemsAllowed||(i=!1,s=As(e.uniqueItemText,t))}}return i&&(s=As(e.addItemText,t)),s&&this._displayNotice(s,$t.addChoice),i},r.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var n=this._notice,o=n&&n.type;return o!==$t.addChoice&&(s.length?this._clearNotice():this._displayNotice(Sa(this.config.noResultsText),$t.noResults)),this._store.dispatch(Xd(s)),s.length},r.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Kd(!0)),this.passedElement.triggerEvent(Zt.search,{value:"",resultCount:0}))},r.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},r.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},r.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Ht.ESC_KEY&&e!==Ht.TAB_KEY&&e!==Ht.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Ht.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Ht.ENTER_KEY:return this._onEnterKey(t,i);case Ht.ESC_KEY:return this._onEscapeKey(t,i);case Ht.UP_KEY:case Ht.PAGE_UP_KEY:case Ht.DOWN_KEY:case Ht.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Ht.DELETE_KEY:case Ht.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},r.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},r.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},r.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},r.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,n=t.target;if(t.preventDefault(),n&&n.hasAttribute("data-button")){this._handleButtonAction(n);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!n||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(Me(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},r.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},r.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===Ht.DOWN_KEY||i===Ht.PAGE_DOWN_KEY?1:-1,n=t.metaKey||i===Ht.PAGE_DOWN_KEY||i===Ht.PAGE_UP_KEY,o=void 0;if(n)s>0?o=this.dropdown.element.querySelector("".concat(bs,":last-of-type")):o=this.dropdown.element.querySelector(bs);else{var a=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));a?o=Qd(a,bs,s):o=this.dropdown.element.querySelector(bs)}o&&(tu(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},r.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},r.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},r.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},r.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(pp&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},r.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},r.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},r.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var n=e===this.input.element;this._isTextElement?n&&i.addFocusState():this._isSelectMultipleElement?n&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),n&&this.showDropdown(!0))}},r.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&(i.removeFocusState(),this._canSearch||this.hideDropdown(!0)):(this._isScrollingOnIe=!1,this.input.element.focus())},r.prototype._onFormReset=function(){var t=this;this._store.withTxn(function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)})},r.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(bs));if(e.length){var i=t,s=this.config.classNames.highlightedState,n=Array.from(this.dropdown.element.querySelectorAll(ms(s)));n.forEach(function(o){Ie(o,s),o.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),B(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Zt.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},r.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(xa(t)),e&&(this.passedElement.triggerEvent(Zt.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Zt.choice,this._getChoiceForOutput(t)))},r.prototype._removeItem=function(t){if(t.id){this._store.dispatch(wa(t));var e=this._notice;e&&e.type===$t.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(t))}},r.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!(!s.duplicateItemsAllowed&&this._store.choices.find(function(a){return s.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var n=s.prependValue,o=s.appendValue;n&&(t.value=n+t.value),o&&(t.value+=o.toString()),(n||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(_a(t)),t.selected&&this._addItem(t,e,i)}},r.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(qd(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)}))},r.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,eu,ko,nn));var s={};Object.keys(this._templates).forEach(function(n){n in i?s[n]=i[n].bind(t):s[n]=t._templates[n].bind(t)}),this._templates=s},r.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,n=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Ta({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:n}),this.containerInner=new Ta({element:t.containerInner(i),classNames:o,type:a,position:n}),this.input=new cu({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Ea({element:t.choiceList(i,s)}),this.itemList=new Ea({element:t.itemList(i,s)}),this.dropdown=new lu({element:t.dropdown(i),classNames:o,type:a})},r.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,n=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(n),e.element.appendChild(this.itemList.element),n.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&n.insertBefore(this.input.element,n.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},r.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn(function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)}),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},r.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var n=t.findIndex(function(o){return o.selected})===-1;n&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?s._isSelectElement&&s._addGroup(o,i):s._addChoice(o,i)})},r.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(n){return i.config.valueComparer(n.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},r.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},r.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},r.version="11.1.0",r})();const oc='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media(min-width:640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}',Ks=ft`
1452
1452
  .form-control .form-control__label {
1453
1453
  display: none;
1454
1454
  }
@@ -2317,9 +2317,9 @@
2317
2317
  display: block;
2318
2318
  object-fit: contain;
2319
2319
  }
2320
- `;function v(r,t,e){return(t=(function(i){var s=(function(n,o){if(typeof n!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var l=a.call(n,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(n)})(i,"string");return typeof s=="symbol"?s:s+""})(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Na(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable}))),e.push.apply(e,i)}return e}function _(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Na(Object(e),!0).forEach((function(i){v(r,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Na(Object(e)).forEach((function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))}))}return r}function rt(r,t){if(r==null)return{};var e,i,s=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l})(r,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);for(i=0;i<n.length;i++)e=n[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(r,e)&&(s[e]=r[e])}return s}function He(r,t){return t||(t=r.slice(0)),Object.freeze(Object.defineProperties(r,{raw:{value:Object.freeze(t)}}))}class Ua{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const W=new class extends Ua{constructor(r){super(),this.configure(r)}configure(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,r)}addFonts(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=_(_({},this.fontPaths),r)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach((r=>{delete this.fontPaths[r]}))}clearFonts(){this.fontPaths={}}restoreDefaults(r){const t=new Ua,e=(r==null?void 0:r.reduce(((i,s)=>(i[s]=t[s],i)),{}))||t;this.configure(e)}},mi=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[r]("fabric",...e)};class je extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class zp extends je{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Hp{}class Vp extends Hp{testPrecision(t,e){const i="precision ".concat(e,` float;
2320
+ `;function v(r,t,e){return(t=(function(i){var s=(function(n,o){if(typeof n!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var l=a.call(n,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(n)})(i,"string");return typeof s=="symbol"?s:s+""})(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Na(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable}))),e.push.apply(e,i)}return e}function y(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Na(Object(e),!0).forEach((function(i){v(r,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Na(Object(e)).forEach((function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))}))}return r}function rt(r,t){if(r==null)return{};var e,i,s=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l})(r,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);for(i=0;i<n.length;i++)e=n[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(r,e)&&(s[e]=r[e])}return s}function He(r,t){return t||(t=r.slice(0)),Object.freeze(Object.defineProperties(r,{raw:{value:Object.freeze(t)}}))}class Ua{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const W=new class extends Ua{constructor(r){super(),this.configure(r)}configure(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,r)}addFonts(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=y(y({},this.fontPaths),r)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach((r=>{delete this.fontPaths[r]}))}clearFonts(){this.fontPaths={}}restoreDefaults(r){const t=new Ua,e=(r==null?void 0:r.reduce(((i,s)=>(i[s]=t[s],i)),{}))||t;this.configure(e)}},mi=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[r]("fabric",...e)};class je extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class zp extends je{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Hp{}class Vp extends Hp{testPrecision(t,e){const i="precision ".concat(e,` float;
2321
2321
  void main(){}`),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find((i=>this.testPrecision(e,i))),e.getExtension("WEBGL_lose_context").loseContext(),mi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Np={};let Wa;const Re=()=>Wa||(Wa={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Vp,dispose(){},copyPasteData:Np}),ss=()=>Re().document,an=()=>Re().window,hc=()=>{var r;return Math.max((r=W.devicePixelRatio)!==null&&r!==void 0?r:an().devicePixelRatio,1)},Ds=new class{constructor(){v(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(r){let{fontFamily:t,fontStyle:e,fontWeight:i}=r;t=t.toLowerCase();const s=this.charWidthsCache;s.has(t)||s.set(t,new Map);const n=s.get(t),o="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return n.has(o)||n.set(o,new Map),n.get(o)}clearFontCache(r){r?this.charWidthsCache.delete((r||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(r){const{perfLimitSizeTotal:t}=W,e=Math.sqrt(t*r);return[Math.floor(e),Math.floor(t/e)]}},so="6.9.1";function Ar(){}const qs=Math.PI/2,Rr=2*Math.PI,Ao=Math.PI/180,qt=Object.freeze([1,0,0,1,0,0]),Do=16,ai=.4477152502,V="center",Y="left",ie="top",ro="bottom",_t="right",se="none",Mo=/\r?\n/,dc="moving",ln="scaling",uc="rotating",Io="rotate",pc="skewing",Hs="resizing",Up="modifyPoly",Wp="modifyPath",Br="changed",cn="scale",oe="scaleX",be="scaleY",rs="skewX",ns="skewY",Dt="fill",re="stroke",zr="modified",Ni="json",Mn="svg",A=new class{constructor(){this[Ni]=new Map,this[Mn]=new Map}has(r){return this[Ni].has(r)}getClass(r){const t=this[Ni].get(r);if(!t)throw new je("No class registered for ".concat(r));return t}setClass(r,t){t?this[Ni].set(t,r):(this[Ni].set(r.type,r),this[Ni].set(r.type.toLowerCase(),r))}getSVGClass(r){return this[Mn].get(r)}setSVGClass(r,t){this[Mn].set(t??r.type.toLowerCase(),r)}},Hr=new class extends Array{remove(r){const t=this.indexOf(r);t>-1&&this.splice(t,1)}cancelAll(){const r=this.splice(0);return r.forEach((t=>t.abort())),r}cancelByCanvas(r){if(!r)return[];const t=this.filter((e=>{var i;return e.target===r||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===r}));return t.forEach((e=>e.abort())),t}cancelByTarget(r){if(!r)return[];const t=this.filter((e=>e.target===r));return t.forEach((e=>e.abort())),t}};class Yp{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach((i=>{let[s,n]=i;this.on(s,n)})),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if(typeof t=="object"){const i=[];return Object.entries(t).forEach((s=>{let[n,o]=s;i.push(this.once(n,o))})),()=>i.forEach((s=>s()))}if(e){const i=this.on(t,(function(){for(var s=arguments.length,n=new Array(s),o=0;o<s;o++)n[o]=arguments[o];e.call(this,...n),i()}));return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach((i=>{let[s,n]=i;this._removeEventListener(s,n)})):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let n=0;n<s.length;n++)s[n].call(this,e||{})}}const Yi=(r,t)=>{const e=r.indexOf(t);return e!==-1&&r.splice(e,1),r},Je=r=>{if(r===0)return 1;switch(Math.abs(r)/qs){case 1:case 3:return 0;case 2:return-1}return Math.cos(r)},Qe=r=>{if(r===0)return 0;const t=r/qs,e=Math.sign(r);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(r)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lo;const i=Qe(t),s=Je(t),n=this.subtract(e);return new x(n.x*s-n.y*i,n.x*i+n.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Lo=new x(0,0),Dr=r=>!!r&&Array.isArray(r._objects);function gc(r){class t extends r{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];const o=this._objects.push(...s);return s.forEach((a=>this._onObjectAdded(a))),o}insertAt(i){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];return this._objects.splice(i,0,...n),n.forEach((a=>this._onObjectAdded(a))),this._objects.length}remove(){const i=this._objects,s=[];for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return o.forEach((l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))})),s}forEachObject(i){this.getObjects().forEach(((s,n,o)=>i(s,n,o)))}getObjects(){for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];return s.length===0?[...this._objects]:this._objects.filter((o=>o.isType(...s)))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some((n=>n instanceof t&&n.contains(i,!0)))}complexity(){return this._objects.reduce(((i,s)=>i+=s.complexity?s.complexity():0),0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Yi(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Yi(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const n=this._objects.indexOf(i);if(n!==0){const o=this.findNewLowerIndex(i,n,s);return Yi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const n=this._objects.indexOf(i);if(n!==this._objects.length-1){const o=this.findNewUpperIndex(i,n,s);return Yi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Yi(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,n){let o;if(n){o=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(i,s,n){let o;if(n){o=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(i){let{left:s,top:n,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(s,n),d=h.add(new x(o,a));for(let u=this._objects.length-1;u>=0;u--){const p=this._objects[u];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,d)||p.isContainedWithinRect(h,d)||l&&p.containsPoint(h)||l&&p.containsPoint(d))&&c.push(p)}return c}}return t}class fc extends Yp{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Mr(r){return an().requestAnimationFrame(r)}function Gp(r){return an().cancelAnimationFrame(r)}let Xp=0;const bi=()=>Xp++,ti=()=>{const r=ss().createElement("canvas");if(!r||r.getContext===void 0)throw new je("Failed to create `canvas` element");return r},Kp=()=>ss().createElement("img"),ve=r=>{const t=ti();return t.width=r.width,t.height=r.height,t},mc=(r,t,e)=>r.toDataURL("image/".concat(t),e),bc=(r,t,e)=>new Promise(((i,s)=>{r.toBlob(i,"image/".concat(t),e)})),xt=r=>r*Ao,ei=r=>r/Ao,qp=r=>r.every(((t,e)=>t===qt[e])),Qt=(r,t,e)=>new x(r).transform(t,e),Ce=r=>{const t=1/(r[0]*r[3]-r[1]*r[2]),e=[t*r[3],-t*r[1],-t*r[2],t*r[0],0,0],{x:i,y:s}=new x(r[4],r[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},Rt=(r,t,e)=>[r[0]*t[0]+r[2]*t[1],r[1]*t[0]+r[3]*t[1],r[0]*t[2]+r[2]*t[3],r[1]*t[2]+r[3]*t[3],e?0:r[0]*t[4]+r[2]*t[5]+r[4],e?0:r[1]*t[4]+r[3]*t[5]+r[5]],Fo=(r,t)=>r.reduceRight(((e,i)=>i&&e?Rt(i,e,t):i||e),void 0)||qt.concat(),vc=r=>{let[t,e]=r;return Math.atan2(e,t)},Vr=r=>{const t=vc(r),e=Math.pow(r[0],2)+Math.pow(r[1],2),i=Math.sqrt(e),s=(r[0]*r[3]-r[2]*r[1])/i,n=Math.atan2(r[0]*r[2]+r[1]*r[3],e);return{angle:ei(t),scaleX:i,scaleY:s,skewX:ei(n),skewY:0,translateX:r[4]||0,translateY:r[5]||0}},Zs=function(r){return[1,0,0,1,r,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function os(){let{angle:r=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=xt(r),s=Je(i),n=Qe(i);return[s,n,-n,s,t?t-(s*t-n*e):0,e?e-(n*t+s*e):0]}const jo=function(r){return[r,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:r,0,0]},yc=r=>Math.tan(xt(r)),_c=r=>[1,0,yc(r),1,0,0],xc=r=>[1,yc(r),0,1,0,0],hn=r=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=r,a=jo(i?-t:t,s?-e:e);return n&&(a=Rt(a,_c(n),!0)),o&&(a=Rt(a,xc(o),!0)),a},Zp=r=>{const{translateX:t=0,translateY:e=0,angle:i=0}=r;let s=Zs(t,e);i&&(s=Rt(s,os({angle:i})));const n=hn(r);return qp(n)||(s=Rt(s,n)),s},Ir=function(r){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((function(i,s){if(t&&t.aborted)return s(new zp("loadImage"));const n=Kp();let o;t&&(o=function(l){n.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){n.onload=n.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(n)};r?(n.onload=a,n.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new je("Error loading ".concat(n.src)))},e&&(n.crossOrigin=e),n.src=r):a()}))},Vs=function(r){let{signal:t,reviver:e=Ar}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((i,s)=>{const n=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(r.map((o=>A.getClass(o.type).fromObject(o,{signal:t}).then((a=>(e(o,a),n.push(a),a)))))).then(i).catch((o=>{n.forEach((a=>{a.dispose&&a.dispose()})),s(o)})).finally((()=>{t&&t.removeEventListener("abort",s)}))}))},dn=function(r){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const n=Object.values(r).map((a=>a&&a.type&&A.has(a.type)?Vs([a],{signal:t}).then((l=>{let[c]=l;return s.push(c),c})):a)),o=Object.keys(r);Promise.all(n).then((a=>a.reduce(((l,c,h)=>(l[o[h]]=c,l)),{}))).then(e).catch((a=>{s.forEach((l=>{l.dispose&&l.dispose()})),i(a)})).finally((()=>{t&&t.removeEventListener("abort",i)}))}))},as=function(r){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce(((t,e)=>(e in r&&(t[e]=r[e]),t)),{})},$o=(r,t)=>Object.keys(r).reduce(((e,i)=>(t(r[i],i,r)&&(e[i]=r[i]),e)),{}),et=(r,t)=>parseFloat(Number(r).toFixed(t)),Ns=r=>"matrix("+r.map((t=>et(t,W.NUM_FRACTION_DIGITS))).join(" ")+")",ge=r=>!!r&&r.toLive!==void 0,Ya=r=>!!r&&typeof r.toObject=="function",Ga=r=>!!r&&r.offsetX!==void 0&&"source"in r,Ei=r=>!!r&&"multiSelectionStacking"in r;function wc(r){const t=r&&we(r);let e=0,i=0;if(!r||!t)return{left:e,top:i};let s=r;const n=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=o.scrollLeft||n.scrollLeft||0,i=o.scrollTop||n.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const we=r=>r.ownerDocument||null,Cc=r=>{var t;return((t=r.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Sc=function(r,t,e){let{width:i,height:s}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;r.width=i,r.height=s,n>1&&(r.setAttribute("width",(i*n).toString()),r.setAttribute("height",(s*n).toString()),t.scale(n,n))},no=(r,t)=>{let{width:e,height:i}=t;e&&(r.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(r.style.height=typeof i=="number"?"".concat(i,"px"):i)};function Xa(r){return r.onselectstart!==void 0&&(r.onselectstart=()=>!1),r.style.userSelect=se,r}class Tc{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&ss().getElementById(t)||ti();var i;if(e.hasAttribute("data-fabric"))throw new je("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;Sc(i,s,t,e)}setCSSDimensions(t){no(this.lower.el,t)}calcOffset(){return(function(t){var e;const i=t&&we(t),s={left:0,top:0};if(!i)return s;const n=((e=Cc(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(n.borderLeftWidth,10)||0,s.top+=parseInt(n.borderTopWidth,10)||0,s.left+=parseInt(n.paddingLeft,10)||0,s.top+=parseInt(n.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=wc(t);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}})(this.lower.el)}dispose(){Re().dispose(this.lower.el),delete this.lower}}const Jp={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...qt]},Qp=["objects"];class Js extends gc(fc){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return Js.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Tc(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const n=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(mi("warn",`Canvas is trying to add an object that belongs to a different canvas.
2322
- Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?hc():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:i=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=_({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const i=t,s=[...this.viewportTransform],n=Qt(t,Ce(s));s[0]=e,s[3]=e;const o=Qt(n,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Mr((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Ce(this.viewportTransform),s=Qt({x:0,y:0},i),n=Qt({x:t,y:e},i),o=s.min(n),a=s.max(n);return this.vptCoords={tl:o,tr:new x(a.x,o.y),bl:new x(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Gp(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],n=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=ge(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?i.toLive(t):i,o&&t.transform(...n),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...n),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Qt(this.getCenterPoint(),Ce(this.viewportTransform))}_centerObject(t,e){t.setXY(e,V,V),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return _(_(_({version:so},as(this,e)),{},{objects:this._objects.filter((n=>!n.excludeFromExport)).map((n=>this._toObject(n,t,e)))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),n}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,n=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return ge(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),ge(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),n&&!n.excludeFromExport&&(i.overlayImage=this._toObject(n,t,e)),i}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
2322
+ Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?hc():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:i=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=y({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const i=t,s=[...this.viewportTransform],n=Qt(t,Ce(s));s[0]=e,s[3]=e;const o=Qt(n,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Mr((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Ce(this.viewportTransform),s=Qt({x:0,y:0},i),n=Qt({x:t,y:e},i),o=s.min(n),a=s.max(n);return this.vptCoords={tl:o,tr:new x(a.x,o.y),bl:new x(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Gp(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],n=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=ge(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?i.toLive(t):i,o&&t.transform(...n),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...n),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Qt(this.getCenterPoint(),Ce(this.viewportTransform))}_centerObject(t,e){t.setXY(e,V,V),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return y(y(y({version:so},as(this,e)),{},{objects:this._objects.filter((n=>!n.excludeFromExport)).map((n=>this._toObject(n,t,e)))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),n}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,n=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return ge(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),ge(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),n&&!n.excludeFromExport&&(i.overlayImage=this._toObject(n,t,e)),i}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
2323
2323
  `)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
2324
2324
  `),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
2325
2325
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
@@ -2337,11 +2337,11 @@ Resulting to default behavior: removing object from previous canvas and adding t
2337
2337
  `.concat(s,`]]></style>
2338
2338
  `):""}_setSVGObjects(t,e){this.forEachObject((i=>{i.excludeFromExport||this._setSVGObject(t,i,e)}))}_setSVGObject(t,e,i){t.push(e.toSVG(i))}_setSVGBgOverlayImage(t,e,i){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(ge(i)){const s=i.repeat||"",n=this.width,o=this.height,a=this["".concat(e,"Vpt")]?Ns(Ce(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(n/2,",").concat(o/2,')" x="').concat(i.offsetX-n/2,'" y="').concat(i.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!Ga(i)?n:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Ga(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
2339
2339
  `))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
2340
- `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new je("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:n=[]}=s,o=rt(s,Qp),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Vs(n,{reviver:e,signal:i}),dn({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:d},{signal:i})]).then((p=>{let[g,f]=p;return this.clear(),this.add(...g),this.set(o),this.set(f),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=ve(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return mc(this.toCanvasElement(o,t),e,i)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return bc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:n,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,p=c*t,g=this.viewportTransform,f=[p,0,0,p,(g[4]-(s||0))*t,(g[5]-(n||0))*t],b=this.enableRetinaScaling,m=ve({width:a,height:l}),y=o?this._objects.filter((w=>o(w))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),y),this.viewportTransform=g,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=b,this.skipControlsDrawing=u,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Hr.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject((t=>t.dispose())),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}v(Js,"ownDefaults",Jp);const tg=["touchstart","touchmove","touchend"],eg=r=>{const t=wc(r.target),e=(function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i})(r);return new x(e.clientX+t.left,e.clientY+t.top)},oo=r=>tg.includes(r.type)||r.pointerType==="touch",Ka=r=>{r.preventDefault(),r.stopPropagation()},Ke=r=>{let t=0,e=0,i=0,s=0;for(let n=0,o=r.length;n<o;n++){const{x:a,y:l}=r[n];(a>i||!n)&&(i=a),(a<t||!n)&&(t=a),(l>s||!n)&&(s=l),(l<e||!n)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},ig=["translateX","translateY","scaleX","scaleY"],sg=(r,t)=>Nr(r,Rt(t,r.calcOwnMatrix())),Nr=(r,t)=>{const e=Vr(t),{translateX:i,translateY:s,scaleX:n,scaleY:o}=e,a=rt(e,ig),l=new x(i,s);r.flipX=!1,r.flipY=!1,Object.assign(r,a),r.set({scaleX:n,scaleY:o}),r.setPositionByOrigin(l,V,V)},rg=r=>{r.scaleX=1,r.scaleY=1,r.skewX=0,r.skewY=0,r.flipX=!1,r.flipY=!1,r.rotate(0)},Ec=r=>({scaleX:r.scaleX,scaleY:r.scaleY,skewX:r.skewX,skewY:r.skewY,angle:r.angle,left:r.left,flipX:r.flipX,flipY:r.flipY,top:r.top}),Ro=(r,t,e)=>{const i=r/2,s=t/2,n=[new x(-i,-s),new x(i,-s),new x(-i,s),new x(i,s)].map((a=>a.transform(e))),o=Ke(n);return new x(o.width,o.height)},un=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qt;return Rt(Ce(arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt),r)},Zi=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;return r.transform(un(t,e))},ng=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;return r.transform(un(t,e),!0)},og=(r,t,e)=>{const i=un(t,e);return Nr(r,Rt(i,r.calcOwnMatrix())),i},Oc=(r,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(r),_(_({},t),{},{target:i})),i.fire(r,t)},ag={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Tt=r=>typeof r=="string"?ag[r]:r-.5,Ur="not-allowed";function kc(r){return Tt(r.originX)===Tt(V)&&Tt(r.originY)===Tt(V)}function qa(r){return .5-Tt(r)}const Ee=(r,t)=>r[t],Pc=(r,t,e,i)=>({e:r,transform:t,pointer:new x(e,i)});function Ac(r,t){const e=r.getTotalAngle()+ei(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Bo(r,t,e,i,s){var n;let{target:o,corner:a}=r;const l=o.controls[a],c=((n=o.canvas)===null||n===void 0?void 0:n.getZoom())||1,h=o.padding/c,d=(function(u,p,g,f){const b=u.getRelativeCenterPoint(),m=g!==void 0&&f!==void 0?u.translateToGivenOrigin(b,V,V,g,f):new x(u.left,u.top);return(u.angle?p.rotate(-xt(u.angle),b):p).subtract(m)})(o,new x(i,s),t,e);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const lg=(r,t,e,i)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=i-o,c=!Ee(s,"lockMovementX")&&s.left!==a,h=!Ee(s,"lockMovementY")&&s.top!==l;return c&&s.set(Y,a),h&&s.set(ie,l),(c||h)&&Oc(dc,Pc(r,t,e,i)),c||h},Wr=r=>r.replace(/\s+/g," "),Za={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},In=(r,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+6*(t-r)*e:e<.5?t:e<2/3?r+(t-r)*(2/3-e)*6:r),Ja=(r,t,e,i)=>{r/=255,t/=255,e/=255;const s=Math.max(r,t,e),n=Math.min(r,t,e);let o,a;const l=(s+n)/2;if(s===n)o=a=0;else{const c=s-n;switch(a=l>.5?c/(2-s-n):c/(s+n),s){case r:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-r)/c+2;break;case e:o=(r-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},Qa=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(r)/(r.endsWith("%")?100:1)},rr=r=>Math.min(Math.round(r),255).toString(16).toUpperCase().padStart(2,"0"),tl=r=>{let[t,e,i,s=1]=r;const n=Math.round(.3*t+.59*e+.11*i);return[n,n,n,s]};class K{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof K)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,n=1]=t;this.setSource([e,i,s,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Za&&(t=Za[t]),t==="transparent"?[255,255,255,0]:K.sourceFromHex(t)||K.sourceFromRgb(t)||K.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=Ja(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=Ja(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(rr(t)).concat(rr(e)).concat(rr(i)).concat(rr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(tl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=tl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof K||(t=new K(t));const e=this.getSource(),i=t.getSource(),[s,n,o]=e.map(((a,l)=>Math.round(.5*a+.5*i[l])));return this.setSource([s,n,o,e[3]]),this}static fromRgb(t){return K.fromRgba(t)}static fromRgba(t){return new K(K.sourceFromRgb(t))}static sourceFromRgb(t){const e=Wr(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[i,s,n]=e.slice(1,4).map((o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a}));return[i,s,n,Qa(e[4])]}}static fromHsl(t){return K.fromHsla(t)}static fromHsla(t){return new K(K.sourceFromHsl(t))}static sourceFromHsl(t){const e=Wr(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const i=(K.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=n;else{const c=n<=.5?n*(s+1):n+s-n*s,h=2*n-c;o=In(h,c,i+1/3),a=In(h,c,i),l=In(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Qa(e[4])]}static fromHex(t){return new K(K.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map((l=>l+l)):e.match(/.{2}/g);const[s,n,o,a=255]=i.map((l=>parseInt(l,16)));return[s,n,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?ei(i):e.includes("turn")?360*i:i}}const Ji=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Do;const e=/\D{0,2}$/.exec(r),i=parseFloat(r),s=W.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},cg=r=>{const[t,e]=r.trim().split(" "),[i,s]=(n=t)&&n!==se?[n.slice(1,4),n.slice(5,8)]:n===se?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},Us=function(r,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const n=new K(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(r,": ").concat(e,"; ").concat(i?"".concat(r,"-opacity: ").concat(i,"; "):""):"".concat(r,'="').concat(e,'" ').concat(i?"".concat(r,'-opacity="').concat(i,'" '):"")};class Dc{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):se,n=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=Us(Dt,this.fill);return[Us(re,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Ns(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,p=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let b;l&&(l.clipPathId="CLIPPATH_".concat(bi()),b='<clipPath id="'.concat(l.clipPathId,`" >
2340
+ `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new je("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:n=[]}=s,o=rt(s,Qp),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Vs(n,{reviver:e,signal:i}),dn({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:d},{signal:i})]).then((p=>{let[g,f]=p;return this.clear(),this.add(...g),this.set(o),this.set(f),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=ve(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return mc(this.toCanvasElement(o,t),e,i)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return bc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:n,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,p=c*t,g=this.viewportTransform,f=[p,0,0,p,(g[4]-(s||0))*t,(g[5]-(n||0))*t],m=this.enableRetinaScaling,b=ve({width:a,height:l}),_=o?this._objects.filter((w=>o(w))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(b.getContext("2d"),_),this.viewportTransform=g,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=m,this.skipControlsDrawing=u,b}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Hr.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject((t=>t.dispose())),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}v(Js,"ownDefaults",Jp);const tg=["touchstart","touchmove","touchend"],eg=r=>{const t=wc(r.target),e=(function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i})(r);return new x(e.clientX+t.left,e.clientY+t.top)},oo=r=>tg.includes(r.type)||r.pointerType==="touch",Ka=r=>{r.preventDefault(),r.stopPropagation()},Ke=r=>{let t=0,e=0,i=0,s=0;for(let n=0,o=r.length;n<o;n++){const{x:a,y:l}=r[n];(a>i||!n)&&(i=a),(a<t||!n)&&(t=a),(l>s||!n)&&(s=l),(l<e||!n)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},ig=["translateX","translateY","scaleX","scaleY"],sg=(r,t)=>Nr(r,Rt(t,r.calcOwnMatrix())),Nr=(r,t)=>{const e=Vr(t),{translateX:i,translateY:s,scaleX:n,scaleY:o}=e,a=rt(e,ig),l=new x(i,s);r.flipX=!1,r.flipY=!1,Object.assign(r,a),r.set({scaleX:n,scaleY:o}),r.setPositionByOrigin(l,V,V)},rg=r=>{r.scaleX=1,r.scaleY=1,r.skewX=0,r.skewY=0,r.flipX=!1,r.flipY=!1,r.rotate(0)},Ec=r=>({scaleX:r.scaleX,scaleY:r.scaleY,skewX:r.skewX,skewY:r.skewY,angle:r.angle,left:r.left,flipX:r.flipX,flipY:r.flipY,top:r.top}),Ro=(r,t,e)=>{const i=r/2,s=t/2,n=[new x(-i,-s),new x(i,-s),new x(-i,s),new x(i,s)].map((a=>a.transform(e))),o=Ke(n);return new x(o.width,o.height)},un=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qt;return Rt(Ce(arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt),r)},Zi=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;return r.transform(un(t,e))},ng=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;return r.transform(un(t,e),!0)},og=(r,t,e)=>{const i=un(t,e);return Nr(r,Rt(i,r.calcOwnMatrix())),i},Oc=(r,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(r),y(y({},t),{},{target:i})),i.fire(r,t)},ag={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Tt=r=>typeof r=="string"?ag[r]:r-.5,Ur="not-allowed";function kc(r){return Tt(r.originX)===Tt(V)&&Tt(r.originY)===Tt(V)}function qa(r){return .5-Tt(r)}const Ee=(r,t)=>r[t],Pc=(r,t,e,i)=>({e:r,transform:t,pointer:new x(e,i)});function Ac(r,t){const e=r.getTotalAngle()+ei(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Bo(r,t,e,i,s){var n;let{target:o,corner:a}=r;const l=o.controls[a],c=((n=o.canvas)===null||n===void 0?void 0:n.getZoom())||1,h=o.padding/c,d=(function(u,p,g,f){const m=u.getRelativeCenterPoint(),b=g!==void 0&&f!==void 0?u.translateToGivenOrigin(m,V,V,g,f):new x(u.left,u.top);return(u.angle?p.rotate(-xt(u.angle),m):p).subtract(b)})(o,new x(i,s),t,e);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const lg=(r,t,e,i)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=i-o,c=!Ee(s,"lockMovementX")&&s.left!==a,h=!Ee(s,"lockMovementY")&&s.top!==l;return c&&s.set(Y,a),h&&s.set(ie,l),(c||h)&&Oc(dc,Pc(r,t,e,i)),c||h},Wr=r=>r.replace(/\s+/g," "),Za={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},In=(r,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+6*(t-r)*e:e<.5?t:e<2/3?r+(t-r)*(2/3-e)*6:r),Ja=(r,t,e,i)=>{r/=255,t/=255,e/=255;const s=Math.max(r,t,e),n=Math.min(r,t,e);let o,a;const l=(s+n)/2;if(s===n)o=a=0;else{const c=s-n;switch(a=l>.5?c/(2-s-n):c/(s+n),s){case r:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-r)/c+2;break;case e:o=(r-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},Qa=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(r)/(r.endsWith("%")?100:1)},rr=r=>Math.min(Math.round(r),255).toString(16).toUpperCase().padStart(2,"0"),tl=r=>{let[t,e,i,s=1]=r;const n=Math.round(.3*t+.59*e+.11*i);return[n,n,n,s]};class K{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof K)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,n=1]=t;this.setSource([e,i,s,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Za&&(t=Za[t]),t==="transparent"?[255,255,255,0]:K.sourceFromHex(t)||K.sourceFromRgb(t)||K.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=Ja(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=Ja(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(rr(t)).concat(rr(e)).concat(rr(i)).concat(rr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(tl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=tl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof K||(t=new K(t));const e=this.getSource(),i=t.getSource(),[s,n,o]=e.map(((a,l)=>Math.round(.5*a+.5*i[l])));return this.setSource([s,n,o,e[3]]),this}static fromRgb(t){return K.fromRgba(t)}static fromRgba(t){return new K(K.sourceFromRgb(t))}static sourceFromRgb(t){const e=Wr(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[i,s,n]=e.slice(1,4).map((o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a}));return[i,s,n,Qa(e[4])]}}static fromHsl(t){return K.fromHsla(t)}static fromHsla(t){return new K(K.sourceFromHsl(t))}static sourceFromHsl(t){const e=Wr(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const i=(K.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=n;else{const c=n<=.5?n*(s+1):n+s-n*s,h=2*n-c;o=In(h,c,i+1/3),a=In(h,c,i),l=In(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Qa(e[4])]}static fromHex(t){return new K(K.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map((l=>l+l)):e.match(/.{2}/g);const[s,n,o,a=255]=i.map((l=>parseInt(l,16)));return[s,n,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?ei(i):e.includes("turn")?360*i:i}}const Ji=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Do;const e=/\D{0,2}$/.exec(r),i=parseFloat(r),s=W.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},cg=r=>{const[t,e]=r.trim().split(" "),[i,s]=(n=t)&&n!==se?[n.slice(1,4),n.slice(5,8)]:n===se?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},Us=function(r,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const n=new K(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(r,": ").concat(e,"; ").concat(i?"".concat(r,"-opacity: ").concat(i,"; "):""):"".concat(r,'="').concat(e,'" ').concat(i?"".concat(r,'-opacity="').concat(i,'" '):"")};class Dc{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):se,n=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=Us(Dt,this.fill);return[Us(re,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Ns(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,p=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(bi()),m='<clipPath id="'.concat(l.clipPathId,`" >
2341
2341
  `).concat(l.toClipPathSVG(i),`</clipPath>
2342
2342
  `)),h&&g.push("<g ",a,this.getSvgCommons(),` >
2343
2343
  `),g.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
2344
- `);const m=[o,c,e?"":this.addPaintOrder()," ",n?'transform="'.concat(n,'" '):""].join("");return t[f]=m,ge(u)&&g.push(u.toSVG(this)),ge(d)&&g.push(d.toSVG(this)),p&&g.push(p.toSVG(this)),l&&g.push(b),g.push(t.join("")),g.push(`</g>
2344
+ `);const b=[o,c,e?"":this.addPaintOrder()," ",n?'transform="'.concat(n,'" '):""].join("");return t[f]=b,ge(u)&&g.push(u.toSVG(this)),ge(d)&&g.push(d.toSVG(this)),p&&g.push(p.toSVG(this)),l&&g.push(m),g.push(t.join("")),g.push(`</g>
2345
2345
  `),h&&g.push(`</g>
2346
2346
  `),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Dt?' paint-order="'.concat(this.paintFirst,'" '):""}}function pn(r){return new RegExp("^("+r.join("|")+")\\b","i")}const Ri="textDecorationThickness",Mc=["fontSize","fontWeight","fontFamily","fontStyle"],Ic=["underline","overline","linethrough"],Lc=[...Mc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Fc=[...Lc,...Ic,"textBackgroundColor","direction",Ri],hg=[...Mc,...Ic,re,"strokeWidth",Dt,"deltaY","textBackgroundColor",Ri],dg={_reNewline:Mo,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Y,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Y,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[Ri]:66.667},Le="justify",Yr="justify-left",Ms="justify-right",Is="justify-center";var el,il,sl;const Se=String.raw(el||(el=He(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),Ln=String.raw(il||(il=He(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),ug=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Se+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Se+"))?\\s+(.*)"),pg={cx:Y,x:Y,r:"radius",cy:ie,y:ie,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":Ri},Fn="font-size",jn="clip-path";pn(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);pn(["symbol","image","marker","pattern","view","svg"]);const rl=pn(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(sl||(sl=He(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),Se,Ln,Se,Ln,Se,Ln,Se));const gg=new x(1,0),jc=new x,$c=(r,t)=>r.rotate(t),ao=(r,t)=>new x(t).subtract(r),lo=r=>r.distanceFrom(jc),co=(r,t)=>Math.atan2(Ls(r,t),mg(r,t)),fg=r=>co(gg,r),zo=r=>r.eq(jc)?r:r.scalarDivide(lo(r)),Rc=function(r){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return zo(new x(-r.y,r.x).scalarMultiply(t?1:-1))},Ls=(r,t)=>r.x*t.y-r.y*t.x,mg=(r,t)=>r.x*t.x+r.y*t.y,nl=(r,t,e)=>{if(r.eq(t)||r.eq(e))return!0;const i=Ls(t,e),s=Ls(t,r),n=Ls(e,r);return i>=0?s>=0&&n<=0:!(s<=0&&n>=0)},ol="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",al=new RegExp("(?:\\s|^)"+ol+ol+"("+Se+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class qe{constructor(t){const e=typeof t=="string"?qe.parseShadow(t):t;Object.assign(this,qe.ownDefaults,e),this.id=bi()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,n=0]=(al.exec(e)||[]).map((o=>parseFloat(o)||0));return{color:(e.replace(al,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:n}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=$c(new x(this.offsetX,this.offsetY),xt(-t.angle)),i=new K(this.color);let s=40,n=40;return t.width&&t.height&&(s=100*et((Math.abs(e.x)+this.blur)/t.width,W.NUM_FRACTION_DIGITS)+20,n=100*et((Math.abs(e.y)+this.blur)/t.height,W.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(n,'%" height="').concat(100+2*n,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
2347
2347
  <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(et(this.blur?this.blur/2:0,W.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
@@ -2353,32 +2353,32 @@ Resulting to default behavior: removing object from previous canvas and adding t
2353
2353
  <feMergeNode in="SourceGraphic"></feMergeNode>
2354
2354
  </feMerge>
2355
2355
  </filter>
2356
- `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=qe.ownDefaults;return this.includeDefaultValues?t:$o(t,((i,s)=>i!==e[s]))}static async fromObject(t){return new this(t)}}v(qe,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(qe,"type","shadow"),A.setClass(qe,"shadow");const es=(r,t,e)=>Math.max(r,Math.min(t,e)),bg=[ie,Y,oe,be,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",rs,ns],ri=[Dt,re,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],vg={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Y,originY:ie,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Dt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},yg=(r,t,e,i)=>-e*Math.cos(r/i*qs)+e+t,_g=()=>!1;class Ho{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:n=0,easing:o=yg,onStart:a=Ar,onChange:l=Ar,onComplete:c=Ar,abort:h=_g,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=n,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>Mr(t)),this.delay):Mr(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:n}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Mr(this.tick)))}register(){Hr.push(this)}unregister(){Hr.remove(this)}abort(){this._state="aborted",this.unregister()}}const xg=["startValue","endValue"];class wg extends Ho{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},rt(t,xg)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const Cg=["startValue","endValue"];class Sg extends Ho{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},rt(t,Cg)),{},{startValue:e,byValue:i.map(((s,n)=>s-e[n]))}))}calculate(t){const e=this.startValue.map(((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Tg=["startValue","endValue","easing","onChange","onComplete","abort"],Eg=(r,t,e,i)=>t+e*(1-Math.cos(r/i*qs)),$n=r=>r&&((t,e,i)=>r(new K(t).toRgba(),e,i));class Og extends Ho{constructor(t){let{startValue:e,endValue:i,easing:s=Eg,onChange:n,onComplete:o,abort:a}=t,l=rt(t,Tg);const c=new K(e).getSource(),h=new K(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map(((d,u)=>d-c[u])),easing:s,onChange:$n(n),onComplete:$n(o),abort:$n(a)}))}calculate(t){const[e,i,s,n]=this.startValue.map(((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l))),o=[...[e,i,s].map(Math.round),es(0,n,1)];return{value:o,valueProgress:o.map(((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0)).find((a=>a!==0))||0}}}function Bc(r){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(r)?new Sg(r):new wg(r);return t.start(),t}function kg(r){const t=new Og(r);return t.start(),t}class lt{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some((e=>e.eq(t)))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((s=>!this.includes(s)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const n=ao(e,i),o=ao(e,t).divide(n);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new x(t).setX(Math.min(t.x-1,...e.map((n=>n.x))));let s=0;for(let n=0;n<e.length;n++){const o=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,i);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,p=c*u-h*d,g=a*u-l*d,f=h*a-c*l;if(f!==0){const b=p/f,m=g/f;return(n||0<=b&&b<=1)&&(o||0<=m&&m<=1)?new lt("Intersection").append(new x(t.x+b*a,t.y+b*l)):new lt}if(p===0||g===0){const b=n||o||lt.isPointContained(t,i,s)||lt.isPointContained(e,i,s)||lt.isPointContained(i,t,e)||lt.isPointContained(s,t,e);return new lt(b?"Coincident":void 0)}return new lt("Parallel")}static intersectSegmentLine(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new lt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=lt.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;n.append(...c.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,i){return lt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new lt,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=lt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(n.push(c),i.append(a,l)):i.append(...c.points)}return n.length>0&&n.length===t.length?new lt("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),n=e.max(i),o=new x(n.x,s.y),a=new x(s.x,n.y);return lt.intersectPolygonPolygon(t,[s,o,n,a])}}class Pg extends fc{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?Qt(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=Qt(t,Ce(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map((a=>Qt(a,o)))}return n}intersectsWithRect(t,e){return lt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=lt.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:n,height:o}=this.getBoundingRect();return i>=t.x&&i+n<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return lt.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y))||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Ke(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(oe,t),this._set(be,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?ei(vc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||qt.concat()}calcACoords(){const t=os({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Zs(e,i),n=Rt(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Qt({x:-a,y:-l},n),tr:Qt({x:a,y:-l},n),bl:Qt({x:-a,y:l},n),br:Qt({x:a,y:l},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Tt(this.originX),Tt(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((n,o)=>n===i[o]))?s.value:(this.group&&(e=Rt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=Zp(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,n=0;this.strokeUniform&&(s=0,n=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new x(o*e.scaleX,a*e.scaleY):Ro(o,a,hn(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,i,s,n){let o=t.x,a=t.y;const l=Tt(s)-Tt(e),c=Tt(n)-Tt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,i){if(e===V&&i===V)return t;const s=this.translateToGivenOrigin(t,e,i,V,V);return this.angle?s.rotate(xt(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,V,V,e,i);return this.angle?s.rotate(xt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Qt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),n=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Y,ie)}}const Ag=["type"],Dg=["extraParam"];let Ue=class Lr extends Pg{static getDefaults(){return Lr.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){mi("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Lr.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ti(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=W.maxCacheSideLimit,n=W.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=W.perfLimitSizeTotal)return e<n&&(t.width=n),i<n&&(t.height=n),t;const o=e/i,[a,l]=Ds.limitDimsByArea(o),c=es(n,a,s),h=es(n,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:n,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==n||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(n,o),this.zoomX=n,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Vr(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==oe&&t!==be||(e=this._constrainScale(e)),t===oe&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof qe||(e=new qe(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===re&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const i=ve(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((n=>{n.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const n=Ce(this.calcTransformMatrix());s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(ge(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[n,,,o]=(i==null?void 0:i.viewportTransform)||qt,a=n*s,l=o*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*W.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!ge(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,n):t.transform(1,0,0,1,s,n),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===re?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/n,a=s.y/this.scaleY/n,l=ve({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/n,s.zoomY/this.scaleY/n),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/s.zoomX,n*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(A.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Ec(this),i=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?hc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new Js(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&rg(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&og(this,this.getViewportTransform()),this.setCoords();const c=ti(),h=this.getBoundingRect(),d=this.shadow,u=new x;if(d){const y=d.blur,w=d.nonScaling?new x(1,1):this.getObjectScaling();u.x=2*Math.round(n(d.offsetX)+y)*n(w.x),u.y=2*Math.round(n(d.offsetY)+y)*n(w.y)}const p=h.width+u.x,g=h.height+u.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new x(f.width/2,f.height/2),V,V);const b=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const m=f.toCanvasElement(a||1,t);return this.set("canvas",b),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),m}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return mc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return bc(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:n,y:o}=this.getRelativeCenterPoint();this.originX=V,this.originY=V,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=n,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Hr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Re().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((i,s)=>{let[n,o]=s;return i[n]=this._animate(n,o,e),i}),{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),n=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??s.reduce(((d,u)=>d[u]),this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(d,u,p)=>{s.reduce(((g,f,b)=>(b===s.length-1&&(g[f]=d),g[f])),this),l&&l(d,u,p)},onComplete:(d,u,p)=>{this.setCoords(),c&&c(d,u,p)}});return n?kg(h):Bc(h)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(e.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,n=0;n<e.length;n++){if(s=e[n],s===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,n)],otherFork:[t,...i.slice(0,o)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),n=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(n);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Lr.customProperties,this.constructor.customProperties||[]);let e;const i=W.NUM_FRACTION_DIGITS,{clipPath:s,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:S,scaleX:T,scaleY:O,angle:k,flipX:E,flipY:P,opacity:R,visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:X,skewY:Q}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const N=Ut=>et(Ut,i),Ct=_(_({},as(this,t)),{},{type:this.constructor.type,version:so,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:Ya(n)?n.toObject():n,stroke:Ya(o)?o.toObject():o,strokeWidth:N(f),strokeDashArray:l&&l.concat(),strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:N(S),scaleX:N(T),scaleY:N(O),angle:N(k),flipX:E,flipY:P,opacity:N(R),shadow:a&&a.toObject(),visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:N(X),skewY:N(Q)},e?{clipPath:e}:null);return this.includeDefaultValues?Ct:this._removeDefaultValues(Ct)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return $o(t,((s,n)=>{if(n===Y||n===ie||n==="type")return!0;const o=i[n];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=rt(t,Ag),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,n=rt(i,Dg);return dn(e,n).then((o=>s?(delete o[s],new this(e[s],o)):new this(o)))}static fromObject(t,e){return this._fromObject(t,e)}};v(Ue,"stateProperties",bg),v(Ue,"cacheProperties",ri),v(Ue,"ownDefaults",vg),v(Ue,"type","FabricObject"),v(Ue,"colorProperties",[Dt,re,"backgroundColor"]),v(Ue,"customProperties",[]),A.setClass(Ue),A.setClass(Ue,"object");const ls=(r,t,e)=>(i,s,n,o)=>{const a=t(i,s,n,o);return a&&Oc(r,_(_({},Pc(i,s,n,o)),e)),a};function cs(r){return(t,e,i,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(l,o,a),h=r(t,e,i,s);return n.setPositionByOrigin(c,e.originX,e.originY),h}}const ll=ls(Hs,cs(((r,t,e,i)=>{const s=Bo(t,t.originX,t.originY,e,i);if(Tt(t.originX)===Tt(V)||Tt(t.originX)===Tt(_t)&&s.x<0||Tt(t.originX)===Tt(Y)&&s.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=kc(t)?2:1,l=n.width,c=Math.abs(s.x*a/n.scaleX)-o;return n.set("width",Math.max(c,1)),l!==n.width}return!1})));function Mg(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n>o?(h=n,r.scale(1,o/n),u=e*n/o):o>n?(h=o,r.scale(n/o,1),d=t*o/n):h=n,r.beginPath(),r.arc(d,u,h/2,0,Rr,!1),r[l](),c&&r.stroke(),r.restore()}function Ig(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=n/2,d=o/2;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r.translate(t,e);const u=s.getTotalAngle();r.rotate(xt(u)),r["".concat(l,"Rect")](-h,-d,n,o),c&&r.strokeRect(-h,-d,n,o),r.restore()}class _e{constructor(t){v(this,"visible",!0),v(this,"actionName",cn),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var n;let{tl:o,tr:a,br:l,bl:c}=s;return((n=e.canvas)===null||n===void 0?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&lt.isPointInPolygon(i,[o,a,l,c])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,n,o){const a=Fo([Zs(i,s),os({angle:t}),jo((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,i,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Mg.call(this,t,e,i,s,n):Ig.call(this,t,e,i,s,n)}}const Lg=(r,t,e)=>e.lockRotation?Ur:t.cursorStyle,Fg=ls(uc,cs(((r,t,e,i)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Ee(s,"lockRotation"))return!1;const d=Math.atan2(o-h.y,n-h.x),u=Math.atan2(i-h.y,e-h.x);let p=ei(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,b=s.snapThreshold||f,m=Math.ceil(p/f)*f,y=Math.floor(p/f)*f;Math.abs(p-y)<b?p=y:Math.abs(p-m)<b&&(p=m)}p<0&&(p=360+p),p%=360;const g=s.angle!==p;return s.angle=p,g})));function zc(r,t){const e=t.canvas,i=r[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Hc(r,t,e){const i=Ee(r,"lockScalingX"),s=Ee(r,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:n,height:o,strokeWidth:a}=r;return n===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const jg=["e","se","s","sw","w","nw","n","ne","e"],Ts=(r,t,e)=>{const i=zc(r,e);if(Hc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Ur;const s=Ac(e,t);return"".concat(jg[s],"-resize")};function Vo(r,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=zc(r,n);let l,c,h,d,u,p;if(Hc(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Bo(t,t.originX,t.originY,e,i),u=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=p),Ee(n,"lockScalingFlip")&&(t.signX!==u||t.signY!==p))return!1;if(d=n._getTransformedDimensions(),a&&!o){const b=Math.abs(l.x)+Math.abs(l.y),{original:m}=t,y=b/(Math.abs(d.x*m.scaleX/n.scaleX)+Math.abs(d.y*m.scaleY/n.scaleY));c=m.scaleX*y,h=m.scaleY*y}else c=Math.abs(l.x*n.scaleX/d.x),h=Math.abs(l.y*n.scaleY/d.y);kc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=qa(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=qa(t.originY),h*=-1,t.signY=p)}const g=n.scaleX,f=n.scaleY;return o?(o==="x"&&n.set(oe,c),o==="y"&&n.set(be,h)):(!Ee(n,"lockScalingX")&&n.set(oe,c),!Ee(n,"lockScalingY")&&n.set(be,h)),g!==n.scaleX||f!==n.scaleY}const nr=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i)))),$g=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"x"})))),Rg=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"y"})))),Bg=["target","ex","ey","skewingSide"],Rn={x:{counterAxis:"y",scale:oe,skew:rs,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:be,skew:ns,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},zg=["ns","nesw","ew","nwse"],Hg=(r,t,e)=>{if(t.x!==0&&Ee(e,"lockSkewingY")||t.y!==0&&Ee(e,"lockSkewingX"))return Ur;const i=Ac(e,t)%4;return"".concat(zg[i],"-resize")};function Vc(r,t,e,i,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Rn[r];if(Ee(n,l))return!1;const{origin:d,flip:u}=Rn[o],p=Tt(e[d])*(n[u]?-1:1),g=-Math.sign(p)*(n[h]?-1:1),f=.5*-((n[c]===0&&Bo(e,V,V,i,s)[r]>0||n[c]>0?1:-1)*g)+.5;return ls(pc,cs(((m,y,w,S)=>(function(T,O,k){let{target:E,ex:P,ey:R,skewingSide:L}=O,F=rt(O,Bg);const{skew:H}=Rn[T],M=k.subtract(new x(P,R)).divide(new x(E.scaleX,E.scaleY))[T],U=E[H],X=F[H],Q=Math.tan(xt(X)),N=T==="y"?E._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:E._getTransformedDimensions({scaleX:1,scaleY:1}).y,Ct=2*M*L/Math.max(N,1)+Q,Ut=ei(Math.atan(Ct));E.set(H,Ut);const Wt=U!==E[H];if(Wt&&T==="y"){const{skewX:Pe,scaleX:de}=E,Ft=E._getTransformedDimensions({skewY:U}),Ae=E._getTransformedDimensions(),ae=Pe!==0?Ft.x/Ae.x:1;ae!==1&&E.set(oe,ae*de)}return Wt})(r,y,new x(w,S)))))(t,_(_({},e),{},{[a]:f,skewingSide:g}),i,s)}const Vg=(r,t,e,i)=>Vc("x",r,t,e,i),Ng=(r,t,e,i)=>Vc("y",r,t,e,i);function gn(r,t){return r[t.canvas.altActionKey]}const or=(r,t,e)=>{const i=gn(r,e);return t.x===0?i?rs:be:t.y===0?i?ns:oe:""},Xi=(r,t,e)=>gn(r,e)?Hg(0,t,e):Ts(r,t,e),cl=(r,t,e,i)=>gn(r,t.target)?Ng(r,t,e,i):$g(r,t,e,i),hl=(r,t,e,i)=>gn(r,t.target)?Vg(r,t,e,i):Rg(r,t,e,i),Nc=()=>({ml:new _e({x:-.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mr:new _e({x:.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mb:new _e({x:0,y:.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),mt:new _e({x:0,y:-.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),tl:new _e({x:-.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),tr:new _e({x:.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),bl:new _e({x:-.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),br:new _e({x:.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),mtr:new _e({x:0,y:-.5,actionHandler:Fg,cursorStyleHandler:Lg,offsetY:-40,withConnection:!0,actionName:Io})}),Ug=()=>({mr:new _e({x:.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs}),ml:new _e({x:-.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs})}),Wg=()=>_(_({},Nc()),Ug());class Ws extends Ue{static getDefaults(){return _(_({},super.getDefaults()),Ws.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ws.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Nc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(cn))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[n,o]=i[s],a=this.controls[n];if(a.shouldActivate(n,this,t,e?o.touchCorner:o.corner))return this.__corner=n,{key:n,control:a,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Zs(e.x,e.y),s=os({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Rt(i,s),o=Rt(t,n),a=Rt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Vr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl(((d,u)=>{const p=d.positionHandler(c,a,this,d);h[u]=Object.assign(p,this._calcCornerCoords(d,p))})),h}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(xt(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=_({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,n=_({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=n.hasBorders,l=n.hasControls,c=Rt(o,this.calcTransformMatrix()),h=Vr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(xt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const n=Ro(this.width,this.height,hn(e)),o=this.isStrokeAccountedForInDimensions()?Lo:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=n.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,n)=>{s.withConnection&&s.getVisibility(this,n)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:n,cornerColor:o}=this,a=_({cornerStrokeColor:s,cornerDashArray:n,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}})),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach((e=>{let[i,s]=e;return this.setControlVisible(i,s)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,n=this.height+4;return e.clearRect(-s/2,-n/2,s,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Uc(r,t){return t.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),r}v(Ws,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Vt extends Ws{}Uc(Vt,[Dc]),A.setClass(Vt),A.setClass(Vt,"object");const Yg=(r,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:n}=r.getImageData(t-i,e-i,s,s);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0};class Wc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const i=ao(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(xt(this.options.skewY)),e.x+=e.y*Math.tan(xt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Gg=new x;class Qi extends Wc{static getOrthogonalRotationFactor(t,e){const i=e?co(t,e):fg(t);return Math.abs(i)<qs?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=co(this.AB,this.AC),this.bisector=zo($c(this.AB.eq(Gg)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),n=Rc(s),o=Qi.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,i*o)}projectBevel(){const t=[];return(this.alpha%Rr==0?[this.B]:[this.B,this.C]).forEach((e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))})),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),n=this.options.strokeUniform?lo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return lo(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new x(Qi.getOrthogonalRotationFactor(this.bisector),Qi.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((n=>{nl(n,t,e)&&i.push(this.A.add(n))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:n,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(xt(s)),Math.tan(xt(n))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new x(Math.sqrt(Math.max(h**2-d**2,0)),d),p=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),g=new x(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map((f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f))).forEach((f=>{nl(f,t,e)&&i.push(this.applySkew(this.A).add(f))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Rr==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),n=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Ls(s,o)>0,l=a?s:n,c=a?n:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector})))}}class dl extends Wc{constructor(t,e,i){super(i),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Rc(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Qi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(zo(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((e=>this.applySkew(e)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const Xg=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(r.length===0)return i;const s=r.reduce(((n,o)=>(n[n.length-1].eq(o)||n.push(new x(o)),n)),[new x(r[0])]);if(s.length===1)e=!0;else if(!e){const n=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,(a=>!a.eq(n)));s.splice(o+1)}return s.forEach(((n,o,a)=>{let l,c;o===0?(c=a[1],l=e?n:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?n:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new dl(n,n,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new Qi(n,l,c,t).project()):i.push(...new dl(n,o===0?c:l,t).project())})),i},No=r=>{const t={};return Object.keys(r).forEach((e=>{t[e]={},Object.keys(r[e]).forEach((i=>{t[e][i]=_({},r[e][i])}))})),t},Kg=r=>r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let _s;const Uo=r=>{if(_s||_s||(_s="Intl"in an()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),_s){const t=_s.segment(r);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return qg(r)},qg=r=>{const t=[];for(let e,i=0;i<r.length;i++)(e=Zg(r,i))!==!1&&t.push(e);return t},Zg=(r,t)=>{const e=r.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return r.charAt(t);if(55296<=e&&e<=56319){if(r.length<=t+1)throw"High surrogate without following low surrogate";const s=r.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return r.charAt(t)+r.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=r.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Wo=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return r.fill!==t.fill||r.stroke!==t.stroke||r.strokeWidth!==t.strokeWidth||r.fontSize!==t.fontSize||r.fontFamily!==t.fontFamily||r.fontWeight!==t.fontWeight||r.fontStyle!==t.fontStyle||r.textDecorationThickness!==t.textDecorationThickness||r.textBackgroundColor!==t.textBackgroundColor||r.deltaY!==t.deltaY||e&&(r.overline!==t.overline||r.underline!==t.underline||r.linethrough!==t.linethrough)},Jg=(r,t)=>{const e=t.split(`
2357
- `),i=[];let s=-1,n={};r=No(r);for(let o=0;o<e.length;o++){const a=Uo(e[o]);if(r[o])for(let l=0;l<a.length;l++){s++;const c=r[o][l];c&&Object.keys(c).length>0&&(Wo(n,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),n=c||{}}else s+=a.length,n={}}return i},Qg=(r,t)=>{if(!Array.isArray(r))return No(r);const e=t.split(Mo),i={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=Uo(e[o]);for(let l=0;l<a.length;l++)s++,r[n]&&r[n].start<=s&&s<r[n].end&&(i[o]=i[o]||{},i[o][l]=_({},r[n].style),s===r[n].end-1&&n++)}return i},_i=["display","transform",Dt,"fill-opacity","fill-rule","opacity",re,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function ul(r,t){const e=r.nodeName,i=r.getAttribute("class"),s=r.getAttribute("id"),n="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+n,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+n,"i"),t=t.replace(o,"")}return t.length===0}function tf(r,t){let e=!0;const i=ul(r,t.pop());return i&&t.length&&(e=(function(s,n){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&n.length;)a&&(o=n.pop()),a=ul(s=s.parentElement,o);return n.length===0})(r,t)),i&&e&&t.length===0}const ef=r=>{var t;return(t=pg[r])!==null&&t!==void 0?t:r},sf=new RegExp("(".concat(Se,")"),"gi"),rf=r=>Wr(r.replace(sf," $1 ").replace(/,/gi," "));var pl,gl,fl,ml,bl,vl,yl;const Xt="(".concat(Se,")"),nf=String.raw(pl||(pl=He(["(skewX)(",")"],["(skewX)\\(","\\)"])),Xt),of=String.raw(gl||(gl=He(["(skewY)(",")"],["(skewY)\\(","\\)"])),Xt),af=String.raw(fl||(fl=He(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Xt,Xt,Xt),lf=String.raw(ml||(ml=He(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Xt,Xt),cf=String.raw(bl||(bl=He(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Xt,Xt),hf=String.raw(vl||(vl=He(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Xt,Xt,Xt,Xt,Xt,Xt),Yo="(?:".concat(hf,"|").concat(cf,"|").concat(af,"|").concat(lf,"|").concat(nf,"|").concat(of,")"),df="(?:".concat(Yo,"*)"),uf=String.raw(yl||(yl=He(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),df),pf=new RegExp(uf),gf=new RegExp(Yo),ff=new RegExp(Yo,"g");function ho(r){const t=[];if(!(r=rf(r).replace(/\s*([()])\s*/gi,"$1"))||r&&!pf.test(r))return[...qt];for(const e of r.matchAll(ff)){const i=gf.exec(e[0]);if(!i)continue;let s=qt;const n=i.filter((g=>!!g)),[,o,...a]=n,[l,c,h,d,u,p]=a.map((g=>parseFloat(g)));switch(o){case"translate":s=Zs(l,c);break;case Io:s=os({angle:l},{x:c,y:h});break;case cn:s=jo(l,c);break;case rs:s=_c(l);break;case ns:s=xc(l);break;case"matrix":s=[l,c,h,d,u,p]}t.push(s)}return Fo(t)}function mf(r,t,e,i){const s=Array.isArray(t);let n,o=t;if(r!==Dt&&r!==re||t!==se){if(r==="strokeUniform")return t==="non-scaling-stroke";if(r==="strokeDashArray")o=t===se?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(r==="transformMatrix")o=e&&e.transformMatrix?Rt(e.transformMatrix,ho(t)):ho(t);else if(r==="visible")o=t!==se&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(r==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(r==="textAnchor")o=t==="start"?Y:t==="end"?_t:V;else if(r==="charSpacing"||r===Ri)n=Ji(t,i)/i*1e3;else if(r==="paintFirst"){const a=t.indexOf(Dt),l=t.indexOf(re);o=Dt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=re)}else{if(r==="href"||r==="xlink:href"||r==="font"||r==="id")return t;if(r==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(Ji):Ji(t,i)}}else o="";return!s&&isNaN(n)?o:n}function bf(r,t){const e=r.match(ug);if(!e)return;const i=e[1],s=e[3],n=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),n&&(t.fontSize=Ji(n)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function vf(r,t){r.replace(/;\s*$/,"").split(";").forEach((e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()}))}function yf(r){const t={},e=r.getAttribute("style");return e&&(typeof e=="string"?vf(e,t):(function(i,s){Object.entries(i).forEach((n=>{let[o,a]=n;a!==void 0&&(s[o.toLowerCase()]=a)}))})(e,t)),t}const _f={stroke:"strokeOpacity",fill:"fillOpacity"};function ni(r,t,e){if(!r)return{};let i,s={},n=Do;r.parentNode&&rl.test(r.parentNode.nodeName)&&(s=ni(r.parentElement,t,e),s.fontSize&&(i=n=Ji(s.fontSize)));const o=_(_(_({},t.reduce(((c,h)=>{const d=r.getAttribute(h);return d&&(c[h]=d),c}),{})),(function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};for(const u in h)tf(c,u.split(" "))&&(d=_(_({},d),h[u]));return d})(r,e)),yf(r));o[jn]&&r.setAttribute(jn,o[jn]),o[Fn]&&(i=Ji(o[Fn],n),o[Fn]="".concat(i));const a={};for(const c in o){const h=ef(c),d=mf(h,o[c],s,i);a[h]=d}a&&a.font&&bf(a.font,a);const l=_(_({},s),a);return rl.test(r.nodeName)?l:(function(c){const h=Vt.getDefaults();return Object.entries(_f).forEach((d=>{let[u,p]=d;if(c[p]===void 0||c[u]==="")return;if(c[u]===void 0){if(!h[u])return;c[u]=h[u]}if(c[u].indexOf("url(")===0)return;const g=new K(c[u]);c[u]=g.setAlpha(et(g.getAlpha()*c[p],2)).toRgba()})),c})(l)}const xf=["left","top","width","height","visible"],Yc=["rx","ry"];class ee extends Vt{static getDefaults(){return _(_({},super.getDefaults()),ee.ownDefaults)}constructor(t){super(),Object.assign(this,ee.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:i}=this,s=-e/2,n=-i/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(s+o,n),t.lineTo(s+e-o,n),l&&t.bezierCurveTo(s+e-ai*o,n,s+e,n+ai*a,s+e,n+a),t.lineTo(s+e,n+i-a),l&&t.bezierCurveTo(s+e,n+i-ai*a,s+e-ai*o,n+i,s+e-o,n+i),t.lineTo(s+o,n+i),l&&t.bezierCurveTo(s+ai*o,n+i,s,n+i-ai*a,s,n+i-a),t.lineTo(s,n+a),l&&t.bezierCurveTo(s,n+ai*a,s+ai*o,n,s+o,n),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Yc,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
2358
- `)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=rt(s,xf);return new this(_(_(_({},e),h),{},{left:n,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(ee,"type","Rect"),v(ee,"cacheProperties",[...ri,...Yc]),v(ee,"ownDefaults",{rx:0,ry:0}),v(ee,"ATTRIBUTE_NAMES",[..._i,"x","y","rx","ry","width","height"]),A.setClass(ee),A.setSVGClass(ee);const Ge="initialization",Gr="added",Go="removed",Xr="imperative",Gc=(r,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:n,group:o}=t,a=o&&o!==r?un(o.calcTransformMatrix(),r.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?ng(new x(i,i),void 0,r.calcTransformMatrix()):Lo,d=!e&&c?i:0,u=Ro(s+d,n+d,Fo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class fn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Ge||e===Xr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Ge&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Xr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=Ke(t.map((d=>Gc(s,d))).reduce(((d,u)=>d.concat(u)),[])),c=new x(a,l),h=new x(n,o).add(c.scalarDivide(2));if(i===Ge){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(fn,"type","strategy");class uo extends fn{shouldPerformLayout(t){return!0}}v(uo,"type","fit-content"),A.setClass(uo);const wf=["strategy"],Cf=["target","strategy","bubbles","prevStrategy"],Xc="layoutManager";class Ys{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new uo;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[zr,dc,Hs,uc,ln,pc,Br,Up,Wp].map((s=>t.on(s,(n=>this.performLayout(s===zr?{type:"object_modified",trigger:s,e:n,target:i}:{type:"object_modifying",trigger:s,e:n,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((i=>i())),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach((e=>this.unsubscribe(e,t)))}subscribeTargets(t){t.targets.forEach((e=>this.subscribe(e,t)))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===Ge||i===Gr?this.subscribeTargets(t):i===Go&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Xr&&t.deep){const n=rt(t,wf);e.forEachObject((o=>o.layoutManager&&o.layoutManager.performLayout(_(_({},n),{},{bubbles:!1,target:o}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,n=i.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===Ge?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=n,h=o.subtract(a).add(l).transform(s===Ge?qt:Ce(e.calcOwnMatrix()),!0).add(c);return{result:n,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:n}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Ge?i.set({left:(o=t.x)!==null&&o!==void 0?o:n.x+s.x*Tt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*Tt(i.originY)}):(i.setPositionByOrigin(n,V,V),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:n,prevStrategy:o}=t,a=rt(t,Cf),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;n&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((e=>e.forEach((i=>i())))),t.clear()}toObject(){return{type:Xc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}A.setClass(Ys,Xc);const Sf=["type","objects","layoutManager"];class Tf extends Ys{performLayout(){}}class fi extends gc(Vt){static getDefaults(){return _(_({},super.getDefaults()),fi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,fi.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((s=>{this.enterGroup(s,!1)})),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Ys,this.layoutManager.performLayout({type:Ge,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(mi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(mi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...s);return this._onAfterObjectsChange(Gr,s),n}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const n=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...n);return this._onAfterObjectsChange(Gr,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Go,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),t==="canvas"&&i!==e&&(this._objects||[]).forEach((s=>{s._set(t,e)})),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const n=s.indexOf(i);n>-1&&(s.splice(n,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Nr(t,Rt(Ce(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Nr(t,Rt(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=Vt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let n=0;n<this._objects.length;n++){var s;const o=this._objects[n];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ce(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(_({target:this,type:Xr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(s){return!s.excludeFromExport})).map((function(s){const n=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=n,o}))}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject((t=>{this._watchObject(!1,t),t.dispose()})),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=ee.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
2356
+ `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=qe.ownDefaults;return this.includeDefaultValues?t:$o(t,((i,s)=>i!==e[s]))}static async fromObject(t){return new this(t)}}v(qe,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(qe,"type","shadow"),A.setClass(qe,"shadow");const es=(r,t,e)=>Math.max(r,Math.min(t,e)),bg=[ie,Y,oe,be,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",rs,ns],ri=[Dt,re,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],vg={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Y,originY:ie,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Dt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},yg=(r,t,e,i)=>-e*Math.cos(r/i*qs)+e+t,_g=()=>!1;class Ho{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:n=0,easing:o=yg,onStart:a=Ar,onChange:l=Ar,onComplete:c=Ar,abort:h=_g,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=n,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>Mr(t)),this.delay):Mr(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:n}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Mr(this.tick)))}register(){Hr.push(this)}unregister(){Hr.remove(this)}abort(){this._state="aborted",this.unregister()}}const xg=["startValue","endValue"];class wg extends Ho{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(y(y({},rt(t,xg)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const Cg=["startValue","endValue"];class Sg extends Ho{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(y(y({},rt(t,Cg)),{},{startValue:e,byValue:i.map(((s,n)=>s-e[n]))}))}calculate(t){const e=this.startValue.map(((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Tg=["startValue","endValue","easing","onChange","onComplete","abort"],Eg=(r,t,e,i)=>t+e*(1-Math.cos(r/i*qs)),$n=r=>r&&((t,e,i)=>r(new K(t).toRgba(),e,i));class Og extends Ho{constructor(t){let{startValue:e,endValue:i,easing:s=Eg,onChange:n,onComplete:o,abort:a}=t,l=rt(t,Tg);const c=new K(e).getSource(),h=new K(i).getSource();super(y(y({},l),{},{startValue:c,byValue:h.map(((d,u)=>d-c[u])),easing:s,onChange:$n(n),onComplete:$n(o),abort:$n(a)}))}calculate(t){const[e,i,s,n]=this.startValue.map(((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l))),o=[...[e,i,s].map(Math.round),es(0,n,1)];return{value:o,valueProgress:o.map(((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0)).find((a=>a!==0))||0}}}function Bc(r){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(r)?new Sg(r):new wg(r);return t.start(),t}function kg(r){const t=new Og(r);return t.start(),t}class lt{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some((e=>e.eq(t)))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((s=>!this.includes(s)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const n=ao(e,i),o=ao(e,t).divide(n);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new x(t).setX(Math.min(t.x-1,...e.map((n=>n.x))));let s=0;for(let n=0;n<e.length;n++){const o=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,i);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,p=c*u-h*d,g=a*u-l*d,f=h*a-c*l;if(f!==0){const m=p/f,b=g/f;return(n||0<=m&&m<=1)&&(o||0<=b&&b<=1)?new lt("Intersection").append(new x(t.x+m*a,t.y+m*l)):new lt}if(p===0||g===0){const m=n||o||lt.isPointContained(t,i,s)||lt.isPointContained(e,i,s)||lt.isPointContained(i,t,e)||lt.isPointContained(s,t,e);return new lt(m?"Coincident":void 0)}return new lt("Parallel")}static intersectSegmentLine(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new lt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=lt.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;n.append(...c.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,i){return lt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new lt,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=lt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(n.push(c),i.append(a,l)):i.append(...c.points)}return n.length>0&&n.length===t.length?new lt("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),n=e.max(i),o=new x(n.x,s.y),a=new x(s.x,n.y);return lt.intersectPolygonPolygon(t,[s,o,n,a])}}class Pg extends fc{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?Qt(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=Qt(t,Ce(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map((a=>Qt(a,o)))}return n}intersectsWithRect(t,e){return lt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=lt.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:n,height:o}=this.getBoundingRect();return i>=t.x&&i+n<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return lt.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y))||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Ke(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(oe,t),this._set(be,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?ei(vc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||qt.concat()}calcACoords(){const t=os({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Zs(e,i),n=Rt(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Qt({x:-a,y:-l},n),tr:Qt({x:a,y:-l},n),bl:Qt({x:-a,y:l},n),br:Qt({x:a,y:l},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Tt(this.originX),Tt(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((n,o)=>n===i[o]))?s.value:(this.group&&(e=Rt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=Zp(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=y({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,n=0;this.strokeUniform&&(s=0,n=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new x(o*e.scaleX,a*e.scaleY):Ro(o,a,hn(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,i,s,n){let o=t.x,a=t.y;const l=Tt(s)-Tt(e),c=Tt(n)-Tt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,i){if(e===V&&i===V)return t;const s=this.translateToGivenOrigin(t,e,i,V,V);return this.angle?s.rotate(xt(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,V,V,e,i);return this.angle?s.rotate(xt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Qt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),n=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Y,ie)}}const Ag=["type"],Dg=["extraParam"];let Ue=class Lr extends Pg{static getDefaults(){return Lr.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){mi("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Lr.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ti(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=W.maxCacheSideLimit,n=W.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=W.perfLimitSizeTotal)return e<n&&(t.width=n),i<n&&(t.height=n),t;const o=e/i,[a,l]=Ds.limitDimsByArea(o),c=es(n,a,s),h=es(n,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:n,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==n||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(n,o),this.zoomX=n,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Vr(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==oe&&t!==be||(e=this._constrainScale(e)),t===oe&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof qe||(e=new qe(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===re&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const i=ve(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((n=>{n.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const n=Ce(this.calcTransformMatrix());s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(ge(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[n,,,o]=(i==null?void 0:i.viewportTransform)||qt,a=n*s,l=o*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*W.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!ge(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,n):t.transform(1,0,0,1,s,n),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===re?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/n,a=s.y/this.scaleY/n,l=ve({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/n,s.zoomY/this.scaleY/n),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/s.zoomX,n*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(A.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Ec(this),i=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?hc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(_=>new Js(_,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&rg(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&og(this,this.getViewportTransform()),this.setCoords();const c=ti(),h=this.getBoundingRect(),d=this.shadow,u=new x;if(d){const _=d.blur,w=d.nonScaling?new x(1,1):this.getObjectScaling();u.x=2*Math.round(n(d.offsetX)+_)*n(w.x),u.y=2*Math.round(n(d.offsetY)+_)*n(w.y)}const p=h.width+u.x,g=h.height+u.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new x(f.width/2,f.height/2),V,V);const m=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const b=f.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),b}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return mc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return bc(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:n,y:o}=this.getRelativeCenterPoint();this.originX=V,this.originY=V,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=n,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Hr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Re().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((i,s)=>{let[n,o]=s;return i[n]=this._animate(n,o,e),i}),{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),n=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=y(y({},i),{},{target:this,startValue:a??s.reduce(((d,u)=>d[u]),this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(d,u,p)=>{s.reduce(((g,f,m)=>(m===s.length-1&&(g[f]=d),g[f])),this),l&&l(d,u,p)},onComplete:(d,u,p)=>{this.setCoords(),c&&c(d,u,p)}});return n?kg(h):Bc(h)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(e.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,n=0;n<e.length;n++){if(s=e[n],s===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,n)],otherFork:[t,...i.slice(0,o)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),n=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(n);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Lr.customProperties,this.constructor.customProperties||[]);let e;const i=W.NUM_FRACTION_DIGITS,{clipPath:s,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:_,strokeUniform:w,strokeMiterLimit:S,scaleX:T,scaleY:k,angle:O,flipX:E,flipY:P,opacity:R,visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:X,skewY:Q}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const N=Ut=>et(Ut,i),Ct=y(y({},as(this,t)),{},{type:this.constructor.type,version:so,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:Ya(n)?n.toObject():n,stroke:Ya(o)?o.toObject():o,strokeWidth:N(f),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:_,strokeUniform:w,strokeMiterLimit:N(S),scaleX:N(T),scaleY:N(k),angle:N(O),flipX:E,flipY:P,opacity:N(R),shadow:a&&a.toObject(),visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:N(X),skewY:N(Q)},e?{clipPath:e}:null);return this.includeDefaultValues?Ct:this._removeDefaultValues(Ct)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return $o(t,((s,n)=>{if(n===Y||n===ie||n==="type")return!0;const o=i[n];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=rt(t,Ag),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,n=rt(i,Dg);return dn(e,n).then((o=>s?(delete o[s],new this(e[s],o)):new this(o)))}static fromObject(t,e){return this._fromObject(t,e)}};v(Ue,"stateProperties",bg),v(Ue,"cacheProperties",ri),v(Ue,"ownDefaults",vg),v(Ue,"type","FabricObject"),v(Ue,"colorProperties",[Dt,re,"backgroundColor"]),v(Ue,"customProperties",[]),A.setClass(Ue),A.setClass(Ue,"object");const ls=(r,t,e)=>(i,s,n,o)=>{const a=t(i,s,n,o);return a&&Oc(r,y(y({},Pc(i,s,n,o)),e)),a};function cs(r){return(t,e,i,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(l,o,a),h=r(t,e,i,s);return n.setPositionByOrigin(c,e.originX,e.originY),h}}const ll=ls(Hs,cs(((r,t,e,i)=>{const s=Bo(t,t.originX,t.originY,e,i);if(Tt(t.originX)===Tt(V)||Tt(t.originX)===Tt(_t)&&s.x<0||Tt(t.originX)===Tt(Y)&&s.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=kc(t)?2:1,l=n.width,c=Math.abs(s.x*a/n.scaleX)-o;return n.set("width",Math.max(c,1)),l!==n.width}return!1})));function Mg(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n>o?(h=n,r.scale(1,o/n),u=e*n/o):o>n?(h=o,r.scale(n/o,1),d=t*o/n):h=n,r.beginPath(),r.arc(d,u,h/2,0,Rr,!1),r[l](),c&&r.stroke(),r.restore()}function Ig(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=n/2,d=o/2;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r.translate(t,e);const u=s.getTotalAngle();r.rotate(xt(u)),r["".concat(l,"Rect")](-h,-d,n,o),c&&r.strokeRect(-h,-d,n,o),r.restore()}class _e{constructor(t){v(this,"visible",!0),v(this,"actionName",cn),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var n;let{tl:o,tr:a,br:l,bl:c}=s;return((n=e.canvas)===null||n===void 0?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&lt.isPointInPolygon(i,[o,a,l,c])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,n,o){const a=Fo([Zs(i,s),os({angle:t}),jo((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,i,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Mg.call(this,t,e,i,s,n):Ig.call(this,t,e,i,s,n)}}const Lg=(r,t,e)=>e.lockRotation?Ur:t.cursorStyle,Fg=ls(uc,cs(((r,t,e,i)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Ee(s,"lockRotation"))return!1;const d=Math.atan2(o-h.y,n-h.x),u=Math.atan2(i-h.y,e-h.x);let p=ei(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,m=s.snapThreshold||f,b=Math.ceil(p/f)*f,_=Math.floor(p/f)*f;Math.abs(p-_)<m?p=_:Math.abs(p-b)<m&&(p=b)}p<0&&(p=360+p),p%=360;const g=s.angle!==p;return s.angle=p,g})));function zc(r,t){const e=t.canvas,i=r[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Hc(r,t,e){const i=Ee(r,"lockScalingX"),s=Ee(r,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:n,height:o,strokeWidth:a}=r;return n===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const jg=["e","se","s","sw","w","nw","n","ne","e"],Ts=(r,t,e)=>{const i=zc(r,e);if(Hc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Ur;const s=Ac(e,t);return"".concat(jg[s],"-resize")};function Vo(r,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=zc(r,n);let l,c,h,d,u,p;if(Hc(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Bo(t,t.originX,t.originY,e,i),u=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=p),Ee(n,"lockScalingFlip")&&(t.signX!==u||t.signY!==p))return!1;if(d=n._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:b}=t,_=m/(Math.abs(d.x*b.scaleX/n.scaleX)+Math.abs(d.y*b.scaleY/n.scaleY));c=b.scaleX*_,h=b.scaleY*_}else c=Math.abs(l.x*n.scaleX/d.x),h=Math.abs(l.y*n.scaleY/d.y);kc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=qa(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=qa(t.originY),h*=-1,t.signY=p)}const g=n.scaleX,f=n.scaleY;return o?(o==="x"&&n.set(oe,c),o==="y"&&n.set(be,h)):(!Ee(n,"lockScalingX")&&n.set(oe,c),!Ee(n,"lockScalingY")&&n.set(be,h)),g!==n.scaleX||f!==n.scaleY}const nr=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i)))),$g=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"x"})))),Rg=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"y"})))),Bg=["target","ex","ey","skewingSide"],Rn={x:{counterAxis:"y",scale:oe,skew:rs,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:be,skew:ns,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},zg=["ns","nesw","ew","nwse"],Hg=(r,t,e)=>{if(t.x!==0&&Ee(e,"lockSkewingY")||t.y!==0&&Ee(e,"lockSkewingX"))return Ur;const i=Ac(e,t)%4;return"".concat(zg[i],"-resize")};function Vc(r,t,e,i,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Rn[r];if(Ee(n,l))return!1;const{origin:d,flip:u}=Rn[o],p=Tt(e[d])*(n[u]?-1:1),g=-Math.sign(p)*(n[h]?-1:1),f=.5*-((n[c]===0&&Bo(e,V,V,i,s)[r]>0||n[c]>0?1:-1)*g)+.5;return ls(pc,cs(((b,_,w,S)=>(function(T,k,O){let{target:E,ex:P,ey:R,skewingSide:L}=k,F=rt(k,Bg);const{skew:H}=Rn[T],M=O.subtract(new x(P,R)).divide(new x(E.scaleX,E.scaleY))[T],U=E[H],X=F[H],Q=Math.tan(xt(X)),N=T==="y"?E._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:E._getTransformedDimensions({scaleX:1,scaleY:1}).y,Ct=2*M*L/Math.max(N,1)+Q,Ut=ei(Math.atan(Ct));E.set(H,Ut);const Wt=U!==E[H];if(Wt&&T==="y"){const{skewX:Pe,scaleX:de}=E,Ft=E._getTransformedDimensions({skewY:U}),Ae=E._getTransformedDimensions(),ae=Pe!==0?Ft.x/Ae.x:1;ae!==1&&E.set(oe,ae*de)}return Wt})(r,_,new x(w,S)))))(t,y(y({},e),{},{[a]:f,skewingSide:g}),i,s)}const Vg=(r,t,e,i)=>Vc("x",r,t,e,i),Ng=(r,t,e,i)=>Vc("y",r,t,e,i);function gn(r,t){return r[t.canvas.altActionKey]}const or=(r,t,e)=>{const i=gn(r,e);return t.x===0?i?rs:be:t.y===0?i?ns:oe:""},Xi=(r,t,e)=>gn(r,e)?Hg(0,t,e):Ts(r,t,e),cl=(r,t,e,i)=>gn(r,t.target)?Ng(r,t,e,i):$g(r,t,e,i),hl=(r,t,e,i)=>gn(r,t.target)?Vg(r,t,e,i):Rg(r,t,e,i),Nc=()=>({ml:new _e({x:-.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mr:new _e({x:.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mb:new _e({x:0,y:.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),mt:new _e({x:0,y:-.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),tl:new _e({x:-.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),tr:new _e({x:.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),bl:new _e({x:-.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),br:new _e({x:.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),mtr:new _e({x:0,y:-.5,actionHandler:Fg,cursorStyleHandler:Lg,offsetY:-40,withConnection:!0,actionName:Io})}),Ug=()=>({mr:new _e({x:.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs}),ml:new _e({x:-.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs})}),Wg=()=>y(y({},Nc()),Ug());class Ws extends Ue{static getDefaults(){return y(y({},super.getDefaults()),Ws.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ws.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Nc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(cn))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[n,o]=i[s],a=this.controls[n];if(a.shouldActivate(n,this,t,e?o.touchCorner:o.corner))return this.__corner=n,{key:n,control:a,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Zs(e.x,e.y),s=os({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Rt(i,s),o=Rt(t,n),a=Rt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Vr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl(((d,u)=>{const p=d.positionHandler(c,a,this,d);h[u]=Object.assign(p,this._calcCornerCoords(d,p))})),h}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(xt(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=y({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,n=y({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=n.hasBorders,l=n.hasControls,c=Rt(o,this.calcTransformMatrix()),h=Vr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(xt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const n=Ro(this.width,this.height,hn(e)),o=this.isStrokeAccountedForInDimensions()?Lo:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=n.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,n)=>{s.withConnection&&s.getVisibility(this,n)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:n,cornerColor:o}=this,a=y({cornerStrokeColor:s,cornerDashArray:n,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}})),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach((e=>{let[i,s]=e;return this.setControlVisible(i,s)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,n=this.height+4;return e.clearRect(-s/2,-n/2,s,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Uc(r,t){return t.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),r}v(Ws,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Vt extends Ws{}Uc(Vt,[Dc]),A.setClass(Vt),A.setClass(Vt,"object");const Yg=(r,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:n}=r.getImageData(t-i,e-i,s,s);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0};class Wc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const i=ao(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(xt(this.options.skewY)),e.x+=e.y*Math.tan(xt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Gg=new x;class Qi extends Wc{static getOrthogonalRotationFactor(t,e){const i=e?co(t,e):fg(t);return Math.abs(i)<qs?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=co(this.AB,this.AC),this.bisector=zo($c(this.AB.eq(Gg)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),n=Rc(s),o=Qi.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,i*o)}projectBevel(){const t=[];return(this.alpha%Rr==0?[this.B]:[this.B,this.C]).forEach((e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))})),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),n=this.options.strokeUniform?lo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return lo(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new x(Qi.getOrthogonalRotationFactor(this.bisector),Qi.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((n=>{nl(n,t,e)&&i.push(this.A.add(n))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:n,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(xt(s)),Math.tan(xt(n))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new x(Math.sqrt(Math.max(h**2-d**2,0)),d),p=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),g=new x(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map((f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f))).forEach((f=>{nl(f,t,e)&&i.push(this.applySkew(this.A).add(f))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Rr==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),n=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Ls(s,o)>0,l=a?s:n,c=a?n:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector})))}}class dl extends Wc{constructor(t,e,i){super(i),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Rc(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Qi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(zo(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((e=>this.applySkew(e)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const Xg=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(r.length===0)return i;const s=r.reduce(((n,o)=>(n[n.length-1].eq(o)||n.push(new x(o)),n)),[new x(r[0])]);if(s.length===1)e=!0;else if(!e){const n=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,(a=>!a.eq(n)));s.splice(o+1)}return s.forEach(((n,o,a)=>{let l,c;o===0?(c=a[1],l=e?n:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?n:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new dl(n,n,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new Qi(n,l,c,t).project()):i.push(...new dl(n,o===0?c:l,t).project())})),i},No=r=>{const t={};return Object.keys(r).forEach((e=>{t[e]={},Object.keys(r[e]).forEach((i=>{t[e][i]=y({},r[e][i])}))})),t},Kg=r=>r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let _s;const Uo=r=>{if(_s||_s||(_s="Intl"in an()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),_s){const t=_s.segment(r);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return qg(r)},qg=r=>{const t=[];for(let e,i=0;i<r.length;i++)(e=Zg(r,i))!==!1&&t.push(e);return t},Zg=(r,t)=>{const e=r.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return r.charAt(t);if(55296<=e&&e<=56319){if(r.length<=t+1)throw"High surrogate without following low surrogate";const s=r.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return r.charAt(t)+r.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=r.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Wo=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return r.fill!==t.fill||r.stroke!==t.stroke||r.strokeWidth!==t.strokeWidth||r.fontSize!==t.fontSize||r.fontFamily!==t.fontFamily||r.fontWeight!==t.fontWeight||r.fontStyle!==t.fontStyle||r.textDecorationThickness!==t.textDecorationThickness||r.textBackgroundColor!==t.textBackgroundColor||r.deltaY!==t.deltaY||e&&(r.overline!==t.overline||r.underline!==t.underline||r.linethrough!==t.linethrough)},Jg=(r,t)=>{const e=t.split(`
2357
+ `),i=[];let s=-1,n={};r=No(r);for(let o=0;o<e.length;o++){const a=Uo(e[o]);if(r[o])for(let l=0;l<a.length;l++){s++;const c=r[o][l];c&&Object.keys(c).length>0&&(Wo(n,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),n=c||{}}else s+=a.length,n={}}return i},Qg=(r,t)=>{if(!Array.isArray(r))return No(r);const e=t.split(Mo),i={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=Uo(e[o]);for(let l=0;l<a.length;l++)s++,r[n]&&r[n].start<=s&&s<r[n].end&&(i[o]=i[o]||{},i[o][l]=y({},r[n].style),s===r[n].end-1&&n++)}return i},_i=["display","transform",Dt,"fill-opacity","fill-rule","opacity",re,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function ul(r,t){const e=r.nodeName,i=r.getAttribute("class"),s=r.getAttribute("id"),n="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+n,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+n,"i"),t=t.replace(o,"")}return t.length===0}function tf(r,t){let e=!0;const i=ul(r,t.pop());return i&&t.length&&(e=(function(s,n){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&n.length;)a&&(o=n.pop()),a=ul(s=s.parentElement,o);return n.length===0})(r,t)),i&&e&&t.length===0}const ef=r=>{var t;return(t=pg[r])!==null&&t!==void 0?t:r},sf=new RegExp("(".concat(Se,")"),"gi"),rf=r=>Wr(r.replace(sf," $1 ").replace(/,/gi," "));var pl,gl,fl,ml,bl,vl,yl;const Xt="(".concat(Se,")"),nf=String.raw(pl||(pl=He(["(skewX)(",")"],["(skewX)\\(","\\)"])),Xt),of=String.raw(gl||(gl=He(["(skewY)(",")"],["(skewY)\\(","\\)"])),Xt),af=String.raw(fl||(fl=He(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Xt,Xt,Xt),lf=String.raw(ml||(ml=He(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Xt,Xt),cf=String.raw(bl||(bl=He(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Xt,Xt),hf=String.raw(vl||(vl=He(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Xt,Xt,Xt,Xt,Xt,Xt),Yo="(?:".concat(hf,"|").concat(cf,"|").concat(af,"|").concat(lf,"|").concat(nf,"|").concat(of,")"),df="(?:".concat(Yo,"*)"),uf=String.raw(yl||(yl=He(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),df),pf=new RegExp(uf),gf=new RegExp(Yo),ff=new RegExp(Yo,"g");function ho(r){const t=[];if(!(r=rf(r).replace(/\s*([()])\s*/gi,"$1"))||r&&!pf.test(r))return[...qt];for(const e of r.matchAll(ff)){const i=gf.exec(e[0]);if(!i)continue;let s=qt;const n=i.filter((g=>!!g)),[,o,...a]=n,[l,c,h,d,u,p]=a.map((g=>parseFloat(g)));switch(o){case"translate":s=Zs(l,c);break;case Io:s=os({angle:l},{x:c,y:h});break;case cn:s=jo(l,c);break;case rs:s=_c(l);break;case ns:s=xc(l);break;case"matrix":s=[l,c,h,d,u,p]}t.push(s)}return Fo(t)}function mf(r,t,e,i){const s=Array.isArray(t);let n,o=t;if(r!==Dt&&r!==re||t!==se){if(r==="strokeUniform")return t==="non-scaling-stroke";if(r==="strokeDashArray")o=t===se?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(r==="transformMatrix")o=e&&e.transformMatrix?Rt(e.transformMatrix,ho(t)):ho(t);else if(r==="visible")o=t!==se&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(r==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(r==="textAnchor")o=t==="start"?Y:t==="end"?_t:V;else if(r==="charSpacing"||r===Ri)n=Ji(t,i)/i*1e3;else if(r==="paintFirst"){const a=t.indexOf(Dt),l=t.indexOf(re);o=Dt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=re)}else{if(r==="href"||r==="xlink:href"||r==="font"||r==="id")return t;if(r==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(Ji):Ji(t,i)}}else o="";return!s&&isNaN(n)?o:n}function bf(r,t){const e=r.match(ug);if(!e)return;const i=e[1],s=e[3],n=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),n&&(t.fontSize=Ji(n)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function vf(r,t){r.replace(/;\s*$/,"").split(";").forEach((e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()}))}function yf(r){const t={},e=r.getAttribute("style");return e&&(typeof e=="string"?vf(e,t):(function(i,s){Object.entries(i).forEach((n=>{let[o,a]=n;a!==void 0&&(s[o.toLowerCase()]=a)}))})(e,t)),t}const _f={stroke:"strokeOpacity",fill:"fillOpacity"};function ni(r,t,e){if(!r)return{};let i,s={},n=Do;r.parentNode&&rl.test(r.parentNode.nodeName)&&(s=ni(r.parentElement,t,e),s.fontSize&&(i=n=Ji(s.fontSize)));const o=y(y(y({},t.reduce(((c,h)=>{const d=r.getAttribute(h);return d&&(c[h]=d),c}),{})),(function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};for(const u in h)tf(c,u.split(" "))&&(d=y(y({},d),h[u]));return d})(r,e)),yf(r));o[jn]&&r.setAttribute(jn,o[jn]),o[Fn]&&(i=Ji(o[Fn],n),o[Fn]="".concat(i));const a={};for(const c in o){const h=ef(c),d=mf(h,o[c],s,i);a[h]=d}a&&a.font&&bf(a.font,a);const l=y(y({},s),a);return rl.test(r.nodeName)?l:(function(c){const h=Vt.getDefaults();return Object.entries(_f).forEach((d=>{let[u,p]=d;if(c[p]===void 0||c[u]==="")return;if(c[u]===void 0){if(!h[u])return;c[u]=h[u]}if(c[u].indexOf("url(")===0)return;const g=new K(c[u]);c[u]=g.setAlpha(et(g.getAlpha()*c[p],2)).toRgba()})),c})(l)}const xf=["left","top","width","height","visible"],Yc=["rx","ry"];class ee extends Vt{static getDefaults(){return y(y({},super.getDefaults()),ee.ownDefaults)}constructor(t){super(),Object.assign(this,ee.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:i}=this,s=-e/2,n=-i/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(s+o,n),t.lineTo(s+e-o,n),l&&t.bezierCurveTo(s+e-ai*o,n,s+e,n+ai*a,s+e,n+a),t.lineTo(s+e,n+i-a),l&&t.bezierCurveTo(s+e,n+i-ai*a,s+e-ai*o,n+i,s+e-o,n+i),t.lineTo(s+o,n+i),l&&t.bezierCurveTo(s+ai*o,n+i,s,n+i-ai*a,s,n+i-a),t.lineTo(s,n+a),l&&t.bezierCurveTo(s,n+ai*a,s+ai*o,n,s+o,n),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Yc,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
2358
+ `)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=rt(s,xf);return new this(y(y(y({},e),h),{},{left:n,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(ee,"type","Rect"),v(ee,"cacheProperties",[...ri,...Yc]),v(ee,"ownDefaults",{rx:0,ry:0}),v(ee,"ATTRIBUTE_NAMES",[..._i,"x","y","rx","ry","width","height"]),A.setClass(ee),A.setSVGClass(ee);const Ge="initialization",Gr="added",Go="removed",Xr="imperative",Gc=(r,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:n,group:o}=t,a=o&&o!==r?un(o.calcTransformMatrix(),r.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?ng(new x(i,i),void 0,r.calcTransformMatrix()):Lo,d=!e&&c?i:0,u=Ro(s+d,n+d,Fo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class fn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Ge||e===Xr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Ge&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Xr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=Ke(t.map((d=>Gc(s,d))).reduce(((d,u)=>d.concat(u)),[])),c=new x(a,l),h=new x(n,o).add(c.scalarDivide(2));if(i===Ge){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(fn,"type","strategy");class uo extends fn{shouldPerformLayout(t){return!0}}v(uo,"type","fit-content"),A.setClass(uo);const wf=["strategy"],Cf=["target","strategy","bubbles","prevStrategy"],Xc="layoutManager";class Ys{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new uo;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=y(y({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[zr,dc,Hs,uc,ln,pc,Br,Up,Wp].map((s=>t.on(s,(n=>this.performLayout(s===zr?{type:"object_modified",trigger:s,e:n,target:i}:{type:"object_modifying",trigger:s,e:n,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((i=>i())),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach((e=>this.unsubscribe(e,t)))}subscribeTargets(t){t.targets.forEach((e=>this.subscribe(e,t)))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===Ge||i===Gr?this.subscribeTargets(t):i===Go&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Xr&&t.deep){const n=rt(t,wf);e.forEachObject((o=>o.layoutManager&&o.layoutManager.performLayout(y(y({},n),{},{bubbles:!1,target:o}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,n=i.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===Ge?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=n,h=o.subtract(a).add(l).transform(s===Ge?qt:Ce(e.calcOwnMatrix()),!0).add(c);return{result:n,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:n}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Ge?i.set({left:(o=t.x)!==null&&o!==void 0?o:n.x+s.x*Tt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*Tt(i.originY)}):(i.setPositionByOrigin(n,V,V),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:n,prevStrategy:o}=t,a=rt(t,Cf),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;n&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(y(y({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((e=>e.forEach((i=>i())))),t.clear()}toObject(){return{type:Xc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}A.setClass(Ys,Xc);const Sf=["type","objects","layoutManager"];class Tf extends Ys{performLayout(){}}class fi extends gc(Vt){static getDefaults(){return y(y({},super.getDefaults()),fi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,fi.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((s=>{this.enterGroup(s,!1)})),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Ys,this.layoutManager.performLayout({type:Ge,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(mi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(mi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...s);return this._onAfterObjectsChange(Gr,s),n}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const n=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...n);return this._onAfterObjectsChange(Gr,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Go,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),t==="canvas"&&i!==e&&(this._objects||[]).forEach((s=>{s._set(t,e)})),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const n=s.indexOf(i);n>-1&&(s.splice(n,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Nr(t,Rt(Ce(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Nr(t,Rt(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=Vt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let n=0;n<this._objects.length;n++){var s;const o=this._objects[n];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ce(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(y({target:this,type:Xr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(s){return!s.excludeFromExport})).map((function(s){const n=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=n,o}))}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return y(y(y({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject((t=>{this._watchObject(!1,t),t.dispose()})),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=ee.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
2359
2359
  `],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
2360
- `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:n}=t,o=rt(t,Sf);return Promise.all([Vs(s,e),dn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,_(_(_({},o),c),{},{layoutManager:new Tf}));if(n){const d=A.getClass(n.type),u=A.getClass(n.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Ys;return h.layoutManager.subscribeTargets({type:Ge,target:h,targets:h.getObjects()}),h.setCoords(),h}))}}v(fi,"type","Group"),v(fi,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),A.setClass(fi);const Ef=(r,t)=>Math.min(t.width/r.width,t.height/r.height),Of=(r,t)=>Math.max(t.width/r.width,t.height/r.height),po="\\s*,?\\s*",xs="".concat(po,"(").concat(Se,")"),kf="".concat(xs).concat(xs).concat(xs).concat(po,"([01])").concat(po,"([01])").concat(xs).concat(xs),Pf={m:"l",M:"L"},Af=(r,t,e,i,s,n,o,a,l,c,h)=>{const d=Je(r),u=Qe(r),p=Je(t),g=Qe(t),f=e*s*p-i*n*g+o,b=i*s*p+e*n*g+a;return["C",c+l*(-e*s*u-i*n*d),h+l*(-i*s*u+e*n*d),f+l*(e*s*g+i*n*p),b+l*(i*s*g-e*n*p),f,b]},_l=(r,t,e,i)=>{const s=Math.atan2(t,r),n=Math.atan2(i,e);return n>=s?n-s:2*Math.PI-(s-n)};function xl(r,t,e,i,s,n,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),Ds.boundsOfCurveCache[l]))return Ds.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*r-12*e+6*s,g=-3*r+9*e-9*s+3*o,f=3*e-3*r;for(let S=0;S<2;++S){if(S>0&&(p=6*t-12*i+6*n,g=-3*t+9*i-9*n+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const P=-f/p;0<P&&P<1&&d.push(P);continue}const T=p*p-4*f*g;if(T<0)continue;const O=c(T),k=(-p+O)/(2*g);0<k&&k<1&&d.push(k);const E=(-p-O)/(2*g);0<E&&E<1&&d.push(E)}let b=d.length;const m=b,y=Kc(r,t,e,i,s,n,o,a);for(;b--;){const{x:S,y:T}=y(d[b]);u[0][b]=S,u[1][b]=T}u[0][m]=r,u[1][m]=t,u[0][m+1]=o,u[1][m+1]=a;const w=[new x(Math.min(...u[0]),Math.min(...u[1])),new x(Math.max(...u[0]),Math.max(...u[1]))];return W.cachesBoundsOfCurve&&(Ds.boundsOfCurveCache[l]=w),w}const Df=(r,t,e)=>{let[i,s,n,o,a,l,c,h]=e;const d=((u,p,g,f,b,m,y)=>{if(g===0||f===0)return[];let w=0,S=0,T=0;const O=Math.PI,k=y*Ao,E=Qe(k),P=Je(k),R=.5*(-P*u-E*p),L=.5*(-P*p+E*u),F=g**2,H=f**2,M=L**2,U=R**2,X=F*H-F*M-H*U;let Q=Math.abs(g),N=Math.abs(f);if(X<0){const vt=Math.sqrt(1-X/(F*H));Q*=vt,N*=vt}else T=(b===m?-1:1)*Math.sqrt(X/(F*M+H*U));const Ct=T*Q*L/N,Ut=-T*N*R/Q,Wt=P*Ct-E*Ut+.5*u,Pe=E*Ct+P*Ut+.5*p;let de=_l(1,0,(R-Ct)/Q,(L-Ut)/N),Ft=_l((R-Ct)/Q,(L-Ut)/N,(-R-Ct)/Q,(-L-Ut)/N);m===0&&Ft>0?Ft-=2*O:m===1&&Ft<0&&(Ft+=2*O);const Ae=Math.ceil(Math.abs(Ft/O*2)),ae=[],At=Ft/Ae,jt=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let le=de+At;for(let vt=0;vt<Ae;vt++)ae[vt]=Af(de,le,P,E,Q,N,Wt,Pe,jt,w,S),w=ae[vt][5],S=ae[vt][6],de=le,le+=At;return ae})(c-r,h-t,s,n,a,l,o);for(let u=0,p=d.length;u<p;u++)d[u][1]+=r,d[u][2]+=t,d[u][3]+=r,d[u][4]+=t,d[u][5]+=r,d[u][6]+=t;return d},Mf=r=>{let t=0,e=0,i=0,s=0;const n=[];let o,a=0,l=0;for(const c of r){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Df(t,e,h).forEach((u=>n.push(u))),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(n.push(d),o=d[0]):o=""}return n},Kr=(r,t,e,i)=>Math.sqrt((e-r)**2+(i-t)**2),Kc=(r,t,e,i,s,n,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),d=(p=>3*p*(1-p)**2)(l),u=(p=>(1-p)**3)(l);return new x(o*c+s*h+e*d+r*u,a*c+n*h+i*d+t*u)},qc=r=>r**2,Zc=r=>2*r*(1-r),Jc=r=>(1-r)**2,If=(r,t,e,i,s,n,o,a)=>l=>{const c=qc(l),h=Zc(l),d=Jc(l),u=3*(d*(e-r)+h*(s-e)+c*(o-s)),p=3*(d*(i-t)+h*(n-i)+c*(a-n));return Math.atan2(p,u)},Lf=(r,t,e,i,s,n)=>o=>{const a=qc(o),l=Zc(o),c=Jc(o);return new x(s*a+e*l+r*c,n*a+i*l+t*c)},Ff=(r,t,e,i,s,n)=>o=>{const a=1-o,l=2*(a*(e-r)+o*(s-e)),c=2*(a*(i-t)+o*(n-i));return Math.atan2(c,l)},wl=(r,t,e)=>{let i=new x(t,e),s=0;for(let n=1;n<=100;n+=1){const o=r(n/100);s+=Kr(i.x,i.y,o.x,o.y),i=o}return s},jf=(r,t)=>{let e,i=0,s=0,n={x:r.x,y:r.y},o=_({},n),a=.01,l=0;const c=r.iterator,h=r.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=Kr(n.x,n.y,o.x,o.y),e+s>t?(i-=a,a/=2):(n=o,i+=a,s+=e);return _(_({},o),{},{angle:h(l)})},Qc=r=>{let t,e,i=0,s=0,n=0,o=0,a=0;const l=[];for(const c of r){const h={x:s,y:n,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=n=c[2];break;case"L":e=h,e.length=Kr(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=Kc(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=If(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=wl(t,s,n),s=c[5],n=c[6];break;case"Q":t=Lf(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ff(s,n,c[1],c[2],c[3],c[4]),e.length=wl(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Kr(s,n,o,a),s=o,n=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:n}),l},$f=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qc(r),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],n=t/s.length,o=r[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return _(_({},new x(s.x,s.y).lerp(new x(s.destX,s.destY),n)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return _(_({},new x(s.x,s.y).lerp(new x(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return jf(s,t)}},Rf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Cl=new RegExp(kf,"g"),Bf=new RegExp(Se,"gi"),zf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Hf=r=>{var t;const e=[],i=(t=r.match(Rf))!==null&&t!==void 0?t:[];for(const s of i){const n=s[0];if(n==="z"||n==="Z"){e.push([n]);continue}const o=zf[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){Cl.lastIndex=0;for(let l=null;l=Cl.exec(s);)a.push(...l.slice(1))}else a=s.match(Bf)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Pf[n];c[0]=l>0&&h?h:n;for(let d=0;d<o;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},Vf=(r,t)=>r.map((e=>e.map(((i,s)=>s===0||t===void 0?i:et(i,t))).join(" "))).join(" ");function go(r,t){const e=r.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach((i=>{let[s,n]=i;return e.setProperty(s,n)})))}class Nf extends Tc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(n,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=ti();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=ss().createElement("div");return t.setAttribute("data-fabric","wrapper"),go(t,{position:"relative"}),Xa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;go(t,_(_({},i),{},{"touch-action":s?"manipulation":se})),Xa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Sc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),no(this.upper.el,t),no(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Re().dispose(this.upper.el),delete this.upper,delete this.container}}class mn extends Js{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),mn.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Nf(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter((e=>!e.group&&e!==t)).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+s,-i+s),n.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(n),t.selectionBackgroundColor=o,n.restore();const a=Math.round(s*this.getRetinaScaling());return Yg(n,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((i=>!!i&&t[i]===!0)):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===cn||e===oe||e===be||e===Hs?s=this.centeredScaling||t.centeredScaling:e===Io&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=_t:["mr","tr","br"].includes(e)&&(i.x=Y),["tl","mt","tr"].includes(e)?i.y=ro:["bl","mb","br"].includes(e)&&(i.y=ie)),i}_setupCurrentTransform(t,e,i){var s;const n=e.group?Zi(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):lg,c=((p,g,f,b)=>{if(!g||!p)return"drag";const m=b.controls[g];return m.getActionName(f,m,b)})(i,o,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:V,y:V}:this._getOriginFromCorner(e,o),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:d.x,originY:d.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:xt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},Ec(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i).transform(this.viewportTransform),a=new x(e+s,i+n).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),d=Math.max(o.x,a.x),u=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Vt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,oo(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const n=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=n,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),n=t.padding/s;if(n){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),d=Je(h)*n,u=Qe(h)*n,p=d+u,g=d-u;i=[new x(o.x-g,o.y-p),new x(a.x+p,a.y-g),new x(l.x+g,l.y+p),new x(c.x-p,c.y+g)]}return lt.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Zi(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Dr(s)&&s.subTargetCheck){const n=this._searchPossibleTargets(s._objects,e);n&&this.targets.push(n)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Dr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let n=s.length-1;n>0;n--){const o=s[n];if(!Dr(o)||!o.interactive)return o}return s[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let n=eg(t),o=s.width||0,a=s.height||0;o&&a||(ie in s&&ro in s&&(a=Math.abs(s.top-s.bottom)),_t in s&&Y in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=Zi(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new x(1,1):new x(i.width/o,i.height/a);return n.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ti(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Ei(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const n=this.getActiveObjects(),o=[],a=[];t.forEach((l=>{n.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))})),n.forEach((l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))})),t.length>0&&n.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):n.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ei(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),Ei(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(zr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ei(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,i);return t.set(s),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ei(e)&&this._activeObject===e){const i=as(t,["angle","flipX","flipY",Y,oe,be,rs,ns,ie]);return sg(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(mn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Uf{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),Yi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Wf=["target","oldTarget","fireCanvas","e"],ce={passive:!1},Ui=(r,t)=>{const e=r.getViewportPoint(t),i=r.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},li=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.addEventListener(...e)},ue=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.removeEventListener(...e)},Yf={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class fo extends mn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Uf(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((e=>{this[e]=this[e].bind(this)})),this.addOrRemove(li,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(Cc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,ce),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel,{passive:!1}),t(i,"contextmenu",this._onContextMenu),t(i,"click",this._onClick),t(i,"dblclick",this._onClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,ce)}removeListeners(){this.addOrRemove(ue,"remove");const t=this._getEventPrefix(),e=we(this.upperCanvasEl);ue(e,"".concat(t,"up"),this._onMouseUp),ue(e,"touchend",this._onTouchEnd,ce),ue(e,"".concat(t,"move"),this._onMouseMove,ce),ue(e,"touchmove",this._onMouseMove,ce),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},Ui(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach((s=>{this.fire("mouse:out",_(_({},i),{},{target:s})),s&&s.fire("mouseout",_({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},Ui(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void li(this.upperCanvasEl,"drag",this._onDragProgress)}Ka(t)}_renderDragEffects(t,e,i){let s=!1;const n=this._dropTarget;n&&n!==e&&n!==i&&(n.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==se,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ue(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),n=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:n,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,n,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},Ui(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&Ka(t),this._basicEventHandler("contextmenu",s),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,n=this._getEventPrefix(),o=we(s);li(o,"touchend",this._onTouchEnd,ce),e&&li(o,"touchmove",this._onMouseMove,ce),ue(s,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ue(e,"".concat(i,"move"),this._onMouseMove,ce);const s=we(e);li(s,"".concat(i,"up"),this._onMouseUp),li(s,"".concat(i,"move"),this._onMouseMove,ce)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=we(this.upperCanvasEl);ue(i,"touchend",this._onTouchEnd,ce),ue(i,"touchmove",this._onMouseMove,ce),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{li(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const s=we(this.upperCanvasEl);ue(s,"".concat(i,"up"),this._onMouseUp),ue(s,"".concat(i,"move"),this._onMouseMove,ce),li(e,"".concat(i,"move"),this._onMouseMove,ce)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,n=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=n===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(n)||!h&&n===this._activeObject)}if(n){const h=n.findControl(this.getViewportPoint(t),oo(t)),{key:d,control:u}=h||{};if(l=d,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,t),c=!0;else if(u){const p=u.getMouseUpHandler(t,n,u);p&&(a=this.getScenePoint(t),p.call(u,t,i,a.x,a.y))}n.isMoving=!1}if(i&&(i.target!==n||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,n),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let n=0;n<s.length;n++)s[n]!==i&&s[n].fire(t,e);return e}_handleEvent(t,e,i){const s=this._target,n=this.targets||[],o=_(_(_({e:t,target:s,subTargets:n},Ui(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?i:{});this.fire("mouse:".concat(e),o),s&&s.fire("mouse".concat(e),o);for(let a=0;a<n.length;a++)n[a]!==s&&n[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,i=!!e&&e===this._activeObject;const{button:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:i}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let n=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,n=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(i=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),oo(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,i);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:i}),n&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Zi(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)n[a]===e||s[a]&&s[a]===i||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:n[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:n,e:o}=e,a=rt(e,Wf);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=Yf[t],u=s!==i;if(s&&u){const p=_(_({},a),{},{e:o,target:s,nextTarget:i},Ui(this,o));n&&this.fire(d,p),s.fire(c,p)}if(i&&u){const p=_(_({},a),{},{e:o,target:i,previousTarget:s},Ui(this,o));n&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,n=s.group?Zi(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,n),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:n,target:o}=e,a=!!n&&n(t,e,i.x,i.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Ei(this._activeObject)?this._activeObject:null,n=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(n){const o=n.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((o=>{i=o.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Ei(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const n=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(n,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(n,t)}else{i.isEditing&&i.exitEditing();const n=new(A.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(i,e),this._hoveredTarget=n,this._setActiveObject(n,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i),a=o.add(new x(s,n)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter((u=>!u.onSelect({e:t}))).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=A.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:i}=this.elements;i.ctx=void 0;const s=super.toCanvasElement(t,e);return i.ctx=i.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const th={x1:0,y1:0,x2:0,y2:0},Gf=_(_({},th),{},{r1:0,r2:0}),Ki=(r,t)=>isNaN(r)&&typeof t=="number"?t:r;function eh(r){return r&&/%$/.test(r)&&Number.isFinite(parseFloat(r))}function ih(r,t){const e=typeof r=="number"?r:typeof r=="string"?parseFloat(r)/(eh(r)?100:1):NaN;return es(0,Ki(e,t),1)}const Xf=/\s*;\s*/,Kf=/\s*:\s*/;function qf(r,t){let e,i;const s=r.getAttribute("style");if(s){const o=s.split(Xf);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Kf).map((h=>h.trim()));l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const n=new K(e||r.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:ih(r.getAttribute("offset"),0),color:n.toRgb(),opacity:Ki(parseFloat(i||r.getAttribute("stop-opacity")||""),1)*n.getAlpha()*t}}function Zf(r,t){const e=[],i=r.getElementsByTagName("stop"),s=ih(t,1);for(let n=i.length;n--;)e.push(qf(i[n],s));return e}function sh(r){return r.nodeName==="linearGradient"||r.nodeName==="LINEARGRADIENT"?"linear":"radial"}function rh(r){return r.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function ye(r,t){return r.getAttribute(t)}function Jf(r,t){return(function(e,i){let s,{width:n,height:o,gradientUnits:a}=i;return Object.entries(e).reduce(((l,c)=>{let[h,d]=c;if(d==="Infinity")s=1;else if(d==="-Infinity")s=0;else{const u=typeof d=="string";s=u?parseFloat(d):d,u&&eh(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(sh(r)==="linear"?(function(e){return{x1:ye(e,"x1")||0,y1:ye(e,"y1")||0,x2:ye(e,"x2")||"100%",y2:ye(e,"y2")||0}})(r):(function(e){return{x1:ye(e,"fx")||ye(e,"cx")||"50%",y1:ye(e,"fy")||ye(e,"cy")||"50%",r1:0,x2:ye(e,"cx")||"50%",y2:ye(e,"cy")||"50%",r2:ye(e,"r")||"50%"}})(r),_(_({},t),{},{gradientUnits:rh(r)}))}class ar{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?Gf:th),s),colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(bi()):bi()})}addColorStop(t){for(const e in t){const i=new K(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},as(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map((e=>_({},e))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():qt.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((d=>_({},d))).sort(((d,u)=>d.offset-u.offset));let a=-this.offsetX,l=-this.offsetY;var c;n==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Ns(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',p,'" y2="',g,`">
2361
- `)}else if(this.type==="radial"){const{x1:d,y1:u,x2:p,y2:g,r1:f,r2:b}=this.coords,m=f>b;i.push("<radialGradient ",h,' cx="',m?d:p,'" cy="',m?u:g,'" r="',m?f:b,'" fx="',m?p:d,'" fy="',m?g:u,`">
2362
- `),m&&(o.reverse(),o.forEach((w=>{w.offset=1-w.offset})));const y=Math.min(f,b);if(y>0){const w=y/Math.max(f,b);o.forEach((S=>{S.offset+=w*(1-S.offset)}))}}return o.forEach((d=>{let{color:u,offset:p,opacity:g}=d;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',u,g!==void 0?";stop-opacity: "+g:";",`"/>
2360
+ `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:n}=t,o=rt(t,Sf);return Promise.all([Vs(s,e),dn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new Tf}));if(n){const d=A.getClass(n.type),u=A.getClass(n.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Ys;return h.layoutManager.subscribeTargets({type:Ge,target:h,targets:h.getObjects()}),h.setCoords(),h}))}}v(fi,"type","Group"),v(fi,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),A.setClass(fi);const Ef=(r,t)=>Math.min(t.width/r.width,t.height/r.height),Of=(r,t)=>Math.max(t.width/r.width,t.height/r.height),po="\\s*,?\\s*",xs="".concat(po,"(").concat(Se,")"),kf="".concat(xs).concat(xs).concat(xs).concat(po,"([01])").concat(po,"([01])").concat(xs).concat(xs),Pf={m:"l",M:"L"},Af=(r,t,e,i,s,n,o,a,l,c,h)=>{const d=Je(r),u=Qe(r),p=Je(t),g=Qe(t),f=e*s*p-i*n*g+o,m=i*s*p+e*n*g+a;return["C",c+l*(-e*s*u-i*n*d),h+l*(-i*s*u+e*n*d),f+l*(e*s*g+i*n*p),m+l*(i*s*g-e*n*p),f,m]},_l=(r,t,e,i)=>{const s=Math.atan2(t,r),n=Math.atan2(i,e);return n>=s?n-s:2*Math.PI-(s-n)};function xl(r,t,e,i,s,n,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),Ds.boundsOfCurveCache[l]))return Ds.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*r-12*e+6*s,g=-3*r+9*e-9*s+3*o,f=3*e-3*r;for(let S=0;S<2;++S){if(S>0&&(p=6*t-12*i+6*n,g=-3*t+9*i-9*n+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const P=-f/p;0<P&&P<1&&d.push(P);continue}const T=p*p-4*f*g;if(T<0)continue;const k=c(T),O=(-p+k)/(2*g);0<O&&O<1&&d.push(O);const E=(-p-k)/(2*g);0<E&&E<1&&d.push(E)}let m=d.length;const b=m,_=Kc(r,t,e,i,s,n,o,a);for(;m--;){const{x:S,y:T}=_(d[m]);u[0][m]=S,u[1][m]=T}u[0][b]=r,u[1][b]=t,u[0][b+1]=o,u[1][b+1]=a;const w=[new x(Math.min(...u[0]),Math.min(...u[1])),new x(Math.max(...u[0]),Math.max(...u[1]))];return W.cachesBoundsOfCurve&&(Ds.boundsOfCurveCache[l]=w),w}const Df=(r,t,e)=>{let[i,s,n,o,a,l,c,h]=e;const d=((u,p,g,f,m,b,_)=>{if(g===0||f===0)return[];let w=0,S=0,T=0;const k=Math.PI,O=_*Ao,E=Qe(O),P=Je(O),R=.5*(-P*u-E*p),L=.5*(-P*p+E*u),F=g**2,H=f**2,M=L**2,U=R**2,X=F*H-F*M-H*U;let Q=Math.abs(g),N=Math.abs(f);if(X<0){const vt=Math.sqrt(1-X/(F*H));Q*=vt,N*=vt}else T=(m===b?-1:1)*Math.sqrt(X/(F*M+H*U));const Ct=T*Q*L/N,Ut=-T*N*R/Q,Wt=P*Ct-E*Ut+.5*u,Pe=E*Ct+P*Ut+.5*p;let de=_l(1,0,(R-Ct)/Q,(L-Ut)/N),Ft=_l((R-Ct)/Q,(L-Ut)/N,(-R-Ct)/Q,(-L-Ut)/N);b===0&&Ft>0?Ft-=2*k:b===1&&Ft<0&&(Ft+=2*k);const Ae=Math.ceil(Math.abs(Ft/k*2)),ae=[],At=Ft/Ae,jt=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let le=de+At;for(let vt=0;vt<Ae;vt++)ae[vt]=Af(de,le,P,E,Q,N,Wt,Pe,jt,w,S),w=ae[vt][5],S=ae[vt][6],de=le,le+=At;return ae})(c-r,h-t,s,n,a,l,o);for(let u=0,p=d.length;u<p;u++)d[u][1]+=r,d[u][2]+=t,d[u][3]+=r,d[u][4]+=t,d[u][5]+=r,d[u][6]+=t;return d},Mf=r=>{let t=0,e=0,i=0,s=0;const n=[];let o,a=0,l=0;for(const c of r){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Df(t,e,h).forEach((u=>n.push(u))),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(n.push(d),o=d[0]):o=""}return n},Kr=(r,t,e,i)=>Math.sqrt((e-r)**2+(i-t)**2),Kc=(r,t,e,i,s,n,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),d=(p=>3*p*(1-p)**2)(l),u=(p=>(1-p)**3)(l);return new x(o*c+s*h+e*d+r*u,a*c+n*h+i*d+t*u)},qc=r=>r**2,Zc=r=>2*r*(1-r),Jc=r=>(1-r)**2,If=(r,t,e,i,s,n,o,a)=>l=>{const c=qc(l),h=Zc(l),d=Jc(l),u=3*(d*(e-r)+h*(s-e)+c*(o-s)),p=3*(d*(i-t)+h*(n-i)+c*(a-n));return Math.atan2(p,u)},Lf=(r,t,e,i,s,n)=>o=>{const a=qc(o),l=Zc(o),c=Jc(o);return new x(s*a+e*l+r*c,n*a+i*l+t*c)},Ff=(r,t,e,i,s,n)=>o=>{const a=1-o,l=2*(a*(e-r)+o*(s-e)),c=2*(a*(i-t)+o*(n-i));return Math.atan2(c,l)},wl=(r,t,e)=>{let i=new x(t,e),s=0;for(let n=1;n<=100;n+=1){const o=r(n/100);s+=Kr(i.x,i.y,o.x,o.y),i=o}return s},jf=(r,t)=>{let e,i=0,s=0,n={x:r.x,y:r.y},o=y({},n),a=.01,l=0;const c=r.iterator,h=r.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=Kr(n.x,n.y,o.x,o.y),e+s>t?(i-=a,a/=2):(n=o,i+=a,s+=e);return y(y({},o),{},{angle:h(l)})},Qc=r=>{let t,e,i=0,s=0,n=0,o=0,a=0;const l=[];for(const c of r){const h={x:s,y:n,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=n=c[2];break;case"L":e=h,e.length=Kr(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=Kc(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=If(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=wl(t,s,n),s=c[5],n=c[6];break;case"Q":t=Lf(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ff(s,n,c[1],c[2],c[3],c[4]),e.length=wl(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Kr(s,n,o,a),s=o,n=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:n}),l},$f=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qc(r),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],n=t/s.length,o=r[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return y(y({},new x(s.x,s.y).lerp(new x(s.destX,s.destY),n)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return y(y({},new x(s.x,s.y).lerp(new x(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return jf(s,t)}},Rf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Cl=new RegExp(kf,"g"),Bf=new RegExp(Se,"gi"),zf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Hf=r=>{var t;const e=[],i=(t=r.match(Rf))!==null&&t!==void 0?t:[];for(const s of i){const n=s[0];if(n==="z"||n==="Z"){e.push([n]);continue}const o=zf[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){Cl.lastIndex=0;for(let l=null;l=Cl.exec(s);)a.push(...l.slice(1))}else a=s.match(Bf)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Pf[n];c[0]=l>0&&h?h:n;for(let d=0;d<o;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},Vf=(r,t)=>r.map((e=>e.map(((i,s)=>s===0||t===void 0?i:et(i,t))).join(" "))).join(" ");function go(r,t){const e=r.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach((i=>{let[s,n]=i;return e.setProperty(s,n)})))}class Nf extends Tc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(n,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=ti();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=ss().createElement("div");return t.setAttribute("data-fabric","wrapper"),go(t,{position:"relative"}),Xa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;go(t,y(y({},i),{},{"touch-action":s?"manipulation":se})),Xa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Sc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),no(this.upper.el,t),no(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Re().dispose(this.upper.el),delete this.upper,delete this.container}}class mn extends Js{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return y(y({},super.getDefaults()),mn.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Nf(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter((e=>!e.group&&e!==t)).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+s,-i+s),n.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(n),t.selectionBackgroundColor=o,n.restore();const a=Math.round(s*this.getRetinaScaling());return Yg(n,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((i=>!!i&&t[i]===!0)):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===cn||e===oe||e===be||e===Hs?s=this.centeredScaling||t.centeredScaling:e===Io&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=_t:["mr","tr","br"].includes(e)&&(i.x=Y),["tl","mt","tr"].includes(e)?i.y=ro:["bl","mb","br"].includes(e)&&(i.y=ie)),i}_setupCurrentTransform(t,e,i){var s;const n=e.group?Zi(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):lg,c=((p,g,f,m)=>{if(!g||!p)return"drag";const b=m.controls[g];return b.getActionName(f,b,m)})(i,o,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:V,y:V}:this._getOriginFromCorner(e,o),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:d.x,originY:d.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:xt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:y(y({},Ec(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i).transform(this.viewportTransform),a=new x(e+s,i+n).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),d=Math.max(o.x,a.x),u=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Vt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,oo(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const n=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=n,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),n=t.padding/s;if(n){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),d=Je(h)*n,u=Qe(h)*n,p=d+u,g=d-u;i=[new x(o.x-g,o.y-p),new x(a.x+p,a.y-g),new x(l.x+g,l.y+p),new x(c.x-p,c.y+g)]}return lt.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Zi(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Dr(s)&&s.subTargetCheck){const n=this._searchPossibleTargets(s._objects,e);n&&this.targets.push(n)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Dr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let n=s.length-1;n>0;n--){const o=s[n];if(!Dr(o)||!o.interactive)return o}return s[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let n=eg(t),o=s.width||0,a=s.height||0;o&&a||(ie in s&&ro in s&&(a=Math.abs(s.top-s.bottom)),_t in s&&Y in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=Zi(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new x(1,1):new x(i.width/o,i.height/a);return n.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ti(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Ei(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const n=this.getActiveObjects(),o=[],a=[];t.forEach((l=>{n.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))})),n.forEach((l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))})),t.length>0&&n.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):n.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ei(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),Ei(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(zr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ei(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,i);return t.set(s),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ei(e)&&this._activeObject===e){const i=as(t,["angle","flipX","flipY",Y,oe,be,rs,ns,ie]);return sg(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(mn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Uf{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),Yi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Wf=["target","oldTarget","fireCanvas","e"],ce={passive:!1},Ui=(r,t)=>{const e=r.getViewportPoint(t),i=r.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},li=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.addEventListener(...e)},ue=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.removeEventListener(...e)},Yf={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class fo extends mn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Uf(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((e=>{this[e]=this[e].bind(this)})),this.addOrRemove(li,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(Cc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,ce),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel,{passive:!1}),t(i,"contextmenu",this._onContextMenu),t(i,"click",this._onClick),t(i,"dblclick",this._onClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,ce)}removeListeners(){this.addOrRemove(ue,"remove");const t=this._getEventPrefix(),e=we(this.upperCanvasEl);ue(e,"".concat(t,"up"),this._onMouseUp),ue(e,"touchend",this._onTouchEnd,ce),ue(e,"".concat(t,"move"),this._onMouseMove,ce),ue(e,"touchmove",this._onMouseMove,ce),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=y({e:t},Ui(this,t));this.fire("mouse:out",y(y({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",y({},i)),this._hoveredTargets.forEach((s=>{this.fire("mouse:out",y(y({},i),{},{target:s})),s&&s.fire("mouseout",y({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",y({e:t},Ui(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void li(this.upperCanvasEl,"drag",this._onDragProgress)}Ka(t)}_renderDragEffects(t,e,i){let s=!1;const n=this._dropTarget;n&&n!==e&&n!==i&&(n.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==se,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ue(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),n=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:n,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,n,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",y({e:t,target:e,subTargets:i,dragSource:this._dragSource},Ui(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&Ka(t),this._basicEventHandler("contextmenu",s),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,n=this._getEventPrefix(),o=we(s);li(o,"touchend",this._onTouchEnd,ce),e&&li(o,"touchmove",this._onMouseMove,ce),ue(s,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ue(e,"".concat(i,"move"),this._onMouseMove,ce);const s=we(e);li(s,"".concat(i,"up"),this._onMouseUp),li(s,"".concat(i,"move"),this._onMouseMove,ce)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=we(this.upperCanvasEl);ue(i,"touchend",this._onTouchEnd,ce),ue(i,"touchmove",this._onMouseMove,ce),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{li(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const s=we(this.upperCanvasEl);ue(s,"".concat(i,"up"),this._onMouseUp),ue(s,"".concat(i,"move"),this._onMouseMove,ce),li(e,"".concat(i,"move"),this._onMouseMove,ce)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,n=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=n===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(n)||!h&&n===this._activeObject)}if(n){const h=n.findControl(this.getViewportPoint(t),oo(t)),{key:d,control:u}=h||{};if(l=d,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,t),c=!0;else if(u){const p=u.getMouseUpHandler(t,n,u);p&&(a=this.getScenePoint(t),p.call(u,t,i,a.x,a.y))}n.isMoving=!1}if(i&&(i.target!==n||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,n),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let n=0;n<s.length;n++)s[n]!==i&&s[n].fire(t,e);return e}_handleEvent(t,e,i){const s=this._target,n=this.targets||[],o=y(y(y({e:t,target:s,subTargets:n},Ui(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?i:{});this.fire("mouse:".concat(e),o),s&&s.fire("mouse".concat(e),o);for(let a=0;a<n.length;a++)n[a]!==s&&n[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,i=!!e&&e===this._activeObject;const{button:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:i}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let n=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,n=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(i=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),oo(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,i);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:i}),n&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Zi(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)n[a]===e||s[a]&&s[a]===i||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:n[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:n,e:o}=e,a=rt(e,Wf);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=Yf[t],u=s!==i;if(s&&u){const p=y(y({},a),{},{e:o,target:s,nextTarget:i},Ui(this,o));n&&this.fire(d,p),s.fire(c,p)}if(i&&u){const p=y(y({},a),{},{e:o,target:i,previousTarget:s},Ui(this,o));n&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,n=s.group?Zi(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,n),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:n,target:o}=e,a=!!n&&n(t,e,i.x,i.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Ei(this._activeObject)?this._activeObject:null,n=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(n){const o=n.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((o=>{i=o.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Ei(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const n=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(n,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(n,t)}else{i.isEditing&&i.exitEditing();const n=new(A.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(i,e),this._hoveredTarget=n,this._setActiveObject(n,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i),a=o.add(new x(s,n)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter((u=>!u.onSelect({e:t}))).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=A.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:i}=this.elements;i.ctx=void 0;const s=super.toCanvasElement(t,e);return i.ctx=i.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const th={x1:0,y1:0,x2:0,y2:0},Gf=y(y({},th),{},{r1:0,r2:0}),Ki=(r,t)=>isNaN(r)&&typeof t=="number"?t:r;function eh(r){return r&&/%$/.test(r)&&Number.isFinite(parseFloat(r))}function ih(r,t){const e=typeof r=="number"?r:typeof r=="string"?parseFloat(r)/(eh(r)?100:1):NaN;return es(0,Ki(e,t),1)}const Xf=/\s*;\s*/,Kf=/\s*:\s*/;function qf(r,t){let e,i;const s=r.getAttribute("style");if(s){const o=s.split(Xf);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Kf).map((h=>h.trim()));l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const n=new K(e||r.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:ih(r.getAttribute("offset"),0),color:n.toRgb(),opacity:Ki(parseFloat(i||r.getAttribute("stop-opacity")||""),1)*n.getAlpha()*t}}function Zf(r,t){const e=[],i=r.getElementsByTagName("stop"),s=ih(t,1);for(let n=i.length;n--;)e.push(qf(i[n],s));return e}function sh(r){return r.nodeName==="linearGradient"||r.nodeName==="LINEARGRADIENT"?"linear":"radial"}function rh(r){return r.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function ye(r,t){return r.getAttribute(t)}function Jf(r,t){return(function(e,i){let s,{width:n,height:o,gradientUnits:a}=i;return Object.entries(e).reduce(((l,c)=>{let[h,d]=c;if(d==="Infinity")s=1;else if(d==="-Infinity")s=0;else{const u=typeof d=="string";s=u?parseFloat(d):d,u&&eh(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(sh(r)==="linear"?(function(e){return{x1:ye(e,"x1")||0,y1:ye(e,"y1")||0,x2:ye(e,"x2")||"100%",y2:ye(e,"y2")||0}})(r):(function(e){return{x1:ye(e,"fx")||ye(e,"cx")||"50%",y1:ye(e,"fy")||ye(e,"cy")||"50%",r1:0,x2:ye(e,"cx")||"50%",y2:ye(e,"cy")||"50%",r2:ye(e,"r")||"50%"}})(r),y(y({},t),{},{gradientUnits:rh(r)}))}class ar{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:y(y({},e==="radial"?Gf:th),s),colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(bi()):bi()})}addColorStop(t){for(const e in t){const i=new K(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return y(y({},as(this,t)),{},{type:this.type,coords:y({},this.coords),colorStops:this.colorStops.map((e=>y({},e))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():qt.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((d=>y({},d))).sort(((d,u)=>d.offset-u.offset));let a=-this.offsetX,l=-this.offsetY;var c;n==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Ns(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',p,'" y2="',g,`">
2361
+ `)}else if(this.type==="radial"){const{x1:d,y1:u,x2:p,y2:g,r1:f,r2:m}=this.coords,b=f>m;i.push("<radialGradient ",h,' cx="',b?d:p,'" cy="',b?u:g,'" r="',b?f:m,'" fx="',b?p:d,'" fy="',b?g:u,`">
2362
+ `),b&&(o.reverse(),o.forEach((w=>{w.offset=1-w.offset})));const _=Math.min(f,m);if(_>0){const w=_/Math.max(f,m);o.forEach((S=>{S.offset+=w*(1-S.offset)}))}}return o.forEach((d=>{let{color:u,offset:p,opacity:g}=d;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',u,g!==void 0?";stop-opacity: "+g:";",`"/>
2363
2363
  `)})),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
2364
- `),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:n,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,n):t.createRadialGradient(e,i,o,s,n,a);return this.colorStops.forEach((c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new K(h).setAlpha(d).toRgba():h)})),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map((s=>_({},s))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=rh(t),n=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:sh(t),coords:Jf(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Zf(t,i.opacity),gradientUnits:s,gradientTransform:ho(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}v(ar,"type","Gradient"),A.setClass(ar,"gradient"),A.setClass(ar,"linear"),A.setClass(ar,"radial");const Qf=["type","source","patternTransform"];class Bn{get type(){return"pattern"}set type(t){mi("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=bi(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return _(_({},as(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:et(this.offsetX,W.NUM_FRACTION_DIGITS),offsetY:et(this.offsetY,W.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:n,id:o}=this,a=Ki(this.offsetX/e,0),l=Ki(this.offsetY/i,0),c=n==="repeat-y"||n==="no-repeat"?1+Math.abs(a||0):Ki(s.width/e,0),h=n==="repeat-x"||n==="no-repeat"?1+Math.abs(l||0):Ki(s.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
2365
- `)}static async fromObject(t,e){let{type:i,source:s,patternTransform:n}=t,o=rt(t,Qf);const a=await Ir(s,_(_({},e),{},{crossOrigin:o.crossOrigin}));return new this(_(_({},o),{},{patternTransform:n&&n.slice(0),source:a}))}}v(Bn,"type","Pattern"),A.setClass(Bn),A.setClass(Bn,"pattern");const tm=["path","left","top"],em=["d"];class Oi extends Vt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:n}=e,o=rt(e,tm);super(),Object.assign(this,Oi.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(Y,s),typeof n=="number"&&this.set(ie,n)}_setPath(t,e){this.path=Mf(Array.isArray(t)?t:Hf(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{path:this.path.map((e=>e.slice()))})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Vf(this.path,W.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
2366
- `)]}_getOffsetTransform(){const t=W.NUM_FRACTION_DIGITS;return" translate(".concat(et(-this.pathOffset.x,t),", ").concat(et(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,V,V)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,n=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],n=o[2],t.push({x:e,y:i},{x:s,y:n});break;case"M":s=o[1],n=o[2],e=s,i=n;break;case"C":t.push(...xl(s,n,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],n=o[6];break;case"Q":t.push(...xl(s,n,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],n=o[4];break;case"Z":s=e,n=i}return Ke(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new x(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{d:n}=s;return new this(n,_(_(_({},rt(s,em)),e),{},{left:void 0,top:void 0}))}}v(Oi,"type","Path"),v(Oi,"cacheProperties",[...ri,"path","fillRule"]),v(Oi,"ATTRIBUTE_NAMES",[..._i,"d"]),A.setClass(Oi),A.setSVGClass(Oi);const im=["left","top","radius"],nh=["radius","startAngle","endAngle","counterClockwise"];class We extends Vt{static getDefaults(){return _(_({},super.getDefaults()),We.ownDefaults)}constructor(t){super(),Object.assign(this,We.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,xt(this.startAngle),xt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(oe)}getRadiusY(){return this.get("radius")*this.get(be)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...nh,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
2364
+ `),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:n,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,n):t.createRadialGradient(e,i,o,s,n,a);return this.colorStops.forEach((c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new K(h).setAlpha(d).toRgba():h)})),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(y(y({},t),{},{colorStops:e?e.map((s=>y({},s))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=rh(t),n=e._findCenterFromElement();return new this(y({id:t.getAttribute("id")||void 0,type:sh(t),coords:Jf(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Zf(t,i.opacity),gradientUnits:s,gradientTransform:ho(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}v(ar,"type","Gradient"),A.setClass(ar,"gradient"),A.setClass(ar,"linear"),A.setClass(ar,"radial");const Qf=["type","source","patternTransform"];class Bn{get type(){return"pattern"}set type(t){mi("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=bi(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return y(y({},as(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:et(this.offsetX,W.NUM_FRACTION_DIGITS),offsetY:et(this.offsetY,W.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:n,id:o}=this,a=Ki(this.offsetX/e,0),l=Ki(this.offsetY/i,0),c=n==="repeat-y"||n==="no-repeat"?1+Math.abs(a||0):Ki(s.width/e,0),h=n==="repeat-x"||n==="no-repeat"?1+Math.abs(l||0):Ki(s.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
2365
+ `)}static async fromObject(t,e){let{type:i,source:s,patternTransform:n}=t,o=rt(t,Qf);const a=await Ir(s,y(y({},e),{},{crossOrigin:o.crossOrigin}));return new this(y(y({},o),{},{patternTransform:n&&n.slice(0),source:a}))}}v(Bn,"type","Pattern"),A.setClass(Bn),A.setClass(Bn,"pattern");const tm=["path","left","top"],em=["d"];class Oi extends Vt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:n}=e,o=rt(e,tm);super(),Object.assign(this,Oi.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(Y,s),typeof n=="number"&&this.set(ie,n)}_setPath(t,e){this.path=Mf(Array.isArray(t)?t:Hf(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),{},{path:this.path.map((e=>e.slice()))})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Vf(this.path,W.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
2366
+ `)]}_getOffsetTransform(){const t=W.NUM_FRACTION_DIGITS;return" translate(".concat(et(-this.pathOffset.x,t),", ").concat(et(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,V,V)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,n=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],n=o[2],t.push({x:e,y:i},{x:s,y:n});break;case"M":s=o[1],n=o[2],e=s,i=n;break;case"C":t.push(...xl(s,n,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],n=o[6];break;case"Q":t.push(...xl(s,n,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],n=o[4];break;case"Z":s=e,n=i}return Ke(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return y(y({},t),{},{pathOffset:new x(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{d:n}=s;return new this(n,y(y(y({},rt(s,em)),e),{},{left:void 0,top:void 0}))}}v(Oi,"type","Path"),v(Oi,"cacheProperties",[...ri,"path","fillRule"]),v(Oi,"ATTRIBUTE_NAMES",[..._i,"d"]),A.setClass(Oi),A.setSVGClass(Oi);const im=["left","top","radius"],nh=["radius","startAngle","endAngle","counterClockwise"];class We extends Vt{static getDefaults(){return y(y({},super.getDefaults()),We.ownDefaults)}constructor(t){super(),Object.assign(this,We.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,xt(this.startAngle),xt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(oe)}getRadiusY(){return this.get("radius")*this.get(be)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...nh,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
2367
2367
  `];{const{radius:e}=this,i=xt(this.startAngle),s=xt(this.endAngle),n=Je(i)*e,o=Qe(i)*e,a=Je(s)*e,l=Qe(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(n," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
2368
- `]}}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,radius:a=0}=s;return new this(_(_({},rt(s,im)),{},{radius:a,left:n-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}v(We,"type","Circle"),v(We,"cacheProperties",[...ri,...nh]),v(We,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(We,"ATTRIBUTE_NAMES",["cx","cy","r",..._i]),A.setClass(We),A.setSVGClass(We);const sm=["x1","y1","x2","y2"],rm=["x1","y1","x2","y2"],mo=["x1","x2","y1","y2"];class ki extends Vt{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,ki.ownDefaults),this.setOptions(n),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=n;typeof o=="number"&&this.set(Y,o),typeof a=="number"&&this.set(ie,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:n,top:o,width:a,height:l}=Ke([{x:t,y:e},{x:i,y:s}]),c=new x(n+a/2,o+l/2);this.setPositionByOrigin(c,V,V)}_set(t,e){return super._set(t,e),mo.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const i=t.strokeStyle;var s;ge(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new x((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:n,height:o}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*n/2,x2:a*-n/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,`" />
2369
- `)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{x1:n=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([n,o,a,l],rt(s,sm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:n}=t,o=rt(t,rm);return this._fromObject(_(_({},o),{},{points:[e,i,s,n]}),{extraParam:"points"})}}v(ki,"type","Line"),v(ki,"cacheProperties",[...ri,...mo]),v(ki,"ATTRIBUTE_NAMES",_i.concat(mo)),A.setClass(ki),A.setSVGClass(ki);class Di extends Vt{static getDefaults(){return _(_({},super.getDefaults()),Di.ownDefaults)}constructor(t){super(),Object.assign(this,Di.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}v(Di,"type","Triangle"),v(Di,"ownDefaults",{width:100,height:100}),A.setClass(Di),A.setSVGClass(Di);const oh=["rx","ry"];class Ye extends Vt{static getDefaults(){return _(_({},super.getDefaults()),Ye.ownDefaults)}constructor(t){super(),Object.assign(this,Ye.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(oe)}getRy(){return this.get("ry")*this.get(be)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...oh,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
2370
- `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Rr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function nm(r){if(!r)return[];const t=r.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(Ye,"type","Ellipse"),v(Ye,"cacheProperties",[...ri,...oh]),v(Ye,"ownDefaults",{rx:0,ry:0}),v(Ye,"ATTRIBUTE_NAMES",[..._i,"cx","cy","rx","ry"]),A.setClass(Ye),A.setSVGClass(Ye);const om=["left","top"],ah={exactBoundingBox:!1};class xe extends Vt{static getDefaults(){return _(_({},super.getDefaults()),xe.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,xe.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(Y,i),typeof s=="number"&&this.set(ie,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Xg(this.points,t,this.isOpen())}_calcDimensions(t){t=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map((c=>c.projectedPoint)):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new x,strokeOffset:new x,strokeDiff:new x};const i=Ke(e),s=hn(_(_({},t),{},{scaleX:1,scaleY:1})),n=Ke(this.points.map((c=>Qt(c,s,!0)))),o=new x(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(xt(this.skewX)),l-=a*Math.tan(xt(this.skewY))),_(_({},i),{},{pathOffset:new x(a,l),strokeOffset:new x(n.left,n.top).subtract(new x(i.left,i.top)).multiply(o),strokeDiff:new x(i.width,i.height).subtract(new x(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=Ke(this.points);return new x(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new x(e+s/2,i+n/2),V,V)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some((a=>this.strokeUniform||this.constructor.layoutProperties.includes(a)))){var e,i;const{width:a,height:l}=this._calcDimensions(t);o=new x((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,n;o=new x((s=t.width)!==null&&s!==void 0?s:this.width,(n=t.height)!==null&&n!==void 0?n:this.height)}return o.multiply(new x(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===oe||t===be)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{points:this.points.map((e=>{let{x:i,y:s}=e;return{x:i,y:s}}))})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=W.NUM_FRACTION_DIGITS;for(let n=0,o=this.points.length;n<o;n++)t.push(et(this.points[n].x-e,s),",",et(this.points[n].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
2371
- `)]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let n=0;n<e;n++){const o=this.points[n];t.lineTo(o.x-i,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(nm(t.getAttribute("points")),_(_({},rt(ni(t,this.ATTRIBUTE_NAMES,i),om)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(xe,"ownDefaults",ah),v(xe,"type","Polyline"),v(xe,"layoutProperties",[rs,ns,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(xe,"cacheProperties",[...ri,"points"]),v(xe,"ATTRIBUTE_NAMES",[..._i]),A.setClass(xe),A.setSVGClass(xe);class lr extends xe{isOpen(){return!1}}v(lr,"ownDefaults",ah),v(lr,"type","Polygon"),A.setClass(lr),A.setSVGClass(lr);class lh extends Vt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const n in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const n in i[s])if(i[s][n][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,n=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};n++,h[t]!==void 0?(s?h[t]!==s&&(o=!1):s=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&n===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,n;for(s in e){for(n in i=e[s],i)delete i[n][t],Object.keys(i[n]).length===0&&delete i[n];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const n=$o(_(_({},this._getStyleDeclaration(i,s)),e),(o=>o!==void 0));this._setStyleDeclaration(i,s,n)}getSelectionStyles(t,e,i){const s=[];for(let n=t;n<(e||t);n++)s.push(this.getStyleAtPosition(n,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return _(_({},as(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}v(lh,"_styleProperties",hg);const am=/ +/g,lm=/"/g;function zn(r,t,e,i,s){return" ".concat((function(n,o){let{left:a,top:l,width:c,height:h}=o,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:W.NUM_FRACTION_DIGITS;const u=Us(Dt,n,!1),[p,g,f,b]=[a,l,c,h].map((m=>et(m,d)));return"<rect ".concat(u,' x="').concat(p,'" y="').concat(g,'" width="').concat(f,'" height="').concat(b,'"></rect>')})(r,{left:t,top:e,width:i,height:s}),`
2372
- `)}const cm=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Hn;class Gt extends lh{static getDefaults(){return _(_({},super.getDefaults()),Gt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Gt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Qc(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Le)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,n,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Le||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,n=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=n.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(n[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===re?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case V:t.textBaseline="middle";break;case"ascender":t.textBaseline=ie;break;case"descender":t.textBaseline=ro}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,n,o){this._renderChars(t,e,i,s,n,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++){const a=this.getHeightOfLine(n);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",n)){s+=a;continue}const l=this._textLines[n].length,c=this._getLineLeftOffset(n);let h,d,u=0,p=0,g=this.getValueOfPropertyAt(n,0,"textBackgroundColor");const f=this.getHeightOfLineImpl(n);for(let b=0;b<l;b++){const m=this.__charBounds[n][b];d=this.getValueOfPropertyAt(n,b,"textBackgroundColor"),this.path?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=d,d&&t.fillRect(-m.width/2,-f*(1-this._fontSizeFraction),m.width,f),t.restore()):d!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=g,g&&t.fillRect(h,s,u,f),p=m.left,u=m.width,g=d):u+=m.kernedWidth}d&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,f)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const n=Ds.getFontCache(e),o=this._getFontDeclaration(e),a=i?i+t:t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,p;if(i&&n.has(i)&&(u=n.get(i)),n.has(t)&&(p=h=n.get(t)),l&&n.has(a)&&(d=n.get(a),p=d-u),h===void 0||u===void 0||d===void 0){const g=(function(){return Hn||(Hn=ve({width:0,height:0}).getContext("2d")),Hn})();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,n.set(t,h)),u===void 0&&l&&i&&(u=g.measureText(i).width,n.set(i,u)),l&&d===void 0&&(d=g.measureText(a).width,n.set(a,d),p=d-u)}return{width:h*c,kernedWidth:p*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const n=this.pathSide===_t,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const d=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Y:h=n?d-s:0;break;case V:h=(d-s)/2;break;case _t:h=n?0:d-s}h+=this.pathStartOffset*(n?-1:1);for(let u=n?l-1:0;n?u>=0:u<l;n?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,n=$f(s.path,i,s.segmentsInfo);e.renderLeft=n.x-s.pathOffset.x,e.renderTop=n.y-s.pathOffset.y,e.angle=n.angle+(this.pathSide===_t?Math.PI:0)}_getGraphemeBox(t,e,i,s,n){const o=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!n){const p=this.__charBounds[e][i-1];u.left=p.left+p.width+l.kernedWidth-l.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let i=this.getHeightOfChar(t,0);for(let s=1,n=this._textLines[t].length;s<n;s++)i=Math.max(this.getHeightOfChar(t,s),i);return e[t]=i*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,i=this._textLines.length;e<i;e++)t+=e===i-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),n=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],s+this._getLineLeftOffset(o),n+i+this.getHeightOfLineImpl(o),o),i+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Dt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,n,o){const a=this.textAlign.includes(Le),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",d=this.direction==="ltr"?1:-1,u=e.direction;let p,g,f,b,m,y="",w=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Y:_t),n-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,i.join(""),s,n),void e.restore();for(let S=0,T=i.length-1;S<=T;S++)b=S===T||this.charSpacing||l,y+=i[S],f=this.__charBounds[o][S],w===0?(s+=d*(f.kernedWidth-f.width),w+=f.width):w+=f.kernedWidth,a&&!b&&this._reSpaceAndTab.test(i[S])&&(b=!0),b||(p=p||this.getCompleteStyleDeclaration(o,S),g=this.getCompleteStyleDeclaration(o,S+1),b=Wo(p,g,!1)),b&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,o,S,y,-w/2,0),e.restore()):(m=s,this._renderChar(t,e,o,S,y,m,n)),y="",p=g,s+=d*w,w=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=ve({width:e,height:i}),n=s.getContext("2d");return s.width=e,s.height=i,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,i),n.lineTo(0,i),n.closePath(),n.translate(e/2,i/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,n;return ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,n=-this.height/2,t.translate(s,n),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:n}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,n,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(n,o-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(n,o-u.offsetX,a-u.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:n*i.size,deltaY:o+n*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,n=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===Le||s===Is&&!o||s===Ms&&!o||s===Yr&&!o?0:(s===V&&(a=i/2),s===_t&&(a=i),s===Is&&(a=i/2),s===Ms&&(a=i),n==="rtl"&&(s===_t||s===Le||s===Ms?a=0:s===Y||s===Yr?a=-i:s!==V&&s!==Is||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),n=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const d=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){i+=d;continue}const u=this._textLines[c],p=d/this.lineHeight,g=this._getLineLeftOffset(c);let f=0,b=0,m=this.getValueOfPropertyAt(c,0,e),y=this.getValueOfPropertyAt(c,0,Dt),w=this.getValueOfPropertyAt(c,0,Ri),S=m,T=y,O=w;const k=i+p*(1-this._fontSizeFraction);let E=this.getHeightOfChar(c,0),P=this.getValueOfPropertyAt(c,0,"deltaY");for(let F=0,H=u.length;F<H;F++){const M=this.__charBounds[c][F];S=this.getValueOfPropertyAt(c,F,e),T=this.getValueOfPropertyAt(c,F,Dt),O=this.getValueOfPropertyAt(c,F,Ri);const U=this.getHeightOfChar(c,F),X=this.getValueOfPropertyAt(c,F,"deltaY");if(n&&S&&T){const Q=this.fontSize*O/1e3;t.save(),t.fillStyle=y,t.translate(M.renderLeft,M.renderTop),t.rotate(M.angle),t.fillRect(-M.kernedWidth/2,l*U+X-a*Q,M.kernedWidth,Q),t.restore()}else if((S!==m||T!==y||U!==E||O!==w||X!==P)&&b>0){const Q=this.fontSize*w/1e3;let N=s+g+f;this.direction==="rtl"&&(N=this.width-N-b),m&&y&&w&&(t.fillStyle=y,t.fillRect(N,k+l*E+P-a*Q,b,Q)),f=M.left,b=M.width,m=S,w=O,y=T,E=U,P=X}else b+=M.kernedWidth}let R=s+g+f;this.direction==="rtl"&&(R=this.width-R-b),t.fillStyle=T;const L=this.fontSize*O/1e3;S&&T&&O&&t.fillRect(R,k+l*E+P-a*L,b-o,L),i+=d}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Gt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(n?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Uo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
2373
- `];let n=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),n=n.concat(i[o],s);return n.pop(),{_unwrappedLines:i,lines:e,graphemeText:n,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject([...Fc,...t])),{},{styles:Jg(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,n=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||i.includes(o),n=n||o==="path";else s=i.includes(t),n=t==="path";return n&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=ni(t,Gt.ATTRIBUTE_NAMES,i),n=_(_({},e),s),{textAnchor:o=Y,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=Do,strokeWidth:p=1}=n,g=rt(n,cm),f=new this(Wr(t.textContent||"").trim(),_({left:d+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:u},g)),b=f.getScaledHeight()/f.height,m=((f.height+f.strokeWidth)*f.lineHeight-f.height)*b,y=f.getScaledHeight()+m;let w=0;return o===V&&(w=f.getScaledWidth()/2),o===_t&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(y-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:p}),f}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Qg(t.styles||{},t.text)}),{extraParam:"text"})}}v(Gt,"textLayoutProperties",Lc),v(Gt,"cacheProperties",[...ri,...Fc]),v(Gt,"ownDefaults",dg),v(Gt,"type","Text"),v(Gt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(Gt,"ATTRIBUTE_NAMES",_i.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Uc(Gt,[class extends Dc{_toSVG(){const r=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(r.textTop,r.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(r){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:r,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:r,withShadow:!0,additionalTransform:Ns(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(r){let{textBgRects:t,textSpans:e}=r;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(lm,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
2374
- `]}_getSVGTextAndBg(r,t){const e=[],i=[];let s,n=r;this.backgroundColor&&i.push(...zn(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+s,n),this._setSVGTextLineText(e,o,t+s,n),n+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(r,t,e,i,s){const n=W.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,r!==r.trim()||!!r.match(am)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(et(l,n),'" '):"",{angle:h,renderLeft:d,renderTop:u,width:p}=s;let g="";if(d!==void 0){const f=p/2;h&&(g=' rotate="'.concat(et(ei(h),n),'"'));const b=os({angle:ei(h)});b[4]=d,b[5]=u;const m=new x(-f,0).transform(b);e=m.x,i=m.y}return'<tspan x="'.concat(et(e,n),'" y="').concat(et(i,n),'" ').concat(c).concat(g).concat(a,">").concat(Kg(r),"</tspan>")}_setSVGTextLineText(r,t,e,i){const s=this.getHeightOfLine(t),n=this.textAlign.includes(Le),o=this._textLines[t];let a,l,c,h,d,u="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)d=g===f||this.charSpacing||this.path,u+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,n&&!d&&this._reSpaceAndTab.test(o[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),d=Wo(a,l,!0)),d&&(h=this._getStyleDeclaration(t,g),r.push(this._createTextCharSpan(u,h,e,i,c)),u="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(r,t,e,i){const s=this._textLines[t],n=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&r.push(...zn(c,e+l,i,a,n)),l=d,a=u,c=o):a+=p}o&&r.push(...zn(c,e+l,i,a,n))}_getSVGLineTopOffset(r){let t,e=0;for(t=0;t<r;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(r){return"".concat(super.getSvgStyles(r)," text-decoration-thickness: ").concat(et(this.textDecorationThickness*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(r,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:d,overline:u,underline:p}=r,g=this.getSvgTextDecoration({underline:p??this.underline,overline:u??this.overline,linethrough:d??this.linethrough}),f=h||this.textDecorationThickness;return[s?Us(re,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(et(f*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; "):"",n?Us(Dt,n):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(r){return["overline","underline","line-through"].filter((t=>r[t.replace("-","")])).join(" ")}}]),A.setClass(Gt),A.setSVGClass(Gt);class hm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach((i=>i())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:n}=e;const o=this.target,a=o.canvas,l=new x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new x(p.left,p.top)),f=a.viewportTransform,b=g.add(d).transform(f,!0),m=o.backgroundColor,y=No(o.styles);o.backgroundColor="";const w={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(w,0,s),o.setSelectionStyles(w,n,o.text.length),o.dirty=!0;const S=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=m,o.styles=y,o.dirty=!0,go(S,{position:"fixed",left:"".concat(-S.width,"px"),border:se,width:"".concat(S.width/u,"px"),height:"".concat(S.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{S.remove()},we(t.target||this.target.hiddenTextarea).body.appendChild(S),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(S,b.x,b.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},n=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=_({text:e.text,value:n},s);t.dataTransfer.setData("text/plain",n),t.dataTransfer.setData("application/fabric",JSON.stringify({value:n,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let n=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(n&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=n[Math.max(0,n.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>u&&l<=p?l=u:l>p&&(l-=p-u),o.removeChars(u,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(n,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+d,o._text.length),o.selectionEnd=Math.min(o.selectionStart+n.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Br,{index:l+d,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,n=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||se;l===se?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Br,{index:o,action:"dragend"}),n.fire("text:changed",{target:s}),n.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Sl=/[ \n\.,;!\?\-]/;class dm extends Gt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:n}=t;return Bc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:n,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach((e=>{e&&!e.isDone()&&(t=!0,e.abort())})),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some((t=>!t||t.isDone()))&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(e===-1||!Mo.test(i[t-1]))?t-1:t,n=i[s];for(;s>0&&s<i.length&&!Sl.test(n);)s+=e,n=i[s];return e===-1&&Sl.test(n)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.searchWordBoundary(t,-1),s=Math.max(i,this.searchWordBoundary(t,1));this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.findLineBoundaryLeft(t),s=this.findLineBoundaryRight(t);this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;we(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,n=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==n||s!==i&&n!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===n||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),n=this.graphemeSplit(s).length;if(t===e)return{selectionStart:n,selectionEnd:n};const o=i.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex,o=this.getValueOfPropertyAt(s,n,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-o,p=d-o,g=new x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/d));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>p&&(g.y=p),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(zr),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==n){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[n])for(let a=o;a<this._unwrappedTextLines[n].length;a++){const l=this.styles[n][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,i-n)}else if(this.styles[i]){const a=this.styles[i],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const n=parseInt(s,10);n>t&&(this.styles[n+e]=i[n],i[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,i,s){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,n[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=n,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:_({},s[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const n=this.styles[t],o=n?_({},n):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(n[c+i]=o[c],o[c-i]||delete n[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},s[i]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),n=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
2375
- `?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,n[0],i),i=i&&i.slice(n[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+n[0],a),o=1;o<a;o++)n[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,n[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,n[o],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,i,e),this._text=[...this._text.slice(0,i),...n,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Y:this._selectionDirection===_t&&(this._selectionDirection=Y,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===_t?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=_t:this._selectionDirection===Y&&(this._selectionDirection=_t,this.selectionStart=e),this.selectionEnd=i)}}class um extends dm{initHiddenTextarea(){const t=this.canvas&&we(this.canvas.getElement())||ss(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map((o=>{let[a,l]=o;return e.setAttribute(a,l)}));const{top:i,left:s,fontSize:n}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(n,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map((o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:i,selectionStart:s,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Br),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(i).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,d=this.selectionEnd,u=h!==d;let p,g,f,b,m=c-l;const y=this.fromStringToGraphemeSelection(s,n,i),w=h>y.selectionStart;u?(g=this._text.slice(h,d),m+=d-h):c<l&&(g=w?this._text.slice(d+m,d):this._text.slice(h,h-m));const S=a.slice(y.selectionEnd-m,y.selectionEnd);if(g&&g.length&&(S.length&&(p=this.getSelectionStyles(h,h+1,!1),p=S.map((()=>p[0]))),u?(f=h,b=d):w?(f=d-g.length,b=d):(f=d,b=d+g.length),this.removeStyleFromTo(f,b)),S.length){const{copyPasteData:T}=Re();e&&S.join("")===T.copiedText&&!W.disableStyleCopyPaste&&(p=T.copiedTextStyle),this.insertNewStyleBlock(S,h,p)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Re();t.copiedText=this.getSelectedText(),W.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n+1,a);return this._textLines[n].slice(o).length+l+1+this.missingNewlineOffset(n)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n-1,a),c=this._textLines[n].slice(0,o),h=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,n,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){n=!0;const h=o-s,d=o,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return n||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===_t);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=es(0,this.selectionStart,s),this.selectionEnd=es(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Y?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Y,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===_t&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Y,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Y&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=_t,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=_t,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Tl=r=>!!r.button;class pm extends um{constructor(){super(...arguments),v(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new hm(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:i}=t;this.canvas&&this.editable&&!Tl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),i&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=i||this.isEditing)))}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const n=this.canvas._activeObject;if(n&&n!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Tl(e)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ce(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,n=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),n=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(n));const a=this._textLines[n].length,l=this.__charBounds[n];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const cr="moveCursorUp",hr="moveCursorDown",dr="moveCursorLeft",ur="moveCursorRight",pr="exitEditing",El=(r,t)=>{const e=t.getRetinaScaling();r.setTransform(e,0,0,e,0,0);const i=t.viewportTransform;r.transform(i[0],i[1],i[2],i[3],i[4],i[5])},gm=_({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:pr,27:pr,33:cr,34:hr,35:ur,36:dr,37:dr,38:cr,39:ur,40:hr},keysMapRtl:{9:pr,27:pr,33:cr,34:hr,35:dr,36:ur,37:ur,38:cr,39:dr,40:hr},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Xe extends pm{static getDefaults(){return _(_({},super.getDefaults()),Xe.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},Xe.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof fo&&this.canvas.textEditingManager.remove(this),e instanceof fo&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),s=i.length>0;let n,o=t;if(s){n=ve(t.canvas),o=n.getContext("2d"),El(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,e):this.renderCursor(o,e),s)for(const a of i){const l=a.clipPath,c=ve(t.canvas),h=c.getContext("2d");if(El(h,this.canvas),!l.absolutePositioned){const d=a.calcTransformMatrix();h.transform(d[0],d[1],d[2],d[3],d[4],d[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(t.setTransform(1,0,0,1,0,0),t.drawImage(n,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:n.left,topOffset:n.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:n}=this.get2DCursorLocation(t);for(let c=0;c<n;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(n),a=this.__charBounds[n][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[n].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===_t||this.textAlign===Le||this.textAlign===Ms?l.left*=-1:this.textAlign===Y||this.textAlign===Yr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Is||(l.left=o-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,n,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,n,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,n,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:s,opacity:n,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=n,t.fillRect(o,a,l,c)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,n=e.selectionEnd,o=this.textAlign.includes(Le),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(n),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const g=this._getLineLeftOffset(p)||0;let f=this.getHeightOfLine(p),b=0,m=0,y=0;if(p===c&&(m=this.__charBounds[c][d].left),p>=c&&p<h)y=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(u===0)y=this.__charBounds[h][u].left;else{const k=this._getWidthOfCharSpacing();y=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-k}b=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let w=i.left+g+m,S=f,T=0;const O=y-m;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",S=1,T=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===_t||this.textAlign===Le||this.textAlign===Ms?w=this.width-w-O:this.textAlign===Y||this.textAlign===Yr?w=i.left+g-y:this.textAlign!==V&&this.textAlign!==Is||(w=i.left+g-y)),t.fillRect(w,i.top+i.topOffset+T,O,S),i.topOffset+=b}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Dt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(Xe,"ownDefaults",gm),v(Xe,"type","IText"),A.setClass(Xe),A.setClass(Xe,"i-text");class pi extends Xe{static getDefaults(){return _(_({},super.getDefaults()),pi.ownDefaults)}constructor(t,e){super(t,_(_({},pi.ownDefaults),e))}static createControls(){return{controls:Wg()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Le)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const n={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
2376
- `&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),n[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,n=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,n=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!n||d<e))for(const u in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let n=0;n<i.wordsData.length;n++)s.push(...this._wrapLine(n,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((n,o)=>{let a=0;const l=e?this.graphemeSplit(n):this.wordSplit(n);return l.length===0?[{word:[],width:0}]:l.map((c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,o,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=0;for(let o=0,a=t.length;o<a;o++)n+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:n}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],p=0,g=0,f=!0;e-=o;const b=Math.max(e,s,this.dynamicMinWidth),m=n[t];let y;for(p=0,y=0;y<m.length;y++){const{word:w,width:S}=m[y];p+=w.length,d+=g+S-a,d>b&&!f?(c.push(u),u=[],d=S,f=!0):d+=a,f||l||u.push(h),u=u.concat(w),g=l?0:this._measureWord([h],t,p),p++,f=!1}return y&&c.push(u),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let n=0;n<i.length;n++)s[n]=i[n].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(pi,"type","Textbox"),v(pi,"textLayoutProperties",[...Xe.textLayoutProperties,"width"]),v(pi,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),A.setClass(pi);class Ol extends fn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:n}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=Ke(Gc(i,s)),l=new x(o,a);if(s.absolutePositioned)return{center:Zi(s.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:d=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(Ol,"type","clip-path"),A.setClass(Ol);class kl extends fn{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new x(i.width||s.x,i.height||s.y)}}v(kl,"type","fixed"),A.setClass(kl);class fm extends Ys{subscribeTargets(t){const e=t.target;t.targets.reduce(((i,s)=>(s.parent&&i.add(s.parent),i)),new Set).forEach((i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((s,n)=>(n.parent&&s.add(n.parent),s)),new Set).forEach((s=>{!i.some((n=>n.parent===s))&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})}))}}class Mi extends fi{static getDefaults(){return _(_({},super.getDefaults()),Mi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Mi.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:n}=e;this.groupInit(t,{left:i,top:s,layoutManager:n??new fm})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach((s=>{const n=this._objects.findIndex((a=>a.isInFrontOf(s))),o=n===-1?this.size():n;this.insertAt(o,s)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(mi("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach((s=>{const{parent:n}=s;n&&i.add(n)})),t===Go?i.forEach((s=>{s._onAfterObjectsChange(Gr,e)})):i.forEach((s=>{s._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=_(_({hasControls:!1},i),{},{forActiveSelection:!0});for(let n=0;n<this._objects.length;n++)this._objects[n]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v(Mi,"type","ActiveSelection"),v(Mi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),A.setClass(Mi),A.setClass(Mi,"activeSelection");class mm{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,n){const o=n.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:n,ctx:o,filterBackend:this};t.forEach((c=>{c.applyTo(a)}));const{imageData:l}=a;return l.width===i&&l.height===s||(n.width=l.width,n.height=l.height),o.putImageData(l,0,0),a}}class ch{constructor(){let{tileSize:t=W.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=ve({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,n,o){const a=this.gl,l=n.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach((u=>{u&&u.applyTo(h)})),(function(u){const p=u.targetCanvas,g=p.width,f=p.height,b=u.destinationWidth,m=u.destinationHeight;g===b&&f===m||(p.width=b,p.height=m)})(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,n){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,n||o),t.texParameteri(a,u,n||o),t.texParameteri(a,p,h),t.texParameteri(a,g,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const n=this.createTexture(this.gl,e.width,e.height,e,i);return n&&(s[t]=n),n}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,n=s.getContext("2d");if(!n)return;n.translate(0,s.height),n.scale(1,-1);const o=i.height-s.height;n.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,n=e.destinationHeight,o=s*n*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,n,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,n);i.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),n=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let Vn;function bm(){const{WebGLProbe:r}=Re();return r.queryWebGL(ti()),W.enableGLFiltering&&r.isSupported(W.textureSize)?new ch({tileSize:W.textureSize}):new mm}function Nn(){return!Vn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Vn=bm()),Vn}const vm=["filters","resizeFilter","src","crossOrigin","type"],hh=["cropX","cropY"];class te extends Vt{static getDefaults(){return _(_({},super.getDefaults()),te.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,te.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(bi()),this.setElement(typeof t=="string"?(this.canvas&&we(this.canvas.getElement())||ss()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(i),(e=t.classList)===null||e===void 0||e.add(te.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Nn(!1);e instanceof ch&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((t=>{const e=this[t];e&&Re().dispose(e),this[t]=void 0}))}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach((i=>{i&&e.push(i.toObject())})),_(_({},super.toObject([...hh,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let n=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=bi();n.push('<clipPath id="imageCrop_'+c+`">
2368
+ `]}}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,radius:a=0}=s;return new this(y(y({},rt(s,im)),{},{radius:a,left:n-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}v(We,"type","Circle"),v(We,"cacheProperties",[...ri,...nh]),v(We,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(We,"ATTRIBUTE_NAMES",["cx","cy","r",..._i]),A.setClass(We),A.setSVGClass(We);const sm=["x1","y1","x2","y2"],rm=["x1","y1","x2","y2"],mo=["x1","x2","y1","y2"];class ki extends Vt{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,ki.ownDefaults),this.setOptions(n),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=n;typeof o=="number"&&this.set(Y,o),typeof a=="number"&&this.set(ie,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:n,top:o,width:a,height:l}=Ke([{x:t,y:e},{x:i,y:s}]),c=new x(n+a/2,o+l/2);this.setPositionByOrigin(c,V,V)}_set(t,e){return super._set(t,e),mo.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const i=t.strokeStyle;var s;ge(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new x((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:n,height:o}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*n/2,x2:a*-n/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,`" />
2369
+ `)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{x1:n=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([n,o,a,l],rt(s,sm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:n}=t,o=rt(t,rm);return this._fromObject(y(y({},o),{},{points:[e,i,s,n]}),{extraParam:"points"})}}v(ki,"type","Line"),v(ki,"cacheProperties",[...ri,...mo]),v(ki,"ATTRIBUTE_NAMES",_i.concat(mo)),A.setClass(ki),A.setSVGClass(ki);class Di extends Vt{static getDefaults(){return y(y({},super.getDefaults()),Di.ownDefaults)}constructor(t){super(),Object.assign(this,Di.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}v(Di,"type","Triangle"),v(Di,"ownDefaults",{width:100,height:100}),A.setClass(Di),A.setSVGClass(Di);const oh=["rx","ry"];class Ye extends Vt{static getDefaults(){return y(y({},super.getDefaults()),Ye.ownDefaults)}constructor(t){super(),Object.assign(this,Ye.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(oe)}getRy(){return this.get("ry")*this.get(be)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...oh,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
2370
+ `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Rr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function nm(r){if(!r)return[];const t=r.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(Ye,"type","Ellipse"),v(Ye,"cacheProperties",[...ri,...oh]),v(Ye,"ownDefaults",{rx:0,ry:0}),v(Ye,"ATTRIBUTE_NAMES",[..._i,"cx","cy","rx","ry"]),A.setClass(Ye),A.setSVGClass(Ye);const om=["left","top"],ah={exactBoundingBox:!1};class xe extends Vt{static getDefaults(){return y(y({},super.getDefaults()),xe.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,xe.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(Y,i),typeof s=="number"&&this.set(ie,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Xg(this.points,t,this.isOpen())}_calcDimensions(t){t=y({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map((c=>c.projectedPoint)):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new x,strokeOffset:new x,strokeDiff:new x};const i=Ke(e),s=hn(y(y({},t),{},{scaleX:1,scaleY:1})),n=Ke(this.points.map((c=>Qt(c,s,!0)))),o=new x(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(xt(this.skewX)),l-=a*Math.tan(xt(this.skewY))),y(y({},i),{},{pathOffset:new x(a,l),strokeOffset:new x(n.left,n.top).subtract(new x(i.left,i.top)).multiply(o),strokeDiff:new x(i.width,i.height).subtract(new x(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=Ke(this.points);return new x(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new x(e+s/2,i+n/2),V,V)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some((a=>this.strokeUniform||this.constructor.layoutProperties.includes(a)))){var e,i;const{width:a,height:l}=this._calcDimensions(t);o=new x((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,n;o=new x((s=t.width)!==null&&s!==void 0?s:this.width,(n=t.height)!==null&&n!==void 0?n:this.height)}return o.multiply(new x(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===oe||t===be)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),{},{points:this.points.map((e=>{let{x:i,y:s}=e;return{x:i,y:s}}))})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=W.NUM_FRACTION_DIGITS;for(let n=0,o=this.points.length;n<o;n++)t.push(et(this.points[n].x-e,s),",",et(this.points[n].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
2371
+ `)]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let n=0;n<e;n++){const o=this.points[n];t.lineTo(o.x-i,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(nm(t.getAttribute("points")),y(y({},rt(ni(t,this.ATTRIBUTE_NAMES,i),om)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(xe,"ownDefaults",ah),v(xe,"type","Polyline"),v(xe,"layoutProperties",[rs,ns,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(xe,"cacheProperties",[...ri,"points"]),v(xe,"ATTRIBUTE_NAMES",[..._i]),A.setClass(xe),A.setSVGClass(xe);class lr extends xe{isOpen(){return!1}}v(lr,"ownDefaults",ah),v(lr,"type","Polygon"),A.setClass(lr),A.setSVGClass(lr);class lh extends Vt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const n in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const n in i[s])if(i[s][n][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,n=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};n++,h[t]!==void 0?(s?h[t]!==s&&(o=!1):s=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&n===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,n;for(s in e){for(n in i=e[s],i)delete i[n][t],Object.keys(i[n]).length===0&&delete i[n];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const n=$o(y(y({},this._getStyleDeclaration(i,s)),e),(o=>o!==void 0));this._setStyleDeclaration(i,s,n)}getSelectionStyles(t,e,i){const s=[];for(let n=t;n<(e||t);n++)s.push(this.getStyleAtPosition(n,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return y(y({},as(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}v(lh,"_styleProperties",hg);const am=/ +/g,lm=/"/g;function zn(r,t,e,i,s){return" ".concat((function(n,o){let{left:a,top:l,width:c,height:h}=o,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:W.NUM_FRACTION_DIGITS;const u=Us(Dt,n,!1),[p,g,f,m]=[a,l,c,h].map((b=>et(b,d)));return"<rect ".concat(u,' x="').concat(p,'" y="').concat(g,'" width="').concat(f,'" height="').concat(m,'"></rect>')})(r,{left:t,top:e,width:i,height:s}),`
2372
+ `)}const cm=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Hn;class Gt extends lh{static getDefaults(){return y(y({},super.getDefaults()),Gt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Gt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Qc(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Le)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,n,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Le||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,n=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=n.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(n[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===re?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case V:t.textBaseline="middle";break;case"ascender":t.textBaseline=ie;break;case"descender":t.textBaseline=ro}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,n,o){this._renderChars(t,e,i,s,n,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++){const a=this.getHeightOfLine(n);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",n)){s+=a;continue}const l=this._textLines[n].length,c=this._getLineLeftOffset(n);let h,d,u=0,p=0,g=this.getValueOfPropertyAt(n,0,"textBackgroundColor");const f=this.getHeightOfLineImpl(n);for(let m=0;m<l;m++){const b=this.__charBounds[n][m];d=this.getValueOfPropertyAt(n,m,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=d,d&&t.fillRect(-b.width/2,-f*(1-this._fontSizeFraction),b.width,f),t.restore()):d!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=g,g&&t.fillRect(h,s,u,f),p=b.left,u=b.width,g=d):u+=b.kernedWidth}d&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,f)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const n=Ds.getFontCache(e),o=this._getFontDeclaration(e),a=i?i+t:t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,p;if(i&&n.has(i)&&(u=n.get(i)),n.has(t)&&(p=h=n.get(t)),l&&n.has(a)&&(d=n.get(a),p=d-u),h===void 0||u===void 0||d===void 0){const g=(function(){return Hn||(Hn=ve({width:0,height:0}).getContext("2d")),Hn})();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,n.set(t,h)),u===void 0&&l&&i&&(u=g.measureText(i).width,n.set(i,u)),l&&d===void 0&&(d=g.measureText(a).width,n.set(a,d),p=d-u)}return{width:h*c,kernedWidth:p*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const n=this.pathSide===_t,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const d=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Y:h=n?d-s:0;break;case V:h=(d-s)/2;break;case _t:h=n?0:d-s}h+=this.pathStartOffset*(n?-1:1);for(let u=n?l-1:0;n?u>=0:u<l;n?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,n=$f(s.path,i,s.segmentsInfo);e.renderLeft=n.x-s.pathOffset.x,e.renderTop=n.y-s.pathOffset.y,e.angle=n.angle+(this.pathSide===_t?Math.PI:0)}_getGraphemeBox(t,e,i,s,n){const o=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!n){const p=this.__charBounds[e][i-1];u.left=p.left+p.width+l.kernedWidth-l.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let i=this.getHeightOfChar(t,0);for(let s=1,n=this._textLines[t].length;s<n;s++)i=Math.max(this.getHeightOfChar(t,s),i);return e[t]=i*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,i=this._textLines.length;e<i;e++)t+=e===i-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),n=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],s+this._getLineLeftOffset(o),n+i+this.getHeightOfLineImpl(o),o),i+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Dt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,n,o){const a=this.textAlign.includes(Le),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",d=this.direction==="ltr"?1:-1,u=e.direction;let p,g,f,m,b,_="",w=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Y:_t),n-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,i.join(""),s,n),void e.restore();for(let S=0,T=i.length-1;S<=T;S++)m=S===T||this.charSpacing||l,_+=i[S],f=this.__charBounds[o][S],w===0?(s+=d*(f.kernedWidth-f.width),w+=f.width):w+=f.kernedWidth,a&&!m&&this._reSpaceAndTab.test(i[S])&&(m=!0),m||(p=p||this.getCompleteStyleDeclaration(o,S),g=this.getCompleteStyleDeclaration(o,S+1),m=Wo(p,g,!1)),m&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,o,S,_,-w/2,0),e.restore()):(b=s,this._renderChar(t,e,o,S,_,b,n)),_="",p=g,s+=d*w,w=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=ve({width:e,height:i}),n=s.getContext("2d");return s.width=e,s.height=i,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,i),n.lineTo(0,i),n.closePath(),n.translate(e/2,i/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,n;return ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,n=-this.height/2,t.translate(s,n),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:n}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,n,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(n,o-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(n,o-u.offsetX,a-u.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:n*i.size,deltaY:o+n*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,n=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===Le||s===Is&&!o||s===Ms&&!o||s===Yr&&!o?0:(s===V&&(a=i/2),s===_t&&(a=i),s===Is&&(a=i/2),s===Ms&&(a=i),n==="rtl"&&(s===_t||s===Le||s===Ms?a=0:s===Y||s===Yr?a=-i:s!==V&&s!==Is||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),n=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const d=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){i+=d;continue}const u=this._textLines[c],p=d/this.lineHeight,g=this._getLineLeftOffset(c);let f=0,m=0,b=this.getValueOfPropertyAt(c,0,e),_=this.getValueOfPropertyAt(c,0,Dt),w=this.getValueOfPropertyAt(c,0,Ri),S=b,T=_,k=w;const O=i+p*(1-this._fontSizeFraction);let E=this.getHeightOfChar(c,0),P=this.getValueOfPropertyAt(c,0,"deltaY");for(let F=0,H=u.length;F<H;F++){const M=this.__charBounds[c][F];S=this.getValueOfPropertyAt(c,F,e),T=this.getValueOfPropertyAt(c,F,Dt),k=this.getValueOfPropertyAt(c,F,Ri);const U=this.getHeightOfChar(c,F),X=this.getValueOfPropertyAt(c,F,"deltaY");if(n&&S&&T){const Q=this.fontSize*k/1e3;t.save(),t.fillStyle=_,t.translate(M.renderLeft,M.renderTop),t.rotate(M.angle),t.fillRect(-M.kernedWidth/2,l*U+X-a*Q,M.kernedWidth,Q),t.restore()}else if((S!==b||T!==_||U!==E||k!==w||X!==P)&&m>0){const Q=this.fontSize*w/1e3;let N=s+g+f;this.direction==="rtl"&&(N=this.width-N-m),b&&_&&w&&(t.fillStyle=_,t.fillRect(N,O+l*E+P-a*Q,m,Q)),f=M.left,m=M.width,b=S,w=k,_=T,E=U,P=X}else m+=M.kernedWidth}let R=s+g+f;this.direction==="rtl"&&(R=this.width-R-m),t.fillStyle=T;const L=this.fontSize*k/1e3;S&&T&&k&&t.fillRect(R,O+l*E+P-a*L,m-o,L),i+=d}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Gt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(n?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Uo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
2373
+ `];let n=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),n=n.concat(i[o],s);return n.pop(),{_unwrappedLines:i,lines:e,graphemeText:n,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject([...Fc,...t])),{},{styles:Jg(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,n=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||i.includes(o),n=n||o==="path";else s=i.includes(t),n=t==="path";return n&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=ni(t,Gt.ATTRIBUTE_NAMES,i),n=y(y({},e),s),{textAnchor:o=Y,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=Do,strokeWidth:p=1}=n,g=rt(n,cm),f=new this(Wr(t.textContent||"").trim(),y({left:d+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:u},g)),m=f.getScaledHeight()/f.height,b=((f.height+f.strokeWidth)*f.lineHeight-f.height)*m,_=f.getScaledHeight()+b;let w=0;return o===V&&(w=f.getScaledWidth()/2),o===_t&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(_-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:p}),f}static fromObject(t){return this._fromObject(y(y({},t),{},{styles:Qg(t.styles||{},t.text)}),{extraParam:"text"})}}v(Gt,"textLayoutProperties",Lc),v(Gt,"cacheProperties",[...ri,...Fc]),v(Gt,"ownDefaults",dg),v(Gt,"type","Text"),v(Gt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(Gt,"ATTRIBUTE_NAMES",_i.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Uc(Gt,[class extends Dc{_toSVG(){const r=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(r.textTop,r.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(r){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:r,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:r,withShadow:!0,additionalTransform:Ns(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(r){let{textBgRects:t,textSpans:e}=r;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(lm,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
2374
+ `]}_getSVGTextAndBg(r,t){const e=[],i=[];let s,n=r;this.backgroundColor&&i.push(...zn(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+s,n),this._setSVGTextLineText(e,o,t+s,n),n+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(r,t,e,i,s){const n=W.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,r!==r.trim()||!!r.match(am)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(et(l,n),'" '):"",{angle:h,renderLeft:d,renderTop:u,width:p}=s;let g="";if(d!==void 0){const f=p/2;h&&(g=' rotate="'.concat(et(ei(h),n),'"'));const m=os({angle:ei(h)});m[4]=d,m[5]=u;const b=new x(-f,0).transform(m);e=b.x,i=b.y}return'<tspan x="'.concat(et(e,n),'" y="').concat(et(i,n),'" ').concat(c).concat(g).concat(a,">").concat(Kg(r),"</tspan>")}_setSVGTextLineText(r,t,e,i){const s=this.getHeightOfLine(t),n=this.textAlign.includes(Le),o=this._textLines[t];let a,l,c,h,d,u="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)d=g===f||this.charSpacing||this.path,u+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,n&&!d&&this._reSpaceAndTab.test(o[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),d=Wo(a,l,!0)),d&&(h=this._getStyleDeclaration(t,g),r.push(this._createTextCharSpan(u,h,e,i,c)),u="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(r,t,e,i){const s=this._textLines[t],n=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&r.push(...zn(c,e+l,i,a,n)),l=d,a=u,c=o):a+=p}o&&r.push(...zn(c,e+l,i,a,n))}_getSVGLineTopOffset(r){let t,e=0;for(t=0;t<r;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(r){return"".concat(super.getSvgStyles(r)," text-decoration-thickness: ").concat(et(this.textDecorationThickness*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(r,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:d,overline:u,underline:p}=r,g=this.getSvgTextDecoration({underline:p??this.underline,overline:u??this.overline,linethrough:d??this.linethrough}),f=h||this.textDecorationThickness;return[s?Us(re,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(et(f*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; "):"",n?Us(Dt,n):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(r){return["overline","underline","line-through"].filter((t=>r[t.replace("-","")])).join(" ")}}]),A.setClass(Gt),A.setSVGClass(Gt);class hm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach((i=>i())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:n}=e;const o=this.target,a=o.canvas,l=new x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new x(p.left,p.top)),f=a.viewportTransform,m=g.add(d).transform(f,!0),b=o.backgroundColor,_=No(o.styles);o.backgroundColor="";const w={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(w,0,s),o.setSelectionStyles(w,n,o.text.length),o.dirty=!0;const S=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=b,o.styles=_,o.dirty=!0,go(S,{position:"fixed",left:"".concat(-S.width,"px"),border:se,width:"".concat(S.width/u,"px"),height:"".concat(S.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{S.remove()},we(t.target||this.target.hiddenTextarea).body.appendChild(S),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(S,m.x,m.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},n=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=y({text:e.text,value:n},s);t.dataTransfer.setData("text/plain",n),t.dataTransfer.setData("application/fabric",JSON.stringify({value:n,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let n=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(n&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=n[Math.max(0,n.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>u&&l<=p?l=u:l>p&&(l-=p-u),o.removeChars(u,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(n,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+d,o._text.length),o.selectionEnd=Math.min(o.selectionStart+n.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Br,{index:l+d,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,n=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||se;l===se?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Br,{index:o,action:"dragend"}),n.fire("text:changed",{target:s}),n.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Sl=/[ \n\.,;!\?\-]/;class dm extends Gt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:n}=t;return Bc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:n,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach((e=>{e&&!e.isDone()&&(t=!0,e.abort())})),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some((t=>!t||t.isDone()))&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(e===-1||!Mo.test(i[t-1]))?t-1:t,n=i[s];for(;s>0&&s<i.length&&!Sl.test(n);)s+=e,n=i[s];return e===-1&&Sl.test(n)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.searchWordBoundary(t,-1),s=Math.max(i,this.searchWordBoundary(t,1));this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.findLineBoundaryLeft(t),s=this.findLineBoundaryRight(t);this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;we(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,n=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==n||s!==i&&n!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===n||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),n=this.graphemeSplit(s).length;if(t===e)return{selectionStart:n,selectionEnd:n};const o=i.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex,o=this.getValueOfPropertyAt(s,n,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-o,p=d-o,g=new x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/d));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>p&&(g.y=p),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(zr),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==n){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[n])for(let a=o;a<this._unwrappedTextLines[n].length;a++){const l=this.styles[n][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,i-n)}else if(this.styles[i]){const a=this.styles[i],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const n=parseInt(s,10);n>t&&(this.styles[n+e]=i[n],i[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,i,s){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,n[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=n,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:y({},s[i-1])}:c?this.styles[t+i]={0:y({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const n=this.styles[t],o=n?y({},n):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(n[c+i]=o[c],o[c-i]||delete n[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=y({},s[i]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=y({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),n=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
2375
+ `?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,n[0],i),i=i&&i.slice(n[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+n[0],a),o=1;o<a;o++)n[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,n[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,n[o],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,i,e),this._text=[...this._text.slice(0,i),...n,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Y:this._selectionDirection===_t&&(this._selectionDirection=Y,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===_t?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=_t:this._selectionDirection===Y&&(this._selectionDirection=_t,this.selectionStart=e),this.selectionEnd=i)}}class um extends dm{initHiddenTextarea(){const t=this.canvas&&we(this.canvas.getElement())||ss(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map((o=>{let[a,l]=o;return e.setAttribute(a,l)}));const{top:i,left:s,fontSize:n}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(n,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map((o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:i,selectionStart:s,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Br),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(i).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,d=this.selectionEnd,u=h!==d;let p,g,f,m,b=c-l;const _=this.fromStringToGraphemeSelection(s,n,i),w=h>_.selectionStart;u?(g=this._text.slice(h,d),b+=d-h):c<l&&(g=w?this._text.slice(d+b,d):this._text.slice(h,h-b));const S=a.slice(_.selectionEnd-b,_.selectionEnd);if(g&&g.length&&(S.length&&(p=this.getSelectionStyles(h,h+1,!1),p=S.map((()=>p[0]))),u?(f=h,m=d):w?(f=d-g.length,m=d):(f=d,m=d+g.length),this.removeStyleFromTo(f,m)),S.length){const{copyPasteData:T}=Re();e&&S.join("")===T.copiedText&&!W.disableStyleCopyPaste&&(p=T.copiedTextStyle),this.insertNewStyleBlock(S,h,p)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Re();t.copiedText=this.getSelectedText(),W.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n+1,a);return this._textLines[n].slice(o).length+l+1+this.missingNewlineOffset(n)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n-1,a),c=this._textLines[n].slice(0,o),h=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,n,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){n=!0;const h=o-s,d=o,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return n||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===_t);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=es(0,this.selectionStart,s),this.selectionEnd=es(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Y?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Y,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===_t&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Y,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Y&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=_t,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=_t,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Tl=r=>!!r.button;class pm extends um{constructor(){super(...arguments),v(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new hm(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:i}=t;this.canvas&&this.editable&&!Tl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),i&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=i||this.isEditing)))}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const n=this.canvas._activeObject;if(n&&n!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Tl(e)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ce(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,n=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),n=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(n));const a=this._textLines[n].length,l=this.__charBounds[n];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const cr="moveCursorUp",hr="moveCursorDown",dr="moveCursorLeft",ur="moveCursorRight",pr="exitEditing",El=(r,t)=>{const e=t.getRetinaScaling();r.setTransform(e,0,0,e,0,0);const i=t.viewportTransform;r.transform(i[0],i[1],i[2],i[3],i[4],i[5])},gm=y({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:pr,27:pr,33:cr,34:hr,35:ur,36:dr,37:dr,38:cr,39:ur,40:hr},keysMapRtl:{9:pr,27:pr,33:cr,34:hr,35:dr,36:ur,37:ur,38:cr,39:dr,40:hr},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Xe extends pm{static getDefaults(){return y(y({},super.getDefaults()),Xe.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,y(y({},Xe.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof fo&&this.canvas.textEditingManager.remove(this),e instanceof fo&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),s=i.length>0;let n,o=t;if(s){n=ve(t.canvas),o=n.getContext("2d"),El(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,e):this.renderCursor(o,e),s)for(const a of i){const l=a.clipPath,c=ve(t.canvas),h=c.getContext("2d");if(El(h,this.canvas),!l.absolutePositioned){const d=a.calcTransformMatrix();h.transform(d[0],d[1],d[2],d[3],d[4],d[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(t.setTransform(1,0,0,1,0,0),t.drawImage(n,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:n.left,topOffset:n.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:n}=this.get2DCursorLocation(t);for(let c=0;c<n;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(n),a=this.__charBounds[n][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[n].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===_t||this.textAlign===Le||this.textAlign===Ms?l.left*=-1:this.textAlign===Y||this.textAlign===Yr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Is||(l.left=o-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,n,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,n,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,n,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:s,opacity:n,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=n,t.fillRect(o,a,l,c)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,n=e.selectionEnd,o=this.textAlign.includes(Le),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(n),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const g=this._getLineLeftOffset(p)||0;let f=this.getHeightOfLine(p),m=0,b=0,_=0;if(p===c&&(b=this.__charBounds[c][d].left),p>=c&&p<h)_=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(u===0)_=this.__charBounds[h][u].left;else{const O=this._getWidthOfCharSpacing();_=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-O}m=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let w=i.left+g+b,S=f,T=0;const k=_-b;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",S=1,T=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===_t||this.textAlign===Le||this.textAlign===Ms?w=this.width-w-k:this.textAlign===Y||this.textAlign===Yr?w=i.left+g-_:this.textAlign!==V&&this.textAlign!==Is||(w=i.left+g-_)),t.fillRect(w,i.top+i.topOffset+T,k,S),i.topOffset+=m}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Dt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(Xe,"ownDefaults",gm),v(Xe,"type","IText"),A.setClass(Xe),A.setClass(Xe,"i-text");class pi extends Xe{static getDefaults(){return y(y({},super.getDefaults()),pi.ownDefaults)}constructor(t,e){super(t,y(y({},pi.ownDefaults),e))}static createControls(){return{controls:Wg()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Le)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const n={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
2376
+ `&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),n[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,n=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,n=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!n||d<e))for(const u in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let n=0;n<i.wordsData.length;n++)s.push(...this._wrapLine(n,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((n,o)=>{let a=0;const l=e?this.graphemeSplit(n):this.wordSplit(n);return l.length===0?[{word:[],width:0}]:l.map((c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,o,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=0;for(let o=0,a=t.length;o<a;o++)n+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:n}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],p=0,g=0,f=!0;e-=o;const m=Math.max(e,s,this.dynamicMinWidth),b=n[t];let _;for(p=0,_=0;_<b.length;_++){const{word:w,width:S}=b[_];p+=w.length,d+=g+S-a,d>m&&!f?(c.push(u),u=[],d=S,f=!0):d+=a,f||l||u.push(h),u=u.concat(w),g=l?0:this._measureWord([h],t,p),p++,f=!1}return _&&c.push(u),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let n=0;n<i.length;n++)s[n]=i[n].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(pi,"type","Textbox"),v(pi,"textLayoutProperties",[...Xe.textLayoutProperties,"width"]),v(pi,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),A.setClass(pi);class Ol extends fn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:n}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=Ke(Gc(i,s)),l=new x(o,a);if(s.absolutePositioned)return{center:Zi(s.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:d=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(Ol,"type","clip-path"),A.setClass(Ol);class kl extends fn{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new x(i.width||s.x,i.height||s.y)}}v(kl,"type","fixed"),A.setClass(kl);class fm extends Ys{subscribeTargets(t){const e=t.target;t.targets.reduce(((i,s)=>(s.parent&&i.add(s.parent),i)),new Set).forEach((i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((s,n)=>(n.parent&&s.add(n.parent),s)),new Set).forEach((s=>{!i.some((n=>n.parent===s))&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})}))}}class Mi extends fi{static getDefaults(){return y(y({},super.getDefaults()),Mi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Mi.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:n}=e;this.groupInit(t,{left:i,top:s,layoutManager:n??new fm})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach((s=>{const n=this._objects.findIndex((a=>a.isInFrontOf(s))),o=n===-1?this.size():n;this.insertAt(o,s)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(mi("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach((s=>{const{parent:n}=s;n&&i.add(n)})),t===Go?i.forEach((s=>{s._onAfterObjectsChange(Gr,e)})):i.forEach((s=>{s._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=y(y({hasControls:!1},i),{},{forActiveSelection:!0});for(let n=0;n<this._objects.length;n++)this._objects[n]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v(Mi,"type","ActiveSelection"),v(Mi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),A.setClass(Mi),A.setClass(Mi,"activeSelection");class mm{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,n){const o=n.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:n,ctx:o,filterBackend:this};t.forEach((c=>{c.applyTo(a)}));const{imageData:l}=a;return l.width===i&&l.height===s||(n.width=l.width,n.height=l.height),o.putImageData(l,0,0),a}}class ch{constructor(){let{tileSize:t=W.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=ve({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,n,o){const a=this.gl,l=n.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach((u=>{u&&u.applyTo(h)})),(function(u){const p=u.targetCanvas,g=p.width,f=p.height,m=u.destinationWidth,b=u.destinationHeight;g===m&&f===b||(p.width=m,p.height=b)})(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,n){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,n||o),t.texParameteri(a,u,n||o),t.texParameteri(a,p,h),t.texParameteri(a,g,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const n=this.createTexture(this.gl,e.width,e.height,e,i);return n&&(s[t]=n),n}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,n=s.getContext("2d");if(!n)return;n.translate(0,s.height),n.scale(1,-1);const o=i.height-s.height;n.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,n=e.destinationHeight,o=s*n*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,n,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,n);i.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),n=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let Vn;function bm(){const{WebGLProbe:r}=Re();return r.queryWebGL(ti()),W.enableGLFiltering&&r.isSupported(W.textureSize)?new ch({tileSize:W.textureSize}):new mm}function Nn(){return!Vn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Vn=bm()),Vn}const vm=["filters","resizeFilter","src","crossOrigin","type"],hh=["cropX","cropY"];class te extends Vt{static getDefaults(){return y(y({},super.getDefaults()),te.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,te.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(bi()),this.setElement(typeof t=="string"?(this.canvas&&we(this.canvas.getElement())||ss()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(i),(e=t.classList)===null||e===void 0||e.add(te.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Nn(!1);e instanceof ch&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((t=>{const e=this[t];e&&Re().dispose(e),this[t]=void 0}))}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach((i=>{i&&e.push(i.toObject())})),y(y({},super.toObject([...hh,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let n=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=bi();n.push('<clipPath id="imageCrop_'+c+`">
2377
2377
  `,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
2378
2378
  `,`</clipPath>
2379
2379
  `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(i-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
2380
2380
  `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(i,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
2381
- `)],this.fill=c}return n=this.paintFirst!==Dt?n.concat(o,t):n.concat(t,o),n}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Ir(t,{crossOrigin:e,signal:i}).then((s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,n=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&n>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=n);const a=ve(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Nn().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter((n=>n&&!n.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=ve({width:i,height:s});this._element=n,this._filteredEl=n}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Nn().applyFilters(t,this._originalElement,i,s,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,n=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,p=Math.min(n*i,c-d),g=Math.min(o*s,h-u),f=-n/2,b=-o/2,m=Math.min(n,c/i-a),y=Math.min(o,h/s-l);e&&t.drawImage(e,d,u,p,g,f,b,m,y)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=cg(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let n,o=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,p=0;return!t||t.alignX===se&&t.alignY===se?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=Ef(this._element,s),n=(e-o*l)/2,t.alignX==="Min"&&(h=-n),t.alignX==="Max"&&(h=n),n=(i-a*c)/2,t.alignY==="Min"&&(d=-n),t.alignY==="Max"&&(d=n)),t.meetOrSlice==="slice"&&(l=c=Of(this._element,s),n=o-e/l,t.alignX==="Mid"&&(u=n/2),t.alignX==="Max"&&(u=n),n=a-i/c,t.alignY==="Mid"&&(p=n/2),t.alignY==="Max"&&(p=n),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:n,crossOrigin:o,type:a}=t,l=rt(t,vm);return Promise.all([Ir(n,_(_({},e),{},{crossOrigin:o})),i&&Vs(i,e),s&&Vs([s],e),dn(l,e)]).then((c=>{let[h,d=[],[u]=[],p={}]=c;return new this(h,_(_({},l),{},{src:n,filters:d,resizeFilter:u},p))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Ir(t,{crossOrigin:e,signal:i}).then((n=>new this(n,s)))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=ni(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"]||s.href,e,s).catch((n=>(mi("log","Unable to parse Image",n),null)))}}v(te,"type","Image"),v(te,"cacheProperties",[...ri,...hh]),v(te,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(te,"CSS_CANVAS","canvas-img"),v(te,"ATTRIBUTE_NAMES",[..._i,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),A.setClass(te),A.setSVGClass(te);pn(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const bn=r=>r.webgl!==void 0,Xo="precision highp float",ym=`
2381
+ `)],this.fill=c}return n=this.paintFirst!==Dt?n.concat(o,t):n.concat(t,o),n}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Ir(t,{crossOrigin:e,signal:i}).then((s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,n=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&n>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=n);const a=ve(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Nn().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter((n=>n&&!n.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=ve({width:i,height:s});this._element=n,this._filteredEl=n}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Nn().applyFilters(t,this._originalElement,i,s,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,n=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,p=Math.min(n*i,c-d),g=Math.min(o*s,h-u),f=-n/2,m=-o/2,b=Math.min(n,c/i-a),_=Math.min(o,h/s-l);e&&t.drawImage(e,d,u,p,g,f,m,b,_)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=cg(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let n,o=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,p=0;return!t||t.alignX===se&&t.alignY===se?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=Ef(this._element,s),n=(e-o*l)/2,t.alignX==="Min"&&(h=-n),t.alignX==="Max"&&(h=n),n=(i-a*c)/2,t.alignY==="Min"&&(d=-n),t.alignY==="Max"&&(d=n)),t.meetOrSlice==="slice"&&(l=c=Of(this._element,s),n=o-e/l,t.alignX==="Mid"&&(u=n/2),t.alignX==="Max"&&(u=n),n=a-i/c,t.alignY==="Mid"&&(p=n/2),t.alignY==="Max"&&(p=n),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:n,crossOrigin:o,type:a}=t,l=rt(t,vm);return Promise.all([Ir(n,y(y({},e),{},{crossOrigin:o})),i&&Vs(i,e),s&&Vs([s],e),dn(l,e)]).then((c=>{let[h,d=[],[u]=[],p={}]=c;return new this(h,y(y({},l),{},{src:n,filters:d,resizeFilter:u},p))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Ir(t,{crossOrigin:e,signal:i}).then((n=>new this(n,s)))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=ni(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"]||s.href,e,s).catch((n=>(mi("log","Unable to parse Image",n),null)))}}v(te,"type","Image"),v(te,"cacheProperties",[...ri,...hh]),v(te,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(te,"CSS_CANVAS","canvas-img"),v(te,"ATTRIBUTE_NAMES",[..._i,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),A.setClass(te),A.setSVGClass(te);pn(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const bn=r=>r.webgl!==void 0,Xo="precision highp float",ym=`
2382
2382
  `.concat(Xo,`;
2383
2383
  varying vec2 vTexCoord;
2384
2384
  uniform sampler2D uTexture;
@@ -2390,7 +2390,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2390
2390
  void main() {
2391
2391
  vTexCoord = aPosition;
2392
2392
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
2393
- }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Re();s!=="highp"&&(e=e.replace(wm,Xo.replace("highp",s)));const n=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!n||!o||!a)throw new je("Vertex, fragment shader or program creation error");if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new je("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new je("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,n),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new je('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let n=0;n<i.length;n++)s[i[n]]=t.getUniformLocation(e,i[n]);return s}sendAttributeData(t,e,i){const s=e.aPosition,n=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){bn(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,i=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:i}=t,s=ve({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return _({type:this.type},t.reduce(((e,i)=>(e[i]=this[i],e)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(rt(t,xm))}}v(Mt,"type","BaseFilter"),v(Mt,"uniformLocations",[]);const Cm={multiply:`gl_FragColor.rgb *= uColor.rgb;
2393
+ }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Re();s!=="highp"&&(e=e.replace(wm,Xo.replace("highp",s)));const n=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!n||!o||!a)throw new je("Vertex, fragment shader or program creation error");if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new je("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new je("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,n),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new je('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let n=0;n<i.length;n++)s[i[n]]=t.getUniformLocation(e,i[n]);return s}sendAttributeData(t,e,i){const s=e.aPosition,n=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){bn(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,i=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:i}=t,s=ve({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return y({type:this.type},t.reduce(((e,i)=>(e[i]=this[i],e)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(rt(t,xm))}}v(Mt,"type","BaseFilter"),v(Mt,"uniformLocations",[]);const Cm={multiply:`gl_FragColor.rgb *= uColor.rgb;
2394
2394
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
2395
2395
  `,add:`gl_FragColor.rgb += uColor.rgb;
2396
2396
  `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -2465,7 +2465,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2465
2465
  vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
2466
2466
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
2467
2467
  }
2468
- `}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:n}}=t;const o=this.image;n.blendImage||(n.blendImage=ti());const a=n.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const d=e[h],u=e[h+1],p=e[h+2],g=e[h+3],f=c[h],b=c[h+1],m=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=d*f/255,e[h+1]=u*b/255,e[h+2]=p*m/255,e[h+3]=g*y/255;break;case"mask":e[h+3]=y}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return _(_({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,n=rt(t,Tm);return te.fromObject(s,e).then((o=>new this(_(_({},n),{},{image:o}))))}}v(fr,"type","BlendImage"),v(fr,"defaults",{mode:"multiply",alpha:1}),v(fr,"uniformLocations",["uTransformMatrix","uImage"]),A.setClass(fr);class mr extends Mt{getFragmentSource(){return`
2468
+ `}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:n}}=t;const o=this.image;n.blendImage||(n.blendImage=ti());const a=n.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const d=e[h],u=e[h+1],p=e[h+2],g=e[h+3],f=c[h],m=c[h+1],b=c[h+2],_=c[h+3];switch(this.mode){case"multiply":e[h]=d*f/255,e[h+1]=u*m/255,e[h+2]=p*b/255,e[h+3]=g*_/255;break;case"mask":e[h+3]=_}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return y(y({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,n=rt(t,Tm);return te.fromObject(s,e).then((o=>new this(y(y({},n),{},{image:o}))))}}v(fr,"type","BlendImage"),v(fr,"defaults",{mode:"multiply",alpha:1}),v(fr,"uniformLocations",["uTransformMatrix","uImage"]),A.setClass(fr);class mr extends Mt{getFragmentSource(){return`
2469
2469
  precision highp float;
2470
2470
  uniform sampler2D uTexture;
2471
2471
  uniform vec2 uDelta;
@@ -2494,7 +2494,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2494
2494
  gl_FragColor.rgb = color.rgb / totalC;
2495
2495
  gl_FragColor.a = color.a / totalA;
2496
2496
  }
2497
- `}applyTo(t){bn(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;this.aspectRatio=i/s,this.horizontal=!0;let n=this.getBlurValue()*i;const o=new Uint8ClampedArray(e),a=15,l=4*i;for(let c=0;c<e.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c-c%l,b=f+l;for(let m=-14;m<a;m++){const y=m/a,w=4*Math.floor(n*y),S=1-Math.abs(y);let T=c+w;T<f?T=f:T>b&&(T=b);const O=e[T+3]*S;h+=e[T]*O,d+=e[T+1]*O,u+=e[T+2]*O,p+=O,g+=S}o[c]=h/p,o[c+1]=d/p,o[c+2]=u/p,o[c+3]=p/g}this.horizontal=!1,n=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c%l,b=o.length-l+f;for(let m=-14;m<a;m++){const y=m/a,w=Math.floor(n*y)*l,S=1-Math.abs(y);let T=c+w;T<f?T=f:T>b&&(T=b);const O=o[T+3]*S;h+=o[T]*O,d+=o[T+1]*O,u+=o[T+2]*O,p+=O,g+=S}e[c]=h/p,e[c+1]=d/p,e[c+2]=u/p,e[c+3]=p/g}}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:i}=this;return e?i>1&&(t=1/i):i<1&&(t=i),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}v(mr,"type","Blur"),v(mr,"defaults",{blur:0}),v(mr,"uniformLocations",["uDelta"]),A.setClass(mr);class br extends Mt{getFragmentSource(){return`
2497
+ `}applyTo(t){bn(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;this.aspectRatio=i/s,this.horizontal=!0;let n=this.getBlurValue()*i;const o=new Uint8ClampedArray(e),a=15,l=4*i;for(let c=0;c<e.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c-c%l,m=f+l;for(let b=-14;b<a;b++){const _=b/a,w=4*Math.floor(n*_),S=1-Math.abs(_);let T=c+w;T<f?T=f:T>m&&(T=m);const k=e[T+3]*S;h+=e[T]*k,d+=e[T+1]*k,u+=e[T+2]*k,p+=k,g+=S}o[c]=h/p,o[c+1]=d/p,o[c+2]=u/p,o[c+3]=p/g}this.horizontal=!1,n=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c%l,m=o.length-l+f;for(let b=-14;b<a;b++){const _=b/a,w=Math.floor(n*_)*l,S=1-Math.abs(_);let T=c+w;T<f?T=f:T>m&&(T=m);const k=o[T+3]*S;h+=o[T]*k,d+=o[T+1]*k,u+=o[T+2]*k,p+=k,g+=S}e[c]=h/p,e[c+1]=d/p,e[c+2]=u/p,e[c+3]=p/g}}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:i}=this;return e?i>1&&(t=1/i):i<1&&(t=i),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}v(mr,"type","Blur"),v(mr,"defaults",{blur:0}),v(mr,"uniformLocations",["uDelta"]),A.setClass(mr);class br extends Mt{getFragmentSource(){return`
2498
2498
  precision highp float;
2499
2499
  uniform sampler2D uTexture;
2500
2500
  uniform float uBrightness;
@@ -2515,7 +2515,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2515
2515
  color *= uColorMatrix;
2516
2516
  color += uConstants;
2517
2517
  gl_FragColor = color;
2518
- }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let n=0;n<e.length;n+=4){const o=e[n],a=e[n+1],l=e[n+2];if(e[n]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[n+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[n+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[n+3];e[n]+=c*i[3],e[n+1]+=c*i[8],e[n+2]+=c*i[13],e[n+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],n=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,n)}toObject(){return _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function zi(r,t){var e;const i=(v(e=class extends qi{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",r),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return A.setClass(i,r),i}v(qi,"type","ColorMatrix"),v(qi,"defaults",dh),v(qi,"uniformLocations",["uColorMatrix","uConstants"]),A.setClass(qi);zi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);zi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);zi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);zi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);zi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);zi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);zi("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Pl extends Mt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){bn(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((e=>{e.applyTo(t)}))}toObject(){return{type:this.type,subFilters:this.subFilters.map((t=>t.toObject()))}}isNeutralState(){return!this.subFilters.some((t=>!t.isNeutralState()))}static fromObject(t,e){return Promise.all((t.subFilters||[]).map((i=>A.getClass(i.type).fromObject(i,e)))).then((i=>new this({subFilters:i})))}}v(Pl,"type","Composed"),A.setClass(Pl);class vr extends Mt{getFragmentSource(){return`
2518
+ }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let n=0;n<e.length;n+=4){const o=e[n],a=e[n+1],l=e[n+2];if(e[n]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[n+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[n+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[n+3];e[n]+=c*i[3],e[n+1]+=c*i[8],e[n+2]+=c*i[13],e[n+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],n=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,n)}toObject(){return y(y({},super.toObject()),{},{matrix:[...this.matrix]})}}function zi(r,t){var e;const i=(v(e=class extends qi{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",r),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return A.setClass(i,r),i}v(qi,"type","ColorMatrix"),v(qi,"defaults",dh),v(qi,"uniformLocations",["uColorMatrix","uConstants"]),A.setClass(qi);zi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);zi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);zi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);zi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);zi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);zi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);zi("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Pl extends Mt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){bn(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((e=>{e.applyTo(t)}))}toObject(){return{type:this.type,subFilters:this.subFilters.map((t=>t.toObject()))}}isNeutralState(){return!this.subFilters.some((t=>!t.isNeutralState()))}static fromObject(t,e){return Promise.all((t.subFilters||[]).map((i=>A.getClass(i.type).fromObject(i,e)))).then((i=>new this({subFilters:i})))}}v(Pl,"type","Composed"),A.setClass(Pl);class vr extends Mt{getFragmentSource(){return`
2519
2519
  precision highp float;
2520
2520
  uniform sampler2D uTexture;
2521
2521
  uniform float uContrast;
@@ -2669,7 +2669,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2669
2669
  gl_FragColor = color;
2670
2670
  gl_FragColor.a = alpha;
2671
2671
  }
2672
- `};class yr extends Mt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Em[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,n=Math.round(Math.sqrt(s.length)),o=Math.floor(n/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,p,g,f,b,m,y,w,S,T,O,k,E;for(O=0;O<l;O++)for(T=0;T<a;T++){for(b=4*(O*a+T),u=0,p=0,g=0,f=0,E=0;E<n;E++)for(k=0;k<n;k++)y=O+E-o,m=T+k-o,y<0||y>=l||m<0||m>=a||(w=4*(y*a+m),S=s[E*n+k],u+=i[w]*S,p+=i[w+1]*S,g+=i[w+2]*S,d||(f+=i[w+3]*S));h[b]=u,h[b+1]=p,h[b+2]=g,h[b+3]=d?i[b+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(yr,"type","Convolute"),v(yr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(yr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),A.setClass(yr);const uh="Gamma";class _r extends Mt{getFragmentSource(){return`
2672
+ `};class yr extends Mt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Em[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,n=Math.round(Math.sqrt(s.length)),o=Math.floor(n/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,p,g,f,m,b,_,w,S,T,k,O,E;for(k=0;k<l;k++)for(T=0;T<a;T++){for(m=4*(k*a+T),u=0,p=0,g=0,f=0,E=0;E<n;E++)for(O=0;O<n;O++)_=k+E-o,b=T+O-o,_<0||_>=l||b<0||b>=a||(w=4*(_*a+b),S=s[E*n+O],u+=i[w]*S,p+=i[w+1]*S,g+=i[w+2]*S,d||(f+=i[w+3]*S));h[m]=u,h[m+1]=p,h[m+2]=g,h[m+3]=d?i[m+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return y(y({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(yr,"type","Convolute"),v(yr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(yr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),A.setClass(yr);const uh="Gamma";class _r extends Mt{getFragmentSource(){return`
2673
2673
  precision highp float;
2674
2674
  uniform sampler2D uTexture;
2675
2675
  uniform vec3 uGamma;
@@ -2712,7 +2712,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2712
2712
  float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
2713
2713
  gl_FragColor = vec4(average, average, average, col.a);
2714
2714
  }
2715
- `};class xr extends Mt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(n+o+a)/3;break;case"lightness":i=(Math.min(n,o,a)+Math.max(n,o,a))/2;break;case"luminosity":i=.21*n+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Om[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(xr,"type","Grayscale"),v(xr,"defaults",{mode:"average"}),v(xr,"uniformLocations",["uMode"]),A.setClass(xr);const km=_(_({},dh),{},{rotation:0});class Un extends qi{calculateMatrix(){const t=this.rotation*Math.PI,e=Je(t),i=Qe(t),s=1/3,n=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-n,s*o+n,0,0,s*o+n,e+s*o,s*o-n,0,0,s*o-n,s*o+n,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(Un,"type","HueRotation"),v(Un,"defaults",km),A.setClass(Un);class wr extends Mt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return`
2715
+ `};class xr extends Mt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(n+o+a)/3;break;case"lightness":i=(Math.min(n,o,a)+Math.max(n,o,a))/2;break;case"luminosity":i=.21*n+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Om[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(xr,"type","Grayscale"),v(xr,"defaults",{mode:"average"}),v(xr,"uniformLocations",["uMode"]),A.setClass(xr);const km=y(y({},dh),{},{rotation:0});class Un extends qi{calculateMatrix(){const t=this.rotation*Math.PI,e=Je(t),i=Qe(t),s=1/3,n=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-n,s*o+n,0,0,s*o+n,e+s*o,s*o-n,0,0,s*o-n,s*o+n,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(Un,"type","HueRotation"),v(Un,"defaults",km),A.setClass(Un);class wr extends Mt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return`
2716
2716
  precision highp float;
2717
2717
  uniform sampler2D uTexture;
2718
2718
  uniform int uInvert;
@@ -2791,7 +2791,7 @@ void main() {
2791
2791
  `),`
2792
2792
  gl_FragColor = color / sum;
2793
2793
  }
2794
- `)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){bn(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const n=e.width,o=e.height,a=Math.round(n*i),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,n,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,n,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,n,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,n,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,n){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,d=i*a;const u=t.filterBackend.resources;let p=0,g=0;const f=e;let b=0;u.sliceByTwo||(u.sliceByTwo=ti());const m=u.sliceByTwo;(m.width<1.5*e||m.height<i)&&(m.width=1.5*e,m.height=i);const y=m.getContext("2d");for(y.clearRect(0,0,1.5*e,i),y.putImageData(o,0,0),s=Math.floor(s),n=Math.floor(n);!l||!c;)e=h,i=d,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),n<Math.floor(d*a)?d=Math.floor(d*a):(d=n,c=!0),y.drawImage(m,p,g,e,i,f,b,h,d),p=f,g=b,b+=d;return y.getImageData(p,g,s,n)}lanczosResize(t,e,i,s,n){const o=t.imageData.data,a=t.ctx.createImageData(s,n),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,d=this.rcpScaleY,u=2/this.rcpScaleX,p=2/this.rcpScaleY,g=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(d*this.lanczosLobes/2),b={},m={x:0,y:0},y={x:0,y:0};return(function w(S){let T,O,k,E,P,R,L,F,H,M,U;for(m.x=(S+.5)*h,y.x=Math.floor(m.x),T=0;T<n;T++){for(m.y=(T+.5)*d,y.y=Math.floor(m.y),P=0,R=0,L=0,F=0,H=0,O=y.x-g;O<=y.x+g;O++)if(!(O<0||O>=e)){M=Math.floor(1e3*Math.abs(O-m.x)),b[M]||(b[M]={});for(let X=y.y-f;X<=y.y+f;X++)X<0||X>=i||(U=Math.floor(1e3*Math.abs(X-m.y)),b[M][U]||(b[M][U]=c(Math.sqrt(Math.pow(M*u,2)+Math.pow(U*p,2))/1e3)),k=b[M][U],k>0&&(E=4*(X*e+O),P+=k,R+=k*o[E],L+=k*o[E+1],F+=k*o[E+2],H+=k*o[E+3]))}E=4*(T*s+S),l[E]=R/P,l[E+1]=L/P,l[E+2]=F/P,l[E+3]=H/P}return++S<s?w(S):a})(0)}bilinearFiltering(t,e,i,s,n){let o,a,l,c,h,d,u,p,g,f,b,m,y,w=0;const S=this.rcpScaleX,T=this.rcpScaleY,O=4*(e-1),k=t.imageData.data,E=t.ctx.createImageData(s,n),P=E.data;for(u=0;u<n;u++)for(p=0;p<s;p++)for(h=Math.floor(S*p),d=Math.floor(T*u),g=S*p-h,f=T*u-d,y=4*(d*e+h),b=0;b<4;b++)o=k[y+b],a=k[y+4+b],l=k[y+O+b],c=k[y+O+4+b],m=o*(1-g)*(1-f)+a*g*(1-f)+l*f*(1-g)+c*g*f,P[w++]=m;return E}hermiteFastResize(t,e,i,s,n){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,d=t.ctx.createImageData(s,n),u=d.data;for(let p=0;p<n;p++)for(let g=0;g<s;g++){const f=4*(g+p*s);let b=0,m=0,y=0,w=0,S=0,T=0,O=0;const k=(p+.5)*a;for(let E=Math.floor(p*a);E<(p+1)*a;E++){const P=Math.abs(k-(E+.5))/c,R=(g+.5)*o,L=P*P;for(let F=Math.floor(g*o);F<(g+1)*o;F++){let H=Math.abs(R-(F+.5))/l;const M=Math.sqrt(L+H*H);M>1&&M<-1||(b=2*M*M*M-3*M*M+1,b>0&&(H=4*(F+E*e),O+=b*h[H+3],y+=b,h[H+3]<255&&(b=b*h[H+3]/250),w+=b*h[H],S+=b*h[H+1],T+=b*h[H+2],m+=b))}}u[f]=w/m,u[f+1]=S/m,u[f+2]=T/m,u[f+3]=O/y}return d}}v(Er,"type","Resize"),v(Er,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(Er,"uniformLocations",["uDelta","uTaps"]),A.setClass(Er);class Or extends Mt{getFragmentSource(){return`
2794
+ `)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){bn(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const n=e.width,o=e.height,a=Math.round(n*i),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,n,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,n,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,n,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,n,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,n){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,d=i*a;const u=t.filterBackend.resources;let p=0,g=0;const f=e;let m=0;u.sliceByTwo||(u.sliceByTwo=ti());const b=u.sliceByTwo;(b.width<1.5*e||b.height<i)&&(b.width=1.5*e,b.height=i);const _=b.getContext("2d");for(_.clearRect(0,0,1.5*e,i),_.putImageData(o,0,0),s=Math.floor(s),n=Math.floor(n);!l||!c;)e=h,i=d,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),n<Math.floor(d*a)?d=Math.floor(d*a):(d=n,c=!0),_.drawImage(b,p,g,e,i,f,m,h,d),p=f,g=m,m+=d;return _.getImageData(p,g,s,n)}lanczosResize(t,e,i,s,n){const o=t.imageData.data,a=t.ctx.createImageData(s,n),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,d=this.rcpScaleY,u=2/this.rcpScaleX,p=2/this.rcpScaleY,g=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(d*this.lanczosLobes/2),m={},b={x:0,y:0},_={x:0,y:0};return(function w(S){let T,k,O,E,P,R,L,F,H,M,U;for(b.x=(S+.5)*h,_.x=Math.floor(b.x),T=0;T<n;T++){for(b.y=(T+.5)*d,_.y=Math.floor(b.y),P=0,R=0,L=0,F=0,H=0,k=_.x-g;k<=_.x+g;k++)if(!(k<0||k>=e)){M=Math.floor(1e3*Math.abs(k-b.x)),m[M]||(m[M]={});for(let X=_.y-f;X<=_.y+f;X++)X<0||X>=i||(U=Math.floor(1e3*Math.abs(X-b.y)),m[M][U]||(m[M][U]=c(Math.sqrt(Math.pow(M*u,2)+Math.pow(U*p,2))/1e3)),O=m[M][U],O>0&&(E=4*(X*e+k),P+=O,R+=O*o[E],L+=O*o[E+1],F+=O*o[E+2],H+=O*o[E+3]))}E=4*(T*s+S),l[E]=R/P,l[E+1]=L/P,l[E+2]=F/P,l[E+3]=H/P}return++S<s?w(S):a})(0)}bilinearFiltering(t,e,i,s,n){let o,a,l,c,h,d,u,p,g,f,m,b,_,w=0;const S=this.rcpScaleX,T=this.rcpScaleY,k=4*(e-1),O=t.imageData.data,E=t.ctx.createImageData(s,n),P=E.data;for(u=0;u<n;u++)for(p=0;p<s;p++)for(h=Math.floor(S*p),d=Math.floor(T*u),g=S*p-h,f=T*u-d,_=4*(d*e+h),m=0;m<4;m++)o=O[_+m],a=O[_+4+m],l=O[_+k+m],c=O[_+k+4+m],b=o*(1-g)*(1-f)+a*g*(1-f)+l*f*(1-g)+c*g*f,P[w++]=b;return E}hermiteFastResize(t,e,i,s,n){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,d=t.ctx.createImageData(s,n),u=d.data;for(let p=0;p<n;p++)for(let g=0;g<s;g++){const f=4*(g+p*s);let m=0,b=0,_=0,w=0,S=0,T=0,k=0;const O=(p+.5)*a;for(let E=Math.floor(p*a);E<(p+1)*a;E++){const P=Math.abs(O-(E+.5))/c,R=(g+.5)*o,L=P*P;for(let F=Math.floor(g*o);F<(g+1)*o;F++){let H=Math.abs(R-(F+.5))/l;const M=Math.sqrt(L+H*H);M>1&&M<-1||(m=2*M*M*M-3*M*M+1,m>0&&(H=4*(F+E*e),k+=m*h[H+3],_+=m,h[H+3]<255&&(m=m*h[H+3]/250),w+=m*h[H],S+=m*h[H+1],T+=m*h[H+2],b+=m))}}u[f]=w/b,u[f+1]=S/b,u[f+2]=T/b,u[f+3]=k/_}return d}}v(Er,"type","Resize"),v(Er,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(Er,"uniformLocations",["uDelta","uTaps"]),A.setClass(Er);class Or extends Mt{getFragmentSource(){return`
2795
2795
  precision highp float;
2796
2796
  uniform sampler2D uTexture;
2797
2797
  uniform float uSaturation;
@@ -2878,9 +2878,9 @@ void main() {
2878
2878
  .type-canvas-container.image-loading pbo-image {
2879
2879
  display: block;
2880
2880
  }
2881
- `;var Mm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,mt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Im(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mm(t,e,s),s};const Wn=[{family:"Calibri",label:"Calibri",fontSizePt:15.9,lineHeight:1.185,maxLines:{default:12,fullSize:23}},{family:"Caveat",label:"Caveat",fontSizePt:16.5,lineHeight:1.245,maxLines:{default:11,fullSize:21}},{family:"Dancing Script",label:"Dancing Script",fontSizePt:16.4,lineHeight:1.25,maxLines:{default:11,fullSize:21}},{family:"Kalam",label:"Kalam",fontSizePt:15,lineHeight:1.25,maxLines:{default:12,fullSize:23}},{family:"Reenie Beanie",label:"Reenie Beanie",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}},{family:"Great Vibes",label:"Great Vibes",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}}],ws={width:5,displayArea:{default:{x:.42,y:3.43,width:4.16,height:3.15},fullSize:{x:.42,y:.42,width:4.16,height:6.16}}};let nt=class extends kt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.displayType="default",this.scale=1,this.logicalSize={width:0,height:0},this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0},this.imgLoading=!1,this.backgroundImage=void 0,this.resizeObserver=void 0,this.dpi=0,this.fontConfig=Wn.find(r=>r.family==="Arial"),this.processedMessage=""}async handleBackgroundImageUrlChange(){this.imgLoading=!0,await this.appendBackgroundImageToCanvas(this.backgroundImageUrl??"",()=>{this.imgLoading=!1}),this.updateTextAreaPosition()}handleBackgroundImageChange(){if(!this.backgroundImage)return;const r=this.canvas.getContext("2d");if(!r)throw new Error("Could not get canvas context");r.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height)}handleProcessedMessageChange(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.emit("pbo-type-canvas-processed",{detail:{message:this.processedMessage}})},300)}inchToPixel(r,t){return r*t}ptToInch(r){return r/72}firstUpdated(){this.resizeObserver=new ResizeObserver(()=>{this.updateTextAreaPosition()}),this.resizeObserver.observe(this.canvasContainer)}updated(r){var t,e,i;if(r.has("message")||r.has("font")||r.has("color")||r.has("alignment")||r.has("areaPosition")||r.has("areaSize")||r.has("displayType")){if(!this.backgroundImage||this.areaSize.width===0||this.areaSize.height===0)return;const s=this.canvas.getContext("2d");if(!s)return;s.clearRect(0,0,this.logicalSize.width,this.logicalSize.height),s.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.fontConfig=Wn.find(n=>n.family===this.font)||Wn[0],this.wrapText({ctx:s,message:this.message,areaPosition:this.areaPosition,areaSize:this.areaSize,maxLineSize:((t=this.fontConfig)==null?void 0:t.maxLines[this.displayType])||12,alignment:this.alignment,fontSizePt:((e=this.fontConfig)==null?void 0:e.fontSizePt)||15.9,lineHeight:((i=this.fontConfig)==null?void 0:i.lineHeight)||1.185,verticalAlignment:this.displayType==="fullSize"?"middle":"top"})}}getMaxStringLength(r,t,e){let i=0;for(let s=1;s<=t.length;s++){const n=t.substring(0,s);if(r.measureText(n).width>e)break;i=s}return i}wrapText({ctx:r,message:t,areaPosition:e,areaSize:i,maxLineSize:s,alignment:n,lineHeight:o=1.185,fontSizePt:a,verticalAlignment:l}){if(!r||!t||!e||!i)return;const h=i.height/s/1.2,d=this.inchToPixel(this.ptToInch(a),this.dpi),u=t.split(`
2882
- `);let p=[];r.font=`${h}px ${this.font}`,u.forEach(f=>{const b=f.split(" ");let m="";for(let y=0;y<b.length;y++)if(r.measureText(b[y]).width>i.width){const T=this.getMaxStringLength(r,b[y],i.width),O=b[y];y+1<b.length?(b[y]=O.substring(0,T),b[y+1]=O.substring(T,O.length)+b[y+1]):(b[y]=O.substring(0,T),b.push(O.substring(T,O.length)))}for(let y=0;y<b.length;y++){let w=m+b[y]+" ";r.measureText(w).width>i.width&&y>0?(p.push(m),m=b[y]+" "):m=w}p.push(m)}),this.processedMessage=p.slice(0,s).join(`
2883
- `);let g=this.areaPosition.left;if(n==="center"&&(g+=this.areaSize.width/2),n==="right"&&(g+=this.areaSize.width),l==="top"){r.textBaseline="top";for(let f=0;f<s&&f<p.length;f++){const b=p[f];r.fillStyle=this.color,r.textAlign=n,r.fillText(b,g,this.areaPosition.top+f*d*o)}}if(l==="middle"){r.textBaseline="middle";for(let f=0;f<s&&f<p.length;f++){const b=p[f],m=Math.min(p.length,s),y=(f+1-m/2-.5)*d*o;r.fillStyle=this.color,r.textAlign=n,r.fillText(b,g,y+this.areaPosition.top+this.areaSize.height/2)}}}updateTextAreaPosition(){if(!this.canvas||!this.backgroundImage)return;const r=window.devicePixelRatio||1,t=this.canvasContainer.clientWidth;this.scale=t/this.backgroundImage.width,this.logicalSize={width:this.canvasContainer.clientWidth,height:this.backgroundImage.height*this.scale},this.canvas.width=this.logicalSize.width*r,this.canvas.height=this.logicalSize.height*r,this.canvas.style.width=`${this.logicalSize.width}px`,this.canvas.style.height=`${this.logicalSize.height}px`;const e=this.canvas.getContext("2d");e&&(e.setTransform(1,0,0,1,0,0),e.scale(r,r),e.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.dpi=this.logicalSize.width/ws.width,this.areaPosition={left:this.inchToPixel(ws.displayArea[this.displayType].x,this.dpi),top:this.inchToPixel(ws.displayArea[this.displayType].y,this.dpi)},this.areaSize={width:this.inchToPixel(ws.displayArea[this.displayType].width,this.dpi),height:this.inchToPixel(ws.displayArea[this.displayType].height,this.dpi)})}async appendBackgroundImageToCanvas(r,t){return new Promise((e,i)=>{const s=new Image;s.onerror=()=>{i(new Error("Failed to load image"))},s.onload=()=>{this.backgroundImage=s,t&&t(),e()},r!==""&&(s.src=r)})}render(){return j`
2881
+ `;var Mm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,mt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Im(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mm(t,e,s),s};const Wn=[{family:"Calibri",label:"Calibri",fontSizePt:15.9,lineHeight:1.185,maxLines:{default:12,fullSize:23}},{family:"Caveat",label:"Caveat",fontSizePt:16.5,lineHeight:1.245,maxLines:{default:11,fullSize:21}},{family:"Dancing Script",label:"Dancing Script",fontSizePt:16.4,lineHeight:1.25,maxLines:{default:11,fullSize:21}},{family:"Kalam",label:"Kalam",fontSizePt:15,lineHeight:1.25,maxLines:{default:12,fullSize:23}},{family:"Reenie Beanie",label:"Reenie Beanie",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}},{family:"Great Vibes",label:"Great Vibes",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}}],ws={width:5,displayArea:{default:{x:.42,y:3.43,width:4.16,height:3.15},fullSize:{x:.42,y:.42,width:4.16,height:6.16}}};let nt=class extends kt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.displayType="default",this.scale=1,this.logicalSize={width:0,height:0},this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0},this.imgLoading=!1,this.backgroundImage=void 0,this.resizeObserver=void 0,this.dpi=0,this.fontConfig=Wn.find(r=>r.family==="Arial"),this.processedMessage=""}async handleBackgroundImageUrlChange(){this.imgLoading=!0,await this.appendBackgroundImageToCanvas(this.backgroundImageUrl??"",()=>{this.imgLoading=!1}),this.updateTextAreaPosition()}handleBackgroundImageChange(){if(!this.backgroundImage)return;const r=this.canvas.getContext("2d");if(!r)throw new Error("Could not get canvas context");r.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height)}handleProcessedMessageChange(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.emit("pbo-type-canvas-processed",{detail:{message:this.processedMessage}})},300)}inchToPixel(r,t){return r*t}ptToInch(r){return r/72}firstUpdated(){this.resizeObserver=new ResizeObserver(()=>{this.updateTextAreaPosition()}),this.resizeObserver.observe(this.canvasContainer)}updated(r){var t,e,i;if(r.has("message")||r.has("font")||r.has("color")||r.has("alignment")||r.has("areaPosition")||r.has("areaSize")||r.has("displayType")){if(!this.backgroundImage||this.areaSize.width===0||this.areaSize.height===0)return;const s=this.canvas.getContext("2d");if(!s)return;s.clearRect(0,0,this.logicalSize.width,this.logicalSize.height),s.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.fontConfig=Wn.find(n=>n.family===this.font)||Wn[0],this.wrapText({ctx:s,message:this.message,areaPosition:this.areaPosition,areaSize:this.areaSize,maxLineSize:((t=this.fontConfig)==null?void 0:t.maxLines[this.displayType])||12,alignment:this.alignment,fontSizePt:((e=this.fontConfig)==null?void 0:e.fontSizePt)||15.9,lineHeight:((i=this.fontConfig)==null?void 0:i.lineHeight)||1.185,verticalAlignment:this.displayType==="fullSize"?"middle":"top"})}}getMaxStringLength(r,t,e){let i=0;for(let s=1;s<=t.length;s++){const n=t.substring(0,s);if(r.measureText(n).width>e)break;i=s}return i}wrapText({ctx:r,message:t,areaPosition:e,areaSize:i,maxLineSize:s,alignment:n,lineHeight:o=1.185,fontSizePt:a,verticalAlignment:l}){if(!r||!t||!e||!i)return;const c=this.inchToPixel(this.ptToInch(a),this.dpi),h=t.split(`
2882
+ `);let d=[];r.font=`400 ${c}px ${this.font}`,h.forEach(p=>{const g=p.split(" ");let f="";for(let m=0;m<g.length;m++)if(r.measureText(g[m]).width>i.width){const w=this.getMaxStringLength(r,g[m],i.width),S=g[m];m+1<g.length?(g[m]=S.substring(0,w),g[m+1]=S.substring(w,S.length)+g[m+1]):(g[m]=S.substring(0,w),g.push(S.substring(w,S.length)))}for(let m=0;m<g.length;m++){let b=f+g[m]+" ";r.measureText(b).width>i.width&&m>0?(d.push(f),f=g[m]+" "):f=b}d.push(f)}),this.processedMessage=d.slice(0,s).join(`
2883
+ `);let u=this.areaPosition.left;if(n==="center"&&(u+=this.areaSize.width/2),n==="right"&&(u+=this.areaSize.width),l==="top"){r.textBaseline="top";for(let p=0;p<s&&p<d.length;p++){const g=d[p];r.fillStyle=this.color,r.textAlign=n,r.fillText(g,u,this.areaPosition.top+p*c*o)}}if(l==="middle"){r.textBaseline="middle";for(let p=0;p<s&&p<d.length;p++){const g=d[p],f=Math.min(d.length,s),m=(p+1-f/2-.5)*c*o;r.fillStyle=this.color,r.textAlign=n,r.fillText(g,u,m+this.areaPosition.top+this.areaSize.height/2)}}}updateTextAreaPosition(){if(!this.canvas||!this.backgroundImage)return;const r=window.devicePixelRatio||1,t=this.canvasContainer.clientWidth;this.scale=t/this.backgroundImage.width,this.logicalSize={width:this.canvasContainer.clientWidth,height:this.backgroundImage.height*this.scale},this.canvas.width=this.logicalSize.width*r,this.canvas.height=this.logicalSize.height*r,this.canvas.style.width=`${this.logicalSize.width}px`,this.canvas.style.height=`${this.logicalSize.height}px`;const e=this.canvas.getContext("2d");e&&(e.setTransform(1,0,0,1,0,0),e.scale(r,r),e.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.dpi=this.logicalSize.width/ws.width,this.areaPosition={left:this.inchToPixel(ws.displayArea[this.displayType].x,this.dpi),top:this.inchToPixel(ws.displayArea[this.displayType].y,this.dpi)},this.areaSize={width:this.inchToPixel(ws.displayArea[this.displayType].width,this.dpi),height:this.inchToPixel(ws.displayArea[this.displayType].height,this.dpi)})}async appendBackgroundImageToCanvas(r,t){return new Promise((e,i)=>{const s=new Image;s.onerror=()=>{i(new Error("Failed to load image"))},s.onload=()=>{this.backgroundImage=s,t&&t(),e()},r!==""&&(s.src=r)})}render(){return j`
2884
2884
  <div
2885
2885
  class="${me({"type-canvas-container":!0,"image-loading":this.imgLoading})}
2886
2886
  "
@@ -3001,7 +3001,7 @@ void main() {
3001
3001
  <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
3002
3002
  <line x1="11" y1="8" x2="11" y2="14"></line>
3003
3003
  <line x1="8" y1="11" x2="14" y2="11"></line>
3004
- </svg>`}render(){var r,t,e,i,s,n,o,a,l,c,h,d,u,p,g,f,b,m,y,w,S,T,O,k;return j`
3004
+ </svg>`}render(){var r,t,e,i,s,n,o,a,l,c,h,d,u,p,g,f,m,b,_,w,S,T,k,O;return j`
3005
3005
  <div class="card--slider--wrapper">
3006
3006
  <div id="thumbnails" class="thumbnails">
3007
3007
  <button
@@ -3117,9 +3117,9 @@ void main() {
3117
3117
  />
3118
3118
  ${Dn(this.type==="type"?j`<pbo-type-canvas
3119
3119
  background-url=${(f=this.card)==null?void 0:f.medias.insert.url}
3120
- message=${(b=this.livePreviewProps)==null?void 0:b.text}
3121
- alignment=${((m=this.livePreviewProps)==null?void 0:m.alignment)||"left"}
3122
- color=${(y=this.livePreviewProps)==null?void 0:y.color}
3120
+ message=${(m=this.livePreviewProps)==null?void 0:m.text}
3121
+ alignment=${((b=this.livePreviewProps)==null?void 0:b.alignment)||"left"}
3122
+ color=${(_=this.livePreviewProps)==null?void 0:_.color}
3123
3123
  font=${(w=this.livePreviewProps)==null?void 0:w.font}
3124
3124
  display-type=${(S=this.card)!=null&&S.hasEditorial?"default":"fullSize"}
3125
3125
  @click="${this.handleOpenZoomedClick}"
@@ -3129,12 +3129,12 @@ void main() {
3129
3129
  id="handwritten-zoomed-preview-canvas"
3130
3130
  background-url=${(T=this.card)==null?void 0:T.medias.insert.url}
3131
3131
  handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
3132
- display-type=${(O=this.card)!=null&&O.hasEditorial?"default":"fullSize"}
3132
+ display-type=${(k=this.card)!=null&&k.hasEditorial?"default":"fullSize"}
3133
3133
  @click="${this.handleOpenZoomedClick}"
3134
3134
  style=${pe({display:this.focusIndex===1?"block":"none"})}
3135
3135
  ></pbo-handwritten-canvas>`:q)}
3136
3136
  <img
3137
- src="${(k=this.card)==null?void 0:k.medias.rendered_2.url}"
3137
+ src="${(O=this.card)==null?void 0:O.medias.rendered_2.url}"
3138
3138
  alt=""
3139
3139
  style=${pe({display:this.focusIndex===2?"block":"none"})}
3140
3140
  />