@arantic/bugpin-widget 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -1,112 +1,112 @@
1
- var BugPin=function(br){"use strict";var cs,st,Gn,je,$n,qn,Kn,Zn,vi,yi,bi,wr={},Jn=[],vc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,xr=Array.isArray;function he(i,t){for(var e in t)i[e]=t[e];return i}function wi(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function _r(i,t,e){var r,s,n,o={};for(n in t)n=="key"?r=t[n]:n=="ref"?s=t[n]:o[n]=t[n];if(arguments.length>2&&(o.children=arguments.length>3?cs.call(arguments,2):e),typeof i=="function"&&i.defaultProps!=null)for(n in i.defaultProps)o[n]===void 0&&(o[n]=i.defaultProps[n]);return hs(i,o,r,s,null)}function hs(i,t,e,r,s){var n={type:i,props:t,key:e,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Gn,__i:-1,__u:0};return s==null&&st.vnode!=null&&st.vnode(n),n}function us(i){return i.children}function ds(i,t){this.props=i,this.context=t}function Ue(i,t){if(t==null)return i.__?Ue(i.__,i.__i+1):null;for(var e;t<i.__k.length;t++)if((e=i.__k[t])!=null&&e.__e!=null)return e.__e;return typeof i.type=="function"?Ue(i):null}function Qn(i){var t,e;if((i=i.__)!=null&&i.__c!=null){for(i.__e=i.__c.base=null,t=0;t<i.__k.length;t++)if((e=i.__k[t])!=null&&e.__e!=null){i.__e=i.__c.base=e.__e;break}return Qn(i)}}function to(i){(!i.__d&&(i.__d=!0)&&je.push(i)&&!gs.__r++||$n!=st.debounceRendering)&&(($n=st.debounceRendering)||qn)(gs)}function gs(){for(var i,t,e,r,s,n,o,a=1;je.length;)je.length>a&&je.sort(Kn),i=je.shift(),a=je.length,i.__d&&(e=void 0,r=void 0,s=(r=(t=i).__v).__e,n=[],o=[],t.__P&&((e=he({},r)).__v=r.__v+1,st.vnode&&st.vnode(e),xi(t.__P,e,r,t.__n,t.__P.namespaceURI,32&r.__u?[s]:null,n,s??Ue(r),!!(32&r.__u),o),e.__v=r.__v,e.__.__k[e.__i]=e,oo(n,e,o),r.__e=r.__=null,e.__e!=s&&Qn(e)));gs.__r=0}function eo(i,t,e,r,s,n,o,a,l,c,h){var u,d,g,f,p,v,b,x=r&&r.__k||Jn,D=t.length;for(l=yc(e,t,x,l,D),u=0;u<D;u++)(g=e.__k[u])!=null&&(d=g.__i==-1?wr:x[g.__i]||wr,g.__i=u,v=xi(i,g,d,s,n,o,a,l,c,h),f=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&Ci(d.ref,null,g),h.push(g.ref,g.__c||f,g)),p==null&&f!=null&&(p=f),(b=!!(4&g.__u))||d.__k===g.__k?l=ro(g,l,i,b):typeof g.type=="function"&&v!==void 0?l=v:f&&(l=f.nextSibling),g.__u&=-7);return e.__e=p,l}function yc(i,t,e,r,s){var n,o,a,l,c,h=e.length,u=h,d=0;for(i.__k=new Array(s),n=0;n<s;n++)(o=t[n])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=i.__k[n]=hs(null,o,null,null,null):xr(o)?o=i.__k[n]=hs(us,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=i.__k[n]=hs(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):i.__k[n]=o,l=n+d,o.__=i,o.__b=i.__b+1,a=null,(c=o.__i=bc(o,e,l,u))!=-1&&(u--,(a=e[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(s>h?d--:s<h&&d++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?d--:c==l+1?d++:(c>l?d--:d++,o.__u|=4))):i.__k[n]=null;if(u)for(n=0;n<h;n++)(a=e[n])!=null&&!(2&a.__u)&&(a.__e==r&&(r=Ue(a)),lo(a,a));return r}function ro(i,t,e,r){var s,n;if(typeof i.type=="function"){for(s=i.__k,n=0;s&&n<s.length;n++)s[n]&&(s[n].__=i,t=ro(s[n],t,e,r));return t}i.__e!=t&&(r&&(t&&i.type&&!t.parentNode&&(t=Ue(i)),e.insertBefore(i.__e,t||null)),t=i.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function so(i,t){return t=t||[],i==null||typeof i=="boolean"||(xr(i)?i.some(function(e){so(e,t)}):t.push(i)),t}function bc(i,t,e,r){var s,n,o,a=i.key,l=i.type,c=t[e],h=c!=null&&(2&c.__u)==0;if(c===null&&a==null||h&&a==c.key&&l==c.type)return e;if(r>(h?1:0)){for(s=e-1,n=e+1;s>=0||n<t.length;)if((c=t[o=s>=0?s--:n++])!=null&&!(2&c.__u)&&a==c.key&&l==c.type)return o}return-1}function io(i,t,e){t[0]=="-"?i.setProperty(t,e??""):i[t]=e==null?"":typeof e!="number"||vc.test(t)?e:e+"px"}function fs(i,t,e,r,s){var n,o;t:if(t=="style")if(typeof e=="string")i.style.cssText=e;else{if(typeof r=="string"&&(i.style.cssText=r=""),r)for(t in r)e&&t in e||io(i.style,t,"");if(e)for(t in e)r&&e[t]==r[t]||io(i.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")n=t!=(t=t.replace(Zn,"$1")),o=t.toLowerCase(),t=o in i||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),i.l||(i.l={}),i.l[t+n]=e,e?r?e.u=r.u:(e.u=vi,i.addEventListener(t,n?bi:yi,n)):i.removeEventListener(t,n?bi:yi,n);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in i)try{i[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?i.removeAttribute(t):i.setAttribute(t,t=="popover"&&e==1?"":e))}}function no(i){return function(t){if(this.l){var e=this.l[t.type+i];if(t.t==null)t.t=vi++;else if(t.t<e.u)return;return e(st.event?st.event(t):t)}}}function xi(i,t,e,r,s,n,o,a,l,c){var h,u,d,g,f,p,v,b,x,D,C,O,S,j,T,L,H,W=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),n=[a=t.__e=e.__e]),(h=st.__b)&&h(t);t:if(typeof W=="function")try{if(b=t.props,x="prototype"in W&&W.prototype.render,D=(h=W.contextType)&&r[h.__c],C=h?D?D.props.value:h.__:r,e.__c?v=(u=t.__c=e.__c).__=u.__E:(x?t.__c=u=new W(b,C):(t.__c=u=new ds(b,C),u.constructor=W,u.render=xc),D&&D.sub(u),u.state||(u.state={}),u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),x&&u.__s==null&&(u.__s=u.state),x&&W.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=he({},u.__s)),he(u.__s,W.getDerivedStateFromProps(b,u.__s))),g=u.props,f=u.state,u.__v=t,d)x&&W.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),x&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(x&&W.getDerivedStateFromProps==null&&b!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,C),t.__v==e.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,C)===!1){for(t.__v!=e.__v&&(u.props=b,u.state=u.__s,u.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(V){V&&(V.__=t)}),O=0;O<u._sb.length;O++)u.__h.push(u._sb[O]);u._sb=[],u.__h.length&&o.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,C),x&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,f,p)})}if(u.context=C,u.props=b,u.__P=i,u.__e=!1,S=st.__r,j=0,x){for(u.state=u.__s,u.__d=!1,S&&S(t),h=u.render(u.props,u.state,u.context),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);u._sb=[]}else do u.__d=!1,S&&S(t),h=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++j<25);u.state=u.__s,u.getChildContext!=null&&(r=he(he({},r),u.getChildContext())),x&&!d&&u.getSnapshotBeforeUpdate!=null&&(p=u.getSnapshotBeforeUpdate(g,f)),L=h,h!=null&&h.type===us&&h.key==null&&(L=ao(h.props.children)),a=eo(i,xr(L)?L:[L],t,e,r,s,n,o,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),v&&(u.__E=u.__=null)}catch(V){if(t.__v=null,l||n!=null)if(V.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;n[n.indexOf(a)]=null,t.__e=a}else{for(H=n.length;H--;)wi(n[H]);_i(t)}else t.__e=e.__e,t.__k=e.__k,V.then||_i(t);st.__e(V,t,e)}else n==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=wc(e.__e,t,e,r,s,n,o,l,c);return(h=st.diffed)&&h(t),128&t.__u?void 0:a}function _i(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(_i)}function oo(i,t,e){for(var r=0;r<e.length;r++)Ci(e[r],e[++r],e[++r]);st.__c&&st.__c(t,i),i.some(function(s){try{i=s.__h,s.__h=[],i.some(function(n){n.call(s)})}catch(n){st.__e(n,s.__v)}})}function ao(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:xr(i)?i.map(ao):he({},i)}function wc(i,t,e,r,s,n,o,a,l){var c,h,u,d,g,f,p,v=e.props||wr,b=t.props,x=t.type;if(x=="svg"?s="http://www.w3.org/2000/svg":x=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),n!=null){for(c=0;c<n.length;c++)if((g=n[c])&&"setAttribute"in g==!!x&&(x?g.localName==x:g.nodeType==3)){i=g,n[c]=null;break}}if(i==null){if(x==null)return document.createTextNode(b);i=document.createElementNS(s,x,b.is&&b),a&&(st.__m&&st.__m(t,n),a=!1),n=null}if(x==null)v===b||a&&i.data==b||(i.data=b);else{if(n=n&&cs.call(i.childNodes),!a&&n!=null)for(v={},c=0;c<i.attributes.length;c++)v[(g=i.attributes[c]).name]=g.value;for(c in v)if(g=v[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=g;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;fs(i,c,null,g,s)}}for(c in b)g=b[c],c=="children"?d=g:c=="dangerouslySetInnerHTML"?h=g:c=="value"?f=g:c=="checked"?p=g:a&&typeof g!="function"||v[c]===g||fs(i,c,g,v[c],s);if(h)a||u&&(h.__html==u.__html||h.__html==i.innerHTML)||(i.innerHTML=h.__html),t.__k=[];else if(u&&(i.innerHTML=""),eo(t.type=="template"?i.content:i,xr(d)?d:[d],t,e,r,x=="foreignObject"?"http://www.w3.org/1999/xhtml":s,n,o,n?n[0]:e.__k&&Ue(e,0),a,l),n!=null)for(c=n.length;c--;)wi(n[c]);a||(c="value",x=="progress"&&f==null?i.removeAttribute("value"):f!=null&&(f!==i[c]||x=="progress"&&!f||x=="option"&&f!=v[c])&&fs(i,c,f,v[c],s),c="checked",p!=null&&p!=i[c]&&fs(i,c,p,v[c],s))}return i}function Ci(i,t,e){try{if(typeof i=="function"){var r=typeof i.__u=="function";r&&i.__u(),r&&t==null||(i.__u=i(t))}else i.current=t}catch(s){st.__e(s,e)}}function lo(i,t,e){var r,s;if(st.unmount&&st.unmount(i),(r=i.ref)&&(r.current&&r.current!=i.__e||Ci(r,null,t)),(r=i.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(n){st.__e(n,t)}r.base=r.__P=null}if(r=i.__k)for(s=0;s<r.length;s++)r[s]&&lo(r[s],t,e||typeof i.type!="function");e||wi(i.__e),i.__c=i.__=i.__e=void 0}function xc(i,t,e){return this.constructor(i,e)}function _c(i,t,e){var r,s,n,o;t==document&&(t=document.documentElement),st.__&&st.__(i,t),s=(r=!1)?null:t.__k,n=[],o=[],xi(t,i=t.__k=_r(us,null,[i]),s||wr,wr,t.namespaceURI,s?null:t.firstChild?cs.call(t.childNodes):null,n,s?s.__e:t.firstChild,r,o),oo(n,i,o)}cs=Jn.slice,st={__e:function(i,t,e,r){for(var s,n,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((n=s.constructor)&&n.getDerivedStateFromError!=null&&(s.setState(n.getDerivedStateFromError(i)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(i,r||{}),o=s.__d),o)return s.__E=s}catch(a){i=a}throw i}},Gn=0,ds.prototype.setState=function(i,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=he({},this.state),typeof i=="function"&&(i=i(he({},e),this.props)),i&&he(e,i),i!=null&&this.__v&&(t&&this._sb.push(t),to(this))},ds.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),to(this))},ds.prototype.render=us,je=[],qn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Kn=function(i,t){return i.__v.__b-t.__v.__b},gs.__r=0,Zn=/(PointerCapture)$|Capture$/i,vi=0,yi=no(!1),bi=no(!0);var Cc=0;function w(i,t,e,r,s,n){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?o=t[a]:l[a]=t[a];var c={type:i,props:l,key:e,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Cc,__i:-1,__u:0,__source:s,__self:n};if(typeof i=="function"&&(o=i.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return st.vnode&&st.vnode(c),c}var Cr,gt,Si,co,Sr=0,ho=[],mt=st,uo=mt.__b,go=mt.__r,fo=mt.diffed,po=mt.__c,mo=mt.unmount,vo=mt.__;function Ti(i,t){mt.__h&&mt.__h(gt,i,Sr||t),Sr=0;var e=gt.__H||(gt.__H={__:[],__h:[]});return i>=e.__.length&&e.__.push({}),e.__[i]}function at(i){return Sr=1,Sc(xo,i)}function Sc(i,t,e){var r=Ti(Cr++,2);if(r.t=i,!r.__c&&(r.__=[xo(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,a);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=gt,!gt.__f)){var s=function(a,l,c){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return!!d.__c});if(h.every(function(d){return!d.__N}))return!n||n.call(this,a,l,c);var u=r.__c.props!==a;return h.forEach(function(d){if(d.__N){var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(u=!0)}}),n&&n.call(this,a,l,c)||u};gt.__f=!0;var n=gt.shouldComponentUpdate,o=gt.componentWillUpdate;gt.componentWillUpdate=function(a,l,c){if(this.__e){var h=n;n=void 0,s(a,l,c),n=h}o&&o.call(this,a,l,c)},gt.shouldComponentUpdate=s}return r.__N||r.__}function Ht(i,t){var e=Ti(Cr++,3);!mt.__s&&wo(e.__H,t)&&(e.__=i,e.u=t,gt.__H.__h.push(e))}function Ft(i){return Sr=5,yo(function(){return{current:i}},[])}function yo(i,t){var e=Ti(Cr++,7);return wo(e.__H,t)&&(e.__=i(),e.__H=t,e.__h=i),e.__}function K(i,t){return Sr=8,yo(function(){return i},t)}function Tc(){for(var i;i=ho.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(ps),i.__H.__h.forEach(ki),i.__H.__h=[]}catch(t){i.__H.__h=[],mt.__e(t,i.__v)}}mt.__b=function(i){gt=null,uo&&uo(i)},mt.__=function(i,t){i&&t.__k&&t.__k.__m&&(i.__m=t.__k.__m),vo&&vo(i,t)},mt.__r=function(i){go&&go(i),Cr=0;var t=(gt=i.__c).__H;t&&(Si===gt?(t.__h=[],gt.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(ps),t.__h.forEach(ki),t.__h=[],Cr=0)),Si=gt},mt.diffed=function(i){fo&&fo(i);var t=i.__c;t&&t.__H&&(t.__H.__h.length&&(ho.push(t)!==1&&co===mt.requestAnimationFrame||((co=mt.requestAnimationFrame)||kc)(Tc)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Si=gt=null},mt.__c=function(i,t){t.some(function(e){try{e.__h.forEach(ps),e.__h=e.__h.filter(function(r){return!r.__||ki(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],mt.__e(r,e.__v)}}),po&&po(i,t)},mt.unmount=function(i){mo&&mo(i);var t,e=i.__c;e&&e.__H&&(e.__H.__.forEach(function(r){try{ps(r)}catch(s){t=s}}),e.__H=void 0,t&&mt.__e(t,e.__v))};var bo=typeof requestAnimationFrame=="function";function kc(i){var t,e=function(){clearTimeout(r),bo&&cancelAnimationFrame(t),setTimeout(i)},r=setTimeout(e,35);bo&&(t=requestAnimationFrame(e))}function ps(i){var t=gt,e=i.__c;typeof e=="function"&&(i.__c=void 0,e()),gt=t}function ki(i){var t=gt;i.__c=i.__(),gt=t}function wo(i,t){return!i||i.length!==t.length||t.some(function(e,r){return e!==i[r]})}function xo(i,t){return typeof t=="function"?t(i):t}/**
1
+ var BugPin=function(wr){"use strict";var us,st,qn,Le,Kn,Zn,Jn,Qn,yi,bi,wi,xr={},to=[],dc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_r=Array.isArray;function ce(i,t){for(var e in t)i[e]=t[e];return i}function xi(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function Cr(i,t,e){var r,s,n,o={};for(n in t)n=="key"?r=t[n]:n=="ref"?s=t[n]:o[n]=t[n];if(arguments.length>2&&(o.children=arguments.length>3?us.call(arguments,2):e),typeof i=="function"&&i.defaultProps!=null)for(n in i.defaultProps)o[n]===void 0&&(o[n]=i.defaultProps[n]);return ds(i,o,r,s,null)}function ds(i,t,e,r,s){var n={type:i,props:t,key:e,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++qn,__i:-1,__u:0};return s==null&&st.vnode!=null&&st.vnode(n),n}function Sr(i){return i.children}function gs(i,t){this.props=i,this.context=t}function Ue(i,t){if(t==null)return i.__?Ue(i.__,i.__i+1):null;for(var e;t<i.__k.length;t++)if((e=i.__k[t])!=null&&e.__e!=null)return e.__e;return typeof i.type=="function"?Ue(i):null}function eo(i){var t,e;if((i=i.__)!=null&&i.__c!=null){for(i.__e=i.__c.base=null,t=0;t<i.__k.length;t++)if((e=i.__k[t])!=null&&e.__e!=null){i.__e=i.__c.base=e.__e;break}return eo(i)}}function ro(i){(!i.__d&&(i.__d=!0)&&Le.push(i)&&!fs.__r++||Kn!=st.debounceRendering)&&((Kn=st.debounceRendering)||Zn)(fs)}function fs(){for(var i,t,e,r,s,n,o,a=1;Le.length;)Le.length>a&&Le.sort(Jn),i=Le.shift(),a=Le.length,i.__d&&(e=void 0,r=void 0,s=(r=(t=i).__v).__e,n=[],o=[],t.__P&&((e=ce({},r)).__v=r.__v+1,st.vnode&&st.vnode(e),_i(t.__P,e,r,t.__n,t.__P.namespaceURI,32&r.__u?[s]:null,n,s??Ue(r),!!(32&r.__u),o),e.__v=r.__v,e.__.__k[e.__i]=e,lo(n,e,o),r.__e=r.__=null,e.__e!=s&&eo(e)));fs.__r=0}function so(i,t,e,r,s,n,o,a,l,c,h){var u,d,g,f,m,y,b,w=r&&r.__k||to,T=t.length;for(l=gc(e,t,w,l,T),u=0;u<T;u++)(g=e.__k[u])!=null&&(d=g.__i==-1?xr:w[g.__i]||xr,g.__i=u,y=_i(i,g,d,s,n,o,a,l,c,h),f=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&Si(d.ref,null,g),h.push(g.ref,g.__c||f,g)),m==null&&f!=null&&(m=f),(b=!!(4&g.__u))||d.__k===g.__k?l=io(g,l,i,b):typeof g.type=="function"&&y!==void 0?l=y:f&&(l=f.nextSibling),g.__u&=-7);return e.__e=m,l}function gc(i,t,e,r,s){var n,o,a,l,c,h=e.length,u=h,d=0;for(i.__k=new Array(s),n=0;n<s;n++)(o=t[n])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=i.__k[n]=ds(null,o,null,null,null):_r(o)?o=i.__k[n]=ds(Sr,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=i.__k[n]=ds(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):i.__k[n]=o,l=n+d,o.__=i,o.__b=i.__b+1,a=null,(c=o.__i=fc(o,e,l,u))!=-1&&(u--,(a=e[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(s>h?d--:s<h&&d++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?d--:c==l+1?d++:(c>l?d--:d++,o.__u|=4))):i.__k[n]=null;if(u)for(n=0;n<h;n++)(a=e[n])!=null&&!(2&a.__u)&&(a.__e==r&&(r=Ue(a)),ho(a,a));return r}function io(i,t,e,r){var s,n;if(typeof i.type=="function"){for(s=i.__k,n=0;s&&n<s.length;n++)s[n]&&(s[n].__=i,t=io(s[n],t,e,r));return t}i.__e!=t&&(r&&(t&&i.type&&!t.parentNode&&(t=Ue(i)),e.insertBefore(i.__e,t||null)),t=i.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function no(i,t){return t=t||[],i==null||typeof i=="boolean"||(_r(i)?i.some(function(e){no(e,t)}):t.push(i)),t}function fc(i,t,e,r){var s,n,o,a=i.key,l=i.type,c=t[e],h=c!=null&&(2&c.__u)==0;if(c===null&&a==null||h&&a==c.key&&l==c.type)return e;if(r>(h?1:0)){for(s=e-1,n=e+1;s>=0||n<t.length;)if((c=t[o=s>=0?s--:n++])!=null&&!(2&c.__u)&&a==c.key&&l==c.type)return o}return-1}function oo(i,t,e){t[0]=="-"?i.setProperty(t,e??""):i[t]=e==null?"":typeof e!="number"||dc.test(t)?e:e+"px"}function ps(i,t,e,r,s){var n,o;t:if(t=="style")if(typeof e=="string")i.style.cssText=e;else{if(typeof r=="string"&&(i.style.cssText=r=""),r)for(t in r)e&&t in e||oo(i.style,t,"");if(e)for(t in e)r&&e[t]==r[t]||oo(i.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")n=t!=(t=t.replace(Qn,"$1")),o=t.toLowerCase(),t=o in i||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),i.l||(i.l={}),i.l[t+n]=e,e?r?e.u=r.u:(e.u=yi,i.addEventListener(t,n?wi:bi,n)):i.removeEventListener(t,n?wi:bi,n);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in i)try{i[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?i.removeAttribute(t):i.setAttribute(t,t=="popover"&&e==1?"":e))}}function ao(i){return function(t){if(this.l){var e=this.l[t.type+i];if(t.t==null)t.t=yi++;else if(t.t<e.u)return;return e(st.event?st.event(t):t)}}}function _i(i,t,e,r,s,n,o,a,l,c){var h,u,d,g,f,m,y,b,w,T,C,S,D,A,_,M,O,V=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),n=[a=t.__e=e.__e]),(h=st.__b)&&h(t);t:if(typeof V=="function")try{if(b=t.props,w="prototype"in V&&V.prototype.render,T=(h=V.contextType)&&r[h.__c],C=h?T?T.props.value:h.__:r,e.__c?y=(u=t.__c=e.__c).__=u.__E:(w?t.__c=u=new V(b,C):(t.__c=u=new gs(b,C),u.constructor=V,u.render=mc),T&&T.sub(u),u.state||(u.state={}),u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),w&&u.__s==null&&(u.__s=u.state),w&&V.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=ce({},u.__s)),ce(u.__s,V.getDerivedStateFromProps(b,u.__s))),g=u.props,f=u.state,u.__v=t,d)w&&V.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),w&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(w&&V.getDerivedStateFromProps==null&&b!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,C),t.__v==e.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,C)===!1){for(t.__v!=e.__v&&(u.props=b,u.state=u.__s,u.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(z){z&&(z.__=t)}),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[],u.__h.length&&o.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,C),w&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,f,m)})}if(u.context=C,u.props=b,u.__P=i,u.__e=!1,D=st.__r,A=0,w){for(u.state=u.__s,u.__d=!1,D&&D(t),h=u.render(u.props,u.state,u.context),_=0;_<u._sb.length;_++)u.__h.push(u._sb[_]);u._sb=[]}else do u.__d=!1,D&&D(t),h=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++A<25);u.state=u.__s,u.getChildContext!=null&&(r=ce(ce({},r),u.getChildContext())),w&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(g,f)),M=h,h!=null&&h.type===Sr&&h.key==null&&(M=co(h.props.children)),a=so(i,_r(M)?M:[M],t,e,r,s,n,o,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),y&&(u.__E=u.__=null)}catch(z){if(t.__v=null,l||n!=null)if(z.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;n[n.indexOf(a)]=null,t.__e=a}else{for(O=n.length;O--;)xi(n[O]);Ci(t)}else t.__e=e.__e,t.__k=e.__k,z.then||Ci(t);st.__e(z,t,e)}else n==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=pc(e.__e,t,e,r,s,n,o,l,c);return(h=st.diffed)&&h(t),128&t.__u?void 0:a}function Ci(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(Ci)}function lo(i,t,e){for(var r=0;r<e.length;r++)Si(e[r],e[++r],e[++r]);st.__c&&st.__c(t,i),i.some(function(s){try{i=s.__h,s.__h=[],i.some(function(n){n.call(s)})}catch(n){st.__e(n,s.__v)}})}function co(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:_r(i)?i.map(co):ce({},i)}function pc(i,t,e,r,s,n,o,a,l){var c,h,u,d,g,f,m,y=e.props||xr,b=t.props,w=t.type;if(w=="svg"?s="http://www.w3.org/2000/svg":w=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),n!=null){for(c=0;c<n.length;c++)if((g=n[c])&&"setAttribute"in g==!!w&&(w?g.localName==w:g.nodeType==3)){i=g,n[c]=null;break}}if(i==null){if(w==null)return document.createTextNode(b);i=document.createElementNS(s,w,b.is&&b),a&&(st.__m&&st.__m(t,n),a=!1),n=null}if(w==null)y===b||a&&i.data==b||(i.data=b);else{if(n=n&&us.call(i.childNodes),!a&&n!=null)for(y={},c=0;c<i.attributes.length;c++)y[(g=i.attributes[c]).name]=g.value;for(c in y)if(g=y[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=g;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;ps(i,c,null,g,s)}}for(c in b)g=b[c],c=="children"?d=g:c=="dangerouslySetInnerHTML"?h=g:c=="value"?f=g:c=="checked"?m=g:a&&typeof g!="function"||y[c]===g||ps(i,c,g,y[c],s);if(h)a||u&&(h.__html==u.__html||h.__html==i.innerHTML)||(i.innerHTML=h.__html),t.__k=[];else if(u&&(i.innerHTML=""),so(t.type=="template"?i.content:i,_r(d)?d:[d],t,e,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":s,n,o,n?n[0]:e.__k&&Ue(e,0),a,l),n!=null)for(c=n.length;c--;)xi(n[c]);a||(c="value",w=="progress"&&f==null?i.removeAttribute("value"):f!=null&&(f!==i[c]||w=="progress"&&!f||w=="option"&&f!=y[c])&&ps(i,c,f,y[c],s),c="checked",m!=null&&m!=i[c]&&ps(i,c,m,y[c],s))}return i}function Si(i,t,e){try{if(typeof i=="function"){var r=typeof i.__u=="function";r&&i.__u(),r&&t==null||(i.__u=i(t))}else i.current=t}catch(s){st.__e(s,e)}}function ho(i,t,e){var r,s;if(st.unmount&&st.unmount(i),(r=i.ref)&&(r.current&&r.current!=i.__e||Si(r,null,t)),(r=i.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(n){st.__e(n,t)}r.base=r.__P=null}if(r=i.__k)for(s=0;s<r.length;s++)r[s]&&ho(r[s],t,e||typeof i.type!="function");e||xi(i.__e),i.__c=i.__=i.__e=void 0}function mc(i,t,e){return this.constructor(i,e)}function vc(i,t,e){var r,s,n,o;t==document&&(t=document.documentElement),st.__&&st.__(i,t),s=(r=!1)?null:t.__k,n=[],o=[],_i(t,i=t.__k=Cr(Sr,null,[i]),s||xr,xr,t.namespaceURI,s?null:t.firstChild?us.call(t.childNodes):null,n,s?s.__e:t.firstChild,r,o),lo(n,i,o)}us=to.slice,st={__e:function(i,t,e,r){for(var s,n,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((n=s.constructor)&&n.getDerivedStateFromError!=null&&(s.setState(n.getDerivedStateFromError(i)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(i,r||{}),o=s.__d),o)return s.__E=s}catch(a){i=a}throw i}},qn=0,gs.prototype.setState=function(i,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ce({},this.state),typeof i=="function"&&(i=i(ce({},e),this.props)),i&&ce(e,i),i!=null&&this.__v&&(t&&this._sb.push(t),ro(this))},gs.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),ro(this))},gs.prototype.render=Sr,Le=[],Zn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Jn=function(i,t){return i.__v.__b-t.__v.__b},fs.__r=0,Qn=/(PointerCapture)$|Capture$/i,yi=0,bi=ao(!1),wi=ao(!0);var yc=0;function p(i,t,e,r,s,n){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?o=t[a]:l[a]=t[a];var c={type:i,props:l,key:e,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--yc,__i:-1,__u:0,__source:s,__self:n};if(typeof i=="function"&&(o=i.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return st.vnode&&st.vnode(c),c}var kr,gt,ki,uo,Tr=0,go=[],vt=st,fo=vt.__b,po=vt.__r,mo=vt.diffed,vo=vt.__c,yo=vt.unmount,bo=vt.__;function Ti(i,t){vt.__h&&vt.__h(gt,i,Tr||t),Tr=0;var e=gt.__H||(gt.__H={__:[],__h:[]});return i>=e.__.length&&e.__.push({}),e.__[i]}function at(i){return Tr=1,bc(Co,i)}function bc(i,t,e){var r=Ti(kr++,2);if(r.t=i,!r.__c&&(r.__=[Co(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,a);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=gt,!gt.__f)){var s=function(a,l,c){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return!!d.__c});if(h.every(function(d){return!d.__N}))return!n||n.call(this,a,l,c);var u=r.__c.props!==a;return h.forEach(function(d){if(d.__N){var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(u=!0)}}),n&&n.call(this,a,l,c)||u};gt.__f=!0;var n=gt.shouldComponentUpdate,o=gt.componentWillUpdate;gt.componentWillUpdate=function(a,l,c){if(this.__e){var h=n;n=void 0,s(a,l,c),n=h}o&&o.call(this,a,l,c)},gt.shouldComponentUpdate=s}return r.__N||r.__}function Ht(i,t){var e=Ti(kr++,3);!vt.__s&&_o(e.__H,t)&&(e.__=i,e.u=t,gt.__H.__h.push(e))}function It(i){return Tr=5,wo(function(){return{current:i}},[])}function wo(i,t){var e=Ti(kr++,7);return _o(e.__H,t)&&(e.__=i(),e.__H=t,e.__h=i),e.__}function N(i,t){return Tr=8,wo(function(){return i},t)}function wc(){for(var i;i=go.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(ms),i.__H.__h.forEach(Oi),i.__H.__h=[]}catch(t){i.__H.__h=[],vt.__e(t,i.__v)}}vt.__b=function(i){gt=null,fo&&fo(i)},vt.__=function(i,t){i&&t.__k&&t.__k.__m&&(i.__m=t.__k.__m),bo&&bo(i,t)},vt.__r=function(i){po&&po(i),kr=0;var t=(gt=i.__c).__H;t&&(ki===gt?(t.__h=[],gt.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(ms),t.__h.forEach(Oi),t.__h=[],kr=0)),ki=gt},vt.diffed=function(i){mo&&mo(i);var t=i.__c;t&&t.__H&&(t.__H.__h.length&&(go.push(t)!==1&&uo===vt.requestAnimationFrame||((uo=vt.requestAnimationFrame)||xc)(wc)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ki=gt=null},vt.__c=function(i,t){t.some(function(e){try{e.__h.forEach(ms),e.__h=e.__h.filter(function(r){return!r.__||Oi(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],vt.__e(r,e.__v)}}),vo&&vo(i,t)},vt.unmount=function(i){yo&&yo(i);var t,e=i.__c;e&&e.__H&&(e.__H.__.forEach(function(r){try{ms(r)}catch(s){t=s}}),e.__H=void 0,t&&vt.__e(t,e.__v))};var xo=typeof requestAnimationFrame=="function";function xc(i){var t,e=function(){clearTimeout(r),xo&&cancelAnimationFrame(t),setTimeout(i)},r=setTimeout(e,35);xo&&(t=requestAnimationFrame(e))}function ms(i){var t=gt,e=i.__c;typeof e=="function"&&(i.__c=void 0,e()),gt=t}function Oi(i){var t=gt;i.__c=i.__(),gt=t}function _o(i,t){return!i||i.length!==t.length||t.some(function(e,r){return e!==i[r]})}function Co(i,t){return typeof t=="function"?t(i):t}/**
2
2
  * @license lucide-preact v0.460.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Oc=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Dc=(...i)=>i.filter((t,e,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===e).join(" ").trim();/**
6
+ */const _c=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Cc=(...i)=>i.filter((t,e,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===e).join(" ").trim();/**
7
7
  * @license lucide-preact v0.460.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */var Mc={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};/**
11
+ */var Sc={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};/**
12
12
  * @license lucide-preact v0.460.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const Ec=({color:i="currentColor",size:t=24,strokeWidth:e=2,absoluteStrokeWidth:r,children:s,iconNode:n,class:o="",...a})=>_r("svg",{...Mc,width:String(t),height:t,stroke:i,"stroke-width":r?Number(e)*24/Number(t):e,class:["lucide",o].join(" "),...a},[...n.map(([l,c])=>_r(l,c)),...so(s)]);/**
16
+ */const kc=({color:i="currentColor",size:t=24,strokeWidth:e=2,absoluteStrokeWidth:r,children:s,iconNode:n,class:o="",...a})=>Cr("svg",{...Sc,width:String(t),height:t,stroke:i,"stroke-width":r?Number(e)*24/Number(t):e,class:["lucide",o].join(" "),...a},[...n.map(([l,c])=>Cr(l,c)),...no(s)]);/**
17
17
  * @license lucide-preact v0.460.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Oi=(i,t)=>{const e=({class:r="",children:s,...n})=>_r(Ec,{...n,iconNode:t,class:Dc(`lucide-${Oc(i)}`,r)},s);return e.displayName=`${i}`,e};/**
21
+ */const Di=(i,t)=>{const e=({class:r="",children:s,...n})=>Cr(kc,{...n,iconNode:t,class:Cc(`lucide-${_c(i)}`,r)},s);return e.displayName=`${i}`,e};/**
22
22
  * @license lucide-preact v0.460.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const Pc=Oi("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
26
+ */const Tc=Di("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
27
27
  * @license lucide-preact v0.460.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const Ac=Oi("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
31
+ */const Oc=Di("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
32
32
  * @license lucide-preact v0.460.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const Lc=Oi("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),jc={bug:Pc,"message-square":Lc,"alert-circle":Ac},Fc=({name:i,class:t,size:e=18,strokeWidth:r=2})=>{const s=jc[i];return s?w(s,{class:t,size:e,strokeWidth:r}):null};function _o(i){var t,e,r="";if(typeof i=="string"||typeof i=="number")r+=i;else if(typeof i=="object")if(Array.isArray(i)){var s=i.length;for(t=0;t<s;t++)i[t]&&(e=_o(i[t]))&&(r&&(r+=" "),r+=e)}else for(e in i)i[e]&&(r&&(r+=" "),r+=e);return r}function Co(){for(var i,t,e=0,r="",s=arguments.length;e<s;e++)(i=arguments[e])&&(t=_o(i))&&(r&&(r+=" "),r+=t);return r}const Rc=(i,t)=>{const e=new Array(i.length+t.length);for(let r=0;r<i.length;r++)e[r]=i[r];for(let r=0;r<t.length;r++)e[i.length+r]=t[r];return e},Ic=(i,t)=>({classGroupId:i,validator:t}),So=(i=new Map,t=null,e)=>({nextPart:i,validators:t,classGroupId:e}),ms="-",To=[],Bc="arbitrary..",zc=i=>{const t=Vc(i),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=i;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Hc(o);const a=o.split(ms),l=a[0]===""&&a.length>1?1:0;return ko(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=e[o];return l?c?Rc(c,l):l:c||To}return e[o]||To}}},ko=(i,t,e)=>{if(i.length-t===0)return e.classGroupId;const s=i[t],n=e.nextPart.get(s);if(n){const c=ko(i,t+1,n);if(c)return c}const o=e.validators;if(o===null)return;const a=t===0?i.join(ms):i.slice(t).join(ms),l=o.length;for(let c=0;c<l;c++){const h=o[c];if(h.validator(a))return h.classGroupId}},Hc=i=>i.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=i.slice(1,-1),e=t.indexOf(":"),r=t.slice(0,e);return r?Bc+r:void 0})(),Vc=i=>{const{theme:t,classGroups:e}=i;return Wc(e,t)},Wc=(i,t)=>{const e=So();for(const r in i){const s=i[r];Di(s,e,r,t)}return e},Di=(i,t,e,r)=>{const s=i.length;for(let n=0;n<s;n++){const o=i[n];Xc(o,t,e,r)}},Xc=(i,t,e,r)=>{if(typeof i=="string"){Yc(i,t,e);return}if(typeof i=="function"){Uc(i,t,e,r);return}Nc(i,t,e,r)},Yc=(i,t,e)=>{const r=i===""?t:Oo(t,i);r.classGroupId=e},Uc=(i,t,e,r)=>{if(Gc(i)){Di(i(r),t,e,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ic(e,i))},Nc=(i,t,e,r)=>{const s=Object.entries(i),n=s.length;for(let o=0;o<n;o++){const[a,l]=s[o];Di(l,Oo(t,a),e,r)}},Oo=(i,t)=>{let e=i;const r=t.split(ms),s=r.length;for(let n=0;n<s;n++){const o=r[n];let a=e.nextPart.get(o);a||(a=So(),e.nextPart.set(o,a)),e=a}return e},Gc=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,$c=i=>{if(i<1)return{get:()=>{},set:()=>{}};let t=0,e=Object.create(null),r=Object.create(null);const s=(n,o)=>{e[n]=o,t++,t>i&&(t=0,r=e,e=Object.create(null))};return{get(n){let o=e[n];if(o!==void 0)return o;if((o=r[n])!==void 0)return s(n,o),o},set(n,o){n in e?e[n]=o:s(n,o)}}},Mi="!",Do=":",qc=[],Mo=(i,t,e,r,s)=>({modifiers:i,hasImportantModifier:t,baseClassName:e,maybePostfixModifierPosition:r,isExternal:s}),Kc=i=>{const{prefix:t,experimentalParseClassName:e}=i;let r=s=>{const n=[];let o=0,a=0,l=0,c;const h=s.length;for(let p=0;p<h;p++){const v=s[p];if(o===0&&a===0){if(v===Do){n.push(s.slice(l,p)),l=p+1;continue}if(v==="/"){c=p;continue}}v==="["?o++:v==="]"?o--:v==="("?a++:v===")"&&a--}const u=n.length===0?s:s.slice(l);let d=u,g=!1;u.endsWith(Mi)?(d=u.slice(0,-1),g=!0):u.startsWith(Mi)&&(d=u.slice(1),g=!0);const f=c&&c>l?c-l:void 0;return Mo(n,g,d,f)};if(t){const s=t+Do,n=r;r=o=>o.startsWith(s)?n(o.slice(s.length)):Mo(qc,!1,o,void 0,!0)}if(e){const s=r;r=n=>e({className:n,parseClassName:s})}return r},Zc=i=>{const t=new Map;return i.orderSensitiveModifiers.forEach((e,r)=>{t.set(e,1e6+r)}),e=>{const r=[];let s=[];for(let n=0;n<e.length;n++){const o=e[n],a=o[0]==="[",l=t.has(o);a||l?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(o)):s.push(o)}return s.length>0&&(s.sort(),r.push(...s)),r}},Jc=i=>({cache:$c(i.cacheSize),parseClassName:Kc(i),sortModifiers:Zc(i),...zc(i)}),Qc=/\s+/,th=(i,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:n}=t,o=[],a=i.trim().split(Qc);let l="";for(let c=a.length-1;c>=0;c-=1){const h=a[c],{isExternal:u,modifiers:d,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:p}=e(h);if(u){l=h+(l.length>0?" "+l:l);continue}let v=!!p,b=r(v?f.substring(0,p):f);if(!b){if(!v){l=h+(l.length>0?" "+l:l);continue}if(b=r(f),!b){l=h+(l.length>0?" "+l:l);continue}v=!1}const x=d.length===0?"":d.length===1?d[0]:n(d).join(":"),D=g?x+Mi:x,C=D+b;if(o.indexOf(C)>-1)continue;o.push(C);const O=s(b,v);for(let S=0;S<O.length;++S){const j=O[S];o.push(D+j)}l=h+(l.length>0?" "+l:l)}return l},eh=(...i)=>{let t=0,e,r,s="";for(;t<i.length;)(e=i[t++])&&(r=Eo(e))&&(s&&(s+=" "),s+=r);return s},Eo=i=>{if(typeof i=="string")return i;let t,e="";for(let r=0;r<i.length;r++)i[r]&&(t=Eo(i[r]))&&(e&&(e+=" "),e+=t);return e},rh=(i,...t)=>{let e,r,s,n;const o=l=>{const c=t.reduce((h,u)=>u(h),i());return e=Jc(c),r=e.cache.get,s=e.cache.set,n=a,a(l)},a=l=>{const c=r(l);if(c)return c;const h=th(l,e);return s(l,h),h};return n=o,(...l)=>n(eh(...l))},sh=[],wt=i=>{const t=e=>e[i]||sh;return t.isThemeGetter=!0,t},Po=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ao=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ih=/^\d+\/\d+$/,nh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ah=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,lh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ch=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ne=i=>ih.test(i),G=i=>!!i&&!Number.isNaN(Number(i)),Ce=i=>!!i&&Number.isInteger(Number(i)),Ei=i=>i.endsWith("%")&&G(i.slice(0,-1)),ue=i=>nh.test(i),hh=()=>!0,uh=i=>oh.test(i)&&!ah.test(i),Lo=()=>!1,dh=i=>lh.test(i),gh=i=>ch.test(i),fh=i=>!B(i)&&!z(i),ph=i=>Ge(i,Bo,Lo),B=i=>Po.test(i),Fe=i=>Ge(i,zo,uh),Pi=i=>Ge(i,wh,G),jo=i=>Ge(i,Ro,Lo),mh=i=>Ge(i,Io,gh),vs=i=>Ge(i,Ho,dh),z=i=>Ao.test(i),Tr=i=>$e(i,zo),vh=i=>$e(i,xh),Fo=i=>$e(i,Ro),yh=i=>$e(i,Bo),bh=i=>$e(i,Io),ys=i=>$e(i,Ho,!0),Ge=(i,t,e)=>{const r=Po.exec(i);return r?r[1]?t(r[1]):e(r[2]):!1},$e=(i,t,e=!1)=>{const r=Ao.exec(i);return r?r[1]?t(r[1]):e:!1},Ro=i=>i==="position"||i==="percentage",Io=i=>i==="image"||i==="url",Bo=i=>i==="length"||i==="size"||i==="bg-size",zo=i=>i==="length",wh=i=>i==="number",xh=i=>i==="family-name",Ho=i=>i==="shadow",_h=rh(()=>{const i=wt("color"),t=wt("font"),e=wt("text"),r=wt("font-weight"),s=wt("tracking"),n=wt("leading"),o=wt("breakpoint"),a=wt("container"),l=wt("spacing"),c=wt("radius"),h=wt("shadow"),u=wt("inset-shadow"),d=wt("text-shadow"),g=wt("drop-shadow"),f=wt("blur"),p=wt("perspective"),v=wt("aspect"),b=wt("ease"),x=wt("animate"),D=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...C(),z,B],S=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],T=()=>[z,B,l],L=()=>[Ne,"full","auto",...T()],H=()=>[Ce,"none","subgrid",z,B],W=()=>["auto",{span:["full",Ce,z,B]},Ce,z,B],V=()=>[Ce,"auto",z,B],U=()=>["auto","min","max","fr",z,B],X=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],tt=()=>["start","end","center","stretch","center-safe","end-safe"],Z=()=>["auto",...T()],J=()=>[Ne,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],A=()=>[i,z,B],ht=()=>[...C(),Fo,jo,{position:[z,B]}],ut=()=>["no-repeat",{repeat:["","x","y","space","round"]}],dt=()=>["auto","cover","contain",yh,ph,{size:[z,B]}],k=()=>[Ei,Tr,Fe],P=()=>["","none","full",c,z,B],E=()=>["",G,Tr,Fe],I=()=>["solid","dashed","dotted","double"],F=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],M=()=>[G,Ei,Fo,jo],Y=()=>["","none",f,z,B],q=()=>["none",G,z,B],N=()=>["none",G,z,B],zt=()=>[G,z,B],ct=()=>[Ne,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ue],breakpoint:[ue],color:[hh],container:[ue],"drop-shadow":[ue],ease:["in","out","in-out"],font:[fh],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ue],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ue],shadow:[ue],spacing:["px",G],text:[ue],"text-shadow":[ue],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ne,B,z,v]}],container:["container"],columns:[{columns:[G,B,z,a]}],"break-after":[{"break-after":D()}],"break-before":[{"break-before":D()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[Ce,"auto",z,B]}],basis:[{basis:[Ne,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[G,Ne,"auto","initial","none",B]}],grow:[{grow:["",G,z,B]}],shrink:[{shrink:["",G,z,B]}],order:[{order:[Ce,"first","last","none",z,B]}],"grid-cols":[{"grid-cols":H()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":H()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":U()}],"auto-rows":[{"auto-rows":U()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...X(),"normal"]}],"justify-items":[{"justify-items":[...tt(),"normal"]}],"justify-self":[{"justify-self":["auto",...tt()]}],"align-content":[{content:["normal",...X()]}],"align-items":[{items:[...tt(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...tt(),{baseline:["","last"]}]}],"place-content":[{"place-content":X()}],"place-items":[{"place-items":[...tt(),"baseline"]}],"place-self":[{"place-self":["auto",...tt()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:Z()}],mx:[{mx:Z()}],my:[{my:Z()}],ms:[{ms:Z()}],me:[{me:Z()}],mt:[{mt:Z()}],mr:[{mr:Z()}],mb:[{mb:Z()}],ml:[{ml:Z()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:J()}],w:[{w:[a,"screen",...J()]}],"min-w":[{"min-w":[a,"screen","none",...J()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...J()]}],h:[{h:["screen","lh",...J()]}],"min-h":[{"min-h":["screen","lh","none",...J()]}],"max-h":[{"max-h":["screen","lh",...J()]}],"font-size":[{text:["base",e,Tr,Fe]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,z,Pi]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ei,B]}],"font-family":[{font:[vh,B,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,z,B]}],"line-clamp":[{"line-clamp":[G,"none",z,Pi]}],leading:[{leading:[n,...T()]}],"list-image":[{"list-image":["none",z,B]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",z,B]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...I(),"wavy"]}],"text-decoration-thickness":[{decoration:[G,"from-font","auto",z,Fe]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[G,"auto",z,B]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",z,B]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",z,B]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ht()}],"bg-repeat":[{bg:ut()}],"bg-size":[{bg:dt()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ce,z,B],radial:["",z,B],conic:[Ce,z,B]},bh,mh]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:k()}],"gradient-via-pos":[{via:k()}],"gradient-to-pos":[{to:k()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...I(),"hidden","none"]}],"divide-style":[{divide:[...I(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...I(),"none","hidden"]}],"outline-offset":[{"outline-offset":[G,z,B]}],"outline-w":[{outline:["",G,Tr,Fe]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",h,ys,vs]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",u,ys,vs]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[G,Fe]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",d,ys,vs]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[G,z,B]}],"mix-blend":[{"mix-blend":[...F(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":F()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[G]}],"mask-image-linear-from-pos":[{"mask-linear-from":M()}],"mask-image-linear-to-pos":[{"mask-linear-to":M()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":M()}],"mask-image-t-to-pos":[{"mask-t-to":M()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":M()}],"mask-image-r-to-pos":[{"mask-r-to":M()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":M()}],"mask-image-b-to-pos":[{"mask-b-to":M()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":M()}],"mask-image-l-to-pos":[{"mask-l-to":M()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":M()}],"mask-image-x-to-pos":[{"mask-x-to":M()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":M()}],"mask-image-y-to-pos":[{"mask-y-to":M()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[z,B]}],"mask-image-radial-from-pos":[{"mask-radial-from":M()}],"mask-image-radial-to-pos":[{"mask-radial-to":M()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[G]}],"mask-image-conic-from-pos":[{"mask-conic-from":M()}],"mask-image-conic-to-pos":[{"mask-conic-to":M()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ht()}],"mask-repeat":[{mask:ut()}],"mask-size":[{mask:dt()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",z,B]}],filter:[{filter:["","none",z,B]}],blur:[{blur:Y()}],brightness:[{brightness:[G,z,B]}],contrast:[{contrast:[G,z,B]}],"drop-shadow":[{"drop-shadow":["","none",g,ys,vs]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",G,z,B]}],"hue-rotate":[{"hue-rotate":[G,z,B]}],invert:[{invert:["",G,z,B]}],saturate:[{saturate:[G,z,B]}],sepia:[{sepia:["",G,z,B]}],"backdrop-filter":[{"backdrop-filter":["","none",z,B]}],"backdrop-blur":[{"backdrop-blur":Y()}],"backdrop-brightness":[{"backdrop-brightness":[G,z,B]}],"backdrop-contrast":[{"backdrop-contrast":[G,z,B]}],"backdrop-grayscale":[{"backdrop-grayscale":["",G,z,B]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[G,z,B]}],"backdrop-invert":[{"backdrop-invert":["",G,z,B]}],"backdrop-opacity":[{"backdrop-opacity":[G,z,B]}],"backdrop-saturate":[{"backdrop-saturate":[G,z,B]}],"backdrop-sepia":[{"backdrop-sepia":["",G,z,B]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",z,B]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[G,"initial",z,B]}],ease:[{ease:["linear","initial",b,z,B]}],delay:[{delay:[G,z,B]}],animate:[{animate:["none",x,z,B]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[p,z,B]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:q()}],"rotate-x":[{"rotate-x":q()}],"rotate-y":[{"rotate-y":q()}],"rotate-z":[{"rotate-z":q()}],scale:[{scale:N()}],"scale-x":[{"scale-x":N()}],"scale-y":[{"scale-y":N()}],"scale-z":[{"scale-z":N()}],"scale-3d":["scale-3d"],skew:[{skew:zt()}],"skew-x":[{"skew-x":zt()}],"skew-y":[{"skew-y":zt()}],transform:[{transform:[z,B,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ct()}],"translate-x":[{"translate-x":ct()}],"translate-y":[{"translate-y":ct()}],"translate-z":[{"translate-z":ct()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",z,B]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",z,B]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[G,Tr,Fe,Pi]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Rt(...i){return _h(Co(i))}const Ch={"bottom-right":"bottom-5 right-5","bottom-left":"bottom-5 left-5","top-right":"top-5 right-5","top-left":"top-5 left-5"},Sh=({position:i,buttonText:t,buttonShape:e,buttonIcon:r,buttonIconSize:s,buttonIconStroke:n,theme:o,lightButtonColor:a,lightTextColor:l,lightButtonHoverColor:c,lightTextHoverColor:h,darkButtonColor:u,darkTextColor:d,darkButtonHoverColor:g,darkTextHoverColor:f,enableHoverScaleEffect:p,tooltipEnabled:v,tooltipText:b,onClick:x})=>{const[D,C]=at(!1),[O,S]=at(!1),[j,T]=at({left:"50%",transform:"translateX(-50%)",arrowLeft:"50%"}),L=Ft(null),H=Ft(null);Ht(()=>{if(o==="dark"){S(!0);return}else if(o==="light"){S(!1);return}const A=window.matchMedia("(prefers-color-scheme: dark)");S(A.matches);const ht=ut=>S(ut.matches);return A.addEventListener("change",ht),()=>A.removeEventListener("change",ht)},[o]),Ht(()=>{if(D&&L.current&&H.current){const A=L.current,ht=H.current;requestAnimationFrame(()=>{const ut=A.getBoundingClientRect(),dt=ht.getBoundingClientRect(),k=window.innerWidth,P=4,E=dt.left+dt.width/2,I=ut.width/2;let F=0;const M=E-I;M<P?F=P-M:M+ut.width>k-P&&(F=k-P-(M+ut.width)),T({left:"50%",transform:`translateX(-50%) translateX(${F}px)`,arrowLeft:"50%"})})}},[D,b]);const W=O?D?g:u:D?c:a,V=O?D?f:d:D?h:l,U=O?u:a,X=O?d:l,tt=e==="round"?"50%":"8px",Z=t||"Report Bug",J=e==="round"?`${s/2}px`:"12px 20px";return w("div",{class:Rt("fixed z-[2147483647]",Ch[i]),children:[w("button",{ref:H,class:Rt("relative flex items-center justify-center gap-2 border-none text-sm font-medium cursor-pointer shadow-lg transition-all duration-200",p&&"hover:scale-110 hover:shadow-xl active:scale-105"),style:{backgroundColor:W,color:V,borderRadius:tt,padding:J},onClick:x,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),"aria-label":Z,children:[r&&w(Fc,{name:r,size:s,strokeWidth:n}),t&&w("span",{children:t})]}),v&&b&&D&&w("div",{ref:L,class:"absolute bottom-full mb-2 px-3 py-1.5 text-xs rounded whitespace-nowrap pointer-events-none z-[2147483647] animate-[bugpin-tooltip-fade-in_0.2s_ease-in-out_forwards] shadow-md",style:{backgroundColor:U,color:X,opacity:0,left:j.left,transform:j.transform},children:[b,w("div",{class:"absolute top-full border-4 border-solid border-transparent",style:{left:j.arrowLeft,transform:"translateX(-50%)",marginTop:"-4px",borderTopColor:U}})]})]})},Vo=i=>typeof i=="boolean"?`${i}`:i===0?"0":i,Wo=Co,Th=((i,t)=>e=>{var r;if((t==null?void 0:t.variants)==null)return Wo(i,e==null?void 0:e.class,e==null?void 0:e.className);const{variants:s,defaultVariants:n}=t,o=Object.keys(s).map(c=>{const h=e==null?void 0:e[c],u=n==null?void 0:n[c];if(h===null)return null;const d=Vo(h)||Vo(u);return s[c][d]}),a=e&&Object.entries(e).reduce((c,h)=>{let[u,d]=h;return d===void 0||(c[u]=d),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,h)=>{let{class:u,className:d,...g}=h;return Object.entries(g).every(f=>{let[p,v]=f;return Array.isArray(v)?v.includes({...n,...a}[p]):{...n,...a}[p]===v})?[...c,u,d]:c},[]);return Wo(i,o,l,e==null?void 0:e.class,e==null?void 0:e.className)})("inline-flex items-center justify-center gap-2 font-medium font-sans cursor-pointer transition-colors border-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary-hover hover:text-primary-hover-foreground",outline:"border border-solid border-input bg-background text-foreground hover:bg-muted",ghost:"bg-transparent hover:bg-muted text-foreground",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90"},size:{default:"h-10 px-4 text-sm rounded-sm",sm:"h-8 px-3 text-xs rounded-sm",lg:"h-12 px-6 text-base rounded",icon:"h-8 w-8 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),Se=({class:i,variant:t,size:e,children:r,type:s="button",...n})=>w("button",{type:s,class:Rt(Th({variant:t,size:e}),i),...n,children:r}),Ai=({class:i,error:t,type:e="text",...r})=>w("input",{type:e,class:Rt("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-transparent transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...r}),kh=({class:i,error:t,...e})=>w("textarea",{class:Rt("min-h-20 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-transparent resize-y transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...e}),Oh=({class:i,error:t,children:e,...r})=>w("select",{class:Rt("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-transparent cursor-pointer transition-colors","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...r,children:e}),kr=({class:i,required:t,children:e,for:r,...s})=>w("label",{for:r,class:Rt("text-sm font-medium text-foreground",i),...s,children:[e,t&&w("span",{class:"text-destructive ml-0.5",children:"*"})]}),Dh=({tabs:i,activeTab:t,onTabChange:e})=>w("div",{class:"inline-flex p-1 bg-muted rounded gap-1",role:"tablist","aria-orientation":"horizontal",children:i.map(r=>{const s=r.id===t;return w("button",{type:"button",role:"tab",id:`tab-${r.id}`,"aria-selected":s,"aria-controls":`tabpanel-${r.id}`,tabIndex:s?0:-1,class:Rt("flex items-center gap-2 px-3 py-1.5 border-none rounded-md bg-transparent text-muted-foreground text-sm font-medium font-sans cursor-pointer transition-colors","hover:text-foreground",s&&"bg-background text-foreground shadow-sm"),onClick:()=>e(r.id),children:[r.icon&&w("span",{class:"flex items-center justify-center [&_svg]:w-4 [&_svg]:h-4",children:r.icon}),r.label]},r.id)})}),Mh={success:"bg-green-50 border-green-200 text-green-600",error:"bg-red-50 border-red-200 text-red-600",info:"bg-blue-50 border-blue-200 text-blue-600"},Eh=({message:i,type:t,onClose:e,duration:r=5e3})=>(Ht(()=>{const s=setTimeout(e,r);return()=>clearTimeout(s)},[e,r]),w("div",{class:Rt("fixed bottom-20 right-5 z-[2147483647] flex items-center gap-3 px-5 py-4 border border-solid rounded text-sm shadow-lg animate-[slideIn_0.3s_ease-out]",Mh[t]),role:"alert","aria-live":"polite",children:[t==="success"&&w("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",fill:"currentColor"})}),t==="error"&&w("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),t==="info"&&w("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z",fill:"currentColor"})}),w("span",{children:i})]})),Ph=10*1024*1024,Ah=50*1024*1024,Lh=["image/png","image/jpeg","image/gif","image/webp"],jh=["video/mp4","video/webm","video/quicktime","video/x-msvideo"],Fh=({media:i,onCapture:t,onUpload:e,onRemove:r,onAnnotate:s,isCapturing:n,enableAnnotation:o})=>{const[a,l]=at(!1),[c,h]=at(null),u=Ft(null),d=S=>S.startsWith("video/"),g=S=>S.startsWith("image/"),f=K(S=>{if(g(S.type)){if(!Lh.includes(S.type))return`Unsupported image format: ${S.type}`;if(S.size>Ph)return"Image too large. Maximum size is 10MB."}else if(d(S.type)){if(!jh.includes(S.type))return`Unsupported video format: ${S.type}`;if(S.size>Ah)return"Video too large. Maximum size is 50MB."}else return`Unsupported file type: ${S.type}`;return null},[]),p=K(async S=>{const j=f(S);if(j){h(j);return}h(null);const T=new FileReader;T.onload=()=>{const L=T.result;if(g(S.type)){const H=new Image;H.onload=()=>{const W={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:S.type,width:H.width,height:H.height};e(W)},H.src=L}else if(d(S.type)){const H=document.createElement("video");H.onloadedmetadata=()=>{const W={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:L,timestamp:new Date,annotated:!1,mimeType:S.type,width:H.videoWidth,height:H.videoHeight};e(W)},H.src=L}},T.readAsDataURL(S)},[f,e]),v=K(S=>{S.preventDefault(),S.stopPropagation(),l(!0)},[]),b=K(S=>{S.preventDefault(),S.stopPropagation(),l(!1)},[]),x=K(async S=>{var T;S.preventDefault(),S.stopPropagation(),l(!1);const j=(T=S.dataTransfer)==null?void 0:T.files;if(j)for(let L=0;L<j.length;L++)await p(j[L])},[p]),D=K(async S=>{const j=S.target,T=j.files;if(T)for(let L=0;L<T.length;L++)await p(T[L]);j.value=""},[p]),C=K(()=>{var S;(S=u.current)==null||S.click()},[]),O=S=>S.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return w("div",{class:"flex flex-col gap-4",children:[w("p",{class:"text-xs text-muted-foreground",children:"Tip: Use the annotation tool to hide any sensitive data before submitting."}),w("div",{class:"flex gap-2",children:[w(Se,{class:"flex-1",onClick:t,disabled:n,children:[w("svg",{class:"w-4.5 h-4.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M12 15.2c1.77 0 3.2-1.43 3.2-3.2S13.77 8.8 12 8.8 8.8 10.23 8.8 12s1.43 3.2 3.2 3.2zM9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",fill:"currentColor"})}),n?"Capturing...":"Capture Screenshot"]}),w("input",{ref:u,type:"file",accept:"image/*,video/*",multiple:!0,style:{display:"none"},onChange:D})]}),c&&w("div",{class:"flex items-center gap-2 px-3 py-2.5 bg-red-50 border border-solid border-red-200 rounded text-red-600 text-sm",children:[w("svg",{class:"w-4.5 h-4.5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),c]}),w("div",{class:Rt("min-h-40 border-2 border-dashed border-border rounded bg-muted transition-colors",a&&"border-primary bg-primary/5",i.length>0&&"border-solid bg-background min-h-0"),onDragOver:v,onDragLeave:b,onDrop:x,children:i.length===0?w("div",{class:"flex flex-col items-center justify-center py-8 px-4 text-gray-500 text-center cursor-pointer transition-colors hover:text-primary [&_svg]:hover:text-primary",onClick:C,children:[w("svg",{class:"w-12 h-12 mb-3 text-gray-400 transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z",fill:"currentColor"})}),w("p",{class:"text-sm font-medium mb-1",children:"Drag and drop files here"}),w("span",{class:"text-xs text-gray-400",children:"or click to browse"})]}):w("div",{class:"grid grid-cols-2 gap-3 p-3",children:[i.map(S=>w("div",{class:"relative rounded overflow-hidden bg-background border border-solid border-border",children:[w("div",{class:"relative aspect-video bg-gray-800",children:[d(S.mimeType)?w("video",{class:"w-full h-full object-contain",src:S.dataUrl,muted:!0}):w("img",{class:"w-full h-full object-contain",src:S.dataUrl,alt:"Screenshot"}),w("div",{class:"absolute top-1.5 left-1.5 flex gap-1",children:[S.annotated&&w("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-blue-100 text-blue-700",children:"Annotated"}),d(S.mimeType)&&w("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-gray-200 text-gray-700",children:"Video"})]})]}),w("div",{class:"flex justify-between px-2 py-1.5 text-xs text-gray-500 border-t border-solid border-gray-200",children:[w("span",{children:O(S.timestamp)}),S.width&&S.height&&w("span",{children:[S.width," x ",S.height]})]}),w("div",{class:"flex gap-1 px-2 py-1.5 border-t border-solid border-gray-200 bg-gray-50",children:[o&&g(S.mimeType)&&w(Se,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-white hover:bg-gray-200",onClick:()=>s(S.id),title:"Annotate",children:w("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",fill:"currentColor"})})}),w(Se,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-white hover:bg-red-50 hover:text-red-600",onClick:()=>r(S.id),title:"Remove",children:w("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]})]},S.id)),w("div",{class:"flex flex-col items-center justify-center gap-2 min-h-28 border-2 border-dashed border-border rounded bg-muted cursor-pointer transition-colors hover:border-primary hover:bg-primary/5 [&_svg]:hover:text-primary [&_span]:hover:text-primary",onClick:C,children:[w("svg",{class:"w-8 h-8 text-gray-400 transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",fill:"currentColor"})}),w("span",{class:"text-xs text-gray-400 transition-colors",children:"Add more"})]})]})}),w("p",{class:"text-xs text-gray-400 text-center",children:"Supported: PNG, JPG, GIF, WebP (max 10MB) - MP4, WebM, MOV, AVI (max 50MB)"})]})},Rh=[{id:"details",label:"Details",icon:w("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",fill:"currentColor"})})},{id:"media",label:"Screenshots",icon:w("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",fill:"currentColor"})})}],Ih=({onClose:i,onSubmit:t,onCaptureScreenshot:e,onAnnotateMedia:r,media:s,onAddMedia:n,onRemoveMedia:o,isSubmitting:a,isCapturing:l,enableAnnotation:c,activeTab:h,onActiveTabChange:u,formData:d,onFormDataChange:g})=>{const[f,p]=at({}),v=K((C,O)=>{g({...d,[C]:O}),f[C]&&p(S=>({...S,[C]:void 0}))},[d,g,f]),b=K(()=>{const C={};return d.title.trim()?d.title.trim().length<4&&(C.title="Title must be at least 4 characters"):C.title="Title is required",d.reporterEmail&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.reporterEmail)&&(C.reporterEmail="Invalid email address"),p(C),Object.keys(C).length===0},[d]),x=K(C=>{if(C.preventDefault(),!b()){u("details");return}t(d,s)},[d,s,b,t,u]),D=s.length;return w("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:w("div",{class:"relative w-full max-w-3xl max-h-[90vh] bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-title",children:[w("div",{class:"flex items-center justify-between p-6 border-b border-solid border-border",children:[w("h2",{id:"bugpin-title",class:"text-lg font-semibold text-foreground tracking-tight",children:"Report a Bug"}),w(Se,{variant:"ghost",size:"icon",onClick:i,"aria-label":"Close",children:w("svg",{class:"w-5 h-5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:w("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",fill:"currentColor"})})})]}),w("div",{class:"p-4 pb-0 bg-transparent",children:w(Dh,{tabs:Rh.map(C=>({...C,label:C.id==="media"&&D>0?`${C.label} (${D})`:C.label})),activeTab:h,onTabChange:u})}),w("div",{class:"flex-1 overflow-y-auto p-6",children:[h==="details"&&w("form",{class:"flex flex-col gap-4",onSubmit:x,children:[w("div",{class:"flex flex-col gap-1.5",children:[w(kr,{for:"bugpin-title-input",required:!0,children:"Title"}),w(Ai,{id:"bugpin-title-input",type:"text",placeholder:"Brief description of the issue",value:d.title,onInput:C=>v("title",C.target.value),maxLength:200,error:!!f.title,"aria-describedby":f.title?"bugpin-title-error":void 0}),f.title&&w("span",{id:"bugpin-title-error",class:"text-destructive text-xs mt-0.5",children:f.title})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(kr,{for:"bugpin-description",children:"Description"}),w(kh,{id:"bugpin-description",placeholder:"Steps to reproduce, expected behavior, etc.",value:d.description,onInput:C=>v("description",C.target.value)})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(kr,{for:"bugpin-priority",children:"Priority"}),w(Oh,{id:"bugpin-priority",value:d.priority,onChange:C=>v("priority",C.target.value),children:[w("option",{value:"highest",children:"Highest"}),w("option",{value:"high",children:"High"}),w("option",{value:"medium",children:"Medium"}),w("option",{value:"low",children:"Low"}),w("option",{value:"lowest",children:"Lowest"})]})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(kr,{for:"bugpin-name",children:"Name (optional)"}),w(Ai,{id:"bugpin-name",type:"text",placeholder:"Your name",value:d.reporterName,onInput:C=>v("reporterName",C.target.value)})]}),w("div",{class:"flex flex-col gap-1.5",children:[w(kr,{for:"bugpin-email",children:"Email (optional)"}),w(Ai,{id:"bugpin-email",type:"email",placeholder:"your@email.com",value:d.reporterEmail,onInput:C=>v("reporterEmail",C.target.value),error:!!f.reporterEmail,"aria-describedby":f.reporterEmail?"bugpin-email-error":void 0}),f.reporterEmail&&w("span",{id:"bugpin-email-error",class:"text-destructive text-xs mt-0.5",children:f.reporterEmail})]})]}),h==="media"&&w(Fh,{media:s,onCapture:e,onUpload:n,onRemove:o,onAnnotate:r,isCapturing:l,enableAnnotation:c})]}),w("div",{class:"flex gap-3 p-6 border-t border-solid border-border bg-muted",children:[w(Se,{variant:"outline",class:"flex-1",onClick:i,disabled:a,children:"Cancel"}),w(Se,{class:"flex-1",onClick:x,disabled:a,children:a?w("span",{class:"w-4 h-4 border-2 border-solid border-white/30 border-t-white rounded-full animate-[spin_0.8s_linear_infinite]"}):"Submit Report"})]}),w("div",{class:"py-3 px-6 text-center text-xs text-muted-foreground border-t border-solid border-border bg-background",children:["Powered by"," ",w("a",{href:"https://bugpin.io",target:"_blank",rel:"noopener noreferrer",class:"text-primary no-underline font-medium hover:underline hover:text-primary-hover",children:"BugPin"})]})]})})};function m(i,t,e){return(t=function(r){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)}(r,"string");return typeof s=="symbol"?s:s+""}(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function Xo(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),e.push.apply(e,r)}return e}function y(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Xo(Object(e),!0).forEach(function(r){m(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Xo(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function ot(i,t){if(i==null)return{};var e,r,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}(i,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);for(r=0;r<n.length;r++)e=n[r],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(i,e)&&(s[e]=i[e])}return s}function re(i,t){return t||(t=i.slice(0)),Object.freeze(Object.defineProperties(i,{raw:{value:Object.freeze(t)}}))}class Yo{constructor(){m(this,"browserShadowBlurConstant",1),m(this,"DPI",96),m(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),m(this,"perfLimitSizeTotal",2097152),m(this,"maxCacheSideLimit",4096),m(this,"minCacheSideLimit",256),m(this,"disableStyleCopyPaste",!1),m(this,"enableGLFiltering",!0),m(this,"textureSize",4096),m(this,"forceGLPutImageData",!1),m(this,"cachesBoundsOfCurve",!1),m(this,"fontPaths",{}),m(this,"NUM_FRACTION_DIGITS",4)}}const Q=new class extends Yo{constructor(i){super(),this.configure(i)}configure(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,i)}addFonts(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=y(y({},this.fontPaths),i)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(i=>{delete this.fontPaths[i]})}clearFonts(){this.fontPaths={}}restoreDefaults(i){const t=new Yo,e=(i==null?void 0:i.reduce((r,s)=>(r[s]=t[s],r),{}))||t;this.configure(e)}},Te=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return console[i]("fabric",...e)};class se extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class Bh extends se{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class zh{}class Hh extends zh{testPrecision(t,e){const r="precision ".concat(e,` float;
37
- void main(){}`),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,r),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(r=>this.testPrecision(e,r)),e.getExtension("WEBGL_lose_context").loseContext(),Te("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Vh={};let Uo;const ie=()=>Uo||(Uo={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Hh,dispose(){},copyPasteData:Vh}),qe=()=>ie().document,bs=()=>ie().window,No=()=>{var i;return Math.max((i=Q.devicePixelRatio)!==null&&i!==void 0?i:bs().devicePixelRatio,1)},Or=new class{constructor(){m(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(i){let{fontFamily:t,fontStyle:e,fontWeight:r}=i;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((r+"").toLowerCase());return n.has(o)||n.set(o,new Map),n.get(o)}clearFontCache(i){i?this.charWidthsCache.delete((i||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(i){const{perfLimitSizeTotal:t}=Q,e=Math.sqrt(t*i);return[Math.floor(e),Math.floor(t/e)]}},Li="6.9.1";function ws(){}const Dr=Math.PI/2,xs=2*Math.PI,ji=Math.PI/180,St=Object.freeze([1,0,0,1,0,0]),Fi=16,ke=.4477152502,$="center",et="left",Dt="top",Ri="bottom",ft="right",Mt="none",Ii=/\r?\n/,Go="moving",_s="scaling",$o="rotating",Bi="rotate",qo="skewing",Mr="resizing",Wh="modifyPoly",Xh="modifyPath",Cs="changed",Ss="scale",Et="scaleX",Vt="scaleY",Ke="skewX",Ze="skewY",xt="fill",Pt="stroke",Ts="modified",Je="json",zi="svg",R=new class{constructor(){this[Je]=new Map,this[zi]=new Map}has(i){return this[Je].has(i)}getClass(i){const t=this[Je].get(i);if(!t)throw new se("No class registered for ".concat(i));return t}setClass(i,t){t?this[Je].set(t,i):(this[Je].set(i.type,i),this[Je].set(i.type.toLowerCase(),i))}getSVGClass(i){return this[zi].get(i)}setSVGClass(i,t){this[zi].set(t??i.type.toLowerCase(),i)}},ks=new class extends Array{remove(i){const t=this.indexOf(i);t>-1&&this.splice(t,1)}cancelAll(){const i=this.splice(0);return i.forEach(t=>t.abort()),i}cancelByCanvas(i){if(!i)return[];const t=this.filter(e=>{var r;return e.target===i||typeof e.target=="object"&&((r=e.target)===null||r===void 0?void 0:r.canvas)===i});return t.forEach(e=>e.abort()),t}cancelByTarget(i){if(!i)return[];const t=this.filter(e=>e.target===i);return t.forEach(e=>e.abort()),t}};class Yh{constructor(){m(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(r=>{let[s,n]=r;this.on(s,n)}),()=>this.off(t);if(e){const r=t;return this.__eventListeners[r]||(this.__eventListeners[r]=[]),this.__eventListeners[r].push(e),()=>this.off(r,e)}return()=>!1}once(t,e){if(typeof t=="object"){const r=[];return Object.entries(t).forEach(s=>{let[n,o]=s;r.push(this.once(n,o))}),()=>r.forEach(s=>s())}if(e){const r=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),r()});return r}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const r=this.__eventListeners[t],s=r.indexOf(e);s>-1&&r.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const r in this.__eventListeners)this._removeEventListener(r);else typeof t=="object"?Object.entries(t).forEach(r=>{let[s,n]=r;this._removeEventListener(s,n)}):this._removeEventListener(t,e)}fire(t,e){var r;if(!this.__eventListeners)return;const s=(r=this.__eventListeners[t])===null||r===void 0?void 0:r.concat();if(s)for(let n=0;n<s.length;n++)s[n].call(this,e||{})}}const Qe=(i,t)=>{const e=i.indexOf(t);return e!==-1&&i.splice(e,1),i},de=i=>{if(i===0)return 1;switch(Math.abs(i)/Dr){case 1:case 3:return 0;case 2:return-1}return Math.cos(i)},ge=i=>{if(i===0)return 0;const t=i/Dr,e=Math.sign(i);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(i)};class _{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 _(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new _(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new _(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new _(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new _(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new _(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new _(this.x/t.x,this.y/t.y)}scalarDivide(t){return new _(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 _(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)}midPointFrom(t){return this.lerp(t)}min(t){return new _(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new _(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,r=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=r}clone(){return new _(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Hi;const r=ge(t),s=de(t),n=this.subtract(e);return new _(n.x*s-n.y*r,n.x*r+n.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new _(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 Hi=new _(0,0),Os=i=>!!i&&Array.isArray(i._objects);function Ko(i){class t extends i{constructor(){super(...arguments),m(this,"_objects",[])}_onObjectAdded(r){}_onObjectRemoved(r){}_onStackOrderChanged(r){}add(){for(var r=arguments.length,s=new Array(r),n=0;n<r;n++)s[n]=arguments[n];const o=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),o}insertAt(r){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(r,0,...n),n.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const r=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=r.indexOf(l);c!==-1&&(r.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(r){this.getObjects().forEach((s,n,o)=>r(s,n,o))}getObjects(){for(var r=arguments.length,s=new Array(r),n=0;n<r;n++)s[n]=arguments[n];return s.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...s))}item(r){return this._objects[r]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(r,s){return!!this._objects.includes(r)||!!s&&this._objects.some(n=>n instanceof t&&n.contains(r,!0))}complexity(){return this._objects.reduce((r,s)=>r+=s.complexity?s.complexity():0,0)}sendObjectToBack(r){return!(!r||r===this._objects[0])&&(Qe(this._objects,r),this._objects.unshift(r),this._onStackOrderChanged(r),!0)}bringObjectToFront(r){return!(!r||r===this._objects[this._objects.length-1])&&(Qe(this._objects,r),this._objects.push(r),this._onStackOrderChanged(r),!0)}sendObjectBackwards(r,s){if(!r)return!1;const n=this._objects.indexOf(r);if(n!==0){const o=this.findNewLowerIndex(r,n,s);return Qe(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}bringObjectForward(r,s){if(!r)return!1;const n=this._objects.indexOf(r);if(n!==this._objects.length-1){const o=this.findNewUpperIndex(r,n,s);return Qe(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}moveObjectTo(r,s){return r!==this._objects[s]&&(Qe(this._objects,r),this._objects.splice(s,0,r),this._onStackOrderChanged(r),!0)}findNewLowerIndex(r,s,n){let o;if(n){o=s;for(let a=s-1;a>=0;--a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(r,s,n){let o;if(n){o=s;for(let a=s+1;a<this._objects.length;++a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(r){let{left:s,top:n,width:o,height:a}=r,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new _(s,n),u=h.add(new _(o,a));for(let d=this._objects.length-1;d>=0;d--){const g=this._objects[d];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,u)||g.isContainedWithinRect(h,u)||l&&g.containsPoint(h)||l&&g.containsPoint(u))&&c.push(g)}return c}}return t}class Zo extends Yh{_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 Ds(i){return bs().requestAnimationFrame(i)}function Uh(i){return bs().cancelAnimationFrame(i)}let Nh=0;const Oe=()=>Nh++,fe=()=>{const i=qe().createElement("canvas");if(!i||i.getContext===void 0)throw new se("Failed to create `canvas` element");return i},Gh=()=>qe().createElement("img"),Wt=i=>{const t=fe();return t.width=i.width,t.height=i.height,t},Jo=(i,t,e)=>i.toDataURL("image/".concat(t),e),Qo=(i,t,e)=>new Promise((r,s)=>{i.toBlob(r,"image/".concat(t),e)}),pt=i=>i*ji,pe=i=>i/ji,$h=i=>i.every((t,e)=>t===St[e]),At=(i,t,e)=>new _(i).transform(t,e),Nt=i=>{const t=1/(i[0]*i[3]-i[1]*i[2]),e=[t*i[3],-t*i[1],-t*i[2],t*i[0],0,0],{x:r,y:s}=new _(i[4],i[5]).transform(e,!0);return e[4]=-r,e[5]=-s,e},Ct=(i,t,e)=>[i[0]*t[0]+i[2]*t[1],i[1]*t[0]+i[3]*t[1],i[0]*t[2]+i[2]*t[3],i[1]*t[2]+i[3]*t[3],e?0:i[0]*t[4]+i[2]*t[5]+i[4],e?0:i[1]*t[4]+i[3]*t[5]+i[5]],Vi=(i,t)=>i.reduceRight((e,r)=>r&&e?Ct(r,e,t):r||e,void 0)||St.concat(),ta=i=>{let[t,e]=i;return Math.atan2(e,t)},Ms=i=>{const t=ta(i),e=Math.pow(i[0],2)+Math.pow(i[1],2),r=Math.sqrt(e),s=(i[0]*i[3]-i[2]*i[1])/r,n=Math.atan2(i[0]*i[2]+i[1]*i[3],e);return{angle:pe(t),scaleX:r,scaleY:s,skewX:pe(n),skewY:0,translateX:i[4]||0,translateY:i[5]||0}},Er=function(i){return[1,0,0,1,i,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function tr(){let{angle:i=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 r=pt(i),s=de(r),n=ge(r);return[s,n,-n,s,t?t-(s*t-n*e):0,e?e-(n*t+s*e):0]}const Wi=function(i){return[i,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:i,0,0]},ea=i=>Math.tan(pt(i)),ra=i=>[1,0,ea(i),1,0,0],sa=i=>[1,ea(i),0,1,0,0],Es=i=>{let{scaleX:t=1,scaleY:e=1,flipX:r=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=i,a=Wi(r?-t:t,s?-e:e);return n&&(a=Ct(a,ra(n),!0)),o&&(a=Ct(a,sa(o),!0)),a},qh=i=>{const{translateX:t=0,translateY:e=0,angle:r=0}=i;let s=Er(t,e);r&&(s=Ct(s,tr({angle:r})));const n=Es(i);return $h(n)||(s=Ct(s,n)),s},Ps=function(i){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(r,s){if(t&&t.aborted)return s(new Bh("loadImage"));const n=Gh();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)),r(n)};i?(n.onload=a,n.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new se("Error loading ".concat(n.src)))},e&&(n.crossOrigin=e),n.src=i):a()})},Pr=function(i){let{signal:t,reviver:e=ws}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((r,s)=>{const n=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(i.map(o=>R.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),n.push(a),a)))).then(r).catch(o=>{n.forEach(a=>{a.dispose&&a.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},As=function(i){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,r)=>{const s=[];t&&t.addEventListener("abort",r,{once:!0});const n=Object.values(i).map(a=>a&&a.type&&R.has(a.type)?Pr([a],{signal:t}).then(l=>{let[c]=l;return s.push(c),c}):a),o=Object.keys(i);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()}),r(a)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},er=function(i){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in i&&(t[e]=i[e]),t),{})},Xi=(i,t)=>Object.keys(i).reduce((e,r)=>(t(i[r],r,i)&&(e[r]=i[r]),e),{}),it=(i,t)=>parseFloat(Number(i).toFixed(t)),Ar=i=>"matrix("+i.map(t=>it(t,Q.NUM_FRACTION_DIGITS)).join(" ")+")",Xt=i=>!!i&&i.toLive!==void 0,ia=i=>!!i&&typeof i.toObject=="function",na=i=>!!i&&i.offsetX!==void 0&&"source"in i,Re=i=>!!i&&"multiSelectionStacking"in i;function oa(i){const t=i&&Gt(i);let e=0,r=0;if(!i||!t)return{left:e,top:r};let s=i;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,r=o.scrollTop||n.scrollTop||0):(e+=s.scrollLeft||0,r+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:r}}const Gt=i=>i.ownerDocument||null,aa=i=>{var t;return((t=i.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},la=function(i,t,e){let{width:r,height:s}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;i.width=r,i.height=s,n>1&&(i.setAttribute("width",(r*n).toString()),i.setAttribute("height",(s*n).toString()),t.scale(n,n))},Yi=(i,t)=>{let{width:e,height:r}=t;e&&(i.style.width=typeof e=="number"?"".concat(e,"px"):e),r&&(i.style.height=typeof r=="number"?"".concat(r,"px"):r)};function ca(i){return i.onselectstart!==void 0&&(i.onselectstart=()=>!1),i.style.userSelect=Mt,i}class ha{constructor(t){m(this,"_originalCanvasStyle",void 0),m(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(r=t)&&r.getContext!==void 0?t:t&&qe().getElementById(t)||fe();var r;if(e.hasAttribute("data-fabric"))throw new se("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:r}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(r)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:r,ctx:s}=this.lower;la(r,s,t,e)}setCSSDimensions(t){Yi(this.lower.el,t)}calcOffset(){return function(t){var e;const r=t&&Gt(t),s={left:0,top:0};if(!r)return s;const n=((e=aa(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=r.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=oa(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(){ie().dispose(this.lower.el),delete this.lower}}const Kh={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...St]},Zh=["objects"];class Lr extends Ko(Zo){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 Lr.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 ha(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;s<e;s++)r[s-1]=arguments[s];const n=super.insertAt(t,...r);return r.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&&(Te("warn",`Canvas is trying to add an object that belongs to a different canvas.
38
- 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?No():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:r=!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}r||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 r=t,s=[...this.viewportTransform],n=At(t,Nt(s));s[0]=e,s[3]=e;const o=At(n,s);s[4]+=r.x-o.x,s[5]+=r.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new _(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 _(-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=Ds(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Nt(this.viewportTransform),s=At({x:0,y:0},r),n=At({x:t,y:e},r),o=s.min(n),a=s.max(n);return this.vptCoords={tl:o,tr:new _(a.x,o.y),bl:new _(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Uh(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const r=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(r[0],r[1],r[2],r[3],r[4],r[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 r=this.viewportTransform;t.save(),t.transform(...r),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 r=0,s=e.length;r<s;++r)e[r]&&e[r].render(t)}_renderBackgroundOrOverlay(t,e){const r=this["".concat(e,"Color")],s=this["".concat(e,"Image")],n=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!r&&!s)return;const a=Xt(r);if(r){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?r.toLive(t):r,o&&t.transform(...n),a){t.transform(1,0,0,1,r.offsetX||0,r.offsetY||0);const l=r.gradientTransform||r.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 _(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new _(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new _(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 _(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new _(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return At(this.getCenterPoint(),Nt(this.viewportTransform))}_centerObject(t,e){t.setXY(e,$,$),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 r=this.clipPath,s=r&&!r.excludeFromExport?this._toObject(r,t,e):null;return y(y(y({version:Li},er(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,r){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](r);return this.includeDefaultValues||(t.includeDefaultValues=!!s),n}__serializeBgOverlay(t,e){const r={},s=this.backgroundImage,n=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return Xt(o)?o.excludeFromExport||(r.background=o.toObject(e)):o&&(r.background=o),Xt(a)?a.excludeFromExport||(r.overlay=a.toObject(e)):a&&(r.overlay=a),s&&!s.excludeFromExport&&(r.backgroundImage=this._toObject(s,t,e)),n&&!n.excludeFromExport&&(r.overlayImage=this._toObject(n,t,e)),r}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const r=[];return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
39
- `)),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push(`</g>
36
+ */const Dc=Di("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),Mc={bug:Tc,"message-square":Dc,"alert-circle":Oc},Ec=({name:i,class:t,size:e=18,strokeWidth:r=2})=>{const s=Mc[i];return s?p(s,{class:t,size:e,strokeWidth:r}):null};function So(i){var t,e,r="";if(typeof i=="string"||typeof i=="number")r+=i;else if(typeof i=="object")if(Array.isArray(i)){var s=i.length;for(t=0;t<s;t++)i[t]&&(e=So(i[t]))&&(r&&(r+=" "),r+=e)}else for(e in i)i[e]&&(r&&(r+=" "),r+=e);return r}function ko(){for(var i,t,e=0,r="",s=arguments.length;e<s;e++)(i=arguments[e])&&(t=So(i))&&(r&&(r+=" "),r+=t);return r}const Pc=(i,t)=>{const e=new Array(i.length+t.length);for(let r=0;r<i.length;r++)e[r]=i[r];for(let r=0;r<t.length;r++)e[i.length+r]=t[r];return e},Ac=(i,t)=>({classGroupId:i,validator:t}),To=(i=new Map,t=null,e)=>({nextPart:i,validators:t,classGroupId:e}),vs="-",Oo=[],Lc="arbitrary..",Fc=i=>{const t=Ic(i),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=i;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return jc(o);const a=o.split(vs),l=a[0]===""&&a.length>1?1:0;return Do(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=e[o];return l?c?Pc(c,l):l:c||Oo}return e[o]||Oo}}},Do=(i,t,e)=>{if(i.length-t===0)return e.classGroupId;const s=i[t],n=e.nextPart.get(s);if(n){const c=Do(i,t+1,n);if(c)return c}const o=e.validators;if(o===null)return;const a=t===0?i.join(vs):i.slice(t).join(vs),l=o.length;for(let c=0;c<l;c++){const h=o[c];if(h.validator(a))return h.classGroupId}},jc=i=>i.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=i.slice(1,-1),e=t.indexOf(":"),r=t.slice(0,e);return r?Lc+r:void 0})(),Ic=i=>{const{theme:t,classGroups:e}=i;return Bc(e,t)},Bc=(i,t)=>{const e=To();for(const r in i){const s=i[r];Mi(s,e,r,t)}return e},Mi=(i,t,e,r)=>{const s=i.length;for(let n=0;n<s;n++){const o=i[n];Rc(o,t,e,r)}},Rc=(i,t,e,r)=>{if(typeof i=="string"){$c(i,t,e);return}if(typeof i=="function"){zc(i,t,e,r);return}Hc(i,t,e,r)},$c=(i,t,e)=>{const r=i===""?t:Mo(t,i);r.classGroupId=e},zc=(i,t,e,r)=>{if(Vc(i)){Mi(i(r),t,e,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ac(e,i))},Hc=(i,t,e,r)=>{const s=Object.entries(i),n=s.length;for(let o=0;o<n;o++){const[a,l]=s[o];Mi(l,Mo(t,a),e,r)}},Mo=(i,t)=>{let e=i;const r=t.split(vs),s=r.length;for(let n=0;n<s;n++){const o=r[n];let a=e.nextPart.get(o);a||(a=To(),e.nextPart.set(o,a)),e=a}return e},Vc=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,Wc=i=>{if(i<1)return{get:()=>{},set:()=>{}};let t=0,e=Object.create(null),r=Object.create(null);const s=(n,o)=>{e[n]=o,t++,t>i&&(t=0,r=e,e=Object.create(null))};return{get(n){let o=e[n];if(o!==void 0)return o;if((o=r[n])!==void 0)return s(n,o),o},set(n,o){n in e?e[n]=o:s(n,o)}}},Ei="!",Eo=":",Xc=[],Po=(i,t,e,r,s)=>({modifiers:i,hasImportantModifier:t,baseClassName:e,maybePostfixModifierPosition:r,isExternal:s}),Yc=i=>{const{prefix:t,experimentalParseClassName:e}=i;let r=s=>{const n=[];let o=0,a=0,l=0,c;const h=s.length;for(let m=0;m<h;m++){const y=s[m];if(o===0&&a===0){if(y===Eo){n.push(s.slice(l,m)),l=m+1;continue}if(y==="/"){c=m;continue}}y==="["?o++:y==="]"?o--:y==="("?a++:y===")"&&a--}const u=n.length===0?s:s.slice(l);let d=u,g=!1;u.endsWith(Ei)?(d=u.slice(0,-1),g=!0):u.startsWith(Ei)&&(d=u.slice(1),g=!0);const f=c&&c>l?c-l:void 0;return Po(n,g,d,f)};if(t){const s=t+Eo,n=r;r=o=>o.startsWith(s)?n(o.slice(s.length)):Po(Xc,!1,o,void 0,!0)}if(e){const s=r;r=n=>e({className:n,parseClassName:s})}return r},Uc=i=>{const t=new Map;return i.orderSensitiveModifiers.forEach((e,r)=>{t.set(e,1e6+r)}),e=>{const r=[];let s=[];for(let n=0;n<e.length;n++){const o=e[n],a=o[0]==="[",l=t.has(o);a||l?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(o)):s.push(o)}return s.length>0&&(s.sort(),r.push(...s)),r}},Gc=i=>({cache:Wc(i.cacheSize),parseClassName:Yc(i),sortModifiers:Uc(i),...Fc(i)}),Nc=/\s+/,qc=(i,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:n}=t,o=[],a=i.trim().split(Nc);let l="";for(let c=a.length-1;c>=0;c-=1){const h=a[c],{isExternal:u,modifiers:d,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:m}=e(h);if(u){l=h+(l.length>0?" "+l:l);continue}let y=!!m,b=r(y?f.substring(0,m):f);if(!b){if(!y){l=h+(l.length>0?" "+l:l);continue}if(b=r(f),!b){l=h+(l.length>0?" "+l:l);continue}y=!1}const w=d.length===0?"":d.length===1?d[0]:n(d).join(":"),T=g?w+Ei:w,C=T+b;if(o.indexOf(C)>-1)continue;o.push(C);const S=s(b,y);for(let D=0;D<S.length;++D){const A=S[D];o.push(T+A)}l=h+(l.length>0?" "+l:l)}return l},Kc=(...i)=>{let t=0,e,r,s="";for(;t<i.length;)(e=i[t++])&&(r=Ao(e))&&(s&&(s+=" "),s+=r);return s},Ao=i=>{if(typeof i=="string")return i;let t,e="";for(let r=0;r<i.length;r++)i[r]&&(t=Ao(i[r]))&&(e&&(e+=" "),e+=t);return e},Zc=(i,...t)=>{let e,r,s,n;const o=l=>{const c=t.reduce((h,u)=>u(h),i());return e=Gc(c),r=e.cache.get,s=e.cache.set,n=a,a(l)},a=l=>{const c=r(l);if(c)return c;const h=qc(l,e);return s(l,h),h};return n=o,(...l)=>n(Kc(...l))},Jc=[],bt=i=>{const t=e=>e[i]||Jc;return t.isThemeGetter=!0,t},Lo=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Fo=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Qc=/^\d+\/\d+$/,th=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,eh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,rh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ih=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ge=i=>Qc.test(i),U=i=>!!i&&!Number.isNaN(Number(i)),_e=i=>!!i&&Number.isInteger(Number(i)),Pi=i=>i.endsWith("%")&&U(i.slice(0,-1)),he=i=>th.test(i),nh=()=>!0,oh=i=>eh.test(i)&&!rh.test(i),jo=()=>!1,ah=i=>sh.test(i),lh=i=>ih.test(i),ch=i=>!R(i)&&!$(i),hh=i=>Ne(i,zo,jo),R=i=>Lo.test(i),Fe=i=>Ne(i,Ho,oh),Ai=i=>Ne(i,ph,U),Io=i=>Ne(i,Ro,jo),uh=i=>Ne(i,$o,lh),ys=i=>Ne(i,Vo,ah),$=i=>Fo.test(i),Or=i=>qe(i,Ho),dh=i=>qe(i,mh),Bo=i=>qe(i,Ro),gh=i=>qe(i,zo),fh=i=>qe(i,$o),bs=i=>qe(i,Vo,!0),Ne=(i,t,e)=>{const r=Lo.exec(i);return r?r[1]?t(r[1]):e(r[2]):!1},qe=(i,t,e=!1)=>{const r=Fo.exec(i);return r?r[1]?t(r[1]):e:!1},Ro=i=>i==="position"||i==="percentage",$o=i=>i==="image"||i==="url",zo=i=>i==="length"||i==="size"||i==="bg-size",Ho=i=>i==="length",ph=i=>i==="number",mh=i=>i==="family-name",Vo=i=>i==="shadow",vh=Zc(()=>{const i=bt("color"),t=bt("font"),e=bt("text"),r=bt("font-weight"),s=bt("tracking"),n=bt("leading"),o=bt("breakpoint"),a=bt("container"),l=bt("spacing"),c=bt("radius"),h=bt("shadow"),u=bt("inset-shadow"),d=bt("text-shadow"),g=bt("drop-shadow"),f=bt("blur"),m=bt("perspective"),y=bt("aspect"),b=bt("ease"),w=bt("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...C(),$,R],D=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],_=()=>[$,R,l],M=()=>[Ge,"full","auto",..._()],O=()=>[_e,"none","subgrid",$,R],V=()=>["auto",{span:["full",_e,$,R]},_e,$,R],z=()=>[_e,"auto",$,R],X=()=>["auto","min","max","fr",$,R],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],G=()=>["start","end","center","stretch","center-safe","end-safe"],K=()=>["auto",..._()],Z=()=>[Ge,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],L=()=>[i,$,R],wt=()=>[...C(),Bo,Io,{position:[$,R]}],mt=()=>["no-repeat",{repeat:["","x","y","space","round"]}],lt=()=>["auto","cover","contain",gh,hh,{size:[$,R]}],k=()=>[Pi,Or,Fe],P=()=>["","none","full",c,$,R],E=()=>["",U,Or,Fe],B=()=>["solid","dashed","dotted","double"],I=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[U,Pi,Bo,Io],dt=()=>["","none",f,$,R],ht=()=>["none",U,$,R],it=()=>["none",U,$,R],kt=()=>[U,$,R],F=()=>[Ge,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[he],breakpoint:[he],color:[nh],container:[he],"drop-shadow":[he],ease:["in","out","in-out"],font:[ch],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[he],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[he],shadow:[he],spacing:["px",U],text:[he],"text-shadow":[he],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ge,R,$,y]}],container:["container"],columns:[{columns:[U,R,$,a]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{start:M()}],end:[{end:M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[_e,"auto",$,R]}],basis:[{basis:[Ge,"full","auto",a,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[U,Ge,"auto","initial","none",R]}],grow:[{grow:["",U,$,R]}],shrink:[{shrink:["",U,$,R]}],order:[{order:[_e,"first","last","none",$,R]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:V()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:V()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":X()}],"auto-rows":[{"auto-rows":X()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...G(),"normal"]}],"justify-self":[{"justify-self":["auto",...G()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...G(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...G(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...G(),"baseline"]}],"place-self":[{"place-self":["auto",...G()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:K()}],mx:[{mx:K()}],my:[{my:K()}],ms:[{ms:K()}],me:[{me:K()}],mt:[{mt:K()}],mr:[{mr:K()}],mb:[{mb:K()}],ml:[{ml:K()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],w:[{w:[a,"screen",...Z()]}],"min-w":[{"min-w":[a,"screen","none",...Z()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",e,Or,Fe]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,$,Ai]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Pi,R]}],"font-family":[{font:[dh,R,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,$,R]}],"line-clamp":[{"line-clamp":[U,"none",$,Ai]}],leading:[{leading:[n,..._()]}],"list-image":[{"list-image":["none",$,R]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",$,R]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:[U,"from-font","auto",$,Fe]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[U,"auto",$,R]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$,R]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",$,R]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:wt()}],"bg-repeat":[{bg:mt()}],"bg-size":[{bg:lt()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},_e,$,R],radial:["",$,R],conic:[_e,$,R]},fh,uh]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:k()}],"gradient-via-pos":[{via:k()}],"gradient-to-pos":[{to:k()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...B(),"hidden","none"]}],"divide-style":[{divide:[...B(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...B(),"none","hidden"]}],"outline-offset":[{"outline-offset":[U,$,R]}],"outline-w":[{outline:["",U,Or,Fe]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",h,bs,ys]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",u,bs,ys]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[U,Fe]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",d,bs,ys]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[U,$,R]}],"mix-blend":[{"mix-blend":[...I(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":I()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[U]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[$,R]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[U]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:wt()}],"mask-repeat":[{mask:mt()}],"mask-size":[{mask:lt()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",$,R]}],filter:[{filter:["","none",$,R]}],blur:[{blur:dt()}],brightness:[{brightness:[U,$,R]}],contrast:[{contrast:[U,$,R]}],"drop-shadow":[{"drop-shadow":["","none",g,bs,ys]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",U,$,R]}],"hue-rotate":[{"hue-rotate":[U,$,R]}],invert:[{invert:["",U,$,R]}],saturate:[{saturate:[U,$,R]}],sepia:[{sepia:["",U,$,R]}],"backdrop-filter":[{"backdrop-filter":["","none",$,R]}],"backdrop-blur":[{"backdrop-blur":dt()}],"backdrop-brightness":[{"backdrop-brightness":[U,$,R]}],"backdrop-contrast":[{"backdrop-contrast":[U,$,R]}],"backdrop-grayscale":[{"backdrop-grayscale":["",U,$,R]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[U,$,R]}],"backdrop-invert":[{"backdrop-invert":["",U,$,R]}],"backdrop-opacity":[{"backdrop-opacity":[U,$,R]}],"backdrop-saturate":[{"backdrop-saturate":[U,$,R]}],"backdrop-sepia":[{"backdrop-sepia":["",U,$,R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",$,R]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[U,"initial",$,R]}],ease:[{ease:["linear","initial",b,$,R]}],delay:[{delay:[U,$,R]}],animate:[{animate:["none",w,$,R]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,$,R]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:ht()}],"rotate-x":[{"rotate-x":ht()}],"rotate-y":[{"rotate-y":ht()}],"rotate-z":[{"rotate-z":ht()}],scale:[{scale:it()}],"scale-x":[{"scale-x":it()}],"scale-y":[{"scale-y":it()}],"scale-z":[{"scale-z":it()}],"scale-3d":["scale-3d"],skew:[{skew:kt()}],"skew-x":[{"skew-x":kt()}],"skew-y":[{"skew-y":kt()}],transform:[{transform:[$,R,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:F()}],"translate-x":[{"translate-x":F()}],"translate-y":[{"translate-y":F()}],"translate-z":[{"translate-z":F()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",$,R]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",$,R]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[U,Or,Fe,Ai]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Bt(...i){return vh(ko(i))}const yh=["dark","theme-dark","dark-mode","dark-theme","wp-dark-mode-active","flavor-dark","is-dark","night","night-mode"],bh=["light","theme-light","light-mode","light-theme","wp-dark-mode-disabled","is-light"],Wo=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme","data-wp-dark-mode-active","data-dark-mode"],Li=["class","style","color-scheme",...Wo];function wh(i){const t=i.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:Number(t[1]),g:Number(t[2]),b:Number(t[3])}:null}function xh(i,t,e){const[r,s,n]=[i/255,t/255,e/255].map(o=>o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4));return .2126*r+.7152*s+.0722*n}function _h(){var t;const i=document.querySelector("script[data-api-key][data-bugpin-theme]");if(i){const e=(t=i.getAttribute("data-bugpin-theme"))==null?void 0:t.toLowerCase();if(e==="dark")return"dark";if(e==="light")return"light"}return null}function Ch(){var e,r,s;const i=document.documentElement,t=document.body;for(const n of[i,t])if(n){for(const o of yh)if(n.classList.contains(o))return"dark";for(const o of bh)if(n.classList.contains(o))return"light"}for(const n of Wo)for(const o of[i,t]){if(!o)continue;const a=(e=o.getAttribute(n))==null?void 0:e.toLowerCase();if(a){if(a==="dark"||a==="true")return"dark";if(a==="light"||a==="false")return"light"}}for(const n of[i,t]){if(!n)continue;const o=(r=n.getAttribute("color-scheme"))==null?void 0:r.toLowerCase();if(o!=null&&o.includes("dark"))return"dark";if(o!=null&&o.includes("light"))return"light"}if(typeof getComputedStyle<"u"){const o=(s=getComputedStyle(i).colorScheme)==null?void 0:s.toLowerCase();if(o){if(o==="dark"||o.startsWith("dark "))return"dark";if(o==="light"||o.startsWith("light "))return"light"}}return null}function Sh(){if(typeof getComputedStyle>"u")return null;const i=document.body;if(!i)return null;const t=getComputedStyle(i).backgroundColor;if(!t||t==="rgba(0, 0, 0, 0)"||t==="transparent")return null;const e=wh(t);if(!e)return null;const r=xh(e.r,e.g,e.b);return r<.4?"dark":r>.6?"light":null}function kh(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Xo(){return _h()??Ch()??Sh()??kh()}function Yo(i){const[t,e]=at(()=>i!=="auto"?i:Xo());return Ht(()=>{if(i!=="auto"){e(i);return}const r=()=>e(Xo());r();let s=null;if(typeof MutationObserver<"u")if(s=new MutationObserver(r),s.observe(document.documentElement,{attributes:!0,attributeFilter:Li}),document.body)s.observe(document.body,{attributes:!0,attributeFilter:Li});else{const o=new MutationObserver(()=>{document.body&&(o.disconnect(),s==null||s.observe(document.body,{attributes:!0,attributeFilter:Li}),r())});o.observe(document.documentElement,{childList:!0})}let n=null;return typeof window<"u"&&typeof window.matchMedia=="function"&&(n=window.matchMedia("(prefers-color-scheme: dark)"),n.addEventListener("change",r)),()=>{s==null||s.disconnect(),n==null||n.removeEventListener("change",r)}},[i]),t}const Th={"bottom-right":"bottom-5 right-5","bottom-left":"bottom-5 left-5","top-right":"top-5 right-5","top-left":"top-5 left-5"},Oh=({position:i,buttonText:t,buttonShape:e,buttonIcon:r,buttonIconSize:s,buttonIconStroke:n,theme:o,lightButtonColor:a,lightTextColor:l,lightButtonHoverColor:c,lightTextHoverColor:h,darkButtonColor:u,darkTextColor:d,darkButtonHoverColor:g,darkTextHoverColor:f,enableHoverScaleEffect:m,tooltipEnabled:y,tooltipText:b,onClick:w})=>{const[T,C]=at(!1),[S,D]=at({left:"50%",transform:"translateX(-50%)",arrowLeft:"50%"}),A=It(null),_=It(null),O=Yo(o)==="dark";Ht(()=>{if(T&&A.current&&_.current){const L=A.current,wt=_.current;requestAnimationFrame(()=>{const mt=L.getBoundingClientRect(),lt=wt.getBoundingClientRect(),k=window.innerWidth,P=4,E=lt.left+lt.width/2,B=mt.width/2;let I=0;const H=E-B;H<P?I=P-H:H+mt.width>k-P&&(I=k-P-(H+mt.width)),D({left:"50%",transform:`translateX(-50%) translateX(${I}px)`,arrowLeft:"50%"})})}},[T,b]);const V=O?T?g:u:T?c:a,z=O?T?f:d:T?h:l,X=O?u:a,W=O?d:l,G=e==="round"?"50%":"8px",K=t||"Report Bug",Z=e==="round"?`${s/2}px`:"12px 20px";return p("div",{class:Bt("fixed z-[2147483647]",Th[i]),children:[p("button",{ref:_,class:Bt("relative flex items-center justify-center gap-2 border-none text-sm font-medium cursor-pointer shadow-lg transition-all duration-200",m&&"hover:scale-110 hover:shadow-xl active:scale-105"),style:{backgroundColor:V,color:z,borderRadius:G,padding:Z},onClick:w,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),"aria-label":K,children:[r&&p(Ec,{name:r,size:s,strokeWidth:n}),t&&p("span",{children:t})]}),y&&b&&T&&p("div",{ref:A,class:"absolute bottom-full mb-2 px-3 py-1.5 text-xs rounded whitespace-nowrap pointer-events-none z-[2147483647] animate-[bugpin-tooltip-fade-in_0.2s_ease-in-out_forwards] shadow-md",style:{backgroundColor:X,color:W,opacity:0,left:S.left,transform:S.transform},children:[b,p("div",{class:"absolute top-full border-4 border-solid border-transparent",style:{left:S.arrowLeft,transform:"translateX(-50%)",marginTop:"-4px",borderTopColor:X}})]})]})},Uo=i=>typeof i=="boolean"?`${i}`:i===0?"0":i,Go=ko,Dh=((i,t)=>e=>{var r;if((t==null?void 0:t.variants)==null)return Go(i,e==null?void 0:e.class,e==null?void 0:e.className);const{variants:s,defaultVariants:n}=t,o=Object.keys(s).map(c=>{const h=e==null?void 0:e[c],u=n==null?void 0:n[c];if(h===null)return null;const d=Uo(h)||Uo(u);return s[c][d]}),a=e&&Object.entries(e).reduce((c,h)=>{let[u,d]=h;return d===void 0||(c[u]=d),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,h)=>{let{class:u,className:d,...g}=h;return Object.entries(g).every(f=>{let[m,y]=f;return Array.isArray(y)?y.includes({...n,...a}[m]):{...n,...a}[m]===y})?[...c,u,d]:c},[]);return Go(i,o,l,e==null?void 0:e.class,e==null?void 0:e.className)})("inline-flex items-center justify-center gap-2 font-medium font-sans cursor-pointer transition-colors border-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary-hover hover:text-primary-hover-foreground",outline:"border border-solid border-input bg-background text-foreground hover:bg-muted",ghost:"bg-transparent hover:bg-muted text-foreground",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90"},size:{default:"h-10 px-4 text-sm rounded-sm",sm:"h-8 px-3 text-xs rounded-sm",lg:"h-12 px-6 text-base rounded",icon:"h-8 w-8 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),ee=({class:i,variant:t,size:e,children:r,type:s="button",...n})=>p("button",{type:s,class:Bt(Dh({variant:t,size:e}),i),...n,children:r}),Fi=({class:i,error:t,type:e="text",...r})=>p("input",{type:e,class:Bt("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-[var(--input-background,transparent)] transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...r}),Mh=({class:i,error:t,...e})=>p("textarea",{class:Bt("min-h-20 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-[var(--input-background,transparent)] resize-y transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...e}),Eh=({class:i,error:t,children:e,...r})=>p("select",{class:Bt("h-10 w-full px-3 py-2 border border-solid border-input rounded-sm text-sm font-sans text-foreground bg-[var(--input-background,transparent)] cursor-pointer transition-colors","focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",t&&"border-destructive focus:border-destructive focus:ring-destructive/20",i),"aria-invalid":t?"true":void 0,...r,children:e}),Dr=({class:i,required:t,children:e,for:r,...s})=>p("label",{for:r,class:Bt("text-sm font-medium text-foreground",i),...s,children:[e,t&&p("span",{class:"text-destructive ml-0.5",children:"*"})]}),Ph=({tabs:i,activeTab:t,onTabChange:e})=>p("div",{class:"inline-flex p-1 bg-muted rounded gap-1",role:"tablist","aria-orientation":"horizontal",children:i.map(r=>{const s=r.id===t;return p("button",{type:"button",role:"tab",id:`tab-${r.id}`,"aria-selected":s,"aria-controls":`tabpanel-${r.id}`,tabIndex:s?0:-1,class:Bt("flex items-center gap-2 px-3 py-1.5 border-none rounded-md bg-transparent text-muted-foreground text-sm font-medium font-sans cursor-pointer transition-colors","hover:text-foreground",s&&"bg-background text-foreground shadow-sm"),onClick:()=>e(r.id),children:[r.icon&&p("span",{class:"flex items-center justify-center [&_svg]:w-4 [&_svg]:h-4",children:r.icon}),r.label]},r.id)})}),Ah={success:"bg-green-50 border-green-200 text-green-600",error:"bg-red-50 border-red-200 text-red-600",info:"bg-blue-50 border-blue-200 text-blue-600"},Lh=({message:i,type:t,onClose:e,duration:r=5e3})=>(Ht(()=>{const s=setTimeout(e,r);return()=>clearTimeout(s)},[e,r]),p("div",{class:Bt("fixed bottom-20 right-5 z-[2147483647] flex items-center gap-3 px-5 py-4 border border-solid rounded text-sm shadow-lg animate-[slideIn_0.3s_ease-out]",Ah[t]),role:"alert","aria-live":"polite",children:[t==="success"&&p("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",fill:"currentColor"})}),t==="error"&&p("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),t==="info"&&p("svg",{class:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z",fill:"currentColor"})}),p("span",{children:i})]})),Fh=10*1024*1024,jh=50*1024*1024,Ih=["image/png","image/jpeg","image/gif","image/webp"],Bh=["video/mp4","video/webm","video/quicktime","video/x-msvideo"],Rh=({media:i,onCapture:t,onUpload:e,onRemove:r,onAnnotate:s,isCapturing:n,enableAnnotation:o,maxImageSize:a=Fh,maxVideoSize:l=jh})=>{const[c,h]=at(!1),[u,d]=at(null),g=It(null),f=O=>O.startsWith("video/"),m=O=>O.startsWith("image/"),y=Math.round(a/(1024*1024)),b=Math.round(l/(1024*1024)),w=N(O=>{if(m(O.type)){if(!Ih.includes(O.type))return`Unsupported image format: ${O.type}`;if(O.size>a)return`Image too large. Maximum size is ${y}MB.`}else if(f(O.type)){if(!Bh.includes(O.type))return`Unsupported video format: ${O.type}`;if(O.size>l)return`Video too large. Maximum size is ${b}MB.`}else return`Unsupported file type: ${O.type}`;return null},[a,y,l,b]),T=N(async O=>{const V=w(O);if(V){d(V);return}d(null);const z=new FileReader;z.onload=()=>{const X=z.result;if(m(O.type)){const W=new Image;W.onload=()=>{const G={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:X,timestamp:new Date,annotated:!1,mimeType:O.type,width:W.width,height:W.height};e(G)},W.src=X}else if(f(O.type)){const W=document.createElement("video");W.onloadedmetadata=()=>{const G={id:`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:X,timestamp:new Date,annotated:!1,mimeType:O.type,width:W.videoWidth,height:W.videoHeight};e(G)},W.src=X}},z.readAsDataURL(O)},[w,e]),C=N(O=>{O.preventDefault(),O.stopPropagation(),h(!0)},[]),S=N(O=>{O.preventDefault(),O.stopPropagation(),h(!1)},[]),D=N(async O=>{var z;O.preventDefault(),O.stopPropagation(),h(!1);const V=(z=O.dataTransfer)==null?void 0:z.files;if(V)for(let X=0;X<V.length;X++)await T(V[X])},[T]),A=N(async O=>{const V=O.target,z=V.files;if(z)for(let X=0;X<z.length;X++)await T(z[X]);V.value=""},[T]),_=N(()=>{var O;(O=g.current)==null||O.click()},[]),M=O=>O.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return p("div",{class:"flex flex-col gap-4",children:[p("p",{class:"text-xs text-muted-foreground",children:"Tip: Use the annotation tool to hide any sensitive data before submitting."}),p("div",{class:"flex gap-2",children:[p(ee,{class:"flex-1",onClick:t,disabled:n,children:[p("svg",{class:"w-4.5 h-4.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 15.2c1.77 0 3.2-1.43 3.2-3.2S13.77 8.8 12 8.8 8.8 10.23 8.8 12s1.43 3.2 3.2 3.2zM9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",fill:"currentColor"})}),n?"Capturing...":"Capture Screenshot"]}),p("input",{ref:g,type:"file",accept:"image/*,video/*",multiple:!0,style:{display:"none"},onChange:A})]}),u&&p("div",{class:"flex items-center gap-2 px-3 py-2.5 bg-red-50 dark:bg-red-950/50 border border-solid border-red-200 dark:border-red-800 rounded text-red-600 dark:text-red-400 text-sm",children:[p("svg",{class:"w-4.5 h-4.5 flex-shrink-0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",fill:"currentColor"})}),u]}),p("div",{class:Bt("min-h-40 border-2 border-dashed border-border rounded bg-muted transition-colors",c&&"border-primary bg-primary/5",i.length>0&&"border-solid bg-background min-h-0"),onDragOver:C,onDragLeave:S,onDrop:D,children:i.length===0?p("div",{class:"flex flex-col items-center justify-center py-8 px-4 text-muted-foreground text-center cursor-pointer transition-colors hover:text-primary [&_svg]:hover:text-primary",onClick:_,children:[p("svg",{class:"w-12 h-12 mb-3 text-muted-foreground transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z",fill:"currentColor"})}),p("p",{class:"text-sm font-medium mb-1",children:"Drag and drop files here"}),p("span",{class:"text-xs text-muted-foreground",children:"or click to browse"})]}):p("div",{class:"grid grid-cols-2 gap-3 p-3",children:[i.map(O=>p("div",{class:"relative rounded overflow-hidden bg-background border border-solid border-border",children:[p("div",{class:"relative aspect-video bg-gray-800",children:[f(O.mimeType)?p("video",{class:"w-full h-full object-contain",src:O.dataUrl,muted:!0}):p("img",{class:"w-full h-full object-contain",src:O.dataUrl,alt:"Screenshot"}),p("div",{class:"absolute top-1.5 left-1.5 flex gap-1",children:[O.annotated&&p("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-blue-100 dark:bg-blue-900/70 text-blue-700 dark:text-blue-300",children:"Annotated"}),f(O.mimeType)&&p("span",{class:"px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Video"})]})]}),p("div",{class:"flex justify-between px-2 py-1.5 text-xs text-muted-foreground border-t border-solid border-border",children:[p("span",{children:M(O.timestamp)}),O.width&&O.height&&p("span",{children:[O.width," x ",O.height]})]}),p("div",{class:"flex gap-1 px-2 py-1.5 border-t border-solid border-border bg-muted",children:[o&&m(O.mimeType)&&p(ee,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-background hover:bg-muted text-foreground",onClick:()=>s(O.id),title:"Annotate",children:p("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",fill:"currentColor"})})}),p(ee,{variant:"ghost",size:"icon",class:"w-7 h-7 bg-background hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950 text-foreground",onClick:()=>r(O.id),title:"Remove",children:p("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]})]},O.id)),p("div",{class:"flex flex-col items-center justify-center gap-2 min-h-28 border-2 border-dashed border-border rounded bg-muted cursor-pointer transition-colors hover:border-primary hover:bg-primary/5 [&_svg]:hover:text-primary [&_span]:hover:text-primary",onClick:_,children:[p("svg",{class:"w-8 h-8 text-muted-foreground transition-colors",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",fill:"currentColor"})}),p("span",{class:"text-xs text-muted-foreground transition-colors",children:"Add more"})]})]})}),p("p",{class:"text-xs text-muted-foreground text-center",children:["Supported: PNG, JPG, GIF, WebP (max ",y,"MB) - MP4, WebM, MOV, AVI (max ",b,"MB)"]})]})},$h="bugpin-skip-screen-capture-consent",zh=({onConfirm:i,onCancel:t})=>{const[e,r]=at(!1);return p("div",{class:"flex-1 flex flex-col items-center justify-center p-6 gap-5 text-center",children:[p("div",{class:"space-y-2 max-w-sm",children:[p("h1",{children:"Browser permission required"}),p("p",{class:"text-sm text-muted-foreground",children:"Your browser will ask for permission to share your screen. Follow the steps shown."})]}),p("div",{class:"grid grid-cols-2 pb-4 gap-3 w-full max-w-xl",children:[p("div",{class:"flex flex-col items-center gap-1.5",children:[p("div",{class:"w-full rounded-lg overflow-hidden border border-solid border-border shadow-sm",children:p("svg",{viewBox:"0 0 200 148",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[p("defs",{children:p("filter",{id:"ff-shadow",x:"-4%",y:"-4%",width:"108%",height:"108%",children:p("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2","flood-opacity":"0.08"})})}),p("rect",{width:"200",height:"180",rx:"10",fill:"#ffffff",filter:"url(#ff-shadow)"}),p("text",{x:"16",y:"24","font-family":"system-ui, -apple-system, sans-serif","font-size":"10","font-weight":"700",fill:"#111",children:"Allow this site to see your screen?"}),p("rect",{x:"14",y:"42",width:"172",height:"26",rx:"6",fill:"#f5f5f5",stroke:"#ddd","stroke-width":"1"}),p("rect",{x:"23",y:"50",width:"11",height:"10",rx:"2",fill:"#d0d0d0"}),p("rect",{x:"25",y:"48",width:"3",height:"3",rx:"1",fill:"#bbb"}),p("rect",{x:"30",y:"48",width:"3",height:"3",rx:"1",fill:"#bbb"}),p("text",{x:"42",y:"55","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"9",fill:"#444",children:"Use operating system settings"}),p("rect",{x:"16",y:"74",width:"11",height:"11",rx:"3",fill:"white",stroke:"#c8c8c8","stroke-width":"1.2"}),p("text",{x:"34",y:"79.5","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#777",children:"Mute website notifications while sharing"}),p("line",{x1:"0",y1:"112",x2:"200",y2:"112",stroke:"#eaeaea","stroke-width":"1"}),p("rect",{x:"82",y:"119",width:"50",height:"22",rx:"6",fill:"white",stroke:"#ddd","stroke-width":"1"}),p("text",{x:"107",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#444","text-anchor":"middle",children:"Block"}),p("rect",{x:"136",y:"117",width:"56",height:"26",rx:"13",fill:"#aaa",opacity:"0.45"}),p("rect",{x:"138",y:"119",width:"52",height:"22",rx:"11",fill:"#9ca3af"}),p("text",{x:"164",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"white","font-weight":"600","text-anchor":"middle",children:"Allow"})]})}),p("p",{class:"text-xs font-medium text-muted-foreground",children:"Firefox"})]}),p("div",{class:"flex flex-col items-center gap-1.5",children:[p("div",{class:"w-full rounded-lg overflow-hidden border border-solid border-border shadow-sm",children:p("svg",{viewBox:"0 0 200 148",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[p("defs",{children:[p("filter",{id:"ce-shadow",x:"-4%",y:"-4%",width:"108%",height:"108%",children:p("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2","flood-opacity":"0.08"})}),p("clipPath",{id:"tab-preview-clip",children:p("rect",{x:"14",y:"48",width:"172",height:"56",rx:"6"})})]}),p("rect",{width:"200",height:"180",rx:"10",fill:"#ffffff",filter:"url(#ce-shadow)"}),p("text",{x:"16",y:"24","font-family":"system-ui, -apple-system, sans-serif","font-size":"10","font-weight":"700",fill:"#111",children:"Allow this site to see this tab?"}),p("text",{x:"16",y:"43","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#777",children:"The site will see this tab's contents."}),p("rect",{x:"14",y:"48",width:"172",height:"56",rx:"6",fill:"white",stroke:"#d4d4d8","stroke-width":"1"}),p("g",{"clip-path":"url(#tab-preview-clip)",children:[p("rect",{x:"14",y:"48",width:"172",height:"13",fill:"#ececec"}),p("circle",{cx:"26",cy:"54",r:"4",fill:"#ccc"}),p("rect",{x:"38",y:"51",width:"100",height:"7",rx:"3.5",fill:"#ddd"}),p("rect",{x:"22",y:"67",width:"72",height:"5",rx:"2.5",fill:"#ddd"}),p("rect",{x:"22",y:"76",width:"140",height:"3.5",rx:"1.75",fill:"#e8e8e8"}),p("rect",{x:"22",y:"83",width:"120",height:"3.5",rx:"1.75",fill:"#e8e8e8"}),p("rect",{x:"22",y:"89",width:"130",height:"3.5",rx:"1.75",fill:"#e8e8e8"}),p("rect",{x:"22",y:"95",width:"100",height:"3.5",rx:"1.75",fill:"#e8e8e8"})]}),p("line",{x1:"0",y1:"112",x2:"200",y2:"112",stroke:"#eaeaea","stroke-width":"1"}),p("rect",{x:"86",y:"119",width:"48",height:"22",rx:"11",fill:"white",stroke:"#ddd","stroke-width":"1"}),p("text",{x:"110",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"#444","text-anchor":"middle",children:"Cancel"}),p("rect",{x:"137",y:"117",width:"56",height:"26",rx:"13",fill:"#aaa",opacity:"0.45"}),p("rect",{x:"139",y:"119",width:"52",height:"22",rx:"11",fill:"#9ca3af"}),p("text",{x:"165",y:"130","dominant-baseline":"central","font-family":"system-ui, -apple-system, sans-serif","font-size":"8",fill:"white","font-weight":"600","text-anchor":"middle",children:"Allow"})]})}),p("p",{class:"text-xs font-medium text-muted-foreground",children:"Chrome · Edge"})]})]}),p("label",{class:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[p("input",{type:"checkbox",checked:e,onChange:n=>r(n.target.checked),class:"w-3.5 h-3.5 accent-primary cursor-pointer"}),"Don't show this again"]}),p("div",{class:"flex gap-3 w-full max-w-xs",children:[p(ee,{variant:"outline",class:"flex-1",onClick:t,children:"Back"}),p(ee,{class:"flex-1",onClick:()=>{e&&localStorage.setItem($h,"true"),i()},children:"Take Screenshot"})]})]})},Hh=[{id:"details",label:"Details",icon:p("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",fill:"currentColor"})})},{id:"media",label:"Screenshots",icon:p("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",fill:"currentColor"})})}],Vh=({onClose:i,onSubmit:t,onCaptureScreenshot:e,onAnnotateMedia:r,media:s,onAddMedia:n,onRemoveMedia:o,isSubmitting:a,isCapturing:l,enableAnnotation:c,activeTab:h,onActiveTabChange:u,formData:d,onFormDataChange:g,showScreenCaptureConsent:f,onConsentConfirm:m,onConsentCancel:y,maxImageSize:b,maxVideoSize:w})=>{const[T,C]=at({}),S=N((M,O)=>{g({...d,[M]:O}),T[M]&&C(V=>({...V,[M]:void 0}))},[d,g,T]),D=N(()=>{const M={};return d.title.trim()?d.title.trim().length<4&&(M.title="Title must be at least 4 characters"):M.title="Title is required",d.reporterEmail&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.reporterEmail)&&(M.reporterEmail="Invalid email address"),C(M),Object.keys(M).length===0},[d]),A=N(M=>{if(M.preventDefault(),!D()){u("details");return}t(d,s)},[d,s,D,t,u]),_=s.length;return p("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:p("div",{class:"relative w-full max-w-3xl max-h-[90vh] bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-title",children:[p("div",{class:"flex items-center justify-between p-6 border-b border-solid border-border",children:[p("h1",{id:"bugpin-title",children:"Report a Bug"}),p(ee,{variant:"ghost",size:"icon",onClick:i,"aria-label":"Close",children:p("svg",{class:"w-5 h-5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:p("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",fill:"currentColor"})})})]}),f?p(zh,{onConfirm:m,onCancel:y}):p(Sr,{children:[p("div",{class:"p-4 pb-0 bg-transparent",children:p(Ph,{tabs:Hh.map(M=>({...M,label:M.id==="media"&&_>0?`${M.label} (${_})`:M.label})),activeTab:h,onTabChange:u})}),p("div",{class:"flex-1 overflow-y-auto p-6",children:[h==="details"&&p("form",{class:"flex flex-col gap-4",onSubmit:A,children:[p("div",{class:"flex flex-col gap-1.5",children:[p(Dr,{for:"bugpin-title-input",required:!0,children:"Title"}),p(Fi,{id:"bugpin-title-input",type:"text",placeholder:"Brief description of the issue",value:d.title,onInput:M=>S("title",M.target.value),maxLength:200,error:!!T.title,"aria-describedby":T.title?"bugpin-title-error":void 0}),T.title&&p("span",{id:"bugpin-title-error",class:"text-destructive text-xs mt-0.5",children:T.title})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Dr,{for:"bugpin-description",children:"Description"}),p(Mh,{id:"bugpin-description",placeholder:"Steps to reproduce, expected behavior, etc.",value:d.description,onInput:M=>S("description",M.target.value)})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Dr,{for:"bugpin-priority",children:"Priority"}),p(Eh,{id:"bugpin-priority",value:d.priority,onChange:M=>S("priority",M.target.value),children:[p("option",{value:"highest",children:"Highest"}),p("option",{value:"high",children:"High"}),p("option",{value:"medium",children:"Medium"}),p("option",{value:"low",children:"Low"}),p("option",{value:"lowest",children:"Lowest"})]})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Dr,{for:"bugpin-name",children:"Name (optional)"}),p(Fi,{id:"bugpin-name",type:"text",placeholder:"Your name",value:d.reporterName,onInput:M=>S("reporterName",M.target.value)})]}),p("div",{class:"flex flex-col gap-1.5",children:[p(Dr,{for:"bugpin-email",children:"Email (optional)"}),p(Fi,{id:"bugpin-email",type:"email",placeholder:"your@email.com",value:d.reporterEmail,onInput:M=>S("reporterEmail",M.target.value),error:!!T.reporterEmail,"aria-describedby":T.reporterEmail?"bugpin-email-error":void 0}),T.reporterEmail&&p("span",{id:"bugpin-email-error",class:"text-destructive text-xs mt-0.5",children:T.reporterEmail})]})]}),h==="media"&&p(Rh,{media:s,onCapture:e,onUpload:n,onRemove:o,onAnnotate:r,isCapturing:l,enableAnnotation:c,maxImageSize:b,maxVideoSize:w})]}),p("div",{class:"flex gap-3 p-6 border-t border-solid border-border bg-muted",children:[p(ee,{variant:"outline",class:"flex-1",onClick:i,disabled:a,children:"Cancel"}),p(ee,{class:"flex-1",onClick:A,disabled:a,children:a?p("span",{class:"w-4 h-4 border-2 border-solid border-white/30 border-t-white rounded-full animate-[spin_0.8s_linear_infinite]"}):"Submit Report"})]})]}),p("div",{class:"py-3 px-6 text-center text-xs text-muted-foreground border-t border-solid border-border bg-background",children:["Powered by"," ",p("a",{href:"https://bugpin.io",target:"_blank",rel:"noopener noreferrer",class:"text-primary no-underline font-medium hover:underline hover:text-primary-hover",children:"BugPin"})]})]})})};function v(i,t,e){return(t=function(r){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)}(r,"string");return typeof s=="symbol"?s:s+""}(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class No{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 tt=new class extends No{constructor(i){super(),this.configure(i)}configure(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,i)}addFonts(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths={...this.fontPaths,...i}}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(i=>{delete this.fontPaths[i]})}clearFonts(){this.fontPaths={}}restoreDefaults(i){const t=new No,e=(i==null?void 0:i.reduce((r,s)=>(r[s]=t[s],r),{}))||t;this.configure(e)}},Ce=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return console[i]("fabric",...e)};class re extends Error{constructor(t,e){super(`fabric: ${t}`,e)}}class Wh extends re{constructor(t){super(`${t} 'options.signal' is in 'aborted' state`)}}class Xh{}class Yh extends Xh{testPrecision(t,e){const r=`precision ${e} float;
37
+ void main(){}`,s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,r),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(r=>this.testPrecision(e,r)),e.getExtension("WEBGL_lose_context").loseContext(),Ce("log",`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Uh={};let qo;const se=()=>qo||(qo={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Yh,dispose(){},copyPasteData:Uh}),Ke=()=>se().document,ws=()=>se().window,Ko=()=>{var i;return Math.max((i=tt.devicePixelRatio)!==null&&i!==void 0?i:ws().devicePixelRatio,1)},Mr=new class{constructor(){v(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(i){let{fontFamily:t,fontStyle:e,fontWeight:r}=i;t=t.toLowerCase();const s=this.charWidthsCache;s.has(t)||s.set(t,new Map);const n=s.get(t),o=`${e.toLowerCase()}_${(r+"").toLowerCase()}`;return n.has(o)||n.set(o,new Map),n.get(o)}clearFontCache(i){i?this.charWidthsCache.delete((i||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(i){const{perfLimitSizeTotal:t}=tt,e=Math.sqrt(t*i);return[Math.floor(e),Math.floor(t/e)]}},ji="7.2.0";function xs(){}const Er=Math.PI/2,Gh=Math.PI/4,Ze=2*Math.PI,Ii=Math.PI/180,Tt=Object.freeze([1,0,0,1,0,0]),Bi=16,Se=.4477152502,Y="center",Q="left",Et="top",Ri="bottom",ft="right",Pt="none",$i=/\r?\n/,Zo="moving",_s="scaling",Jo="rotating",zi="rotate",Qo="skewing",Pr="resizing",Nh="modifyPoly",qh="modifyPath",Cs="changed",Ss="scale",At="scaleX",Vt="scaleY",Je="skewX",Qe="skewY",_t="fill",Rt="stroke",ks="modified",je="ltr",ue="rtl",Hi="normal",tr="json",Vi="svg",j=new class{constructor(){this[tr]=new Map,this[Vi]=new Map}has(i){return this[tr].has(i)}getClass(i){const t=this[tr].get(i);if(!t)throw new re(`No class registered for ${i}`);return t}setClass(i,t){t?this[tr].set(t,i):(this[tr].set(i.type,i),this[tr].set(i.type.toLowerCase(),i))}getSVGClass(i){return this[Vi].get(i)}setSVGClass(i,t){this[Vi].set(t??i.type.toLowerCase(),i)}},Ts=new class extends Array{remove(i){const t=this.indexOf(i);t>-1&&this.splice(t,1)}cancelAll(){const i=this.splice(0);return i.forEach(t=>t.abort()),i}cancelByCanvas(i){if(!i)return[];const t=this.filter(e=>{var r;return e.target===i||typeof e.target=="object"&&((r=e.target)===null||r===void 0?void 0:r.canvas)===i});return t.forEach(e=>e.abort()),t}cancelByTarget(i){if(!i)return[];const t=this.filter(e=>e.target===i);return t.forEach(e=>e.abort()),t}};class Kh{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(r=>{let[s,n]=r;this.on(s,n)}),()=>this.off(t);if(e){const r=t;return this.__eventListeners[r]||(this.__eventListeners[r]=[]),this.__eventListeners[r].push(e),()=>this.off(r,e)}return()=>!1}once(t,e){if(typeof t=="object"){const r=[];return Object.entries(t).forEach(s=>{let[n,o]=s;r.push(this.once(n,o))}),()=>r.forEach(s=>s())}if(e){const r=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),r()});return r}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const r=this.__eventListeners[t],s=r.indexOf(e);s>-1&&r.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const r in this.__eventListeners)this._removeEventListener(r);else typeof t=="object"?Object.entries(t).forEach(r=>{let[s,n]=r;this._removeEventListener(s,n)}):this._removeEventListener(t,e)}fire(t,e){var r;if(!this.__eventListeners)return;const s=(r=this.__eventListeners[t])===null||r===void 0?void 0:r.concat();if(s)for(let n=0;n<s.length;n++)s[n].call(this,e||{})}}const er=(i,t)=>{const e=i.indexOf(t);return e!==-1&&i.splice(e,1),i},de=i=>{if(i===0)return 1;switch(Math.abs(i)/Er){case 1:case 3:return 0;case 2:return-1}return Math.cos(i)},ge=i=>{if(i===0)return 0;const t=i/Er,e=Math.sign(i);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(i)};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,r=this.y-t.y;return Math.sqrt(e*e+r*r)}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`${this.x},${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,r=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=r}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Wi;const r=ge(t),s=de(t),n=this.subtract(e);return new x(n.x*s-n.y*r,n.x*r+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 Wi=new x(0,0),Os=i=>!!i&&Array.isArray(i._objects);function ta(i){class t extends i{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(r){}_onObjectRemoved(r){}_onStackOrderChanged(r){}add(){for(var r=arguments.length,s=new Array(r),n=0;n<r;n++)s[n]=arguments[n];const o=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),o}insertAt(r){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(r,0,...n),n.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const r=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=r.indexOf(l);c!==-1&&(r.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(r){this.getObjects().forEach((s,n,o)=>r(s,n,o))}getObjects(){for(var r=arguments.length,s=new Array(r),n=0;n<r;n++)s[n]=arguments[n];return s.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...s))}item(r){return this._objects[r]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(r,s){return!!this._objects.includes(r)||!!s&&this._objects.some(n=>n instanceof t&&n.contains(r,!0))}complexity(){return this._objects.reduce((r,s)=>r+=s.complexity?s.complexity():0,0)}sendObjectToBack(r){return!(!r||r===this._objects[0])&&(er(this._objects,r),this._objects.unshift(r),this._onStackOrderChanged(r),!0)}bringObjectToFront(r){return!(!r||r===this._objects[this._objects.length-1])&&(er(this._objects,r),this._objects.push(r),this._onStackOrderChanged(r),!0)}sendObjectBackwards(r,s){if(!r)return!1;const n=this._objects.indexOf(r);if(n!==0){const o=this.findNewLowerIndex(r,n,s);return er(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}bringObjectForward(r,s){if(!r)return!1;const n=this._objects.indexOf(r);if(n!==this._objects.length-1){const o=this.findNewUpperIndex(r,n,s);return er(this._objects,r),this._objects.splice(o,0,r),this._onStackOrderChanged(r),!0}return!1}moveObjectTo(r,s){return r!==this._objects[s]&&(er(this._objects,r),this._objects.splice(s,0,r),this._onStackOrderChanged(r),!0)}findNewLowerIndex(r,s,n){let o;if(n){o=s;for(let a=s-1;a>=0;--a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(r,s,n){let o;if(n){o=s;for(let a=s+1;a<this._objects.length;++a)if(r.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(r){let{left:s,top:n,width:o,height:a}=r,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(s,n),u=h.add(new x(o,a));for(let d=this._objects.length-1;d>=0;d--){const g=this._objects[d];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,u)||g.isContainedWithinRect(h,u)||l&&g.containsPoint(h)||l&&g.containsPoint(u))&&c.push(g)}return c}}return t}class ea extends Kh{_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 Ds(i){return ws().requestAnimationFrame(i)}function Zh(i){return ws().cancelAnimationFrame(i)}let Jh=0;const ke=()=>Jh++,fe=()=>{const i=Ke().createElement("canvas");if(!i||i.getContext===void 0)throw new re("Failed to create `canvas` element");return i},Qh=()=>Ke().createElement("img"),Wt=i=>{const t=fe();return t.width=i.width,t.height=i.height,t},ra=(i,t,e)=>i.toDataURL(`image/${t}`,e),sa=(i,t,e)=>new Promise((r,s)=>{i.toBlob(r,`image/${t}`,e)}),pt=i=>i*Ii,Te=i=>i/Ii,tu=i=>i.every((t,e)=>t===Tt[e]),Lt=(i,t,e)=>new x(i).transform(t,e),Ut=i=>{const t=1/(i[0]*i[3]-i[1]*i[2]),e=[t*i[3],-t*i[1],-t*i[2],t*i[0],0,0],{x:r,y:s}=new x(i[4],i[5]).transform(e,!0);return e[4]=-r,e[5]=-s,e},Ct=(i,t,e)=>[i[0]*t[0]+i[2]*t[1],i[1]*t[0]+i[3]*t[1],i[0]*t[2]+i[2]*t[3],i[1]*t[2]+i[3]*t[3],e?0:i[0]*t[4]+i[2]*t[5]+i[4],e?0:i[1]*t[4]+i[3]*t[5]+i[5]],Xi=(i,t)=>i.reduceRight((e,r)=>r&&e?Ct(r,e,t):r||e,void 0)||Tt.concat(),ia=i=>{let[t,e]=i;return Math.atan2(e,t)},Ms=i=>{const t=ia(i),e=Math.pow(i[0],2)+Math.pow(i[1],2),r=Math.sqrt(e),s=(i[0]*i[3]-i[2]*i[1])/r,n=Math.atan2(i[0]*i[2]+i[1]*i[3],e);return{angle:Te(t),scaleX:r,scaleY:s,skewX:Te(n),skewY:0,translateX:i[4]||0,translateY:i[5]||0}},Ar=function(i){return[1,0,0,1,i,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function rr(){let{angle:i=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 r=pt(i),s=de(r),n=ge(r);return[s,n,-n,s,t?t-(s*t-n*e):0,e?e-(n*t+s*e):0]}const Yi=function(i){return[i,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:i,0,0]},na=i=>Math.tan(pt(i)),oa=i=>[1,0,na(i),1,0,0],aa=i=>[1,na(i),0,1,0,0],Es=i=>{let{scaleX:t=1,scaleY:e=1,flipX:r=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=i,a=Yi(r?-t:t,s?-e:e);return n&&(a=Ct(a,oa(n),!0)),o&&(a=Ct(a,aa(o),!0)),a},eu=i=>{const{translateX:t=0,translateY:e=0,angle:r=0}=i;let s=Ar(t,e);r&&(s=Ct(s,rr({angle:r})));const n=Es(i);return tu(n)||(s=Ct(s,n)),s},Ps=function(i){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(r,s){if(t&&t.aborted)return s(new Wh("loadImage"));const n=Qh();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)),r(n)};i?(n.onload=a,n.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new re(`Error loading ${n.src}`))},e&&(n.crossOrigin=e),n.src=i):a()})},Lr=function(i){let{signal:t,reviver:e=xs}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((r,s)=>{const n=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(i.map(o=>j.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),n.push(a),a)))).then(r).catch(o=>{n.forEach(a=>{a.dispose&&a.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},As=function(i){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,r)=>{const s=[];t&&t.addEventListener("abort",r,{once:!0});const n=Object.values(i).map(a=>a&&a.type&&j.has(a.type)?Lr([a],{signal:t}).then(l=>{let[c]=l;return s.push(c),c}):a),o=Object.keys(i);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()}),r(a)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},sr=function(i){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in i&&(t[e]=i[e]),t),{})},Ui=(i,t)=>Object.keys(i).reduce((e,r)=>(t(i[r],r,i)&&(e[r]=i[r]),e),{}),nt=(i,t)=>parseFloat(Number(i).toFixed(t)),Fr=i=>"matrix("+i.map(t=>nt(t,tt.NUM_FRACTION_DIGITS)).join(" ")+")",Xt=i=>!!i&&i.toLive!==void 0,la=i=>!!i&&typeof i.toObject=="function",ca=i=>!!i&&i.offsetX!==void 0&&"source"in i,Ie=i=>!!i&&"multiSelectionStacking"in i;function ha(i){const t=i&&Gt(i);let e=0,r=0;if(!i||!t)return{left:e,top:r};let s=i;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,r=o.scrollTop||n.scrollTop||0):(e+=s.scrollLeft||0,r+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:r}}const Gt=i=>i.ownerDocument||null,ua=i=>{var t;return((t=i.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},da=function(i,t,e){let{width:r,height:s}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;i.width=r,i.height=s,n>1&&(i.setAttribute("width",(r*n).toString()),i.setAttribute("height",(s*n).toString()),t.scale(n,n))},Gi=(i,t)=>{let{width:e,height:r}=t;e&&(i.style.width=typeof e=="number"?`${e}px`:e),r&&(i.style.height=typeof r=="number"?`${r}px`:r)};function ga(i){return i.onselectstart!==void 0&&(i.onselectstart=()=>!1),i.style.userSelect=Pt,i}class fa{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=(r=t)&&r.getContext!==void 0?t:t&&Ke().getElementById(t)||fe();var r;if(e.hasAttribute("data-fabric"))throw new re("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:r}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width",`${e}`),s.setAttribute("height",`${r}`),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:r,ctx:s}=this.lower;da(r,s,t,e)}setCSSDimensions(t){Gi(this.lower.el,t)}calcOffset(){return function(t){var e;const r=t&&Gt(t),s={left:0,top:0};if(!r)return s;const n=((e=ua(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=r.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=ha(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(){se().dispose(this.lower.el),delete this.lower}}const ru={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Tt],patternQuality:"best"},q=i=>i.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let jr;const Ni=i=>{if(jr||jr||(jr="Intl"in ws()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),jr){const t=jr.segment(i);return Array.from(t).map(e=>{let{segment:r}=e;return r})}return su(i)},su=i=>{const t=[];for(let e,r=0;r<i.length;r++)(e=iu(i,r))!==!1&&t.push(e);return t},iu=(i,t)=>{const e=i.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return i.charAt(t);if(55296<=e&&e<=56319){if(i.length<=t+1)throw"High surrogate without following low surrogate";const s=i.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return i.charAt(t)+i.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const r=i.charCodeAt(t-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1};class Ir extends ta(ea){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 Ir.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 fa(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;s<e;s++)r[s-1]=arguments[s];const n=super.insertAt(t,...r);return r.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&&(Ce("warn",`Canvas is trying to add an object that belongs to a different canvas.
38
+ 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?Ko():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:r=!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}r||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 r=t,s=[...this.viewportTransform],n=Lt(t,Ut(s));s[0]=e,s[3]=e;const o=Lt(n,s);s[4]+=r.x-o.x,s[5]+=r.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=Ds(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Ut(this.viewportTransform),s=Lt({x:0,y:0},r),n=Lt({x:t,y:e},r),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&&(Zh(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const r=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality=this.patternQuality,this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(r[0],r[1],r[2],r[3],r[4],r[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 r=this.viewportTransform;t.save(),t.transform(...r),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 r=0,s=e.length;r<s;++r)e[r]&&e[r].render(t)}_renderBackgroundOrOverlay(t,e){const r=this[`${e}Color`],s=this[`${e}Image`],n=this.viewportTransform,o=this[`${e}Vpt`];if(!r&&!s)return;const a=Xt(r);if(r){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?r.toLive(t):r,o&&t.transform(...n),a){t.transform(1,0,0,1,r.offsetX||0,r.offsetY||0);const l=r.gradientTransform||r.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")}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 Lt(this.getCenterPoint(),Ut(this.viewportTransform))}_centerObject(t,e){t.setXY(e,Y,Y),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 r=this.clipPath,s=r&&!r.excludeFromExport?this._toObject(r,t,e):null;return{version:ji,...sr(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,r){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](r);return this.includeDefaultValues||(t.includeDefaultValues=!!s),n}__serializeBgOverlay(t,e){const r={},s=this.backgroundImage,n=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return Xt(o)?o.excludeFromExport||(r.background=o.toObject(e)):o&&(r.background=o),Xt(a)?a.excludeFromExport||(r.overlay=a.toObject(e)):a&&(r.overlay=a),s&&!s.excludeFromExport&&(r.backgroundImage=this._toObject(s,t,e)),n&&!n.excludeFromExport&&(r.overlayImage=this._toObject(n,t,e)),r}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const r=[];var s;return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push(`<g clip-path="url(#${q((s=this.clipPath.clipPathId)!==null&&s!==void 0?s:"")})" >
39
+ `),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push(`</g>
40
40
  `),this._setSVGBgOverlayColor(r,"overlay"),this._setSVGBgOverlayImage(r,"overlayImage",e),r.push("</svg>"),r.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
41
41
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
42
- `)}_setSVGHeader(t,e){const r=e.width||"".concat(this.width),s=e.height||"".concat(this.height),n=Q.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(it(-l[4]/l[0],n)," ").concat(it(-l[5]/l[3],n)," ").concat(it(this.width/l[0],n)," ").concat(it(this.height/l[3],n),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',r,'" ','height="',s,'" ',a,`xml:space="preserve">
43
- `,"<desc>Created with Fabric.js ",Li,`</desc>
42
+ `)}_setSVGHeader(t,e){const r=e.width||`${this.width}`,s=e.height||`${this.height}`,n=tt.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a=`viewBox="${o.x} ${o.y} ${o.width} ${o.height}" `;else if(this.svgViewportTransformation){const l=this.viewportTransform;a=`viewBox="${nt(-l[4]/l[0],n)} ${nt(-l[5]/l[3],n)} ${nt(this.width/l[0],n)} ${nt(this.height/l[3],n)}" `}else a=`viewBox="0 0 ${this.width} ${this.height}" `;t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',r,'" ','height="',s,'" ',a,`xml:space="preserve">
43
+ `,"<desc>Created with Fabric.js ",ji,`</desc>
44
44
  `,`<defs>
45
45
  `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
46
- `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Oe()),'<clipPath id="'.concat(e.clipPathId,`" >
47
- `).concat(e.toClipPathSVG(t.reviver),`</clipPath>
48
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(Xt(e)){const r=this["".concat(t,"Vpt")],s=this.viewportTransform,n={isType:()=>!1,width:this.width/(r?s[0]:1),height:this.height/(r?s[3]:1)};return e.toSVG(n,{additionalTransform:r?Ar(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},r=Q.fontPaths;this._objects.forEach(function n(o){t.push(o),Os(o)&&o._objects.forEach(n)}),t.forEach(n=>{if(!(o=n)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=n;!e[l]&&r[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&r[u]&&(e[u]=!0)})}))});const s=Object.keys(e).map(n=>` @font-face {
49
- font-family: '`.concat(n,`';
50
- src: url('`).concat(r[n],`');
46
+ `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId=`CLIPPATH_${ke()}`,`<clipPath id="${e.clipPathId}" >
47
+ ${e.toClipPathSVG(t.reviver)}</clipPath>
48
+ `):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this[`${t}Color`];if(Xt(e)){const r=this[`${t}Vpt`],s=this.viewportTransform,n={isType:()=>!1,width:this.width/(r?s[0]:1),height:this.height/(r?s[3]:1)};return e.toSVG(n,{additionalTransform:r?Fr(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},r=tt.fontPaths;this._objects.forEach(function n(o){t.push(o),Os(o)&&o._objects.forEach(n)}),t.forEach(n=>{if(!(o=n)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=n;!e[l]&&r[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&r[u]&&(e[u]=!0)})}))});const s=Object.keys(e).map(n=>` @font-face {
49
+ font-family: '${n}';
50
+ src: url('${r[n]}');
51
51
  }
52
- `)).join("");return s?` <style type="text/css"><![CDATA[
53
- `.concat(s,`]]></style>
54
- `):""}_setSVGObjects(t,e){this.forEachObject(r=>{r.excludeFromExport||this._setSVGObject(t,r,e)})}_setSVGObject(t,e,r){t.push(e.toSVG(r))}_setSVGBgOverlayImage(t,e,r){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(r))}_setSVGBgOverlayColor(t,e){const r=this["".concat(e,"Color")];if(r)if(Xt(r)){const s=r.repeat||"",n=this.width,o=this.height,a=this["".concat(e,"Vpt")]?Ar(Nt(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(n/2,",").concat(o/2,')" x="').concat(r.offsetX-n/2,'" y="').concat(r.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!na(r)?n:r.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!na(r)?o:r.source.height,'" fill="url(#SVGID_').concat(r.id,`)"></rect>
55
- `))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',r,'"',`></rect>
56
- `)}loadFromJSON(t,e){let{signal:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new se("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:n=[]}=s,o=ot(s,Zh),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:u}=o,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Pr(n,{reviver:e,signal:r}),As({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:u},{signal:r})]).then(g=>{let[f,p]=g;return this.clear(),this.add(...f),this.set(o),this.set(p),this.renderOnAddRemove=d,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Wt(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return Jo(this.toCanvasElement(o,t),e,r)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return Qo(this.toCanvasElement(o,t),e,r)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:r,left:s,top:n,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(r||this.height)*t,c=this.getZoom(),h=this.width,u=this.height,d=this.skipControlsDrawing,g=c*t,f=this.viewportTransform,p=[g,0,0,g,(f[4]-(s||0))*t,(f[5]-(n||0))*t],v=this.enableRetinaScaling,b=Wt({width:a,height:l}),x=o?this._objects.filter(D=>o(D)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=p,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(b.getContext("2d"),x),this.viewportTransform=f,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=v,this.skipControlsDrawing=d,b}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),ks.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const r=()=>{this.destroy(),t(!0)};r.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=r:r()})}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," }>")}}m(Lr,"ownDefaults",Kh);const Jh=["touchstart","touchmove","touchend"],Qh=i=>{const t=oa(i.target),e=function(r){const s=r.changedTouches;return s&&s[0]?s[0]:r}(i);return new _(e.clientX+t.left,e.clientY+t.top)},Ui=i=>Jh.includes(i.type)||i.pointerType==="touch",ua=i=>{i.preventDefault(),i.stopPropagation()},me=i=>{let t=0,e=0,r=0,s=0;for(let n=0,o=i.length;n<o;n++){const{x:a,y:l}=i[n];(a>r||!n)&&(r=a),(a<t||!n)&&(t=a),(l>s||!n)&&(s=l),(l<e||!n)&&(e=l)}return{left:t,top:e,width:r-t,height:s-e}},tu=["translateX","translateY","scaleX","scaleY"],eu=(i,t)=>Ls(i,Ct(t,i.calcOwnMatrix())),Ls=(i,t)=>{const e=Ms(t),{translateX:r,translateY:s,scaleX:n,scaleY:o}=e,a=ot(e,tu),l=new _(r,s);i.flipX=!1,i.flipY=!1,Object.assign(i,a),i.set({scaleX:n,scaleY:o}),i.setPositionByOrigin(l,$,$)},ru=i=>{i.scaleX=1,i.scaleY=1,i.skewX=0,i.skewY=0,i.flipX=!1,i.flipY=!1,i.rotate(0)},da=i=>({scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,angle:i.angle,left:i.left,flipX:i.flipX,flipY:i.flipY,top:i.top}),Ni=(i,t,e)=>{const r=i/2,s=t/2,n=[new _(-r,-s),new _(r,-s),new _(-r,s),new _(r,s)].map(a=>a.transform(e)),o=me(n);return new _(o.width,o.height)},js=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:St;return Ct(Nt(arguments.length>1&&arguments[1]!==void 0?arguments[1]:St),i)},rr=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:St,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:St;return i.transform(js(t,e))},su=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:St,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:St;return i.transform(js(t,e),!0)},iu=(i,t,e)=>{const r=js(t,e);return Ls(i,Ct(r,i.calcOwnMatrix())),r},ga=(i,t)=>{var e;const{transform:{target:r}}=t;(e=r.canvas)===null||e===void 0||e.fire("object:".concat(i),y(y({},t),{},{target:r})),r.fire(i,t)},nu={left:-.5,top:-.5,center:0,bottom:.5,right:.5},vt=i=>typeof i=="string"?nu[i]:i-.5,Fs="not-allowed";function fa(i){return vt(i.originX)===vt($)&&vt(i.originY)===vt($)}function pa(i){return .5-vt(i)}const $t=(i,t)=>i[t],ma=(i,t,e,r)=>({e:i,transform:t,pointer:new _(e,r)});function va(i,t){const e=i.getTotalAngle()+pe(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Gi(i,t,e,r,s){var n;let{target:o,corner:a}=i;const l=o.controls[a],c=((n=o.canvas)===null||n===void 0?void 0:n.getZoom())||1,h=o.padding/c,u=function(d,g,f,p){const v=d.getRelativeCenterPoint(),b=f!==void 0&&p!==void 0?d.translateToGivenOrigin(v,$,$,f,p):new _(d.left,d.top);return(d.angle?g.rotate(-pt(d.angle),v):g).subtract(b)}(o,new _(r,s),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const ou=(i,t,e,r)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=r-o,c=!$t(s,"lockMovementX")&&s.left!==a,h=!$t(s,"lockMovementY")&&s.top!==l;return c&&s.set(et,a),h&&s.set(Dt,l),(c||h)&&ga(Go,ma(i,t,e,r)),c||h},Rs=i=>i.replace(/\s+/g," "),ya={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"},$i=(i,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+6*(t-i)*e:e<.5?t:e<2/3?i+(t-i)*(2/3-e)*6:i),ba=(i,t,e,r)=>{i/=255,t/=255,e/=255;const s=Math.max(i,t,e),n=Math.min(i,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 i:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-i)/c+2;break;case e:o=(i-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),r]},wa=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(i)/(i.endsWith("%")?100:1)},Is=i=>Math.min(Math.round(i),255).toString(16).toUpperCase().padStart(2,"0"),xa=i=>{let[t,e,r,s=1]=i;const n=Math.round(.3*t+.59*e+.11*r);return[n,n,n,s]};class rt{constructor(t){if(m(this,"isUnrecognised",!1),t)if(t instanceof rt)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,r,s,n=1]=t;this.setSource([e,r,s,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in ya&&(t=ya[t]),t==="transparent"?[255,255,255,0]:rt.sourceFromHex(t)||rt.sourceFromRgb(t)||rt.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,r]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(r,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,r]=ba(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(r,"%)")}toHsla(){const[t,e,r,s]=ba(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(r,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,s]=this.getSource();return"".concat(Is(t)).concat(Is(e)).concat(Is(r)).concat(Is(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(xa(this.getSource())),this}toBlackWhite(t){const[e,,,r]=xa(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,r]),this}overlayWith(t){t instanceof rt||(t=new rt(t));const e=this.getSource(),r=t.getSource(),[s,n,o]=e.map((a,l)=>Math.round(.5*a+.5*r[l]));return this.setSource([s,n,o,e[3]]),this}static fromRgb(t){return rt.fromRgba(t)}static fromRgba(t){return new rt(rt.sourceFromRgb(t))}static sourceFromRgb(t){const e=Rs(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[r,s,n]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[r,s,n,wa(e[4])]}}static fromHsl(t){return rt.fromHsla(t)}static fromHsla(t){return new rt(rt.sourceFromHsl(t))}static sourceFromHsl(t){const e=Rs(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 r=(rt.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=$i(h,c,r+.3333333333333333),a=$i(h,c,r),l=$i(h,c,r-.3333333333333333)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),wa(e[4])]}static fromHex(t){return new rt(rt.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 r;r=e.length<=4?e.split("").map(l=>l+l):e.match(/.{2}/g);const[s,n,o,a=255]=r.map(l=>parseInt(l,16));return[s,n,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),r=parseFloat(e);return e.includes("rad")?pe(r):e.includes("turn")?360*r:r}}const sr=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fi;const e=/\D{0,2}$/.exec(i),r=parseFloat(i),s=Q.DPI;switch(e==null?void 0:e[0]){case"mm":return r*s/25.4;case"cm":return r*s/2.54;case"in":return r*s;case"pt":return r*s/72;case"pc":return r*s/72*12;case"em":return r*t;default:return r}},au=i=>{const[t,e]=i.trim().split(" "),[r,s]=(n=t)&&n!==Mt?[n.slice(1,4),n.slice(5,8)]:n===Mt?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:r,alignY:s}},jr=function(i,t){let e,r,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 rt(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(r=o.toString())}else e="none";return s?"".concat(i,": ").concat(e,"; ").concat(r?"".concat(i,"-opacity: ").concat(r,"; "):""):"".concat(i,'="').concat(e,'" ').concat(r?"".concat(i,'-opacity="').concat(r,'" '):"")};class _a{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):Mt,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;",u=t?"":this.getSvgFilter(),d=jr(xt,this.fill);return[jr(Pt,this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,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 r=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Ar(r));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:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:r,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,u=this.stroke,d=this.fill,g=this.shadow,f=[],p=t.indexOf("COMMON_PARTS");let v;l&&(l.clipPathId="CLIPPATH_".concat(Oe()),v='<clipPath id="'.concat(l.clipPathId,`" >
57
- `).concat(l.toClipPathSVG(r),`</clipPath>
58
- `)),h&&f.push("<g ",a,this.getSvgCommons(),` >
52
+ `).join("");return s?` <style type="text/css"><![CDATA[
53
+ ${s}]]></style>
54
+ `:""}_setSVGObjects(t,e){this.forEachObject(r=>{r.excludeFromExport||this._setSVGObject(t,r,e)})}_setSVGObject(t,e,r){t.push(e.toSVG(r))}_setSVGBgOverlayImage(t,e,r){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(r))}_setSVGBgOverlayColor(t,e){const r=this[`${e}Color`];if(r)if(Xt(r)){const s=r.repeat||"",n=this.width,o=this.height,a=this[`${e}Vpt`]?Fr(Ut(this.viewportTransform)):"";t.push(`<rect transform="${a} translate(${n/2},${o/2})" x="${r.offsetX-n/2}" y="${r.offsetY-o/2}" width="${s!=="repeat-y"&&s!=="no-repeat"||!ca(r)?n:r.source.width}" height="${s!=="repeat-x"&&s!=="no-repeat"||!ca(r)?o:r.source.height}" fill="url(#SVGID_${r.id})"></rect>
55
+ `)}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',r,'"',`></rect>
56
+ `)}loadFromJSON(t,e){let{signal:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new re("`json` is undefined"));const{objects:s=[],...n}=typeof t=="string"?JSON.parse(t):t,{backgroundImage:o,background:a,overlayImage:l,overlay:c,clipPath:h}=n,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Lr(s,{reviver:e,signal:r}),As({backgroundImage:o,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:r})]).then(d=>{let[g,f]=d;return this.clear(),this.add(...g),this.set(n),this.set(f),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Wt(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return ra(this.toCanvasElement(o,t),e,r)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return sa(this.toCanvasElement(o,t),e,r)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:r,left:s,top:n,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(r||this.height)*t,c=this.getZoom(),h=this.width,u=this.height,d=this.skipControlsDrawing,g=c*t,f=this.viewportTransform,m=[g,0,0,g,(f[4]-(s||0))*t,(f[5]-(n||0))*t],y=this.enableRetinaScaling,b=Wt({width:a,height:l}),w=o?this._objects.filter(T=>o(T)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=m,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(b.getContext("2d"),w),this.viewportTransform=f,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=y,this.skipControlsDrawing=d,b}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Ts.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const r=()=>{this.destroy(),t(!0)};r.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=r:r()})}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 (${this.complexity()}): { objects: ${this._objects.length} }>`}}v(Ir,"ownDefaults",ru);const nu=["touchstart","touchmove","touchend"],ou=i=>{const t=ha(i.target),e=function(r){const s=r.changedTouches;return s&&s[0]?s[0]:r}(i);return new x(e.clientX+t.left,e.clientY+t.top)},qi=i=>nu.includes(i.type)||i.pointerType==="touch",pa=i=>{i.preventDefault(),i.stopPropagation()},pe=i=>{let t=0,e=0,r=0,s=0;for(let n=0,o=i.length;n<o;n++){const{x:a,y:l}=i[n];(a>r||!n)&&(r=a),(a<t||!n)&&(t=a),(l>s||!n)&&(s=l),(l<e||!n)&&(e=l)}return{left:t,top:e,width:r-t,height:s-e}},au=(i,t)=>Ls(i,Ct(t,i.calcOwnMatrix())),Ls=(i,t)=>{const{translateX:e,translateY:r,scaleX:s,scaleY:n,...o}=Ms(t),a=new x(e,r);i.flipX=!1,i.flipY=!1,Object.assign(i,o),i.set({scaleX:s,scaleY:n}),i.setPositionByOrigin(a,Y,Y)},lu=i=>{i.scaleX=1,i.scaleY=1,i.skewX=0,i.skewY=0,i.flipX=!1,i.flipY=!1,i.rotate(0)},ma=i=>({scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,angle:i.angle,left:i.left,flipX:i.flipX,flipY:i.flipY,top:i.top}),Ki=(i,t,e)=>{const r=i/2,s=t/2,n=[new x(-r,-s),new x(r,-s),new x(-r,s),new x(r,s)].map(a=>a.transform(e)),o=pe(n);return new x(o.width,o.height)},Fs=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tt;return Ct(Ut(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tt),i)},ir=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tt;return i.transform(Fs(t,e))},cu=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tt;return i.transform(Fs(t,e),!0)},hu=(i,t,e)=>{const r=Fs(t,e);return Ls(i,Ct(r,i.calcOwnMatrix())),r},uu={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Ot=i=>typeof i=="string"?uu[i]:i-.5,du=new x(1,0),va=new x,ya=(i,t)=>i.rotate(t),js=(i,t)=>new x(t).subtract(i),Zi=i=>i.distanceFrom(va),Ji=(i,t)=>Math.atan2(Br(i,t),gu(i,t)),ba=i=>Ji(du,i),Qi=i=>i.eq(va)?i:i.scalarDivide(Zi(i)),wa=function(i){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Qi(new x(-i.y,i.x).scalarMultiply(t?1:-1))},Br=(i,t)=>i.x*t.y-i.y*t.x,gu=(i,t)=>i.x*t.x+i.y*t.y,xa=(i,t,e)=>{if(i.eq(t)||i.eq(e))return!0;const r=Br(t,e),s=Br(t,i),n=Br(e,i);return r>=0?s>=0&&n<=0:!(s<=0&&n>=0)},Is="not-allowed";function _a(i){return Ot(i.originX)===Ot(Y)&&Ot(i.originY)===Ot(Y)}function Ca(i){return .5-Ot(i)}const Nt=(i,t)=>i[t],Sa=(i,t,e,r)=>({e:i,transform:t,pointer:new x(e,r)});function ka(i,t,e){const r=e,s=ir(i.getCenterPoint(),i.canvas.viewportTransform,void 0),n=ba(js(s,r))+Ze;return Math.round(n%Ze/Gh)}function tn(i,t,e,r,s){var n;let{target:o,corner:a}=i;const l=o.controls[a],c=((n=o.canvas)===null||n===void 0?void 0:n.getZoom())||1,h=o.padding/c,u=function(d,g,f,m){const y=d.getRelativeCenterPoint(),b=f!==void 0&&m!==void 0?d.translateToGivenOrigin(y,Y,Y,f,m):new x(d.left,d.top);return(d.angle?g.rotate(-pt(d.angle),y):g).subtract(b)}(o,new x(r,s),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const Bs=i=>i.replace(/\s+/g," "),Ta={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"},en=(i,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+6*(t-i)*e:e<.5?t:e<2/3?i+(t-i)*(2/3-e)*6:i),Oa=(i,t,e,r)=>{i/=255,t/=255,e/=255;const s=Math.max(i,t,e),n=Math.min(i,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 i:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-i)/c+2;break;case e:o=(i-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),r]},Da=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(i)/(i.endsWith("%")?100:1)},Rs=i=>Math.min(Math.round(i),255).toString(16).toUpperCase().padStart(2,"0"),Ma=i=>{let[t,e,r,s=1]=i;const n=Math.round(.3*t+.59*e+.11*r);return[n,n,n,s]};class rt{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof rt)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,r,s,n=1]=t;this.setSource([e,r,s,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Ta&&(t=Ta[t]),t==="transparent"?[255,255,255,0]:rt.sourceFromHex(t)||rt.sourceFromRgb(t)||rt.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,r]=this.getSource();return`rgb(${t},${e},${r})`}toRgba(){return`rgba(${this.getSource().join(",")})`}toHsl(){const[t,e,r]=Oa(...this.getSource());return`hsl(${t},${e}%,${r}%)`}toHsla(){const[t,e,r,s]=Oa(...this.getSource());return`hsla(${t},${e}%,${r}%,${s})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,s]=this.getSource();return`${Rs(t)}${Rs(e)}${Rs(r)}${Rs(Math.round(255*s))}`}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Ma(this.getSource())),this}toBlackWhite(t){const[e,,,r]=Ma(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,r]),this}overlayWith(t){t instanceof rt||(t=new rt(t));const e=this.getSource(),r=t.getSource(),[s,n,o]=e.map((a,l)=>Math.round(.5*a+.5*r[l]));return this.setSource([s,n,o,e[3]]),this}static fromRgb(t){return rt.fromRgba(t)}static fromRgba(t){return new rt(rt.sourceFromRgb(t))}static sourceFromRgb(t){const e=Bs(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[r,s,n]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[r,s,n,Da(e[4])]}}static fromHsl(t){return rt.fromHsla(t)}static fromHsla(t){return new rt(rt.sourceFromHsl(t))}static sourceFromHsl(t){const e=Bs(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 r=(rt.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=en(h,c,r+.3333333333333333),a=en(h,c,r),l=en(h,c,r-.3333333333333333)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Da(e[4])]}static fromHex(t){return new rt(rt.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 r;r=e.length<=4?e.split("").map(l=>l+l):e.match(/.{2}/g);const[s,n,o,a=255]=r.map(l=>parseInt(l,16));return[s,n,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),r=parseFloat(e);return e.includes("rad")?Te(r):e.includes("turn")?360*r:r}}const nr=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bi;const e=/\D{0,2}$/.exec(i),r=parseFloat(i),s=tt.DPI;switch(e==null?void 0:e[0]){case"mm":return r*s/25.4;case"cm":return r*s/2.54;case"in":return r*s;case"pt":return r*s/72;case"pc":return r*s/72*12;case"em":return r*t;default:return r}},fu=i=>{const[t,e]=i.trim().split(" "),[r,s]=(n=t)&&n!==Pt?[n.slice(1,4),n.slice(5,8)]:n===Pt?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:r,alignY:s}},Rr=function(i,t){let e,r,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e=`url(#SVGID_${q(t.id)})`;else{const n=new rt(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(r=o.toString())}else e="none";return s?`${i}: ${e}; ${r?`${i}-opacity: ${r}; `:""}`:`${i}="${e}" ${r?`${i}-opacity="${r}" `:""}`};class Ea{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):Pt,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;",u=t?"":this.getSvgFilter(),d=Rr(_t,this.fill);return[Rr(Rt,this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,h].map(g=>q(g)).join("")}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${q(this.shadow.id)});`:""}getSvgCommons(){return[this.id?`id="${q(String(this.id))}" `:"",this.clipPath?`clip-path="url(#${this.clipPath.clipPathId})" `:""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t?this.calcTransformMatrix():this.calcOwnMatrix();return`${`transform="${Fr(r)}`}${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:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:r,withShadow:s,additionalTransform:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":`style="${this.getSvgStyles()}" `,a=s?`style="${this.getSvgFilter()}" `:"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,u=this.stroke,d=this.fill,g=this.shadow,f=[],m=t.indexOf("COMMON_PARTS");let y;l&&(l.clipPathId=`CLIPPATH_${ke()}`,y=`<clipPath id="${l.clipPathId}" >
57
+ ${l.toClipPathSVG(r)}</clipPath>
58
+ `),h&&f.push("<g ",a,this.getSvgCommons(),` >
59
59
  `),f.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
60
- `);const b=[o,c,e?"":this.addPaintOrder()," ",n?'transform="'.concat(n,'" '):""].join("");return t[p]=b,Xt(d)&&f.push(d.toSVG(this)),Xt(u)&&f.push(u.toSVG(this)),g&&f.push(g.toSVG(this)),l&&f.push(v),f.push(t.join("")),f.push(`</g>
60
+ `);const b=[o,c,e?"":this.addPaintOrder()," ",n?`transform="${n}" `:""].join("");return t[m]=b,Xt(d)&&f.push(d.toSVG(this)),Xt(u)&&f.push(u.toSVG(this)),g&&f.push(g.toSVG(this)),l&&f.push(y),f.push(t.join("")),f.push(`</g>
61
61
  `),h&&f.push(`</g>
62
- `),r?r(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==xt?' paint-order="'.concat(this.paintFirst,'" '):""}}function Bs(i){return new RegExp("^("+i.join("|")+")\\b","i")}const Ie="textDecorationThickness",Ca=["fontSize","fontWeight","fontFamily","fontStyle"],Sa=["underline","overline","linethrough"],Ta=[...Ca,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],ka=[...Ta,...Sa,"textBackgroundColor","direction",Ie],lu=[...Ca,...Sa,Pt,"strokeWidth",xt,"deltaY","textBackgroundColor",Ie],cu={_reNewline:Ii,_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:et,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:et,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,[Ie]:66.667},ne="justify",zs="justify-left",Fr="justify-right",Rr="justify-center";var Oa,Da,Ma;const qt=String.raw(Oa||(Oa=re(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),qi=String.raw(Da||(Da=re(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),hu=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+qt+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+qt+"))?\\s+(.*)"),uu={cx:et,x:et,r:"radius",cy:Dt,y:Dt,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":Ie},Ki="font-size",Zi="clip-path";Bs(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),Bs(["symbol","image","marker","pattern","view","svg"]);const Ea=Bs(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(Ma||(Ma=re(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),qt,qi,qt,qi,qt,qi,qt));const du=new _(1,0),Pa=new _,Aa=(i,t)=>i.rotate(t),Ji=(i,t)=>new _(t).subtract(i),Qi=i=>i.distanceFrom(Pa),tn=(i,t)=>Math.atan2(Ir(i,t),fu(i,t)),gu=i=>tn(du,i),en=i=>i.eq(Pa)?i:i.scalarDivide(Qi(i)),La=function(i){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return en(new _(-i.y,i.x).scalarMultiply(t?1:-1))},Ir=(i,t)=>i.x*t.y-i.y*t.x,fu=(i,t)=>i.x*t.x+i.y*t.y,ja=(i,t,e)=>{if(i.eq(t)||i.eq(e))return!0;const r=Ir(t,e),s=Ir(t,i),n=Ir(e,i);return r>=0?s>=0&&n<=0:!(s<=0&&n>=0)},Fa="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Ra=new RegExp("(?:\\s|^)"+Fa+Fa+"("+qt+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class oe{constructor(t){const e=typeof t=="string"?oe.parseShadow(t):t;Object.assign(this,oe.ownDefaults,e),this.id=Oe()}static parseShadow(t){const e=t.trim(),[,r=0,s=0,n=0]=(Ra.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Ra,"")||"rgb(0,0,0)").trim(),offsetX:r,offsetY:s,blur:n}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Aa(new _(this.offsetX,this.offsetY),pt(-t.angle)),r=new rt(this.color);let s=40,n=40;return t.width&&t.height&&(s=100*it((Math.abs(e.x)+this.blur)/t.width,Q.NUM_FRACTION_DIGITS)+20,n=100*it((Math.abs(e.y)+this.blur)/t.height,Q.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,`%" >
63
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(it(this.blur?this.blur/2:0,Q.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
64
- <feOffset dx="`).concat(it(e.x,Q.NUM_FRACTION_DIGITS),'" dy="').concat(it(e.y,Q.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
65
- <feFlood flood-color="`).concat(r.toRgb(),'" flood-opacity="').concat(r.getAlpha(),`"/>
62
+ `),r?r(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==_t?` paint-order="${q(this.paintFirst)}" `:""}}function $s(i){return new RegExp("^("+i.join("|")+")\\b","i")}const Be="textDecorationThickness",Pa=["fontSize","fontWeight","fontFamily","fontStyle"],Aa=["underline","overline","linethrough"],La=[...Pa,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Fa=[...La,...Aa,"textBackgroundColor","direction",Be],pu=[...Pa,...Aa,Rt,"strokeWidth",_t,"deltaY","textBackgroundColor",Be],mu={_reNewline:$i,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:Hi,fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Q,fontStyle:Hi,lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Q,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:je,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,[Be]:66.667},ie="justify",zs="justify-left",$r="justify-right",zr="justify-center",Re=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,vu=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Re+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Re+"))?\\s+(.*)"),yu={cx:Q,x:Q,r:"radius",cy:Et,y:Et,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":Be},rn="font-size",sn="clip-path";$s(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),$s(["symbol","image","marker","pattern","view","svg"]);const ja=$s(["symbol","g","a","svg","clipPath","defs"]),Ia="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Ba=new RegExp("(?:\\s|^)"+Ia+Ia+"("+Re+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ne{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=typeof t=="string"?ne.parseShadow(t):t;Object.assign(this,ne.ownDefaults,e),this.id=ke()}static parseShadow(t){const e=t.trim(),[,r=0,s=0,n=0]=(Ba.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Ba,"")||"rgb(0,0,0)").trim(),offsetX:r,offsetY:s,blur:n}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=ya(new x(this.offsetX,this.offsetY),pt(-t.angle)),r=tt.NUM_FRACTION_DIGITS,s=new rt(this.color);let n=40,o=40;return t.width&&t.height&&(n=100*nt((Math.abs(e.x)+this.blur)/t.width,r)+20,o=100*nt((Math.abs(e.y)+this.blur)/t.height,r)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),`<filter id="SVGID_${q(this.id)}" y="-${o}%" height="${100+2*o}%" x="-${n}%" width="${100+2*n}%" >
63
+ <feGaussianBlur in="SourceAlpha" stdDeviation="${nt(this.blur?this.blur/2:0,r)}"></feGaussianBlur>
64
+ <feOffset dx="${nt(e.x,r)}" dy="${nt(e.y,r)}" result="oBlur" ></feOffset>
65
+ <feFlood flood-color="${s.toRgb()}" flood-opacity="${s.getAlpha()}"/>
66
66
  <feComposite in2="oBlur" operator="in" />
67
67
  <feMerge>
68
68
  <feMergeNode></feMergeNode>
69
69
  <feMergeNode in="SourceGraphic"></feMergeNode>
70
70
  </feMerge>
71
71
  </filter>
72
- `)}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=oe.ownDefaults;return this.includeDefaultValues?t:Xi(t,(r,s)=>r!==e[s])}static async fromObject(t){return new this(t)}}m(oe,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),m(oe,"type","shadow"),R.setClass(oe,"shadow");const ir=(i,t,e)=>Math.max(i,Math.min(t,e)),pu=[Dt,et,Et,Vt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Ke,Ze],ve=[xt,Pt,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],mu={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:et,originY:Dt,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:xt,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},vu=(i,t,e,r)=>-e*Math.cos(i/r*Dr)+e+t,yu=()=>!1;class rn{constructor(t){let{startValue:e,byValue:r,duration:s=500,delay:n=0,easing:o=vu,onStart:a=ws,onChange:l=ws,onComplete:c=ws,abort:h=yu,target:u}=t;m(this,"_state","pending"),m(this,"durationProgress",0),m(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=u,this.startValue=e,this.byValue=r,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(()=>Ds(t),this.delay):Ds(t)}tick(t){const e=(t||+new Date)-this.startTime,r=Math.min(e,this.duration);this.durationProgress=r/this.duration;const{value:s,valueProgress:n}=this.calculate(r);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),Ds(this.tick)))}register(){ks.push(this)}unregister(){ks.remove(this)}abort(){this._state="aborted",this.unregister()}}const bu=["startValue","endValue"];class wu extends rn{constructor(t){let{startValue:e=0,endValue:r=100}=t;super(y(y({},ot(t,bu)),{},{startValue:e,byValue:r-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 xu=["startValue","endValue"];class _u extends rn{constructor(t){let{startValue:e=[0],endValue:r=[100]}=t;super(y(y({},ot(t,xu)),{},{startValue:e,byValue:r.map((s,n)=>s-e[n])}))}calculate(t){const e=this.startValue.map((r,s)=>this.easing(t,r,this.byValue[s],this.duration,s));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Cu=["startValue","endValue","easing","onChange","onComplete","abort"],Su=(i,t,e,r)=>t+e*(1-Math.cos(i/r*Dr)),sn=i=>i&&((t,e,r)=>i(new rt(t).toRgba(),e,r));class Tu extends rn{constructor(t){let{startValue:e,endValue:r,easing:s=Su,onChange:n,onComplete:o,abort:a}=t,l=ot(t,Cu);const c=new rt(e).getSource(),h=new rt(r).getSource();super(y(y({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:s,onChange:sn(n),onComplete:sn(o),abort:sn(a)}))}calculate(t){const[e,r,s,n]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,r,s].map(Math.round),ir(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 Ia(i){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(i)?new _u(i):new wu(i);return t.start(),t}function ku(i){const t=new Tu(i);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),r=0;r<t;r++)e[r]=arguments[r];return this.points=this.points.concat(e.filter(s=>!this.includes(s))),this}static isPointContained(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(r))return t.eq(e);if(e.x===r.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,r.y)&&t.y<=Math.max(e.y,r.y));if(e.y===r.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,r.x)&&t.x<=Math.max(e.x,r.x));{const n=Ji(e,r),o=Ji(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 r=new _(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,r);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,r,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-r.x,h=s.y-r.y,u=t.x-r.x,d=t.y-r.y,g=c*d-h*u,f=a*d-l*u,p=h*a-c*l;if(p!==0){const v=g/p,b=f/p;return(n||0<=v&&v<=1)&&(o||0<=b&&b<=1)?new lt("Intersection").append(new _(t.x+v*a,t.y+v*l)):new lt}if(g===0||f===0){const v=n||o||lt.isPointContained(t,r,s)||lt.isPointContained(e,r,s)||lt.isPointContained(r,t,e)||lt.isPointContained(s,t,e);return new lt(v?"Coincident":void 0)}return new lt("Parallel")}static intersectSegmentLine(t,e,r,s){return lt.intersectLineLine(t,e,r,s,!1,!0)}static intersectSegmentSegment(t,e,r,s){return lt.intersectLineLine(t,e,r,s,!1,!1)}static intersectLinePolygon(t,e,r){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new lt,o=r.length;for(let a,l,c,h=0;h<o;h++){if(a=r[h],l=r[(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,r){return lt.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=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),r.append(a,l)):r.append(...c.points)}return n.length>0&&n.length===t.length?new lt("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(t,e,r){const s=e.min(r),n=e.max(r),o=new _(n.x,s.y),a=new _(s.x,n.y);return lt.intersectPolygonPolygon(t,[s,o,n,a])}}class Ou extends Zo{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?At(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=At(t,Nt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new _(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:r,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,r,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map(a=>At(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:r,top:s,width:n,height:o}=this.getBoundingRect();return r>=t.x&&r+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(r=>r.x<=e.x&&r.x>=t.x&&r.y<=e.y&&r.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(r=>(r.x>=e.x||r.x<=t.x)&&(r.y>=e.y||r.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return me(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(Et,t),this._set(Vt,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?pe(ta(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||St.concat()}calcACoords(){const t=tr({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),s=Er(e,r),n=Ct(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:At({x:-a,y:-l},n),tr:At({x:a,y:-l},n),bl:At({x:-a,y:l},n),br:At({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,vt(this.originX),vt(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 r=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every((n,o)=>n===r[o])?s.value:(this.group&&(e=Ct(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:r,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const r=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:r.x,translateY:r.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=qh(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new _(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),r=e.strokeWidth;let s=r,n=0;this.strokeUniform&&(s=0,n=r);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new _(o*e.scaleX,a*e.scaleY):Ni(o,a,Es(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,r,s,n){let o=t.x,a=t.y;const l=vt(s)-vt(e),c=vt(n)-vt(r);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new _(o,a)}translateToCenterPoint(t,e,r){if(e===$&&r===$)return t;const s=this.translateToGivenOrigin(t,e,r,$,$);return this.angle?s.rotate(pt(this.angle),t):s}translateToOriginPoint(t,e,r){const s=this.translateToGivenOrigin(t,$,$,e,r);return this.angle?s.rotate(pt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?At(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new _(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,r){const s=this.translateToCenterPoint(t,e,r),n=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),et,Dt)}}const Du=["type"],Mu=["extraParam"];let ye=class mi extends Ou{static getDefaults(){return mi.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Te("warn","Setting type has no effect",t)}constructor(t){super(),m(this,"_cacheContext",null),Object.assign(this,mi.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=fe(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,r=t.height,s=Q.maxCacheSideLimit,n=Q.minCacheSideLimit;if(e<=s&&r<=s&&e*r<=Q.perfLimitSizeTotal)return e<n&&(t.width=n),r<n&&(t.height=n),t;const o=e/r,[a,l]=Or.limitDimsByArea(o),c=ir(n,a,s),h=ir(n,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),r>h&&(t.zoomY/=r/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),r=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(r+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:r,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:r,height:s,zoomX:n,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=r!==t.width||s!==t.height,h=this.zoomX!==n||this.zoomY!==o;if(!t||!e)return!1;if(c||h){r!==t.width||s!==t.height?(t.width=r,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,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,r=this.calcTransformMatrix(!e);t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}getObjectScaling(){if(!this.group)return new _(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Ms(this.calcTransformMatrix());return new _(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}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!==Et&&t!==Vt||(e=this._constrainScale(e)),t===Et&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof oe||(e=new oe(e));const r=this[t]!==e;return this[t]=e,r&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||r&&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:r,cacheTranslationX:s,cacheTranslationY:n}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,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===Pt&&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,r){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0),t.restore()}drawObject(t,e,r){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,r),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const r=Wt(e),s=r.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=r,e.parentClipPaths.forEach(n=>{n.transform(s)}),e.parentClipPaths.push(t),t.absolutePositioned){const n=Nt(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),r}_drawClipPath(t,e,r){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,r);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,r=this._cacheContext;return!(!e||!r||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&r&&!t&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.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 r=e.stroke;r&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,Xt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?this._applyPatternForTransformedGradient(t,r):(t.strokeStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:r}=e;r&&(Xt(r)?(t.fillStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.fillStyle=r)}_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,r=this.canvas,s=this.getCanvasRetinaScaling(),[n,,,o]=(r==null?void 0:r.viewportTransform)||St,a=n*s,l=o*s,c=e.nonScaling?new _(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*Q.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(!Xt(e))return{offsetX:0,offsetY:0};const r=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),r&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),{offsetX:s,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===Pt?(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 r;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/n,a=s.y/this.scaleY/n,l=Wt({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=(r=c.createPattern(l,"no-repeat"))!==null&&r!==void 0?r:"")}_findCenterFromElement(){return new _(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(R.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=da(this),r=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?No():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(x=>new Lr(x,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&ru(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&iu(this,this.getViewportTransform()),this.setCoords();const c=fe(),h=this.getBoundingRect(),u=this.shadow,d=new _;if(u){const x=u.blur,D=u.nonScaling?new _(1,1):this.getObjectScaling();d.x=2*Math.round(n(u.offsetX)+x)*n(D.x),d.y=2*Math.round(n(u.offsetY)+x)*n(D.y)}const g=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(g),c.height=Math.ceil(f);const p=l(c);t.format==="jpeg"&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new _(p.width/2,p.height/2),$,$);const v=this.canvas;p._objects=[this],this.set("canvas",p),this.setCoords();const b=p.toCanvasElement(a||1,t);return this.set("canvas",v),this.shadow=s,r&&(this.group=r),this.set(e),this.setCoords(),p._objects=[],p.destroy(),b}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Jo(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Qo(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:r,originY:s}=this;if(e){const{x:n,y:o}=this.getRelativeCenterPoint();this.originX=$,this.originY=$,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),r,s);this.left=n,this.top=o,this.originX=r,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){ks.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&ie().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((r,s)=>{let[n,o]=s;return r[n]=this._animate(n,o,e),r},{})}_animate(t,e){let r=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}=r,h=y(y({},r),{},{target:this,startValue:a??s.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,g)=>{s.reduce((f,p,v)=>(v===s.length-1&&(f[p]=u),f[p]),this),l&&l(u,d,g)},onComplete:(u,d,g)=>{this.setCoords(),c&&c(u,d,g)}});return n?ku(h):Ia(h)}isDescendantOf(t){const{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.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(),r=t.getAncestors();if(e.length===0&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.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<r.length;o++){if(this===r[o])return{fork:[],otherFork:[t,...r.slice(0,o)],common:[this,...e]};if(s===r[o])return{fork:[this,...e.slice(0,n)],otherFork:[t,...r.slice(0,o)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...r],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 r=e.common[0]||this.canvas;if(!r)return;const s=e.fork.pop(),n=e.otherFork.pop(),o=r._objects.indexOf(s),a=r._objects.indexOf(n);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(mi.customProperties,this.constructor.customProperties||[]);let e;const r=Q.NUM_FRACTION_DIGITS,{clipPath:s,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:g,height:f,strokeWidth:p,strokeLineCap:v,strokeDashOffset:b,strokeLineJoin:x,strokeUniform:D,strokeMiterLimit:C,scaleX:O,scaleY:S,angle:j,flipX:T,flipY:L,opacity:H,visible:W,backgroundColor:V,fillRule:U,paintFirst:X,globalCompositeOperation:tt,skewX:Z,skewY:J}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const A=ut=>it(ut,r),ht=y(y({},er(this,t)),{},{type:this.constructor.type,version:Li,originX:u,originY:d,left:A(c),top:A(h),width:A(g),height:A(f),fill:ia(n)?n.toObject():n,stroke:ia(o)?o.toObject():o,strokeWidth:A(p),strokeDashArray:l&&l.concat(),strokeLineCap:v,strokeDashOffset:b,strokeLineJoin:x,strokeUniform:D,strokeMiterLimit:A(C),scaleX:A(O),scaleY:A(S),angle:A(j),flipX:T,flipY:L,opacity:A(H),shadow:a&&a.toObject(),visible:W,backgroundColor:V,fillRule:U,paintFirst:X,globalCompositeOperation:tt,skewX:A(Z),skewY:A(J)},e?{clipPath:e}:null);return this.includeDefaultValues?ht:this._removeDefaultValues(ht)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Xi(t,(s,n)=>{if(n===et||n===Dt||n==="type")return!0;const o=r[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=ot(t,Du),r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=r,n=ot(r,Mu);return As(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)}};m(ye,"stateProperties",pu),m(ye,"cacheProperties",ve),m(ye,"ownDefaults",mu),m(ye,"type","FabricObject"),m(ye,"colorProperties",[xt,Pt,"backgroundColor"]),m(ye,"customProperties",[]),R.setClass(ye),R.setClass(ye,"object");const nr=(i,t,e)=>(r,s,n,o)=>{const a=t(r,s,n,o);return a&&ga(i,y(y({},ma(r,s,n,o)),e)),a};function or(i){return(t,e,r,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(l,o,a),h=i(t,e,r,s);return n.setPositionByOrigin(c,e.originX,e.originY),h}}const Ba=nr(Mr,or((i,t,e,r)=>{const s=Gi(t,t.originX,t.originY,e,r);if(vt(t.originX)===vt($)||vt(t.originX)===vt(ft)&&s.x<0||vt(t.originX)===vt(et)&&s.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=fa(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 Eu(i,t,e,r,s){r=r||{};const n=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:s.transparentCorners,l=a?Pt:xt,c=!a&&(r.cornerStrokeColor||s.cornerStrokeColor);let h,u=t,d=e;i.save(),i.fillStyle=r.cornerColor||s.cornerColor||"",i.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor||"",n>o?(h=n,i.scale(1,o/n),d=e*n/o):o>n?(h=o,i.scale(n/o,1),u=t*o/n):h=n,i.beginPath(),i.arc(u,d,h/2,0,xs,!1),i[l](),c&&i.stroke(),i.restore()}function Pu(i,t,e,r,s){r=r||{};const n=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,a=r.transparentCorners!==void 0?r.transparentCorners:s.transparentCorners,l=a?Pt:xt,c=!a&&(r.cornerStrokeColor||s.cornerStrokeColor),h=n/2,u=o/2;i.save(),i.fillStyle=r.cornerColor||s.cornerColor||"",i.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor||"",i.translate(t,e);const d=s.getTotalAngle();i.rotate(pt(d)),i["".concat(l,"Rect")](-h,-u,n,o),c&&i.strokeRect(-h,-u,n,o),i.restore()}class Kt{constructor(t){m(this,"visible",!0),m(this,"actionName",Ss),m(this,"angle",0),m(this,"x",0),m(this,"y",0),m(this,"offsetX",0),m(this,"offsetY",0),m(this,"sizeX",0),m(this,"sizeY",0),m(this,"touchSizeX",0),m(this,"touchSizeY",0),m(this,"cursorStyle","crosshair"),m(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,r,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(r,[o,a,l,c])}getActionHandler(t,e,r){return this.actionHandler}getMouseDownHandler(t,e,r){return this.mouseDownHandler}getMouseUpHandler(t,e,r){return this.mouseUpHandler}cursorStyleHandler(t,e,r){return e.cursorStyle}getActionName(t,e,r){return e.actionName}getVisibility(t,e){var r,s;return(r=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&r!==void 0?r:this.visible}setVisibility(t,e,r){this.visible=t}positionHandler(t,e,r,s){return new _(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,s,n,o){const a=Vi([Er(r,s),tr({angle:t}),Wi((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new _(-.5,-.5).transform(a),tr:new _(.5,-.5).transform(a),br:new _(.5,.5).transform(a),bl:new _(-.5,.5).transform(a)}}render(t,e,r,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Eu.call(this,t,e,r,s,n):Pu.call(this,t,e,r,s,n)}}const Au=(i,t,e)=>e.lockRotation?Fs:t.cursorStyle,Lu=nr($o,or((i,t,e,r)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if($t(s,"lockRotation"))return!1;const u=Math.atan2(o-h.y,n-h.x),d=Math.atan2(r-h.y,e-h.x);let g=pe(d-u+a);if(s.snapAngle&&s.snapAngle>0){const p=s.snapAngle,v=s.snapThreshold||p,b=Math.ceil(g/p)*p,x=Math.floor(g/p)*p;Math.abs(g-x)<v?g=x:Math.abs(g-b)<v&&(g=b)}g<0&&(g=360+g),g%=360;const f=s.angle!==g;return s.angle=g,f}));function za(i,t){const e=t.canvas,r=i[e.uniScaleKey];return e.uniformScaling&&!r||!e.uniformScaling&&r}function Ha(i,t,e){const r=$t(i,"lockScalingX"),s=$t(i,"lockScalingY");if(r&&s||!t&&(r||s)&&e||r&&t==="x"||s&&t==="y")return!0;const{width:n,height:o,strokeWidth:a}=i;return n===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const ju=["e","se","s","sw","w","nw","n","ne","e"],Br=(i,t,e)=>{const r=za(i,e);if(Ha(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",r))return Fs;const s=va(e,t);return"".concat(ju[s],"-resize")};function nn(i,t,e,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=za(i,n);let l,c,h,u,d,g;if(Ha(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Gi(t,t.originX,t.originY,e,r),d=o!=="y"?Math.sign(l.x||t.signX||1):1,g=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=g),$t(n,"lockScalingFlip")&&(t.signX!==d||t.signY!==g))return!1;if(u=n._getTransformedDimensions(),a&&!o){const v=Math.abs(l.x)+Math.abs(l.y),{original:b}=t,x=v/(Math.abs(u.x*b.scaleX/n.scaleX)+Math.abs(u.y*b.scaleY/n.scaleY));c=b.scaleX*x,h=b.scaleY*x}else c=Math.abs(l.x*n.scaleX/u.x),h=Math.abs(l.y*n.scaleY/u.y);fa(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=pa(t.originX),c*=-1,t.signX=d),t.signY!==g&&o!=="x"&&(t.originY=pa(t.originY),h*=-1,t.signY=g)}const f=n.scaleX,p=n.scaleY;return o?(o==="x"&&n.set(Et,c),o==="y"&&n.set(Vt,h)):(!$t(n,"lockScalingX")&&n.set(Et,c),!$t(n,"lockScalingY")&&n.set(Vt,h)),f!==n.scaleX||p!==n.scaleY}const Hs=nr(_s,or((i,t,e,r)=>nn(i,t,e,r))),Fu=nr(_s,or((i,t,e,r)=>nn(i,t,e,r,{by:"x"}))),Ru=nr(_s,or((i,t,e,r)=>nn(i,t,e,r,{by:"y"}))),Iu=["target","ex","ey","skewingSide"],on={x:{counterAxis:"y",scale:Et,skew:Ke,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Vt,skew:Ze,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Bu=["ns","nesw","ew","nwse"],zu=(i,t,e)=>{if(t.x!==0&&$t(e,"lockSkewingY")||t.y!==0&&$t(e,"lockSkewingX"))return Fs;const r=va(e,t)%4;return"".concat(Bu[r],"-resize")};function Va(i,t,e,r,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=on[i];if($t(n,l))return!1;const{origin:u,flip:d}=on[o],g=vt(e[u])*(n[d]?-1:1),f=-Math.sign(g)*(n[h]?-1:1),p=.5*-((n[c]===0&&Gi(e,$,$,r,s)[i]>0||n[c]>0?1:-1)*f)+.5;return nr(qo,or((b,x,D,C)=>function(O,S,j){let{target:T,ex:L,ey:H,skewingSide:W}=S,V=ot(S,Iu);const{skew:U}=on[O],X=j.subtract(new _(L,H)).divide(new _(T.scaleX,T.scaleY))[O],tt=T[U],Z=V[U],J=Math.tan(pt(Z)),A=O==="y"?T._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:T._getTransformedDimensions({scaleX:1,scaleY:1}).y,ht=2*X*W/Math.max(A,1)+J,ut=pe(Math.atan(ht));T.set(U,ut);const dt=tt!==T[U];if(dt&&O==="y"){const{skewX:k,scaleX:P}=T,E=T._getTransformedDimensions({skewY:tt}),I=T._getTransformedDimensions(),F=k!==0?E.x/I.x:1;F!==1&&T.set(Et,F*P)}return dt}(i,x,new _(D,C))))(t,y(y({},e),{},{[a]:p,skewingSide:f}),r,s)}const Hu=(i,t,e,r)=>Va("x",i,t,e,r),Vu=(i,t,e,r)=>Va("y",i,t,e,r);function Vs(i,t){return i[t.canvas.altActionKey]}const Ws=(i,t,e)=>{const r=Vs(i,e);return t.x===0?r?Ke:Vt:t.y===0?r?Ze:Et:""},ar=(i,t,e)=>Vs(i,e)?zu(0,t,e):Br(i,t,e),Wa=(i,t,e,r)=>Vs(i,t.target)?Vu(i,t,e,r):Fu(i,t,e,r),Xa=(i,t,e,r)=>Vs(i,t.target)?Hu(i,t,e,r):Ru(i,t,e,r),Ya=()=>({ml:new Kt({x:-.5,y:0,cursorStyleHandler:ar,actionHandler:Wa,getActionName:Ws}),mr:new Kt({x:.5,y:0,cursorStyleHandler:ar,actionHandler:Wa,getActionName:Ws}),mb:new Kt({x:0,y:.5,cursorStyleHandler:ar,actionHandler:Xa,getActionName:Ws}),mt:new Kt({x:0,y:-.5,cursorStyleHandler:ar,actionHandler:Xa,getActionName:Ws}),tl:new Kt({x:-.5,y:-.5,cursorStyleHandler:Br,actionHandler:Hs}),tr:new Kt({x:.5,y:-.5,cursorStyleHandler:Br,actionHandler:Hs}),bl:new Kt({x:-.5,y:.5,cursorStyleHandler:Br,actionHandler:Hs}),br:new Kt({x:.5,y:.5,cursorStyleHandler:Br,actionHandler:Hs}),mtr:new Kt({x:0,y:-.5,actionHandler:Lu,cursorStyleHandler:Au,offsetY:-40,withConnection:!0,actionName:Bi})}),Wu=()=>({mr:new Kt({x:.5,y:0,actionHandler:Ba,cursorStyleHandler:ar,actionName:Mr}),ml:new Kt({x:-.5,y:0,actionHandler:Ba,cursorStyleHandler:ar,actionName:Mr})}),Xu=()=>y(y({},Ya()),Wu());class zr extends ye{static getDefaults(){return y(y({},super.getDefaults()),zr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),zr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Ya()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,r=e.target,s=e.action;if(this===r&&s&&s.startsWith(Ss))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 r=Object.entries(this.oCoords);for(let s=r.length-1;s>=0;s--){const[n,o]=r[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(),r=Er(e.x,e.y),s=tr({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Ct(r,s),o=Ct(t,n),a=Ct(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Ms(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((u,d)=>{const g=u.positionHandler(c,a,this,u);h[d]=Object.assign(g,this._calcCornerCoords(u,g))}),h}_calcCornerCoords(t,e){const r=this.getTotalAngle();return{corner:t.calcCornerCoords(r,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(r,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(),r=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(pt(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=y({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},r);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:r,hasControls:s}=this,n=y({hasBorders:r,hasControls:s},e),o=this.getViewportTransform(),a=n.hasBorders,l=n.hasControls,c=Ct(o,this.calcTransformMatrix()),h=Ms(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(pt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let s;if(r&&r.forActiveSelection||this.group){const n=Ni(this.width,this.height,Es(e)),o=this.isStrokeAccountedForInDimensions()?Hi:(this.strokeUniform?new _().scalarAdd(this.canvas?this.canvas.getZoom():1):new _(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,r)}drawControlsConnectingLines(t,e){let r=!1;t.beginPath(),this.forEachControl((s,n)=>{s.withConnection&&s.getVisibility(this,n)&&(r=!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))}),r&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const r=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:n,cornerColor:o}=this,a=y({cornerStrokeColor:s,cornerDashArray:n,cornerColor:o},e);t.setTransform(r,0,0,r,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[r,s]=e;return this.setControlVisible(r,s)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const r=this.canvas.viewportTransform;e.save(),e.transform(r[0],r[1],r[2],r[3],r[4],r[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 Ua(i,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(i.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})}),i}m(zr,"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 yt extends zr{}Ua(yt,[_a]),R.setClass(yt),R.setClass(yt,"object");const Yu=(i,t,e,r)=>{const s=2*(r=Math.round(r))+1,{data:n}=i.getImageData(t-r,e-r,s,s);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0};class Na{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new _(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new _(1/this.options.scaleX,1/this.options.scaleY):new _(1,1)}createSideVector(t,e){const r=Ji(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new _(t);return e.y+=e.x*Math.tan(pt(this.options.skewY)),e.x+=e.y*Math.tan(pt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Uu=new _;class lr extends Na{static getOrthogonalRotationFactor(t,e){const r=e?tn(t,e):gu(t);return Math.abs(r)<Dr?-1:1}constructor(t,e,r,s){super(s),m(this,"AB",void 0),m(this,"AC",void 0),m(this,"alpha",void 0),m(this,"bisector",void 0),this.A=new _(t),this.B=new _(e),this.C=new _(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=tn(this.AB,this.AC),this.bisector=en(Aa(this.AB.eq(Uu)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),n=La(s),o=lr.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,r*o)}projectBevel(){const t=[];return(this.alpha%xs==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),r=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*r),n=this.options.strokeUniform?Qi(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Qi(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const r=[],s=new _(lr.getOrthogonalRotationFactor(this.bisector),lr.getOrthogonalRotationFactor(new _(this.bisector.y,this.bisector.x)));return[new _(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new _(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(n=>{ja(n,t,e)&&r.push(this.A.add(n))}),r}projectRoundWithSkew(t,e){const r=[],{skewX:s,skewY:n,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new _(Math.tan(pt(s)),Math.tan(pt(n))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new _(Math.sqrt(Math.max(h**2-u**2,0)),u),g=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),f=new _(g,Math.sqrt(Math.max(h**2-g**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(p=>this.applySkew(l?p.multiply(this.strokeUniformScalar):p)).forEach(p=>{ja(p,t,e)&&r.push(this.applySkew(this.A).add(p))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%xs==0,r=this.applySkew(this.A),s=t[e?0:2].subtract(r),n=t[e?1:0].subtract(r),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Ir(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 Ga extends Na{constructor(t,e,r){super(r),this.A=new _(t),this.T=new _(e)}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(La(s),r)}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 _(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 lr(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new _(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),r=this.scaleUnitVector(en(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(r);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 Nu=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const r=[];if(i.length===0)return r;const s=i.reduce((n,o)=>(n[n.length-1].eq(o)||n.push(new _(o)),n),[new _(i[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?r.push(...new Ga(n,n,t).project()):!e||o!==0&&o!==a.length-1?r.push(...new lr(n,l,c,t).project()):r.push(...new Ga(n,o===0?c:l,t).project())}),r},an=i=>{const t={};return Object.keys(i).forEach(e=>{t[e]={},Object.keys(i[e]).forEach(r=>{t[e][r]=y({},i[e][r])})}),t},Gu=i=>i.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let Hr;const ln=i=>{if(Hr||Hr||(Hr="Intl"in bs()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Hr){const t=Hr.segment(i);return Array.from(t).map(e=>{let{segment:r}=e;return r})}return $u(i)},$u=i=>{const t=[];for(let e,r=0;r<i.length;r++)(e=qu(i,r))!==!1&&t.push(e);return t},qu=(i,t)=>{const e=i.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return i.charAt(t);if(55296<=e&&e<=56319){if(i.length<=t+1)throw"High surrogate without following low surrogate";const s=i.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return i.charAt(t)+i.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const r=i.charCodeAt(t-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1},cn=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return i.fill!==t.fill||i.stroke!==t.stroke||i.strokeWidth!==t.strokeWidth||i.fontSize!==t.fontSize||i.fontFamily!==t.fontFamily||i.fontWeight!==t.fontWeight||i.fontStyle!==t.fontStyle||i.textDecorationThickness!==t.textDecorationThickness||i.textBackgroundColor!==t.textBackgroundColor||i.deltaY!==t.deltaY||e&&(i.overline!==t.overline||i.underline!==t.underline||i.linethrough!==t.linethrough)},Ku=(i,t)=>{const e=t.split(`
73
- `),r=[];let s=-1,n={};i=an(i);for(let o=0;o<e.length;o++){const a=ln(e[o]);if(i[o])for(let l=0;l<a.length;l++){s++;const c=i[o][l];c&&Object.keys(c).length>0&&(cn(n,c,!0)?r.push({start:s,end:s+1,style:c}):r[r.length-1].end++),n=c||{}}else s+=a.length,n={}}return r},Zu=(i,t)=>{if(!Array.isArray(i))return an(i);const e=t.split(Ii),r={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=ln(e[o]);for(let l=0;l<a.length;l++)s++,i[n]&&i[n].start<=s&&s<i[n].end&&(r[o]=r[o]||{},r[o][l]=y({},i[n].style),s===i[n].end-1&&n++)}return r},De=["display","transform",xt,"fill-opacity","fill-rule","opacity",Pt,"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 $a(i,t){const e=i.nodeName,r=i.getAttribute("class"),s=i.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,"")),r&&t.length){const a=r.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+n,"i"),t=t.replace(o,"")}return t.length===0}function Ju(i,t){let e=!0;const r=$a(i,t.pop());return r&&t.length&&(e=function(s,n){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&n.length;)a&&(o=n.pop()),a=$a(s=s.parentElement,o);return n.length===0}(i,t)),r&&e&&t.length===0}const Qu=i=>{var t;return(t=uu[i])!==null&&t!==void 0?t:i},td=new RegExp("(".concat(qt,")"),"gi"),ed=i=>Rs(i.replace(td," $1 ").replace(/,/gi," "));var qa,Ka,Za,Ja,Qa,tl,el;const Tt="(".concat(qt,")"),rd=String.raw(qa||(qa=re(["(skewX)(",")"],["(skewX)\\(","\\)"])),Tt),sd=String.raw(Ka||(Ka=re(["(skewY)(",")"],["(skewY)\\(","\\)"])),Tt),id=String.raw(Za||(Za=re(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Tt,Tt,Tt),nd=String.raw(Ja||(Ja=re(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Tt,Tt),od=String.raw(Qa||(Qa=re(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Tt,Tt),ad=String.raw(tl||(tl=re(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Tt,Tt,Tt,Tt,Tt,Tt),hn="(?:".concat(ad,"|").concat(od,"|").concat(id,"|").concat(nd,"|").concat(rd,"|").concat(sd,")"),ld="(?:".concat(hn,"*)"),cd=String.raw(el||(el=re(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),ld),hd=new RegExp(cd),ud=new RegExp(hn),dd=new RegExp(hn,"g");function un(i){const t=[];if(!(i=ed(i).replace(/\s*([()])\s*/gi,"$1"))||i&&!hd.test(i))return[...St];for(const e of i.matchAll(dd)){const r=ud.exec(e[0]);if(!r)continue;let s=St;const n=r.filter(f=>!!f),[,o,...a]=n,[l,c,h,u,d,g]=a.map(f=>parseFloat(f));switch(o){case"translate":s=Er(l,c);break;case Bi:s=tr({angle:l},{x:c,y:h});break;case Ss:s=Wi(l,c);break;case Ke:s=ra(l);break;case Ze:s=sa(l);break;case"matrix":s=[l,c,h,u,d,g]}t.push(s)}return Vi(t)}function gd(i,t,e,r){const s=Array.isArray(t);let n,o=t;if(i!==xt&&i!==Pt||t!==Mt){if(i==="strokeUniform")return t==="non-scaling-stroke";if(i==="strokeDashArray")o=t===Mt?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(i==="transformMatrix")o=e&&e.transformMatrix?Ct(e.transformMatrix,un(t)):un(t);else if(i==="visible")o=t!==Mt&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(i==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(i==="textAnchor")o=t==="start"?et:t==="end"?ft:$;else if(i==="charSpacing"||i===Ie)n=sr(t,r)/r*1e3;else if(i==="paintFirst"){const a=t.indexOf(xt),l=t.indexOf(Pt);o=xt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=Pt)}else{if(i==="href"||i==="xlink:href"||i==="font"||i==="id")return t;if(i==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(sr):sr(t,r)}}else o="";return!s&&isNaN(n)?o:n}function fd(i,t){const e=i.match(hu);if(!e)return;const r=e[1],s=e[3],n=e[4],o=e[5],a=e[6];r&&(t.fontStyle=r),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),n&&(t.fontSize=sr(n)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function pd(i,t){i.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[r,s]=e.split(":");t[r.trim().toLowerCase()]=s.trim()})}function md(i){const t={},e=i.getAttribute("style");return e&&(typeof e=="string"?pd(e,t):function(r,s){Object.entries(r).forEach(n=>{let[o,a]=n;a!==void 0&&(s[o.toLowerCase()]=a)})}(e,t)),t}const vd={stroke:"strokeOpacity",fill:"fillOpacity"};function be(i,t,e){if(!i)return{};let r,s={},n=Fi;i.parentNode&&Ea.test(i.parentNode.nodeName)&&(s=be(i.parentElement,t,e),s.fontSize&&(r=n=sr(s.fontSize)));const o=y(y(y({},t.reduce((c,h)=>{const u=i.getAttribute(h);return u&&(c[h]=u),c},{})),function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u={};for(const d in h)Ju(c,d.split(" "))&&(u=y(y({},u),h[d]));return u}(i,e)),md(i));o[Zi]&&i.setAttribute(Zi,o[Zi]),o[Ki]&&(r=sr(o[Ki],n),o[Ki]="".concat(r));const a={};for(const c in o){const h=Qu(c),u=gd(h,o[c],s,r);a[h]=u}a&&a.font&&fd(a.font,a);const l=y(y({},s),a);return Ea.test(i.nodeName)?l:function(c){const h=yt.getDefaults();return Object.entries(vd).forEach(u=>{let[d,g]=u;if(c[g]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;const f=new rt(c[d]);c[d]=f.setAlpha(it(f.getAlpha()*c[g],2)).toRgba()}),c}(l)}const yd=["left","top","width","height","visible"],rl=["rx","ry"];class Lt extends yt{static getDefaults(){return y(y({},super.getDefaults()),Lt.ownDefaults)}constructor(t){super(),Object.assign(this,Lt.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:r}=this,s=-e/2,n=-r/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,r/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-ke*o,n,s+e,n+ke*a,s+e,n+a),t.lineTo(s+e,n+r-a),l&&t.bezierCurveTo(s+e,n+r-ke*a,s+e-ke*o,n+r,s+e-o,n+r),t.lineTo(s+o,n+r),l&&t.bezierCurveTo(s+ke*o,n+r,s,n+r-ke*a,s,n+r-a),t.lineTo(s,n+a),l&&t.bezierCurveTo(s,n+ke*a,s+ke*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([...rl,...t])}_toSVG(){const{width:t,height:e,rx:r,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(r,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
74
- `)]}static async fromElement(t,e,r){const s=be(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=ot(s,yd);return new this(y(y(y({},e),h),{},{left:n,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}m(Lt,"type","Rect"),m(Lt,"cacheProperties",[...ve,...rl]),m(Lt,"ownDefaults",{rx:0,ry:0}),m(Lt,"ATTRIBUTE_NAMES",[...De,"x","y","rx","ry","width","height"]),R.setClass(Lt),R.setSVGClass(Lt);const we="initialization",Xs="added",dn="removed",Ys="imperative",sl=(i,t)=>{const{strokeUniform:e,strokeWidth:r,width:s,height:n,group:o}=t,a=o&&o!==i?js(o.calcTransformMatrix(),i.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?su(new _(r,r),void 0,i.calcTransformMatrix()):Hi,u=!e&&c?r:0,d=Ni(s+u,n+u,Vi([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class Us{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:s}=t;return e===we||e===Ys||!!r&&s!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==we&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:r,target:s}=e;if(r===Ys&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=me(t.map(u=>sl(s,u)).reduce((u,d)=>u.concat(d),[])),c=new _(a,l),h=new _(n,o).add(c.scalarDivide(2));if(r===we){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new _(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}m(Us,"type","strategy");class gn extends Us{shouldPerformLayout(t){return!0}}m(gn,"type","fit-content"),R.setClass(gn);const bd=["strategy"],wd=["target","strategy","bubbles","prevStrategy"],il="layoutManager";class Vr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new gn;m(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 r=this.getLayoutResult(e);r&&this.commitLayout(e,r),this.onAfterLayout(e,r),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:r}=e;return[Ts,Go,Mr,$o,_s,qo,Cs,Wh,Xh].map(s=>t.on(s,n=>this.performLayout(s===Ts?{type:"object_modified",trigger:s,e:n,target:r}:{type:"object_modifying",trigger:s,e:n,target:r})))}subscribe(t,e){this.unsubscribe(t,e);const r=this.attachHandlers(t,e);this._subscriptions.set(t,r)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(r=>r()),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:r}=t,{canvas:s}=e;if(r===we||r===Xs?this.subscribeTargets(t):r===dn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),r===Ys&&t.deep){const n=ot(t,bd);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(y(y({},n),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:r,type:s}=t,n=r.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===we?new _:e.getRelativeCenterPoint(),{center:a,correction:l=new _,relativeCorrection:c=new _}=n,h=o.subtract(a).add(l).transform(s===we?St:Nt(e.calcOwnMatrix()),!0).add(c);return{result:n,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:r}=t,{result:{size:s},nextCenter:n}=e;var o,a;r.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===we?r.set({left:(o=t.x)!==null&&o!==void 0?o:n.x+s.x*vt(r.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*vt(r.originY)}):(r.setPositionByOrigin(n,$,$),r.setCoords(),r.set("dirty",!0))}layoutObjects(t,e){const{target:r}=t;r.forEachObject(s=>{s.group===r&&this.layoutObject(t,e,s)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,r.clipPath)}layoutObject(t,e,r){let{offset:s}=e;r.set({left:r.left+s.x,top:r.top+s.y})}onAfterLayout(t,e){const{target:r,strategy:s,bubbles:n,prevStrategy:o}=t,a=ot(t,wd),{canvas:l}=r;r.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:r});const c=r.parent;n&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(r),c.layoutManager.performLayout(y(y({},a),{},{target:c}))),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(r=>r())),t.clear()}toObject(){return{type:il,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}R.setClass(Vr,il);const xd=["type","objects","layoutManager"];class _d extends Vr{performLayout(){}}class Me extends Ko(yt){static getDefaults(){return y(y({},super.getDefaults()),Me.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),m(this,"_activeObjects",[]),m(this,"__objectSelectionTracker",void 0),m(this,"__objectSelectionDisposer",void 0),Object.assign(this,Me.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var r;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=(r=e.layoutManager)!==null&&r!==void 0?r:new Vr,this.layoutManager.performLayout({type:we,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Te("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Te("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,r,s)=>this.canEnterGroup(e)&&s.indexOf(e)===r)}add(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const s=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...s);return this._onAfterObjectsChange(Xs,s),n}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;s<e;s++)r[s-1]=arguments[s];const n=this._filterObjectsBeforeEnteringGroup(r),o=super.insertAt(t,...n);return this._onAfterObjectsChange(Xs,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(dn,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 r=this[t];return super._set(t,e),t==="canvas"&&r!==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:r}=e;const s=this._activeObjects;if(t)s.push(r),this._set("dirty",!0);else if(s.length>0){const n=s.indexOf(r);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&&Ls(t,Ct(Nt(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const r=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();r&&(r===t||t.isDescendantOf(r))&&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||(Ls(t,Ct(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const r=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;r>-1&&this._activeObjects.splice(r,1)}shouldCache(){const t=yt.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,r){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(...Nt(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,r)}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:Ys},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const r=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const n=s.includeDefaultValues;s.includeDefaultValues=r;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=Lt.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
72
+ `}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=ne.ownDefaults;return this.includeDefaultValues?t:Ui(t,(r,s)=>r!==e[s])}static async fromObject(t){return new this(t)}}v(ne,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(ne,"type","shadow"),j.setClass(ne,"shadow");const or=(i,t,e)=>Math.max(i,Math.min(t,e)),bu=[Et,Q,At,Vt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Je,Qe],me=[_t,Rt,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],wu={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:Y,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:_t,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},xu=(i,t,e,r)=>-e*Math.cos(i/r*Er)+e+t,_u=()=>!1;class nn{constructor(t){let{startValue:e,byValue:r,duration:s=500,delay:n=0,easing:o=xu,onStart:a=xs,onChange:l=xs,onComplete:c=xs,abort:h=_u,target:u}=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=u,this.startValue=e,this.byValue=r,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(()=>Ds(t),this.delay):Ds(t)}tick(t){const e=(t||+new Date)-this.startTime,r=Math.min(e,this.duration);this.durationProgress=r/this.duration;const{value:s,valueProgress:n}=this.calculate(r);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),Ds(this.tick)))}register(){Ts.push(this)}unregister(){Ts.remove(this)}abort(){this._state="aborted",this.unregister()}}class Cu extends nn{constructor(t){let{startValue:e=0,endValue:r=100,...s}=t;super({...s,startValue:e,byValue:r-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)}}}class Su extends nn{constructor(t){let{startValue:e=[0],endValue:r=[100],...s}=t;super({...s,startValue:e,byValue:r.map((n,o)=>n-e[o])})}calculate(t){const e=this.startValue.map((r,s)=>this.easing(t,r,this.byValue[s],this.duration,s));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const ku=(i,t,e,r)=>t+e*(1-Math.cos(i/r*Er)),on=i=>i&&((t,e,r)=>i(new rt(t).toRgba(),e,r));class Tu extends nn{constructor(t){let{startValue:e,endValue:r,easing:s=ku,onChange:n,onComplete:o,abort:a,...l}=t;const c=new rt(e).getSource(),h=new rt(r).getSource();super({...l,startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:s,onChange:on(n),onComplete:on(o),abort:on(a)})}calculate(t){const[e,r,s,n]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,r,s].map(Math.round),or(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 Ra(i){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(i)?new Su(i):new Cu(i);return t.start(),t}function Ou(i){const t=new Tu(i);return t.start(),t}class ct{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),r=0;r<t;r++)e[r]=arguments[r];return this.points=this.points.concat(e.filter(s=>!this.includes(s))),this}static isPointContained(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(r))return t.eq(e);if(e.x===r.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,r.y)&&t.y<=Math.max(e.y,r.y));if(e.y===r.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,r.x)&&t.x<=Math.max(e.x,r.x));{const n=js(e,r),o=js(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 r=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,r);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,r,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-r.x,h=s.y-r.y,u=t.x-r.x,d=t.y-r.y,g=c*d-h*u,f=a*d-l*u,m=h*a-c*l;if(m!==0){const y=g/m,b=f/m;return(n||0<=y&&y<=1)&&(o||0<=b&&b<=1)?new ct("Intersection").append(new x(t.x+y*a,t.y+y*l)):new ct}if(g===0||f===0){const y=n||o||ct.isPointContained(t,r,s)||ct.isPointContained(e,r,s)||ct.isPointContained(r,t,e)||ct.isPointContained(s,t,e);return new ct(y?"Coincident":void 0)}return new ct("Parallel")}static intersectSegmentLine(t,e,r,s){return ct.intersectLineLine(t,e,r,s,!1,!0)}static intersectSegmentSegment(t,e,r,s){return ct.intersectLineLine(t,e,r,s,!1,!1)}static intersectLinePolygon(t,e,r){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new ct,o=r.length;for(let a,l,c,h=0;h<o;h++){if(a=r[h],l=r[(h+1)%o],c=ct.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,r){return ct.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=new ct,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ct.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(n.push(c),r.append(a,l)):r.append(...c.points)}return n.length>0&&n.length===t.length?new ct("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(t,e,r){const s=e.min(r),n=e.max(r),o=new x(n.x,s.y),a=new x(s.x,n.y);return ct.intersectPolygonPolygon(t,[s,o,n,a])}}class Du extends ea{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?Lt(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=Lt(t,Ut(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:r,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,r,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map(a=>Lt(a,o))}return n}intersectsWithRect(t,e){return ct.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ct.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:r,top:s,width:n,height:o}=this.getBoundingRect();return r>=t.x&&r+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 ct.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(r=>r.x<=e.x&&r.x>=t.x&&r.y<=e.y&&r.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(r=>(r.x>=e.x||r.x<=t.x)&&(r.y>=e.y||r.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return pe(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(At,t),this._set(Vt,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?Te(ia(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Tt.concat()}calcACoords(){const t=rr({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),s=Ar(e,r),n=Ct(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Lt({x:-a,y:-l},n),tr:Lt({x:a,y:-l},n),bl:Lt({x:-a,y:l},n),br:Lt({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,Ot(this.originX),Ot(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 r=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every((n,o)=>n===r[o])?s.value:(this.group&&(e=Ct(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:r,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key.every((o,a)=>o===t[a]))return e.value;const r=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:r.x,translateY:r.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=eu(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},r=e.strokeWidth;let s=r,n=0;this.strokeUniform&&(s=0,n=r);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):Ki(o,a,Es(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,r,s,n){let o=t.x,a=t.y;const l=Ot(s)-Ot(e),c=Ot(n)-Ot(r);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,r){if(e===Y&&r===Y)return t;const s=this.translateToGivenOrigin(t,e,r,Y,Y);return this.angle?s.rotate(pt(this.angle),t):s}translateToOriginPoint(t,e,r){const s=this.translateToGivenOrigin(t,Y,Y,e,r);return this.angle?s.rotate(pt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Lt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.getPositionByOrigin(t,e)}getPositionByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,r){const s=this.translateToCenterPoint(t,e,r),n=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.getPositionByOrigin(Q,Et)}positionByLeftTop(t){return this.setPositionByOrigin(t,Q,Et)}}let ve=class vi extends Du{static getDefaults(){return vi.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Ce("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,vi.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=fe(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,r=t.height,s=tt.maxCacheSideLimit,n=tt.minCacheSideLimit;if(e<=s&&r<=s&&e*r<=tt.perfLimitSizeTotal)return e<n&&(t.width=n),r<n&&(t.height=n),t;const o=e/r,[a,l]=Mr.limitDimsByArea(o),c=or(n,a,s),h=or(n,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),r>h&&(t.zoomY/=r/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),r=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(r+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:r,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:r,height:s,zoomX:n,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=r!==t.width||s!==t.height,h=this.zoomX!==n||this.zoomY!==o;if(!t||!e)return!1;if(c||h){r!==t.width||s!==t.height?(t.width=r,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,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,r=this.calcTransformMatrix(!e);t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Ms(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(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}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!==At&&t!==Vt||(e=this._constrainScale(e)),t===At&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ne||(e=new ne(e));const r=this[t]!==e;return this[t]=e,r&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||r&&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:r,cacheTranslationX:s,cacheTranslationY:n}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,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===Rt&&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,r){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0),t.restore()}drawObject(t,e,r){const s=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this.fire("before:render",{ctx:t}),this._render(t),this._drawClipPath(t,this.clipPath,r),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const r=Wt(e),s=r.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=r,e.parentClipPaths.forEach(n=>{n.transform(s)}),e.parentClipPaths.push(t),t.absolutePositioned){const n=Ut(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),r}_drawClipPath(t,e,r){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,r);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,r=this._cacheContext;return!(!e||!r||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&r&&!t&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.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 r=e.stroke;r&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,Xt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?this._applyPatternForTransformedGradient(t,r):(t.strokeStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:r}=e;r&&(Xt(r)?(t.fillStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.fillStyle=r)}_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,r=this.canvas,s=this.getCanvasRetinaScaling(),[n,,,o]=(r==null?void 0:r.viewportTransform)||Tt,a=n*s,l=o*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*tt.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(!Xt(e))return{offsetX:0,offsetY:0};const r=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),r&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),{offsetX:s,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===Rt?(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 r;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/n,a=s.y/this.scaleY/n,l=Wt({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=(r=c.createPattern(l,"no-repeat"))!==null&&r!==void 0?r:"")}_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(j.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=ma(this),r=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?Ko():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(w=>new Ir(w,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&lu(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&hu(this,this.getViewportTransform()),this.setCoords();const c=fe(),h=this.getBoundingRect(),u=this.shadow,d=new x;if(u){const w=u.blur,T=u.nonScaling?new x(1,1):this.getObjectScaling();d.x=2*Math.round(n(u.offsetX)+w)*n(T.x),d.y=2*Math.round(n(u.offsetY)+w)*n(T.y)}const g=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(g),c.height=Math.ceil(f);const m=l(c);t.format==="jpeg"&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new x(m.width/2,m.height/2),Y,Y);const y=this.canvas;m._objects=[this],this.set("canvas",m),this.setCoords();const b=m.toCanvasElement(a||1,t);return this.set("canvas",y),this.shadow=s,r&&(this.group=r),this.set(e),this.setCoords(),m._objects=[],m.destroy(),b}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ra(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return sa(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:r,originY:s}=this;if(e){const{x:n,y:o}=this.getRelativeCenterPoint();this.originX=Y,this.originY=Y,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.getPositionByOrigin(r,s);this.left=n,this.top=o,this.originX=r,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Ts.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&se().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((r,s)=>{let[n,o]=s;return r[n]=this._animate(n,o,e),r},{})}_animate(t,e){let r=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}=r,h={...r,target:this,startValue:a??s.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,g)=>{s.reduce((f,m,y)=>(y===s.length-1&&(f[m]=u),f[m]),this),l&&l(u,d,g)},onComplete:(u,d,g)=>{this.setCoords(),c&&c(u,d,g)}};return n?Ou(h):Ra(h)}isDescendantOf(t){const{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.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(),r=t.getAncestors();if(e.length===0&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.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<r.length;o++){if(this===r[o])return{fork:[],otherFork:[t,...r.slice(0,o)],common:[this,...e]};if(s===r[o])return{fork:[this,...e.slice(0,n)],otherFork:[t,...r.slice(0,o)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...r],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 r=e.common[0]||this.canvas;if(!r)return;const s=e.fork.pop(),n=e.otherFork.pop(),o=r._objects.indexOf(s),a=r._objects.indexOf(n);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(vi.customProperties,this.constructor.customProperties||[]);let e;const r=tt.NUM_FRACTION_DIGITS,{clipPath:s,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:g,height:f,strokeWidth:m,strokeLineCap:y,strokeDashOffset:b,strokeLineJoin:w,strokeUniform:T,strokeMiterLimit:C,scaleX:S,scaleY:D,angle:A,flipX:_,flipY:M,opacity:O,visible:V,backgroundColor:z,fillRule:X,paintFirst:W,globalCompositeOperation:G,skewX:K,skewY:Z}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const L=mt=>nt(mt,r),wt={...sr(this,t),type:this.constructor.type,version:ji,originX:u,originY:d,left:L(c),top:L(h),width:L(g),height:L(f),fill:la(n)?n.toObject():n,stroke:la(o)?o.toObject():o,strokeWidth:L(m),strokeDashArray:l&&l.concat(),strokeLineCap:y,strokeDashOffset:b,strokeLineJoin:w,strokeUniform:T,strokeMiterLimit:L(C),scaleX:L(S),scaleY:L(D),angle:L(A),flipX:_,flipY:M,opacity:L(O),shadow:a&&a.toObject(),visible:V,backgroundColor:z,fillRule:X,paintFirst:W,globalCompositeOperation:G,skewX:L(K),skewY:L(Z),...e?{clipPath:e}:null};return this.includeDefaultValues?wt:this._removeDefaultValues(wt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Ui(t,(s,n)=>{if(n===Q||n===Et||n==="type")return!0;const o=r[n];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)})}toString(){return`#<${this.constructor.type}>`}static _fromObject(t){let{type:e,...r}=t,{extraParam:s,...n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return As(r,n).then(o=>s?(delete o[s],new this(r[s],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};v(ve,"stateProperties",bu),v(ve,"cacheProperties",me),v(ve,"ownDefaults",wu),v(ve,"type","FabricObject"),v(ve,"colorProperties",[_t,Rt,"backgroundColor"]),v(ve,"customProperties",[]),j.setClass(ve),j.setClass(ve,"object");const $a=(i,t)=>{var e;const{transform:{target:r}}=t;(e=r.canvas)===null||e===void 0||e.fire(`object:${i}`,{...t,target:r}),r.fire(i,t)},ar=(i,t,e)=>(r,s,n,o)=>{const a=t(r,s,n,o);return a&&$a(i,{...Sa(r,s,n,o),...e}),a};function lr(i){return(t,e,r,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getPositionByOrigin(o,a),c=i(t,e,r,s);return n.setPositionByOrigin(l,e.originX,e.originY),c}}const Mu=(i,t,e,r)=>(s,n,o,a)=>{const l=tn(n,n.originX,n.originY,o,a)[e],c=Ot(n[t]);if(c===0||c>0&&l<0||c<0&&l>0){const{target:h}=n,u=h.strokeWidth/(h.strokeUniform?h[r]:1),d=_a(n)?2:1,g=h[i],f=Math.abs(l*d/h[r])-u;return h.set(i,Math.max(f,1)),g!==h[i]}return!1},Eu=Mu("width","originX","x","scaleX"),za=ar(Pr,lr(Eu));function Pu(i,t,e,r,s){i.save();const{stroke:n,xSize:o,ySize:a,opName:l}=this.commonRenderProps(i,t,e,s,r);let c=o;o>a?i.scale(1,a/o):a>o&&(c=a,i.scale(o/a,1)),i.beginPath(),i.arc(0,0,c/2,0,Ze,!1),i[l](),n&&i.stroke(),i.restore()}function Au(i,t,e,r,s){i.save();const{stroke:n,xSize:o,ySize:a,opName:l}=this.commonRenderProps(i,t,e,s,r),c=o/2,h=a/2;i[`${l}Rect`](-c,-h,o,a),n&&i.strokeRect(-c,-h,o,a),i.restore()}class qt{constructor(t){v(this,"visible",!0),v(this,"actionName",Ss),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)}getTransformAnchorPoint(){var t;return(t=this.transformAnchorPoint)!==null&&t!==void 0?t:new x(.5-this.x,.5-this.y)}shouldActivate(t,e,r,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)&&ct.isPointInPolygon(r,[o,a,l,c])}getActionHandler(t,e,r){return this.actionHandler}getMouseDownHandler(t,e,r){return this.mouseDownHandler}getMouseUpHandler(t,e,r){return this.mouseUpHandler}cursorStyleHandler(t,e,r,s){return e.cursorStyle}getActionName(t,e,r){return e.actionName}getVisibility(t,e){var r,s;return(r=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&r!==void 0?r:this.visible}setVisibility(t,e,r){this.visible=t}positionHandler(t,e,r,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,s,n,o){const a=Xi([Ar(r,s),rr({angle:t}),Yi((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)}}commonRenderProps(t,e,r,s){let n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const{cornerSize:o,cornerColor:a,transparentCorners:l,cornerStrokeColor:c}=n,h=o||s.cornerSize,u=this.sizeX||h,d=this.sizeY||h,g=l!==void 0?l:s.transparentCorners,f=g?Rt:_t,m=c||s.cornerStrokeColor,y=!g&&!!m;return t.fillStyle=a||s.cornerColor||"",t.strokeStyle=m||"",t.translate(e,r),t.rotate(pt(s.getTotalAngle())),{stroke:y,xSize:u,ySize:d,transparentCorners:g,opName:f}}render(t,e,r,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Pu.call(this,t,e,r,s,n):Au.call(this,t,e,r,s,n)}}const Lu=(i,t,e)=>e.lockRotation?Is:t.cursorStyle,Fu=ar(Jo,lr((i,t,e,r)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.getPositionByOrigin(l,c);if(Nt(s,"lockRotation"))return!1;const u=Math.atan2(o-h.y,n-h.x),d=Math.atan2(r-h.y,e-h.x);let g=Te(d-u+a);if(s.snapAngle&&s.snapAngle>0){const m=s.snapAngle,y=s.snapThreshold||m,b=Math.ceil(g/m)*m,w=Math.floor(g/m)*m;Math.abs(g-w)<y?g=w:Math.abs(g-b)<y&&(g=b)}g<0&&(g=360+g),g%=360;const f=s.angle!==g;return s.angle=g,f}));function Ha(i,t){const e=t.canvas,r=i[e.uniScaleKey];return e.uniformScaling&&!r||!e.uniformScaling&&r}function Va(i,t,e){const r=Nt(i,"lockScalingX"),s=Nt(i,"lockScalingY");if(r&&s||!t&&(r||s)&&e||r&&t==="x"||s&&t==="y")return!0;const{width:n,height:o,strokeWidth:a}=i;return n===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const ju=["e","se","s","sw","w","nw","n","ne","e"],Hr=(i,t,e,r)=>{const s=Ha(i,e);if(Va(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",s))return Is;const n=ka(e,0,r);return`${ju[n]}-resize`};function an(i,t,e,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=Ha(i,n);let l,c,h,u,d,g;if(Va(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=tn(t,t.originX,t.originY,e,r),d=o!=="y"?Math.sign(l.x||t.signX||1):1,g=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=g),Nt(n,"lockScalingFlip")&&(t.signX!==d||t.signY!==g))return!1;if(u=n._getTransformedDimensions(),a&&!o){const y=Math.abs(l.x)+Math.abs(l.y),{original:b}=t,w=y/(Math.abs(u.x*b.scaleX/n.scaleX)+Math.abs(u.y*b.scaleY/n.scaleY));c=b.scaleX*w,h=b.scaleY*w}else c=Math.abs(l.x*n.scaleX/u.x),h=Math.abs(l.y*n.scaleY/u.y);_a(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=Ca(t.originX),c*=-1,t.signX=d),t.signY!==g&&o!=="x"&&(t.originY=Ca(t.originY),h*=-1,t.signY=g)}const f=n.scaleX,m=n.scaleY;return o?(o==="x"&&n.set(At,c),o==="y"&&n.set(Vt,h)):(!Nt(n,"lockScalingX")&&n.set(At,c),!Nt(n,"lockScalingY")&&n.set(Vt,h)),f!==n.scaleX||m!==n.scaleY}const Hs=ar(_s,lr((i,t,e,r)=>an(i,t,e,r))),Iu=ar(_s,lr((i,t,e,r)=>an(i,t,e,r,{by:"x"}))),Bu=ar(_s,lr((i,t,e,r)=>an(i,t,e,r,{by:"y"}))),ln={x:{counterAxis:"y",scale:At,skew:Je,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Vt,skew:Qe,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Ru=["ns","nesw","ew","nwse"],$u=(i,t,e,r)=>{if(t.x!==0&&Nt(e,"lockSkewingY")||t.y!==0&&Nt(e,"lockSkewingX"))return Is;const s=ka(e,0,r)%4;return`${Ru[s]}-resize`};function Wa(i,t,e,r,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=ln[i];if(Nt(n,l))return!1;const{origin:u,flip:d}=ln[o],g=Ot(e[u])*(n[d]?-1:1),f=-Math.sign(g)*(n[h]?-1:1),m=.5*-((n[c]===0&&tn(e,Y,Y,r,s)[i]>0||n[c]>0?1:-1)*f)+.5;return ar(Qo,lr((b,w,T,C)=>function(S,D,A){let{target:_,ex:M,ey:O,skewingSide:V,...z}=D;const{skew:X}=ln[S],W=A.subtract(new x(M,O)).divide(new x(_.scaleX,_.scaleY))[S],G=_[X],K=z[X],Z=Math.tan(pt(K)),L=S==="y"?_._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:_._getTransformedDimensions({scaleX:1,scaleY:1}).y,wt=2*W*V/Math.max(L,1)+Z,mt=Te(Math.atan(wt));_.set(X,mt);const lt=G!==_[X];if(lt&&S==="y"){const{skewX:k,scaleX:P}=_,E=_._getTransformedDimensions({skewY:G}),B=_._getTransformedDimensions(),I=k!==0?E.x/B.x:1;I!==1&&_.set(At,I*P)}return lt}(i,w,new x(T,C))))(t,{...e,[a]:m,skewingSide:f},r,s)}const zu=(i,t,e,r)=>Wa("x",i,t,e,r),Hu=(i,t,e,r)=>Wa("y",i,t,e,r);function Vs(i,t){return i[t.canvas.altActionKey]}const Ws=(i,t,e)=>{const r=Vs(i,e);return t.x===0?r?Je:Vt:t.y===0?r?Qe:At:""},cr=(i,t,e,r)=>Vs(i,e)?$u(0,t,e,r):Hr(i,t,e,r),Xa=(i,t,e,r)=>Vs(i,t.target)?Hu(i,t,e,r):Iu(i,t,e,r),Ya=(i,t,e,r)=>Vs(i,t.target)?zu(i,t,e,r):Bu(i,t,e,r),Ua=()=>({ml:new qt({x:-.5,y:0,cursorStyleHandler:cr,actionHandler:Xa,getActionName:Ws}),mr:new qt({x:.5,y:0,cursorStyleHandler:cr,actionHandler:Xa,getActionName:Ws}),mb:new qt({x:0,y:.5,cursorStyleHandler:cr,actionHandler:Ya,getActionName:Ws}),mt:new qt({x:0,y:-.5,cursorStyleHandler:cr,actionHandler:Ya,getActionName:Ws}),tl:new qt({x:-.5,y:-.5,cursorStyleHandler:Hr,actionHandler:Hs}),tr:new qt({x:.5,y:-.5,cursorStyleHandler:Hr,actionHandler:Hs}),bl:new qt({x:-.5,y:.5,cursorStyleHandler:Hr,actionHandler:Hs}),br:new qt({x:.5,y:.5,cursorStyleHandler:Hr,actionHandler:Hs}),mtr:new qt({x:0,y:-.5,actionHandler:Fu,cursorStyleHandler:Lu,offsetY:-40,withConnection:!0,actionName:zi})}),Vu=()=>({mr:new qt({x:.5,y:0,actionHandler:za,cursorStyleHandler:cr,actionName:Pr}),ml:new qt({x:-.5,y:0,actionHandler:za,cursorStyleHandler:cr,actionName:Pr})}),Wu=()=>({...Ua(),...Vu()});class Vr extends ve{static getDefaults(){return{...super.getDefaults(),...Vr.ownDefaults}}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Vr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Ua()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,r=e.target,s=e.action;if(this===r&&s&&s.startsWith(Ss))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 r=Object.entries(this.oCoords);for(let s=r.length-1;s>=0;s--){const[n,o]=r[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(),r=Ar(e.x,e.y),s=rr({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Ct(r,s),o=Ct(t,n),a=Ct(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Ms(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((u,d)=>{const g=u.positionHandler(c,a,this,u);h[d]=Object.assign(g,this._calcCornerCoords(u,g))}),h}_calcCornerCoords(t,e){const r=this.getTotalAngle();return{corner:t.calcCornerCoords(r,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(r,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(),r=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(pt(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s={hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray,...r};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:r,hasControls:s}=this,n={hasBorders:r,hasControls:s,...e},o=this.getViewportTransform(),a=n.hasBorders,l=n.hasControls,c=Ct(o,this.calcTransformMatrix()),h=Ms(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(pt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let s;if(r&&r.forActiveSelection||this.group){const n=Ki(this.width,this.height,Es(e)),o=this.isStrokeAccountedForInDimensions()?Wi:(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,r)}drawControlsConnectingLines(t,e){let r=!1;t.beginPath(),this.forEachControl((s,n)=>{s.withConnection&&s.getVisibility(this,n)&&(r=!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))}),r&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const r=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:n,cornerColor:o}=this,a={cornerStrokeColor:s,cornerDashArray:n,cornerColor:o,...e};t.setTransform(r,0,0,r,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[r,s]=e;return this.setControlVisible(r,s)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const r=this.canvas.viewportTransform;e.save(),e.transform(r[0],r[1],r[2],r[3],r[4],r[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 Ga(i,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(i.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})}),i}v(Vr,"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 ut extends Vr{}Ga(ut,[Ea]),j.setClass(ut),j.setClass(ut,"object");const Xu=(i,t,e,r)=>{const s=2*(r=Math.round(r))+1,{data:n}=i.getImageData(t-r,e-r,s,s);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0};class Na{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 r=js(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(pt(this.options.skewY)),e.x+=e.y*Math.tan(pt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Yu=new x;class hr extends Na{static getOrthogonalRotationFactor(t,e){const r=e?Ji(t,e):ba(t);return Math.abs(r)<Er?-1:1}constructor(t,e,r,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(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Ji(this.AB,this.AC),this.bisector=Qi(ya(this.AB.eq(Yu)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),n=wa(s),o=hr.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,r*o)}projectBevel(){const t=[];return(this.alpha%Ze===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),r=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*r),n=this.options.strokeUniform?Zi(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Zi(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const r=[],s=new x(hr.getOrthogonalRotationFactor(this.bisector),hr.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=>{xa(n,t,e)&&r.push(this.A.add(n))}),r}projectRoundWithSkew(t,e){const r=[],{skewX:s,skewY:n,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(pt(s)),Math.tan(pt(n))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new x(Math.sqrt(Math.max(h**2-u**2,0)),u),g=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),f=new x(g,Math.sqrt(Math.max(h**2-g**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(m=>this.applySkew(l?m.multiply(this.strokeUniformScalar):m)).forEach(m=>{xa(m,t,e)&&r.push(this.applySkew(this.A).add(m))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Ze===0,r=this.applySkew(this.A),s=t[e?0:2].subtract(r),n=t[e?1:0].subtract(r),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Br(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 qa extends Na{constructor(t,e,r){super(r),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(wa(s),r)}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 hr(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),r=this.scaleUnitVector(Qi(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(r);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 Uu=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const r=[];if(i.length===0)return r;const s=i.reduce((n,o)=>(n[n.length-1].eq(o)||n.push(new x(o)),n),[new x(i[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?r.push(...new qa(n,n,t).project()):!e||o!==0&&o!==a.length-1?r.push(...new hr(n,l,c,t).project()):r.push(...new qa(n,o===0?c:l,t).project())}),r},cn=i=>{const t={};return Object.keys(i).forEach(e=>{t[e]={},Object.keys(i[e]).forEach(r=>{t[e][r]={...i[e][r]}})}),t},hn=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return i.fill!==t.fill||i.stroke!==t.stroke||i.strokeWidth!==t.strokeWidth||i.fontSize!==t.fontSize||i.fontFamily!==t.fontFamily||i.fontWeight!==t.fontWeight||i.fontStyle!==t.fontStyle||i.textDecorationThickness!==t.textDecorationThickness||i.textBackgroundColor!==t.textBackgroundColor||i.deltaY!==t.deltaY||e&&(i.overline!==t.overline||i.underline!==t.underline||i.linethrough!==t.linethrough)},Gu=(i,t)=>{const e=t.split(`
73
+ `),r=[];let s=-1,n={};i=cn(i);for(let o=0;o<e.length;o++){const a=Ni(e[o]);if(i[o])for(let l=0;l<a.length;l++){s++;const c=i[o][l];c&&Object.keys(c).length>0&&(hn(n,c,!0)?r.push({start:s,end:s+1,style:c}):r[r.length-1].end++),n=c||{}}else s+=a.length,n={}}return r},Nu=(i,t)=>{if(!Array.isArray(i))return cn(i);const e=t.split($i),r={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=Ni(e[o]);for(let l=0;l<a.length;l++)s++,i[n]&&i[n].start<=s&&s<i[n].end&&(r[o]=r[o]||{},r[o][l]={...i[n].style},s===i[n].end-1&&n++)}return r},Oe=["display","transform",_t,"fill-opacity","fill-rule","opacity",Rt,"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 Ka(i,t){const e=i.nodeName,r=i.getAttribute("class"),s=i.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,"")),r&&t.length){const a=r.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+n,"i"),t=t.replace(o,"")}return t.length===0}function qu(i,t){let e=!0;const r=Ka(i,t.pop());return r&&t.length&&(e=function(s,n){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&n.length;)a&&(o=n.pop()),a=Ka(s=s.parentElement,o);return n.length===0}(i,t)),r&&e&&t.length===0}function Ku(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e={};for(const r in t)qu(i,r.split(" "))&&(e={...e,...t[r]});return e}const Zu=i=>{var t;return(t=yu[i])!==null&&t!==void 0?t:i},Ju=new RegExp(`(${Re})`,"gi"),Dt=`(${Re})`,Qu=String.raw`(skewX)\(${Dt}\)`,td=String.raw`(skewY)\(${Dt}\)`,ed=String.raw`(rotate)\(${Dt}(?: ${Dt} ${Dt})?\)`,rd=String.raw`(scale)\(${Dt}(?: ${Dt})?\)`,sd=String.raw`(translate)\(${Dt}(?: ${Dt})?\)`,un=`(?:${String.raw`(matrix)\(${Dt} ${Dt} ${Dt} ${Dt} ${Dt} ${Dt}\)`}|${sd}|${ed}|${rd}|${Qu}|${td})`,id=`(?:${un}*)`,nd=String.raw`^\s*(?:${id}?)\s*$`,od=new RegExp(nd),ad=new RegExp(un),ld=new RegExp(un,"g");function dn(i){const t=[];if(!(i=(e=>Bs(e.replace(Ju," $1 ").replace(/,/gi," ")))(i).replace(/\s*([()])\s*/gi,"$1"))||i&&!od.test(i))return[...Tt];for(const e of i.matchAll(ld)){const r=ad.exec(e[0]);if(!r)continue;let s=Tt;const n=r.filter(f=>!!f),[,o,...a]=n,[l,c,h,u,d,g]=a.map(f=>parseFloat(f));switch(o){case"translate":s=Ar(l,c);break;case zi:s=rr({angle:l},{x:c,y:h});break;case Ss:s=Yi(l,c);break;case Je:s=oa(l);break;case Qe:s=aa(l);break;case"matrix":s=[l,c,h,u,d,g]}t.push(s)}return Xi(t)}function cd(i,t,e,r){const s=Array.isArray(t);let n,o=t;if(i!==_t&&i!==Rt||t!==Pt){if(i==="strokeUniform")return t==="non-scaling-stroke";if(i==="strokeDashArray")o=t===Pt?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(i==="transformMatrix")o=e&&e.transformMatrix?Ct(e.transformMatrix,dn(t)):dn(t);else if(i==="visible")o=t!==Pt&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(i==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(i==="textAnchor")o=t==="start"?Q:t==="end"?ft:Y;else if(i==="charSpacing"||i===Be)n=nr(t,r)/r*1e3;else if(i==="paintFirst"){const a=t.indexOf(_t),l=t.indexOf(Rt);o=_t,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=Rt)}else{if(i==="href"||i==="xlink:href"||i==="font"||i==="id")return t;if(i==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(nr):nr(t,r)}}else o="";return!s&&isNaN(n)?o:n}function hd(i,t){i.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[r,s]=e.split(":");t[r.trim().toLowerCase()]=s.trim()})}function ud(i){const t={},e=i.getAttribute("style");return e&&(typeof e=="string"?hd(e,t):function(r,s){Object.entries(r).forEach(n=>{let[o,a]=n;a!==void 0&&(s[o.toLowerCase()]=a)})}(e,t)),t}const dd={stroke:"strokeOpacity",fill:"fillOpacity"};function ye(i,t,e){if(!i)return{};let r,s={},n=Bi;i.parentNode&&ja.test(i.parentNode.nodeName)&&(s=ye(i.parentElement,t,e),s.fontSize&&(r=n=nr(s.fontSize)));const o={...t.reduce((c,h)=>{const u=i.getAttribute(h);return u&&(c[h]=u),c},{}),...Ku(i,e),...ud(i)};o[sn]&&i.setAttribute(sn,o[sn]),o[rn]&&(r=nr(o[rn],n),o[rn]=`${r}`);const a={};for(const c in o){const h=Zu(c),u=cd(h,o[c],s,r);a[h]=u}a&&a.font&&function(c,h){const u=c.match(vu);if(!u)return;const d=u[1],g=u[3],f=u[4],m=u[5],y=u[6];d&&(h.fontStyle=d),g&&(h.fontWeight=isNaN(parseFloat(g))?g:parseFloat(g)),f&&(h.fontSize=nr(f)),y&&(h.fontFamily=y),m&&(h.lineHeight=m===Hi?1:m)}(a.font,a);const l={...s,...a};return ja.test(i.nodeName)?l:function(c){const h=ut.getDefaults();return Object.entries(dd).forEach(u=>{let[d,g]=u;if(c[g]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;const f=new rt(c[d]);c[d]=f.setAlpha(nt(f.getAlpha()*c[g],2)).toRgba()}),c}(l)}const Za=["rx","ry"];class Ft extends ut{static getDefaults(){return{...super.getDefaults(),...Ft.ownDefaults}}constructor(t){super(),Object.assign(this,Ft.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:r}=this,s=-e/2,n=-r/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,r/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-Se*o,n,s+e,n+Se*a,s+e,n+a),t.lineTo(s+e,n+r-a),l&&t.bezierCurveTo(s+e,n+r-Se*a,s+e-Se*o,n+r,s+e-o,n+r),t.lineTo(s+o,n+r),l&&t.bezierCurveTo(s+Se*o,n+r,s,n+r-Se*a,s,n+r-a),t.lineTo(s,n+a),l&&t.bezierCurveTo(s,n+Se*a,s+Se*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([...Za,...t])}_toSVG(){const{width:t,height:e,rx:r,ry:s}=this;return["<rect ","COMMON_PARTS",`x="${-t/2}" y="${-e/2}" rx="${q(r)}" ry="${q(s)}" width="${q(t)}" height="${q(e)}" />
74
+ `]}static async fromElement(t,e,r){const{left:s=0,top:n=0,width:o=0,height:a=0,visible:l=!0,...c}=ye(t,this.ATTRIBUTE_NAMES,r);return new this({...e,...c,left:s,top:n,width:o,height:a,visible:!!(l&&o&&a)})}}v(Ft,"type","Rect"),v(Ft,"cacheProperties",[...me,...Za]),v(Ft,"ownDefaults",{rx:0,ry:0}),v(Ft,"ATTRIBUTE_NAMES",[...Oe,"x","y","rx","ry","width","height"]),j.setClass(Ft),j.setSVGClass(Ft);const be="initialization",Xs="added",gn="removed",Ys="imperative",Ja=(i,t)=>{const{strokeUniform:e,strokeWidth:r,width:s,height:n,group:o}=t,a=o&&o!==i?Fs(o.calcTransformMatrix(),i.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?cu(new x(r,r),void 0,i.calcTransformMatrix()):Wi,u=!e&&c?r:0,d=Ki(s+u,n+u,Xi([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class Us{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:s}=t;return e===be||e===Ys||!!r&&s!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==be&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:r,target:s}=e;if(r===Ys&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=pe(t.map(u=>Ja(s,u)).reduce((u,d)=>u.concat(d),[])),c=new x(a,l),h=new x(n,o).add(c.scalarDivide(2));if(r===be){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(Us,"type","strategy");class fn extends Us{shouldPerformLayout(t){return!0}}v(fn,"type","fit-content"),j.setClass(fn);const Qa="layoutManager";class Wr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new fn;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 r=this.getLayoutResult(e);r&&this.commitLayout(e,r),this.onAfterLayout(e,r),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:r}=e;return[ks,Zo,Pr,Jo,_s,Qo,Cs,Nh,qh].map(s=>t.on(s,n=>this.performLayout(s===ks?{type:"object_modified",trigger:s,e:n,target:r}:{type:"object_modifying",trigger:s,e:n,target:r})))}subscribe(t,e){this.unsubscribe(t,e);const r=this.attachHandlers(t,e);this._subscriptions.set(t,r)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(r=>r()),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:r}=t,{canvas:s}=e;if(r===be||r===Xs?this.subscribeTargets(t):r===gn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),r===Ys&&t.deep){const{strategy:n,...o}=t;e.forEachObject(a=>a.layoutManager&&a.layoutManager.performLayout({...o,bubbles:!1,target:a}))}}getLayoutResult(t){const{target:e,strategy:r,type:s}=t,n=r.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===be?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=n,h=o.subtract(a).add(l).transform(s===be?Tt:Ut(e.calcOwnMatrix()),!0).add(c);return{result:n,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:r}=t,{result:{size:s},nextCenter:n}=e;var o,a;r.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===be?r.set({left:(o=t.x)!==null&&o!==void 0?o:n.x+s.x*Ot(r.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*Ot(r.originY)}):(r.setPositionByOrigin(n,Y,Y),r.setCoords(),r.set("dirty",!0))}layoutObjects(t,e){const{target:r}=t;r.forEachObject(s=>{s.group===r&&this.layoutObject(t,e,s)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,r.clipPath)}layoutObject(t,e,r){let{offset:s}=e;r.set({left:r.left+s.x,top:r.top+s.y})}onAfterLayout(t,e){const{target:r,strategy:s,bubbles:n,prevStrategy:o,...a}=t,{canvas:l}=r;r.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:r});const c=r.parent;n&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(r),c.layoutManager.performLayout({...a,target:c})),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(r=>r())),t.clear()}toObject(){return{type:Qa,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}j.setClass(Wr,Qa);class gd extends Wr{performLayout(){}}class De extends ta(ut){static getDefaults(){return{...super.getDefaults(),...De.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,De.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var r;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=(r=e.layoutManager)!==null&&r!==void 0?r:new Wr,this.layoutManager.performLayout({type:be,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Ce("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Ce("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,r,s)=>this.canEnterGroup(e)&&s.indexOf(e)===r)}add(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const s=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...s);return this._onAfterObjectsChange(Xs,s),n}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;s<e;s++)r[s-1]=arguments[s];const n=this._filterObjectsBeforeEnteringGroup(r),o=super.insertAt(t,...n);return this._onAfterObjectsChange(Xs,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(gn,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 r=this[t];return super._set(t,e),t==="canvas"&&r!==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:r}=e;const s=this._activeObjects;if(t)s.push(r),this._set("dirty",!0);else if(s.length>0){const n=s.indexOf(r);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&&Ls(t,Ct(Ut(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const r=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();r&&(r===t||t.isDescendantOf(r))&&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||(Ls(t,Ct(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const r=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;r>-1&&this._activeObjects.splice(r,1)}shouldCache(){const t=ut.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,r){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(...Ut(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,r)}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:Ys,...t})}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const r=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const n=s.includeDefaultValues;s.includeDefaultValues=r;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: (${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=Ft.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
75
75
  `],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
76
- `),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=[],r=this._createSVGBgRect(t);r&&e.push(" ",r);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:r,objects:s=[],layoutManager:n}=t,o=ot(t,xd);return Promise.all([Pr(s,e),As(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new _d}));if(n){const u=R.getClass(n.type),d=R.getClass(n.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Vr;return h.layoutManager.subscribeTargets({type:we,target:h,targets:h.getObjects()}),h.setCoords(),h})}}m(Me,"type","Group"),m(Me,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),R.setClass(Me);const Cd=(i,t)=>Math.min(t.width/i.width,t.height/i.height),Sd=(i,t)=>Math.max(t.width/i.width,t.height/i.height),fn="\\s*,?\\s*",Wr="".concat(fn,"(").concat(qt,")"),Td="".concat(Wr).concat(Wr).concat(Wr).concat(fn,"([01])").concat(fn,"([01])").concat(Wr).concat(Wr),kd={m:"l",M:"L"},Od=(i,t,e,r,s,n,o,a,l,c,h)=>{const u=de(i),d=ge(i),g=de(t),f=ge(t),p=e*s*g-r*n*f+o,v=r*s*g+e*n*f+a;return["C",c+l*(-e*s*d-r*n*u),h+l*(-r*s*d+e*n*u),p+l*(e*s*f+r*n*g),v+l*(r*s*f-e*n*g),p,v]},nl=(i,t,e,r)=>{const s=Math.atan2(t,i),n=Math.atan2(r,e);return n>=s?n-s:2*Math.PI-(s-n)};function ol(i,t,e,r,s,n,o,a){let l;if(Q.cachesBoundsOfCurve&&(l=[...arguments].join(),Or.boundsOfCurveCache[l]))return Or.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let g=6*i-12*e+6*s,f=-3*i+9*e-9*s+3*o,p=3*e-3*i;for(let C=0;C<2;++C){if(C>0&&(g=6*t-12*r+6*n,f=-3*t+9*r-9*n+3*a,p=3*r-3*t),h(f)<1e-12){if(h(g)<1e-12)continue;const L=-p/g;0<L&&L<1&&u.push(L);continue}const O=g*g-4*p*f;if(O<0)continue;const S=c(O),j=(-g+S)/(2*f);0<j&&j<1&&u.push(j);const T=(-g-S)/(2*f);0<T&&T<1&&u.push(T)}let v=u.length;const b=v,x=al(i,t,e,r,s,n,o,a);for(;v--;){const{x:C,y:O}=x(u[v]);d[0][v]=C,d[1][v]=O}d[0][b]=i,d[1][b]=t,d[0][b+1]=o,d[1][b+1]=a;const D=[new _(Math.min(...d[0]),Math.min(...d[1])),new _(Math.max(...d[0]),Math.max(...d[1]))];return Q.cachesBoundsOfCurve&&(Or.boundsOfCurveCache[l]=D),D}const Dd=(i,t,e)=>{let[r,s,n,o,a,l,c,h]=e;const u=((d,g,f,p,v,b,x)=>{if(f===0||p===0)return[];let D=0,C=0,O=0;const S=Math.PI,j=x*ji,T=ge(j),L=de(j),H=.5*(-L*d-T*g),W=.5*(-L*g+T*d),V=f**2,U=p**2,X=W**2,tt=H**2,Z=V*U-V*X-U*tt;let J=Math.abs(f),A=Math.abs(p);if(Z<0){const N=Math.sqrt(1-Z/(V*U));J*=N,A*=N}else O=(v===b?-1:1)*Math.sqrt(Z/(V*X+U*tt));const ht=O*J*W/A,ut=-O*A*H/J,dt=L*ht-T*ut+.5*d,k=T*ht+L*ut+.5*g;let P=nl(1,0,(H-ht)/J,(W-ut)/A),E=nl((H-ht)/J,(W-ut)/A,(-H-ht)/J,(-W-ut)/A);b===0&&E>0?E-=2*S:b===1&&E<0&&(E+=2*S);const I=Math.ceil(Math.abs(E/S*2)),F=[],M=E/I,Y=8/3*Math.sin(M/4)*Math.sin(M/4)/Math.sin(M/2);let q=P+M;for(let N=0;N<I;N++)F[N]=Od(P,q,L,T,J,A,dt,k,Y,D,C),D=F[N][5],C=F[N][6],P=q,q+=M;return F})(c-i,h-t,s,n,a,l,o);for(let d=0,g=u.length;d<g;d++)u[d][1]+=i,u[d][2]+=t,u[d][3]+=i,u[d][4]+=t,u[d][5]+=i,u[d][6]+=t;return u},Md=i=>{let t=0,e=0,r=0,s=0;const n=[];let o,a=0,l=0;for(const c of i){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],r=h[1],s=h[2],u=["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],u=["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],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[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],u=["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],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Dd(t,e,h).forEach(d=>n.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=r,e=s,u=["Z"]}u?(n.push(u),o=u[0]):o=""}return n},Ns=(i,t,e,r)=>Math.sqrt((e-i)**2+(r-t)**2),al=(i,t,e,r,s,n,o,a)=>l=>{const c=l**3,h=(g=>3*g**2*(1-g))(l),u=(g=>3*g*(1-g)**2)(l),d=(g=>(1-g)**3)(l);return new _(o*c+s*h+e*u+i*d,a*c+n*h+r*u+t*d)},ll=i=>i**2,cl=i=>2*i*(1-i),hl=i=>(1-i)**2,Ed=(i,t,e,r,s,n,o,a)=>l=>{const c=ll(l),h=cl(l),u=hl(l),d=3*(u*(e-i)+h*(s-e)+c*(o-s)),g=3*(u*(r-t)+h*(n-r)+c*(a-n));return Math.atan2(g,d)},Pd=(i,t,e,r,s,n)=>o=>{const a=ll(o),l=cl(o),c=hl(o);return new _(s*a+e*l+i*c,n*a+r*l+t*c)},Ad=(i,t,e,r,s,n)=>o=>{const a=1-o,l=2*(a*(e-i)+o*(s-e)),c=2*(a*(r-t)+o*(n-r));return Math.atan2(c,l)},ul=(i,t,e)=>{let r=new _(t,e),s=0;for(let n=1;n<=100;n+=1){const o=i(n/100);s+=Ns(r.x,r.y,o.x,o.y),r=o}return s},Ld=(i,t)=>{let e,r=0,s=0,n={x:i.x,y:i.y},o=y({},n),a=.01,l=0;const c=i.iterator,h=i.angleFinder;for(;s<t&&a>1e-4;)o=c(r),l=r,e=Ns(n.x,n.y,o.x,o.y),e+s>t?(r-=a,a/=2):(n=o,r+=a,s+=e);return y(y({},o),{},{angle:h(l)})},dl=i=>{let t,e,r=0,s=0,n=0,o=0,a=0;const l=[];for(const c of i){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=Ns(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=al(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=Ed(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=ul(t,s,n),s=c[5],n=c[6];break;case"Q":t=Pd(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ad(s,n,c[1],c[2],c[3],c[4]),e.length=ul(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Ns(s,n,o,a),s=o,n=a}r+=e.length,l.push(e)}return l.push({length:r,x:s,y:n}),l},jd=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:dl(i),r=0;for(;t-e[r].length>0&&r<e.length-2;)t-=e[r].length,r++;const s=e[r],n=t/s.length,o=i[r];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return y(y({},new _(s.x,s.y).lerp(new _(s.destX,s.destY),n)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return y(y({},new _(s.x,s.y).lerp(new _(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return Ld(s,t)}},Fd=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),gl=new RegExp(Td,"g"),Rd=new RegExp(qt,"gi"),Id={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Bd=i=>{var t;const e=[],r=(t=i.match(Fd))!==null&&t!==void 0?t:[];for(const s of r){const n=s[0];if(n==="z"||n==="Z"){e.push([n]);continue}const o=Id[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){gl.lastIndex=0;for(let l=null;l=gl.exec(s);)a.push(...l.slice(1))}else a=s.match(Rd)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=kd[n];c[0]=l>0&&h?h:n;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},zd=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=new _(i[0]),r=new _(i[1]),s=1,n=0;const o=[],a=i.length,l=a>2;let c;for(l&&(s=i[2].x<r.x?-1:i[2].x===r.x?0:1,n=i[2].y<r.y?-1:i[2].y===r.y?0:1),o.push(["M",e.x-s*t,e.y-n*t]),c=1;c<a;c++){if(!e.eq(r)){const h=e.midPointFrom(r);o.push(["Q",e.x,e.y,h.x,h.y])}e=i[c],c+1<i.length&&(r=i[c+1])}return l&&(s=e.x>i[c-2].x?1:e.x===i[c-2].x?0:-1,n=e.y>i[c-2].y?1:e.y===i[c-2].y?0:-1),o.push(["L",e.x+s*t,e.y+n*t]),o},fl=(i,t)=>i.map(e=>e.map((r,s)=>s===0||t===void 0?r:it(r,t)).join(" ")).join(" ");function pn(i,t){const e=i.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(r=>{let[s,n]=r;return e.setProperty(s,n)}))}class Hd extends ha{constructor(t){let{allowTouchScrolling:e=!1,containerClass:r=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),m(this,"upper",void 0),m(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(r),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=fe();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=qe().createElement("div");return t.setAttribute("data-fabric","wrapper"),pn(t,{position:"relative"}),ca(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:s}=e;pn(t,y(y({},r),{},{"touch-action":s?"manipulation":Mt})),ca(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:s}=this.upper;la(r,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Yi(this.upper.el,t),Yi(this.container,t)}cleanupDOM(t){const e=this.container,{el:r}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(r),e.parentNode&&e.parentNode.replaceChild(r,e)}dispose(){super.dispose(),ie().dispose(this.upper.el),delete this.upper,delete this.container}}class Gs extends Lr{constructor(){super(...arguments),m(this,"targets",[]),m(this,"_hoveredTargets",[]),m(this,"_currentTransform",null),m(this,"_groupSelector",null),m(this,"contextTopDirty",!1)}static getDefaults(){return y(y({},super.getDefaults()),Gs.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 Hd(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(),r=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=r,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,r){const s=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+s,-r+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 Yu(n,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(r=>!!r&&t[r]===!0):t[e])}_shouldClearSelection(t,e){const r=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&r.length>1&&r.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,r){if(!t)return;let s;return e===Ss||e===Et||e===Vt||e===Mr?s=this.centeredScaling||t.centeredScaling:e===Bi&&(s=this.centeredRotation||t.centeredRotation),s?!r:r}_getOriginFromCorner(t,e){const r={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?r.x=ft:["mr","tr","br"].includes(e)&&(r.x=et),["tl","mt","tr"].includes(e)?r.y=Ri:["bl","mb","br"].includes(e)&&(r.y=Dt)),r}_setupCurrentTransform(t,e,r){var s;const n=e.group?rr(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=r&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):ou,c=((g,f,p,v)=>{if(!f||!g)return"drag";const b=v.controls[f];return b.getActionName(p,b,v)})(r,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:$,y:$}:this._getOriginFromCorner(e,o),d={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:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:pt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:y(y({},da(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:r,deltaX:s,deltaY:n}=this._groupSelector,o=new _(e,r).transform(this.viewportTransform),a=new _(e+s,r+n).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,yt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),r=this._activeObject,s=this.getActiveObjects();if(this.targets=[],r&&s.length>=1){if(r.findControl(e,Ui(t))||s.length>1&&this.searchPossibleTargets([r],e))return r;if(r===this.searchPossibleTargets([r],e)){if(this.preserveObjectStacking){const n=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==r?(this.targets=n,r):o}return r}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let r=t.getCoords();const s=this.getZoom(),n=t.padding/s;if(n){const[o,a,l,c]=r,h=Math.atan2(a.y-o.y,a.x-o.x),u=de(h)*n,d=ge(h)*n,g=u+d,f=u-d;r=[new _(o.x-f,o.y-g),new _(a.x+g,a.y-f),new _(l.x+f,l.y+g),new _(c.x-g,c.y+f)]}return lt.isPointInPolygon(e,r)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,rr(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let r=t.length;for(;r--;){const s=t[r];if(this._checkTarget(s,e)){if(Os(s)&&s.subTargetCheck){const n=this._searchPossibleTargets(s._objects,e);n&&this.targets.push(n)}return s}}}searchPossibleTargets(t,e){const r=this._searchPossibleTargets(t,e);if(r&&Os(r)&&r.interactive&&this.targets[0]){const s=this.targets;for(let n=s.length-1;n>0;n--){const o=s[n];if(!Os(o)||!o.interactive)return o}return s[0]}return r}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 r=this.upperCanvasEl,s=r.getBoundingClientRect();let n=Qh(t),o=s.width||0,a=s.height||0;o&&a||(Dt in s&&Ri in s&&(a=Math.abs(s.top-s.bottom)),ft in s&&et 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=rr(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new _(1,1):new _(r.width/o,r.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=fe(),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 Re(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,s=!1;const n=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{n.includes(l)||(r=!0,l.fire("deselected",{e,target:l}),a.push(l))}),n.forEach(l=>{t.includes(l)||(r=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&n.length>0?(s=!0,r&&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 r=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(r,e),s}_setActiveObject(t,e){const r=this._activeObject;return r!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Re(t)&&r!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const r=this._activeObject;return!!r&&!r.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===r&&this.endCurrentTransform(t),Re(r)&&r===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),r=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[r]});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,r=e.target,s={e:t,target:r,transform:e,action:e.action};r._scaling&&(r._scaling=!1),r.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),r.fire(Ts,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Re(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,r){const s=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,r);return t.set(s),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Re(e)&&this._activeObject===e){const r=er(t,["angle","flipX","flipY",et,Et,Vt,Ke,Ze,Dt]);return eu(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(s)}}m(Gs,"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 Vd{constructor(t){m(this,"targets",[]),m(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},r=t.upperCanvasEl;r.addEventListener("click",e),this.__disposer=()=>r.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),Qe(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 Wd=["target","oldTarget","fireCanvas","e"],It={passive:!1},cr=(i,t)=>{const e=i.getViewportPoint(t),r=i.getScenePoint(t);return{viewportPoint:e,scenePoint:r,pointer:e,absolutePointer:r}},Ee=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return i.addEventListener(...e)},Yt=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return i.removeEventListener(...e)},Xd={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 mn extends Gs{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),m(this,"_isClick",void 0),m(this,"textEditingManager",new Vd(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(Ee,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const r=this.upperCanvasEl,s=this._getEventPrefix();t(aa(r),"resize",this._onResize),t(r,s+"down",this._onMouseDown),t(r,"".concat(s,"move"),this._onMouseMove,It),t(r,"".concat(s,"out"),this._onMouseOut),t(r,"".concat(s,"enter"),this._onMouseEnter),t(r,"wheel",this._onMouseWheel,{passive:!1}),t(r,"contextmenu",this._onContextMenu),t(r,"click",this._onClick),t(r,"dblclick",this._onClick),t(r,"dragstart",this._onDragStart),t(r,"dragend",this._onDragEnd),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,It)}removeListeners(){this.addOrRemove(Yt,"remove");const t=this._getEventPrefix(),e=Gt(this.upperCanvasEl);Yt(e,"".concat(t,"up"),this._onMouseUp),Yt(e,"touchend",this._onTouchEnd,It),Yt(e,"".concat(t,"move"),this._onMouseMove,It),Yt(e,"touchmove",this._onMouseMove,It),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,r=y({e:t},cr(this,t));this.fire("mouse:out",y(y({},r),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",y({},r)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",y(y({},r),{},{target:s})),s&&s.fire("mouseout",y({},r))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",y({e:t},cr(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 r={e:t,target:e};return this.fire("dragstart",r),e.fire("dragstart",r),void Ee(this.upperCanvasEl,"drag",this._onDragProgress)}ua(t)}_renderDragEffects(t,e,r){let s=!1;const n=this._dropTarget;n&&n!==e&&n!==r&&(n.clearContextTop(),s=!0),e==null||e.clearContextTop(),r!==e&&(r==null||r.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),r&&(o.save(),r.transform(o),r.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==Mt,r=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:r};Yt(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:r,targets:s}=this.findDragTargets(t),n=this._dragSource,o={e:t,target:r,subTargets:s,dragSource:n,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(r,o),r&&(r.canDrop(t)&&(a=r),r.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:r}=this.findDragTargets(t),s={e:t,target:e,subTargets:r,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:r}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",y({e:t,target:e,subTargets:r,dragSource:this._dragSource},cr(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),r=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&ua(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 r=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||r&&this._target===r)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,n=this._getEventPrefix(),o=Gt(s);Ee(o,"touchend",this._onTouchEnd,It),e&&Ee(o,"touchmove",this._onMouseMove,It),Yt(s,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,r=this._getEventPrefix();Yt(e,"".concat(r,"move"),this._onMouseMove,It);const s=Gt(e);Ee(s,"".concat(r,"up"),this._onMouseUp),Ee(s,"".concat(r,"move"),this._onMouseMove,It)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),r=Gt(this.upperCanvasEl);Yt(r,"touchend",this._onTouchEnd,It),Yt(r,"touchmove",this._onMouseMove,It),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{Ee(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,r=this._getEventPrefix();if(this._isMainEvent(t)){const s=Gt(this.upperCanvasEl);Yt(s,"".concat(r,"up"),this._onMouseUp),Yt(s,"".concat(r,"move"),this._onMouseMove,It),Ee(e,"".concat(r,"move"),this._onMouseMove,It)}}_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 r=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(r&&(this._finalizeCurrentTransform(t),c=r.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),Ui(t)),{key:u,control:d}=h||{};if(l=u,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,t),c=!0;else if(d){const g=d.getMouseUpHandler(t,n,d);g&&(a=this.getScenePoint(t),g.call(d,t,r,a.x,a.y))}n.isMoving=!1}if(r&&(r.target!==n||r.corner!==l)){const h=r.target&&r.target.controls[r.corner],u=h&&h.getMouseUpHandler(t,r.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,r,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:r,subTargets:s=[]}=e;this.fire(t,e),r&&r.fire(t,e);for(let n=0;n<s.length;n++)s[n]!==r&&s[n].fire(t,e);return e}_handleEvent(t,e,r){const s=this._target,n=this.targets||[],o=y(y(y({e:t,target:s,subTargets:n},cr(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"?r:{});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,r=!!e&&e===this._activeObject;const{button:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:r}),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(r=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),Ui(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,r);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:r}),n&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=rr(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 r=this.getScenePoint(t);e.deltaX=r.x-e.x,e.deltaY=r.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const r=this.findTarget(t);this._setCursorFromEvent(t,r),this._fireOverOutEvents(t,r)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const r=this._hoveredTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:r,fireCanvas:!0});for(let a=0;a<o;a++)n[a]===e||s[a]&&s[a]===r||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const r=this._draggedoverTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:t,oldTarget:r,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:r,oldTarget:s,fireCanvas:n,e:o}=e,a=ot(e,Wd);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=Xd[t],d=s!==r;if(s&&d){const g=y(y({},a),{},{e:o,target:s,nextTarget:r},cr(this,o));n&&this.fire(u,g),s.fire(c,g)}if(r&&d){const g=y(y({},a),{},{e:o,target:r,previousTarget:s},cr(this,o));n&&this.fire(h,g),r.fire(l,g)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),r=this._currentTransform,s=r.target,n=s.group?rr(e,void 0,s.group.calcTransformMatrix()):e;r.shiftKey=t.shiftKey,r.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,r,n),r.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,r){const{action:s,actionHandler:n,target:o}=e,a=!!n&&n(t,e,r.x,r.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 r=e.hoverCursor||this.hoverCursor;const s=Re(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=>{r=o.hoverCursor||r}),this.setCursor(r)}handleMultiSelection(t,e){const r=this._activeObject,s=Re(r);if(r&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(r!==e||s)&&(s||!e.isDescendantOf(r)&&!r.isDescendantOf(e))&&!e.onSelect({e:t})&&!r.getActiveControl()){if(s){const n=r.getObjects();if(e===r){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(n,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===r?(r.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],r.size()===1&&this._setActiveObject(r.item(0),t)):(r.multiSelectAdd(e),this._hoveredTarget=r,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(n,t)}else{r.isEditing&&r.exitEditing();const n=new(R.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(r,e),this._hoveredTarget=n,this._setActiveObject(n,t),this._fireSelectionEvents([r],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:r,deltaX:s,deltaY:n}=this._groupSelector,o=new _(e,r),a=o.add(new _(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}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=R.getClass("ActiveSelection");this.setActiveObject(new d(u,{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:r}=this.elements;r.ctx=void 0;const s=super.toCanvasElement(t,e);return r.ctx=r.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const pl={x1:0,y1:0,x2:0,y2:0},Yd=y(y({},pl),{},{r1:0,r2:0}),hr=(i,t)=>isNaN(i)&&typeof t=="number"?t:i;function ml(i){return i&&/%$/.test(i)&&Number.isFinite(parseFloat(i))}function vl(i,t){const e=typeof i=="number"?i:typeof i=="string"?parseFloat(i)/(ml(i)?100:1):NaN;return ir(0,hr(e,t),1)}const Ud=/\s*;\s*/,Nd=/\s*:\s*/;function Gd(i,t){let e,r;const s=i.getAttribute("style");if(s){const o=s.split(Ud);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Nd).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(r=c)}}const n=new rt(e||i.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:vl(i.getAttribute("offset"),0),color:n.toRgb(),opacity:hr(parseFloat(r||i.getAttribute("stop-opacity")||""),1)*n.getAlpha()*t}}function $d(i,t){const e=[],r=i.getElementsByTagName("stop"),s=vl(t,1);for(let n=r.length;n--;)e.push(Gd(r[n],s));return e}function yl(i){return i.nodeName==="linearGradient"||i.nodeName==="LINEARGRADIENT"?"linear":"radial"}function bl(i){return i.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Zt(i,t){return i.getAttribute(t)}function qd(i,t){return function(e,r){let s,{width:n,height:o,gradientUnits:a}=r;return Object.entries(e).reduce((l,c)=>{let[h,u]=c;if(u==="Infinity")s=1;else if(u==="-Infinity")s=0;else{const d=typeof u=="string";s=d?parseFloat(u):u,d&&ml(u)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l},{})}(yl(i)==="linear"?function(e){return{x1:Zt(e,"x1")||0,y1:Zt(e,"y1")||0,x2:Zt(e,"x2")||"100%",y2:Zt(e,"y2")||0}}(i):function(e){return{x1:Zt(e,"fx")||Zt(e,"cx")||"50%",y1:Zt(e,"fy")||Zt(e,"cy")||"50%",r1:0,x2:Zt(e,"cx")||"50%",y2:Zt(e,"cy")||"50%",r2:Zt(e,"r")||"50%"}}(i),y(y({},t),{},{gradientUnits:bl(i)}))}class $s{constructor(t){const{type:e="linear",gradientUnits:r="pixels",coords:s={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:y(y({},e==="radial"?Yd:pl),s),colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Oe()):Oe()})}addColorStop(t){for(const e in t){const r=new rt(t[e]);this.colorStops.push({offset:parseFloat(e),color:r.toRgb(),opacity:r.getAlpha()})}return this}toObject(t){return y(y({},er(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 r=[],s=this.gradientTransform?this.gradientTransform.concat():St.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>y({},u)).sort((u,d)=>u.offset-d.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(Ar(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:g,y2:f}=this.coords;r.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',g,'" y2="',f,`">
77
- `)}else if(this.type==="radial"){const{x1:u,y1:d,x2:g,y2:f,r1:p,r2:v}=this.coords,b=p>v;r.push("<radialGradient ",h,' cx="',b?u:g,'" cy="',b?d:f,'" r="',b?p:v,'" fx="',b?g:u,'" fy="',b?f:d,`">
78
- `),b&&(o.reverse(),o.forEach(D=>{D.offset=1-D.offset}));const x=Math.min(p,v);if(x>0){const D=x/Math.max(p,v);o.forEach(C=>{C.offset+=D*(1-C.offset)})}}return o.forEach(u=>{let{color:d,offset:g,opacity:f}=u;r.push("<stop ",'offset="',100*g+"%",'" style="stop-color:',d,f!==void 0?";stop-opacity: "+f:";",`"/>
76
+ `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?`opacity: ${q(this.opacity)};`:"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],r=this._createSVGBgRect(t);r&&e.push(" ",r);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:r,objects:s=[],layoutManager:n,...o}=t;return Promise.all([Lr(s,e),As(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,{...o,...c,layoutManager:new gd});if(n){const u=j.getClass(n.type),d=j.getClass(n.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Wr;return h.layoutManager.subscribeTargets({type:be,target:h,targets:h.getObjects()}),h.setCoords(),h})}}v(De,"type","Group"),v(De,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),j.setClass(De);const fd=(i,t)=>Math.min(t.width/i.width,t.height/i.height),pd=(i,t)=>Math.max(t.width/i.width,t.height/i.height),pn="\\s*,?\\s*",Xr=`${pn}(${Re})`,md=`${Xr}${Xr}${Xr}${pn}([01])${pn}([01])${Xr}${Xr}`,vd={m:"l",M:"L"},yd=(i,t,e,r,s,n,o,a,l,c,h)=>{const u=de(i),d=ge(i),g=de(t),f=ge(t),m=e*s*g-r*n*f+o,y=r*s*g+e*n*f+a;return["C",c+l*(-e*s*d-r*n*u),h+l*(-r*s*d+e*n*u),m+l*(e*s*f+r*n*g),y+l*(r*s*f-e*n*g),m,y]},tl=(i,t,e,r)=>{const s=Math.atan2(t,i),n=Math.atan2(r,e);return n>=s?n-s:2*Math.PI-(s-n)};function el(i,t,e,r,s,n,o,a){let l;if(tt.cachesBoundsOfCurve&&(l=[...arguments].join(),Mr.boundsOfCurveCache[l]))return Mr.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let g=6*i-12*e+6*s,f=-3*i+9*e-9*s+3*o,m=3*e-3*i;for(let C=0;C<2;++C){if(C>0&&(g=6*t-12*r+6*n,f=-3*t+9*r-9*n+3*a,m=3*r-3*t),h(f)<1e-12){if(h(g)<1e-12)continue;const M=-m/g;0<M&&M<1&&u.push(M);continue}const S=g*g-4*m*f;if(S<0)continue;const D=c(S),A=(-g+D)/(2*f);0<A&&A<1&&u.push(A);const _=(-g-D)/(2*f);0<_&&_<1&&u.push(_)}let y=u.length;const b=y,w=rl(i,t,e,r,s,n,o,a);for(;y--;){const{x:C,y:S}=w(u[y]);d[0][y]=C,d[1][y]=S}d[0][b]=i,d[1][b]=t,d[0][b+1]=o,d[1][b+1]=a;const T=[new x(Math.min(...d[0]),Math.min(...d[1])),new x(Math.max(...d[0]),Math.max(...d[1]))];return tt.cachesBoundsOfCurve&&(Mr.boundsOfCurveCache[l]=T),T}const bd=(i,t,e)=>{let[r,s,n,o,a,l,c,h]=e;const u=((d,g,f,m,y,b,w)=>{if(f===0||m===0)return[];let T=0,C=0,S=0;const D=Math.PI,A=w*Ii,_=ge(A),M=de(A),O=.5*(-M*d-_*g),V=.5*(-M*g+_*d),z=f**2,X=m**2,W=V**2,G=O**2,K=z*X-z*W-X*G;let Z=Math.abs(f),L=Math.abs(m);if(K<0){const it=Math.sqrt(1-K/(z*X));Z*=it,L*=it}else S=(y===b?-1:1)*Math.sqrt(K/(z*W+X*G));const wt=S*Z*V/L,mt=-S*L*O/Z,lt=M*wt-_*mt+.5*d,k=_*wt+M*mt+.5*g;let P=tl(1,0,(O-wt)/Z,(V-mt)/L),E=tl((O-wt)/Z,(V-mt)/L,(-O-wt)/Z,(-V-mt)/L);b===0&&E>0?E-=2*D:b===1&&E<0&&(E+=2*D);const B=Math.ceil(Math.abs(E/D*2)),I=[],H=E/B,dt=8/3*Math.sin(H/4)*Math.sin(H/4)/Math.sin(H/2);let ht=P+H;for(let it=0;it<B;it++)I[it]=yd(P,ht,M,_,Z,L,lt,k,dt,T,C),T=I[it][5],C=I[it][6],P=ht,ht+=H;return I})(c-i,h-t,s,n,a,l,o);for(let d=0,g=u.length;d<g;d++)u[d][1]+=i,u[d][2]+=t,u[d][3]+=i,u[d][4]+=t,u[d][5]+=i,u[d][6]+=t;return u},wd=i=>{let t=0,e=0,r=0,s=0;const n=[];let o,a=0,l=0;for(const c of i){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],r=h[1],s=h[2],u=["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],u=["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],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[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],u=["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],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":bd(t,e,h).forEach(d=>n.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=r,e=s,u=["Z"]}u?(n.push(u),o=u[0]):o=""}return n},Gs=(i,t,e,r)=>Math.sqrt((e-i)**2+(r-t)**2),rl=(i,t,e,r,s,n,o,a)=>l=>{const c=l**3,h=(g=>3*g**2*(1-g))(l),u=(g=>3*g*(1-g)**2)(l),d=(g=>(1-g)**3)(l);return new x(o*c+s*h+e*u+i*d,a*c+n*h+r*u+t*d)},sl=i=>i**2,il=i=>2*i*(1-i),nl=i=>(1-i)**2,xd=(i,t,e,r,s,n,o,a)=>l=>{const c=sl(l),h=il(l),u=nl(l),d=3*(u*(e-i)+h*(s-e)+c*(o-s)),g=3*(u*(r-t)+h*(n-r)+c*(a-n));return Math.atan2(g,d)},_d=(i,t,e,r,s,n)=>o=>{const a=sl(o),l=il(o),c=nl(o);return new x(s*a+e*l+i*c,n*a+r*l+t*c)},Cd=(i,t,e,r,s,n)=>o=>{const a=1-o,l=2*(a*(e-i)+o*(s-e)),c=2*(a*(r-t)+o*(n-r));return Math.atan2(c,l)},ol=(i,t,e)=>{let r=new x(t,e),s=0;for(let n=1;n<=100;n+=1){const o=i(n/100);s+=Gs(r.x,r.y,o.x,o.y),r=o}return s},Sd=(i,t)=>{let e,r=0,s=0,n={x:i.x,y:i.y},o={...n},a=.01,l=0;const c=i.iterator,h=i.angleFinder;for(;s<t&&a>1e-4;)o=c(r),l=r,e=Gs(n.x,n.y,o.x,o.y),e+s>t?(r-=a,a/=2):(n=o,r+=a,s+=e);return{...o,angle:h(l)}},al=i=>{let t,e,r=0,s=0,n=0,o=0,a=0;const l=[];for(const c of i){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=Gs(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=rl(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=xd(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=ol(t,s,n),s=c[5],n=c[6];break;case"Q":t=_d(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Cd(s,n,c[1],c[2],c[3],c[4]),e.length=ol(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Gs(s,n,o,a),s=o,n=a}r+=e.length,l.push(e)}return l.push({length:r,x:s,y:n}),l},kd=function(i,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:al(i),r=0;for(;t-e[r].length>0&&r<e.length-2;)t-=e[r].length,r++;const s=e[r],n=t/s.length,o=i[r];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 Sd(s,t)}},Td=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),ll=new RegExp(md,"g"),Od=new RegExp(Re,"gi"),Dd={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Md=i=>{var t;const e=[],r=(t=i.match(Td))!==null&&t!==void 0?t:[];for(const s of r){const n=s[0];if(n==="z"||n==="Z"){e.push([n]);continue}const o=Dd[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){ll.lastIndex=0;for(let l=null;l=ll.exec(s);)a.push(...l.slice(1))}else a=s.match(Od)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=vd[n];c[0]=l>0&&h?h:n;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},Ed=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=new x(i[0]),r=new x(i[1]),s=1,n=0;const o=[],a=i.length,l=a>2;let c;for(l&&(s=i[2].x<r.x?-1:i[2].x===r.x?0:1,n=i[2].y<r.y?-1:i[2].y===r.y?0:1),o.push(["M",e.x-s*t,e.y-n*t]),c=1;c<a;c++){if(!e.eq(r)){const h=e.midPointFrom(r);o.push(["Q",e.x,e.y,h.x,h.y])}e=i[c],c+1<i.length&&(r=i[c+1])}return l&&(s=e.x>i[c-2].x?1:e.x===i[c-2].x?0:-1,n=e.y>i[c-2].y?1:e.y===i[c-2].y?0:-1),o.push(["L",e.x+s*t,e.y+n*t]),o},cl=(i,t)=>i.map(e=>e.map((r,s)=>s===0||t===void 0?r:nt(r,t)).join(" ")).join(" ");function mn(i,t){const e=i.style;e&&Object.entries(t).forEach(r=>{let[s,n]=r;return e.setProperty(s,n)})}class Pd extends fa{constructor(t){let{allowTouchScrolling:e=!1,containerClass:r=""}=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(r),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=fe();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=Ke().createElement("div");return t.setAttribute("data-fabric","wrapper"),mn(t,{position:"relative"}),ga(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:s}=e;mn(t,{...r,"touch-action":s?"manipulation":Pt}),ga(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:s}=this.upper;da(r,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Gi(this.upper.el,t),Gi(this.container,t)}cleanupDOM(t){const e=this.container,{el:r}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(r),e.parentNode&&e.parentNode.replaceChild(r,e)}dispose(){super.dispose(),se().dispose(this.upper.el),delete this.upper,delete this.container}}const Ad=(i,t,e,r)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=r-o,c=!Nt(s,"lockMovementX")&&s.left!==a,h=!Nt(s,"lockMovementY")&&s.top!==l;return c&&s.set(Q,a),h&&s.set(Et,l),(c||h)&&$a(Zo,Sa(i,t,e,r)),c||h};class Ns extends Ir{constructor(){super(...arguments),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return{...super.getDefaults(),...Ns.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 Pd(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(),r=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=r,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,r){const s=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+s,-r+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 Xu(n,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(r=>!!r&&t[r]===!0):t[e])}_shouldClearSelection(t,e){const r=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&r.length>1&&r.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,r){if(!t)return;let s;return e===Ss||e===At||e===Vt||e===Pr?s=this.centeredScaling||t.centeredScaling:e===zi&&(s=this.centeredRotation||t.centeredRotation),s?!r:r}_getOriginFromCorner(t,e){const r=e?t.controls[e].getTransformAnchorPoint():{x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?r.x=ft:["mr","tr","br"].includes(e)&&(r.x=Q),["tl","mt","tr"].includes(e)?r.y=Ri:["bl","mb","br"].includes(e)&&(r.y=Et)),r}_setupCurrentTransform(t,e,r){var s;const n=e.group?ir(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=r&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):Ad,c=((_,M,O,V)=>{if(!M||!_)return"drag";const z=V.controls[M];return z.getActionName(O,z,V)})(r,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:Y,y:Y}:this._getOriginFromCorner(e,o),{scaleX:d,scaleY:g,skewX:f,skewY:m,left:y,top:b,angle:w,width:T,height:C,cropX:S,cropY:D}=e,A={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:d,scaleY:g,skewX:f,skewY:m,offsetX:n.x-y,offsetY:n.y-b,originX:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:pt(w),width:T,height:C,shiftKey:t.shiftKey,altKey:h,original:{...ma(e),originX:u.x,originY:u.y,cropX:S,cropY:D}};this._currentTransform=A,this.fire("before:transform",{e:t,transform:A})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:r,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,r).transform(this.viewportTransform),a=new x(e+s,r+n).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,ut.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this._targetInfo)return this._targetInfo;if(this.skipTargetFind)return{subTargets:[],currentSubTargets:[]};const e=this.getScenePoint(t),r=this._activeObject,s=this.getActiveObjects(),n=this.searchPossibleTargets(this._objects,e),{subTargets:o,container:a,target:l}=n,c={...n,currentSubTargets:o,currentContainer:a,currentTarget:l};if(!r)return c;const h={...this.searchPossibleTargets([r],e),currentSubTargets:o,currentContainer:a,currentTarget:l};return r.findControl(this.getViewportPoint(t),qi(t))?{...h,target:r}:h.target&&(s.length>1||!this.preserveObjectStacking||this.preserveObjectStacking&&t[this.altSelectionKey])?h:c}_pointIsInObjectSelectionArea(t,e){let r=t.getCoords();const s=this.getZoom(),n=t.padding/s;if(n){const[o,a,l,c]=r,h=Math.atan2(a.y-o.y,a.x-o.x),u=de(h)*n,d=ge(h)*n,g=u+d,f=u-d;r=[new x(o.x-f,o.y-g),new x(a.x+g,a.y-f),new x(l.x+f,l.y+g),new x(c.x-g,c.y+f)]}return ct.isPointInPolygon(e,r)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,e)){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;{const r=e.transform(this.viewportTransform);if(!this.isTargetTransparent(t,r.x,r.y))return!0}}return!1}_searchPossibleTargets(t,e,r){let s=t.length;for(;s--;){const n=t[s];if(this._checkTarget(n,e)){if(Os(n)&&n.subTargetCheck){const{target:o}=this._searchPossibleTargets(n._objects,e,r);o&&r.push(o)}return{target:n,subTargets:r}}}return{subTargets:[]}}searchPossibleTargets(t,e){const r=this._searchPossibleTargets(t,e,[]);r.container=r.target;const{container:s,subTargets:n}=r;if(s&&Os(s)&&s.interactive&&n[0]){for(let o=n.length-1;o>0;o--){const a=n[o];if(!Os(a)||!a.interactive)return r.target=a,r}return r.target=n[0],r}return r}getViewportPoint(t){return this._viewportPoint?this._viewportPoint:this._getPointerImpl(t,!0)}getScenePoint(t){return this._scenePoint?this._scenePoint:this._getPointerImpl(t)}_getPointerImpl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const r=this.upperCanvasEl,s=r.getBoundingClientRect();let n=ou(t),o=s.width||0,a=s.height||0;o&&a||(Et in s&&Ri in s&&(a=Math.abs(s.top-s.bottom)),ft in s&&Q 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=ir(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(r.width/o,r.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=fe(),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 Ie(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,s=!1;const n=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{n.includes(l)||(r=!0,l.fire("deselected",{e,target:l}),a.push(l))}),n.forEach(l=>{t.includes(l)||(r=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&n.length>0?(s=!0,r&&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 r=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(r,e),s}_setActiveObject(t,e){const r=this._activeObject;return r!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ie(t)&&r!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const r=this._activeObject;return!!r&&!r.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===r&&this.endCurrentTransform(t),Ie(r)&&r===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),r=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[r]});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,r=e.target,s={e:t,target:r,transform:e,action:e.action};r._scaling&&(r._scaling=!1),r.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),r.fire(ks,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ie(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,r){const s=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,r);return t.set(s),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ie(e)&&this._activeObject===e){const r=sr(t,["angle","flipX","flipY",Q,At,Vt,Je,Qe,Et]);return au(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(s)}}v(Ns,"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:!0,fireRightClick:!0,fireMiddleClick:!0,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!0});class Ld{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},r=t.upperCanvasEl;r.addEventListener("click",e),this.__disposer=()=>r.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),er(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 $t={passive:!1},$e=(i,t)=>({viewportPoint:i.getViewportPoint(t),scenePoint:i.getScenePoint(t)}),Me=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return i.addEventListener(...e)},Yt=function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return i.removeEventListener(...e)},Fd={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 vn extends Ns{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Ld(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(Me)}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const r=this.upperCanvasEl,s=this._getEventPrefix();t(ua(r),"resize",this._onResize),t(r,s+"down",this._onMouseDown),t(r,`${s}move`,this._onMouseMove,$t),t(r,`${s}out`,this._onMouseOut),t(r,`${s}enter`,this._onMouseEnter),t(r,"wheel",this._onMouseWheel,{passive:!1}),t(r,"contextmenu",this._onContextMenu),e||(t(r,"click",this._onClick),t(r,"dblclick",this._onClick)),t(r,"dragstart",this._onDragStart),t(r,"dragend",this._onDragEnd),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,$t)}removeListeners(){this.addOrRemove(Yt);const t=this._getEventPrefix(),e=Gt(this.upperCanvasEl);Yt(e,`${t}up`,this._onMouseUp),Yt(e,"touchend",this._onTouchEnd,$t),Yt(e,`${t}move`,this._onMouseMove,$t),Yt(e,"touchmove",this._onMouseMove,$t),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_onMouseOut(t){const e=this._hoveredTarget,r={e:t,...$e(this,t)};this.fire("mouse:out",{...r,target:e}),this._hoveredTarget=void 0,e&&e.fire("mouseout",{...r}),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",{...r,target:s}),s&&s.fire("mouseout",{...r})}),this._hoveredTargets=[]}_onMouseEnter(t){const{target:e}=this.findTarget(t);this._currentTransform||e||(this.fire("mouse:over",{e:t,...$e(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 r={e:t,target:e};return this.fire("dragstart",r),e.fire("dragstart",r),void Me(this.upperCanvasEl,"drag",this._onDragProgress)}pa(t)}_renderDragEffects(t,e,r){let s=!1;const n=this._dropTarget;n&&n!==e&&n!==r&&(n.clearContextTop(),s=!0),e==null||e.clearContextTop(),r!==e&&(r==null||r.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),r&&(o.save(),r.transform(o),r.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const{currentSubTargets:e}=this.findTarget(t),r=!!t.dataTransfer&&t.dataTransfer.dropEffect!==Pt,s=r?this._activeObject:void 0,n={e:t,target:this._dragSource,subTargets:e,dragSource:this._dragSource,didDrop:r,dropTarget:s};Yt(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",n),this._dragSource&&this._dragSource.fire("dragend",n),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)}_onDragOver(t){const e="dragover",{currentContainer:r,currentSubTargets:s}=this.findTarget(t),n=this._dragSource,o={e:t,target:r,subTargets:s,dragSource:n,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(t,r,o),r&&(r.canDrop(t)&&(a=r),r.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{currentContainer:e,currentSubTargets:r}=this.findTarget(t),s={e:t,target:e,subTargets:r,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(t,e,s)}_onDragLeave(t){const{currentSubTargets:e}=this.findTarget(t),r={e:t,target:this._draggedoverTarget,subTargets:e,dragSource:this._dragSource};this.fire("dragleave",r),this._fireEnterLeaveEvents(t,void 0,r),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this._hoveredTargets=[]}_onDrop(t){const{currentContainer:e,currentSubTargets:r}=this.findTarget(t),s=this._basicEventHandler("drop:before",{e:t,target:e,subTargets:r,dragSource:this._dragSource,...$e(this,t)});s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const{target:e,subTargets:r}=this.findTarget(t),s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&pa(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())}fireEventFromPointerEvent(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};this._cacheTransformEventData(t);const{target:n,subTargets:o}=this.findTarget(t),a={e:t,target:n,subTargets:o,...$e(this,t),transform:this._currentTransform,...s};this.fire(e,a),n&&n.fire(r,a);for(let l=0;l<o.length;l++)o[l]!==n&&o[l].fire(r,a);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){this._cacheTransformEventData(t);let e=!this.allowTouchScrolling;const r=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t);const{target:s}=this.findTarget(t);(this.isDrawingMode||r&&s===r)&&(e=!0),e&&t.preventDefault();const n=this.upperCanvasEl,o=this._getEventPrefix(),a=Gt(n);Me(a,"touchend",this._onTouchEnd,$t),e&&Me(a,"touchmove",this._onMouseMove,$t),Yt(n,`${o}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(t){this._cacheTransformEventData(t),this.__onMouseDown(t);const e=this.upperCanvasEl,r=this._getEventPrefix();Yt(e,`${r}move`,this._onMouseMove,$t);const s=Gt(e);Me(s,`${r}up`,this._onMouseUp),Me(s,`${r}move`,this._onMouseMove,$t),this._resetTransformEventData()}_onTouchEnd(t){if(t.touches.length>0)return;this._cacheTransformEventData(t),this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),r=Gt(this.upperCanvasEl);Yt(r,"touchend",this._onTouchEnd,$t),Yt(r,"touchmove",this._onMouseMove,$t),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{Me(this.upperCanvasEl,`${e}down`,this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this._cacheTransformEventData(t),this.__onMouseUp(t);const e=this.upperCanvasEl,r=this._getEventPrefix();if(this._isMainEvent(t)){const s=Gt(this.upperCanvasEl);Yt(s,`${r}up`,this._onMouseUp),Yt(s,`${r}move`,this._onMouseMove,$t),Me(e,`${r}move`,this._onMouseMove,$t)}this._resetTransformEventData()}_onMouseMove(t){this._cacheTransformEventData(t);const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t),this._resetTransformEventData()}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._handleEvent(t,"up:before");const r=this._currentTransform,s=this._isClick,{target:n}=this.findTarget(t),{button:o}=t;if(o)return void((this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"));if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(r&&(this._finalizeCurrentTransform(t),c=r.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),qi(t)),{key:u,control:d}=h||{};if(l=u,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,t),c=!0;else if(d){const g=d.getMouseUpHandler(t,n,d);g&&(a=this.getScenePoint(t),g.call(d,t,r,a.x,a.y))}n.isMoving=!1}if(r&&(r.target!==n||r.corner!==l)){const h=r.target&&r.target.controls[r.corner],u=h&&h.getMouseUpHandler(t,r.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,r,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:r,subTargets:s=[]}=e;this.fire(t,e),r&&r.fire(t,e);for(let n=0;n<s.length;n++)s[n]!==r&&s[n].fire(t,e);return e}_handleEvent(t,e,r){const{target:s,subTargets:n}=this.findTarget(t),o={e:t,target:s,subTargets:n,...$e(this,t),transform:this._currentTransform,...e==="down:before"||e==="down"?r:{}};e!=="up:before"&&e!=="up"||(o.isClick=this._isClick),this.fire(`mouse:${e}`,o),s&&s.fire(`mouse${e}`,o);for(let a=0;a<n.length;a++)n[a]!==s&&n[a].fire(`mouse${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._handleEvent(t,"down:before");let{target:e}=this.findTarget(t),r=!!e&&e===this._activeObject;const{button:s}=t;if(s)return void((this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:r}));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(r=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),qi(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,r);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:r}),n&&this.requestRenderAll()}_resetTransformEventData(){this._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(t),this._scenePoint=ir(this._viewportPoint,void 0,this.viewportTransform),this._targetInfo=this.findTarget(t),this._currentTransform&&(this._targetInfo.target=this._currentTransform.target)}__onMouseMove(t){if(this._isClick=!1,this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const r=this.getScenePoint(t);e.deltaX=r.x-e.x,e.deltaY=r.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const{target:r}=this.findTarget(t);this._setCursorFromEvent(t,r),this._fireOverOutEvents(t,r)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move")}_fireOverOutEvents(t,e){const{_hoveredTarget:r,_hoveredTargets:s}=this,{subTargets:n}=this.findTarget(t),o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:r,fireCanvas:!0});for(let a=0;a<o;a++)n[a]===e||s[a]&&s[a]===r||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=n}_fireEnterLeaveEvents(t,e,r){const s=this._draggedoverTarget,n=this._hoveredTargets,{subTargets:o}=this.findTarget(t),a=Math.max(n.length,o.length);this.fireSyntheticInOutEvents("drag",{...r,target:e,oldTarget:s,fireCanvas:!0});for(let l=0;l<a;l++)this.fireSyntheticInOutEvents("drag",{...r,target:o[l],oldTarget:n[l]});this._draggedoverTarget=e}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:s,fireCanvas:n,e:o,...a}=e;const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=Fd[t],d=s!==r;if(s&&d){const g={...a,e:o,target:s,nextTarget:r,...$e(this,o)};n&&this.fire(u,g),s.fire(c,g)}if(r&&d){const g={...a,e:o,target:r,previousTarget:s,...$e(this,o)};n&&this.fire(h,g),r.fire(l,g)}}_transformObject(t){const e=this.getScenePoint(t),r=this._currentTransform,s=r.target,n=s.group?ir(e,void 0,s.group.calcTransformMatrix()):e;r.shiftKey=t.shiftKey,r.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,r,n),r.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,r){const{action:s,actionHandler:n,target:o}=e,a=!!n&&n(t,e,r.x,r.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 r=e.hoverCursor||this.hoverCursor;const s=Ie(this._activeObject)?this._activeObject:null,n=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(n){const{control:o,coord:a}=n;this.setCursor(o.cursorStyleHandler(t,o,e,a))}else{if(e.subTargetCheck){const{subTargets:o}=this.findTarget(t);o.concat().reverse().forEach(a=>{r=a.hoverCursor||r})}this.setCursor(r)}}handleMultiSelection(t,e){const r=this._activeObject,s=Ie(r);if(r&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(r!==e||s)&&(s||!e.isDescendantOf(r)&&!r.isDescendantOf(e))&&!e.onSelect({e:t})&&!r.getActiveControl()){if(s){const n=r.getObjects();let o=[];if(e===r){const a=this.getScenePoint(t);let l=this.searchPossibleTargets(n,a);if(l.target?(e=l.target,o=l.subTargets):(l=this.searchPossibleTargets(this._objects,a),e=l.target,o=l.subTargets),!e||!e.selectable)return!1}e.group===r?(r.remove(e),this._hoveredTarget=e,this._hoveredTargets=o,r.size()===1&&this._setActiveObject(r.item(0),t)):(r.multiSelectAdd(e),this._hoveredTarget=r,this._hoveredTargets=o),this._fireSelectionEvents(n,t)}else{r.isEditing&&r.exitEditing();const n=new(j.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(r,e),this._hoveredTarget=n,this._setActiveObject(n,t),this._fireSelectionEvents([r],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:r,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,r),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}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=j.getClass("ActiveSelection");this.setActiveObject(new d(u,{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:r}=this.elements;r.ctx=void 0;const s=super.toCanvasElement(t,e);return r.ctx=r.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const hl={x1:0,y1:0,x2:0,y2:0},jd={...hl,r1:0,r2:0},ur=(i,t)=>isNaN(i)&&typeof t=="number"?t:i;function ul(i){return i&&/%$/.test(i)&&Number.isFinite(parseFloat(i))}function dl(i,t){const e=typeof i=="number"?i:typeof i=="string"?parseFloat(i)/(ul(i)?100:1):NaN;return or(0,ur(e,t),1)}const Id=/\s*;\s*/,Bd=/\s*:\s*/;function Rd(i,t){let e,r;const s=i.getAttribute("style");if(s){const o=s.split(Id);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Bd).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(r=c)}}e=e||i.getAttribute("stop-color")||"rgb(0,0,0)",r=ur(parseFloat(r||i.getAttribute("stop-opacity")||""),1);const n=new rt(e);return n.setAlpha(n.getAlpha()*r*t),{offset:dl(i.getAttribute("offset"),0),color:n.toRgba()}}function $d(i,t){const e=[],r=i.getElementsByTagName("stop"),s=dl(t,1);for(let n=r.length;n--;)e.push(Rd(r[n],s));return e}function gl(i){return i.nodeName==="linearGradient"||i.nodeName==="LINEARGRADIENT"?"linear":"radial"}function fl(i){return i.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Kt(i,t){return i.getAttribute(t)}function zd(i,t){return function(e,r){let s,{width:n,height:o,gradientUnits:a}=r;return Object.entries(e).reduce((l,c)=>{let[h,u]=c;if(u==="Infinity")s=1;else if(u==="-Infinity")s=0;else{const d=typeof u=="string";s=d?parseFloat(u):u,d&&ul(u)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l},{})}(gl(i)==="linear"?function(e){return{x1:Kt(e,"x1")||0,y1:Kt(e,"y1")||0,x2:Kt(e,"x2")||"100%",y2:Kt(e,"y2")||0}}(i):function(e){return{x1:Kt(e,"fx")||Kt(e,"cx")||"50%",y1:Kt(e,"fy")||Kt(e,"cy")||"50%",r1:0,x2:Kt(e,"cx")||"50%",y2:Kt(e,"cy")||"50%",r2:Kt(e,"r")||"50%"}}(i),{...t,gradientUnits:fl(i)})}class qs{constructor(t){const{type:e="linear",gradientUnits:r="pixels",coords:s={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:{...e==="radial"?jd:hl,...s},colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?`${c}_${ke()}`:ke()})}addColorStop(t){for(const e in t)this.colorStops.push({offset:parseFloat(e),color:t[e]});return this}toObject(t){return{...sr(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 r=[],s=this.gradientTransform?this.gradientTransform.concat():Tt.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(d=>({...d})).sort((d,g)=>d.offset-g.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_${q(String(this.id))}"`,`gradientUnits="${n}"`,`gradientTransform="${e?e+" ":""}${Fr(s)}"`,""].join(" "),u=d=>parseFloat(String(d));if(this.type==="linear"){const{x1:d,y1:g,x2:f,y2:m}=this.coords,y=u(d),b=u(g),w=u(f),T=u(m);r.push("<linearGradient ",h,' x1="',y,'" y1="',b,'" x2="',w,'" y2="',T,`">
77
+ `)}else if(this.type==="radial"){const{x1:d,y1:g,x2:f,y2:m,r1:y,r2:b}=this.coords,w=u(d),T=u(g),C=u(f),S=u(m),D=u(y),A=u(b),_=D>A;r.push("<radialGradient ",h,' cx="',_?w:C,'" cy="',_?T:S,'" r="',_?D:A,'" fx="',_?C:w,'" fy="',_?S:T,`">
78
+ `),_&&(o.reverse(),o.forEach(O=>{O.offset=1-O.offset}));const M=Math.min(D,A);if(M>0){const O=M/Math.max(D,A);o.forEach(V=>{V.offset+=O*(1-V.offset)})}}return o.forEach(d=>{let{color:g,offset:f}=d;r.push(`<stop offset="${100*f}%" style="stop-color:${g};"/>
79
79
  `)}),r.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
80
- `),r.join("")}toLive(t){const{x1:e,y1:r,x2:s,y2:n,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,r,s,n):t.createRadialGradient(e,r,o,s,n,a);return this.colorStops.forEach(c=>{let{color:h,opacity:u,offset:d}=c;l.addColorStop(d,u!==void 0?new rt(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:r}=t;return new this(y(y({},t),{},{colorStops:e?e.map(s=>y({},s)):void 0,gradientTransform:r?[...r]:void 0}))}static fromElement(t,e,r){const s=bl(t),n=e._findCenterFromElement();return new this(y({id:t.getAttribute("id")||void 0,type:yl(t),coords:qd(t,{width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height}),colorStops:$d(t,r.opacity),gradientUnits:s,gradientTransform:un(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}m($s,"type","Gradient"),R.setClass($s,"gradient"),R.setClass($s,"linear"),R.setClass($s,"radial");const Kd=["type","source","patternTransform"];class vn{get type(){return"pattern"}set type(t){Te("warn","Setting type has no effect",t)}constructor(t){m(this,"repeat","repeat"),m(this,"offsetX",0),m(this,"offsetY",0),m(this,"crossOrigin",""),this.id=Oe(),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:r}=this;return y(y({},er(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:it(this.offsetX,Q.NUM_FRACTION_DIGITS),offsetY:it(this.offsetY,Q.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:r}=t;const{source:s,repeat:n,id:o}=this,a=hr(this.offsetX/e,0),l=hr(this.offsetY/r,0),c=n==="repeat-y"||n==="no-repeat"?1+Math.abs(a||0):hr(s.width/e,0),h=n==="repeat-x"||n==="no-repeat"?1+Math.abs(l||0):hr(s.height/r,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(`
81
- `)}static async fromObject(t,e){let{type:r,source:s,patternTransform:n}=t,o=ot(t,Kd);const a=await Ps(s,y(y({},e),{},{crossOrigin:o.crossOrigin}));return new this(y(y({},o),{},{patternTransform:n&&n.slice(0),source:a}))}}m(vn,"type","Pattern"),R.setClass(vn),R.setClass(vn,"pattern");class Zd{constructor(t){m(this,"color","rgb(0, 0, 0)"),m(this,"width",1),m(this,"shadow",null),m(this,"strokeLineCap","round"),m(this,"strokeLineJoin","round"),m(this,"strokeMiterLimit",10),m(this,"strokeDashArray",null),m(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new rt(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,r=t.contextTop,s=t.getZoom()*t.getRetinaScaling();r.shadowColor=e.color,r.shadowBlur=e.blur*s,r.shadowOffsetX=e.offsetX*s,r.shadowOffsetY=e.offsetY*s}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}const Jd=["path","left","top"],Qd=["d"];class Pe extends yt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:r,left:s,top:n}=e,o=ot(e,Jd);super(),Object.assign(this,Pe.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(et,s),typeof n=="number"&&this.set(Dt,n)}_setPath(t,e){this.path=Md(Array.isArray(t)?t:Bd(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new _(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,r=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+r);break;case"M":t.moveTo(s[1]+e,s[2]+r);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+r,s[3]+e,s[4]+r,s[5]+e,s[6]+r);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+r,s[3]+e,s[4]+r);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=fl(this.path,Q.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
82
- `)]}_getOffsetTransform(){const t=Q.NUM_FRACTION_DIGITS;return" translate(".concat(it(-this.pathOffset.x,t),", ").concat(it(-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:r,pathOffset:s}=this._calcDimensions();this.set({width:e,height:r,pathOffset:s}),t&&this.setPositionByOrigin(s,$,$)}_calcBoundsFromPath(){const t=[];let e=0,r=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:r},{x:s,y:n});break;case"M":s=o[1],n=o[2],e=s,r=n;break;case"C":t.push(...ol(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(...ol(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=r}return me(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return y(y({},t),{},{pathOffset:new _(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){const s=be(t,this.ATTRIBUTE_NAMES,r),{d:n}=s;return new this(n,y(y(y({},ot(s,Qd)),e),{},{left:void 0,top:void 0}))}}m(Pe,"type","Path"),m(Pe,"cacheProperties",[...ve,"path","fillRule"]),m(Pe,"ATTRIBUTE_NAMES",[...De,"d"]),R.setClass(Pe),R.setSVGClass(Pe);class qs extends Zd{constructor(t){super(t),m(this,"decimate",.4),m(this,"drawStraightLine",!1),m(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,r){const s=e.midPointFrom(r);return t.quadraticCurveTo(e.x,e.y,s.x,s.y),s}onMouseDown(t,e){let{e:r}=e;this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:r}=e;if(this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],(this.limitedToCanvasSize!==!0||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const s=this._points,n=s.length,o=this.canvas.contextTop;this._saveAndTransform(o),this.oldEnd&&(o.beginPath(),o.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=qs.drawSegment(o,s[n-2],s[n-1]),o.stroke(),o.restore()}}onMouseUp(t){let{e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.canvas.contextTop,e=this._points[0],r=this._points[1];if(this._saveAndTransform(t),t.beginPath(),this._points.length===2&&e.x===r.x&&e.y===r.y){const s=this.width/1e3;e.x-=s,r.x+=s}t.moveTo(e.x,e.y);for(let s=1;s<this._points.length;s++)qs.drawSegment(t,e,r),e=this._points[s],r=this._points[s+1];t.lineTo(e.x,e.y),t.stroke(),t.restore()}convertPointsToSVGPath(t){const e=this.width/1e3;return zd(t,e)}createPath(t){const e=new Pe(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,e.shadow=new oe(this.shadow)),e}decimatePoints(t,e){if(t.length<=2)return t;let r,s=t[0];const n=this.canvas.getZoom(),o=Math.pow(e/n,2),a=t.length-1,l=[s];for(let c=1;c<a-1;c++)r=Math.pow(s.x-t[c].x,2)+Math.pow(s.y-t[c].y,2),r>=o&&(s=t[c],l.push(s));return l.push(t[a]),l}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(r){return fl(r)==="M 0 0 Q 0 0 0 0 L 0 0"}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const tg=["left","top","radius"],wl=["radius","startAngle","endAngle","counterClockwise"];class xe extends yt{static getDefaults(){return y(y({},super.getDefaults()),xe.ownDefaults)}constructor(t){super(),Object.assign(this,xe.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,pt(this.startAngle),pt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(Et)}getRadiusY(){return this.get("radius")*this.get(Vt)}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([...wl,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
83
- `];{const{radius:e}=this,r=pt(this.startAngle),s=pt(this.endAngle),n=de(r)*e,o=ge(r)*e,a=de(s)*e,l=ge(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",` />
84
- `]}}static async fromElement(t,e,r){const s=be(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:o=0,radius:a=0}=s;return new this(y(y({},ot(s,tg)),{},{radius:a,left:n-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}m(xe,"type","Circle"),m(xe,"cacheProperties",[...ve,...wl]),m(xe,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),m(xe,"ATTRIBUTE_NAMES",["cx","cy","r",...De]),R.setClass(xe),R.setSVGClass(xe);const eg=["x1","y1","x2","y2"],rg=["x1","y1","x2","y2"],yn=["x1","x2","y1","y2"];class Jt extends yt{constructor(){let[t,e,r,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,Jt.ownDefaults),this.setOptions(n),this.x1=t,this.x2=r,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=n;typeof o=="number"&&this.set(et,o),typeof a=="number"&&this.set(Dt,a)}_setWidthHeight(){const{x1:t,y1:e,x2:r,y2:s}=this;this.width=Math.abs(r-t),this.height=Math.abs(s-e);const{left:n,top:o,width:a,height:l}=me([{x:t,y:e},{x:r,y:s}]),c=new _(n+a/2,o+l/2);this.setPositionByOrigin(c,$,$)}_set(t,e){return super._set(t,e),yn.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 r=t.strokeStyle;var s;Xt(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=r}_findCenterFromElement(){return new _((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:r,y2:s,width:n,height:o}=this,a=t<=e?-1:1,l=r<=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:r,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(r,'" x2="').concat(e,'" y2="').concat(s,`" />
85
- `)]}static async fromElement(t,e,r){const s=be(t,this.ATTRIBUTE_NAMES,r),{x1:n=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([n,o,a,l],ot(s,eg))}static fromObject(t){let{x1:e,y1:r,x2:s,y2:n}=t,o=ot(t,rg);return this._fromObject(y(y({},o),{},{points:[e,r,s,n]}),{extraParam:"points"})}}m(Jt,"type","Line"),m(Jt,"cacheProperties",[...ve,...yn]),m(Jt,"ATTRIBUTE_NAMES",De.concat(yn)),R.setClass(Jt),R.setSVGClass(Jt);class Be extends yt{static getDefaults(){return y(y({},super.getDefaults()),Be.ownDefaults)}constructor(t){super(),Object.assign(this,Be.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,r),t.lineTo(0,-r),t.lineTo(e,r),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),'" />']}}m(Be,"type","Triangle"),m(Be,"ownDefaults",{width:100,height:100}),R.setClass(Be),R.setSVGClass(Be);const xl=["rx","ry"];class Qt extends yt{static getDefaults(){return y(y({},super.getDefaults()),Qt.ownDefaults)}constructor(t){super(),Object.assign(this,Qt.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(Et)}getRy(){return this.get("ry")*this.get(Vt)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...xl,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
86
- `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,xs,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){const s=be(t,this.ATTRIBUTE_NAMES,r);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function sg(i){if(!i)return[];const t=i.replace(/,/g," ").trim().split(/\s+/),e=[];for(let r=0;r<t.length;r+=2)e.push({x:parseFloat(t[r]),y:parseFloat(t[r+1])});return e}m(Qt,"type","Ellipse"),m(Qt,"cacheProperties",[...ve,...xl]),m(Qt,"ownDefaults",{rx:0,ry:0}),m(Qt,"ATTRIBUTE_NAMES",[...De,"cx","cy","rx","ry"]),R.setClass(Qt),R.setSVGClass(Qt);const ig=["left","top"],_l={exactBoundingBox:!1};class te extends yt{static getDefaults(){return y(y({},super.getDefaults()),te.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),m(this,"strokeDiff",void 0),Object.assign(this,te.ownDefaults),this.setOptions(e),this.points=t;const{left:r,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof r=="number"&&this.set(et,r),typeof s=="number"&&this.set(Dt,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Nu(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 _,strokeOffset:new _,strokeDiff:new _};const r=me(e),s=Es(y(y({},t),{},{scaleX:1,scaleY:1})),n=me(this.points.map(c=>At(c,s,!0))),o=new _(this.scaleX,this.scaleY);let a=r.left+r.width/2,l=r.top+r.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(pt(this.skewX)),l-=a*Math.tan(pt(this.skewY))),y(y({},r),{},{pathOffset:new _(a,l),strokeOffset:new _(n.left,n.top).subtract(new _(r.left,r.top)).multiply(o),strokeDiff:new _(r.width,r.height).subtract(new _(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=me(this.points);return new _(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:r,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 _(e+s/2,r+n/2),$,$)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new _(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,r;const{width:a,height:l}=this._calcDimensions(t);o=new _((e=t.width)!==null&&e!==void 0?e:a,(r=t.height)!==null&&r!==void 0?r:l)}else{var s,n;o=new _((s=t.width)!==null&&s!==void 0?s:this.width,(n=t.height)!==null&&n!==void 0?n:this.height)}return o.multiply(new _(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const r=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&r&&((t===Et||t===Vt)&&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:r,y:s}=e;return{x:r,y:s}})})}_toSVG(){const t=[],e=this.pathOffset.x,r=this.pathOffset.y,s=Q.NUM_FRACTION_DIGITS;for(let n=0,o=this.points.length;n<o;n++)t.push(it(this.points[n].x-e,s),",",it(this.points[n].y-r,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
87
- `)]}_render(t){const e=this.points.length,r=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-r,this.points[0].y-s);for(let n=0;n<e;n++){const o=this.points[n];t.lineTo(o.x-r,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,r){return new this(sg(t.getAttribute("points")),y(y({},ot(be(t,this.ATTRIBUTE_NAMES,r),ig)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}m(te,"ownDefaults",_l),m(te,"type","Polyline"),m(te,"layoutProperties",[Ke,Ze,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),m(te,"cacheProperties",[...ve,"points"]),m(te,"ATTRIBUTE_NAMES",[...De]),R.setClass(te),R.setSVGClass(te);class Xr extends te{isOpen(){return!1}}m(Xr,"ownDefaults",_l),m(Xr,"type","Polygon"),R.setClass(Xr),R.setSVGClass(Xr);class Cl extends yt{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 r in e)for(const s in e[r])for(const n in e[r][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const r=e===void 0?this.styles:{0:this.styles[e]};for(const s in r)for(const n in r[s])if(r[s][n][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let r,s,n=0,o=!0,a=0;for(const l in e){r=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?r++:delete e[l][c]}r===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 r,s,n;for(s in e){for(n in r=e[s],r)delete r[n][t],Object.keys(r[n]).length===0&&delete r[n];Object.keys(r).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:r,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(r)||this._setLineStyle(r);const n=Xi(y(y({},this._getStyleDeclaration(r,s)),e),o=>o!==void 0);this._setStyleDeclaration(r,s,n)}getSelectionStyles(t,e,r){const s=[];for(let n=t;n<(e||t);n++)s.push(this.getStyleAtPosition(n,r));return s}getStyleAtPosition(t,e){const{lineIndex:r,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(r,s):this._getStyleDeclaration(r,s)}setSelectionStyles(t,e,r){for(let s=e;s<(r||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var r;const s=this.styles&&this.styles[t];return s&&(r=s[e])!==null&&r!==void 0?r:{}}getCompleteStyleDeclaration(t,e){return y(y({},er(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,r){this.styles[t][e]=r}_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]}}m(Cl,"_styleProperties",lu);const ng=/ +/g,og=/"/g;function bn(i,t,e,r,s){return" ".concat(function(n,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Q.NUM_FRACTION_DIGITS;const d=jr(xt,n,!1),[g,f,p,v]=[a,l,c,h].map(b=>it(b,u));return"<rect ".concat(d,' x="').concat(g,'" y="').concat(f,'" width="').concat(p,'" height="').concat(v,'"></rect>')}(i,{left:t,top:e,width:r,height:s}),`
88
- `)}const ag=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let wn;class kt extends Cl{static getDefaults(){return y(y({},super.getDefaults()),kt.ownDefaults)}constructor(t,e){super(),m(this,"__charBounds",[]),Object.assign(this,kt.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=dl(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(ne)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,s,n,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===ne||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)))){r=a.length,t=(this.width-e)/r;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 r=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<r.length;s++){if(t<=r[s].length)return{lineIndex:s,charIndex:t};t-=r[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:r[s-1].length<t?r[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===Pt?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,r){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case $:t.textBaseline="middle";break;case"ascender":t.textBaseline=Dt;break;case"descender":t.textBaseline=Ri}t.font=this._getFontDeclaration(e,r)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,r=this._textLines.length;e<r;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,r,s,n,o){this._renderChars(t,e,r,s,n,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,r=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,u,d=0,g=0,f=this.getValueOfPropertyAt(n,0,"textBackgroundColor");const p=this.getHeightOfLineImpl(n);for(let v=0;v<l;v++){const b=this.__charBounds[n][v];u=this.getValueOfPropertyAt(n,v,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=u,u&&t.fillRect(-b.width/2,-p*(1-this._fontSizeFraction),b.width,p),t.restore()):u!==f?(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,s,d,p),g=b.left,d=b.width,f=u):d+=b.kernedWidth}u&&!this.path&&(h=r+c+g,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,s,d,p)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,s){const n=Or.getFontCache(e),o=this._getFontDeclaration(e),a=r?r+t:t,l=r&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,g;if(r&&n.has(r)&&(d=n.get(r)),n.has(t)&&(g=h=n.get(t)),l&&n.has(a)&&(u=n.get(a),g=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return wn||(wn=Wt({width:0,height:0}).getContext("2d")),wn}();this._setTextStyles(f,e,!0),h===void 0&&(g=h=f.measureText(t).width,n.set(t,h)),d===void 0&&l&&r&&(d=f.measureText(r).width,n.set(r,d)),l&&u===void 0&&(u=f.measureText(a).width,n.set(a,u),g=u-d)}return{width:h*c,kernedWidth:g*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,r,s=0;const n=this.pathSide===ft,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 u=a[h];r=this._getGraphemeBox(u,t,h,e),c[h]=r,s+=r.kernedWidth,e=u}if(c[l]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case et:h=n?u-s:0;break;case $:h=(u-s)/2;break;case ft:h=n?0:u-s}h+=this.pathStartOffset*(n?-1:1);for(let d=n?l-1:0;n?d>=0:d<l;n?d--:d++)r=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,r),h+=r.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const r=t+e.kernedWidth/2,s=this.path,n=jd(s.path,r,s.segmentsInfo);e.renderLeft=n.x-s.pathOffset.x,e.renderTop=n.y-s.pathOffset.y,e.angle=n.angle+(this.pathSide===ft?Math.PI:0)}_getGraphemeBox(t,e,r,s,n){const o=this.getCompleteStyleDeclaration(e,r),a=s?this.getCompleteStyleDeclaration(e,r-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(r>0&&!n){const g=this.__charBounds[e][r-1];d.left=g.left+g.width+l.kernedWidth-l.width}return d}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let r=this.getHeightOfChar(t,0);for(let s=1,n=this._textLines[t].length;s<n;s++)r=Math.max(this.getHeightOfChar(t,s),r);return e[t]=r*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,r=this._textLines.length;e<r;e++)t+=e===r-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 r=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+r+this.getHeightOfLineImpl(o),o),r+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(xt))&&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,r,s,n,o){const a=this.textAlign.includes(ne),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",u=this.direction==="ltr"?1:-1,d=e.direction;let g,f,p,v,b,x="",D=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?et:ft),n-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,r.join(""),s,n),void e.restore();for(let C=0,O=r.length-1;C<=O;C++)v=C===O||this.charSpacing||l,x+=r[C],p=this.__charBounds[o][C],D===0?(s+=u*(p.kernedWidth-p.width),D+=p.width):D+=p.kernedWidth,a&&!v&&this._reSpaceAndTab.test(r[C])&&(v=!0),v||(g=g||this.getCompleteStyleDeclaration(o,C),f=this.getCompleteStyleDeclaration(o,C+1),v=cn(g,f,!1)),v&&(l?(e.save(),e.translate(p.renderLeft,p.renderTop),e.rotate(p.angle),this._renderChar(t,e,o,C,x,-D/2,0),e.restore()):(b=s,this._renderChar(t,e,o,C,x,b,n)),x="",g=f,s+=u*D,D=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,s=Wt({width:e,height:r}),n=s.getContext("2d");return s.width=e,s.height=r,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,r),n.lineTo(0,r),n.closePath(),n.translate(e/2,r/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(s,"no-repeat")}handleFiller(t,e,r){let s,n;return Xt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?(s=-this.width/2,n=-this.height/2,t.translate(s,n),t[e]=this._applyPatternGradientTransformText(r),{offsetX:s,offsetY:n}):(t[e]=r.toLive(t),this._applyPatternGradientTransform(t,r)):(t[e]=r,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:r,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",r)}_setFillStyles(t,e){let{fill:r}=e;return this.handleFiller(t,"fillStyle",r)}_renderChar(t,e,r,s,n,o,a){const l=this._getStyleDeclaration(r,s),c=this.getCompleteStyleDeclaration(r,s),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(n,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(n,o-d.offsetX,a-d.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,r){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*r.size,deltaY:o+n*r.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),r=this.width-e,s=this.textAlign,n=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===ne||s===Rr&&!o||s===Fr&&!o||s===zs&&!o?0:(s===$&&(a=r/2),s===ft&&(a=r),s===Rr&&(a=r/2),s===Fr&&(a=r),n==="rtl"&&(s===ft||s===ne||s===Fr?a=0:s===et||s===zs?a=-r:s!==$&&s!==Rr||(a=-r/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,r){var s;return(s=this._getStyleDeclaration(t,e)[r])!==null&&s!==void 0?s:this[r]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let r=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 u=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){r+=u;continue}const d=this._textLines[c],g=u/this.lineHeight,f=this._getLineLeftOffset(c);let p=0,v=0,b=this.getValueOfPropertyAt(c,0,e),x=this.getValueOfPropertyAt(c,0,xt),D=this.getValueOfPropertyAt(c,0,Ie),C=b,O=x,S=D;const j=r+g*(1-this._fontSizeFraction);let T=this.getHeightOfChar(c,0),L=this.getValueOfPropertyAt(c,0,"deltaY");for(let V=0,U=d.length;V<U;V++){const X=this.__charBounds[c][V];C=this.getValueOfPropertyAt(c,V,e),O=this.getValueOfPropertyAt(c,V,xt),S=this.getValueOfPropertyAt(c,V,Ie);const tt=this.getHeightOfChar(c,V),Z=this.getValueOfPropertyAt(c,V,"deltaY");if(n&&C&&O){const J=this.fontSize*S/1e3;t.save(),t.fillStyle=x,t.translate(X.renderLeft,X.renderTop),t.rotate(X.angle),t.fillRect(-X.kernedWidth/2,l*tt+Z-a*J,X.kernedWidth,J),t.restore()}else if((C!==b||O!==x||tt!==T||S!==D||Z!==L)&&v>0){const J=this.fontSize*D/1e3;let A=s+f+p;this.direction==="rtl"&&(A=this.width-A-v),b&&x&&D&&(t.fillStyle=x,t.fillRect(A,j+l*T+L-a*J,v,J)),p=X.left,v=X.width,b=C,D=S,x=O,T=tt,L=Z}else v+=X.kernedWidth}let H=s+f+p;this.direction==="rtl"&&(H=this.width-H-v),t.fillStyle=O;const W=this.fontSize*S/1e3;C&&O&&S&&t.fillRect(H,j+l*T+L-a*W,v-o,W),r+=u}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:r=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(",")||kt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,r,"".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 ln(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),r=new Array(e.length),s=[`
89
- `];let n=[];for(let o=0;o<e.length;o++)r[o]=this.graphemeSplit(e[o]),n=n.concat(r[o],s);return n.pop(),{_unwrappedLines:r,lines:e,graphemeText:n,graphemeLines:r}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject([...ka,...t])),{},{styles:Ku(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:r}=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||r.includes(o),n=n||o==="path";else s=r.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,r){const s=be(t,kt.ATTRIBUTE_NAMES,r),n=y(y({},e),s),{textAnchor:o=et,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=Fi,strokeWidth:g=1}=n,f=ot(n,ag),p=new this(Rs(t.textContent||"").trim(),y({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},f)),v=p.getScaledHeight()/p.height,b=((p.height+p.strokeWidth)*p.lineHeight-p.height)*v,x=p.getScaledHeight()+b;let D=0;return o===$&&(D=p.getScaledWidth()/2),o===ft&&(D=p.getScaledWidth()),p.set({left:p.left-D,top:p.top-(x-p.fontSize*(.07+p._fontSizeFraction))/p.lineHeight,strokeWidth:g}),p}static fromObject(t){return this._fromObject(y(y({},t),{},{styles:Zu(t.styles||{},t.text)}),{extraParam:"text"})}}m(kt,"textLayoutProperties",Ta),m(kt,"cacheProperties",[...ve,...ka]),m(kt,"ownDefaults",cu),m(kt,"type","Text"),m(kt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),m(kt,"ATTRIBUTE_NAMES",De.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Ua(kt,[class extends _a{_toSVG(){const i=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(i.textTop,i.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(i){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:i,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:i,withShadow:!0,additionalTransform:Ar(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(i){let{textBgRects:t,textSpans:e}=i;const r=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(og,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",r?'text-decoration="'.concat(r,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
90
- `]}_getSVGTextAndBg(i,t){const e=[],r=[];let s,n=i;this.backgroundColor&&r.push(...bn(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(r,o,t+s,n),this._setSVGTextLineText(e,o,t+s,n),n+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:r}}_createTextCharSpan(i,t,e,r,s){const n=Q.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,i!==i.trim()||!!i.match(ng)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(it(l,n),'" '):"",{angle:h,renderLeft:u,renderTop:d,width:g}=s;let f="";if(u!==void 0){const p=g/2;h&&(f=' rotate="'.concat(it(pe(h),n),'"'));const v=tr({angle:pe(h)});v[4]=u,v[5]=d;const b=new _(-p,0).transform(v);e=b.x,r=b.y}return'<tspan x="'.concat(it(e,n),'" y="').concat(it(r,n),'" ').concat(c).concat(f).concat(a,">").concat(Gu(i),"</tspan>")}_setSVGTextLineText(i,t,e,r){const s=this.getHeightOfLine(t),n=this.textAlign.includes(ne),o=this._textLines[t];let a,l,c,h,u,d="",g=0;r+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,p=o.length-1;f<=p;f++)u=f===p||this.charSpacing||this.path,d+=o[f],c=this.__charBounds[t][f],g===0?(e+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=cn(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),i.push(this._createTextCharSpan(d,h,e,r,c)),d="",a=l,this.direction==="rtl"?e-=g:e+=g,g=0)}_setSVGTextLineBg(i,t,e,r){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:u,width:d,kernedWidth:g}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&i.push(...bn(c,e+l,r,a,n)),l=u,a=d,c=o):a+=g}o&&i.push(...bn(c,e+l,r,a,n))}_getSVGLineTopOffset(i){let t,e=0;for(t=0;t<i;t++)e+=this.getHeightOfLine(t);const r=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*r/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(i){return"".concat(super.getSvgStyles(i)," text-decoration-thickness: ").concat(it(this.textDecorationThickness*this.getObjectScaling().y/10,Q.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(i,t){const{fontFamily:e,strokeWidth:r,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:u,overline:d,underline:g}=i,f=this.getSvgTextDecoration({underline:g??this.underline,overline:d??this.overline,linethrough:u??this.linethrough}),p=h||this.textDecorationThickness;return[s?jr(Pt,s):"",r?"stroke-width: ".concat(r,"; "):"",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,"; "):"",f?"text-decoration: ".concat(f,"; text-decoration-thickness: ").concat(it(p*this.getObjectScaling().y/10,Q.NUM_FRACTION_DIGITS),"%; "):"",n?jr(xt,n):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(i){return["overline","underline","line-through"].filter(t=>i[t.replace("-","")]).join(" ")}}]),R.setClass(kt),R.setSVGClass(kt);class lg{constructor(t){m(this,"target",void 0),m(this,"__mouseDownInPlace",!1),m(this,"__dragStartFired",!1),m(this,"__isDraggingOver",!1),m(this,"__dragStartSelection",void 0),m(this,"__dragImageDisposer",void 0),m(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(r=>r()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,r=e.getSelectionStartFromPointer(t);return e.isEditing&&r>=e.selectionStart&&r<=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 r;let{selectionStart:s,selectionEnd:n}=e;const o=this.target,a=o.canvas,l=new _(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new _(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),g=o.getBoundingRect(),f=h.subtract(new _(g.left,g.top)),p=a.viewportTransform,v=f.add(u).transform(p,!0),b=o.backgroundColor,x=an(o.styles);o.backgroundColor="";const D={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(D,0,s),o.setSelectionStyles(D,n,o.text.length),o.dirty=!0;const C=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=b,o.styles=x,o.dirty=!0,pn(C,{position:"fixed",left:"".concat(-C.width,"px"),border:Mt,width:"".concat(C.width/d,"px"),height:"".concat(C.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{C.remove()},Gt(t.target||this.target.hiddenTextarea).body.appendChild(C),(r=t.dataTransfer)===null||r===void 0||r.setDragImage(C,v.x,v.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,r=this.isActive();if(r&&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(),r}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),r=this.__dragStartSelection;return e<r.selectionStart||e>r.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const r=this.targetCanDrop(e);!this.__isDraggingOver&&r&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r?this.__isDraggingOver=!0:this.__isDraggingOver&&!r&&(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:r}=t,s=r.defaultPrevented;this.__isDraggingOver=!1,r.preventDefault();let n=(e=r.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(r);const{styles:c}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},h=n[Math.max(0,n.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,g=this.__dragStartSelection.selectionEnd;l>d&&l<=g?l=d:l>g&&(l-=g-d),o.removeChars(d,g),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(r),o.selectionStart=Math.min(l+u,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(Cs,{index:l+u,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 r;const s=this.target,n=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((r=e.dataTransfer)===null||r===void 0?void 0:r.dropEffect)||Mt;l===Mt?(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(Cs,{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 cg extends kt{constructor(){super(...arguments),m(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:r,delay:s,onComplete:n}=t;return Ia({startValue:this._currentCursorOpacity,endValue:e,duration:r,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,r=t-1;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r--;for(;/\S/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findWordBoundaryRight(t){let e=0,r=t;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r++;for(;/\S/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}findLineBoundaryLeft(t){let e=0,r=t-1;for(;!/\n/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findLineBoundaryRight(t){let e=0,r=t;for(;!/\n/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}searchWordBoundary(t,e){const r=this._text;let s=t>0&&this._reSpace.test(r[t])&&(e===-1||!Ii.test(r[t-1]))?t-1:t,n=r[s];for(;s>0&&s<r.length&&!Sl.test(n);)s+=e,n=r[s];return e===-1&&Sl.test(n)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const r=this.searchWordBoundary(t,-1),s=Math.max(r,this.searchWordBoundary(t,1));this.selectionStart=r,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const r=this.findLineBoundaryLeft(t),s=this.findLineBoundaryRight(t);this.selectionStart=r,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;Gt(e).activeElement!==e&&e.focus();const r=this.getSelectionStartFromPointer(t),s=this.selectionStart,n=this.selectionEnd;(r===this.__selectionStartOnMouseDown&&s!==n||s!==r&&n!==r)&&(r>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=r):(this.selectionStart=r,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,r){const s=r.slice(0,t),n=this.graphemeSplit(s).length;if(t===e)return{selectionStart:n,selectionEnd:n};const o=r.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,r){const s=r.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+r.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),r=this.get2DCursorLocation(t),s=r.lineIndex,n=r.charIndex,o=this.getValueOfPropertyAt(s,n,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,g=u-o,f=new _(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new _(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>g&&(f.y=g),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:"".concat(f.x,"px"),top:"".concat(f.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(Ts),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:r,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:o}=this.get2DCursorLocation(e,!0);if(r!==n){if(this.styles[r])for(let a=s;a<this._unwrappedTextLines[r].length;a++)delete this.styles[r][a];if(this.styles[n])for(let a=o;a<this._unwrappedTextLines[n].length;a++){const l=this.styles[n][a];l&&(this.styles[r]||(this.styles[r]={}),this.styles[r][s+a-o]=l)}for(let a=r+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,r-n)}else if(this.styles[r]){const a=this.styles[r],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[r]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const r=Object.assign({},this.styles);for(const s in this.styles){const n=parseInt(s,10);n>t&&(this.styles[n+e]=r[n],r[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,r,s){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;r||(r=1),this.shiftLineStyles(t,r);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,n[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+r]=n,h=!0),(h||o>e)&&r--;r>0;)s&&s[r-1]?this.styles[t+r]={0:y({},s[r-1])}:c?this.styles[t+r]={0:y({},c)}:delete this.styles[t+r],r--;this._forceClearCache=!0}insertCharStyleObject(t,e,r,s){this.styles||(this.styles={});const n=this.styles[t],o=n?y({},n):{};r||(r=1);for(const l in o){const c=parseInt(l,10);c>=e&&(n[c+r]=o[c],o[c-r]||delete n[c])}if(this._forceClearCache=!0,s){for(;r--;)Object.keys(s[r]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+r]=y({},s[r]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&r--;)this.styles[t][e+r]=y({},a)}insertNewStyleBlock(t,e,r){const s=this.get2DCursorLocation(e,!0),n=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
91
- `?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,n[0],r),r=r&&r.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],r):r&&this.styles[s.lineIndex+o]&&r[0]&&(this.styles[s.lineIndex+o][0]=r[0]),r=r&&r.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,n[o],r)}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,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r;s>r&&this.removeStyleFromTo(r,s);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,r,e),this._text=[...this._text.slice(0,r),...n,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,r){r<=t?(e===t?this._selectionDirection=et:this._selectionDirection===ft&&(this._selectionDirection=et,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===ft?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=ft:this._selectionDirection===et&&(this._selectionDirection=ft,this.selectionStart=e),this.selectionEnd=r)}}class hg extends cg{initHiddenTextarea(){const t=this.canvas&&Gt(this.canvas.getElement())||qe(),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:r,left:s,fontSize:n}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(r,"; 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:r,selectionStart:s,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Cs),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(r).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,u=this.selectionEnd,d=h!==u;let g,f,p,v,b=c-l;const x=this.fromStringToGraphemeSelection(s,n,r),D=h>x.selectionStart;d?(f=this._text.slice(h,u),b+=u-h):c<l&&(f=D?this._text.slice(u+b,u):this._text.slice(h,h-b));const C=a.slice(x.selectionEnd-b,x.selectionEnd);if(f&&f.length&&(C.length&&(g=this.getSelectionStyles(h,h+1,!1),g=C.map(()=>g[0])),d?(p=h,v=u):D?(p=u-f.length,v=u):(p=u,v=u+f.length),this.removeStyleFromTo(p,v)),C.length){const{copyPasteData:O}=ie();e&&C.join("")===O.copiedText&&!Q.disableStyleCopyPaste&&(g=O.copiedTextStyle),this.insertNewStyleBlock(C,h,g)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:r,selectionEnd:s}=e;this.compositionStart=r,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=ie();t.copiedText=this.getSelectedText(),Q.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 r,s=this._getLineLeftOffset(t);return e>0&&(r=this.__charBounds[t][e-1],s+=r.left+r.width),s}getDownCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(r),n=s.lineIndex;if(n===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-r;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 r=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(r),n=s.lineIndex;if(n===0||t.metaKey||t.keyCode===33)return-r;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 r=this._textLines[t];let s,n,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=r.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){n=!0;const h=o-s,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return n||(a=r.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 r=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===ft);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),r!==0){const s=this.text.length;this.selectionStart=ir(0,this.selectionStart,s),this.selectionEnd=ir(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===et?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,r){let s;if(t.altKey)s=this["findWordBoundary".concat(r)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=r==="Left"?-1:1,!0;s=this["findLineBoundary".concat(r)](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=et,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===ft&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=et,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 r="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[r](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===et&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=ft,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=ft,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Tl=i=>!!i.button;class ug extends hg{constructor(){super(...arguments),m(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 lg(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:r}=t;this.canvas&&this.editable&&!Tl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),r&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=r||this.isEditing)))}mouseUpHandler(t){let{e,transform:r}=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||r&&r.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),r=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(r,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Nt(this.calcTransformMatrix())).add(new _(-this._getLeftOffset(),-this._getTopOffset()));let r=0,s=0,n=0;for(let c=0;c<this._textLines.length&&r<=e.y;c++)r+=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 Ks="moveCursorUp",Zs="moveCursorDown",Js="moveCursorLeft",Qs="moveCursorRight",ti="exitEditing",kl=(i,t)=>{const e=t.getRetinaScaling();i.setTransform(e,0,0,e,0,0);const r=t.viewportTransform;i.transform(r[0],r[1],r[2],r[3],r[4],r[5])},dg=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:ti,27:ti,33:Ks,34:Zs,35:Qs,36:Js,37:Js,38:Ks,39:Qs,40:Zs},keysMapRtl:{9:ti,27:ti,33:Ks,34:Zs,35:Js,36:Qs,37:Qs,38:Ks,39:Js,40:Zs},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class ae extends ug{static getDefaults(){return y(y({},super.getDefaults()),ae.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,y(y({},ae.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 mn&&this.canvas.textEditingManager.remove(this),e instanceof mn&&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,r=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,r)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,r)}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 r=super.toCanvasElement(t);return this.isEditing=e,r}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),r=this.findAncestorsWithClipPath(),s=r.length>0;let n,o=t;if(s){n=Wt(t.canvas),o=n.getContext("2d"),kl(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 r){const l=a.clipPath,c=Wt(t.canvas),h=c.getContext("2d");if(kl(h,this.canvas),!l.absolutePositioned){const u=a.calcTransformMatrix();h.transform(u[0],u[1],u[2],u[3],u[4],u[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 r=this._getLeftOffset(),s=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:r,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,r=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&&(r=a.left),this.charSpacing!==0&&s===this._textLines[n].length&&(r-=this._getWidthOfCharSpacing());const l={top:e,left:o+(r>0?r:0)};return this.direction==="rtl"&&(this.textAlign===ft||this.textAlign===ne||this.textAlign===Fr?l.left*=-1:this.textAlign===et||this.textAlign===zs?l.left=o-(r>0?r:0):this.textAlign!==$&&this.textAlign!==Rr||(l.left=o-(r>0?r: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 r=this.get2DCursorLocation(t),s=r.lineIndex,n=r.charIndex>0?r.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,r){const{color:s,opacity:n,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(r,e);t.fillStyle=s,t.globalAlpha=n,t.fillRect(o,a,l,c)}renderSelection(t,e){const r={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,r,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,r){const s=e.selectionStart,n=e.selectionEnd,o=this.textAlign.includes(ne),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(n),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let g=c;g<=h;g++){const f=this._getLineLeftOffset(g)||0;let p=this.getHeightOfLine(g),v=0,b=0,x=0;if(g===c&&(b=this.__charBounds[c][u].left),g>=c&&g<h)x=o&&!this.isEndOfWrapping(g)?this.width:this.getLineWidth(g)||5;else if(g===h)if(d===0)x=this.__charBounds[h][d].left;else{const j=this._getWidthOfCharSpacing();x=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-j}v=p,(this.lineHeight<1||g===h&&this.lineHeight>1)&&(p/=this.lineHeight);let D=r.left+f+b,C=p,O=0;const S=x-b;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",C=1,O=p):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===ft||this.textAlign===ne||this.textAlign===Fr?D=this.width-D-S:this.textAlign===et||this.textAlign===zs?D=r.left+f-x:this.textAlign!==$&&this.textAlign!==Rr||(D=r.left+f-x)),t.fillRect(D,r.top+r.topOffset+O,S,C),r.topOffset+=v}}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,xt)}_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()}}m(ae,"ownDefaults",dg),m(ae,"type","IText"),R.setClass(ae),R.setClass(ae,"i-text");class ze extends ae{static getDefaults(){return y(y({},super.getDefaults()),ze.ownDefaults)}constructor(t,e){super(t,y(y({},ze.ownDefaults),e))}static createControls(){return{controls:Xu()}}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(ne)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,r=0,s=0;const n={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
92
- `&&o>0?(r=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(r++,s++),n[o]={line:e,offset:r},s+=t.graphemeLines[o].length,r+=t.graphemeLines[o].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[e];r&&(e=r.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,r=0,s=t+1,n=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,r=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 u=parseInt(h,10);if(u>=r&&(!n||u<e))for(const d in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[t];if(!r)return{};t=r.line,e=r.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,r){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,r)}_deleteStyleDeclaration(t,e){const r=this._styleMap[t];super._deleteStyleDeclaration(r.line,r.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 r=this.getGraphemeDataForRender(t),s=[];for(let n=0;n<r.wordsData.length;n++)s.push(...this._wrapLine(n,e,r));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,r=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),u=this._measureWord(h,o,a);return s=Math.max(u,s),a+=h.length+r.length,{word:h,width:u}})}),largestWordWidth:s}}_measureWord(t,e){let r,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,r,!0).kernedWidth,r=t[o];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,r){let{largestWordWidth:s,wordsData:n}=r,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],g=0,f=0,p=!0;e-=o;const v=Math.max(e,s,this.dynamicMinWidth),b=n[t];let x;for(g=0,x=0;x<b.length;x++){const{word:D,width:C}=b[x];g+=D.length,u+=f+C-a,u>v&&!p?(c.push(d),d=[],u=C,p=!0):u+=a,p||l||d.push(h),d=d.concat(D),f=l?0:this._measureWord([h],t,g),g++,p=!1}return x&&c.push(d),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),r=this._wrapText(e.lines,this.width),s=new Array(r.length);for(let n=0;n<r.length;n++)s[n]=r[n].join("");return e.lines=s,e.graphemeLines=r,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const r=parseInt(e,10);if(this._textLines[r]){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])}}m(ze,"type","Textbox"),m(ze,"textLayoutProperties",[...ae.textLayoutProperties,"width"]),m(ze,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),R.setClass(ze);class Ol extends Us{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:r}=t,{clipPath:s,group:n}=r;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=me(sl(r,s)),l=new _(o,a);if(s.absolutePositioned)return{center:rr(s.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new _,correction:u=new _}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:r.getRelativeCenterPoint().add(c),size:l}}}}m(Ol,"type","clip-path"),R.setClass(Ol);class Dl extends Us{getInitialSize(t,e){let{target:r}=t,{size:s}=e;return new _(r.width||s.x,r.height||s.y)}}m(Dl,"type","fixed"),R.setClass(Dl);class gg extends Vr{subscribeTargets(t){const e=t.target;t.targets.reduce((r,s)=>(s.parent&&r.add(s.parent),r),new Set).forEach(r=>{r.layoutManager.subscribeTargets({target:r,targets:[e]})})}unsubscribeTargets(t){const e=t.target,r=e.getObjects();t.targets.reduce((s,n)=>(n.parent&&s.add(n.parent),s),new Set).forEach(s=>{!r.some(n=>n.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})})}}class He extends Me{static getDefaults(){return y(y({},super.getDefaults()),He.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,He.ownDefaults),this.setOptions(e);const{left:r,top:s,layoutManager:n}=e;this.groupInit(t,{left:r,top:s,layoutManager:n??new gg})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];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))?(Te("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 r=new Set;e.forEach(s=>{const{parent:n}=s;n&&r.add(n)}),t===dn?r.forEach(s=>{s._onAfterObjectsChange(Xs,e)}):r.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,r){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=y(y({hasControls:!1},r),{},{forActiveSelection:!0});for(let n=0;n<this._objects.length;n++)this._objects[n]._renderControls(t,s);super._renderControls(t,e),t.restore()}}m(He,"type","ActiveSelection"),m(He,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),R.setClass(He),R.setClass(He,"activeSelection");class fg{constructor(){m(this,"resources",{})}applyFilters(t,e,r,s,n){const o=n.getContext("2d");if(!o)return;o.drawImage(e,0,0,r,s);const a={sourceWidth:r,sourceHeight:s,imageData:o.getImageData(0,0,r,s),originalEl:e,originalImageData:o.getImageData(0,0,r,s),canvasEl:n,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===r&&l.height===s||(n.width=l.width,n.height=l.height),o.putImageData(l,0,0),a}}class Ml{constructor(){let{tileSize:t=Q.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};m(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),m(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const r=Wt({width:t,height:e}),s=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=r,this.gl=s)}applyFilters(t,e,r,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:r,sourceHeight:s,destinationWidth:r,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,r,s,c?void 0:e),targetTexture:this.createTexture(a,r,s),originalTexture:c||this.createTexture(a,r,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const g=d.targetCanvas,f=g.width,p=g.height,v=d.destinationWidth,b=d.destinationHeight;f===v&&p===b||(g.width=v,g.height=b)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),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,r,s,n){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:g,TEXTURE_WRAP_T:f}=t,p=t.createTexture();return t.bindTexture(a,p),t.texParameteri(a,u,n||o),t.texParameteri(a,d,n||o),t.texParameteri(a,g,h),t.texParameteri(a,f,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,r,0,l,c,null),p}getCachedTexture(t,e,r){const{textureCache:s}=this;if(s[t])return s[t];{const n=this.createTexture(this.gl,e.width,e.height,e,r);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 r=t.canvas,s=e.targetCanvas,n=s.getContext("2d");if(!n)return;n.translate(0,s.height),n.scale(1,-1);const o=r.height-s.height;n.drawImage(r,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const r=e.targetCanvas.getContext("2d"),s=e.destinationWidth,n=e.destinationHeight,o=s*n*4;if(!r)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);r.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const r=t.getExtension("WEBGL_debug_renderer_info");if(r){const s=t.getParameter(r.UNMASKED_RENDERER_WEBGL),n=t.getParameter(r.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let xn;function pg(){const{WebGLProbe:i}=ie();return i.queryWebGL(fe()),Q.enableGLFiltering&&i.isSupported(Q.textureSize)?new Ml({tileSize:Q.textureSize}):new fg}function _n(){return!xn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(xn=pg()),xn}const mg=["filters","resizeFilter","src","crossOrigin","type"],El=["cropX","cropY"];class _t extends yt{static getDefaults(){return y(y({},super.getDefaults()),_t.ownDefaults)}constructor(t,e){super(),m(this,"_lastScaleX",1),m(this,"_lastScaleY",1),m(this,"_filterScalingX",1),m(this,"_filterScalingY",1),this.filters=[],Object.assign(this,_t.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Oe()),this.setElement(typeof t=="string"?(this.canvas&&Gt(this.canvas.getElement())||qe()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let r=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(r),(e=t.classList)===null||e===void 0||e.add(_t.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=_n(!1);e instanceof Ml&&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&&ie().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,r=this.height/2;t.beginPath(),t.moveTo(-e,-r),t.lineTo(e,-r),t.lineTo(e,r),t.lineTo(-e,r),t.lineTo(-e,-r),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(r=>{r&&e.push(r.toObject())}),y(y({},super.toObject([...El,...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,r=-this.width/2,s=-this.height/2;let n=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=Oe();n.push('<clipPath id="imageCrop_'+c+`">
93
- `,' <rect x="'+r+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
80
+ `),r.join("")}toLive(t){const{x1:e,y1:r,x2:s,y2:n,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,r,s,n):t.createRadialGradient(e,r,o,s,n,a);return this.colorStops.forEach(c=>{let{color:h,offset:u}=c;l.addColorStop(u,h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:r}=t;return new this({...t,colorStops:e?e.map(s=>({...s})):void 0,gradientTransform:r?[...r]:void 0})}static fromElement(t,e,r){const s=fl(t),n=e._findCenterFromElement();return new this({id:t.getAttribute("id")||void 0,type:gl(t),coords:zd(t,{width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height}),colorStops:$d(t,r.opacity),gradientUnits:s,gradientTransform:dn(t.getAttribute("gradientTransform")||""),...s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}})}}v(qs,"type","Gradient"),j.setClass(qs,"gradient"),j.setClass(qs,"linear"),j.setClass(qs,"radial");class yn{get type(){return"pattern"}set type(t){Ce("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=ke(),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:r}=this;return{...sr(this,t),type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:nt(this.offsetX,tt.NUM_FRACTION_DIGITS),offsetY:nt(this.offsetY,tt.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG(t){let{width:e,height:r}=t;const{source:s,repeat:n,id:o}=this,a=ur(this.offsetX/e,0),l=ur(this.offsetY/r,0),c=n==="repeat-y"||n==="no-repeat"?1+Math.abs(a||0):ur(s.width/e,0),h=n==="repeat-x"||n==="no-repeat"?1+Math.abs(l||0):ur(s.height/r,0);return[`<pattern id="SVGID_${q(o)}" x="${a}" y="${l}" width="${c}" height="${h}">`,`<image x="0" y="0" width="${s.width}" height="${s.height}" xlink:href="${q(this.sourceToString())}"></image>`,"</pattern>",""].join(`
81
+ `)}static async fromObject(t,e){let{type:r,source:s,patternTransform:n,...o}=t;const a=await Ps(s,{...e,crossOrigin:o.crossOrigin});return new this({...o,patternTransform:n&&n.slice(0),source:a})}}v(yn,"type","Pattern"),j.setClass(yn),j.setClass(yn,"pattern");class Hd{constructor(t){v(this,"color","rgb(0, 0, 0)"),v(this,"width",1),v(this,"shadow",null),v(this,"strokeLineCap","round"),v(this,"strokeLineJoin","round"),v(this,"strokeMiterLimit",10),v(this,"strokeDashArray",null),v(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new rt(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,r=t.contextTop,s=t.getZoom()*t.getRetinaScaling();r.shadowColor=e.color,r.shadowBlur=e.blur*s,r.shadowOffsetX=e.offsetX*s,r.shadowOffsetY=e.offsetY*s}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}class Ee extends ut{constructor(t){let{path:e,left:r,top:s,...n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Ee.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),typeof r=="number"&&this.set(Q,r),typeof s=="number"&&this.set(Et,s)}_setPath(t,e){this.path=wd(Array.isArray(t)?t:Md(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,r=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+r);break;case"M":t.moveTo(s[1]+e,s[2]+r);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+r,s[3]+e,s[4]+r,s[5]+e,s[6]+r);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+r,s[3]+e,s[4]+r);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${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(){return["<path ","COMMON_PARTS",`d="${cl(this.path,tt.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />
82
+ `]}_getOffsetTransform(){const t=tt.NUM_FRACTION_DIGITS;return` translate(${nt(-this.pathOffset.x,t)}, ${nt(-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:r,pathOffset:s}=this._calcDimensions();this.set({width:e,height:r,pathOffset:s}),t&&this.setPositionByOrigin(s,Y,Y)}_calcBoundsFromPath(){const t=[];let e=0,r=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:r},{x:s,y:n});break;case"M":s=o[1],n=o[2],e=s,r=n;break;case"C":t.push(...el(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(...el(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=r}return pe(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,r){const{d:s,...n}=ye(t,this.ATTRIBUTE_NAMES,r);return new this(s,{...n,...e,left:void 0,top:void 0})}}v(Ee,"type","Path"),v(Ee,"cacheProperties",[...me,"path","fillRule"]),v(Ee,"ATTRIBUTE_NAMES",[...Oe,"d"]),j.setClass(Ee),j.setSVGClass(Ee);class Ks extends Hd{constructor(t){super(t),v(this,"decimate",.4),v(this,"drawStraightLine",!1),v(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,r){const s=e.midPointFrom(r);return t.quadraticCurveTo(e.x,e.y,s.x,s.y),s}onMouseDown(t,e){let{e:r}=e;this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:r}=e;if(this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],(this.limitedToCanvasSize!==!0||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const s=this._points,n=s.length,o=this.canvas.contextTop;this._saveAndTransform(o),this.oldEnd&&(o.beginPath(),o.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=Ks.drawSegment(o,s[n-2],s[n-1]),o.stroke(),o.restore()}}onMouseUp(t){let{e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.canvas.contextTop,e=this._points[0],r=this._points[1];if(this._saveAndTransform(t),t.beginPath(),this._points.length===2&&e.x===r.x&&e.y===r.y){const s=this.width/1e3;e.x-=s,r.x+=s}t.moveTo(e.x,e.y);for(let s=1;s<this._points.length;s++)Ks.drawSegment(t,e,r),e=this._points[s],r=this._points[s+1];t.lineTo(e.x,e.y),t.stroke(),t.restore()}convertPointsToSVGPath(t){const e=this.width/1e3;return Ed(t,e)}createPath(t){const e=new Ee(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,e.shadow=new ne(this.shadow)),e}decimatePoints(t,e){if(t.length<=2)return t;let r,s=t[0];const n=this.canvas.getZoom(),o=Math.pow(e/n,2),a=t.length-1,l=[s];for(let c=1;c<a-1;c++)r=Math.pow(s.x-t[c].x,2)+Math.pow(s.y-t[c].y,2),r>=o&&(s=t[c],l.push(s));return l.push(t[a]),l}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(r){return cl(r)==="M 0 0 Q 0 0 0 0 L 0 0"}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const pl=["radius","startAngle","endAngle","counterClockwise"];class we extends ut{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,pt(this.startAngle),pt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(At)}getRadiusY(){return this.get("radius")*this.get(Vt)}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([...pl,...t])}_toSVG(){const{radius:t,startAngle:e,endAngle:r}=this,s=(r-e)%360;if(s===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',`${q(t)}`,`" />
83
+ `];{const n=pt(e),o=pt(r),a=de(n)*t,l=ge(n)*t,c=de(o)*t,h=ge(o)*t;return[`<path d="M ${a} ${l} A ${t} ${t} 0 ${s>180?1:0} ${this.counterClockwise?0:1} ${c} ${h}" `,"COMMON_PARTS",` />
84
+ `]}}static async fromElement(t,e,r){const{left:s=0,top:n=0,radius:o=0,...a}=ye(t,this.ATTRIBUTE_NAMES,r);return new this({...a,radius:o,left:s-o,top:n-o})}static fromObject(t){return super._fromObject(t)}}v(we,"type","Circle"),v(we,"cacheProperties",[...me,...pl]),v(we,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(we,"ATTRIBUTE_NAMES",["cx","cy","r",...Oe]),j.setClass(we),j.setSVGClass(we);const bn=["x1","x2","y1","y2"];class Zt extends ut{constructor(){let[t,e,r,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,Zt.ownDefaults),this.setOptions(n),this.x1=t,this.x2=r,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=n;typeof o=="number"&&this.set(Q,o),typeof a=="number"&&this.set(Et,a)}_setWidthHeight(){const{x1:t,y1:e,x2:r,y2:s}=this;this.width=Math.abs(r-t),this.height=Math.abs(s-e);const{left:n,top:o,width:a,height:l}=pe([{x:t,y:e},{x:r,y:s}]),c=new x(n+a/2,o+l/2);this.setPositionByOrigin(c,Y,Y)}_set(t,e){return super._set(t,e),bn.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 r=t.strokeStyle;var s;Xt(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=r}_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:r,y2:s,width:n,height:o}=this,a=t<=e?-.5:.5,l=r<=s?-.5:.5;return{x1:a*n,x2:a*-n,y1:l*o,y2:l*-o}}_toSVG(){const{x1:t,x2:e,y1:r,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",`x1="${t}" y1="${r}" x2="${e}" y2="${s}" />
85
+ `]}static async fromElement(t,e,r){const{x1:s=0,y1:n=0,x2:o=0,y2:a=0,...l}=ye(t,this.ATTRIBUTE_NAMES,r);return new this([s,n,o,a],l)}static fromObject(t){let{x1:e,y1:r,x2:s,y2:n,...o}=t;return this._fromObject({...o,points:[e,r,s,n]},{extraParam:"points"})}}v(Zt,"type","Line"),v(Zt,"cacheProperties",[...me,...bn]),v(Zt,"ATTRIBUTE_NAMES",Oe.concat(bn)),j.setClass(Zt),j.setSVGClass(Zt);class ze extends ut{static getDefaults(){return{...super.getDefaults(),...ze.ownDefaults}}constructor(t){super(),Object.assign(this,ze.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,r),t.lineTo(0,-r),t.lineTo(e,r),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',`${-t} ${e},0 ${-e},${t} ${e}`,'" />']}}v(ze,"type","Triangle"),v(ze,"ownDefaults",{width:100,height:100}),j.setClass(ze),j.setSVGClass(ze);const ml=["rx","ry"];class Jt extends ut{static getDefaults(){return{...super.getDefaults(),...Jt.ownDefaults}}constructor(t){super(),Object.assign(this,Jt.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(At)}getRy(){return this.get("ry")*this.get(Vt)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...ml,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",`cx="0" cy="0" rx="${q(this.rx)}" ry="${q(this.ry)}" />
86
+ `]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Ze,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){const s=ye(t,this.ATTRIBUTE_NAMES,r);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}v(Jt,"type","Ellipse"),v(Jt,"cacheProperties",[...me,...ml]),v(Jt,"ownDefaults",{rx:0,ry:0}),v(Jt,"ATTRIBUTE_NAMES",[...Oe,"cx","cy","rx","ry"]),j.setClass(Jt),j.setSVGClass(Jt);const vl={exactBoundingBox:!1};class Qt extends ut{static getDefaults(){return{...super.getDefaults(),...Qt.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,Qt.ownDefaults),this.setOptions(e),this.points=t;const{left:r,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof r=="number"&&this.set(Q,r),typeof s=="number"&&this.set(Et,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Uu(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 r=pe(e),s=Es({...t,scaleX:1,scaleY:1}),n=pe(this.points.map(c=>Lt(c,s,!0))),o=new x(this.scaleX,this.scaleY);let a=r.left+r.width/2,l=r.top+r.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(pt(this.skewX)),l-=a*Math.tan(pt(this.skewY))),{...r,pathOffset:new x(a,l),strokeOffset:new x(n.left,n.top).subtract(new x(r.left,r.top)).multiply(o),strokeDiff:new x(r.width,r.height).subtract(new x(n.width,n.height)).multiply(o)}}_findCenterFromElement(){const t=pe(this.points);return new x(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:r,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,r+n/2),Y,Y)}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,r;const{width:a,height:l}=this._calcDimensions(t);o=new x((e=t.width)!==null&&e!==void 0?e:a,(r=t.height)!==null&&r!==void 0?r: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 r=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&r&&((t===At||t===Vt)&&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:r,y:s}=e;return{x:r,y:s}})}}_toSVG(){const t=this.pathOffset.x,e=this.pathOffset.y,r=tt.NUM_FRACTION_DIGITS,s=this.points.map(n=>{let{x:o,y:a}=n;return`${nt(o-t,r)},${nt(a-e,r)}`}).join(" ");return[`<${q(this.constructor.type).toLowerCase()} `,"COMMON_PARTS",`points="${s}" />
87
+ `]}_render(t){const e=this.points.length,r=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-r,this.points[0].y-s);for(let n=0;n<e;n++){const o=this.points[n];t.lineTo(o.x-r,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,r){const s=function(l){if(!l)return[];const c=l.replace(/,/g," ").trim().split(/\s+/),h=[];for(let u=0;u<c.length;u+=2)h.push({x:parseFloat(c[u]),y:parseFloat(c[u+1])});return h}(t.getAttribute("points")),{left:n,top:o,...a}=ye(t,this.ATTRIBUTE_NAMES,r);return new this(s,{...a,...e})}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(Qt,"ownDefaults",vl),v(Qt,"type","Polyline"),v(Qt,"layoutProperties",[Je,Qe,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(Qt,"cacheProperties",[...me,"points"]),v(Qt,"ATTRIBUTE_NAMES",[...Oe]),j.setClass(Qt),j.setSVGClass(Qt);class Yr extends Qt{isOpen(){return!1}}v(Yr,"ownDefaults",vl),v(Yr,"type","Polygon"),j.setClass(Yr),j.setSVGClass(Yr);class yl extends ut{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 r in e)for(const s in e[r])for(const n in e[r][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const r=e===void 0?this.styles:{0:this.styles[e]};for(const s in r)for(const n in r[s])if(r[s][n][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let r,s,n=0,o=!0,a=0;for(const l in e){r=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?r++:delete e[l][c]}r===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 r,s,n;for(s in e){for(n in r=e[s],r)delete r[n][t],Object.keys(r[n]).length===0&&delete r[n];Object.keys(r).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:r,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(r)||this._setLineStyle(r);const n=Ui({...this._getStyleDeclaration(r,s),...e},o=>o!==void 0);this._setStyleDeclaration(r,s,n)}getSelectionStyles(t,e,r){const s=[];for(let n=t;n<(e||t);n++)s.push(this.getStyleAtPosition(n,r));return s}getStyleAtPosition(t,e){const{lineIndex:r,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(r,s):this._getStyleDeclaration(r,s)}setSelectionStyles(t,e,r){for(let s=e;s<(r||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var r;const s=this.styles&&this.styles[t];return s&&(r=s[e])!==null&&r!==void 0?r:{}}getCompleteStyleDeclaration(t,e){return{...sr(this,this.constructor._styleProperties),...this._getStyleDeclaration(t,e)}}_setStyleDeclaration(t,e,r){this.styles[t][e]=r}_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(yl,"_styleProperties",pu);const Vd=/ +/g,Wd=/"/g;function wn(i,t,e,r,s){return` ${function(n,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:tt.NUM_FRACTION_DIGITS;const d=Rr(_t,n,!1),[g,f,m,y]=[a,l,c,h].map(b=>nt(b,u));return`<rect ${d} x="${g}" y="${f}" width="${m}" height="${y}"></rect>`}(i,{left:t,top:e,width:r,height:s})}
88
+ `}let xn;class Mt extends yl{static getDefaults(){return{...super.getDefaults(),...Mt.ownDefaults}}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Mt.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=al(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(ie)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,s,n,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===ie||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)))){r=a.length,t=(this.width-e)/r;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 r=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<r.length;s++){if(t<=r[s].length)return{lineIndex:s,charIndex:t};t-=r[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:r[s-1].length<t?r[s-1].length:t}}toString(){return`#<Text (${this.complexity()}): { "text": "${this.text}", "fontFamily": "${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===Rt?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,r){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case Y:t.textBaseline="middle";break;case"ascender":t.textBaseline=Et;break;case"descender":t.textBaseline=Ri}t.font=this._getFontDeclaration(e,r)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,r=this._textLines.length;e<r;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,r,s,n,o){this._renderChars(t,e,r,s,n,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,r=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,u,d=0,g=0,f=this.getValueOfPropertyAt(n,0,"textBackgroundColor");const m=this.getHeightOfLineImpl(n);for(let y=0;y<l;y++){const b=this.__charBounds[n][y];u=this.getValueOfPropertyAt(n,y,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=u,u&&t.fillRect(-b.width/2,-m*(1-this._fontSizeFraction),b.width,m),t.restore()):u!==f?(h=r+c+g,this.direction===ue&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,s,d,m),g=b.left,d=b.width,f=u):d+=b.kernedWidth}u&&!this.path&&(h=r+c+g,this.direction===ue&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,s,d,m)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,s){const n=Mr.getFontCache(e),o=this._getFontDeclaration(e),a=r?r+t:t,l=r&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,g;if(r&&n.has(r)&&(d=n.get(r)),n.has(t)&&(g=h=n.get(t)),l&&n.has(a)&&(u=n.get(a),g=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return xn||(xn=Wt({width:0,height:0}).getContext("2d")),xn}();this._setTextStyles(f,e,!0),h===void 0&&(g=h=f.measureText(t).width,n.set(t,h)),d===void 0&&l&&r&&(d=f.measureText(r).width,n.set(r,d)),l&&u===void 0&&(u=f.measureText(a).width,n.set(a,u),g=u-d)}return{width:h*c,kernedWidth:g*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,r,s=0;const n=this.pathSide===ft,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 u=a[h];r=this._getGraphemeBox(u,t,h,e),c[h]=r,s+=r.kernedWidth,e=u}if(c[l]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Q:h=n?u-s:0;break;case Y:h=(u-s)/2;break;case ft:h=n?0:u-s}h+=this.pathStartOffset*(n?-1:1);for(let d=n?l-1:0;n?d>=0:d<l;n?d--:d++)r=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,r),h+=r.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const r=t+e.kernedWidth/2,s=this.path,n=kd(s.path,r,s.segmentsInfo);e.renderLeft=n.x-s.pathOffset.x,e.renderTop=n.y-s.pathOffset.y,e.angle=n.angle+(this.pathSide===ft?Math.PI:0)}_getGraphemeBox(t,e,r,s,n){const o=this.getCompleteStyleDeclaration(e,r),a=s?this.getCompleteStyleDeclaration(e,r-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(r>0&&!n){const g=this.__charBounds[e][r-1];d.left=g.left+g.width+l.kernedWidth-l.width}return d}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let r=this.getHeightOfChar(t,0);for(let s=1,n=this._textLines[t].length;s<n;s++)r=Math.max(this.getHeightOfChar(t,s),r);return e[t]=r*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,r=this._textLines.length;e<r;e++)t+=e===r-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction===je?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let r=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+r+this.getHeightOfLineImpl(o),o),r+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(_t))&&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,r,s,n,o){const a=this.textAlign.includes(ie),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction===je,u=this.direction===je?1:-1,d=e.direction;let g,f,m,y,b,w="",T=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",h?je:ue),e.direction=h?je:ue,e.textAlign=h?Q:ft),n-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,r.join(""),s,n),void e.restore();for(let C=0,S=r.length-1;C<=S;C++)y=C===S||this.charSpacing||l,w+=r[C],m=this.__charBounds[o][C],T===0?(s+=u*(m.kernedWidth-m.width),T+=m.width):T+=m.kernedWidth,a&&!y&&this._reSpaceAndTab.test(r[C])&&(y=!0),y||(g=g||this.getCompleteStyleDeclaration(o,C),f=this.getCompleteStyleDeclaration(o,C+1),y=hn(g,f,!1)),y&&(l?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,C,w,-T/2,0),e.restore()):(b=s,this._renderChar(t,e,o,C,w,b,n)),w="",g=f,s+=u*T,T=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,s=Wt({width:e,height:r}),n=s.getContext("2d");return s.width=e,s.height=r,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,r),n.lineTo(0,r),n.closePath(),n.translate(e/2,r/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(s,"no-repeat")}handleFiller(t,e,r){let s,n;return Xt(r)?r.gradientUnits==="percentage"||r.gradientTransform||r.patternTransform?(s=-this.width/2,n=-this.height/2,t.translate(s,n),t[e]=this._applyPatternGradientTransformText(r),{offsetX:s,offsetY:n}):(t[e]=r.toLive(t),this._applyPatternGradientTransform(t,r)):(t[e]=r,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:r,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",r)}_setFillStyles(t,e){let{fill:r}=e;return this.handleFiller(t,"fillStyle",r)}_renderChar(t,e,r,s,n,o,a){const l=this._getStyleDeclaration(r,s),c=this.getCompleteStyleDeclaration(r,s),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(n,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(n,o-d.offsetX,a-d.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,r){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*r.size,deltaY:o+n*r.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),r=this.width-e,s=this.textAlign,n=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===ie||s===zr&&!o||s===$r&&!o||s===zs&&!o?0:(s===Y&&(a=r/2),s===ft&&(a=r),s===zr&&(a=r/2),s===$r&&(a=r),n===ue&&(s===ft||s===$r?a=0:s===Q||s===zs?a=-r:s!==Y&&s!==zr||(a=-r/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,r){var s;return(s=this._getStyleDeclaration(t,e)[r])!==null&&s!==void 0?s:this[r]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let r=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 u=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){r+=u;continue}const d=this._textLines[c],g=u/this.lineHeight,f=this._getLineLeftOffset(c);let m=0,y=0,b=this.getValueOfPropertyAt(c,0,e),w=this.getValueOfPropertyAt(c,0,_t),T=this.getValueOfPropertyAt(c,0,Be),C=b,S=w,D=T;const A=r+g*(1-this._fontSizeFraction);let _=this.getHeightOfChar(c,0),M=this.getValueOfPropertyAt(c,0,"deltaY");for(let z=0,X=d.length;z<X;z++){const W=this.__charBounds[c][z];C=this.getValueOfPropertyAt(c,z,e),S=this.getValueOfPropertyAt(c,z,_t),D=this.getValueOfPropertyAt(c,z,Be);const G=this.getHeightOfChar(c,z),K=this.getValueOfPropertyAt(c,z,"deltaY");if(n&&C&&S){const Z=this.fontSize*D/1e3;t.save(),t.fillStyle=w,t.translate(W.renderLeft,W.renderTop),t.rotate(W.angle),t.fillRect(-W.kernedWidth/2,l*G+K-a*Z,W.kernedWidth,Z),t.restore()}else if((C!==b||S!==w||G!==_||D!==T||K!==M)&&y>0){const Z=this.fontSize*T/1e3;let L=s+f+m;this.direction===ue&&(L=this.width-L-y),b&&w&&T&&(t.fillStyle=w,t.fillRect(L,A+l*_+M-a*Z,y,Z)),m=W.left,y=W.width,b=C,T=D,w=S,_=G,M=K}else y+=W.kernedWidth}let O=s+f+m;this.direction===ue&&(O=this.width-O-y),t.fillStyle=S;const V=this.fontSize*D/1e3;C&&S&&D&&t.fillRect(O,A+l*_+M-a*V,y-o,V),r+=u}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:r=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(",")||Mt.genericFonts.includes(t.toLowerCase())?t:`"${t}"`;return[e,r,`${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 Ni(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),r=new Array(e.length),s=[`
89
+ `];let n=[];for(let o=0;o<e.length;o++)r[o]=this.graphemeSplit(e[o]),n=n.concat(r[o],s);return n.pop(),{_unwrappedLines:r,lines:e,graphemeText:n,graphemeLines:r}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return{...super.toObject([...Fa,...t]),styles:Gu(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(t,e){const{textLayoutProperties:r}=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||r.includes(o),n=n||o==="path";else s=r.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,r){const s=ye(t,Mt.ATTRIBUTE_NAMES,r),{textAnchor:n=Q,textDecoration:o="",dx:a=0,dy:l=0,top:c=0,left:h=0,fontSize:u=Bi,strokeWidth:d=1,...g}={...e,...s},f=new this(Bs(t.textContent||"").trim(),{left:h+a,top:c+l,underline:o.includes("underline"),overline:o.includes("overline"),linethrough:o.includes("line-through"),strokeWidth:0,fontSize:u,...g}),m=f.getScaledHeight()/f.height,y=((f.height+f.strokeWidth)*f.lineHeight-f.height)*m,b=f.getScaledHeight()+y;let w=0;return n===Y&&(w=f.getScaledWidth()/2),n===ft&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(b-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:d}),f}static fromObject(t){return this._fromObject({...t,styles:Nu(t.styles||{},t.text)},{extraParam:"text"})}}v(Mt,"textLayoutProperties",La),v(Mt,"cacheProperties",[...me,...Fa]),v(Mt,"ownDefaults",mu),v(Mt,"type","Text"),v(Mt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(Mt,"ATTRIBUTE_NAMES",Oe.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Ga(Mt,[class extends Ea{_toSVG(){const i=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(i.textTop,i.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(i){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:i,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:i,withShadow:!0,additionalTransform:Fr(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(i){let{textBgRects:t,textSpans:e}=i;const r=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ',`font-family="${q(this.fontFamily.replace(Wd,"'"))}" `,`font-size="${q(this.fontSize)}" `,this.fontStyle?`font-style="${q(this.fontStyle)}" `:"",this.fontWeight?`font-weight="${q(this.fontWeight)}" `:"",r?`text-decoration="${r}" `:"",this.direction==="rtl"?'direction="rtl" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
90
+ `]}_getSVGTextAndBg(i,t){const e=[],r=[];let s,n=i;this.backgroundColor&&r.push(wn(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(r,o,t+s,n),this._setSVGTextLineText(e,o,t+s,n),n+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:r}}_createTextCharSpan(i,t,e,r,s){const n=tt.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,i!==i.trim()||!!i.match(Vd)),a=o?`style="${o}"`:"",l=t.deltaY,c=l?` dy="${nt(l,n)}" `:"",{angle:h,renderLeft:u,renderTop:d,width:g}=s;let f="";if(u!==void 0){const m=g/2;h&&(f=` rotate="${nt(Te(h),n)}"`);const y=rr({angle:Te(h)});y[4]=u,y[5]=d;const b=new x(-m,0).transform(y);e=b.x,r=b.y}return`<tspan x="${nt(e,n)}" y="${nt(r,n)}" ${c}${f}${a}>${q(i)}</tspan>`}_setSVGTextLineText(i,t,e,r){const s=this.getHeightOfLine(t),n=this.textAlign.includes(ie),o=this._textLines[t];let a,l,c,h,u,d="",g=0;r+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,m=o.length-1;f<=m;f++)u=f===m||this.charSpacing||this.path,d+=o[f],c=this.__charBounds[t][f],g===0?(e+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=hn(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),i.push(this._createTextCharSpan(d,h,e,r,c)),d="",a=l,this.direction==="rtl"?e-=g:e+=g,g=0)}_setSVGTextLineBg(i,t,e,r){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:u,width:d,kernedWidth:g}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&i.push(wn(c,e+l,r,a,n)),l=u,a=d,c=o):a+=g}o&&i.push(wn(c,e+l,r,a,n))}getSvgStyles(i){return`${super.getSvgStyles(i)} text-decoration-thickness: ${nt(this.textDecorationThickness*this.getObjectScaling().y/10,tt.NUM_FRACTION_DIGITS)}%; white-space: pre;`}getSvgSpanStyles(i,t){const{fontFamily:e,strokeWidth:r,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,textDecorationThickness:c,linethrough:h,overline:u,underline:d}=i,g=this.getSvgTextDecoration({underline:d??this.underline,overline:u??this.overline,linethrough:h??this.linethrough}),f=c||this.textDecorationThickness;return[s?Rr(Rt,s):"",r?`stroke-width: ${q(r)}; `:"",e?`font-family: ${e.includes("'")||e.includes('"')?q(e):`'${q(e)}'`}; `:"",o?`font-size: ${q(o)}px; `:"",a?`font-style: ${q(a)}; `:"",l?`font-weight: ${q(l)}; `:"",g?`text-decoration: ${g}; text-decoration-thickness: ${nt(f*this.getObjectScaling().y/10,tt.NUM_FRACTION_DIGITS)}%; `:"",n?Rr(_t,n):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(i){return["overline","underline","line-through"].filter(t=>i[t.replace("-","")]).join(" ")}}]),j.setClass(Mt),j.setSVGClass(Mt);class Xd{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(r=>r()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,r=e.getSelectionStartFromPointer(t);return e.isEditing&&r>=e.selectionStart&&r<=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 r;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()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),g=o.getBoundingRect(),f=h.subtract(new x(g.left,g.top)),m=a.viewportTransform,y=f.add(u).transform(m,!0),b=o.backgroundColor,w=cn(o.styles);o.backgroundColor="";const T={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(T,0,s),o.setSelectionStyles(T,n,o.text.length),o.dirty=!0;const C=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=b,o.styles=w,o.dirty=!0,mn(C,{position:"fixed",left:-C.width+"px",border:Pt,width:C.width/d+"px",height:C.height/d+"px"}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{C.remove()},Gt(t.target||this.target.hiddenTextarea).body.appendChild(C),(r=t.dataTransfer)===null||r===void 0||r.setDragImage(C,y.x,y.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,r=this.isActive();if(r&&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(),r}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),r=this.__dragStartSelection;return e<r.selectionStart||e>r.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const r=this.targetCanDrop(e);!this.__isDraggingOver&&r&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r?this.__isDraggingOver=!0:this.__isDraggingOver&&!r&&(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:r}=t,s=r.defaultPrevented;this.__isDraggingOver=!1,r.preventDefault();let n=(e=r.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(r);const{styles:c}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},h=n[Math.max(0,n.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,g=this.__dragStartSelection.selectionEnd;l>d&&l<=g?l=d:l>g&&(l-=g-d),o.removeChars(d,g),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(r),o.selectionStart=Math.min(l+u,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(Cs,{index:l+u,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 r;const s=this.target,n=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((r=e.dataTransfer)===null||r===void 0?void 0:r.dropEffect)||Pt;l===Pt?(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(Cs,{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 bl=/[ \n\.,;!\?\-]/;class Yd extends Mt{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:r,delay:s,onComplete:n}=t;return Ra({startValue:this._currentCursorOpacity,endValue:e,duration:r,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,r=t-1;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r--;for(;/\S/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findWordBoundaryRight(t){let e=0,r=t;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r++;for(;/\S/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}findLineBoundaryLeft(t){let e=0,r=t-1;for(;!/\n/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findLineBoundaryRight(t){let e=0,r=t;for(;!/\n/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}searchWordBoundary(t,e){const r=this._text;let s=t>0&&this._reSpace.test(r[t])&&(e===-1||!$i.test(r[t-1]))?t-1:t,n=r[s];for(;s>0&&s<r.length&&!bl.test(n);)s+=e,n=r[s];return e===-1&&bl.test(n)&&s++,s}selectWord(t){t=t??this.selectionStart;const e=this.searchWordBoundary(t,-1),r=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=t??this.selectionStart;const e=this.findLineBoundaryLeft(t),r=this.findLineBoundaryRight(t);this.selectionStart=e,this.selectionEnd=r,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;Gt(e).activeElement!==e&&e.focus();const r=this.getSelectionStartFromPointer(t),s=this.selectionStart,n=this.selectionEnd;(r===this.__selectionStartOnMouseDown&&s!==n||s!==r&&n!==r)&&(r>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=r):(this.selectionStart=r,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,r){const s=r.slice(0,t),n=this.graphemeSplit(s).length;if(t===e)return{selectionStart:n,selectionEnd:n};const o=r.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,r){const s=r.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+r.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(){const{hiddenTextarea:t,direction:e,textAlign:r,inCompositionMode:s}=this;if(!t)return;const n=r!==ie?r.replace("justify-",""):e===je?Q:ft,o=this.getPositionByOrigin(n,"top");this.cursorOffsetCache={},this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setPositionByOrigin(o,n,"top"),this.setCoords();const a=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=a.selectionEnd,s||(this.selectionStart=a.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),r=this.get2DCursorLocation(t),s=r.lineIndex,n=r.charIndex,o=this.getValueOfPropertyAt(s,n,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,g=u-o,f=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/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>g&&(f.y=g),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:`${f.x}px`,top:`${f.y}px`,fontSize:`${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)}exitEditingImpl(){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(),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(ks),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:r,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:o}=this.get2DCursorLocation(e,!0);if(r!==n){if(this.styles[r])for(let a=s;a<this._unwrappedTextLines[r].length;a++)delete this.styles[r][a];if(this.styles[n])for(let a=o;a<this._unwrappedTextLines[n].length;a++){const l=this.styles[n][a];l&&(this.styles[r]||(this.styles[r]={}),this.styles[r][s+a-o]=l)}for(let a=r+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,r-n)}else if(this.styles[r]){const a=this.styles[r],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[r]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const r=Object.assign({},this.styles);for(const s in this.styles){const n=parseInt(s,10);n>t&&(this.styles[n+e]=r[n],r[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,r,s){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;r||(r=1),this.shiftLineStyles(t,r);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,n[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+r]=n,h=!0),(h||o>e)&&r--;r>0;)s&&s[r-1]?this.styles[t+r]={0:{...s[r-1]}}:c?this.styles[t+r]={0:{...c}}:delete this.styles[t+r],r--;this._forceClearCache=!0}insertCharStyleObject(t,e,r,s){this.styles||(this.styles={});const n=this.styles[t],o=n?{...n}:{};r||(r=1);for(const l in o){const c=parseInt(l,10);c>=e&&(n[c+r]=o[c],o[c-r]||delete n[c])}if(this._forceClearCache=!0,s){for(;r--;)Object.keys(s[r]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+r]={...s[r]});return}if(!n)return;const a=n[e?e-1:1];for(;a&&r--;)this.styles[t][e+r]={...a}}insertNewStyleBlock(t,e,r){const s=this.get2DCursorLocation(e,!0),n=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
91
+ `?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,n[0],r),r=r&&r.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],r):r&&this.styles[s.lineIndex+o]&&r[0]&&(this.styles[s.lineIndex+o][0]=r[0]),r=r&&r.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,n[o],r)}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,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r;s>r&&this.removeStyleFromTo(r,s);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,r,e),this._text=[...this._text.slice(0,r),...n,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,r){r<=t?(e===t?this._selectionDirection=Q:this._selectionDirection===ft&&(this._selectionDirection=Q,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===ft?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=ft:this._selectionDirection===Q&&(this._selectionDirection=ft,this.selectionStart=e),this.selectionEnd=r)}}class Ud extends Yd{initHiddenTextarea(){const t=this.canvas&&Gt(this.canvas.getElement())||Ke(),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:r,left:s,fontSize:n}=this._calcTextareaPosition();e.style.cssText=`position: absolute; top: ${r}; left: ${s}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${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:r,selectionStart:s,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Cs),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(r).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,u=this.selectionEnd,d=h!==u;let g,f,m,y,b=c-l;const w=this.fromStringToGraphemeSelection(s,n,r),T=h>w.selectionStart;d?(f=this._text.slice(h,u),b+=u-h):c<l&&(f=T?this._text.slice(u+b,u):this._text.slice(h,h-b));const C=a.slice(w.selectionEnd-b,w.selectionEnd);if(f&&f.length&&(C.length&&(g=this.getSelectionStyles(h,h+1,!1),g=C.map(()=>g[0])),d?(m=h,y=u):T?(m=u-f.length,y=u):(m=u,y=u+f.length),this.removeStyleFromTo(m,y)),C.length){const{copyPasteData:S}=se();e&&C.join("")===S.copiedText&&!tt.disableStyleCopyPaste&&(g=S.copiedTextStyle),this.insertNewStyleBlock(C,h,g)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:r,selectionEnd:s}=e;this.compositionStart=r,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=se();t.copiedText=this.getSelectedText(),tt.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 r,s=this._getLineLeftOffset(t);return e>0&&(r=this.__charBounds[t][e-1],s+=r.left+r.width),s}getDownCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(r),n=s.lineIndex;if(n===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-r;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 r=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(r),n=s.lineIndex;if(n===0||t.metaKey||t.keyCode===33)return-r;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 r=this._textLines[t];let s,n,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=r.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){n=!0;const h=o-s,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return n||(a=r.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 r=this[`get${t}CursorOffset`](e,this._selectionDirection===ft);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),r!==0){const s=this.text.length;this.selectionStart=or(0,this.selectionStart,s),this.selectionEnd=or(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Q?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,r){let s;if(t.altKey)s=this[`findWordBoundary${r}`](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=r==="Left"?-1:1,!0;s=this[`findLineBoundary${r}`](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=Q,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===ft&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Q,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 r=`moveCursor${t}${e.shiftKey?"WithShift":"WithoutShift"}`;this._currentCursorOpacity=1,this[r](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Q&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=ft,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=ft,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const wl=i=>!!i.button;class Gd extends Ud{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 Xd(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:r}=t;this.canvas&&this.editable&&!wl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),r&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=r||this.isEditing)))}mouseUpHandler(t){let{e,transform:r}=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||r&&r.actionPerformed||wl(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),r=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(r,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ut(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let r=0,s=0,n=0;for(let c=0;c<this._textLines.length&&r<=e.y;c++)r+=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 Zs="moveCursorUp",Js="moveCursorDown",Qs="moveCursorLeft",ti="moveCursorRight",ei="exitEditing",xl=(i,t)=>{const e=t.getRetinaScaling();i.setTransform(e,0,0,e,0,0);const r=t.viewportTransform;i.transform(r[0],r[1],r[2],r[3],r[4],r[5])},Nd={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:ei,27:ei,33:Zs,34:Js,35:ti,36:Qs,37:Qs,38:Zs,39:ti,40:Js},keysMapRtl:{9:ei,27:ei,33:Zs,34:Js,35:Qs,36:ti,37:ti,38:Zs,39:Qs,40:Js},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"},_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1};class oe extends Gd{static getDefaults(){return{...super.getDefaults(),...oe.ownDefaults}}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,{...oe.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 vn&&this.canvas.textEditingManager.remove(this),e instanceof vn&&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,r=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,r)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,r)}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 r=super.toCanvasElement(t);return this.isEditing=e,r}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),r=this.findAncestorsWithClipPath(),s=r.length>0;let n,o=t;if(s){n=Wt(t.canvas),o=n.getContext("2d"),xl(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 r){const l=a.clipPath,c=Wt(t.canvas),h=c.getContext("2d");if(xl(h,this.canvas),!l.absolutePositioned){const u=a.calcTransformMatrix();h.transform(u[0],u[1],u[2],u[3],u[4],u[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 r=this._getLeftOffset(),s=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:r,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,r=0;const{charIndex:s,lineIndex:n}=this.get2DCursorLocation(t),{textAlign:o,direction:a}=this;for(let u=0;u<n;u++)e+=this.getHeightOfLine(u);const l=this._getLineLeftOffset(n),c=this.__charBounds[n][s];c&&(r=c.left),this.charSpacing!==0&&s===this._textLines[n].length&&(r-=this._getWidthOfCharSpacing());let h=l+(r>0?r:0);return a===ue&&(o===ft||o===ie||o===$r?h*=-1:o===Q||o===zs?h=l-(r>0?r:0):o!==Y&&o!==zr||(h=l-(r>0?r:0))),{top:e,left:h}}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 r=this.get2DCursorLocation(t),s=r.lineIndex,n=r.charIndex>0?r.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,r){const{color:s,opacity:n,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(r,e);t.fillStyle=s,t.globalAlpha=n,t.fillRect(o,a,l,c)}renderSelection(t,e){const r={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,r,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,r){const{textAlign:s,direction:n}=this,o=e.selectionStart,a=e.selectionEnd,l=s.includes(ie),c=this.get2DCursorLocation(o),h=this.get2DCursorLocation(a),u=c.lineIndex,d=h.lineIndex,g=c.charIndex<0?0:c.charIndex,f=h.charIndex<0?0:h.charIndex;for(let m=u;m<=d;m++){const y=this._getLineLeftOffset(m)||0;let b=this.getHeightOfLine(m),w=0,T=0,C=0;if(m===u&&(T=this.__charBounds[u][g].left),m>=u&&m<d)C=l&&!this.isEndOfWrapping(m)?this.width:this.getLineWidth(m)||5;else if(m===d)if(f===0)C=this.__charBounds[d][f].left;else{const M=this._getWidthOfCharSpacing();C=this.__charBounds[d][f-1].left+this.__charBounds[d][f-1].width-M}w=b,(this.lineHeight<1||m===d&&this.lineHeight>1)&&(b/=this.lineHeight);let S=r.left+y+T,D=b,A=0;const _=C-T;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",D=1,A=b):t.fillStyle=this.selectionColor,n===ue&&(s===ft||s===ie||s===$r?S=this.width-S-_:s===Q||s===zs?S=r.left+y-C:s!==Y&&s!==zr||(S=r.left+y-C)),t.fillRect(S,r.top+r.topOffset+A,_,D),r.topOffset+=w}}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,_t)}_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(oe,"ownDefaults",Nd),v(oe,"type","IText"),j.setClass(oe),j.setClass(oe,"i-text");class He extends oe{static getDefaults(){return{...super.getDefaults(),...He.ownDefaults}}constructor(t,e){super(t,{...He.ownDefaults,...e})}static createControls(){return{controls:Wu()}}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(ie)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,r=0,s=0;const n={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
92
+ `&&o>0?(r=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(r++,s++),n[o]={line:e,offset:r},s+=t.graphemeLines[o].length,r+=t.graphemeLines[o].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[e];r&&(e=r.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,r=0,s=t+1,n=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,r=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 u=parseInt(h,10);if(u>=r&&(!n||u<e))for(const d in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[t];if(!r)return{};t=r.line,e=r.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,r){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,r)}_deleteStyleDeclaration(t,e){const r=this._styleMap[t];super._deleteStyleDeclaration(r.line,r.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 r=this.getGraphemeDataForRender(t),s=[];for(let n=0;n<r.wordsData.length;n++)s.push(...this._wrapLine(n,e,r));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,r=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),u=this._measureWord(h,o,a);return s=Math.max(u,s),a+=h.length+r.length,{word:h,width:u}})}),largestWordWidth:s}}_measureWord(t,e){let r,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,r,!0).kernedWidth,r=t[o];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,r){let{largestWordWidth:s,wordsData:n}=r,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],g=0,f=0,m=!0;e-=o;const y=Math.max(e,s,this.dynamicMinWidth),b=n[t];let w;for(g=0,w=0;w<b.length;w++){const{word:T,width:C}=b[w];g+=T.length,u+=f+C-a,u>y&&!m?(c.push(d),d=[],u=C,m=!0):u+=a,m||l||d.push(h),d=d.concat(T),f=l?0:this._measureWord([h],t,g),g++,m=!1}return w&&c.push(d),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),r=this._wrapText(e.lines,this.width),s=new Array(r.length);for(let n=0;n<r.length;n++)s[n]=r[n].join("");return e.lines=s,e.graphemeLines=r,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const r=parseInt(e,10);if(this._textLines[r]){const s=this._styleMap[e].line;t.set(`${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(He,"type","Textbox"),v(He,"textLayoutProperties",[...oe.textLayoutProperties,"width"]),v(He,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),j.setClass(He);class _l extends Us{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:r}=t,{clipPath:s,group:n}=r;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=pe(Ja(r,s)),l=new x(o,a);if(s.absolutePositioned)return{center:ir(s.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:u=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:r.getRelativeCenterPoint().add(c),size:l}}}}v(_l,"type","clip-path"),j.setClass(_l);class Cl extends Us{getInitialSize(t,e){let{target:r}=t,{size:s}=e;return new x(r.width||s.x,r.height||s.y)}}v(Cl,"type","fixed"),j.setClass(Cl);class qd extends Wr{subscribeTargets(t){const e=t.target;t.targets.reduce((r,s)=>(s.parent&&r.add(s.parent),r),new Set).forEach(r=>{r.layoutManager.subscribeTargets({target:r,targets:[e]})})}unsubscribeTargets(t){const e=t.target,r=e.getObjects();t.targets.reduce((s,n)=>(n.parent&&s.add(n.parent),s),new Set).forEach(s=>{!r.some(n=>n.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})})}}class Ve extends De{static getDefaults(){return{...super.getDefaults(),...Ve.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,Ve.ownDefaults),this.setOptions(e);const{left:r,top:s,layoutManager:n}=e;this.groupInit(t,{left:r,top:s,layoutManager:n??new qd})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];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))?(Ce("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 r=new Set;e.forEach(s=>{const{parent:n}=s;n&&r.add(n)}),t===gn?r.forEach(s=>{s._onAfterObjectsChange(Xs,e)}):r.forEach(s=>{s._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return`#<ActiveSelection: (${this.complexity()})>`}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,r){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s={hasControls:!1,...r,forActiveSelection:!0};for(let n=0;n<this._objects.length;n++)this._objects[n]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v(Ve,"type","ActiveSelection"),v(Ve,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),j.setClass(Ve),j.setClass(Ve,"activeSelection");class Kd{constructor(){v(this,"resources",{})}applyFilters(t,e,r,s,n){const o=n.getContext("2d",{willReadFrequently:!0,desynchronized:!0});if(!o)return;o.drawImage(e,0,0,r,s);const a={sourceWidth:r,sourceHeight:s,imageData:o.getImageData(0,0,r,s),originalEl:e,originalImageData:o.getImageData(0,0,r,s),canvasEl:n,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===r&&l.height===s||(n.width=l.width,n.height=l.height),o.putImageData(l,0,0),a}}class Sl{constructor(){let{tileSize:t=tt.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 r=Wt({width:t,height:e}),s=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=r,this.gl=s)}applyFilters(t,e,r,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:r,sourceHeight:s,destinationWidth:r,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,r,s,c?void 0:e),targetTexture:this.createTexture(a,r,s),originalTexture:c||this.createTexture(a,r,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const g=d.targetCanvas,f=g.width,m=g.height,y=d.destinationWidth,b=d.destinationHeight;f===y&&m===b||(g.width=y,g.height=b)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),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,r,s,n){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:g,TEXTURE_WRAP_T:f}=t,m=t.createTexture();return t.bindTexture(a,m),t.texParameteri(a,u,n||o),t.texParameteri(a,d,n||o),t.texParameteri(a,g,h),t.texParameteri(a,f,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,r,0,l,c,null),m}getCachedTexture(t,e,r){const{textureCache:s}=this;if(s[t])return s[t];{const n=this.createTexture(this.gl,e.width,e.height,e,r);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 r=t.canvas,s=e.targetCanvas,n=s.getContext("2d");if(!n)return;n.translate(0,s.height),n.scale(1,-1);const o=r.height-s.height;n.drawImage(r,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const r=e.targetCanvas.getContext("2d"),s=e.destinationWidth,n=e.destinationHeight,o=s*n*4;if(!r)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);r.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const r=t.getExtension("WEBGL_debug_renderer_info");if(r){const s=t.getParameter(r.UNMASKED_RENDERER_WEBGL),n=t.getParameter(r.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let _n;function Zd(){const{WebGLProbe:i}=se();return i.queryWebGL(fe()),tt.enableGLFiltering&&i.isSupported(tt.textureSize)?new Sl({tileSize:tt.textureSize}):new Kd}function Cn(){return!_n&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(_n=Zd()),_n}const kl=["cropX","cropY"];class St extends ut{static getDefaults(){return{...super.getDefaults(),...St.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,St.ownDefaults),this.setOptions(e),this.cacheKey=`texture${ke()}`,this.setElement(typeof t=="string"?(this.canvas&&Gt(this.canvas.getElement())||Ke()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._element=t,this._originalElement=t,this._setWidthHeight(e),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Cn(!1);e instanceof Sl&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{const e=this[t];e&&se().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,r=this.height/2;t.beginPath(),t.moveTo(-e,-r),t.lineTo(e,-r),t.lineTo(e,r),t.lineTo(-e,r),t.lineTo(-e,-r),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(r=>{r&&e.push(r.toObject())}),{...super.toObject([...kl,...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,r=-this.width/2,s=-this.height/2;let n=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=ke();n.push('<clipPath id="imageCrop_'+c+`">
93
+ `,' <rect x="'+r+'" y="'+s+'" width="'+q(this.width)+'" height="'+q(this.height)+`" />
94
94
  `,`</clipPath>
95
- `),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(r-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
96
- `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(r,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
97
- `)],this.fill=c}return n=this.paintFirst!==xt?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:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Ps(t,{crossOrigin:e,signal:r}).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,r=this.getTotalObjectScaling(),s=r.x,n=r.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=Wt(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,_n().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,r=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=Wt({width:r,height:s});this._element=n,this._filteredEl=n}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,r,s),this._lastScaleX=1,this._lastScaleY=1);_n().applyFilters(t,this._originalElement,r,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 r=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,u=a*r,d=l*s,g=Math.min(n*r,c-u),f=Math.min(o*s,h-d),p=-n/2,v=-o/2,b=Math.min(n,c/r-a),x=Math.min(o,h/s-l);e&&t.drawImage(e,u,d,g,f,p,v,b,x)}_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 r=this.getOriginalSize();this.width=t||r.width,this.height=e||r.height}parsePreserveAspectRatioAttribute(){const t=au(this.preserveAspectRatio||""),e=this.width,r=this.height,s={width:e,height:r};let n,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,g=0;return!t||t.alignX===Mt&&t.alignY===Mt?(l=e/o,c=r/a):(t.meetOrSlice==="meet"&&(l=c=Cd(this._element,s),n=(e-o*l)/2,t.alignX==="Min"&&(h=-n),t.alignX==="Max"&&(h=n),n=(r-a*c)/2,t.alignY==="Min"&&(u=-n),t.alignY==="Max"&&(u=n)),t.meetOrSlice==="slice"&&(l=c=Sd(this._element,s),n=o-e/l,t.alignX==="Mid"&&(d=n/2),t.alignX==="Max"&&(d=n),n=a-r/c,t.alignY==="Mid"&&(g=n/2),t.alignY==="Max"&&(g=n),o=e/l,a=r/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:g}}static fromObject(t,e){let{filters:r,resizeFilter:s,src:n,crossOrigin:o,type:a}=t,l=ot(t,mg);return Promise.all([Ps(n,y(y({},e),{},{crossOrigin:o})),r&&Pr(r,e),s&&Pr([s],e),As(l,e)]).then(c=>{let[h,u=[],[d]=[],g={}]=c;return new this(h,y(y({},l),{},{src:n,filters:u,resizeFilter:d},g))})}static fromURL(t){let{crossOrigin:e=null,signal:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Ps(t,{crossOrigin:e,signal:r}).then(n=>new this(n,s))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;const s=be(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(s["xlink:href"]||s.href,e,s).catch(n=>(Te("log","Unable to parse Image",n),null))}}m(_t,"type","Image"),m(_t,"cacheProperties",[...ve,...El]),m(_t,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),m(_t,"CSS_CANVAS","canvas-img"),m(_t,"ATTRIBUTE_NAMES",[...De,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),R.setClass(_t),R.setSVGClass(_t),Bs(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const ei=i=>i.webgl!==void 0,Cn="precision highp float",vg=`
98
- `.concat(Cn,`;
95
+ `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",`xlink:href="${q(this.getSrc(!0))}" x="${r-this.cropX}" y="${s-this.cropY}" width="${e.width||e.naturalWidth}" height="${e.height||e.naturalHeight}"${l}${a}></image>
96
+ `),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[` <rect x="${r}" y="${s}" width="${q(this.width)}" height="${q(this.height)}" style="${this.getSvgStyles()}" />
97
+ `],this.fill=c}return n=this.paintFirst!==_t?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:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Ps(t,{crossOrigin:e,signal:r}).then(s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,r=this.getTotalObjectScaling(),s=r.x,n=r.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=Wt(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Cn().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(`${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,r=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=Wt({width:r,height:s});this._element=n,this._filteredEl=n}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,r,s),this._lastScaleX=1,this._lastScaleY=1);Cn().applyFilters(t,this._originalElement,r,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 r=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,u=a*r,d=l*s,g=Math.min(n*r,c-u),f=Math.min(o*s,h-d),m=-n/2,y=-o/2,b=Math.min(n,c/r-a),w=Math.min(o,h/s-l);e&&t.drawImage(e,u,d,g,f,m,y,b,w)}_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 r=this.getOriginalSize();this.width=t||r.width,this.height=e||r.height}parsePreserveAspectRatioAttribute(){const t=fu(this.preserveAspectRatio||""),e=this.width,r=this.height,s={width:e,height:r};let n,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,g=0;return!t||t.alignX===Pt&&t.alignY===Pt?(l=e/o,c=r/a):(t.meetOrSlice==="meet"&&(l=c=fd(this._element,s),n=(e-o*l)/2,t.alignX==="Min"&&(h=-n),t.alignX==="Max"&&(h=n),n=(r-a*c)/2,t.alignY==="Min"&&(u=-n),t.alignY==="Max"&&(u=n)),t.meetOrSlice==="slice"&&(l=c=pd(this._element,s),n=o-e/l,t.alignX==="Mid"&&(d=n/2),t.alignX==="Max"&&(d=n),n=a-r/c,t.alignY==="Mid"&&(g=n/2),t.alignY==="Max"&&(g=n),o=e/l,a=r/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:g}}static fromObject(t,e){let{filters:r,resizeFilter:s,src:n,crossOrigin:o,type:a,...l}=t;return Promise.all([Ps(n,{...e,crossOrigin:o}),r&&Lr(r,e),s?Lr([s],e):[],As(l,e)]).then(c=>{let[h,u=[],[d],g={}]=c;return new this(h,{...l,src:n,filters:u,resizeFilter:d,...g})})}static fromURL(t){let{crossOrigin:e=null,signal:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Ps(t,{crossOrigin:e,signal:r}).then(n=>new this(n,s))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;const s=ye(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(s["xlink:href"]||s.href,e,s).catch(n=>(Ce("log","Unable to parse Image",n),null))}}v(St,"type","Image"),v(St,"cacheProperties",[...me,...kl]),v(St,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(St,"ATTRIBUTE_NAMES",[...Oe,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),j.setClass(St),j.setSVGClass(St),$s(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const ri=i=>i.webgl!==void 0,Sn="precision highp float",Jd=`
98
+ ${Sn};
99
99
  varying vec2 vTexCoord;
100
100
  uniform sampler2D uTexture;
101
101
  void main() {
102
102
  gl_FragColor = texture2D(uTexture, vTexCoord);
103
- }`),yg=["type"],bg=["type"],wg=new RegExp(Cn,"g");class bt{get type(){return this.constructor.type}constructor(){let t=ot(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},yg);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return vg}getVertexSource(){return`
103
+ }`,Qd=new RegExp(Sn,"g");class yt{get type(){return this.constructor.type}constructor(){let{type:t,...e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,this.constructor.defaults,e)}getFragmentSource(){return Jd}getVertexSource(){return`
104
104
  attribute vec2 aPosition;
105
105
  varying vec2 vTexCoord;
106
106
  void main() {
107
107
  vTexCoord = aPosition;
108
108
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
109
- }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=ie();s!=="highp"&&(e=e.replace(wg,Cn.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 se("Vertex, fragment shader or program creation error");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new se("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 se("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 se('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 r=this.constructor.uniformLocations,s={};for(let n=0;n<r.length;n++)s[r[n]]=t.getUniformLocation(e,r[n]);return s}sendAttributeData(t,e,r){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,r,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const r=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===r&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,r,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){ei(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,r=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(r.program),this.sendAttributeData(e,r.attributeLocations,t.aPosition),e.uniform1f(r.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(r.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,r.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,r){t.activeTexture(r),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:r}=t,s=Wt({width:e,height:r});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return y({type:this.type},t.reduce((e,r)=>(e[r]=this[r],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(ot(t,bg))}}m(bt,"type","BaseFilter"),m(bt,"uniformLocations",[]);const xg={multiply:`gl_FragColor.rgb *= uColor.rgb;
109
+ }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=se();s!=="highp"&&(e=e.replace(Qd,Sn.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 re("Vertex, fragment shader or program creation error");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new re(`Vertex shader compile error for ${this.type}: ${t.getShaderInfoLog(n)}`);if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new re(`Fragment shader compile error for ${this.type}: ${t.getShaderInfoLog(o)}`);if(t.attachShader(a,n),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new re(`Shader link error for "${this.type}" ${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 r=this.constructor.uniformLocations,s={};for(let n=0;n<r.length;n++)s[r[n]]=t.getUniformLocation(e,r[n]);return s}sendAttributeData(t,e,r){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,r,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const r=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===r&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,r,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){ri(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,r=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(r.program),this.sendAttributeData(e,r.attributeLocations,t.aPosition),e.uniform1f(r.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(r.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,r.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,r){t.activeTexture(r),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:r}=t,s=Wt({width:e,height:r});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return{type:this.type,...t.reduce((e,r)=>(e[r]=this[r],e),{})}}toJSON(){return this.toObject()}static async fromObject(t,e){let{type:r,...s}=t;return new this(s)}}v(yt,"type","BaseFilter"),v(yt,"uniformLocations",[]);const tg={multiply:`gl_FragColor.rgb *= uColor.rgb;
110
110
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
111
111
  `,add:`gl_FragColor.rgb += uColor.rgb;
112
112
  `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -133,7 +133,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
133
133
  `,tint:`
134
134
  gl_FragColor.rgb *= (1.0 - uColor.a);
135
135
  gl_FragColor.rgb += uColor.rgb;
136
- `};class Yr extends bt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
136
+ `};class Ur extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`
137
137
  precision highp float;
138
138
  uniform sampler2D uTexture;
139
139
  uniform vec4 uColor;
@@ -142,10 +142,10 @@ Resulting to default behavior: removing object from previous canvas and adding t
142
142
  vec4 color = texture2D(uTexture, vTexCoord);
143
143
  gl_FragColor = color;
144
144
  if (color.a > 0.0) {
145
- `.concat(xg[this.mode],`
145
+ ${tg[this.mode]}
146
146
  }
147
147
  }
148
- `)}applyTo2d(t){let{imageData:{data:e}}=t;const r=new rt(this.color).getSource(),s=this.alpha,n=r[0]*s,o=r[1]*s,a=r[2]*s,l=1-s;for(let c=0;c<e.length;c+=4){const h=e[c],u=e[c+1],d=e[c+2];let g,f,p;switch(this.mode){case"multiply":g=h*n/255,f=u*o/255,p=d*a/255;break;case"screen":g=255-(255-h)*(255-n)/255,f=255-(255-u)*(255-o)/255,p=255-(255-d)*(255-a)/255;break;case"add":g=h+n,f=u+o,p=d+a;break;case"difference":g=Math.abs(h-n),f=Math.abs(u-o),p=Math.abs(d-a);break;case"subtract":g=h-n,f=u-o,p=d-a;break;case"darken":g=Math.min(h,n),f=Math.min(u,o),p=Math.min(d,a);break;case"lighten":g=Math.max(h,n),f=Math.max(u,o),p=Math.max(d,a);break;case"overlay":g=n<128?2*h*n/255:255-2*(255-h)*(255-n)/255,f=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,p=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":g=n+h-2*n*h/255,f=o+u-2*o*u/255,p=a+d-2*a*d/255;break;case"tint":g=n+h*l,f=o+u*l,p=a+d*l}e[c]=g,e[c+1]=f,e[c+2]=p}}sendUniformData(t,e){const r=new rt(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,t.uniform4fv(e.uColor,r)}}m(Yr,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),m(Yr,"type","BlendColor"),m(Yr,"uniformLocations",["uColor"]),R.setClass(Yr);const _g={multiply:`
148
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=new rt(this.color).getSource(),s=this.alpha,n=r[0]*s,o=r[1]*s,a=r[2]*s,l=1-s;for(let c=0;c<e.length;c+=4){const h=e[c],u=e[c+1],d=e[c+2];let g,f,m;switch(this.mode){case"multiply":g=h*n/255,f=u*o/255,m=d*a/255;break;case"screen":g=255-(255-h)*(255-n)/255,f=255-(255-u)*(255-o)/255,m=255-(255-d)*(255-a)/255;break;case"add":g=h+n,f=u+o,m=d+a;break;case"difference":g=Math.abs(h-n),f=Math.abs(u-o),m=Math.abs(d-a);break;case"subtract":g=h-n,f=u-o,m=d-a;break;case"darken":g=Math.min(h,n),f=Math.min(u,o),m=Math.min(d,a);break;case"lighten":g=Math.max(h,n),f=Math.max(u,o),m=Math.max(d,a);break;case"overlay":g=n<128?2*h*n/255:255-2*(255-h)*(255-n)/255,f=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,m=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":g=n+h-2*n*h/255,f=o+u-2*o*u/255,m=a+d-2*a*d/255;break;case"tint":g=n+h*l,f=o+u*l,m=a+d*l}e[c]=g,e[c+1]=f,e[c+2]=m}}sendUniformData(t,e){const r=new rt(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,t.uniform4fv(e.uColor,r)}}v(Ur,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),v(Ur,"type","BlendColor"),v(Ur,"uniformLocations",["uColor"]),j.setClass(Ur);const eg={multiply:`
149
149
  precision highp float;
150
150
  uniform sampler2D uTexture;
151
151
  uniform sampler2D uImage;
@@ -171,7 +171,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
171
171
  color.a = color2.a;
172
172
  gl_FragColor = color;
173
173
  }
174
- `},Cg=["type","image"];class Ur extends bt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return _g[this.mode]}getVertexSource(){return`
174
+ `};class Gr extends yt{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return eg[this.mode]}getVertexSource(){return`
175
175
  attribute vec2 aPosition;
176
176
  varying vec2 vTexCoord;
177
177
  varying vec2 vTexCoord2;
@@ -181,7 +181,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
181
181
  vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
182
182
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
183
183
  }
184
- `}applyToWebGL(t){const e=t.context,r=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,r,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:r}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/r,1]}applyTo2d(t){let{imageData:{data:e,width:r,height:s},filterBackend:{resources:n}}=t;const o=this.image;n.blendImage||(n.blendImage=fe());const a=n.blendImage,l=a.getContext("2d");a.width!==r||a.height!==s?(a.width=r,a.height=s):l.clearRect(0,0,r,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,r,s);const c=l.getImageData(0,0,r,s).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],g=e[h+2],f=e[h+3],p=c[h],v=c[h+1],b=c[h+2],x=c[h+3];switch(this.mode){case"multiply":e[h]=u*p/255,e[h+1]=d*v/255,e[h+2]=g*b/255,e[h+3]=f*x/255;break;case"mask":e[h+3]=x}}}sendUniformData(t,e){const r=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,r)}toObject(){return y(y({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:r,image:s}=t,n=ot(t,Cg);return _t.fromObject(s,e).then(o=>new this(y(y({},n),{},{image:o})))}}m(Ur,"type","BlendImage"),m(Ur,"defaults",{mode:"multiply",alpha:1}),m(Ur,"uniformLocations",["uTransformMatrix","uImage"]),R.setClass(Ur);class Nr extends bt{getFragmentSource(){return`
184
+ `}applyToWebGL(t){const e=t.context,r=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,r,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:r}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/r,1]}applyTo2d(t){let{imageData:{data:e,width:r,height:s},filterBackend:{resources:n}}=t;const o=this.image;n.blendImage||(n.blendImage=fe());const a=n.blendImage,l=a.getContext("2d");a.width!==r||a.height!==s?(a.width=r,a.height=s):l.clearRect(0,0,r,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,r,s);const c=l.getImageData(0,0,r,s).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],g=e[h+2],f=e[h+3],m=c[h],y=c[h+1],b=c[h+2],w=c[h+3];switch(this.mode){case"multiply":e[h]=u*m/255,e[h+1]=d*y/255,e[h+2]=g*b/255,e[h+3]=f*w/255;break;case"mask":e[h+3]=w}}}sendUniformData(t,e){const r=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,r)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject(t,e){let{type:r,image:s,...n}=t;return St.fromObject(s,e).then(o=>new this({...n,image:o}))}}v(Gr,"type","BlendImage"),v(Gr,"defaults",{mode:"multiply",alpha:1}),v(Gr,"uniformLocations",["uTransformMatrix","uImage"]),j.setClass(Gr);class Nr extends yt{getFragmentSource(){return`
185
185
  precision highp float;
186
186
  uniform sampler2D uTexture;
187
187
  uniform vec2 uDelta;
@@ -210,7 +210,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
210
210
  gl_FragColor.rgb = color.rgb / totalC;
211
211
  gl_FragColor.a = color.a / totalA;
212
212
  }
213
- `}applyTo(t){ei(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:r,height:s}}=t;this.aspectRatio=r/s,this.horizontal=!0;let n=this.getBlurValue()*r;const o=new Uint8ClampedArray(e),a=15,l=4*r;for(let c=0;c<e.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const p=c-c%l,v=p+l;for(let b=-14;b<a;b++){const x=b/a,D=4*Math.floor(n*x),C=1-Math.abs(x);let O=c+D;O<p?O=p:O>v&&(O=v);const S=e[O+3]*C;h+=e[O]*S,u+=e[O+1]*S,d+=e[O+2]*S,g+=S,f+=C}o[c]=h/g,o[c+1]=u/g,o[c+2]=d/g,o[c+3]=g/f}this.horizontal=!1,n=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const p=c%l,v=o.length-l+p;for(let b=-14;b<a;b++){const x=b/a,D=Math.floor(n*x)*l,C=1-Math.abs(x);let O=c+D;O<p?O=p:O>v&&(O=v);const S=o[O+3]*C;h+=o[O]*S,u+=o[O+1]*S,d+=o[O+2]*S,g+=S,f+=C}e[c]=h/g,e[c+1]=u/g,e[c+2]=d/g,e[c+3]=g/f}}sendUniformData(t,e){const r=this.chooseRightDelta();t.uniform2fv(e.uDelta,r)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:r}=this;return e?r>1&&(t=1/r):r<1&&(t=r),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}m(Nr,"type","Blur"),m(Nr,"defaults",{blur:0}),m(Nr,"uniformLocations",["uDelta"]),R.setClass(Nr);class Gr extends bt{getFragmentSource(){return`
213
+ `}applyTo(t){ri(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:r,height:s}}=t;this.aspectRatio=r/s,this.horizontal=!0;let n=this.getBlurValue()*r;const o=new Uint8ClampedArray(e),a=15,l=4*r;for(let c=0;c<e.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const m=c-c%l,y=m+l;for(let b=-14;b<a;b++){const w=b/a,T=4*Math.floor(n*w),C=1-Math.abs(w);let S=c+T;S<m?S=m:S>y&&(S=y);const D=e[S+3]*C;h+=e[S]*D,u+=e[S+1]*D,d+=e[S+2]*D,g+=D,f+=C}o[c]=h/g,o[c+1]=u/g,o[c+2]=d/g,o[c+3]=g/f}this.horizontal=!1,n=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let h=0,u=0,d=0,g=0,f=0;const m=c%l,y=o.length-l+m;for(let b=-14;b<a;b++){const w=b/a,T=Math.floor(n*w)*l,C=1-Math.abs(w);let S=c+T;S<m?S=m:S>y&&(S=y);const D=o[S+3]*C;h+=o[S]*D,u+=o[S+1]*D,d+=o[S+2]*D,g+=D,f+=C}e[c]=h/g,e[c+1]=u/g,e[c+2]=d/g,e[c+3]=g/f}}sendUniformData(t,e){const r=this.chooseRightDelta();t.uniform2fv(e.uDelta,r)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:r}=this;return e?r>1&&(t=1/r):r<1&&(t=r),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}v(Nr,"type","Blur"),v(Nr,"defaults",{blur:0}),v(Nr,"uniformLocations",["uDelta"]),j.setClass(Nr);class qr extends yt{getFragmentSource(){return`
214
214
  precision highp float;
215
215
  uniform sampler2D uTexture;
216
216
  uniform float uBrightness;
@@ -220,7 +220,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
220
220
  color.rgb += uBrightness;
221
221
  gl_FragColor = color;
222
222
  }
223
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=r,e[s+1]+=r,e[s+2]+=r}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}m(Gr,"type","Brightness"),m(Gr,"defaults",{brightness:0}),m(Gr,"uniformLocations",["uBrightness"]),R.setClass(Gr);const Pl={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ve extends bt{getFragmentSource(){return`
223
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=r,e[s+1]+=r,e[s+2]+=r}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}v(qr,"type","Brightness"),v(qr,"defaults",{brightness:0}),v(qr,"uniformLocations",["uBrightness"]),j.setClass(qr);const Tl={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class We extends yt{getFragmentSource(){return`
224
224
  precision highp float;
225
225
  uniform sampler2D uTexture;
226
226
  varying vec2 vTexCoord;
@@ -231,7 +231,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
231
231
  color *= uColorMatrix;
232
232
  color += uConstants;
233
233
  gl_FragColor = color;
234
- }`}applyTo2d(t){const e=t.imageData.data,r=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*r[0]+a*r[1]+l*r[2]+255*r[4],e[n+1]=o*r[5]+a*r[6]+l*r[7]+255*r[9],e[n+2]=o*r[10]+a*r[11]+l*r[12]+255*r[14],!s){const c=e[n+3];e[n]+=c*r[3],e[n+1]+=c*r[8],e[n+2]+=c*r[13],e[n+3]=o*r[15]+a*r[16]+l*r[17]+c*r[18]+255*r[19]}}}sendUniformData(t,e){const r=this.matrix,s=[r[0],r[1],r[2],r[3],r[5],r[6],r[7],r[8],r[10],r[11],r[12],r[13],r[15],r[16],r[17],r[18]],n=[r[4],r[9],r[14],r[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,n)}toObject(){return y(y({},super.toObject()),{},{matrix:[...this.matrix]})}}function We(i,t){var e;const r=(m(e=class extends Ve{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",i),m(e,"defaults",{colorsOnly:!1,matrix:t}),e);return R.setClass(r,i),r}m(Ve,"type","ColorMatrix"),m(Ve,"defaults",Pl),m(Ve,"uniformLocations",["uColorMatrix","uConstants"]),R.setClass(Ve);const Sg=We("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Tg=We("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),kg=We("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),Og=We("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),Dg=We("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),Mg=We("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Eg=We("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 Sn extends bt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){ei(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(r=>R.getClass(r.type).fromObject(r,e))).then(r=>new this({subFilters:r}))}}m(Sn,"type","Composed"),R.setClass(Sn);class $r extends bt{getFragmentSource(){return`
234
+ }`}applyTo2d(t){const e=t.imageData.data,r=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*r[0]+a*r[1]+l*r[2]+255*r[4],e[n+1]=o*r[5]+a*r[6]+l*r[7]+255*r[9],e[n+2]=o*r[10]+a*r[11]+l*r[12]+255*r[14],!s){const c=e[n+3];e[n]+=c*r[3],e[n+1]+=c*r[8],e[n+2]+=c*r[13],e[n+3]=o*r[15]+a*r[16]+l*r[17]+c*r[18]+255*r[19]}}}sendUniformData(t,e){const r=this.matrix,s=[r[0],r[1],r[2],r[3],r[5],r[6],r[7],r[8],r[10],r[11],r[12],r[13],r[15],r[16],r[17],r[18]],n=[r[4],r[9],r[14],r[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,n)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}}function Xe(i,t){var e;const r=(v(e=class extends We{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",i),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return j.setClass(r,i),r}v(We,"type","ColorMatrix"),v(We,"defaults",Tl),v(We,"uniformLocations",["uColorMatrix","uConstants"]),j.setClass(We);const rg=Xe("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),sg=Xe("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),ig=Xe("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),ng=Xe("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),og=Xe("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),ag=Xe("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),lg=Xe("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 kn extends yt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){ri(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(r=>j.getClass(r.type).fromObject(r,e))).then(r=>new this({subFilters:r}))}}v(kn,"type","Composed"),j.setClass(kn);class Kr extends yt{getFragmentSource(){return`
235
235
  precision highp float;
236
236
  uniform sampler2D uTexture;
237
237
  uniform float uContrast;
@@ -241,7 +241,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
241
241
  float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
242
242
  color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
243
243
  gl_FragColor = color;
244
- }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(let n=0;n<e.length;n+=4)e[n]=s*(e[n]-128)+128,e[n+1]=s*(e[n+1]-128)+128,e[n+2]=s*(e[n+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}m($r,"type","Contrast"),m($r,"defaults",{contrast:0}),m($r,"uniformLocations",["uContrast"]),R.setClass($r);const Pg={Convolute_3_1:`
244
+ }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(let n=0;n<e.length;n+=4)e[n]=s*(e[n]-128)+128,e[n+1]=s*(e[n+1]-128)+128,e[n+2]=s*(e[n+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}v(Kr,"type","Contrast"),v(Kr,"defaults",{contrast:0}),v(Kr,"uniformLocations",["uContrast"]),j.setClass(Kr);const cg={Convolute_3_1:`
245
245
  precision highp float;
246
246
  uniform sampler2D uTexture;
247
247
  uniform float uMatrix[9];
@@ -385,7 +385,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
385
385
  gl_FragColor = color;
386
386
  gl_FragColor.a = alpha;
387
387
  }
388
- `};class qr extends bt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Pg[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,r=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,u=this.opaque?1:0;let d,g,f,p,v,b,x,D,C,O,S,j,T;for(S=0;S<l;S++)for(O=0;O<a;O++){for(v=4*(S*a+O),d=0,g=0,f=0,p=0,T=0;T<n;T++)for(j=0;j<n;j++)x=S+T-o,b=O+j-o,x<0||x>=l||b<0||b>=a||(D=4*(x*a+b),C=s[T*n+j],d+=r[D]*C,g+=r[D+1]*C,f+=r[D+2]*C,u||(p+=r[D+3]*C));h[v]=d,h[v+1]=g,h[v+2]=f,h[v+3]=u?r[v+3]:p}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return y(y({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}m(qr,"type","Convolute"),m(qr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),m(qr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),R.setClass(qr);const Al="Gamma";class Kr extends bt{getFragmentSource(){return`
388
+ `};class Zr extends yt{getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${this.opaque?1:0}`}getFragmentSource(){return cg[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,r=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,u=this.opaque?1:0;let d,g,f,m,y,b,w,T,C,S,D,A,_;for(D=0;D<l;D++)for(S=0;S<a;S++){for(y=4*(D*a+S),d=0,g=0,f=0,m=0,_=0;_<n;_++)for(A=0;A<n;A++)w=D+_-o,b=S+A-o,w<0||w>=l||b<0||b>=a||(T=4*(w*a+b),C=s[_*n+A],d+=r[T]*C,g+=r[T+1]*C,f+=r[T+2]*C,u||(m+=r[T+3]*C));h[y]=d,h[y+1]=g,h[y+2]=f,h[y+3]=u?r[y+3]:m}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}}v(Zr,"type","Convolute"),v(Zr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(Zr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),j.setClass(Zr);const Ol="Gamma";class Jr extends yt{getFragmentSource(){return`
389
389
  precision highp float;
390
390
  uniform sampler2D uTexture;
391
391
  uniform vec3 uGamma;
@@ -399,7 +399,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
399
399
  gl_FragColor = color;
400
400
  gl_FragColor.rgb *= color.a;
401
401
  }
402
- `}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.gamma,s=1/r[0],n=1/r[1],o=1/r[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,n),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:Al,gamma:this.gamma.concat()}}}m(Kr,"type",Al),m(Kr,"defaults",{gamma:[1,1,1]}),m(Kr,"uniformLocations",["uGamma"]),R.setClass(Kr);const Ag={average:`
402
+ `}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.gamma,s=1/r[0],n=1/r[1],o=1/r[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,n),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:Ol,gamma:this.gamma.concat()}}}v(Jr,"type",Ol),v(Jr,"defaults",{gamma:[1,1,1]}),v(Jr,"uniformLocations",["uGamma"]),j.setClass(Jr);const hg={average:`
403
403
  precision highp float;
404
404
  uniform sampler2D uTexture;
405
405
  varying vec2 vTexCoord;
@@ -428,7 +428,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
428
428
  float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
429
429
  gl_FragColor = vec4(average, average, average, col.a);
430
430
  }
431
- `};class Zr extends bt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r,s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":r=(n+o+a)/3;break;case"lightness":r=(Math.min(n,o,a)+Math.max(n,o,a))/2;break;case"luminosity":r=.21*n+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=r}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Ag[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}m(Zr,"type","Grayscale"),m(Zr,"defaults",{mode:"average"}),m(Zr,"uniformLocations",["uMode"]),R.setClass(Zr);const Lg=y(y({},Pl),{},{rotation:0});class ri extends Ve{calculateMatrix(){const t=this.rotation*Math.PI,e=de(t),r=ge(t),s=1/3,n=Math.sqrt(s)*r,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}}}m(ri,"type","HueRotation"),m(ri,"defaults",Lg),R.setClass(ri);class Jr extends bt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r=0;r<e.length;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2],this.alpha&&(e[r+3]=255-e[r+3])}getFragmentSource(){return`
431
+ `};class Qr extends yt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r,s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":r=(n+o+a)/3;break;case"lightness":r=(Math.min(n,o,a)+Math.max(n,o,a))/2;break;case"luminosity":r=.21*n+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=r}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return hg[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(Qr,"type","Grayscale"),v(Qr,"defaults",{mode:"average"}),v(Qr,"uniformLocations",["uMode"]),j.setClass(Qr);const ug={...Tl,rotation:0};class si extends We{calculateMatrix(){const t=this.rotation*Math.PI,e=de(t),r=ge(t),s=1/3,n=Math.sqrt(s)*r,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(si,"type","HueRotation"),v(si,"defaults",ug),j.setClass(si);class ts extends yt{applyTo2d(t){let{imageData:{data:e}}=t;for(let r=0;r<e.length;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2],this.alpha&&(e[r+3]=255-e[r+3])}getFragmentSource(){return`
432
432
  precision highp float;
433
433
  uniform sampler2D uTexture;
434
434
  uniform int uInvert;
@@ -446,7 +446,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
446
446
  gl_FragColor = color;
447
447
  }
448
448
  }
449
- `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}m(Jr,"type","Invert"),m(Jr,"defaults",{alpha:!1,invert:!0}),m(Jr,"uniformLocations",["uInvert","uAlpha"]),R.setClass(Jr);class Qr extends bt{getFragmentSource(){return`
449
+ `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}v(ts,"type","Invert"),v(ts,"defaults",{alpha:!1,invert:!0}),v(ts,"uniformLocations",["uInvert","uAlpha"]),j.setClass(ts);class es extends yt{getFragmentSource(){return`
450
450
  precision highp float;
451
451
  uniform sampler2D uTexture;
452
452
  uniform float uStepH;
@@ -461,7 +461,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
461
461
  color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
462
462
  gl_FragColor = color;
463
463
  }
464
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.noise;for(let s=0;s<e.length;s+=4){const n=(.5-Math.random())*r;e[s]+=n,e[s+1]+=n,e[s+2]+=n}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}m(Qr,"type","Noise"),m(Qr,"defaults",{noise:0}),m(Qr,"uniformLocations",["uNoise","uSeed"]),R.setClass(Qr);class ts extends bt{applyTo2d(t){let{imageData:{data:e,width:r,height:s}}=t;for(let n=0;n<s;n+=this.blocksize)for(let o=0;o<r;o+=this.blocksize){const a=4*n*r+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=n;d<Math.min(n+this.blocksize,s);d++)for(let g=o;g<Math.min(o+this.blocksize,r);g++){const f=4*d*r+4*g;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
464
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.noise;for(let s=0;s<e.length;s+=4){const n=(.5-Math.random())*r;e[s]+=n,e[s+1]+=n,e[s+2]+=n}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}v(es,"type","Noise"),v(es,"defaults",{noise:0}),v(es,"uniformLocations",["uNoise","uSeed"]),j.setClass(es);class rs extends yt{applyTo2d(t){let{imageData:{data:e,width:r,height:s}}=t;for(let n=0;n<s;n+=this.blocksize)for(let o=0;o<r;o+=this.blocksize){const a=4*n*r+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=n;d<Math.min(n+this.blocksize,s);d++)for(let g=o;g<Math.min(o+this.blocksize,r);g++){const f=4*d*r+4*g;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
465
465
  precision highp float;
466
466
  uniform sampler2D uTexture;
467
467
  uniform float uBlocksize;
@@ -479,7 +479,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
479
479
  vec4 color = texture2D(uTexture, squareCoords);
480
480
  gl_FragColor = color;
481
481
  }
482
- `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}m(ts,"type","Pixelate"),m(ts,"defaults",{blocksize:4}),m(ts,"uniformLocations",["uBlocksize"]),R.setClass(ts);class es extends bt{getFragmentSource(){return`
482
+ `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}v(rs,"type","Pixelate"),v(rs,"defaults",{blocksize:4}),v(rs,"uniformLocations",["uBlocksize"]),j.setClass(rs);class ss extends yt{getFragmentSource(){return`
483
483
  precision highp float;
484
484
  uniform sampler2D uTexture;
485
485
  uniform vec4 uLow;
@@ -491,23 +491,23 @@ void main() {
491
491
  gl_FragColor.a = 0.0;
492
492
  }
493
493
  }
494
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=255*this.distance,s=new rt(this.color).getSource(),n=[s[0]-r,s[1]-r,s[2]-r],o=[s[0]+r,s[1]+r,s[2]+r];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>n[0]&&c>n[1]&&h>n[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const r=new rt(this.color).getSource(),s=this.distance,n=[0+r[0]/255-s,0+r[1]/255-s,0+r[2]/255-s,1],o=[r[0]/255+s,r[1]/255+s,r[2]/255+s,1];t.uniform4fv(e.uLow,n),t.uniform4fv(e.uHigh,o)}}m(es,"type","RemoveColor"),m(es,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),m(es,"uniformLocations",["uLow","uHigh"]),R.setClass(es);class rs extends bt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,r=this.getFilterWindow(),s=new Array(r);for(let n=1;n<=r;n++)s[n-1]=t(n*e);return s}generateShader(t){const e=new Array(t);for(let r=1;r<=t;r++)e[r-1]="".concat(r,".0 * uDelta");return`
494
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=255*this.distance,s=new rt(this.color).getSource(),n=[s[0]-r,s[1]-r,s[2]-r],o=[s[0]+r,s[1]+r,s[2]+r];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>n[0]&&c>n[1]&&h>n[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const r=new rt(this.color).getSource(),s=this.distance,n=[0+r[0]/255-s,0+r[1]/255-s,0+r[2]/255-s,1],o=[r[0]/255+s,r[1]/255+s,r[2]/255+s,1];t.uniform4fv(e.uLow,n),t.uniform4fv(e.uHigh,o)}}v(ss,"type","RemoveColor"),v(ss,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),v(ss,"uniformLocations",["uLow","uHigh"]),j.setClass(ss);class is extends yt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return`${this.type}_${t}`}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,r=this.getFilterWindow(),s=new Array(r);for(let n=1;n<=r;n++)s[n-1]=t(n*e);return s}generateShader(t){const e=new Array(t);for(let r=1;r<=t;r++)e[r-1]=`${r}.0 * uDelta`;return`
495
495
  precision highp float;
496
496
  uniform sampler2D uTexture;
497
497
  uniform vec2 uDelta;
498
498
  varying vec2 vTexCoord;
499
- uniform float uTaps[`.concat(t,`];
499
+ uniform float uTaps[${t}];
500
500
  void main() {
501
501
  vec4 color = texture2D(uTexture, vTexCoord);
502
502
  float sum = 1.0;
503
- `).concat(e.map((r,s)=>`
504
- color += texture2D(uTexture, vTexCoord + `.concat(r,") * uTaps[").concat(s,"] + texture2D(uTexture, vTexCoord - ").concat(r,") * uTaps[").concat(s,`];
505
- sum += 2.0 * uTaps[`).concat(s,`];
506
- `)).join(`
507
- `),`
503
+ ${e.map((r,s)=>`
504
+ color += texture2D(uTexture, vTexCoord + ${r}) * uTaps[${s}] + texture2D(uTexture, vTexCoord - ${r}) * uTaps[${s}];
505
+ sum += 2.0 * uTaps[${s}];
506
+ `).join(`
507
+ `)}
508
508
  gl_FragColor = color / sum;
509
509
  }
510
- `)}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){ei(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 r=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(r)/r}}applyTo2d(t){const e=t.imageData,r=this.scaleX,s=this.scaleY;this.rcpScaleX=1/r,this.rcpScaleY=1/s;const n=e.width,o=e.height,a=Math.round(n*r),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,r,s,n){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=r*a;const d=t.filterBackend.resources;let g=0,f=0;const p=e;let v=0;d.sliceByTwo||(d.sliceByTwo=fe());const b=d.sliceByTwo;(b.width<1.5*e||b.height<r)&&(b.width=1.5*e,b.height=r);const x=b.getContext("2d");for(x.clearRect(0,0,1.5*e,r),x.putImageData(o,0,0),s=Math.floor(s),n=Math.floor(n);!l||!c;)e=h,r=u,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),n<Math.floor(u*a)?u=Math.floor(u*a):(u=n,c=!0),x.drawImage(b,g,f,e,r,p,v,h,u),g=p,f=v,v+=u;return x.getImageData(g,f,s,n)}lanczosResize(t,e,r,s,n){const o=t.imageData.data,a=t.ctx.createImageData(s,n),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,g=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),p=Math.ceil(u*this.lanczosLobes/2),v={},b={x:0,y:0},x={x:0,y:0};return function D(C){let O,S,j,T,L,H,W,V,U,X,tt;for(b.x=(C+.5)*h,x.x=Math.floor(b.x),O=0;O<n;O++){for(b.y=(O+.5)*u,x.y=Math.floor(b.y),L=0,H=0,W=0,V=0,U=0,S=x.x-f;S<=x.x+f;S++)if(!(S<0||S>=e)){X=Math.floor(1e3*Math.abs(S-b.x)),v[X]||(v[X]={});for(let Z=x.y-p;Z<=x.y+p;Z++)Z<0||Z>=r||(tt=Math.floor(1e3*Math.abs(Z-b.y)),v[X][tt]||(v[X][tt]=c(Math.sqrt(Math.pow(X*d,2)+Math.pow(tt*g,2))/1e3)),j=v[X][tt],j>0&&(T=4*(Z*e+S),L+=j,H+=j*o[T],W+=j*o[T+1],V+=j*o[T+2],U+=j*o[T+3]))}T=4*(O*s+C),l[T]=H/L,l[T+1]=W/L,l[T+2]=V/L,l[T+3]=U/L}return++C<s?D(C):a}(0)}bilinearFiltering(t,e,r,s,n){let o,a,l,c,h,u,d,g,f,p,v,b,x,D=0;const C=this.rcpScaleX,O=this.rcpScaleY,S=4*(e-1),j=t.imageData.data,T=t.ctx.createImageData(s,n),L=T.data;for(d=0;d<n;d++)for(g=0;g<s;g++)for(h=Math.floor(C*g),u=Math.floor(O*d),f=C*g-h,p=O*d-u,x=4*(u*e+h),v=0;v<4;v++)o=j[x+v],a=j[x+4+v],l=j[x+S+v],c=j[x+S+4+v],b=o*(1-f)*(1-p)+a*f*(1-p)+l*p*(1-f)+c*f*p,L[D++]=b;return T}hermiteFastResize(t,e,r,s,n){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,u=t.ctx.createImageData(s,n),d=u.data;for(let g=0;g<n;g++)for(let f=0;f<s;f++){const p=4*(f+g*s);let v=0,b=0,x=0,D=0,C=0,O=0,S=0;const j=(g+.5)*a;for(let T=Math.floor(g*a);T<(g+1)*a;T++){const L=Math.abs(j-(T+.5))/c,H=(f+.5)*o,W=L*L;for(let V=Math.floor(f*o);V<(f+1)*o;V++){let U=Math.abs(H-(V+.5))/l;const X=Math.sqrt(W+U*U);X>1&&X<-1||(v=2*X*X*X-3*X*X+1,v>0&&(U=4*(V+T*e),S+=v*h[U+3],x+=v,h[U+3]<255&&(v=v*h[U+3]/250),D+=v*h[U],C+=v*h[U+1],O+=v*h[U+2],b+=v))}}d[p]=D/b,d[p+1]=C/b,d[p+2]=O/b,d[p+3]=S/x}return u}}m(rs,"type","Resize"),m(rs,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),m(rs,"uniformLocations",["uDelta","uTaps"]),R.setClass(rs);class ss extends bt{getFragmentSource(){return`
510
+ `}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){ri(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 r=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(r)/r}}applyTo2d(t){const e=t.imageData,r=this.scaleX,s=this.scaleY;this.rcpScaleX=1/r,this.rcpScaleY=1/s;const n=e.width,o=e.height,a=Math.round(n*r),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,r,s,n){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=r*a;const d=t.filterBackend.resources;let g=0,f=0;const m=e;let y=0;d.sliceByTwo||(d.sliceByTwo=fe());const b=d.sliceByTwo;(b.width<1.5*e||b.height<r)&&(b.width=1.5*e,b.height=r);const w=b.getContext("2d");for(w.clearRect(0,0,1.5*e,r),w.putImageData(o,0,0),s=Math.floor(s),n=Math.floor(n);!l||!c;)e=h,r=u,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),n<Math.floor(u*a)?u=Math.floor(u*a):(u=n,c=!0),w.drawImage(b,g,f,e,r,m,y,h,u),g=m,f=y,y+=u;return w.getImageData(g,f,s,n)}lanczosResize(t,e,r,s,n){const o=t.imageData.data,a=t.ctx.createImageData(s,n),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,g=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),m=Math.ceil(u*this.lanczosLobes/2),y={},b={x:0,y:0},w={x:0,y:0};return function T(C){let S,D,A,_,M,O,V,z,X,W,G;for(b.x=(C+.5)*h,w.x=Math.floor(b.x),S=0;S<n;S++){for(b.y=(S+.5)*u,w.y=Math.floor(b.y),M=0,O=0,V=0,z=0,X=0,D=w.x-f;D<=w.x+f;D++)if(!(D<0||D>=e)){W=Math.floor(1e3*Math.abs(D-b.x)),y[W]||(y[W]={});for(let K=w.y-m;K<=w.y+m;K++)K<0||K>=r||(G=Math.floor(1e3*Math.abs(K-b.y)),y[W][G]||(y[W][G]=c(Math.sqrt(Math.pow(W*d,2)+Math.pow(G*g,2))/1e3)),A=y[W][G],A>0&&(_=4*(K*e+D),M+=A,O+=A*o[_],V+=A*o[_+1],z+=A*o[_+2],X+=A*o[_+3]))}_=4*(S*s+C),l[_]=O/M,l[_+1]=V/M,l[_+2]=z/M,l[_+3]=X/M}return++C<s?T(C):a}(0)}bilinearFiltering(t,e,r,s,n){let o,a,l,c,h,u,d,g,f,m,y,b,w,T=0;const C=this.rcpScaleX,S=this.rcpScaleY,D=4*(e-1),A=t.imageData.data,_=t.ctx.createImageData(s,n),M=_.data;for(d=0;d<n;d++)for(g=0;g<s;g++)for(h=Math.floor(C*g),u=Math.floor(S*d),f=C*g-h,m=S*d-u,w=4*(u*e+h),y=0;y<4;y++)o=A[w+y],a=A[w+4+y],l=A[w+D+y],c=A[w+D+4+y],b=o*(1-f)*(1-m)+a*f*(1-m)+l*m*(1-f)+c*f*m,M[T++]=b;return _}hermiteFastResize(t,e,r,s,n){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,u=t.ctx.createImageData(s,n),d=u.data;for(let g=0;g<n;g++)for(let f=0;f<s;f++){const m=4*(f+g*s);let y=0,b=0,w=0,T=0,C=0,S=0,D=0;const A=(g+.5)*a;for(let _=Math.floor(g*a);_<(g+1)*a;_++){const M=Math.abs(A-(_+.5))/c,O=(f+.5)*o,V=M*M;for(let z=Math.floor(f*o);z<(f+1)*o;z++){let X=Math.abs(O-(z+.5))/l;const W=Math.sqrt(V+X*X);W>1&&W<-1||(y=2*W*W*W-3*W*W+1,y>0&&(X=4*(z+_*e),D+=y*h[X+3],w+=y,h[X+3]<255&&(y=y*h[X+3]/250),T+=y*h[X],C+=y*h[X+1],S+=y*h[X+2],b+=y))}}d[m]=T/b,d[m+1]=C/b,d[m+2]=S/b,d[m+3]=D/w}return u}}v(is,"type","Resize"),v(is,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(is,"uniformLocations",["uDelta","uTaps"]),j.setClass(is);class ns extends yt{getFragmentSource(){return`
511
511
  precision highp float;
512
512
  uniform sampler2D uTexture;
513
513
  uniform float uSaturation;
@@ -521,7 +521,7 @@ void main() {
521
521
  color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
522
522
  gl_FragColor = color;
523
523
  }
524
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.saturation;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a);e[s]+=l!==n?(l-n)*r:0,e[s+1]+=l!==o?(l-o)*r:0,e[s+2]+=l!==a?(l-a)*r:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}m(ss,"type","Saturation"),m(ss,"defaults",{saturation:0}),m(ss,"uniformLocations",["uSaturation"]),R.setClass(ss);class is extends bt{getFragmentSource(){return`
524
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.saturation;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a);e[s]+=l!==n?(l-n)*r:0,e[s+1]+=l!==o?(l-o)*r:0,e[s+2]+=l!==a?(l-a)*r:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}v(ns,"type","Saturation"),v(ns,"defaults",{saturation:0}),v(ns,"uniformLocations",["uSaturation"]),j.setClass(ns);class os extends yt{getFragmentSource(){return`
525
525
  precision highp float;
526
526
  uniform sampler2D uTexture;
527
527
  uniform float uVibrance;
@@ -536,6 +536,6 @@ void main() {
536
536
  color.b += max != color.b ? (max - color.b) * amt : 0.00;
537
537
  gl_FragColor = color;
538
538
  }
539
- `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.vibrance;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a),c=(n+o+a)/3,h=2*Math.abs(l-c)/255*r;e[s]+=l!==n?(l-n)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}m(is,"type","Vibrance"),m(is,"defaults",{vibrance:0}),m(is,"uniformLocations",["uVibrance"]),R.setClass(is);var Tn=Object.freeze({__proto__:null,BaseFilter:bt,BlackWhite:Eg,BlendColor:Yr,BlendImage:Ur,Blur:Nr,Brightness:Gr,Brownie:Sg,ColorMatrix:Ve,Composed:Sn,Contrast:$r,Convolute:qr,Gamma:Kr,Grayscale:Zr,HueRotation:ri,Invert:Jr,Kodachrome:kg,Noise:Qr,Pixelate:ts,Polaroid:Dg,RemoveColor:es,Resize:rs,Saturation:ss,Sepia:Mg,Technicolor:Og,Vibrance:is,Vintage:Tg});const Ll=Symbol.for("bugpin-toObject-patched");if(!yt.prototype[Ll]){const i=yt.prototype.toObject;yt.prototype.toObject=function(t){const e=[...new Set(["data",...t||[]])];return i.call(this,e)},yt.prototype[Ll]=!0}const jg=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000"],Fg=[2,4,6,8];let Rg=0;function Ig(i,t,e){var D,C,O;const r=t,s=++Rg;r.data&&(r.data.generationId=s);const n=i.getZoom(),o=((D=i.viewportTransform)==null?void 0:D.slice())||[1,0,0,1,0,0];i.setZoom(1),i.setViewportTransform([1,0,0,1,0,0]),i.renderAll(),t.setCoords();const a=t.getBoundingRect(),l=a.left,c=a.top,h=a.width,u=a.height;if(h<5||u<5){i.setZoom(n),i.setViewportTransform(o),i.renderAll();return}const d=e.getElement(),g=e.scaleX||1,f=e.scaleY||1,v=((C=r.data)==null?void 0:C.blockSize)||Math.max(3,Math.round(Math.min(h,u)/20)),b=document.createElement("canvas");b.width=h,b.height=u;const x=b.getContext("2d");if(x){x.drawImage(d,l/g,c/f,h/g,u/f,0,0,h,u);const S=new _t(b);S.filters=[new Tn.Pixelate({blocksize:v})],S.applyFilters();const j=S.getElement();if(((O=r.data)==null?void 0:O.generationId)!==s){i.setZoom(n),i.setViewportTransform(o),i.renderAll();return}t.setElement(j),t.set({scaleX:1,scaleY:1,width:h,height:u}),r.data={type:"pixelate",blockSize:v,generationId:s}}i.setZoom(n),i.setViewportTransform(o),i.renderAll()}const Bg=({screenshot:i,onSave:t,onCancel:e})=>{const r=Ft(null),s=Ft(null),n=Ft(null),[o,a]=at("select"),[l,c]=at("#ef4444"),[h,u]=at(4),[d,g]=at(!1),[f,p]=at(!1),[v,b]=at(1),[x,D]=at(!1),C=Ft([]),O=Ft(-1),S=Ft(!1),j=Ft(!1),T=Ft(null),L=Ft(null);Ht(()=>{if(!r.current)return;const k=new mn(r.current,{isDrawingMode:!1,selection:!0});n.current=k,_t.fromURL(i).then(I=>{var N;L.current={width:I.width||800,height:I.height||600};const F=(N=s.current)==null?void 0:N.getBoundingClientRect(),M=F?F.width-32:800,Y=F?F.height-32:600,q=Math.min(M/(I.width||800),Y/(I.height||600));k.setDimensions({width:(I.width||800)*q,height:(I.height||600)*q}),I.scaleToWidth(k.width),k.backgroundImage=I,k.renderAll(),H()}),k.freeDrawingBrush=new qs(k),k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h,k.on("path:created",()=>{H()}),k.on("object:modified",I=>{var M;const F=I.target;((M=F==null?void 0:F.data)==null?void 0:M.type)==="pixelate"&&F instanceof _t&&k.backgroundImage&&(Ig(k,F,k.backgroundImage),H())});const P=r.current,E=I=>I.preventDefault();return P==null||P.addEventListener("contextmenu",E),()=>{P==null||P.removeEventListener("contextmenu",E),k.dispose()}},[i]),Ht(()=>{if(!n.current)return;const k=n.current;k.freeDrawingBrush&&(k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h)},[l,h]),Ht(()=>{if(!n.current)return;const k=n.current;k.isDrawingMode=o==="pen",k.selection=o==="select",o==="select"?k.defaultCursor="default":o==="pan"?k.defaultCursor="grab":k.defaultCursor="crosshair",D(o==="pan")},[o]);const H=K(()=>{if(!n.current)return;const k=JSON.stringify(n.current.toJSON());C.current=C.current.slice(0,O.current+1),C.current.push(k),O.current=C.current.length-1,g(O.current>0),p(!1)},[]),W=K(()=>{if(!n.current||O.current<=0)return;O.current--;const k=C.current[O.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(O.current>0),p(O.current<C.current.length-1)})},[]),V=K(()=>{if(!n.current||O.current>=C.current.length-1)return;O.current++;const k=C.current[O.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(O.current>0),p(O.current<C.current.length-1)})},[]),U=K(k=>{var F;if(!n.current||o==="pen"||o==="select"||o==="pan"||k.target||(F=n.current)!=null&&F.findTarget(k.e))return;S.current=!0;const P=n.current,E=P.getPointer(k.e);let I=null;switch(o){case"rectangle":I=new Lt({left:E.x,top:E.y,width:0,height:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!1,hasControls:!1,hasBorders:!1});break;case"circle":I=new Qt({left:E.x,top:E.y,rx:0,ry:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!1,hasControls:!1,hasBorders:!1});break;case"line":I=new Jt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1});break;case"arrow":I=new Jt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1}),I._isArrow=!0;break;case"text":I=new ae("Text",{left:E.x,top:E.y,fontSize:20,fill:l,selectable:!0,editable:!0}),P.add(I),P.setActiveObject(I),I.enterEditing(),S.current=!1;return;case"pixelate":I=new Lt({left:E.x,top:E.y,width:0,height:0,fill:"rgba(128, 128, 128, 0.3)",stroke:"#666",strokeWidth:1,strokeDashArray:[5,5],selectable:!1,hasControls:!1,hasBorders:!1});break}I&&(I._startPoint={x:E.x,y:E.y},P.add(I),P._drawingShape=I)},[o,l,h]),X=K(k=>{if(!n.current||!S.current)return;const P=n.current,E=P._drawingShape;if(!E||!E._startPoint)return;const I=P.getPointer(k.e),F=E._startPoint;if(E instanceof Lt){const M=I.x-F.x,Y=I.y-F.y;E.set({left:M>0?F.x:I.x,top:Y>0?F.y:I.y,width:Math.abs(M),height:Math.abs(Y)})}else if(E instanceof Qt){const M=Math.abs(I.x-F.x)/2,Y=Math.abs(I.y-F.y)/2;E.set({left:Math.min(F.x,I.x),top:Math.min(F.y,I.y),rx:M,ry:Y})}else E instanceof Jt&&E.set({x2:I.x,y2:I.y});P.renderAll()},[]),tt=K(async()=>{var k;if(S.current&&n.current){S.current=!1;const P=n.current,E=P._drawingShape;if(E){if(o==="pixelate"&&E instanceof Lt&&P.backgroundImage){const F=E,M=P.getZoom(),Y=((k=P.viewportTransform)==null?void 0:k.slice())||[1,0,0,1,0,0];P.setZoom(1),P.setViewportTransform([1,0,0,1,0,0]),P.renderAll(),F.setCoords();const q=F.getBoundingRect(),N=q.left,zt=q.top,ct=q.width,Ut=q.height;if(ct>5&&Ut>5){const Ot=P.backgroundImage,Ye=Ot.getElement(),nt=Ot.scaleX||1,le=Ot.scaleY||1,ee=document.createElement("canvas");ee.width=ct,ee.height=Ut;const _e=ee.getContext("2d");if(_e){_e.drawImage(Ye,N/nt,zt/le,ct/nt,Ut/le,0,0,ct,Ut);const vr=Math.max(3,Math.round(Math.min(ct,Ut)/20)),Le=new _t(ee,{left:N,top:zt,selectable:!0,hasControls:!0,hasBorders:!0});Le.data={type:"pixelate",blockSize:vr},Le.filters=[new Tn.Pixelate({blocksize:vr})],Le.applyFilters(),P.remove(F),P.add(Le)}}else P.remove(F);P.setZoom(M),P.setViewportTransform(Y),P.renderAll()}else if(E._isArrow&&E instanceof Jt){const F=E,M=F.x1||0,Y=F.y1||0,q=F.x2||0,N=F.y2||0,zt=q-M,ct=N-Y,Ut=Math.sqrt(zt*zt+ct*ct);if(Ut>10){const Ot=Math.atan2(ct,zt),Ye=F.strokeWidth||2,nt=Math.max(Ye*5,Math.min(Ye*7,Ut/3)),le=nt*.35,ee=q-nt*Math.cos(Ot),_e=N-nt*Math.sin(Ot),vr=ee-le*Math.cos(Ot-Math.PI/2),Le=_e-le*Math.sin(Ot-Math.PI/2),ce=ee-le*Math.cos(Ot+Math.PI/2),as=_e-le*Math.sin(Ot+Math.PI/2);F.set({x2:ee,y2:_e});const ls=new Xr([{x:q,y:N},{x:vr,y:Le},{x:ce,y:as}],{fill:F.stroke,stroke:F.stroke,strokeWidth:1,selectable:!1}),yr=new Me([F,ls],{selectable:!0,hasControls:!0,hasBorders:!0});P.remove(F),P.add(yr)}else E.set({selectable:!0,hasControls:!0,hasBorders:!0})}else E.set({selectable:!0,hasControls:!0,hasBorders:!0});P._drawingShape=void 0}H()}},[H,o]);Ht(()=>{if(!n.current)return;const k=n.current;return k.on("mouse:down",U),k.on("mouse:move",X),k.on("mouse:up",tt),()=>{k.off("mouse:down",U),k.off("mouse:move",X),k.off("mouse:up",tt)}},[U,X,tt]);const Z=K(()=>{var zt;if(!n.current)return;const k=n.current,P=k.getZoom(),E=((zt=k.viewportTransform)==null?void 0:zt.slice())||[1,0,0,1,0,0];k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll();const I=L.current,F=I?I.width/(k.width||1):1,M=[];if(k.backgroundImage&&F>1){const ct=k.backgroundImage,Ut=ct.getElement(),Ot=ct.scaleX||1,Ye=ct.scaleY||1;k.getObjects().forEach(nt=>{var ee,_e;const le=nt;if(((ee=le.data)==null?void 0:ee.type)==="pixelate"&&nt instanceof _t){const vr=nt.getElement(),Le={width:nt.width||0,height:nt.height||0,scaleX:nt.scaleX||1,scaleY:nt.scaleY||1,left:nt.left||0,top:nt.top||0,angle:nt.angle||0,skewX:nt.skewX||0,skewY:nt.skewY||0,flipX:nt.flipX||!1,flipY:nt.flipY||!1};M.push({obj:nt,originalElement:vr,originalState:Le}),nt.setCoords();const ce=nt.getBoundingRect(),as=ce.width*F,ls=ce.height*F,yr=document.createElement("canvas");yr.width=as,yr.height=ls;const mc=yr.getContext("2d");if(mc){mc.drawImage(Ut,ce.left/Ot,ce.top/Ye,ce.width/Ot,ce.height/Ye,0,0,as,ls);const Lp=((_e=le.data)==null?void 0:_e.blockSize)||Math.max(3,Math.round(Math.min(ce.width,ce.height)/20)),jp=Math.round(Lp*F),Nn=new _t(yr);Nn.filters=[new Tn.Pixelate({blocksize:jp})],Nn.applyFilters(),nt.setElement(Nn.getElement()),nt.set({width:as,height:ls,scaleX:1/F,scaleY:1/F})}}}),k.renderAll()}const Y=k.toDataURL({format:"png",quality:1,multiplier:F});M.forEach(({obj:ct,originalElement:Ut,originalState:Ot})=>{ct.setElement(Ut),ct.set(Ot)}),k.setZoom(P),k.setViewportTransform(E),k.renderAll();const N=k.getObjects().map(ct=>ct.toObject());t(Y,{objects:N})},[t]),J=K(()=>{if(!n.current)return;const k=n.current,P=k.getActiveObjects();P.length>0&&(P.forEach(E=>k.remove(E)),k.discardActiveObject(),k.renderAll(),H())},[H]),A=K(()=>{if(!n.current)return;const k=n.current,P=Math.min(v*1.2,3),E=new _(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[v]),ht=K(()=>{if(!n.current)return;const k=n.current,P=Math.max(v/1.2,.5),E=new _(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[v]),ut=K(()=>{if(!n.current)return;const k=n.current;b(1),k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll()},[]);Ht(()=>{if(!n.current)return;const k=n.current,P=F=>{const M=F.e;(M.buttons===2||M.buttons===1&&x||M.buttons===1&&o==="pan")&&(M.preventDefault(),j.current=!0,k.selection=!1,T.current={x:M.clientX,y:M.clientY},k.setCursor("grabbing"))},E=F=>{if(j.current&&T.current){const M=F.e,Y=k.viewportTransform;Y[4]+=M.clientX-T.current.x,Y[5]+=M.clientY-T.current.y,k.requestRenderAll(),T.current={x:M.clientX,y:M.clientY}}},I=()=>{j.current&&(j.current=!1,T.current=null,k.setCursor(x||o==="pan"?"grab":"default"),k.selection=o==="select")};return k.on("mouse:down",P),k.on("mouse:move",E),k.on("mouse:up",I),()=>{k.off("mouse:down",P),k.off("mouse:move",E),k.off("mouse:up",I)}},[x,o]),Ht(()=>{const k=E=>{if(E.key===" "&&!x&&(E.preventDefault(),D(!0),n.current&&n.current.setCursor("grab")),E.key==="Delete"||E.key==="Backspace"){const I=document.activeElement;(I==null?void 0:I.tagName)!=="INPUT"&&(I==null?void 0:I.tagName)!=="TEXTAREA"&&J()}(E.ctrlKey||E.metaKey)&&E.key==="z"&&(E.preventDefault(),E.shiftKey?V():W())},P=E=>{E.key===" "&&x&&(D(!1),n.current&&n.current.setCursor(o==="pan"?"grab":"default"))};return window.addEventListener("keydown",k),window.addEventListener("keyup",P),()=>{window.removeEventListener("keydown",k),window.removeEventListener("keyup",P)}},[J,W,V,x,o]);const dt=({tool:k,icon:P,label:E})=>w("button",{class:Rt("flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors","hover:bg-gray-100 hover:text-gray-800","[&_svg]:w-4.5 [&_svg]:h-4.5",o===k&&"bg-primary/10 text-primary"),onClick:()=>a(k),title:E,children:w("span",{dangerouslySetInnerHTML:{__html:P}})});return w("div",{class:"flex flex-col",children:[w("div",{class:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-solid border-border bg-muted",children:[w("div",{class:"flex items-center gap-1",children:[w(dt,{tool:"select",label:"Select",icon:'<svg viewBox="0 0 24 24"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z" fill="currentColor"/></svg>'}),w(dt,{tool:"pan",label:"Pan (or hold Space)",icon:'<svg viewBox="0 0 24 24"><path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z" fill="currentColor"/></svg>'}),w(dt,{tool:"pen",label:"Pen",icon:'<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="currentColor"/></svg>'}),w(dt,{tool:"line",label:"Line",icon:'<svg viewBox="0 0 24 24"><line x1="5" y1="19" x2="19" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'}),w(dt,{tool:"arrow",label:"Arrow",icon:'<svg viewBox="0 0 24 24"><line x1="5" y1="19" x2="19" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M19 5l-6 2 4 4 2-6z" fill="currentColor"/></svg>'}),w(dt,{tool:"rectangle",label:"Rectangle",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),w(dt,{tool:"circle",label:"Circle",icon:'<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),w(dt,{tool:"text",label:"Text",icon:'<svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4H5z" fill="currentColor"/></svg>'}),w(dt,{tool:"pixelate",label:"Pixelate",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="4" height="4" fill="currentColor"/><rect x="10" y="3" width="4" height="4" fill="currentColor"/><rect x="17" y="3" width="4" height="4" fill="currentColor"/><rect x="3" y="10" width="4" height="4" fill="currentColor"/><rect x="10" y="10" width="4" height="4" fill="currentColor"/><rect x="17" y="10" width="4" height="4" fill="currentColor"/><rect x="3" y="17" width="4" height="4" fill="currentColor"/><rect x="10" y="17" width="4" height="4" fill="currentColor"/><rect x="17" y="17" width="4" height="4" fill="currentColor"/></svg>'})]}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:jg.map(k=>w("button",{class:Rt("w-6 h-6 rounded-full border-2 border-solid cursor-pointer transition-transform hover:scale-110",l===k?"border-gray-800 scale-110":"border-transparent"),style:{backgroundColor:k},onClick:()=>c(k),title:k},k))}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:Fg.map(k=>w("button",{class:Rt("flex items-center justify-center w-8 h-8 border-none rounded bg-transparent cursor-pointer transition-colors","hover:bg-gray-100",h===k&&"bg-primary/10"),onClick:()=>u(k),title:`${k}px`,children:w("span",{class:"w-5 bg-gray-800 rounded-full",style:{height:`${k}px`}})},k))}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:[w("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:W,disabled:!d,title:"Undo (Ctrl+Z)",children:w("svg",{viewBox:"0 0 24 24",children:w("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",fill:"currentColor"})})}),w("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:V,disabled:!f,title:"Redo (Ctrl+Shift+Z)",children:w("svg",{viewBox:"0 0 24 24",children:w("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z",fill:"currentColor"})})}),w("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:J,title:"Delete selected (Del)",children:w("svg",{viewBox:"0 0 24 24",children:w("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]}),w("div",{class:"w-px h-6 bg-border"}),w("div",{class:"flex items-center gap-1",children:[w("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:ht,disabled:v<=.5,title:"Zoom Out - Hold Space to pan when zoomed",children:w("svg",{viewBox:"0 0 24 24",children:w("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z",fill:"currentColor"})})}),w("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:ut,title:`Reset Zoom (${Math.round(v*100)}%) - Hold Space to pan`,children:w("svg",{viewBox:"0 0 24 24",children:w("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z",fill:"currentColor"})})}),w("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:A,disabled:v>=3,title:"Zoom In - Hold Space to pan when zoomed",children:w("svg",{viewBox:"0 0 24 24",children:w("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z",fill:"currentColor"})})})]})]}),w("div",{class:"min-h-[600px] min-w-[700px] max-h-[70vh] overflow-auto flex items-center justify-center p-4 bg-gray-800",ref:s,children:w("canvas",{ref:r})}),w("div",{class:"flex gap-3 p-4 border-t border-solid border-border bg-muted",children:[w(Se,{variant:"outline",class:"flex-1",onClick:e,children:"Cancel"}),w(Se,{class:"flex-1",onClick:Z,children:"Done"})]})]})};function zg(i,t){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),s=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(s),t&&(r.href=t),s.href=i,s.href}const Hg=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function Ae(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let ur=null;function jl(i={}){return ur||(i.includeStyleProperties?(ur=i.includeStyleProperties,ur):(ur=Ae(window.getComputedStyle(document.documentElement)),ur))}function si(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Vg(i){const t=si(i,"border-left-width"),e=si(i,"border-right-width");return i.clientWidth+t+e}function Wg(i){const t=si(i,"border-top-width"),e=si(i,"border-bottom-width");return i.clientHeight+t+e}function Fl(i,t={}){const e=t.width||Vg(i),r=t.height||Wg(i);return{width:e,height:r}}function Xg(){let i,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(i=parseInt(e,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}const Bt=16384;function Yg(i){(i.width>Bt||i.height>Bt)&&(i.width>Bt&&i.height>Bt?i.width>i.height?(i.height*=Bt/i.width,i.width=Bt):(i.width*=Bt/i.height,i.height=Bt):i.width>Bt?(i.height*=Bt/i.width,i.width=Bt):(i.width*=Bt/i.height,i.height=Bt))}function ii(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=i})}async function Ug(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Ng(i,t,e){const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),n=document.createElementNS(r,"foreignObject");return s.setAttribute("width",`${t}`),s.setAttribute("height",`${e}`),s.setAttribute("viewBox",`0 0 ${t} ${e}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),s.appendChild(n),n.appendChild(i),Ug(s)}const jt=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||jt(e,t)};function Gg(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function $g(i,t){return jl(t).map(e=>{const r=i.getPropertyValue(e),s=i.getPropertyPriority(e);return`${e}: ${r}${s?" !important":""};`}).join(" ")}function qg(i,t,e,r){const s=`.${i}:${t}`,n=e.cssText?Gg(e):$g(e,r);return document.createTextNode(`${s}{${n}}`)}function Rl(i,t,e,r){const s=window.getComputedStyle(i,e),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=Hg();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(qg(o,e,s,r)),t.appendChild(a)}function Kg(i,t,e){Rl(i,t,":before",e),Rl(i,t,":after",e)}const Il="application/font-woff",Bl="image/jpeg",Zg={woff:Il,woff2:Il,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Bl,jpeg:Bl,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Jg(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function kn(i){const t=Jg(i).toLowerCase();return Zg[t]||""}function Qg(i){return i.split(/,/)[1]}function On(i){return i.search(/^(data:)/)!==-1}function tf(i,t){return`data:${t};base64,${i}`}async function zl(i,t,e){const r=await fetch(i,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const s=await r.blob();return new Promise((n,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{n(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(s)})}const Dn={};function ef(i,t,e){let r=i.replace(/\?.*/,"");return e&&(r=i),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Mn(i,t,e){const r=ef(i,t,e.includeQueryParams);if(Dn[r]!=null)return Dn[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let s;try{const n=await zl(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),Qg(a)));s=tf(n,t)}catch(n){s=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;n&&(o=typeof n=="string"?n:n.message),o&&console.warn(o)}return Dn[r]=s,s}async function rf(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):ii(t)}async function sf(i,t){if(i.currentSrc){const n=document.createElement("canvas"),o=n.getContext("2d");n.width=i.clientWidth,n.height=i.clientHeight,o==null||o.drawImage(i,0,0,n.width,n.height);const a=n.toDataURL();return ii(a)}const e=i.poster,r=kn(e),s=await Mn(e,r,t);return ii(s)}async function nf(i,t){var e;try{if(!((e=i==null?void 0:i.contentDocument)===null||e===void 0)&&e.body)return await ni(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function of(i,t){return jt(i,HTMLCanvasElement)?rf(i):jt(i,HTMLVideoElement)?sf(i,t):jt(i,HTMLIFrameElement)?nf(i,t):i.cloneNode(Hl(i))}const af=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",Hl=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function lf(i,t,e){var r,s;if(Hl(t))return t;let n=[];return af(i)&&i.assignedNodes?n=Ae(i.assignedNodes()):jt(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?n=Ae(i.contentDocument.body.childNodes):n=Ae(((s=i.shadowRoot)!==null&&s!==void 0?s:i).childNodes),n.length===0||jt(i,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>ni(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function cf(i,t,e){const r=t.style;if(!r)return;const s=window.getComputedStyle(i);s.cssText?(r.cssText=s.cssText,r.transformOrigin=s.transformOrigin):jl(e).forEach(n=>{let o=s.getPropertyValue(n);n==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),jt(i,HTMLIFrameElement)&&n==="display"&&o==="inline"&&(o="block"),n==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(n,o,s.getPropertyPriority(n))})}function hf(i,t){jt(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),jt(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function uf(i,t){if(jt(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(s=>i.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function df(i,t,e){return jt(t,Element)&&(cf(i,t,e),Kg(i,t,e),hf(i,t),uf(i,t)),t}async function gf(i,t){const e=i.querySelectorAll?i.querySelectorAll("use"):[];if(e.length===0)return i;const r={};for(let n=0;n<e.length;n++){const a=e[n].getAttribute("xlink:href");if(a){const l=i.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await ni(c,t,!0))}}const s=Object.values(r);if(s.length){const n="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg");o.setAttribute("xmlns",n),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(n,"defs");o.appendChild(a);for(let l=0;l<s.length;l++)a.appendChild(s[l]);i.appendChild(o)}return i}async function ni(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>of(r,t)).then(r=>lf(i,r,t)).then(r=>df(i,r,t)).then(r=>gf(r,t))}const Vl=/url\((['"]?)([^'"]+?)\1\)/g,ff=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,pf=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function mf(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function vf(i){const t=[];return i.replace(Vl,(e,r,s)=>(t.push(s),e)),t.filter(e=>!On(e))}async function yf(i,t,e,r,s){try{const n=e?zg(t,e):t,o=kn(t);let a;return s||(a=await Mn(n,o,r)),i.replace(mf(t),`$1${a}$3`)}catch{}return i}function bf(i,{preferredFontFormat:t}){return t?i.replace(pf,e=>{for(;;){const[r,,s]=ff.exec(e)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):i}function Wl(i){return i.search(Vl)!==-1}async function Xl(i,t,e){if(!Wl(i))return i;const r=bf(i,e);return vf(r).reduce((n,o)=>n.then(a=>yf(a,o,t,e)),Promise.resolve(r))}async function dr(i,t,e){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(s){const n=await Xl(s,null,e);return t.style.setProperty(i,n,t.style.getPropertyPriority(i)),!0}return!1}async function wf(i,t){await dr("background",i,t)||await dr("background-image",i,t),await dr("mask",i,t)||await dr("-webkit-mask",i,t)||await dr("mask-image",i,t)||await dr("-webkit-mask-image",i,t)}async function xf(i,t){const e=jt(i,HTMLImageElement);if(!(e&&!On(i.src))&&!(jt(i,SVGImageElement)&&!On(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,s=await Mn(r,kn(r),t);await new Promise((n,o)=>{i.onload=n,i.onerror=t.onImageErrorHandler?(...l)=>{try{n(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=i;a.decode&&(a.decode=n),a.loading==="lazy"&&(a.loading="eager"),e?(i.srcset="",i.src=s):i.href.baseVal=s})}async function _f(i,t){const r=Ae(i.childNodes).map(s=>Yl(s,t));await Promise.all(r).then(()=>i)}async function Yl(i,t){jt(i,Element)&&(await wf(i,t),await xf(i,t),await _f(i,t))}function Cf(i,t){const{style:e}=i;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(s=>{e[s]=r[s]}),i}const Ul={};async function Nl(i){let t=Ul[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},Ul[i]=t,t}async function Gl(i,t){let e=i.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,n=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),zl(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>e)}function $l(i){if(i==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=i.replace(e,"");const s=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=s.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(s,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=n.exec(r);if(l===null){if(l=a.exec(r),l===null)break;n.lastIndex=a.lastIndex}else a.lastIndex=n.lastIndex;t.push(l[0])}return t}async function Sf(i,t){const e=[],r=[];return i.forEach(s=>{if("cssRules"in s)try{Ae(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=Nl(l).then(h=>Gl(h,t)).then(h=>$l(h).forEach(u=>{try{s.insertRule(u,u.startsWith("@import")?a+=1:s.cssRules.length)}catch(d){console.error("Error inserting rule from remote css",{rule:u,error:d})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(n){const o=i.find(a=>a.href==null)||document.styleSheets[0];s.href!=null&&r.push(Nl(s.href).then(a=>Gl(a,t)).then(a=>$l(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",n)}}),Promise.all(r).then(()=>(i.forEach(s=>{if("cssRules"in s)try{Ae(s.cssRules||[]).forEach(n=>{e.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),e))}function Tf(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Wl(t.style.getPropertyValue("src")))}async function kf(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=Ae(i.ownerDocument.styleSheets),r=await Sf(e,t);return Tf(r)}function ql(i){return i.trim().replace(/["']/g,"")}function Of(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(ql(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&e(n)})}return e(i),t}async function Df(i,t){const e=await kf(i,t),r=Of(i);return(await Promise.all(e.filter(n=>r.has(ql(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return Xl(n.cssText,o,t)}))).join(`
540
- `)}async function Mf(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Df(i,t);if(e){const r=document.createElement("style"),s=document.createTextNode(e);r.appendChild(s),i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r)}}async function Ef(i,t={}){const{width:e,height:r}=Fl(i,t),s=await ni(i,t,!0);return await Mf(s,t),await Yl(s,t),Cf(s,t),await Ng(s,e,r)}async function En(i,t={}){const{width:e,height:r}=Fl(i,t),s=await Ef(i,t),n=await ii(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Xg(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||Yg(o),o.style.width=`${c}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(n,0,0,o.width,o.height),o}const Pf=2,gr=16384,oi=4e7,Kl="data-bugpin-exclude";async function Af(){document.fonts&&document.fonts.ready&&await document.fonts.ready}async function Lf(i){const t=i.querySelectorAll("img"),e=[];t.forEach(r=>{r.complete?r.decode&&e.push(r.decode().catch(()=>{})):e.push(new Promise(s=>{const n=async()=>{if(r.removeEventListener("load",n),r.removeEventListener("error",o),r.decode)try{await r.decode()}catch{}s()},o=()=>{r.removeEventListener("load",n),r.removeEventListener("error",o),s()};r.addEventListener("load",n,{once:!0}),r.addEventListener("error",o,{once:!0})}))}),e.length>0&&await Promise.all(e)}function Pn(i,t,e="visible"){const r=Math.ceil(i),s=Math.ceil(t);if(r>gr||s>gr)throw e==="fullpage"?new Error(`Full page dimensions (${r}x${s}) exceed maximum canvas size (${gr}px). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot dimensions (${r}x${s}) exceed maximum canvas size (${gr}px). Try capturing a smaller element or use visible viewport mode.`);if(r*s>oi)throw e==="fullpage"?new Error(`Full page total pixels (${r*s}) exceed maximum (${oi}). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot total pixels (${r*s}) exceed maximum (${oi}). Try capturing a smaller element or use visible viewport mode.`);let n=Math.min(window.devicePixelRatio||1,Pf),o=r*n,a=s*n,l=o*a;for(;n>1&&(o>gr||a>gr||l>oi);)n-=.5,o=r*n,a=s*n,l=o*a;return Math.max(1,n)}function An(i){return!(i instanceof HTMLElement&&(i.tagName==="SCRIPT"||i.hasAttribute(Kl)))}function jf(){if(window.scrollY>0||window.scrollX>0)return null;const i=document.querySelectorAll("*");for(const t of i){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t),r=e.overflowY,s=e.overflowX;if(r==="auto"||r==="scroll"||s==="auto"||s==="scroll"){const o=t.scrollHeight>t.clientHeight&&t.scrollTop>0,a=t.scrollWidth>t.clientWidth&&t.scrollLeft>0;if(o||a)return t}}return null}function Ln(){const i=window.getComputedStyle(document.body).backgroundColor,t=window.getComputedStyle(document.documentElement).backgroundColor,e=r=>!r||r==="transparent"||r==="rgba(0, 0, 0, 0)";return e(i)?e(t)?"#ffffff":t:i}async function Ff(){try{const i=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1}),t=document.createElement("video");t.srcObject=i,t.autoplay=!0,await new Promise(s=>{t.onloadedmetadata=()=>s()}),await new Promise(s=>setTimeout(s,100));const e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight;const r=e.getContext("2d");if(!r)throw new Error("Failed to get canvas context");return r.drawImage(t,0,0),i.getTracks().forEach(s=>s.stop()),e.toDataURL("image/png")}catch(i){throw i instanceof Error&&i.name==="NotAllowedError"?new Error("Screen capture permission denied"):i}}async function Rf(i={}){const{method:t="visible",selector:e,useScreenCaptureAPI:r=!1,cacheBust:s}=i;if(r)return Ff();let n;switch(t){case"element":if(!e)throw new Error("Selector required for element capture");const g=document.querySelector(e);if(!g||!(g instanceof HTMLElement))throw new Error(`Element not found: ${e}`);n=g;break;case"fullpage":case"visible":default:n=document.documentElement;break}const o=jf();let a,l,c,h;o&&o!==document.documentElement&&o!==document.body?(a=o.scrollLeft,l=o.scrollTop,c=o.clientWidth,h=o.clientHeight,t==="visible"&&(n=o)):(a=window.scrollX||window.pageXOffset||0,l=window.scrollY||window.pageYOffset||0,c=document.documentElement.clientWidth,h=document.documentElement.clientHeight);const u=document.querySelectorAll(`[${Kl}]`),d=new Map;u.forEach(g=>{g instanceof HTMLElement&&(d.set(g,g.style.visibility),g.style.visibility="hidden")});try{if(await Af(),await Lf(n),t==="visible"){const x=Pn(c,h,"visible"),D=Ln(),C=a+c,O=l+h;console.log("[BugPin] Capture debug:",{scrollX:a,scrollY:l,viewportWidth:c,viewportHeight:h,captureWidth:C,captureHeight:O,dpr:x});const j=await En(n,{cacheBust:s??!1,pixelRatio:x,width:C,height:O,backgroundColor:D,filter:An});console.log("[BugPin] Canvas captured:",{canvasWidth:j.width,canvasHeight:j.height,expectedWidth:C*x,expectedHeight:O*x});const T=document.createElement("canvas");T.width=c*x,T.height=h*x;const L=T.getContext("2d");if(!L)throw new Error("Failed to get canvas context");return L.fillStyle=D,L.fillRect(0,0,T.width,T.height),L.drawImage(j,a*x,l*x,c*x,h*x,0,0,c*x,h*x),T.toDataURL("image/png")}if(t==="fullpage"){const x=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth),D=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight),C=Pn(x,D,"fullpage"),O=Ln();return(await En(n,{cacheBust:s??!0,pixelRatio:C,width:x,height:D,backgroundColor:O,filter:An})).toDataURL("image/png")}const g=n.getBoundingClientRect(),f=Pn(g.width,g.height,"element"),p=Ln();return(await En(n,{cacheBust:s??!1,pixelRatio:f,backgroundColor:p,filter:An})).toDataURL("image/png")}finally{u.forEach(g=>{g instanceof HTMLElement&&(g.style.visibility=d.get(g)||"")})}}function Zl(i){const t=i.split(","),e=t[0].match(/:(.*?);/),r=e?e[1]:"image/png",s=atob(t[1]),n=new Uint8Array(s.length);for(let o=0;o<s.length;o++)n[o]=s.charCodeAt(o);return new Blob([n],{type:r})}function Jl(i){return i.startsWith("data:image/webp")?"webp":i.startsWith("data:image/jpeg")?"jpg":i.startsWith("data:image/gif")?"gif":"png"}const fr=[],ns=[],os=[],If=30;let Ql=!1;function Bf(){if(Ql)return;Ql=!0;const i=console.error;console.error=(...o)=>{fr.push({type:"error",message:o.map(a=>String(a)).join(" "),timestamp:new Date().toISOString()}),i.apply(console,o)};const t=console.warn;console.warn=(...o)=>{fr.push({type:"warn",message:o.map(a=>String(a)).join(" "),timestamp:new Date().toISOString()}),t.apply(console,o)};const e=window.onerror;window.onerror=(o,a,l,c,h)=>(fr.push({type:"error",message:String(o),source:a||void 0,line:l||void 0,timestamp:new Date().toISOString()}),e?e.apply(window,[o,a,l,c,h]):!1),window.addEventListener("unhandledrejection",o=>{fr.push({type:"error",message:`Unhandled Promise Rejection: ${String(o.reason)}`,timestamp:new Date().toISOString()})});const r=window.fetch.bind(window);window.fetch=async function(o,a){const l=typeof o=="string"?o:o instanceof URL?o.href:o.url,c=(a==null?void 0:a.method)||"GET";try{const h=await r(o,a);return h.status>=300&&ns.push({url:l,method:c,status:h.status,statusText:h.statusText,timestamp:new Date().toISOString()}),h}catch(h){throw ns.push({url:l,method:c,status:0,statusText:h instanceof Error?h.message:"Network Error",timestamp:new Date().toISOString()}),h}};const s=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(o,a){return this._bugpinMethod=o,this._bugpinUrl=typeof a=="string"?a:a.href,s.apply(this,arguments)},XMLHttpRequest.prototype.send=function(){return this.addEventListener("load",function(){this.status>=300&&ns.push({url:this._bugpinUrl||"",method:this._bugpinMethod||"GET",status:this.status,statusText:this.statusText,timestamp:new Date().toISOString()})}),n.apply(this,arguments)},document.addEventListener("click",o=>{var c,h,u,d;const a=o.target;if(!a||a.closest("[data-bugpin-exclude]"))return;let l=null;if(a.tagName==="BUTTON"||a.closest("button"))l={type:"button",text:((c=(a.tagName==="BUTTON"?a:a.closest("button")).textContent)==null?void 0:c.trim().slice(0,50))||void 0,timestamp:new Date().toISOString()};else if(a.tagName==="A"||a.closest("a")){const g=a.tagName==="A"?a:a.closest("a");l={type:"link",text:((h=g.textContent)==null?void 0:h.trim().slice(0,50))||void 0,url:g.href||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="INPUT"&&a.type==="checkbox"){const g=a;l={type:"checkbox",text:g.name||g.id||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="INPUT"){const g=a;l={type:"input",inputType:g.type||"text",text:g.name||((u=g.placeholder)==null?void 0:u.slice(0,30))||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="SELECT"||a.closest('[role="combobox"]')){const g=a.tagName==="SELECT"?a:null;l={type:"select",text:(g==null?void 0:g.name)||void 0,timestamp:new Date().toISOString()}}else(a.onclick||a.getAttribute("role")==="button"||a.classList.contains("btn")||a.closest('[role="button"]'))&&(l={type:"other",text:((d=a.textContent)==null?void 0:d.trim().slice(0,50))||void 0,timestamp:new Date().toISOString()});l&&zf(l)},!0)}function zf(i){os.push(i),os.length>If&&os.shift()}function Hf(){var r,s,n,o,a;const i=navigator.userAgent;let t="Unknown",e="";return i.includes("Firefox/")?(t="Firefox",e=((r=i.match(/Firefox\/([\d.]+)/))==null?void 0:r[1])||""):i.includes("Edg/")?(t="Edge",e=((s=i.match(/Edg\/([\d.]+)/))==null?void 0:s[1])||""):i.includes("Chrome/")?(t="Chrome",e=((n=i.match(/Chrome\/([\d.]+)/))==null?void 0:n[1])||""):i.includes("Safari/")&&!i.includes("Chrome")?(t="Safari",e=((o=i.match(/Version\/([\d.]+)/))==null?void 0:o[1])||""):(i.includes("Opera/")||i.includes("OPR/"))&&(t="Opera",e=((a=i.match(/(?:Opera|OPR)\/([\d.]+)/))==null?void 0:a[1])||""),{name:t,version:e,userAgent:i}}function Vf(){var s,n,o,a,l;const i=navigator.userAgent;let t="desktop",e="Unknown",r;if(/Mobi|Android|iPhone|iPad|iPod/i.test(i)&&(/iPad|Tablet/i.test(i)||window.innerWidth>=768&&/Android/i.test(i)?t="tablet":t="mobile"),i.includes("Windows")){e="Windows";const c=i.match(/Windows NT ([\d.]+)/);if(c){const h=c[1];r={"10.0":"10/11","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista"}[h]||h}}else i.includes("Mac OS X")?(e="macOS",r=(n=(s=i.match(/Mac OS X ([\d._]+)/))==null?void 0:s[1])==null?void 0:n.replace(/_/g,".")):i.includes("Linux")?(e=i.includes("Android")?"Android":"Linux",e==="Android"&&(r=(o=i.match(/Android ([\d.]+)/))==null?void 0:o[1])):(i.includes("iPhone")||i.includes("iPad"))&&(e="iOS",r=(l=(a=i.match(/OS ([\d_]+)/))==null?void 0:a[1])==null?void 0:l.replace(/_/g,"."));return{type:t,os:e,osVersion:r}}function Wf(){return{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}function Xf(){const i={cookies:[],localStorage:[],sessionStorage:[]};try{const t=document.cookie;t&&(i.cookies=t.split(";").map(e=>e.split("=")[0].trim()))}catch{}try{for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e&&i.localStorage.push(e)}}catch{}try{for(let t=0;t<sessionStorage.length;t++){const e=sessionStorage.key(t);e&&i.sessionStorage.push(e)}}catch{}return i}function Yf(){try{const i=performance.getEntriesByType("navigation");if(i.length>0){const t=i[0];return Math.round(t.loadEventEnd-t.startTime)}}catch{}}function Uf(){return{url:window.location.href,title:document.title||void 0,referrer:document.referrer||void 0,browser:Hf(),device:Vf(),viewport:Wf(),timestamp:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,pageLoadTime:Yf(),consoleErrors:fr.length>0?[...fr]:void 0,networkErrors:ns.length>0?[...ns]:void 0,userActivity:os.length>0?[...os]:void 0,storageKeys:Xf()}}const jn=(i,t)=>t.some(e=>i instanceof e);let tc,ec;function Nf(){return tc||(tc=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Gf(){return ec||(ec=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Fn=new WeakMap,Rn=new WeakMap,ai=new WeakMap;function $f(i){const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("success",n),i.removeEventListener("error",o)},n=()=>{e(Xe(i.result)),s()},o=()=>{r(i.error),s()};i.addEventListener("success",n),i.addEventListener("error",o)});return ai.set(t,i),t}function qf(i){if(Fn.has(i))return;const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("complete",n),i.removeEventListener("error",o),i.removeEventListener("abort",o)},n=()=>{e(),s()},o=()=>{r(i.error||new DOMException("AbortError","AbortError")),s()};i.addEventListener("complete",n),i.addEventListener("error",o),i.addEventListener("abort",o)});Fn.set(i,t)}let In={get(i,t,e){if(i instanceof IDBTransaction){if(t==="done")return Fn.get(i);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Xe(i[t])},set(i,t,e){return i[t]=e,!0},has(i,t){return i instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in i}};function rc(i){In=i(In)}function Kf(i){return Gf().includes(i)?function(...t){return i.apply(Bn(this),t),Xe(this.request)}:function(...t){return Xe(i.apply(Bn(this),t))}}function Zf(i){return typeof i=="function"?Kf(i):(i instanceof IDBTransaction&&qf(i),jn(i,Nf())?new Proxy(i,In):i)}function Xe(i){if(i instanceof IDBRequest)return $f(i);if(Rn.has(i))return Rn.get(i);const t=Zf(i);return t!==i&&(Rn.set(i,t),ai.set(t,i)),t}const Bn=i=>ai.get(i);function sc(i,t,{blocked:e,upgrade:r,blocking:s,terminated:n}={}){const o=indexedDB.open(i,t),a=Xe(o);return r&&o.addEventListener("upgradeneeded",l=>{r(Xe(o.result),l.oldVersion,l.newVersion,Xe(o.transaction),l)}),e&&o.addEventListener("blocked",l=>e(l.oldVersion,l.newVersion,l)),a.then(l=>{n&&l.addEventListener("close",()=>n()),s&&l.addEventListener("versionchange",c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const Jf=["get","getKey","getAll","getAllKeys","count"],Qf=["put","add","delete","clear"],zn=new Map;function ic(i,t){if(!(i instanceof IDBDatabase&&!(t in i)&&typeof t=="string"))return;if(zn.get(t))return zn.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,s=Qf.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(s||Jf.includes(e)))return;const n=async function(o,...a){const l=this.transaction(o,s?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[e](...a),s&&l.done]))[0]};return zn.set(t,n),n}rc(i=>({...i,get:(t,e,r)=>ic(t,e)||i.get(t,e,r),has:(t,e)=>!!ic(t,e)||i.has(t,e)}));const tp=["continue","continuePrimaryKey","advance"],nc={},Hn=new WeakMap,oc=new WeakMap,ep={get(i,t){if(!tp.includes(t))return i[t];let e=nc[t];return e||(e=nc[t]=function(...r){Hn.set(this,oc.get(this)[t](...r))}),e}};async function*rp(...i){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...i)),!t)return;t=t;const e=new Proxy(t,ep);for(oc.set(e,t),ai.set(e,Bn(t));t;)yield e,t=await(Hn.get(e)||t.continue()),Hn.delete(e)}function ac(i,t){return t===Symbol.asyncIterator&&jn(i,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&jn(i,[IDBIndex,IDBObjectStore])}rc(i=>({...i,get(t,e,r){return ac(t,e)?rp:i.get(t,e,r)},has(t,e){return ac(t,e)||i.has(t,e)}}));const sp="bugpin-reports",ip=2,pr="pending-reports",lc=5,np=5e3,op=3e5,ap=2;let li=null,cc=null;function lp(i){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[i]||"bin"}async function ci(){if(li)return li;try{return li=await sc(sp,ip,{upgrade(i){i.objectStoreNames.contains(pr)||i.createObjectStore(pr,{keyPath:"id"}).createIndex("by-created","createdAt")}}),li}catch(i){throw console.error("[BugPin] Failed to initialize IndexedDB:",i),i}}function cp(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function hi(){return navigator.onLine!==!1}function hp(i){const t=np*Math.pow(ap,i);return Math.min(t,op)}async function hc(i){const t=await ci(),e={...i,id:cp(),createdAt:new Date().toISOString(),retryCount:0};return await t.put(pr,e),console.log("[BugPin] Report buffered for later submission:",e.id),hi()&&ui().catch(console.error),e.id}async function up(){try{return await(await ci()).getAllFromIndex(pr,"by-created")}catch{return[]}}async function uc(i){try{await(await ci()).delete(pr,i),console.log("[BugPin] Removed buffered report:",i)}catch(t){console.error("[BugPin] Failed to remove buffered report:",t)}}async function dp(i){try{await(await ci()).put(pr,i)}catch(t){console.error("[BugPin] Failed to update buffered report:",t)}}async function gp(i){var t,e;try{const r=new URL("/api/widget/submit",i.serverUrl),s=new FormData;if(s.append("data",JSON.stringify({title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,metadata:i.metadata,mediaCount:((t=i.media)==null?void 0:t.length)||0,mediaAnnotations:(e=i.media)==null?void 0:e.map(o=>o.annotations).filter(Boolean)})),i.media&&i.media.length>0)for(let o=0;o<i.media.length;o++){const a=i.media[o],l=Zl(a.dataUrl),c=Jl(a.dataUrl)||lp(a.mimeType),u=a.mimeType.startsWith("video/")?"video":"screenshot";s.append("media",l,`${u}-${o}.${c}`)}const n=await fetch(r.toString(),{method:"POST",body:s,headers:{"x-api-key":i.apiKey}});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.message||`HTTP ${n.status}`)}return!0}catch(r){throw console.error("[BugPin] Failed to submit buffered report:",r),r}}async function ui(){if(!hi())return console.log("[BugPin] Offline, skipping sync"),{synced:0,failed:0};const i=await up();if(i.length===0)return{synced:0,failed:0};console.log(`[BugPin] Syncing ${i.length} pending reports...`);let t=0,e=0;for(const r of i){if(r.lastRetryAt){const n=new Date(r.lastRetryAt).getTime()+hp(r.retryCount);if(Date.now()<n)continue}try{await gp(r),await uc(r.id),t++,console.log("[BugPin] Successfully synced report:",r.id)}catch(s){e++,r.retryCount++,r.lastRetryAt=new Date().toISOString(),r.error=s instanceof Error?s.message:"Unknown error",r.retryCount>=lc?(console.error("[BugPin] Max retries exceeded, removing report:",r.id),await uc(r.id)):(await dp(r),console.log(`[BugPin] Report retry scheduled (attempt ${r.retryCount}/${lc}):`,r.id))}}return{synced:t,failed:e}}function fp(){window.addEventListener("online",()=>{console.log("[BugPin] Back online, syncing pending reports..."),ui().catch(console.error)}),cc||(cc=setInterval(()=>{hi()&&ui().catch(console.error)},3e4)),hi()&&ui().catch(console.error)}fp();function pp(){return navigator.onLine!==!1}function mp(i){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[i]||"bin"}async function vp(i){const{apiKey:t,serverUrl:e,media:r,...s}=i;if(!pp())return console.log("[BugPin] Offline, buffering report for later submission"),await hc({apiKey:t,serverUrl:e,title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,media:r,metadata:s.metadata}),{success:!0,message:"Report saved. It will be submitted when you're back online."};const n=new URL("/api/widget/submit",e),o=new FormData;if(o.append("data",JSON.stringify({title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,metadata:s.metadata,mediaCount:(r==null?void 0:r.length)||0,mediaAnnotations:r==null?void 0:r.map(a=>a.annotations).filter(Boolean)})),r&&r.length>0)for(let a=0;a<r.length;a++){const l=r[a],c=Zl(l.dataUrl),h=Jl(l.dataUrl)||mp(l.mimeType),d=l.mimeType.startsWith("video/")?"video":"screenshot";console.log(`[BugPin] Media ${a}: dataUrl length=${l.dataUrl.length}, blob size=${c.size}, type=${c.type}`),o.append("media",c,`${d}-${a}.${h}`)}try{const a=await fetch(n.toString(),{method:"POST",body:o,headers:{"x-api-key":t}}),l=await a.json();if(!a.ok||!l.success)throw new Error(l.message||l.error||"Failed to submit report");return l}catch(a){if(a instanceof TypeError&&a.message.includes("fetch"))return console.log("[BugPin] Network error, buffering report for later submission"),await hc({apiKey:t,serverUrl:e,title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,media:r,metadata:s.metadata}),{success:!0,message:"Report saved. It will be submitted when the connection is restored."};throw a}}const yp="bugpin-drafts",bp=1,mr="draft-media",wp="bugpin-draft-";let di=null;async function gi(){if(di)return di;try{return di=await sc(yp,bp,{upgrade(i){i.objectStoreNames.contains(mr)||i.createObjectStore(mr,{keyPath:"apiKey"})}}),di}catch(i){throw console.error("[BugPin] Failed to initialize draft database:",i),i}}function Vn(i){return`${wp}${i}`}function xp(i,t,e){try{const r={formData:t,activeTab:e,savedAt:new Date().toISOString()};localStorage.setItem(Vn(i),JSON.stringify(r))}catch(r){console.error("[BugPin] Failed to save form draft:",r)}}function dc(i){try{const t=localStorage.getItem(Vn(i));return t?JSON.parse(t):null}catch(t){return console.error("[BugPin] Failed to load form draft:",t),null}}function _p(i){try{localStorage.removeItem(Vn(i))}catch(t){console.error("[BugPin] Failed to clear form draft:",t)}}async function Cp(i,t){try{await(await gi()).put(mr,{apiKey:i,media:t,savedAt:new Date().toISOString()})}catch(e){console.error("[BugPin] Failed to save media draft:",e)}}async function Sp(i){try{const e=await(await gi()).get(mr,i);return(e==null?void 0:e.media)||[]}catch(t){return console.error("[BugPin] Failed to load media draft:",t),[]}}async function gc(i){try{await(await gi()).delete(mr,i)}catch(t){console.error("[BugPin] Failed to clear media draft:",t)}}async function Tp(i){if(dc(i))return!0;try{const r=await(await gi()).get(mr,i);return r!==void 0&&r.media.length>0}catch{return!1}}async function kp(i,t,e,r){xp(i,t,e),r.length>0?await Cp(i,r):await gc(i)}async function Op(i){const t=dc(i),e=await Sp(i);return!t&&e.length===0?null:{formData:(t==null?void 0:t.formData)||{title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},activeTab:(t==null?void 0:t.activeTab)||"details",media:e}}async function Dp(i){_p(i),await gc(i)}const fi={save:kp,load:Op,clear:Dp,has:Tp};function Mp(i){return i==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":i}const Wn={title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},Ep=({config:i,deps:t})=>{const e=(t==null?void 0:t.WidgetDialog)??Ih,r=(t==null?void 0:t.AnnotationCanvas)??Bg,s=(t==null?void 0:t.captureScreenshot)??Rf,n=(t==null?void 0:t.captureContext)??Uf,o=(t==null?void 0:t.submitReport)??vp,a=Ft(null),[l,c]=at("closed"),[h,u]=at(!1),[d,g]=at(!1),[f,p]=at([]),[v,b]=at(null),[x,D]=at(null),[C,O]=at("details"),[S,j]=at(Wn),[T,L]=at(!1),[H,W]=at(!1);Ht(()=>{l==="form"&&!T&&fi.load(i.apiKey).then(M=>{M&&(j(M.formData),O(M.activeTab),p(M.media)),L(!0)})},[l,T,i.apiKey]),Ht(()=>{const M=a.current;if(!M)return;const Y=()=>{Mp(i.theme)==="dark"?(M.style.setProperty("--button-color",i.dialogDarkButtonColor),M.style.setProperty("--button-text-color",i.dialogDarkTextColor),M.style.setProperty("--button-hover-color",i.dialogDarkButtonHoverColor),M.style.setProperty("--button-hover-text-color",i.dialogDarkTextHoverColor)):(M.style.setProperty("--button-color",i.dialogLightButtonColor),M.style.setProperty("--button-text-color",i.dialogLightTextColor),M.style.setProperty("--button-hover-color",i.dialogLightButtonHoverColor),M.style.setProperty("--button-hover-text-color",i.dialogLightTextHoverColor))};if(Y(),i.theme==="auto"){const q=window.matchMedia("(prefers-color-scheme: dark)"),N=()=>Y();return q.addEventListener("change",N),()=>q.removeEventListener("change",N)}},[i.theme,i.dialogLightButtonColor,i.dialogLightTextColor,i.dialogLightButtonHoverColor,i.dialogLightTextHoverColor,i.dialogDarkButtonColor,i.dialogDarkTextColor,i.dialogDarkButtonHoverColor,i.dialogDarkTextHoverColor]);const V=K(()=>{c("form")},[]),U=S.title.trim()||S.description.trim()||S.reporterEmail.trim()||S.reporterName.trim()||f.length>0,X=K(()=>{U?W(!0):(c("closed"),b(null),L(!1))},[U]),tt=K(()=>{fi.save(i.apiKey,S,C,f),W(!1),c("closed"),b(null),L(!1)},[i.apiKey,S,C,f]),Z=K(()=>{p([]),O("details"),j(Wn),fi.clear(i.apiKey),W(!1),c("closed"),b(null),L(!1)},[i.apiKey]),J=K((M=!1)=>{M===!0&&(p([]),O("details"),j(Wn),fi.clear(i.apiKey)),W(!1),c("closed"),b(null),L(!1)},[i.apiKey]);Ht(()=>{const M=()=>V(),Y=()=>X();return document.addEventListener("bugpin:open",M),document.addEventListener("bugpin:close",Y),()=>{document.removeEventListener("bugpin:open",M),document.removeEventListener("bugpin:close",Y)}},[V,X]);const A=K(async()=>{if(i.enableScreenshot){g(!0),c("closed"),await new Promise(M=>setTimeout(M,100));try{const M=await s({method:i.captureMethod,useScreenCaptureAPI:i.useScreenCaptureAPI}),Y=new Image;Y.onload=()=>{console.log(`[BugPin] Captured screenshot: ${Y.width}x${Y.height}, dataUrl length=${M.length}`);const q={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png",width:Y.width,height:Y.height};p(N=>[...N,q]),g(!1),O("media"),c("form")},Y.onerror=()=>{const q={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:M,timestamp:new Date,annotated:!1,mimeType:"image/png"};p(N=>[...N,q]),g(!1),O("media"),c("form")},Y.src=M}catch(M){console.error("[BugPin] Failed to capture screenshot:",M),g(!1),c("form"),D({message:"Failed to capture screenshot",type:"error"})}}},[i,s]),ht=K(M=>{p(Y=>[...Y,M])},[]),ut=K(M=>{p(Y=>Y.filter(q=>q.id!==M))},[]),dt=K(M=>{b(M),c("annotating")},[]),k=K((M,Y)=>{v&&p(q=>q.map(N=>N.id===v?{...N,dataUrl:M,annotated:!0,annotations:Y}:N)),b(null),c("form")},[v]),P=K(()=>{b(null),c("form")},[]),E=K(async(M,Y)=>{u(!0);try{const q=n();await o({apiKey:i.apiKey,serverUrl:i.serverUrl,title:M.title,description:M.description,priority:M.priority,reporterEmail:M.reporterEmail||void 0,reporterName:M.reporterName||void 0,media:Y.map(N=>({dataUrl:N.dataUrl,mimeType:N.mimeType,annotations:N.annotations})),metadata:q}),D({message:"Bug report submitted successfully!",type:"success"}),J(!0)}catch(q){console.error("[BugPin] Failed to submit report:",q),D({message:q instanceof Error?q.message:"Failed to submit report",type:"error"})}finally{u(!1)}},[i,J,n,o]),I=K(()=>{D(null)},[]),F=v?f.find(M=>M.id===v):null;return w("div",{ref:a,class:`bugpin-container bugpin-theme-${i.theme}`,children:[w(Sh,{position:i.position,buttonText:i.buttonText,buttonShape:i.buttonShape,buttonIcon:i.buttonIcon,buttonIconSize:i.buttonIconSize,buttonIconStroke:i.buttonIconStroke,theme:i.theme,lightButtonColor:i.lightButtonColor,lightTextColor:i.lightTextColor,lightButtonHoverColor:i.lightButtonHoverColor,lightTextHoverColor:i.lightTextHoverColor,darkButtonColor:i.darkButtonColor,darkTextColor:i.darkTextColor,darkButtonHoverColor:i.darkButtonHoverColor,darkTextHoverColor:i.darkTextHoverColor,enableHoverScaleEffect:i.enableHoverScaleEffect,tooltipEnabled:i.tooltipEnabled,tooltipText:i.tooltipText,onClick:V}),l==="annotating"&&F&&w("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:w("div",{class:"relative max-w-4xl max-h-[90vh] bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",children:w(r,{screenshot:F.dataUrl,onSave:k,onCancel:P})})}),l==="form"&&w(e,{onClose:X,onSubmit:E,onCaptureScreenshot:A,onAnnotateMedia:dt,media:f,onAddMedia:ht,onRemoveMedia:ut,isSubmitting:h,isCapturing:d,enableAnnotation:i.enableAnnotation,activeTab:C,onActiveTabChange:O,formData:S,onFormDataChange:j}),H&&w("div",{class:"fixed inset-0 z-[2147483647] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:w("div",{class:"relative w-full max-w-sm bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-confirm-title",children:w("div",{class:"p-6",children:[w("h3",{id:"bugpin-confirm-title",class:"text-lg font-semibold text-foreground tracking-tight mb-2",children:"Save draft?"}),w("p",{class:"text-sm text-muted-foreground mb-6",children:"You have unsaved changes. Would you like to save them as a draft for later?"}),w("div",{class:"flex gap-3",children:[w("button",{type:"button",onClick:Z,class:"flex-1 px-4 py-2 text-sm font-medium rounded border border-solid border-border bg-background text-foreground hover:bg-muted transition-colors",children:"Discard"}),w("button",{type:"button",onClick:tt,class:"flex-1 px-4 py-2 text-sm font-medium rounded border border-solid border-transparent text-[var(--button-text-color)] bg-[var(--button-color)] hover:bg-[var(--button-hover-color)] hover:text-[var(--button-hover-text-color)] transition-colors",children:"Save Draft"})]})]})})}),x&&w(Eh,{message:x.message,type:x.type,onClose:I})]})},Xn={apiKey:"",serverUrl:window.location.origin,position:"bottom-right",buttonText:null,buttonShape:"round",buttonIcon:"bug",buttonIconSize:18,buttonIconStroke:2,theme:"auto",lightButtonColor:"#02658D",lightTextColor:"#ffffff",lightButtonHoverColor:"#024F6F",lightTextHoverColor:"#ffffff",darkButtonColor:"#02658D",darkTextColor:"#ffffff",darkButtonHoverColor:"#036F9B",darkTextHoverColor:"#ffffff",dialogLightButtonColor:"#02658D",dialogLightTextColor:"#ffffff",dialogLightButtonHoverColor:"#024F6F",dialogLightTextHoverColor:"#ffffff",dialogDarkButtonColor:"#02658D",dialogDarkTextColor:"#ffffff",dialogDarkButtonHoverColor:"#036F9B",dialogDarkTextHoverColor:"#ffffff",enableHoverScaleEffect:!0,tooltipEnabled:!1,tooltipText:null,enableScreenshot:!0,enableAnnotation:!0,enableConsoleCapture:!0,captureMethod:"visible",useScreenCaptureAPI:!1,maxScreenshotSize:5*1024*1024},Pp='/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-200:oklch(88.5% .062 18.334);--color-red-600:oklch(57.7% .245 27.325);--color-green-50:oklch(98.2% .018 155.826);--color-green-200:oklch(92.5% .084 155.995);--color-green-600:oklch(62.7% .194 149.214);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-3xl:48rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--shadow-sm:var(--shadow-sm);--shadow-lg:var(--shadow-lg);--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{box-sizing:border-box;margin:0;padding:0}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.top-1\\.5{top:calc(var(--spacing)*1.5)}.top-5{top:calc(var(--spacing)*5)}.top-full{top:100%}.right-5{right:calc(var(--spacing)*5)}.bottom-5{bottom:calc(var(--spacing)*5)}.bottom-20{bottom:calc(var(--spacing)*20)}.bottom-full{bottom:100%}.left-1\\.5{left:calc(var(--spacing)*1.5)}.left-5{left:calc(var(--spacing)*5)}.z-\\[2147483646\\]{z-index:2147483646}.z-\\[2147483647\\]{z-index:2147483647}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.ml-0\\.5{margin-left:calc(var(--spacing)*.5)}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-flex{display:inline-flex}.aspect-video{aspect-ratio:var(--aspect-video)}.h-4{height:calc(var(--spacing)*4)}.h-4\\.5{height:calc(var(--spacing)*4.5)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-full{height:100%}.max-h-\\[70vh\\]{max-height:70vh}.max-h-\\[90vh\\]{max-height:90vh}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-20{min-height:calc(var(--spacing)*20)}.min-h-28{min-height:calc(var(--spacing)*28)}.min-h-40{min-height:calc(var(--spacing)*40)}.min-h-\\[600px\\]{min-height:600px}.w-4{width:calc(var(--spacing)*4)}.w-4\\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-12{width:calc(var(--spacing)*12)}.w-full{width:100%}.w-px{width:1px}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-sm{max-width:var(--container-sm)}.min-w-\\[700px\\]{min-width:700px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-\\[bugpin-tooltip-fade-in_0\\.2s_ease-in-out_forwards\\]{animation:.2s ease-in-out forwards bugpin-tooltip-fade-in}.animate-\\[fadeIn_0\\.2s_ease-out\\]{animation:.2s ease-out fadeIn}.animate-\\[slideIn_0\\.3s_ease-out\\]{animation:.3s ease-out slideIn}.animate-\\[slideUp_0\\.2s_ease-out\\]{animation:.2s ease-out slideUp}.animate-\\[spin_0\\.8s_linear_infinite\\]{animation:.8s linear infinite spin}.cursor-pointer{cursor:pointer}.resize-y{resize:vertical}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-md{border-radius:calc(var(--radius) - 4px)}.rounded-sm{border-radius:calc(var(--radius) - 2px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-none{--tw-border-style:none;border-style:none}.border-solid{--tw-border-style:solid;border-style:solid}.border-blue-200{border-color:var(--color-blue-200)}.border-border{border-color:var(--border)}.border-destructive{border-color:var(--destructive)}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-800{border-color:var(--color-gray-800)}.border-green-200{border-color:var(--color-green-200)}.border-input{border-color:var(--input)}.border-primary{border-color:var(--primary)}.border-red-200{border-color:var(--color-red-200)}.border-transparent{border-color:#0000}.border-white\\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-t-white{border-top-color:var(--color-white)}.bg-\\[var\\(--button-color\\)\\]{background-color:var(--button-color)}.bg-background{background-color:var(--background)}.bg-black\\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-border{background-color:var(--border)}.bg-destructive{background-color:var(--destructive)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-green-50{background-color:var(--color-green-50)}.bg-muted{background-color:var(--muted)}.bg-primary,.bg-primary\\/5{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.bg-primary\\/5{background-color:color-mix(in oklab,var(--primary)5%,transparent)}}.bg-primary\\/10{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.bg-primary\\/10{background-color:color-mix(in oklab,var(--primary)10%,transparent)}}.bg-red-50{background-color:var(--color-red-50)}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.object-contain{object-fit:contain}.p-1{padding:calc(var(--spacing)*1)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-8{padding-block:calc(var(--spacing)*8)}.pb-0{padding-bottom:calc(var(--spacing)*0)}.text-center{text-align:center}.font-sans{font-family:var(--font-sans)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-\\[var\\(--button-text-color\\)\\]{color:var(--button-text-color)}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-destructive{color:var(--destructive)}.text-destructive-foreground{color:var(--destructive-foreground)}.text-foreground{color:var(--foreground)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-green-600{color:var(--color-green-600)}.text-muted-foreground{color:var(--muted-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-600{color:var(--color-red-600)}.uppercase{text-transform:uppercase}.no-underline{text-decoration-line:none}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.placeholder\\:text-muted-foreground::placeholder{color:var(--muted-foreground)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-\\[var\\(--button-hover-color\\)\\]:hover{background-color:var(--button-hover-color)}.hover\\:bg-destructive\\/90:hover{background-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-destructive\\/90:hover{background-color:color-mix(in oklab,var(--destructive)90%,transparent)}}.hover\\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\\:bg-gray-200:hover{background-color:var(--color-gray-200)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/5:hover{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-primary\\/5:hover{background-color:color-mix(in oklab,var(--primary)5%,transparent)}}.hover\\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\\:text-\\[var\\(--button-hover-text-color\\)\\]:hover{color:var(--button-hover-text-color)}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-gray-800:hover{color:var(--color-gray-800)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-hover:hover{color:var(--primary-hover)}.hover\\:text-primary-hover-foreground:hover{color:var(--primary-hover-foreground)}.hover\\:text-red-600:hover{color:var(--color-red-600)}.hover\\:underline:hover{text-decoration-line:underline}.hover\\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:border-destructive:focus{border-color:var(--destructive)}.focus\\:border-ring:focus{border-color:var(--ring)}.focus\\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\\:ring-destructive\\/20:focus{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.focus\\:ring-destructive\\/20:focus{--tw-ring-color:color-mix(in oklab,var(--destructive)20%,transparent)}}.focus\\:ring-ring\\/20:focus{--tw-ring-color:var(--ring)}@supports (color:color-mix(in lab,red,red)){.focus\\:ring-ring\\/20:focus{--tw-ring-color:color-mix(in oklab,var(--ring)20%,transparent)}}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\\:ring-ring:focus-visible{--tw-ring-color:var(--ring)}.focus-visible\\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\\:scale-105:active{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}@media (hover:hover){.\\[\\&_span\\]\\:hover\\:text-primary span:hover{color:var(--primary)}}.\\[\\&_svg\\]\\:h-4 svg{height:calc(var(--spacing)*4)}.\\[\\&_svg\\]\\:h-4\\.5 svg{height:calc(var(--spacing)*4.5)}.\\[\\&_svg\\]\\:w-4 svg{width:calc(var(--spacing)*4)}.\\[\\&_svg\\]\\:w-4\\.5 svg{width:calc(var(--spacing)*4.5)}@media (hover:hover){.\\[\\&_svg\\]\\:hover\\:text-primary svg:hover{color:var(--primary)}}}#bugpin-root{--bugpin-primary-50:#e6f3f9;--bugpin-primary-100:#cbe7f2;--bugpin-primary-200:#9ed1e6;--bugpin-primary-300:#6ab8d8;--bugpin-primary-400:#2e9bc6;--bugpin-primary-500:#0e84b1;--bugpin-primary-600:#036f9b;--bugpin-primary-700:#02658d;--bugpin-primary-800:#024f6f;--bugpin-primary-900:#013a52;--bugpin-primary-950:#012738;--background:#fff;--foreground:#0a0a0a;--muted:#f5f5f5;--muted-foreground:#737373;--border:#e5e5e5;--input:#e5e5e5;--ring:#a3a3a3;--destructive:#ef4444;--destructive-foreground:#fafafa;--radius:.5rem;--shadow-sm:0 1px 2px 0 #0000000d;--shadow:0 1px 3px 0 #0000001a,0 1px 2px -1px #0000001a;--shadow-lg:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a;color:var(--foreground);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif;font-size:14px;line-height:1.5}.bugpin-container{--primary:var(--button-color,var(--bugpin-primary-700));--primary-foreground:var(--button-text-color,#fafafa);--primary-hover:var(--button-hover-color,var(--bugpin-primary-800));--primary-hover-foreground:var(--button-hover-text-color,#fafafa)}.bugpin-theme-dark,.bugpin-container.bugpin-theme-dark{--background:#0a0a0a;--foreground:#fafafa;--muted:#262626;--muted-foreground:#a3a3a3;--border:#262626;--input:#262626;--ring:#d4d4d4}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes slideIn{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes spin{to{transform:rotate(360deg)}}@keyframes bugpin-tooltip-fade-in{0%{opacity:0}to{opacity:1}}.priority-lowest{color:#6b7280}.priority-low{color:#3b82f6}.priority-medium{color:#f59e0b}.priority-high{color:#ef4444}.priority-highest{color:#dc2626}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}';Bf();let fc=!1;async function pc(i,t){var e,r,s;try{const n=await fetch(`${t}/api/widget/config/${i}`);if(n.ok){const o=await n.json();if(o.success&&o.config){const a=o.config;return{buttonText:a.buttonText,buttonShape:a.buttonShape,buttonIcon:a.buttonIcon,buttonIconSize:a.buttonIconSize,buttonIconStroke:a.buttonIconStroke,position:a.position,theme:a.theme,lightButtonColor:a.lightButtonColor,lightTextColor:a.lightTextColor,lightButtonHoverColor:a.lightButtonHoverColor,lightTextHoverColor:a.lightTextHoverColor,darkButtonColor:a.darkButtonColor,darkTextColor:a.darkTextColor,darkButtonHoverColor:a.darkButtonHoverColor,darkTextHoverColor:a.darkTextHoverColor,dialogLightButtonColor:a.dialogLightButtonColor,dialogLightTextColor:a.dialogLightTextColor,dialogLightButtonHoverColor:a.dialogLightButtonHoverColor,dialogLightTextHoverColor:a.dialogLightTextHoverColor,dialogDarkButtonColor:a.dialogDarkButtonColor,dialogDarkTextColor:a.dialogDarkTextColor,dialogDarkButtonHoverColor:a.dialogDarkButtonHoverColor,dialogDarkTextHoverColor:a.dialogDarkTextHoverColor,enableHoverScaleEffect:a.enableHoverScaleEffect,tooltipEnabled:a.tooltipEnabled,tooltipText:a.tooltipText,enableScreenshot:((e=a.features)==null?void 0:e.screenshot)??!0,enableAnnotation:((r=a.features)==null?void 0:r.annotation)??!0,enableConsoleCapture:((s=a.features)==null?void 0:s.consoleCapture)??!0,captureMethod:a.captureMethod,useScreenCaptureAPI:a.useScreenCaptureAPI}}}else if(n.status===403&&(await n.json()).error==="PROJECT_PAUSED")return console.info("[BugPin] Widget disabled - project is paused"),null}catch(n){console.warn("[BugPin] Failed to fetch widget config, using defaults",n)}return{}}function Yn(i){if(fc){console.warn("[BugPin] Widget already initialized");return}fc=!0;const t=document.createElement("div");t.id="bugpin-widget",t.setAttribute("data-bugpin-exclude","true");const e=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=Pp,e.appendChild(r);const s=document.createElement("div");s.id="bugpin-root",e.appendChild(s),document.body.appendChild(t),_c(_r(Ep,{config:i}),s)}async function Ap(i){const t=i.getAttribute("data-api-key");if(!t){console.error("[BugPin] Missing data-api-key attribute");return}const e=i.getAttribute("data-server-url")||new URL(i.src).origin,r=await pc(t,e);if(r===null)return;const s={...Xn,...r,apiKey:t,serverUrl:e,...i.getAttribute("data-position")&&{position:i.getAttribute("data-position")},...i.getAttribute("data-button-text")&&{buttonText:i.getAttribute("data-button-text")},...i.getAttribute("data-theme")&&{theme:i.getAttribute("data-theme")}};Yn(s)}const Un={init:async i=>{const t=i.serverUrl||Xn.serverUrl,e=await pc(i.apiKey,t);if(e===null)return;const r={...Xn,...e,...i,serverUrl:t};Yn(r)},open:()=>{document.dispatchEvent(new CustomEvent("bugpin:open"))},close:()=>{document.dispatchEvent(new CustomEvent("bugpin:close"))}};typeof window<"u"&&(window.BugPin=Un);const pi=document.currentScript;if(pi!=null&&pi.hasAttribute("data-api-key")){const i=()=>Ap(pi);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}return br.BugPin=Un,br.createWidget=Yn,br.default=Un,Object.defineProperties(br,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),br}({});
539
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.vibrance;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a),c=(n+o+a)/3,h=2*Math.abs(l-c)/255*r;e[s]+=l!==n?(l-n)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(os,"type","Vibrance"),v(os,"defaults",{vibrance:0}),v(os,"uniformLocations",["uVibrance"]),j.setClass(os);var Tn=Object.freeze({__proto__:null,BaseFilter:yt,BlackWhite:lg,BlendColor:Ur,BlendImage:Gr,Blur:Nr,Brightness:qr,Brownie:rg,ColorMatrix:We,Composed:kn,Contrast:Kr,Convolute:Zr,Gamma:Jr,Grayscale:Qr,HueRotation:si,Invert:ts,Kodachrome:ig,Noise:es,Pixelate:rs,Polaroid:og,RemoveColor:ss,Resize:is,Saturation:ns,Sepia:ag,Technicolor:ng,Vibrance:os,Vintage:sg});ut.ownDefaults.originX="left",ut.ownDefaults.originY="top";const Dl=Symbol.for("bugpin-toObject-patched");if(!ut.prototype[Dl]){const i=ut.prototype.toObject;ut.prototype.toObject=function(t){const e=[...new Set(["data",...t||[]])];return i.call(this,e)},ut.prototype[Dl]=!0}const dg=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000"],gg=[2,4,6,8];let fg=0;function pg(i,t,e){var T,C,S;const r=t,s=++fg;r.data&&(r.data.generationId=s);const n=i.getZoom(),o=((T=i.viewportTransform)==null?void 0:T.slice())||[1,0,0,1,0,0];i.setZoom(1),i.setViewportTransform([1,0,0,1,0,0]),i.renderAll(),t.setCoords();const a=t.getBoundingRect(),l=a.left,c=a.top,h=a.width,u=a.height;if(h<5||u<5){i.setZoom(n),i.setViewportTransform(o),i.renderAll();return}const d=e.getElement(),g=e.scaleX||1,f=e.scaleY||1,y=((C=r.data)==null?void 0:C.blockSize)||Math.max(3,Math.round(Math.min(h,u)/20)),b=document.createElement("canvas");b.width=h,b.height=u;const w=b.getContext("2d");if(w){w.drawImage(d,l/g,c/f,h/g,u/f,0,0,h,u);const D=new St(b);D.filters=[new Tn.Pixelate({blocksize:y})],D.applyFilters();const A=D.getElement();if(((S=r.data)==null?void 0:S.generationId)!==s){i.setZoom(n),i.setViewportTransform(o),i.renderAll();return}t.setElement(A),t.set({scaleX:1,scaleY:1,width:h,height:u}),r.data={type:"pixelate",blockSize:y,generationId:s}}i.setZoom(n),i.setViewportTransform(o),i.renderAll()}const mg=({screenshot:i,onSave:t,onCancel:e})=>{const r=It(null),s=It(null),n=It(null),[o,a]=at("select"),[l,c]=at("#ef4444"),[h,u]=at(4),[d,g]=at(!1),[f,m]=at(!1),[y,b]=at(1),[w,T]=at(!1),C=It([]),S=It(-1),D=It(!1),A=It(!1),_=It(null),M=It(null);Ht(()=>{if(!r.current)return;const k=new vn(r.current,{isDrawingMode:!1,selection:!0});n.current=k,St.fromURL(i).then(B=>{var it;M.current={width:B.width||800,height:B.height||600};const I=(it=s.current)==null?void 0:it.getBoundingClientRect(),H=I?I.width-32:800,dt=I?I.height-32:600,ht=Math.min(H/(B.width||800),dt/(B.height||600));k.setDimensions({width:(B.width||800)*ht,height:(B.height||600)*ht}),B.scaleToWidth(k.width),k.backgroundImage=B,k.renderAll(),O()}),k.freeDrawingBrush=new Ks(k),k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h,k.on("path:created",()=>{O()}),k.on("object:modified",B=>{var H;const I=B.target;((H=I==null?void 0:I.data)==null?void 0:H.type)==="pixelate"&&I instanceof St&&k.backgroundImage&&(pg(k,I,k.backgroundImage),O())});const P=r.current,E=B=>B.preventDefault();return P==null||P.addEventListener("contextmenu",E),()=>{P==null||P.removeEventListener("contextmenu",E),k.dispose()}},[i]),Ht(()=>{if(!n.current)return;const k=n.current;k.freeDrawingBrush&&(k.freeDrawingBrush.color=l,k.freeDrawingBrush.width=h)},[l,h]),Ht(()=>{if(!n.current)return;const k=n.current;k.isDrawingMode=o==="pen",k.selection=o==="select",o==="select"?k.defaultCursor="default":o==="pan"?k.defaultCursor="grab":k.defaultCursor="crosshair",T(o==="pan")},[o]);const O=N(()=>{if(!n.current)return;const k=JSON.stringify(n.current.toJSON());C.current=C.current.slice(0,S.current+1),C.current.push(k),S.current=C.current.length-1,g(S.current>0),m(!1)},[]),V=N(()=>{if(!n.current||S.current<=0)return;S.current--;const k=C.current[S.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(S.current>0),m(S.current<C.current.length-1)})},[]),z=N(()=>{if(!n.current||S.current>=C.current.length-1)return;S.current++;const k=C.current[S.current];n.current.loadFromJSON(JSON.parse(k)).then(()=>{var P;(P=n.current)==null||P.renderAll(),g(S.current>0),m(S.current<C.current.length-1)})},[]),X=N(k=>{var I;if(!n.current||o==="pen"||o==="select"||o==="pan"||k.target||(I=n.current)!=null&&I.findTarget(k.e).target)return;D.current=!0;const P=n.current,E=k.scenePoint;let B=null;switch(o){case"rectangle":B=new Ft({left:E.x,top:E.y,width:0,height:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!1,hasControls:!1,hasBorders:!1});break;case"circle":B=new Jt({left:E.x,top:E.y,rx:0,ry:0,stroke:l,strokeWidth:h,fill:"transparent",selectable:!1,hasControls:!1,hasBorders:!1});break;case"line":B=new Zt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1});break;case"arrow":B=new Zt([E.x,E.y,E.x,E.y],{stroke:l,strokeWidth:h,selectable:!1,hasControls:!1,hasBorders:!1}),B._isArrow=!0;break;case"text":B=new oe("Text",{left:E.x,top:E.y,fontSize:20,fill:l,selectable:!0,editable:!0}),P.add(B),P.setActiveObject(B),B.enterEditing(),D.current=!1;return;case"pixelate":B=new Ft({left:E.x,top:E.y,width:0,height:0,fill:"rgba(128, 128, 128, 0.3)",stroke:"#666",strokeWidth:1,strokeDashArray:[5,5],selectable:!1,hasControls:!1,hasBorders:!1});break}B&&(B._startPoint={x:E.x,y:E.y},P.add(B),P._drawingShape=B)},[o,l,h]),W=N(k=>{if(!n.current||!D.current)return;const P=n.current,E=P._drawingShape;if(!E||!E._startPoint)return;const B=k.scenePoint,I=E._startPoint;if(E instanceof Ft){const H=B.x-I.x,dt=B.y-I.y;E.set({left:H>0?I.x:B.x,top:dt>0?I.y:B.y,width:Math.abs(H),height:Math.abs(dt)})}else if(E instanceof Jt){const H=Math.abs(B.x-I.x)/2,dt=Math.abs(B.y-I.y)/2;E.set({left:Math.min(I.x,B.x),top:Math.min(I.y,B.y),rx:H,ry:dt})}else E instanceof Zt&&E.set({x2:B.x,y2:B.y});P.renderAll()},[]),G=N(async()=>{var k;if(D.current&&n.current){D.current=!1;const P=n.current,E=P._drawingShape;if(E){if(o==="pixelate"&&E instanceof Ft&&P.backgroundImage){const I=E,H=P.getZoom(),dt=((k=P.viewportTransform)==null?void 0:k.slice())||[1,0,0,1,0,0];P.setZoom(1),P.setViewportTransform([1,0,0,1,0,0]),P.renderAll(),I.setCoords();const ht=I.getBoundingRect(),it=ht.left,kt=ht.top,F=ht.width,J=ht.height;if(F>5&&J>5){const et=P.backgroundImage,xt=et.getElement(),ot=et.scaleX||1,ae=et.scaleY||1,te=document.createElement("canvas");te.width=F,te.height=J;const xe=te.getContext("2d");if(xe){xe.drawImage(xt,it/ot,kt/ae,F/ot,J/ae,0,0,F,J);const yr=Math.max(3,Math.round(Math.min(F,J)/20)),Ae=new St(te,{left:it,top:kt,selectable:!0,hasControls:!0,hasBorders:!0});Ae.data={type:"pixelate",blockSize:yr},Ae.filters=[new Tn.Pixelate({blocksize:yr})],Ae.applyFilters(),P.remove(I),P.add(Ae)}}else P.remove(I);P.setZoom(H),P.setViewportTransform(dt),P.renderAll()}else if(E._isArrow&&E instanceof Zt){const I=E,H=I.x1||0,dt=I.y1||0,ht=I.x2||0,it=I.y2||0,kt=ht-H,F=it-dt,J=Math.sqrt(kt*kt+F*F);if(J>10){const et=Math.atan2(F,kt),xt=I.strokeWidth||2,ot=Math.max(xt*5,Math.min(xt*7,J/3)),ae=ot*.35,te=ht-ot*Math.cos(et),xe=it-ot*Math.sin(et),yr=te-ae*Math.cos(et-Math.PI/2),Ae=xe-ae*Math.sin(et-Math.PI/2),le=te-ae*Math.cos(et+Math.PI/2),cs=xe-ae*Math.sin(et+Math.PI/2);I.set({x2:te,y2:xe});const hs=new Yr([{x:ht,y:it},{x:yr,y:Ae},{x:le,y:cs}],{fill:I.stroke,stroke:I.stroke,strokeWidth:1,selectable:!1}),br=new De([I,hs],{selectable:!0,hasControls:!0,hasBorders:!0});P.remove(I),P.add(br)}else E.set({selectable:!0,hasControls:!0,hasBorders:!0})}else E.set({selectable:!0,hasControls:!0,hasBorders:!0});P._drawingShape=void 0}O()}},[O,o]);Ht(()=>{if(!n.current)return;const k=n.current;return k.on("mouse:down",X),k.on("mouse:move",W),k.on("mouse:up",G),()=>{k.off("mouse:down",X),k.off("mouse:move",W),k.off("mouse:up",G)}},[X,W,G]);const K=N(()=>{var kt;if(!n.current)return;const k=n.current,P=k.getZoom(),E=((kt=k.viewportTransform)==null?void 0:kt.slice())||[1,0,0,1,0,0];k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll();const B=M.current,I=B?B.width/(k.width||1):1,H=[];if(k.backgroundImage&&I>1){const F=k.backgroundImage,J=F.getElement(),et=F.scaleX||1,xt=F.scaleY||1;k.getObjects().forEach(ot=>{var te,xe;const ae=ot;if(((te=ae.data)==null?void 0:te.type)==="pixelate"&&ot instanceof St){const yr=ot.getElement(),Ae={width:ot.width||0,height:ot.height||0,scaleX:ot.scaleX||1,scaleY:ot.scaleY||1,left:ot.left||0,top:ot.top||0,angle:ot.angle||0,skewX:ot.skewX||0,skewY:ot.skewY||0,flipX:ot.flipX||!1,flipY:ot.flipY||!1};H.push({obj:ot,originalElement:yr,originalState:Ae}),ot.setCoords();const le=ot.getBoundingRect(),cs=le.width*I,hs=le.height*I,br=document.createElement("canvas");br.width=cs,br.height=hs;const uc=br.getContext("2d");if(uc){uc.drawImage(J,le.left/et,le.top/xt,le.width/et,le.height/xt,0,0,cs,hs);const gp=((xe=ae.data)==null?void 0:xe.blockSize)||Math.max(3,Math.round(Math.min(le.width,le.height)/20)),fp=Math.round(gp*I),Nn=new St(br);Nn.filters=[new Tn.Pixelate({blocksize:fp})],Nn.applyFilters(),ot.setElement(Nn.getElement()),ot.set({width:cs,height:hs,scaleX:1/I,scaleY:1/I})}}}),k.renderAll()}const dt=k.toDataURL({format:"png",quality:1,multiplier:I});H.forEach(({obj:F,originalElement:J,originalState:et})=>{F.setElement(J),F.set(et)}),k.setZoom(P),k.setViewportTransform(E),k.renderAll();const it=k.getObjects().map(F=>F.toObject());t(dt,{objects:it})},[t]),Z=N(()=>{if(!n.current)return;const k=n.current,P=k.getActiveObjects();P.length>0&&(P.forEach(E=>k.remove(E)),k.discardActiveObject(),k.renderAll(),O())},[O]),L=N(()=>{if(!n.current)return;const k=n.current,P=Math.min(y*1.2,3),E=new x(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[y]),wt=N(()=>{if(!n.current)return;const k=n.current,P=Math.max(y/1.2,.5),E=new x(k.width/2,k.height/2);k.zoomToPoint(E,P),b(P)},[y]),mt=N(()=>{if(!n.current)return;const k=n.current;b(1),k.setZoom(1),k.setViewportTransform([1,0,0,1,0,0]),k.renderAll()},[]);Ht(()=>{if(!n.current)return;const k=n.current,P=I=>{const H=I.e;(H.buttons===2||H.buttons===1&&w||H.buttons===1&&o==="pan")&&(H.preventDefault(),A.current=!0,k.selection=!1,_.current={x:H.clientX,y:H.clientY},k.setCursor("grabbing"))},E=I=>{if(A.current&&_.current){const H=I.e,dt=k.viewportTransform;dt[4]+=H.clientX-_.current.x,dt[5]+=H.clientY-_.current.y,k.requestRenderAll(),_.current={x:H.clientX,y:H.clientY}}},B=()=>{A.current&&(A.current=!1,_.current=null,k.setCursor(w||o==="pan"?"grab":"default"),k.selection=o==="select")};return k.on("mouse:down",P),k.on("mouse:move",E),k.on("mouse:up",B),()=>{k.off("mouse:down",P),k.off("mouse:move",E),k.off("mouse:up",B)}},[w,o]),Ht(()=>{const k=E=>{if(E.key===" "&&!w&&(E.preventDefault(),T(!0),n.current&&n.current.setCursor("grab")),E.key==="Delete"||E.key==="Backspace"){const B=document.activeElement;(B==null?void 0:B.tagName)!=="INPUT"&&(B==null?void 0:B.tagName)!=="TEXTAREA"&&Z()}(E.ctrlKey||E.metaKey)&&E.key==="z"&&(E.preventDefault(),E.shiftKey?z():V())},P=E=>{E.key===" "&&w&&(T(!1),n.current&&n.current.setCursor(o==="pan"?"grab":"default"))};return window.addEventListener("keydown",k),window.addEventListener("keyup",P),()=>{window.removeEventListener("keydown",k),window.removeEventListener("keyup",P)}},[Z,V,z,w,o]);const lt=({tool:k,icon:P,label:E})=>p("button",{class:Bt("flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors","hover:bg-gray-100 hover:text-gray-800","[&_svg]:w-4.5 [&_svg]:h-4.5",o===k&&"bg-primary/10 text-primary"),onClick:()=>a(k),title:E,children:p("span",{dangerouslySetInnerHTML:{__html:P}})});return p("div",{class:"flex flex-col",children:[p("div",{class:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-solid border-border bg-muted",children:[p("div",{class:"flex items-center gap-1",children:[p(lt,{tool:"select",label:"Select",icon:'<svg viewBox="0 0 24 24"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z" fill="currentColor"/></svg>'}),p(lt,{tool:"pan",label:"Pan (or hold Space)",icon:'<svg viewBox="0 0 24 24"><path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z" fill="currentColor"/></svg>'}),p(lt,{tool:"pen",label:"Pen",icon:'<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="currentColor"/></svg>'}),p(lt,{tool:"line",label:"Line",icon:'<svg viewBox="0 0 24 24"><line x1="5" y1="19" x2="19" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'}),p(lt,{tool:"arrow",label:"Arrow",icon:'<svg viewBox="0 0 24 24"><line x1="5" y1="19" x2="19" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M19 5l-6 2 4 4 2-6z" fill="currentColor"/></svg>'}),p(lt,{tool:"rectangle",label:"Rectangle",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),p(lt,{tool:"circle",label:"Circle",icon:'<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/></svg>'}),p(lt,{tool:"text",label:"Text",icon:'<svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4H5z" fill="currentColor"/></svg>'}),p(lt,{tool:"pixelate",label:"Pixelate",icon:'<svg viewBox="0 0 24 24"><rect x="3" y="3" width="4" height="4" fill="currentColor"/><rect x="10" y="3" width="4" height="4" fill="currentColor"/><rect x="17" y="3" width="4" height="4" fill="currentColor"/><rect x="3" y="10" width="4" height="4" fill="currentColor"/><rect x="10" y="10" width="4" height="4" fill="currentColor"/><rect x="17" y="10" width="4" height="4" fill="currentColor"/><rect x="3" y="17" width="4" height="4" fill="currentColor"/><rect x="10" y="17" width="4" height="4" fill="currentColor"/><rect x="17" y="17" width="4" height="4" fill="currentColor"/></svg>'})]}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:dg.map(k=>p("button",{class:Bt("w-6 h-6 rounded-full border-2 border-solid cursor-pointer transition-transform hover:scale-110",l===k?"border-gray-800 scale-110":"border-transparent"),style:{backgroundColor:k},onClick:()=>c(k),title:k},k))}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:gg.map(k=>p("button",{class:Bt("flex items-center justify-center w-8 h-8 border-none rounded bg-transparent cursor-pointer transition-colors","hover:bg-gray-100",h===k&&"bg-primary/10"),onClick:()=>u(k),title:`${k}px`,children:p("span",{class:"w-5 bg-gray-800 rounded-full",style:{height:`${k}px`}})},k))}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:[p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:V,disabled:!d,title:"Undo (Ctrl+Z)",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:z,disabled:!f,title:"Redo (Ctrl+Shift+Z)",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:Z,title:"Delete selected (Del)",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",fill:"currentColor"})})})]}),p("div",{class:"w-px h-6 bg-border"}),p("div",{class:"flex items-center gap-1",children:[p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:wt,disabled:y<=.5,title:"Zoom Out - Hold Space to pan when zoomed",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:mt,title:`Reset Zoom (${Math.round(y*100)}%) - Hold Space to pan`,children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z",fill:"currentColor"})})}),p("button",{class:"flex items-center justify-center w-8 h-8 border-none rounded bg-transparent text-gray-600 cursor-pointer transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:w-4.5 [&_svg]:h-4.5",onClick:L,disabled:y>=3,title:"Zoom In - Hold Space to pan when zoomed",children:p("svg",{viewBox:"0 0 24 24",children:p("path",{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z",fill:"currentColor"})})})]})]}),p("div",{class:"min-h-[600px] min-w-[700px] max-h-[70vh] overflow-auto flex items-center justify-center p-4 bg-gray-800",ref:s,children:p("canvas",{ref:r})}),p("div",{class:"flex gap-3 p-4 border-t border-solid border-border bg-muted",children:[p(ee,{variant:"outline",class:"flex-1",onClick:e,children:"Cancel"}),p(ee,{class:"flex-1",onClick:K,children:"Done"})]})]})};function vg(i,t){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),s=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(s),t&&(r.href=t),s.href=i,s.href}const yg=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function Pe(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let dr=null;function Ml(i={}){return dr||(i.includeStyleProperties?(dr=i.includeStyleProperties,dr):(dr=Pe(window.getComputedStyle(document.documentElement)),dr))}function ii(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function bg(i){const t=ii(i,"border-left-width"),e=ii(i,"border-right-width");return i.clientWidth+t+e}function wg(i){const t=ii(i,"border-top-width"),e=ii(i,"border-bottom-width");return i.clientHeight+t+e}function El(i,t={}){const e=t.width||bg(i),r=t.height||wg(i);return{width:e,height:r}}function xg(){let i,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(i=parseInt(e,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}const zt=16384;function _g(i){(i.width>zt||i.height>zt)&&(i.width>zt&&i.height>zt?i.width>i.height?(i.height*=zt/i.width,i.width=zt):(i.width*=zt/i.height,i.height=zt):i.width>zt?(i.height*=zt/i.width,i.width=zt):(i.width*=zt/i.height,i.height=zt))}function ni(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=i})}async function Cg(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Sg(i,t,e){const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),n=document.createElementNS(r,"foreignObject");return s.setAttribute("width",`${t}`),s.setAttribute("height",`${e}`),s.setAttribute("viewBox",`0 0 ${t} ${e}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),s.appendChild(n),n.appendChild(i),Cg(s)}const jt=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||jt(e,t)};function kg(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function Tg(i,t){return Ml(t).map(e=>{const r=i.getPropertyValue(e),s=i.getPropertyPriority(e);return`${e}: ${r}${s?" !important":""};`}).join(" ")}function Og(i,t,e,r){const s=`.${i}:${t}`,n=e.cssText?kg(e):Tg(e,r);return document.createTextNode(`${s}{${n}}`)}function Pl(i,t,e,r){const s=window.getComputedStyle(i,e),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=yg();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(Og(o,e,s,r)),t.appendChild(a)}function Dg(i,t,e){Pl(i,t,":before",e),Pl(i,t,":after",e)}const Al="application/font-woff",Ll="image/jpeg",Mg={woff:Al,woff2:Al,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Ll,jpeg:Ll,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Eg(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function On(i){const t=Eg(i).toLowerCase();return Mg[t]||""}function Pg(i){return i.split(/,/)[1]}function Dn(i){return i.search(/^(data:)/)!==-1}function Ag(i,t){return`data:${t};base64,${i}`}async function Fl(i,t,e){const r=await fetch(i,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const s=await r.blob();return new Promise((n,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{n(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(s)})}const Mn={};function Lg(i,t,e){let r=i.replace(/\?.*/,"");return e&&(r=i),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function En(i,t,e){const r=Lg(i,t,e.includeQueryParams);if(Mn[r]!=null)return Mn[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let s;try{const n=await Fl(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),Pg(a)));s=Ag(n,t)}catch(n){s=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;n&&(o=typeof n=="string"?n:n.message),o&&console.warn(o)}return Mn[r]=s,s}async function Fg(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):ni(t)}async function jg(i,t){if(i.currentSrc){const n=document.createElement("canvas"),o=n.getContext("2d");n.width=i.clientWidth,n.height=i.clientHeight,o==null||o.drawImage(i,0,0,n.width,n.height);const a=n.toDataURL();return ni(a)}const e=i.poster,r=On(e),s=await En(e,r,t);return ni(s)}async function Ig(i,t){var e;try{if(!((e=i==null?void 0:i.contentDocument)===null||e===void 0)&&e.body)return await oi(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function Bg(i,t){return jt(i,HTMLCanvasElement)?Fg(i):jt(i,HTMLVideoElement)?jg(i,t):jt(i,HTMLIFrameElement)?Ig(i,t):i.cloneNode(jl(i))}const Rg=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",jl=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function $g(i,t,e){var r,s;if(jl(t))return t;let n=[];return Rg(i)&&i.assignedNodes?n=Pe(i.assignedNodes()):jt(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?n=Pe(i.contentDocument.body.childNodes):n=Pe(((s=i.shadowRoot)!==null&&s!==void 0?s:i).childNodes),n.length===0||jt(i,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>oi(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function zg(i,t,e){const r=t.style;if(!r)return;const s=window.getComputedStyle(i);s.cssText?(r.cssText=s.cssText,r.transformOrigin=s.transformOrigin):Ml(e).forEach(n=>{let o=s.getPropertyValue(n);n==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),jt(i,HTMLIFrameElement)&&n==="display"&&o==="inline"&&(o="block"),n==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(n,o,s.getPropertyPriority(n))})}function Hg(i,t){jt(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),jt(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function Vg(i,t){if(jt(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(s=>i.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function Wg(i,t,e){return jt(t,Element)&&(zg(i,t,e),Dg(i,t,e),Hg(i,t),Vg(i,t)),t}async function Xg(i,t){const e=i.querySelectorAll?i.querySelectorAll("use"):[];if(e.length===0)return i;const r={};for(let n=0;n<e.length;n++){const a=e[n].getAttribute("xlink:href");if(a){const l=i.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await oi(c,t,!0))}}const s=Object.values(r);if(s.length){const n="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg");o.setAttribute("xmlns",n),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(n,"defs");o.appendChild(a);for(let l=0;l<s.length;l++)a.appendChild(s[l]);i.appendChild(o)}return i}async function oi(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>Bg(r,t)).then(r=>$g(i,r,t)).then(r=>Wg(i,r,t)).then(r=>Xg(r,t))}const Il=/url\((['"]?)([^'"]+?)\1\)/g,Yg=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ug=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Gg(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Ng(i){const t=[];return i.replace(Il,(e,r,s)=>(t.push(s),e)),t.filter(e=>!Dn(e))}async function qg(i,t,e,r,s){try{const n=e?vg(t,e):t,o=On(t);let a;return s||(a=await En(n,o,r)),i.replace(Gg(t),`$1${a}$3`)}catch{}return i}function Kg(i,{preferredFontFormat:t}){return t?i.replace(Ug,e=>{for(;;){const[r,,s]=Yg.exec(e)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):i}function Bl(i){return i.search(Il)!==-1}async function Rl(i,t,e){if(!Bl(i))return i;const r=Kg(i,e);return Ng(r).reduce((n,o)=>n.then(a=>qg(a,o,t,e)),Promise.resolve(r))}async function gr(i,t,e){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(s){const n=await Rl(s,null,e);return t.style.setProperty(i,n,t.style.getPropertyPriority(i)),!0}return!1}async function Zg(i,t){await gr("background",i,t)||await gr("background-image",i,t),await gr("mask",i,t)||await gr("-webkit-mask",i,t)||await gr("mask-image",i,t)||await gr("-webkit-mask-image",i,t)}async function Jg(i,t){const e=jt(i,HTMLImageElement);if(!(e&&!Dn(i.src))&&!(jt(i,SVGImageElement)&&!Dn(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,s=await En(r,On(r),t);await new Promise((n,o)=>{i.onload=n,i.onerror=t.onImageErrorHandler?(...l)=>{try{n(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=i;a.decode&&(a.decode=n),a.loading==="lazy"&&(a.loading="eager"),e?(i.srcset="",i.src=s):i.href.baseVal=s})}async function Qg(i,t){const r=Pe(i.childNodes).map(s=>$l(s,t));await Promise.all(r).then(()=>i)}async function $l(i,t){jt(i,Element)&&(await Zg(i,t),await Jg(i,t),await Qg(i,t))}function tf(i,t){const{style:e}=i;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(s=>{e[s]=r[s]}),i}const zl={};async function Hl(i){let t=zl[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},zl[i]=t,t}async function Vl(i,t){let e=i.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,n=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),Fl(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>e)}function Wl(i){if(i==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=i.replace(e,"");const s=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=s.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(s,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=n.exec(r);if(l===null){if(l=a.exec(r),l===null)break;n.lastIndex=a.lastIndex}else a.lastIndex=n.lastIndex;t.push(l[0])}return t}async function ef(i,t){const e=[],r=[];return i.forEach(s=>{if("cssRules"in s)try{Pe(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=Hl(l).then(h=>Vl(h,t)).then(h=>Wl(h).forEach(u=>{try{s.insertRule(u,u.startsWith("@import")?a+=1:s.cssRules.length)}catch(d){console.error("Error inserting rule from remote css",{rule:u,error:d})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(n){const o=i.find(a=>a.href==null)||document.styleSheets[0];s.href!=null&&r.push(Hl(s.href).then(a=>Vl(a,t)).then(a=>Wl(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",n)}}),Promise.all(r).then(()=>(i.forEach(s=>{if("cssRules"in s)try{Pe(s.cssRules||[]).forEach(n=>{e.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),e))}function rf(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Bl(t.style.getPropertyValue("src")))}async function sf(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=Pe(i.ownerDocument.styleSheets),r=await ef(e,t);return rf(r)}function Xl(i){return i.trim().replace(/["']/g,"")}function nf(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(Xl(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&e(n)})}return e(i),t}async function of(i,t){const e=await sf(i,t),r=nf(i);return(await Promise.all(e.filter(n=>r.has(Xl(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return Rl(n.cssText,o,t)}))).join(`
540
+ `)}async function af(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await of(i,t);if(e){const r=document.createElement("style"),s=document.createTextNode(e);r.appendChild(s),i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r)}}async function lf(i,t={}){const{width:e,height:r}=El(i,t),s=await oi(i,t,!0);return await af(s,t),await $l(s,t),tf(s,t),await Sg(s,e,r)}async function Pn(i,t={}){const{width:e,height:r}=El(i,t),s=await lf(i,t),n=await ni(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||xg(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||_g(o),o.style.width=`${c}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(n,0,0,o.width,o.height),o}const cf=2,fr=16384,ai=4e7,Yl="data-bugpin-exclude";async function hf(){document.fonts&&document.fonts.ready&&await document.fonts.ready}async function uf(i){const t=i.querySelectorAll("img"),e=[];t.forEach(r=>{r.complete?r.decode&&e.push(r.decode().catch(()=>{})):e.push(new Promise(s=>{const n=async()=>{if(r.removeEventListener("load",n),r.removeEventListener("error",o),r.decode)try{await r.decode()}catch{}s()},o=()=>{r.removeEventListener("load",n),r.removeEventListener("error",o),s()};r.addEventListener("load",n,{once:!0}),r.addEventListener("error",o,{once:!0})}))}),e.length>0&&await Promise.all(e)}function An(i,t,e="visible"){const r=Math.ceil(i),s=Math.ceil(t);if(r>fr||s>fr)throw e==="fullpage"?new Error(`Full page dimensions (${r}x${s}) exceed maximum canvas size (${fr}px). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot dimensions (${r}x${s}) exceed maximum canvas size (${fr}px). Try capturing a smaller element or use visible viewport mode.`);if(r*s>ai)throw e==="fullpage"?new Error(`Full page total pixels (${r*s}) exceed maximum (${ai}). This page is too large for full page capture. Use visible viewport mode instead.`):new Error(`Screenshot total pixels (${r*s}) exceed maximum (${ai}). Try capturing a smaller element or use visible viewport mode.`);let n=Math.min(window.devicePixelRatio||1,cf),o=r*n,a=s*n,l=o*a;for(;n>1&&(o>fr||a>fr||l>ai);)n-=.5,o=r*n,a=s*n,l=o*a;return Math.max(1,n)}function Ln(i){return!(i instanceof HTMLElement&&(i.tagName==="SCRIPT"||i.hasAttribute(Yl)))}function df(){if(window.scrollY>0||window.scrollX>0)return null;const i=document.querySelectorAll("*");for(const t of i){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t),r=e.overflowY,s=e.overflowX;if(r==="auto"||r==="scroll"||s==="auto"||s==="scroll"){const o=t.scrollHeight>t.clientHeight&&t.scrollTop>0,a=t.scrollWidth>t.clientWidth&&t.scrollLeft>0;if(o||a)return t}}return null}function Fn(){const i=window.getComputedStyle(document.body).backgroundColor,t=window.getComputedStyle(document.documentElement).backgroundColor,e=r=>!r||r==="transparent"||r==="rgba(0, 0, 0, 0)";return e(i)?e(t)?"#ffffff":t:i}const gf="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQI12NgAAIABQABNjN9GQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAA0lEQVQI12P4z8BQDwAEgAF/QualzQAAAABJRU5ErkJggg==";function ff(){try{for(const i of document.styleSheets)if(i.href)try{i.cssRules}catch{return!0}}catch{return!0}return!1}function jn(){const i=ff();return i&&console.log("[BugPin] Cross-origin stylesheets detected, skipping font embedding"),{skipFonts:i,imagePlaceholder:gf,onImageErrorHandler:()=>{}}}function pf(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}async function mf(){if(!pf())throw new Error("Screen Capture API is not available. The host page must be served over HTTPS and include the header: Permissions-Policy: display-capture=self");const i=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0});try{const t=document.createElement("video");t.srcObject=i,t.autoplay=!0,await new Promise(s=>{t.onloadedmetadata=()=>s()}),await new Promise(s=>setTimeout(s,100));const e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight;const r=e.getContext("2d");if(!r)throw new Error("Failed to get canvas context");return r.drawImage(t,0,0),e.toDataURL("image/png")}finally{i.getTracks().forEach(t=>t.stop())}}async function vf(i={}){const{method:t="visible",selector:e,useScreenCaptureAPI:r=!1,cacheBust:s}=i;if(r)try{return await mf()}catch(g){console.warn("[BugPin] Screen Capture API unavailable, falling back to DOM capture.","Ensure the page is served over HTTPS and the browser has screen recording permission.",`(${g instanceof Error?g.message:g})`)}let n;switch(t){case"element":if(!e)throw new Error("Selector required for element capture");const g=document.querySelector(e);if(!g||!(g instanceof HTMLElement))throw new Error(`Element not found: ${e}`);n=g;break;case"fullpage":case"visible":default:n=document.documentElement;break}const o=df();let a,l,c,h;o&&o!==document.documentElement&&o!==document.body?(a=o.scrollLeft,l=o.scrollTop,c=o.clientWidth,h=o.clientHeight,t==="visible"&&(n=o)):(a=window.scrollX||window.pageXOffset||0,l=window.scrollY||window.pageYOffset||0,c=document.documentElement.clientWidth,h=document.documentElement.clientHeight);const u=document.querySelectorAll(`[${Yl}]`),d=new Map;u.forEach(g=>{g instanceof HTMLElement&&(d.set(g,g.style.visibility),g.style.visibility="hidden")});try{if(await hf(),await uf(n),t==="visible"){const w=An(c,h,"visible"),T=Fn(),C=a+c,S=l+h;console.log("[BugPin] Capture debug:",{scrollX:a,scrollY:l,viewportWidth:c,viewportHeight:h,captureWidth:C,captureHeight:S,dpr:w});const D={...jn(),cacheBust:s??!1,pixelRatio:w,width:C,height:S,backgroundColor:T,filter:Ln},A=await Pn(n,D);console.log("[BugPin] Canvas captured:",{canvasWidth:A.width,canvasHeight:A.height,expectedWidth:C*w,expectedHeight:S*w});const _=document.createElement("canvas");_.width=c*w,_.height=h*w;const M=_.getContext("2d");if(!M)throw new Error("Failed to get canvas context");return M.fillStyle=T,M.fillRect(0,0,_.width,_.height),M.drawImage(A,a*w,l*w,c*w,h*w,0,0,c*w,h*w),_.toDataURL("image/png")}if(t==="fullpage"){const w=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth),T=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight),C=An(w,T,"fullpage"),S=Fn(),D={...jn(),cacheBust:s??!0,pixelRatio:C,width:w,height:T,backgroundColor:S,filter:Ln};return(await Pn(n,D)).toDataURL("image/png")}const g=n.getBoundingClientRect(),f=An(g.width,g.height,"element"),m=Fn(),y={...jn(),cacheBust:s??!1,pixelRatio:f,backgroundColor:m,filter:Ln};return(await Pn(n,y)).toDataURL("image/png")}finally{u.forEach(g=>{g instanceof HTMLElement&&(g.style.visibility=d.get(g)||"")})}}function Ul(i){const t=i.split(","),e=t[0].match(/:(.*?);/),r=e?e[1]:"image/png",s=atob(t[1]),n=new Uint8Array(s.length);for(let o=0;o<s.length;o++)n[o]=s.charCodeAt(o);return new Blob([n],{type:r})}function Gl(i){return i.startsWith("data:image/webp")?"webp":i.startsWith("data:image/jpeg")?"jpg":i.startsWith("data:image/gif")?"gif":"png"}const pr=[],as=[],ls=[],yf=30;let Nl=!1;function bf(){if(Nl)return;Nl=!0;const i=console.error;console.error=(...o)=>{pr.push({type:"error",message:o.map(a=>String(a)).join(" "),timestamp:new Date().toISOString()}),i.apply(console,o)};const t=console.warn;console.warn=(...o)=>{pr.push({type:"warn",message:o.map(a=>String(a)).join(" "),timestamp:new Date().toISOString()}),t.apply(console,o)};const e=window.onerror;window.onerror=(o,a,l,c,h)=>(pr.push({type:"error",message:String(o),source:a||void 0,line:l||void 0,timestamp:new Date().toISOString()}),e?e.apply(window,[o,a,l,c,h]):!1),window.addEventListener("unhandledrejection",o=>{pr.push({type:"error",message:`Unhandled Promise Rejection: ${String(o.reason)}`,timestamp:new Date().toISOString()})});const r=window.fetch.bind(window);window.fetch=async function(o,a){const l=typeof o=="string"?o:o instanceof URL?o.href:o.url,c=(a==null?void 0:a.method)||"GET";try{const h=await r(o,a);return h.status>=300&&as.push({url:l,method:c,status:h.status,statusText:h.statusText,timestamp:new Date().toISOString()}),h}catch(h){throw as.push({url:l,method:c,status:0,statusText:h instanceof Error?h.message:"Network Error",timestamp:new Date().toISOString()}),h}};const s=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(o,a){return this._bugpinMethod=o,this._bugpinUrl=typeof a=="string"?a:a.href,s.apply(this,arguments)},XMLHttpRequest.prototype.send=function(){return this.addEventListener("load",function(){this.status>=300&&as.push({url:this._bugpinUrl||"",method:this._bugpinMethod||"GET",status:this.status,statusText:this.statusText,timestamp:new Date().toISOString()})}),n.apply(this,arguments)},document.addEventListener("click",o=>{var c,h,u,d;const a=o.target;if(!a||a.closest("[data-bugpin-exclude]"))return;let l=null;if(a.tagName==="BUTTON"||a.closest("button"))l={type:"button",text:((c=(a.tagName==="BUTTON"?a:a.closest("button")).textContent)==null?void 0:c.trim().slice(0,50))||void 0,timestamp:new Date().toISOString()};else if(a.tagName==="A"||a.closest("a")){const g=a.tagName==="A"?a:a.closest("a");l={type:"link",text:((h=g.textContent)==null?void 0:h.trim().slice(0,50))||void 0,url:g.href||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="INPUT"&&a.type==="checkbox"){const g=a;l={type:"checkbox",text:g.name||g.id||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="INPUT"){const g=a;l={type:"input",inputType:g.type||"text",text:g.name||((u=g.placeholder)==null?void 0:u.slice(0,30))||void 0,timestamp:new Date().toISOString()}}else if(a.tagName==="SELECT"||a.closest('[role="combobox"]')){const g=a.tagName==="SELECT"?a:null;l={type:"select",text:(g==null?void 0:g.name)||void 0,timestamp:new Date().toISOString()}}else(a.onclick||a.getAttribute("role")==="button"||a.classList.contains("btn")||a.closest('[role="button"]'))&&(l={type:"other",text:((d=a.textContent)==null?void 0:d.trim().slice(0,50))||void 0,timestamp:new Date().toISOString()});l&&wf(l)},!0)}function wf(i){ls.push(i),ls.length>yf&&ls.shift()}function xf(){var r,s,n,o,a;const i=navigator.userAgent;let t="Unknown",e="";return i.includes("Firefox/")?(t="Firefox",e=((r=i.match(/Firefox\/([\d.]+)/))==null?void 0:r[1])||""):i.includes("Edg/")?(t="Edge",e=((s=i.match(/Edg\/([\d.]+)/))==null?void 0:s[1])||""):i.includes("Chrome/")?(t="Chrome",e=((n=i.match(/Chrome\/([\d.]+)/))==null?void 0:n[1])||""):i.includes("Safari/")&&!i.includes("Chrome")?(t="Safari",e=((o=i.match(/Version\/([\d.]+)/))==null?void 0:o[1])||""):(i.includes("Opera/")||i.includes("OPR/"))&&(t="Opera",e=((a=i.match(/(?:Opera|OPR)\/([\d.]+)/))==null?void 0:a[1])||""),{name:t,version:e,userAgent:i}}function _f(){var s,n,o,a,l;const i=navigator.userAgent;let t="desktop",e="Unknown",r;if(/Mobi|Android|iPhone|iPad|iPod/i.test(i)&&(/iPad|Tablet/i.test(i)||window.innerWidth>=768&&/Android/i.test(i)?t="tablet":t="mobile"),i.includes("Windows")){e="Windows";const c=i.match(/Windows NT ([\d.]+)/);if(c){const h=c[1];r={"10.0":"10/11","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista"}[h]||h}}else i.includes("Mac OS X")?(e="macOS",r=(n=(s=i.match(/Mac OS X ([\d._]+)/))==null?void 0:s[1])==null?void 0:n.replace(/_/g,".")):i.includes("Linux")?(e=i.includes("Android")?"Android":"Linux",e==="Android"&&(r=(o=i.match(/Android ([\d.]+)/))==null?void 0:o[1])):(i.includes("iPhone")||i.includes("iPad"))&&(e="iOS",r=(l=(a=i.match(/OS ([\d_]+)/))==null?void 0:a[1])==null?void 0:l.replace(/_/g,"."));return{type:t,os:e,osVersion:r}}function Cf(){return{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}function Sf(){const i={cookies:[],localStorage:[],sessionStorage:[]};try{const t=document.cookie;t&&(i.cookies=t.split(";").map(e=>e.split("=")[0].trim()))}catch{}try{for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e&&i.localStorage.push(e)}}catch{}try{for(let t=0;t<sessionStorage.length;t++){const e=sessionStorage.key(t);e&&i.sessionStorage.push(e)}}catch{}return i}function kf(){try{const i=performance.getEntriesByType("navigation");if(i.length>0){const t=i[0];return Math.round(t.loadEventEnd-t.startTime)}}catch{}}function Tf(){return{url:window.location.href,title:document.title||void 0,referrer:document.referrer||void 0,browser:xf(),device:_f(),viewport:Cf(),timestamp:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,pageLoadTime:kf(),consoleErrors:pr.length>0?[...pr]:void 0,networkErrors:as.length>0?[...as]:void 0,userActivity:ls.length>0?[...ls]:void 0,storageKeys:Sf()}}const In=(i,t)=>t.some(e=>i instanceof e);let ql,Kl;function Of(){return ql||(ql=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Df(){return Kl||(Kl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Bn=new WeakMap,Rn=new WeakMap,li=new WeakMap;function Mf(i){const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("success",n),i.removeEventListener("error",o)},n=()=>{e(Ye(i.result)),s()},o=()=>{r(i.error),s()};i.addEventListener("success",n),i.addEventListener("error",o)});return li.set(t,i),t}function Ef(i){if(Bn.has(i))return;const t=new Promise((e,r)=>{const s=()=>{i.removeEventListener("complete",n),i.removeEventListener("error",o),i.removeEventListener("abort",o)},n=()=>{e(),s()},o=()=>{r(i.error||new DOMException("AbortError","AbortError")),s()};i.addEventListener("complete",n),i.addEventListener("error",o),i.addEventListener("abort",o)});Bn.set(i,t)}let $n={get(i,t,e){if(i instanceof IDBTransaction){if(t==="done")return Bn.get(i);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Ye(i[t])},set(i,t,e){return i[t]=e,!0},has(i,t){return i instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in i}};function Zl(i){$n=i($n)}function Pf(i){return Df().includes(i)?function(...t){return i.apply(zn(this),t),Ye(this.request)}:function(...t){return Ye(i.apply(zn(this),t))}}function Af(i){return typeof i=="function"?Pf(i):(i instanceof IDBTransaction&&Ef(i),In(i,Of())?new Proxy(i,$n):i)}function Ye(i){if(i instanceof IDBRequest)return Mf(i);if(Rn.has(i))return Rn.get(i);const t=Af(i);return t!==i&&(Rn.set(i,t),li.set(t,i)),t}const zn=i=>li.get(i);function Jl(i,t,{blocked:e,upgrade:r,blocking:s,terminated:n}={}){const o=indexedDB.open(i,t),a=Ye(o);return r&&o.addEventListener("upgradeneeded",l=>{r(Ye(o.result),l.oldVersion,l.newVersion,Ye(o.transaction),l)}),e&&o.addEventListener("blocked",l=>e(l.oldVersion,l.newVersion,l)),a.then(l=>{n&&l.addEventListener("close",()=>n()),s&&l.addEventListener("versionchange",c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const Lf=["get","getKey","getAll","getAllKeys","count"],Ff=["put","add","delete","clear"],Hn=new Map;function Ql(i,t){if(!(i instanceof IDBDatabase&&!(t in i)&&typeof t=="string"))return;if(Hn.get(t))return Hn.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,s=Ff.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(s||Lf.includes(e)))return;const n=async function(o,...a){const l=this.transaction(o,s?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[e](...a),s&&l.done]))[0]};return Hn.set(t,n),n}Zl(i=>({...i,get:(t,e,r)=>Ql(t,e)||i.get(t,e,r),has:(t,e)=>!!Ql(t,e)||i.has(t,e)}));const jf=["continue","continuePrimaryKey","advance"],tc={},Vn=new WeakMap,ec=new WeakMap,If={get(i,t){if(!jf.includes(t))return i[t];let e=tc[t];return e||(e=tc[t]=function(...r){Vn.set(this,ec.get(this)[t](...r))}),e}};async function*Bf(...i){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...i)),!t)return;t=t;const e=new Proxy(t,If);for(ec.set(e,t),li.set(e,zn(t));t;)yield e,t=await(Vn.get(e)||t.continue()),Vn.delete(e)}function rc(i,t){return t===Symbol.asyncIterator&&In(i,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&In(i,[IDBIndex,IDBObjectStore])}Zl(i=>({...i,get(t,e,r){return rc(t,e)?Bf:i.get(t,e,r)},has(t,e){return rc(t,e)||i.has(t,e)}}));const Rf="bugpin-reports",$f=2,mr="pending-reports",sc=5,zf=5e3,Hf=3e5,Vf=2;let ci=null,ic=null;function Wf(i){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[i]||"bin"}async function hi(){if(ci)return ci;try{return ci=await Jl(Rf,$f,{upgrade(i){i.objectStoreNames.contains(mr)||i.createObjectStore(mr,{keyPath:"id"}).createIndex("by-created","createdAt")}}),ci}catch(i){throw console.error("[BugPin] Failed to initialize IndexedDB:",i),i}}function Xf(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function ui(){return navigator.onLine!==!1}function Yf(i){const t=zf*Math.pow(Vf,i);return Math.min(t,Hf)}async function nc(i){const t=await hi(),e={...i,id:Xf(),createdAt:new Date().toISOString(),retryCount:0};return await t.put(mr,e),console.log("[BugPin] Report buffered for later submission:",e.id),ui()&&di().catch(console.error),e.id}async function Uf(){try{return await(await hi()).getAllFromIndex(mr,"by-created")}catch{return[]}}async function oc(i){try{await(await hi()).delete(mr,i),console.log("[BugPin] Removed buffered report:",i)}catch(t){console.error("[BugPin] Failed to remove buffered report:",t)}}async function Gf(i){try{await(await hi()).put(mr,i)}catch(t){console.error("[BugPin] Failed to update buffered report:",t)}}async function Nf(i){var t,e;try{const r=new URL("/api/widget/submit",i.serverUrl),s=new FormData;if(s.append("data",JSON.stringify({title:i.title,description:i.description,priority:i.priority,reporterEmail:i.reporterEmail,reporterName:i.reporterName,metadata:i.metadata,mediaCount:((t=i.media)==null?void 0:t.length)||0,mediaAnnotations:(e=i.media)==null?void 0:e.map(o=>o.annotations).filter(Boolean)})),i.media&&i.media.length>0)for(let o=0;o<i.media.length;o++){const a=i.media[o],l=Ul(a.dataUrl),c=Gl(a.dataUrl)||Wf(a.mimeType),u=a.mimeType.startsWith("video/")?"video":"screenshot";s.append("media",l,`${u}-${o}.${c}`)}const n=await fetch(r.toString(),{method:"POST",body:s,headers:{"x-api-key":i.apiKey}});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.message||`HTTP ${n.status}`)}return!0}catch(r){throw console.error("[BugPin] Failed to submit buffered report:",r),r}}async function di(){if(!ui())return console.log("[BugPin] Offline, skipping sync"),{synced:0,failed:0};const i=await Uf();if(i.length===0)return{synced:0,failed:0};console.log(`[BugPin] Syncing ${i.length} pending reports...`);let t=0,e=0;for(const r of i){if(r.lastRetryAt){const n=new Date(r.lastRetryAt).getTime()+Yf(r.retryCount);if(Date.now()<n)continue}try{await Nf(r),await oc(r.id),t++,console.log("[BugPin] Successfully synced report:",r.id)}catch(s){e++,r.retryCount++,r.lastRetryAt=new Date().toISOString(),r.error=s instanceof Error?s.message:"Unknown error",r.retryCount>=sc?(console.error("[BugPin] Max retries exceeded, removing report:",r.id),await oc(r.id)):(await Gf(r),console.log(`[BugPin] Report retry scheduled (attempt ${r.retryCount}/${sc}):`,r.id))}}return{synced:t,failed:e}}function qf(){window.addEventListener("online",()=>{console.log("[BugPin] Back online, syncing pending reports..."),di().catch(console.error)}),ic||(ic=setInterval(()=>{ui()&&di().catch(console.error)},3e4)),ui()&&di().catch(console.error)}qf();function Kf(){return navigator.onLine!==!1}function Zf(i){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi"}[i]||"bin"}async function Jf(i){const{apiKey:t,serverUrl:e,media:r,...s}=i;if(!Kf())return console.log("[BugPin] Offline, buffering report for later submission"),await nc({apiKey:t,serverUrl:e,title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,media:r,metadata:s.metadata}),{success:!0,message:"Report saved. It will be submitted when you're back online."};const n=new URL("/api/widget/submit",e),o=new FormData;if(o.append("data",JSON.stringify({title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,metadata:s.metadata,mediaCount:(r==null?void 0:r.length)||0,mediaAnnotations:r==null?void 0:r.map(a=>a.annotations).filter(Boolean)})),r&&r.length>0)for(let a=0;a<r.length;a++){const l=r[a],c=Ul(l.dataUrl),h=Gl(l.dataUrl)||Zf(l.mimeType),d=l.mimeType.startsWith("video/")?"video":"screenshot";console.log(`[BugPin] Media ${a}: dataUrl length=${l.dataUrl.length}, blob size=${c.size}, type=${c.type}`),o.append("media",c,`${d}-${a}.${h}`)}try{const a=await fetch(n.toString(),{method:"POST",body:o,headers:{"x-api-key":t}}),l=await a.json();if(!a.ok||!l.success)throw new Error(l.message||l.error||"Failed to submit report");return l}catch(a){if(a instanceof TypeError&&a.message.includes("fetch"))return console.log("[BugPin] Network error, buffering report for later submission"),await nc({apiKey:t,serverUrl:e,title:s.title,description:s.description,priority:s.priority,reporterEmail:s.reporterEmail,reporterName:s.reporterName,media:r,metadata:s.metadata}),{success:!0,message:"Report saved. It will be submitted when the connection is restored."};throw a}}const Qf="bugpin-drafts",tp=1,vr="draft-media",ep="bugpin-draft-";let gi=null;async function fi(){if(gi)return gi;try{return gi=await Jl(Qf,tp,{upgrade(i){i.objectStoreNames.contains(vr)||i.createObjectStore(vr,{keyPath:"apiKey"})}}),gi}catch(i){throw console.error("[BugPin] Failed to initialize draft database:",i),i}}function Wn(i){return`${ep}${i}`}function rp(i,t,e){try{const r={formData:t,activeTab:e,savedAt:new Date().toISOString()};localStorage.setItem(Wn(i),JSON.stringify(r))}catch(r){console.error("[BugPin] Failed to save form draft:",r)}}function ac(i){try{const t=localStorage.getItem(Wn(i));return t?JSON.parse(t):null}catch(t){return console.error("[BugPin] Failed to load form draft:",t),null}}function sp(i){try{localStorage.removeItem(Wn(i))}catch(t){console.error("[BugPin] Failed to clear form draft:",t)}}async function ip(i,t){try{await(await fi()).put(vr,{apiKey:i,media:t,savedAt:new Date().toISOString()})}catch(e){console.error("[BugPin] Failed to save media draft:",e)}}async function np(i){try{const e=await(await fi()).get(vr,i);return(e==null?void 0:e.media)||[]}catch(t){return console.error("[BugPin] Failed to load media draft:",t),[]}}async function lc(i){try{await(await fi()).delete(vr,i)}catch(t){console.error("[BugPin] Failed to clear media draft:",t)}}async function op(i){if(ac(i))return!0;try{const r=await(await fi()).get(vr,i);return r!==void 0&&r.media.length>0}catch{return!1}}async function ap(i,t,e,r){rp(i,t,e),r.length>0?await ip(i,r):await lc(i)}async function lp(i){const t=ac(i),e=await np(i);return!t&&e.length===0?null:{formData:(t==null?void 0:t.formData)||{title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},activeTab:(t==null?void 0:t.activeTab)||"details",media:e}}async function cp(i){sp(i),await lc(i)}const pi={save:ap,load:lp,clear:cp,has:op},Xn={title:"",description:"",priority:"medium",reporterEmail:"",reporterName:""},hp=({config:i,deps:t})=>{const e=(t==null?void 0:t.WidgetDialog)??Vh,r=(t==null?void 0:t.AnnotationCanvas)??mg,s=(t==null?void 0:t.captureScreenshot)??vf,n=(t==null?void 0:t.captureContext)??Tf,o=(t==null?void 0:t.submitReport)??Jf,a=It(null),l=Yo(i.theme),[c,h]=at("closed"),[u,d]=at(!1),[g,f]=at(!1),[m,y]=at([]),[b,w]=at(null),[T,C]=at(null),[S,D]=at("details"),[A,_]=at(Xn),[M,O]=at(!1),[V,z]=at(!1),[X,W]=at(!1);Ht(()=>{c==="form"&&!M&&pi.load(i.apiKey).then(F=>{F&&(_(F.formData),D(F.activeTab),y(F.media)),O(!0)})},[c,M,i.apiKey]),Ht(()=>{const F=a.current;F&&(l==="dark"?(F.style.setProperty("--button-color",i.dialogDarkButtonColor),F.style.setProperty("--button-text-color",i.dialogDarkTextColor),F.style.setProperty("--button-hover-color",i.dialogDarkButtonHoverColor),F.style.setProperty("--button-hover-text-color",i.dialogDarkTextHoverColor),F.style.setProperty("--background",i.dialogDarkBackgroundColor),F.style.setProperty("--muted",i.dialogDarkSecondaryColor),F.style.setProperty("--input-background",i.dialogDarkInputColor),F.style.setProperty("--foreground",i.dialogDarkForegroundColor)):(F.style.setProperty("--button-color",i.dialogLightButtonColor),F.style.setProperty("--button-text-color",i.dialogLightTextColor),F.style.setProperty("--button-hover-color",i.dialogLightButtonHoverColor),F.style.setProperty("--button-hover-text-color",i.dialogLightTextHoverColor),F.style.setProperty("--background",i.dialogLightBackgroundColor),F.style.setProperty("--muted",i.dialogLightSecondaryColor),F.style.setProperty("--input-background",i.dialogLightInputColor),F.style.setProperty("--foreground",i.dialogLightForegroundColor)))},[l,i.dialogLightButtonColor,i.dialogLightTextColor,i.dialogLightButtonHoverColor,i.dialogLightTextHoverColor,i.dialogLightBackgroundColor,i.dialogLightSecondaryColor,i.dialogLightInputColor,i.dialogLightForegroundColor,i.dialogDarkButtonColor,i.dialogDarkTextColor,i.dialogDarkButtonHoverColor,i.dialogDarkTextHoverColor,i.dialogDarkBackgroundColor,i.dialogDarkSecondaryColor,i.dialogDarkInputColor,i.dialogDarkForegroundColor]);const G=N(()=>{h("form")},[]),K=A.title.trim()||A.description.trim()||A.reporterEmail.trim()||A.reporterName.trim()||m.length>0,Z=N(()=>{K?z(!0):(h("closed"),w(null),O(!1))},[K]),L=N(()=>{pi.save(i.apiKey,A,S,m),z(!1),h("closed"),w(null),O(!1)},[i.apiKey,A,S,m]),wt=N(()=>{y([]),D("details"),_(Xn),pi.clear(i.apiKey),z(!1),h("closed"),w(null),O(!1)},[i.apiKey]),mt=N((F=!1)=>{F===!0&&(y([]),D("details"),_(Xn),pi.clear(i.apiKey)),z(!1),h("closed"),w(null),O(!1)},[i.apiKey]);Ht(()=>{const F=()=>G(),J=()=>Z();return document.addEventListener("bugpin:open",F),document.addEventListener("bugpin:close",J),()=>{document.removeEventListener("bugpin:open",F),document.removeEventListener("bugpin:close",J)}},[G,Z]);const lt=N(async()=>{if(i.enableScreenshot){if(i.useScreenCaptureAPI&&!X&&!(localStorage.getItem("bugpin-skip-screen-capture-consent")==="true")){W(!0);return}W(!1),f(!0),h("closed"),await new Promise(F=>setTimeout(F,100));try{const F=await s({method:i.captureMethod,useScreenCaptureAPI:i.useScreenCaptureAPI}),J=new Image;J.onload=()=>{console.log(`[BugPin] Captured screenshot: ${J.width}x${J.height}, dataUrl length=${F.length}`);const et={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:F,timestamp:new Date,annotated:!1,mimeType:"image/png",width:J.width,height:J.height};y(xt=>[...xt,et]),f(!1),D("media"),h("form")},J.onerror=()=>{const et={id:`capture-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,dataUrl:F,timestamp:new Date,annotated:!1,mimeType:"image/png"};y(xt=>[...xt,et]),f(!1),D("media"),h("form")},J.src=F}catch(F){console.error("[BugPin] Failed to capture screenshot:",F),f(!1),h("form"),C({message:"Failed to capture screenshot",type:"error"})}}},[i,s,X]),k=N(()=>{lt()},[lt]),P=N(()=>{W(!1)},[]),E=N(F=>{y(J=>[...J,F])},[]),B=N(F=>{y(J=>J.filter(et=>et.id!==F))},[]),I=N(F=>{w(F),h("annotating")},[]),H=N((F,J)=>{b&&y(et=>et.map(xt=>xt.id===b?{...xt,dataUrl:F,annotated:!0,annotations:J}:xt)),w(null),h("form")},[b]),dt=N(()=>{w(null),h("form")},[]),ht=N(async(F,J)=>{d(!0);try{const et=n();await o({apiKey:i.apiKey,serverUrl:i.serverUrl,title:F.title,description:F.description,priority:F.priority,reporterEmail:F.reporterEmail||void 0,reporterName:F.reporterName||void 0,media:J.map(xt=>({dataUrl:xt.dataUrl,mimeType:xt.mimeType,annotations:xt.annotations})),metadata:et}),C({message:"Bug report submitted successfully!",type:"success"}),mt(!0)}catch(et){console.error("[BugPin] Failed to submit report:",et),C({message:et instanceof Error?et.message:"Failed to submit report",type:"error"})}finally{d(!1)}},[i,mt,n,o]),it=N(()=>{C(null)},[]),kt=b?m.find(F=>F.id===b):null;return p("div",{ref:a,class:`bugpin-container bugpin-theme-${l}`,children:[p(Oh,{position:i.position,buttonText:i.buttonText,buttonShape:i.buttonShape,buttonIcon:i.buttonIcon,buttonIconSize:i.buttonIconSize,buttonIconStroke:i.buttonIconStroke,theme:i.theme,lightButtonColor:i.lightButtonColor,lightTextColor:i.lightTextColor,lightButtonHoverColor:i.lightButtonHoverColor,lightTextHoverColor:i.lightTextHoverColor,darkButtonColor:i.darkButtonColor,darkTextColor:i.darkTextColor,darkButtonHoverColor:i.darkButtonHoverColor,darkTextHoverColor:i.darkTextHoverColor,enableHoverScaleEffect:i.enableHoverScaleEffect,tooltipEnabled:i.tooltipEnabled,tooltipText:i.tooltipText,onClick:G}),c==="annotating"&&kt&&p("div",{class:"fixed inset-0 z-[2147483646] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:p("div",{class:"relative max-w-4xl max-h-[90vh] bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",children:p(r,{screenshot:kt.dataUrl,onSave:H,onCancel:dt})})}),c==="form"&&p(e,{onClose:Z,onSubmit:ht,onCaptureScreenshot:lt,onAnnotateMedia:I,media:m,onAddMedia:E,onRemoveMedia:B,isSubmitting:u,isCapturing:g,enableAnnotation:i.enableAnnotation,maxImageSize:i.maxImageUploadSize,maxVideoSize:i.maxVideoUploadSize,activeTab:S,onActiveTabChange:D,formData:A,onFormDataChange:_,showScreenCaptureConsent:X,onConsentConfirm:k,onConsentCancel:P}),V&&p("div",{class:"fixed inset-0 z-[2147483647] bg-black/50 flex items-center justify-center p-5 animate-[fadeIn_0.2s_ease-out]",children:p("div",{class:"relative w-full max-w-sm bg-background border border-solid border-border rounded shadow-lg overflow-hidden flex flex-col animate-[slideUp_0.2s_ease-out]",role:"dialog","aria-modal":"true","aria-labelledby":"bugpin-confirm-title",children:p("div",{class:"p-6",children:[p("h1",{id:"bugpin-confirm-title",class:"tracking-tight mb-2",children:"Save draft?"}),p("p",{class:"text-sm text-muted-foreground mb-6",children:"You have unsaved changes. Would you like to save them as a draft for later?"}),p("div",{class:"flex gap-3",children:[p("button",{type:"button",onClick:wt,class:"flex-1 px-4 py-2 text-sm font-medium rounded border border-solid border-border bg-background text-foreground hover:bg-muted transition-colors",children:"Discard"}),p("button",{type:"button",onClick:L,class:"flex-1 px-4 py-2 text-sm font-medium rounded border border-solid border-transparent text-[var(--button-text-color)] bg-[var(--button-color)] hover:bg-[var(--button-hover-color)] hover:text-[var(--button-hover-text-color)] transition-colors",children:"Save Draft"})]})]})})}),T&&p(Lh,{message:T.message,type:T.type,onClose:it})]})},Yn={apiKey:"",serverUrl:window.location.origin,position:"bottom-right",buttonText:null,buttonShape:"round",buttonIcon:"bug",buttonIconSize:18,buttonIconStroke:2,theme:"auto",lightButtonColor:"#02658D",lightTextColor:"#ffffff",lightButtonHoverColor:"#024F6F",lightTextHoverColor:"#ffffff",darkButtonColor:"#02658D",darkTextColor:"#ffffff",darkButtonHoverColor:"#036F9B",darkTextHoverColor:"#ffffff",dialogLightButtonColor:"#02658D",dialogLightTextColor:"#ffffff",dialogLightButtonHoverColor:"#024F6F",dialogLightTextHoverColor:"#ffffff",dialogLightBackgroundColor:"#ffffff",dialogLightSecondaryColor:"#f5f5f5",dialogLightInputColor:"#ffffff",dialogLightForegroundColor:"#0a0a0a",dialogDarkButtonColor:"#02658D",dialogDarkTextColor:"#ffffff",dialogDarkButtonHoverColor:"#036F9B",dialogDarkTextHoverColor:"#ffffff",dialogDarkBackgroundColor:"#0a0a0a",dialogDarkSecondaryColor:"#262626",dialogDarkInputColor:"#1a1a1a",dialogDarkForegroundColor:"#fafafa",enableHoverScaleEffect:!0,tooltipEnabled:!1,tooltipText:null,enableScreenshot:!0,enableAnnotation:!0,enableConsoleCapture:!0,captureMethod:"visible",useScreenCaptureAPI:!1,maxScreenshotSize:5*1024*1024,maxImageUploadSize:10*1024*1024,maxVideoUploadSize:50*1024*1024},up='/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-200:oklch(88.5% .062 18.334);--color-red-400:oklch(70.4% .191 22.216);--color-red-600:oklch(57.7% .245 27.325);--color-red-800:oklch(44.4% .177 26.899);--color-red-950:oklch(25.8% .092 26.042);--color-green-50:oklch(98.2% .018 155.826);--color-green-200:oklch(92.5% .084 155.995);--color-green-600:oklch(62.7% .194 149.214);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-900:oklch(37.9% .146 265.522);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-xl:36rem;--container-3xl:48rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-medium:500;--tracking-tight:-.025em;--tracking-wide:.025em;--shadow-sm:var(--shadow-sm);--shadow-lg:var(--shadow-lg);--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{box-sizing:border-box;margin:0;padding:0}h1,h2,h3,h4,h5,h6{color:var(--foreground);font-weight:600;line-height:1.3}h1{font-size:1.25rem}h2{font-size:1rem}h3{font-size:.9375rem}h4,h5,h6{font-size:.875rem}p{color:var(--foreground);font-size:.875rem;line-height:1.5}#bugpin-root{--bugpin-primary-50:#e6f3f9;--bugpin-primary-100:#cbe7f2;--bugpin-primary-200:#9ed1e6;--bugpin-primary-300:#6ab8d8;--bugpin-primary-400:#2e9bc6;--bugpin-primary-500:#0e84b1;--bugpin-primary-600:#036f9b;--bugpin-primary-700:#02658d;--bugpin-primary-800:#024f6f;--bugpin-primary-900:#013a52;--bugpin-primary-950:#012738;--background:#fff;--foreground:#0a0a0a;--muted:#f5f5f5;--muted-foreground:#737373;--border:#e5e5e5;--input:#e5e5e5;--ring:#a3a3a3;--destructive:#ef4444;--destructive-foreground:#fafafa;--radius:.5rem;--shadow-sm:0 1px 2px 0 #0000000d;--shadow:0 1px 3px 0 #0000001a,0 1px 2px -1px #0000001a;--shadow-lg:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a;color:var(--foreground);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif;font-size:14px;line-height:1.5}.bugpin-container{--primary:var(--button-color,var(--bugpin-primary-700));--primary-foreground:var(--button-text-color,#fafafa);--primary-hover:var(--button-hover-color,var(--bugpin-primary-800));--primary-hover-foreground:var(--button-hover-text-color,#fafafa)}.bugpin-theme-dark,.bugpin-container.bugpin-theme-dark{--background:#0a0a0a;--foreground:#fafafa;--muted:#262626;--muted-foreground:#a3a3a3;--border:#262626;--input:#262626;--ring:#d4d4d4}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes slideIn{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes spin{to{transform:rotate(360deg)}}@keyframes bugpin-tooltip-fade-in{0%{opacity:0}to{opacity:1}}.priority-lowest{color:#6b7280}.priority-low{color:#3b82f6}.priority-medium{color:#f59e0b}.priority-high{color:#ef4444}.priority-highest{color:#dc2626}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.top-1\\.5{top:calc(var(--spacing)*1.5)}.top-5{top:calc(var(--spacing)*5)}.top-full{top:100%}.right-5{right:calc(var(--spacing)*5)}.bottom-5{bottom:calc(var(--spacing)*5)}.bottom-20{bottom:calc(var(--spacing)*20)}.bottom-full{bottom:100%}.left-1\\.5{left:calc(var(--spacing)*1.5)}.left-5{left:calc(var(--spacing)*5)}.z-\\[2147483646\\]{z-index:2147483646}.z-\\[2147483647\\]{z-index:2147483647}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.ml-0\\.5{margin-left:calc(var(--spacing)*.5)}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-flex{display:inline-flex}.aspect-video{aspect-ratio:var(--aspect-video)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-4\\.5{height:calc(var(--spacing)*4.5)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-full{height:100%}.max-h-\\[70vh\\]{max-height:70vh}.max-h-\\[90vh\\]{max-height:90vh}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-20{min-height:calc(var(--spacing)*20)}.min-h-28{min-height:calc(var(--spacing)*28)}.min-h-40{min-height:calc(var(--spacing)*40)}.min-h-\\[600px\\]{min-height:600px}.w-3\\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-12{width:calc(var(--spacing)*12)}.w-full{width:100%}.w-px{width:1px}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-\\[700px\\]{min-width:700px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-\\[bugpin-tooltip-fade-in_0\\.2s_ease-in-out_forwards\\]{animation:.2s ease-in-out forwards bugpin-tooltip-fade-in}.animate-\\[fadeIn_0\\.2s_ease-out\\]{animation:.2s ease-out fadeIn}.animate-\\[slideIn_0\\.3s_ease-out\\]{animation:.3s ease-out slideIn}.animate-\\[slideUp_0\\.2s_ease-out\\]{animation:.2s ease-out slideUp}.animate-\\[spin_0\\.8s_linear_infinite\\]{animation:.8s linear infinite spin}.cursor-pointer{cursor:pointer}.resize-y{resize:vertical}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:calc(var(--radius) + 2px)}.rounded-md{border-radius:calc(var(--radius) - 4px)}.rounded-sm{border-radius:calc(var(--radius) - 2px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-none{--tw-border-style:none;border-style:none}.border-solid{--tw-border-style:solid;border-style:solid}.border-blue-200{border-color:var(--color-blue-200)}.border-border{border-color:var(--border)}.border-destructive{border-color:var(--destructive)}.border-gray-800{border-color:var(--color-gray-800)}.border-green-200{border-color:var(--color-green-200)}.border-input{border-color:var(--input)}.border-primary{border-color:var(--primary)}.border-red-200{border-color:var(--color-red-200)}.border-transparent{border-color:#0000}.border-white\\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-t-white{border-top-color:var(--color-white)}.bg-\\[var\\(--button-color\\)\\]{background-color:var(--button-color)}.bg-\\[var\\(--input-background\\,transparent\\)\\]{background-color:var(--input-background,transparent)}.bg-background{background-color:var(--background)}.bg-black\\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-border{background-color:var(--border)}.bg-destructive{background-color:var(--destructive)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-green-50{background-color:var(--color-green-50)}.bg-muted{background-color:var(--muted)}.bg-primary,.bg-primary\\/5{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.bg-primary\\/5{background-color:color-mix(in oklab,var(--primary)5%,transparent)}}.bg-primary\\/10{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.bg-primary\\/10{background-color:color-mix(in oklab,var(--primary)10%,transparent)}}.bg-red-50{background-color:var(--color-red-50)}.bg-transparent{background-color:#0000}.object-contain{object-fit:contain}.p-1{padding:calc(var(--spacing)*1)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-8{padding-block:calc(var(--spacing)*8)}.pb-0{padding-bottom:calc(var(--spacing)*0)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.text-center{text-align:center}.font-sans{font-family:var(--font-sans)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-\\[var\\(--button-text-color\\)\\]{color:var(--button-text-color)}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-destructive{color:var(--destructive)}.text-destructive-foreground{color:var(--destructive-foreground)}.text-foreground{color:var(--foreground)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-green-600{color:var(--color-green-600)}.text-muted-foreground{color:var(--muted-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-600{color:var(--color-red-600)}.uppercase{text-transform:uppercase}.no-underline{text-decoration-line:none}.accent-primary{accent-color:var(--primary)}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.select-none{-webkit-user-select:none;user-select:none}.placeholder\\:text-muted-foreground::placeholder{color:var(--muted-foreground)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-\\[var\\(--button-hover-color\\)\\]:hover{background-color:var(--button-hover-color)}.hover\\:bg-destructive\\/90:hover{background-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-destructive\\/90:hover{background-color:color-mix(in oklab,var(--destructive)90%,transparent)}}.hover\\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/5:hover{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-primary\\/5:hover{background-color:color-mix(in oklab,var(--primary)5%,transparent)}}.hover\\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\\:text-\\[var\\(--button-hover-text-color\\)\\]:hover{color:var(--button-hover-text-color)}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-gray-800:hover{color:var(--color-gray-800)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-hover:hover{color:var(--primary-hover)}.hover\\:text-primary-hover-foreground:hover{color:var(--primary-hover-foreground)}.hover\\:text-red-600:hover{color:var(--color-red-600)}.hover\\:underline:hover{text-decoration-line:underline}.hover\\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:border-destructive:focus{border-color:var(--destructive)}.focus\\:border-ring:focus{border-color:var(--ring)}.focus\\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\\:ring-destructive\\/20:focus{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.focus\\:ring-destructive\\/20:focus{--tw-ring-color:color-mix(in oklab,var(--destructive)20%,transparent)}}.focus\\:ring-ring\\/20:focus{--tw-ring-color:var(--ring)}@supports (color:color-mix(in lab,red,red)){.focus\\:ring-ring\\/20:focus{--tw-ring-color:color-mix(in oklab,var(--ring)20%,transparent)}}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\\:ring-ring:focus-visible{--tw-ring-color:var(--ring)}.focus-visible\\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\\:scale-105:active{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}.dark\\:border-red-800:is(.bugpin-theme-dark *){border-color:var(--color-red-800)}.dark\\:bg-blue-900\\/70:is(.bugpin-theme-dark *){background-color:#1c398eb3}@supports (color:color-mix(in lab,red,red)){.dark\\:bg-blue-900\\/70:is(.bugpin-theme-dark *){background-color:color-mix(in oklab,var(--color-blue-900)70%,transparent)}}.dark\\:bg-gray-700:is(.bugpin-theme-dark *){background-color:var(--color-gray-700)}.dark\\:bg-red-950\\/50:is(.bugpin-theme-dark *){background-color:#46080980}@supports (color:color-mix(in lab,red,red)){.dark\\:bg-red-950\\/50:is(.bugpin-theme-dark *){background-color:color-mix(in oklab,var(--color-red-950)50%,transparent)}}.dark\\:text-blue-300:is(.bugpin-theme-dark *){color:var(--color-blue-300)}.dark\\:text-gray-300:is(.bugpin-theme-dark *){color:var(--color-gray-300)}.dark\\:text-red-400:is(.bugpin-theme-dark *){color:var(--color-red-400)}@media (hover:hover){.dark\\:hover\\:bg-red-950:is(.bugpin-theme-dark *):hover{background-color:var(--color-red-950)}.\\[\\&_span\\]\\:hover\\:text-primary span:hover{color:var(--primary)}}.\\[\\&_svg\\]\\:h-4 svg{height:calc(var(--spacing)*4)}.\\[\\&_svg\\]\\:h-4\\.5 svg{height:calc(var(--spacing)*4.5)}.\\[\\&_svg\\]\\:w-4 svg{width:calc(var(--spacing)*4)}.\\[\\&_svg\\]\\:w-4\\.5 svg{width:calc(var(--spacing)*4.5)}@media (hover:hover){.\\[\\&_svg\\]\\:hover\\:text-primary svg:hover{color:var(--primary)}}}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}';bf();let cc=!1;async function hc(i,t){var e,r,s;try{const n=await fetch(`${t}/api/widget/config/${i}`);if(n.ok){const o=await n.json();if(o.success&&o.config){const a=o.config;return{buttonText:a.buttonText,buttonShape:a.buttonShape,buttonIcon:a.buttonIcon,buttonIconSize:a.buttonIconSize,buttonIconStroke:a.buttonIconStroke,position:a.position,theme:a.theme,lightButtonColor:a.lightButtonColor,lightTextColor:a.lightTextColor,lightButtonHoverColor:a.lightButtonHoverColor,lightTextHoverColor:a.lightTextHoverColor,darkButtonColor:a.darkButtonColor,darkTextColor:a.darkTextColor,darkButtonHoverColor:a.darkButtonHoverColor,darkTextHoverColor:a.darkTextHoverColor,dialogLightButtonColor:a.dialogLightButtonColor,dialogLightTextColor:a.dialogLightTextColor,dialogLightButtonHoverColor:a.dialogLightButtonHoverColor,dialogLightTextHoverColor:a.dialogLightTextHoverColor,dialogLightBackgroundColor:a.dialogLightBackgroundColor,dialogLightSecondaryColor:a.dialogLightSecondaryColor,dialogLightInputColor:a.dialogLightInputColor,dialogLightForegroundColor:a.dialogLightForegroundColor,dialogDarkButtonColor:a.dialogDarkButtonColor,dialogDarkTextColor:a.dialogDarkTextColor,dialogDarkButtonHoverColor:a.dialogDarkButtonHoverColor,dialogDarkTextHoverColor:a.dialogDarkTextHoverColor,dialogDarkBackgroundColor:a.dialogDarkBackgroundColor,dialogDarkSecondaryColor:a.dialogDarkSecondaryColor,dialogDarkInputColor:a.dialogDarkInputColor,dialogDarkForegroundColor:a.dialogDarkForegroundColor,enableHoverScaleEffect:a.enableHoverScaleEffect,tooltipEnabled:a.tooltipEnabled,tooltipText:a.tooltipText,enableScreenshot:((e=a.features)==null?void 0:e.screenshot)??!0,enableAnnotation:((r=a.features)==null?void 0:r.annotation)??!0,enableConsoleCapture:((s=a.features)==null?void 0:s.consoleCapture)??!0,captureMethod:a.captureMethod,useScreenCaptureAPI:a.useScreenCaptureAPI,maxImageUploadSize:a.maxImageUploadSizeMb?a.maxImageUploadSizeMb*1024*1024:void 0,maxVideoUploadSize:a.maxVideoUploadSizeMb?a.maxVideoUploadSizeMb*1024*1024:void 0}}}else if(n.status===403&&(await n.json()).error==="PROJECT_PAUSED")return console.info("[BugPin] Widget disabled - project is paused"),null}catch(n){console.warn("[BugPin] Failed to fetch widget config, using defaults",n)}return{}}function Un(i){if(cc){console.warn("[BugPin] Widget already initialized");return}cc=!0;const t=document.createElement("div");t.id="bugpin-widget",t.setAttribute("data-bugpin-exclude","true");const e=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=up,e.appendChild(r);const s=document.createElement("div");s.id="bugpin-root",e.appendChild(s),document.body.appendChild(t),vc(Cr(hp,{config:i}),s)}async function dp(i){const t=i.getAttribute("data-api-key");if(!t){console.error("[BugPin] Missing data-api-key attribute");return}const e=i.getAttribute("data-server-url")||new URL(i.src).origin,r=await hc(t,e);if(r===null)return;const s={...Yn,...r,apiKey:t,serverUrl:e,...i.getAttribute("data-position")&&{position:i.getAttribute("data-position")},...i.getAttribute("data-button-text")&&{buttonText:i.getAttribute("data-button-text")},...i.getAttribute("data-theme")&&{theme:i.getAttribute("data-theme")}};Un(s)}const Gn={init:async i=>{const t=i.serverUrl||Yn.serverUrl,e=await hc(i.apiKey,t);if(e===null)return;const r={...Yn,...e,...i,serverUrl:t};Un(r)},open:()=>{document.dispatchEvent(new CustomEvent("bugpin:open"))},close:()=>{document.dispatchEvent(new CustomEvent("bugpin:close"))}};typeof window<"u"&&(window.BugPin=Gn);const mi=document.currentScript;if(mi!=null&&mi.hasAttribute("data-api-key")){const i=()=>dp(mi);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}return wr.BugPin=Gn,wr.createWidget=Un,wr.default=Gn,Object.defineProperties(wr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),wr}({});
541
541
  //# sourceMappingURL=widget.js.map