maestro-agent 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +316 -2
- package/bin/maestro.ts +5 -0
- package/dist/maestro +0 -0
- package/dist/web/assets/Connections-DV2Kql1Z.js +1 -0
- package/dist/web/assets/GanttView-CCT_rFpY.js +39 -0
- package/dist/web/assets/Home-BFbUIh2z.js +1 -0
- package/dist/web/assets/HooksCrons-ASM5-jDm.js +1 -0
- package/dist/web/assets/ProjectDetail-KZZi6IAd.js +1 -0
- package/dist/web/assets/Roles-KQ94PG3H.js +4 -0
- package/dist/web/assets/ScheduledTasks-CdJHJpEV.js +1 -0
- package/dist/web/assets/Settings-CTflMta-.js +1 -0
- package/dist/web/assets/Skills-D09W1mwX.js +2 -0
- package/dist/web/assets/Wizard-CW6B0wc3.js +1 -0
- package/dist/web/assets/WorkspaceChat-CthETL_A.js +1 -0
- package/dist/web/assets/WorkspaceDashboard-DTAesQuT.js +1 -0
- package/dist/web/assets/WorkspaceNew-Em4msIKn.js +1 -0
- package/dist/web/assets/WorkspaceProjects-Dxg2BpQy.js +1 -0
- package/dist/web/assets/WorkspaceTasks-C20mnnkP.js +1 -0
- package/dist/web/assets/index-B1k33vcR.js +11 -0
- package/dist/web/assets/index-Bk2hHz7P.css +1 -0
- package/dist/web/assets/index-Ddy5AJwx.js +61 -0
- package/dist/web/assets/useEventStream-DTID465I.js +1 -0
- package/dist/web/index.html +13 -0
- package/package.json +49 -6
- package/src/api/agents.ts +76 -0
- package/src/api/audit.ts +19 -0
- package/src/api/autopilot.ts +73 -0
- package/src/api/chat.ts +801 -0
- package/src/api/chief.ts +84 -0
- package/src/api/config.ts +39 -0
- package/src/api/gantt.ts +72 -0
- package/src/api/hooks.ts +54 -0
- package/src/api/inbox.ts +125 -0
- package/src/api/lark.ts +32 -0
- package/src/api/memory.ts +37 -0
- package/src/api/ops.ts +89 -0
- package/src/api/projects.ts +105 -0
- package/src/api/roles.ts +123 -0
- package/src/api/runtimes.ts +62 -0
- package/src/api/scheduled-tasks.ts +203 -0
- package/src/api/sessions.ts +479 -0
- package/src/api/skills.ts +386 -0
- package/src/api/tasks.ts +457 -0
- package/src/api/telegram.ts +94 -0
- package/src/api/templates.ts +36 -0
- package/src/api/webhooks.ts +20 -0
- package/src/api/workspaces.ts +150 -0
- package/src/bridges/lark/index.ts +213 -0
- package/src/bridges/telegram/index.ts +273 -0
- package/src/bridges/telegram/polling.ts +185 -0
- package/src/chat/index.ts +86 -0
- package/src/chief/index.ts +461 -0
- package/src/core/cli.ts +333 -0
- package/src/core/db.ts +53 -0
- package/src/core/event-bus.ts +33 -0
- package/src/core/index.ts +6 -0
- package/src/core/migrations.ts +303 -0
- package/src/core/router.ts +69 -0
- package/src/core/schema.sql +232 -0
- package/src/core/server.ts +308 -0
- package/src/core/validate.ts +22 -0
- package/src/discovery/index.ts +194 -0
- package/src/gateway/adapters/telegram.ts +148 -0
- package/src/gateway/index.ts +31 -0
- package/src/gateway/manager.ts +176 -0
- package/src/gateway/types.ts +77 -0
- package/src/inbox/index.ts +500 -0
- package/src/ops/artifact-sync.ts +65 -0
- package/src/ops/autopilot.ts +338 -0
- package/src/ops/gc.ts +252 -0
- package/src/ops/index.ts +226 -0
- package/src/ops/project-serial.ts +52 -0
- package/src/ops/role-dispatch.ts +111 -0
- package/src/ops/runtime-scheduler.ts +447 -0
- package/src/ops/task-blocking.ts +65 -0
- package/src/ops/task-deps.ts +37 -0
- package/src/ops/task-workspace.ts +60 -0
- package/src/roles/index.ts +258 -0
- package/src/roles/prompt-assembler.ts +85 -0
- package/src/roles/workspace-role.ts +155 -0
- package/src/scheduler/index.ts +461 -0
- package/src/session/output-parser.ts +75 -0
- package/src/session/realtime-parser.ts +40 -0
- package/src/skills/builtin.ts +155 -0
- package/src/skills/skill-extractor.ts +452 -0
- package/src/skills/skill-md.ts +282 -0
- package/src/transport/http-api.ts +75 -0
- package/src/transport/index.ts +4 -0
- package/src/transport/local-pty.ts +119 -0
- package/src/transport/ssh.ts +176 -0
- package/src/transport/types.ts +20 -0
- package/src/workflows/index.ts +231 -0
- package/index.js +0 -1
- package/maestro-agent-0.0.1.tgz +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{a as br,c as Ms,r as rt,j as Ot,g as Lo,p as Ao}from"./index-Ddy5AJwx.js";import{u as Do}from"./useEventStream-DTID465I.js";var gi={exports:{}},Ro=gi.exports,Os;function Po(){return Os||(Os=1,(function(i,t){(function(e,s){i.exports=s()})(Ro,(function(){var e=1e3,s=6e4,n=36e5,r="millisecond",a="second",o="minute",h="hour",l="day",d="week",p="month",u="quarter",g="year",f="date",m="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,S=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(P){var A=["th","st","nd","rd"],$=P%100;return"["+P+(A[($-20)%10]||A[$]||A[0])+"]"}},c=function(P,A,$){var w=String(P);return!w||w.length>=A?P:""+Array(A+1-w.length).join($)+P},v={s:c,z:function(P){var A=-P.utcOffset(),$=Math.abs(A),w=Math.floor($/60),E=$%60;return(A<=0?"+":"-")+c(w,2,"0")+":"+c(E,2,"0")},m:function P(A,$){if(A.date()<$.date())return-P($,A);var w=12*($.year()-A.year())+($.month()-A.month()),E=A.clone().add(w,p),R=$-E<0,D=A.clone().add(w+(R?-1:1),p);return+(-(w+($-E)/(R?E-D:D-E))||0)},a:function(P){return P<0?Math.ceil(P)||0:Math.floor(P)},p:function(P){return{M:p,y:g,w:d,d:l,D:f,h,m:o,s:a,ms:r,Q:u}[P]||String(P||"").toLowerCase().replace(/s$/,"")},u:function(P){return P===void 0}},x="en",T={};T[x]=y;var O="$isDayjsObject",_=function(P){return P instanceof F||!(!P||!P[O])},C=function P(A,$,w){var E;if(!A)return x;if(typeof A=="string"){var R=A.toLowerCase();T[R]&&(E=R),$&&(T[R]=$,E=R);var D=A.split("-");if(!E&&D.length>1)return P(D[0])}else{var G=A.name;T[G]=A,E=G}return!w&&E&&(x=E),E||!w&&x},k=function(P,A){if(_(P))return P.clone();var $=typeof A=="object"?A:{};return $.date=P,$.args=arguments,new F($)},L=v;L.l=C,L.i=_,L.w=function(P,A){return k(P,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var F=(function(){function P($){this.$L=C($.locale,null,!0),this.parse($),this.$x=this.$x||$.x||{},this[O]=!0}var A=P.prototype;return A.parse=function($){this.$d=(function(w){var E=w.date,R=w.utc;if(E===null)return new Date(NaN);if(L.u(E))return new Date;if(E instanceof Date)return new Date(E);if(typeof E=="string"&&!/Z$/i.test(E)){var D=E.match(b);if(D){var G=D[2]-1||0,B=(D[7]||"0").substring(0,3);return R?new Date(Date.UTC(D[1],G,D[3]||1,D[4]||0,D[5]||0,D[6]||0,B)):new Date(D[1],G,D[3]||1,D[4]||0,D[5]||0,D[6]||0,B)}}return new Date(E)})($),this.init()},A.init=function(){var $=this.$d;this.$y=$.getFullYear(),this.$M=$.getMonth(),this.$D=$.getDate(),this.$W=$.getDay(),this.$H=$.getHours(),this.$m=$.getMinutes(),this.$s=$.getSeconds(),this.$ms=$.getMilliseconds()},A.$utils=function(){return L},A.isValid=function(){return this.$d.toString()!==m},A.isSame=function($,w){var E=k($);return this.startOf(w)<=E&&E<=this.endOf(w)},A.isAfter=function($,w){return k($)<this.startOf(w)},A.isBefore=function($,w){return this.endOf(w)<k($)},A.$g=function($,w,E){return L.u($)?this[w]:this.set(E,$)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function($,w){var E=this,R=!!L.u(w)||w,D=L.p($),G=function(K,X){var q=L.w(E.$u?Date.UTC(E.$y,X,K):new Date(E.$y,X,K),E);return R?q:q.endOf(l)},B=function(K,X){return L.w(E.toDate()[K].apply(E.toDate("s"),(R?[0,0,0,0]:[23,59,59,999]).slice(X)),E)},H=this.$W,U=this.$M,j=this.$D,z="set"+(this.$u?"UTC":"");switch(D){case g:return R?G(1,0):G(31,11);case p:return R?G(1,U):G(0,U+1);case d:var I=this.$locale().weekStart||0,W=(H<I?H+7:H)-I;return G(R?j-W:j+(6-W),U);case l:case f:return B(z+"Hours",0);case h:return B(z+"Minutes",1);case o:return B(z+"Seconds",2);case a:return B(z+"Milliseconds",3);default:return this.clone()}},A.endOf=function($){return this.startOf($,!1)},A.$set=function($,w){var E,R=L.p($),D="set"+(this.$u?"UTC":""),G=(E={},E[l]=D+"Date",E[f]=D+"Date",E[p]=D+"Month",E[g]=D+"FullYear",E[h]=D+"Hours",E[o]=D+"Minutes",E[a]=D+"Seconds",E[r]=D+"Milliseconds",E)[R],B=R===l?this.$D+(w-this.$W):w;if(R===p||R===g){var H=this.clone().set(f,1);H.$d[G](B),H.init(),this.$d=H.set(f,Math.min(this.$D,H.daysInMonth())).$d}else G&&this.$d[G](B);return this.init(),this},A.set=function($,w){return this.clone().$set($,w)},A.get=function($){return this[L.p($)]()},A.add=function($,w){var E,R=this;$=Number($);var D=L.p(w),G=function(U){var j=k(R);return L.w(j.date(j.date()+Math.round(U*$)),R)};if(D===p)return this.set(p,this.$M+$);if(D===g)return this.set(g,this.$y+$);if(D===l)return G(1);if(D===d)return G(7);var B=(E={},E[o]=s,E[h]=n,E[a]=e,E)[D]||1,H=this.$d.getTime()+$*B;return L.w(H,this)},A.subtract=function($,w){return this.add(-1*$,w)},A.format=function($){var w=this,E=this.$locale();if(!this.isValid())return E.invalidDate||m;var R=$||"YYYY-MM-DDTHH:mm:ssZ",D=L.z(this),G=this.$H,B=this.$m,H=this.$M,U=E.weekdays,j=E.months,z=E.meridiem,I=function(X,q,J,Z){return X&&(X[q]||X(w,R))||J[q].slice(0,Z)},W=function(X){return L.s(G%12||12,X,"0")},K=z||function(X,q,J){var Z=X<12?"AM":"PM";return J?Z.toLowerCase():Z};return R.replace(S,(function(X,q){return q||(function(J){switch(J){case"YY":return String(w.$y).slice(-2);case"YYYY":return L.s(w.$y,4,"0");case"M":return H+1;case"MM":return L.s(H+1,2,"0");case"MMM":return I(E.monthsShort,H,j,3);case"MMMM":return I(j,H);case"D":return w.$D;case"DD":return L.s(w.$D,2,"0");case"d":return String(w.$W);case"dd":return I(E.weekdaysMin,w.$W,U,2);case"ddd":return I(E.weekdaysShort,w.$W,U,3);case"dddd":return U[w.$W];case"H":return String(G);case"HH":return L.s(G,2,"0");case"h":return W(1);case"hh":return W(2);case"a":return K(G,B,!0);case"A":return K(G,B,!1);case"m":return String(B);case"mm":return L.s(B,2,"0");case"s":return String(w.$s);case"ss":return L.s(w.$s,2,"0");case"SSS":return L.s(w.$ms,3,"0");case"Z":return D}return null})(X)||D.replace(":","")}))},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function($,w,E){var R,D=this,G=L.p(w),B=k($),H=(B.utcOffset()-this.utcOffset())*s,U=this-B,j=function(){return L.m(D,B)};switch(G){case g:R=j()/12;break;case p:R=j();break;case u:R=j()/3;break;case d:R=(U-H)/6048e5;break;case l:R=(U-H)/864e5;break;case h:R=U/n;break;case o:R=U/s;break;case a:R=U/e;break;default:R=U}return E?R:L.a(R)},A.daysInMonth=function(){return this.endOf(p).$D},A.$locale=function(){return T[this.$L]},A.locale=function($,w){if(!$)return this.$L;var E=this.clone(),R=C($,w,!0);return R&&(E.$L=R),E},A.clone=function(){return L.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},P})(),N=F.prototype;return k.prototype=N,[["$ms",r],["$s",a],["$m",o],["$H",h],["$W",l],["$M",p],["$y",g],["$D",f]].forEach((function(P){N[P[1]]=function(A){return this.$g(A,P[0],P[1])}})),k.extend=function(P,A){return P.$i||(P(A,F,k),P.$i=!0),k},k.locale=C,k.isDayjs=_,k.unix=function(P){return k(1e3*P)},k.en=T[x],k.Ls=T,k.p={},k}))})(gi)),gi.exports}var Io=Po();const et=br(Io);var xr=typeof global=="object"&&global&&global.Object===Object&&global,Go=typeof self=="object"&&self&&self.Object===Object&&self,Nt=xr||Go||Function("return this")(),Dt=Nt.Symbol,_r=Object.prototype,Fo=_r.hasOwnProperty,No=_r.toString,fe=Dt?Dt.toStringTag:void 0;function Ho(i){var t=Fo.call(i,fe),e=i[fe];try{i[fe]=void 0;var s=!0}catch{}var n=No.call(i);return s&&(t?i[fe]=e:delete i[fe]),n}var $o=Object.prototype,Bo=$o.toString;function Uo(i){return Bo.call(i)}var Wo="[object Null]",zo="[object Undefined]",Ls=Dt?Dt.toStringTag:void 0;function Ut(i){return i==null?i===void 0?zo:Wo:Ls&&Ls in Object(i)?Ho(i):Uo(i)}function Lt(i){return i!=null&&typeof i=="object"}var Vo="[object Symbol]";function wi(i){return typeof i=="symbol"||Lt(i)&&Ut(i)==Vo}function wr(i,t){for(var e=-1,s=i==null?0:i.length,n=Array(s);++e<s;)n[e]=t(i[e],e,i);return n}var ft=Array.isArray,As=Dt?Dt.prototype:void 0,Ds=As?As.toString:void 0;function Sr(i){if(typeof i=="string")return i;if(ft(i))return wr(i,Sr)+"";if(wi(i))return Ds?Ds.call(i):"";var t=i+"";return t=="0"&&1/i==-1/0?"-0":t}var Yo=/\s/;function jo(i){for(var t=i.length;t--&&Yo.test(i.charAt(t)););return t}var Ko=/^\s+/;function Xo(i){return i&&i.slice(0,jo(i)+1).replace(Ko,"")}function _t(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Rs=NaN,qo=/^[-+]0x[0-9a-f]+$/i,Qo=/^0b[01]+$/i,Jo=/^0o[0-7]+$/i,Zo=parseInt;function Ps(i){if(typeof i=="number")return i;if(wi(i))return Rs;if(_t(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=_t(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Xo(i);var e=Qo.test(i);return e||Jo.test(i)?Zo(i.slice(2),e?2:8):qo.test(i)?Rs:+i}function as(i){return i}var ta="[object AsyncFunction]",ea="[object Function]",ia="[object GeneratorFunction]",sa="[object Proxy]";function Bt(i){if(!_t(i))return!1;var t=Ut(i);return t==ea||t==ia||t==ta||t==sa}var Di=Nt["__core-js_shared__"],Is=(function(){var i=/[^.]+$/.exec(Di&&Di.keys&&Di.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function na(i){return!!Is&&Is in i}var ra=Function.prototype,oa=ra.toString;function ee(i){if(i!=null){try{return oa.call(i)}catch{}try{return i+""}catch{}}return""}var aa=/[\\^$.*+?()[\]{}|]/g,ha=/^\[object .+?Constructor\]$/,la=Function.prototype,ca=Object.prototype,da=la.toString,ua=ca.hasOwnProperty,fa=RegExp("^"+da.call(ua).replace(aa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ga(i){if(!_t(i)||na(i))return!1;var t=Bt(i)?fa:ha;return t.test(ee(i))}function pa(i,t){return i==null?void 0:i[t]}function ie(i,t){var e=pa(i,t);return ga(e)?e:void 0}var Xi=ie(Nt,"WeakMap"),Gs=Object.create,ma=(function(){function i(){}return function(t){if(!_t(t))return{};if(Gs)return Gs(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}})();function ya(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}function Tr(i,t){var e=-1,s=i.length;for(t||(t=Array(s));++e<s;)t[e]=i[e];return t}var va=800,ba=16,xa=Date.now;function _a(i){var t=0,e=0;return function(){var s=xa(),n=ba-(s-e);if(e=s,n>0){if(++t>=va)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}function wa(i){return function(){return i}}var vi=(function(){try{var i=ie(Object,"defineProperty");return i({},"",{}),i}catch{}})(),Sa=vi?function(i,t){return vi(i,"toString",{configurable:!0,enumerable:!1,value:wa(t),writable:!0})}:as,Cr=_a(Sa);function Ta(i,t){for(var e=-1,s=i==null?0:i.length;++e<s&&t(i[e],e,i)!==!1;);return i}var Ca=9007199254740991,ka=/^(?:0|[1-9]\d*)$/;function Si(i,t){var e=typeof i;return t=t??Ca,!!t&&(e=="number"||e!="symbol"&&ka.test(i))&&i>-1&&i%1==0&&i<t}function hs(i,t,e){t=="__proto__"&&vi?vi(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}function hi(i,t){return i===t||i!==i&&t!==t}var Ea=Object.prototype,Ma=Ea.hasOwnProperty;function kr(i,t,e){var s=i[t];(!(Ma.call(i,t)&&hi(s,e))||e===void 0&&!(t in i))&&hs(i,t,e)}function ce(i,t,e,s){var n=!e;e||(e={});for(var r=-1,a=t.length;++r<a;){var o=t[r],h=void 0;h===void 0&&(h=i[o]),n?hs(e,o,h):kr(e,o,h)}return e}var Fs=Math.max;function Er(i,t,e){return t=Fs(t===void 0?i.length-1:t,0),function(){for(var s=arguments,n=-1,r=Fs(s.length-t,0),a=Array(r);++n<r;)a[n]=s[t+n];n=-1;for(var o=Array(t+1);++n<t;)o[n]=s[n];return o[t]=e(a),ya(i,this,o)}}function Oa(i,t){return Cr(Er(i,t,as),i+"")}var La=9007199254740991;function ls(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=La}function Ti(i){return i!=null&&ls(i.length)&&!Bt(i)}function Aa(i,t,e){if(!_t(e))return!1;var s=typeof t;return(s=="number"?Ti(e)&&Si(t,e.length):s=="string"&&t in e)?hi(e[t],i):!1}function Da(i){return Oa(function(t,e){var s=-1,n=e.length,r=n>1?e[n-1]:void 0,a=n>2?e[2]:void 0;for(r=i.length>3&&typeof r=="function"?(n--,r):void 0,a&&Aa(e[0],e[1],a)&&(r=n<3?void 0:r,n=1),t=Object(t);++s<n;){var o=e[s];o&&i(t,o,s,r)}return t})}var Ra=Object.prototype;function cs(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Ra;return i===e}function Pa(i,t){for(var e=-1,s=Array(i);++e<i;)s[e]=t(e);return s}var Ia="[object Arguments]";function Ns(i){return Lt(i)&&Ut(i)==Ia}var Mr=Object.prototype,Ga=Mr.hasOwnProperty,Fa=Mr.propertyIsEnumerable,si=Ns((function(){return arguments})())?Ns:function(i){return Lt(i)&&Ga.call(i,"callee")&&!Fa.call(i,"callee")};function Na(){return!1}var Or=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Hs=Or&&typeof module=="object"&&module&&!module.nodeType&&module,Ha=Hs&&Hs.exports===Or,$s=Ha?Nt.Buffer:void 0,$a=$s?$s.isBuffer:void 0,ni=$a||Na,Ba="[object Arguments]",Ua="[object Array]",Wa="[object Boolean]",za="[object Date]",Va="[object Error]",Ya="[object Function]",ja="[object Map]",Ka="[object Number]",Xa="[object Object]",qa="[object RegExp]",Qa="[object Set]",Ja="[object String]",Za="[object WeakMap]",th="[object ArrayBuffer]",eh="[object DataView]",ih="[object Float32Array]",sh="[object Float64Array]",nh="[object Int8Array]",rh="[object Int16Array]",oh="[object Int32Array]",ah="[object Uint8Array]",hh="[object Uint8ClampedArray]",lh="[object Uint16Array]",ch="[object Uint32Array]",dt={};dt[ih]=dt[sh]=dt[nh]=dt[rh]=dt[oh]=dt[ah]=dt[hh]=dt[lh]=dt[ch]=!0;dt[Ba]=dt[Ua]=dt[th]=dt[Wa]=dt[eh]=dt[za]=dt[Va]=dt[Ya]=dt[ja]=dt[Ka]=dt[Xa]=dt[qa]=dt[Qa]=dt[Ja]=dt[Za]=!1;function dh(i){return Lt(i)&&ls(i.length)&&!!dt[Ut(i)]}function ds(i){return function(t){return i(t)}}var Lr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ei=Lr&&typeof module=="object"&&module&&!module.nodeType&&module,uh=ei&&ei.exports===Lr,Ri=uh&&xr.process,ae=(function(){try{var i=ei&&ei.require&&ei.require("util").types;return i||Ri&&Ri.binding&&Ri.binding("util")}catch{}})(),Bs=ae&&ae.isTypedArray,us=Bs?ds(Bs):dh,fh=Object.prototype,gh=fh.hasOwnProperty;function Ar(i,t){var e=ft(i),s=!e&&si(i),n=!e&&!s&&ni(i),r=!e&&!s&&!n&&us(i),a=e||s||n||r,o=a?Pa(i.length,String):[],h=o.length;for(var l in i)(t||gh.call(i,l))&&!(a&&(l=="length"||n&&(l=="offset"||l=="parent")||r&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Si(l,h)))&&o.push(l);return o}function Dr(i,t){return function(e){return i(t(e))}}var ph=Dr(Object.keys,Object),mh=Object.prototype,yh=mh.hasOwnProperty;function vh(i){if(!cs(i))return ph(i);var t=[];for(var e in Object(i))yh.call(i,e)&&e!="constructor"&&t.push(e);return t}function Ci(i){return Ti(i)?Ar(i):vh(i)}function bh(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var xh=Object.prototype,_h=xh.hasOwnProperty;function wh(i){if(!_t(i))return bh(i);var t=cs(i),e=[];for(var s in i)s=="constructor"&&(t||!_h.call(i,s))||e.push(s);return e}function li(i){return Ti(i)?Ar(i,!0):wh(i)}var Sh=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Th=/^\w*$/;function fs(i,t){if(ft(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||wi(i)?!0:Th.test(i)||!Sh.test(i)||t!=null&&i in Object(t)}var ri=ie(Object,"create");function Ch(){this.__data__=ri?ri(null):{},this.size=0}function kh(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var Eh="__lodash_hash_undefined__",Mh=Object.prototype,Oh=Mh.hasOwnProperty;function Lh(i){var t=this.__data__;if(ri){var e=t[i];return e===Eh?void 0:e}return Oh.call(t,i)?t[i]:void 0}var Ah=Object.prototype,Dh=Ah.hasOwnProperty;function Rh(i){var t=this.__data__;return ri?t[i]!==void 0:Dh.call(t,i)}var Ph="__lodash_hash_undefined__";function Ih(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=ri&&t===void 0?Ph:t,this}function Zt(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}Zt.prototype.clear=Ch;Zt.prototype.delete=kh;Zt.prototype.get=Lh;Zt.prototype.has=Rh;Zt.prototype.set=Ih;function Gh(){this.__data__=[],this.size=0}function ki(i,t){for(var e=i.length;e--;)if(hi(i[e][0],t))return e;return-1}var Fh=Array.prototype,Nh=Fh.splice;function Hh(i){var t=this.__data__,e=ki(t,i);if(e<0)return!1;var s=t.length-1;return e==s?t.pop():Nh.call(t,e,1),--this.size,!0}function $h(i){var t=this.__data__,e=ki(t,i);return e<0?void 0:t[e][1]}function Bh(i){return ki(this.__data__,i)>-1}function Uh(i,t){var e=this.__data__,s=ki(e,i);return s<0?(++this.size,e.push([i,t])):e[s][1]=t,this}function Vt(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}Vt.prototype.clear=Gh;Vt.prototype.delete=Hh;Vt.prototype.get=$h;Vt.prototype.has=Bh;Vt.prototype.set=Uh;var oi=ie(Nt,"Map");function Wh(){this.size=0,this.__data__={hash:new Zt,map:new(oi||Vt),string:new Zt}}function zh(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}function Ei(i,t){var e=i.__data__;return zh(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Vh(i){var t=Ei(this,i).delete(i);return this.size-=t?1:0,t}function Yh(i){return Ei(this,i).get(i)}function jh(i){return Ei(this,i).has(i)}function Kh(i,t){var e=Ei(this,i),s=e.size;return e.set(i,t),this.size+=e.size==s?0:1,this}function Yt(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}Yt.prototype.clear=Wh;Yt.prototype.delete=Vh;Yt.prototype.get=Yh;Yt.prototype.has=jh;Yt.prototype.set=Kh;var Xh="Expected a function";function gs(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(Xh);var e=function(){var s=arguments,n=t?t.apply(this,s):s[0],r=e.cache;if(r.has(n))return r.get(n);var a=i.apply(this,s);return e.cache=r.set(n,a)||r,a};return e.cache=new(gs.Cache||Yt),e}gs.Cache=Yt;var qh=500;function Qh(i){var t=gs(i,function(s){return e.size===qh&&e.clear(),s}),e=t.cache;return t}var Jh=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Zh=/\\(\\)?/g,tl=Qh(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(Jh,function(e,s,n,r){t.push(n?r.replace(Zh,"$1"):s||e)}),t});function el(i){return i==null?"":Sr(i)}function Mi(i,t){return ft(i)?i:fs(i,t)?[i]:tl(el(i))}function he(i){if(typeof i=="string"||wi(i))return i;var t=i+"";return t=="0"&&1/i==-1/0?"-0":t}function ps(i,t){t=Mi(t,i);for(var e=0,s=t.length;i!=null&&e<s;)i=i[he(t[e++])];return e&&e==s?i:void 0}function il(i,t,e){var s=i==null?void 0:ps(i,t);return s===void 0?e:s}function ms(i,t){for(var e=-1,s=t.length,n=i.length;++e<s;)i[n+e]=t[e];return i}var Us=Dt?Dt.isConcatSpreadable:void 0;function sl(i){return ft(i)||si(i)||!!(Us&&i&&i[Us])}function nl(i,t,e,s,n){var r=-1,a=i.length;for(e||(e=sl),n||(n=[]);++r<a;){var o=i[r];e(o)?ms(n,o):n[n.length]=o}return n}function rl(i){var t=i==null?0:i.length;return t?nl(i):[]}function ol(i){return Cr(Er(i,void 0,rl),i+"")}var ys=Dr(Object.getPrototypeOf,Object),al="[object Object]",hl=Function.prototype,ll=Object.prototype,Rr=hl.toString,cl=ll.hasOwnProperty,dl=Rr.call(Object);function Pr(i){if(!Lt(i)||Ut(i)!=al)return!1;var t=ys(i);if(t===null)return!0;var e=cl.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Rr.call(e)==dl}function ul(i,t,e){var s=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var r=Array(n);++s<n;)r[s]=i[s+t];return r}function fl(){this.__data__=new Vt,this.size=0}function gl(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}function pl(i){return this.__data__.get(i)}function ml(i){return this.__data__.has(i)}var yl=200;function vl(i,t){var e=this.__data__;if(e instanceof Vt){var s=e.__data__;if(!oi||s.length<yl-1)return s.push([i,t]),this.size=++e.size,this;e=this.__data__=new Yt(s)}return e.set(i,t),this.size=e.size,this}function Gt(i){var t=this.__data__=new Vt(i);this.size=t.size}Gt.prototype.clear=fl;Gt.prototype.delete=gl;Gt.prototype.get=pl;Gt.prototype.has=ml;Gt.prototype.set=vl;function bl(i,t){return i&&ce(t,Ci(t),i)}function xl(i,t){return i&&ce(t,li(t),i)}var Ir=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ws=Ir&&typeof module=="object"&&module&&!module.nodeType&&module,_l=Ws&&Ws.exports===Ir,zs=_l?Nt.Buffer:void 0,Vs=zs?zs.allocUnsafe:void 0;function Gr(i,t){if(t)return i.slice();var e=i.length,s=Vs?Vs(e):new i.constructor(e);return i.copy(s),s}function wl(i,t){for(var e=-1,s=i==null?0:i.length,n=0,r=[];++e<s;){var a=i[e];t(a,e,i)&&(r[n++]=a)}return r}function Fr(){return[]}var Sl=Object.prototype,Tl=Sl.propertyIsEnumerable,Ys=Object.getOwnPropertySymbols,vs=Ys?function(i){return i==null?[]:(i=Object(i),wl(Ys(i),function(t){return Tl.call(i,t)}))}:Fr;function Cl(i,t){return ce(i,vs(i),t)}var kl=Object.getOwnPropertySymbols,Nr=kl?function(i){for(var t=[];i;)ms(t,vs(i)),i=ys(i);return t}:Fr;function El(i,t){return ce(i,Nr(i),t)}function Hr(i,t,e){var s=t(i);return ft(i)?s:ms(s,e(i))}function qi(i){return Hr(i,Ci,vs)}function $r(i){return Hr(i,li,Nr)}var Qi=ie(Nt,"DataView"),Ji=ie(Nt,"Promise"),Zi=ie(Nt,"Set"),js="[object Map]",Ml="[object Object]",Ks="[object Promise]",Xs="[object Set]",qs="[object WeakMap]",Qs="[object DataView]",Ol=ee(Qi),Ll=ee(oi),Al=ee(Ji),Dl=ee(Zi),Rl=ee(Xi),It=Ut;(Qi&&It(new Qi(new ArrayBuffer(1)))!=Qs||oi&&It(new oi)!=js||Ji&&It(Ji.resolve())!=Ks||Zi&&It(new Zi)!=Xs||Xi&&It(new Xi)!=qs)&&(It=function(i){var t=Ut(i),e=t==Ml?i.constructor:void 0,s=e?ee(e):"";if(s)switch(s){case Ol:return Qs;case Ll:return js;case Al:return Ks;case Dl:return Xs;case Rl:return qs}return t});var Pl=Object.prototype,Il=Pl.hasOwnProperty;function Gl(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&Il.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var bi=Nt.Uint8Array;function bs(i){var t=new i.constructor(i.byteLength);return new bi(t).set(new bi(i)),t}function Fl(i,t){var e=t?bs(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var Nl=/\w*$/;function Hl(i){var t=new i.constructor(i.source,Nl.exec(i));return t.lastIndex=i.lastIndex,t}var Js=Dt?Dt.prototype:void 0,Zs=Js?Js.valueOf:void 0;function $l(i){return Zs?Object(Zs.call(i)):{}}function Br(i,t){var e=t?bs(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Bl="[object Boolean]",Ul="[object Date]",Wl="[object Map]",zl="[object Number]",Vl="[object RegExp]",Yl="[object Set]",jl="[object String]",Kl="[object Symbol]",Xl="[object ArrayBuffer]",ql="[object DataView]",Ql="[object Float32Array]",Jl="[object Float64Array]",Zl="[object Int8Array]",tc="[object Int16Array]",ec="[object Int32Array]",ic="[object Uint8Array]",sc="[object Uint8ClampedArray]",nc="[object Uint16Array]",rc="[object Uint32Array]";function oc(i,t,e){var s=i.constructor;switch(t){case Xl:return bs(i);case Bl:case Ul:return new s(+i);case ql:return Fl(i,e);case Ql:case Jl:case Zl:case tc:case ec:case ic:case sc:case nc:case rc:return Br(i,e);case Wl:return new s;case zl:case jl:return new s(i);case Vl:return Hl(i);case Yl:return new s;case Kl:return $l(i)}}function Ur(i){return typeof i.constructor=="function"&&!cs(i)?ma(ys(i)):{}}var ac="[object Map]";function hc(i){return Lt(i)&&It(i)==ac}var tn=ae&&ae.isMap,lc=tn?ds(tn):hc,cc="[object Set]";function dc(i){return Lt(i)&&It(i)==cc}var en=ae&&ae.isSet,uc=en?ds(en):dc,fc=1,gc=2,pc=4,Wr="[object Arguments]",mc="[object Array]",yc="[object Boolean]",vc="[object Date]",bc="[object Error]",zr="[object Function]",xc="[object GeneratorFunction]",_c="[object Map]",wc="[object Number]",Vr="[object Object]",Sc="[object RegExp]",Tc="[object Set]",Cc="[object String]",kc="[object Symbol]",Ec="[object WeakMap]",Mc="[object ArrayBuffer]",Oc="[object DataView]",Lc="[object Float32Array]",Ac="[object Float64Array]",Dc="[object Int8Array]",Rc="[object Int16Array]",Pc="[object Int32Array]",Ic="[object Uint8Array]",Gc="[object Uint8ClampedArray]",Fc="[object Uint16Array]",Nc="[object Uint32Array]",ct={};ct[Wr]=ct[mc]=ct[Mc]=ct[Oc]=ct[yc]=ct[vc]=ct[Lc]=ct[Ac]=ct[Dc]=ct[Rc]=ct[Pc]=ct[_c]=ct[wc]=ct[Vr]=ct[Sc]=ct[Tc]=ct[Cc]=ct[kc]=ct[Ic]=ct[Gc]=ct[Fc]=ct[Nc]=!0;ct[bc]=ct[zr]=ct[Ec]=!1;function ii(i,t,e,s,n,r){var a,o=t&fc,h=t&gc,l=t&pc;if(e&&(a=n?e(i,s,n,r):e(i)),a!==void 0)return a;if(!_t(i))return i;var d=ft(i);if(d){if(a=Gl(i),!o)return Tr(i,a)}else{var p=It(i),u=p==zr||p==xc;if(ni(i))return Gr(i,o);if(p==Vr||p==Wr||u&&!n){if(a=h||u?{}:Ur(i),!o)return h?El(i,xl(a,i)):Cl(i,bl(a,i))}else{if(!ct[p])return n?i:{};a=oc(i,p,o)}}r||(r=new Gt);var g=r.get(i);if(g)return g;r.set(i,a),uc(i)?i.forEach(function(b){a.add(ii(b,t,e,b,i,r))}):lc(i)&&i.forEach(function(b,S){a.set(S,ii(b,t,e,S,i,r))});var f=l?h?$r:qi:h?li:Ci,m=d?void 0:f(i);return Ta(m||i,function(b,S){m&&(S=b,b=i[S]),kr(a,S,ii(b,t,e,S,i,r))}),a}var Hc=1,$c=4;function le(i){return ii(i,Hc|$c)}var Bc="__lodash_hash_undefined__";function Uc(i){return this.__data__.set(i,Bc),this}function Wc(i){return this.__data__.has(i)}function xi(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Yt;++t<e;)this.add(i[t])}xi.prototype.add=xi.prototype.push=Uc;xi.prototype.has=Wc;function zc(i,t){for(var e=-1,s=i==null?0:i.length;++e<s;)if(t(i[e],e,i))return!0;return!1}function Vc(i,t){return i.has(t)}var Yc=1,jc=2;function Yr(i,t,e,s,n,r){var a=e&Yc,o=i.length,h=t.length;if(o!=h&&!(a&&h>o))return!1;var l=r.get(i),d=r.get(t);if(l&&d)return l==t&&d==i;var p=-1,u=!0,g=e&jc?new xi:void 0;for(r.set(i,t),r.set(t,i);++p<o;){var f=i[p],m=t[p];if(s)var b=a?s(m,f,p,t,i,r):s(f,m,p,i,t,r);if(b!==void 0){if(b)continue;u=!1;break}if(g){if(!zc(t,function(S,y){if(!Vc(g,y)&&(f===S||n(f,S,e,s,r)))return g.push(y)})){u=!1;break}}else if(!(f===m||n(f,m,e,s,r))){u=!1;break}}return r.delete(i),r.delete(t),u}function Kc(i){var t=-1,e=Array(i.size);return i.forEach(function(s,n){e[++t]=[n,s]}),e}function Xc(i){var t=-1,e=Array(i.size);return i.forEach(function(s){e[++t]=s}),e}var qc=1,Qc=2,Jc="[object Boolean]",Zc="[object Date]",td="[object Error]",ed="[object Map]",id="[object Number]",sd="[object RegExp]",nd="[object Set]",rd="[object String]",od="[object Symbol]",ad="[object ArrayBuffer]",hd="[object DataView]",sn=Dt?Dt.prototype:void 0,Pi=sn?sn.valueOf:void 0;function ld(i,t,e,s,n,r,a){switch(e){case hd:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case ad:return!(i.byteLength!=t.byteLength||!r(new bi(i),new bi(t)));case Jc:case Zc:case id:return hi(+i,+t);case td:return i.name==t.name&&i.message==t.message;case sd:case rd:return i==t+"";case ed:var o=Kc;case nd:var h=s&qc;if(o||(o=Xc),i.size!=t.size&&!h)return!1;var l=a.get(i);if(l)return l==t;s|=Qc,a.set(i,t);var d=Yr(o(i),o(t),s,n,r,a);return a.delete(i),d;case od:if(Pi)return Pi.call(i)==Pi.call(t)}return!1}var cd=1,dd=Object.prototype,ud=dd.hasOwnProperty;function fd(i,t,e,s,n,r){var a=e&cd,o=qi(i),h=o.length,l=qi(t),d=l.length;if(h!=d&&!a)return!1;for(var p=h;p--;){var u=o[p];if(!(a?u in t:ud.call(t,u)))return!1}var g=r.get(i),f=r.get(t);if(g&&f)return g==t&&f==i;var m=!0;r.set(i,t),r.set(t,i);for(var b=a;++p<h;){u=o[p];var S=i[u],y=t[u];if(s)var c=a?s(y,S,u,t,i,r):s(S,y,u,i,t,r);if(!(c===void 0?S===y||n(S,y,e,s,r):c)){m=!1;break}b||(b=u=="constructor")}if(m&&!b){var v=i.constructor,x=t.constructor;v!=x&&"constructor"in i&&"constructor"in t&&!(typeof v=="function"&&v instanceof v&&typeof x=="function"&&x instanceof x)&&(m=!1)}return r.delete(i),r.delete(t),m}var gd=1,nn="[object Arguments]",rn="[object Array]",di="[object Object]",pd=Object.prototype,on=pd.hasOwnProperty;function md(i,t,e,s,n,r){var a=ft(i),o=ft(t),h=a?rn:It(i),l=o?rn:It(t);h=h==nn?di:h,l=l==nn?di:l;var d=h==di,p=l==di,u=h==l;if(u&&ni(i)){if(!ni(t))return!1;a=!0,d=!1}if(u&&!d)return r||(r=new Gt),a||us(i)?Yr(i,t,e,s,n,r):ld(i,t,h,e,s,n,r);if(!(e&gd)){var g=d&&on.call(i,"__wrapped__"),f=p&&on.call(t,"__wrapped__");if(g||f){var m=g?i.value():i,b=f?t.value():t;return r||(r=new Gt),n(m,b,e,s,r)}}return u?(r||(r=new Gt),fd(i,t,e,s,n,r)):!1}function xs(i,t,e,s,n){return i===t?!0:i==null||t==null||!Lt(i)&&!Lt(t)?i!==i&&t!==t:md(i,t,e,s,xs,n)}var yd=1,vd=2;function bd(i,t,e,s){var n=e.length,r=n;if(i==null)return!r;for(i=Object(i);n--;){var a=e[n];if(a[2]?a[1]!==i[a[0]]:!(a[0]in i))return!1}for(;++n<r;){a=e[n];var o=a[0],h=i[o],l=a[1];if(a[2]){if(h===void 0&&!(o in i))return!1}else{var d=new Gt,p;if(!(p===void 0?xs(l,h,yd|vd,s,d):p))return!1}}return!0}function jr(i){return i===i&&!_t(i)}function xd(i){for(var t=Ci(i),e=t.length;e--;){var s=t[e],n=i[s];t[e]=[s,n,jr(n)]}return t}function Kr(i,t){return function(e){return e==null?!1:e[i]===t&&(t!==void 0||i in Object(e))}}function _d(i){var t=xd(i);return t.length==1&&t[0][2]?Kr(t[0][0],t[0][1]):function(e){return e===i||bd(e,i,t)}}function wd(i,t){return i!=null&&t in Object(i)}function Sd(i,t,e){t=Mi(t,i);for(var s=-1,n=t.length,r=!1;++s<n;){var a=he(t[s]);if(!(r=i!=null&&e(i,a)))break;i=i[a]}return r||++s!=n?r:(n=i==null?0:i.length,!!n&&ls(n)&&Si(a,n)&&(ft(i)||si(i)))}function Td(i,t){return i!=null&&Sd(i,t,wd)}var Cd=1,kd=2;function Ed(i,t){return fs(i)&&jr(t)?Kr(he(i),t):function(e){var s=il(e,i);return s===void 0&&s===t?Td(e,i):xs(t,s,Cd|kd)}}function Md(i){return function(t){return t==null?void 0:t[i]}}function Od(i){return function(t){return ps(t,i)}}function Ld(i){return fs(i)?Md(he(i)):Od(i)}function Ad(i){return typeof i=="function"?i:i==null?as:typeof i=="object"?ft(i)?Ed(i[0],i[1]):_d(i):Ld(i)}function Dd(i){return function(t,e,s){for(var n=-1,r=Object(t),a=s(t),o=a.length;o--;){var h=a[++n];if(e(r[h],h,r)===!1)break}return t}}var Rd=Dd(),Ii=function(){return Nt.Date.now()},Pd="Expected a function",Id=Math.max,Gd=Math.min;function Xr(i,t,e){var s,n,r,a,o,h,l=0,d=!1,p=!1,u=!0;if(typeof i!="function")throw new TypeError(Pd);t=Ps(t)||0,_t(e)&&(d=!!e.leading,p="maxWait"in e,r=p?Id(Ps(e.maxWait)||0,t):r,u="trailing"in e?!!e.trailing:u);function g(T){var O=s,_=n;return s=n=void 0,l=T,a=i.apply(_,O),a}function f(T){return l=T,o=setTimeout(S,t),d?g(T):a}function m(T){var O=T-h,_=T-l,C=t-O;return p?Gd(C,r-_):C}function b(T){var O=T-h,_=T-l;return h===void 0||O>=t||O<0||p&&_>=r}function S(){var T=Ii();if(b(T))return y(T);o=setTimeout(S,m(T))}function y(T){return o=void 0,u&&s?g(T):(s=n=void 0,a)}function c(){o!==void 0&&clearTimeout(o),l=0,s=h=n=o=void 0}function v(){return o===void 0?a:y(Ii())}function x(){var T=Ii(),O=b(T);if(s=arguments,n=this,h=T,O){if(o===void 0)return f(h);if(p)return clearTimeout(o),o=setTimeout(S,t),g(h)}return o===void 0&&(o=setTimeout(S,t)),a}return x.cancel=c,x.flush=v,x}function ts(i,t,e){(e!==void 0&&!hi(i[t],e)||e===void 0&&!(t in i))&&hs(i,t,e)}function Fd(i){return Lt(i)&&Ti(i)}function es(i,t){if(!(t==="constructor"&&typeof i[t]=="function")&&t!="__proto__")return i[t]}function Nd(i){return ce(i,li(i))}function Hd(i,t,e,s,n,r,a){var o=es(i,e),h=es(t,e),l=a.get(h);if(l){ts(i,e,l);return}var d=r?r(o,h,e+"",i,t,a):void 0,p=d===void 0;if(p){var u=ft(h),g=!u&&ni(h),f=!u&&!g&&us(h);d=h,u||g||f?ft(o)?d=o:Fd(o)?d=Tr(o):g?(p=!1,d=Gr(h,!0)):f?(p=!1,d=Br(h,!0)):d=[]:Pr(h)||si(h)?(d=o,si(o)?d=Nd(o):(!_t(o)||Bt(o))&&(d=Ur(h))):p=!1}p&&(a.set(h,d),n(d,h,s,r,a),a.delete(h)),ts(i,e,d)}function qr(i,t,e,s,n){i!==t&&Rd(t,function(r,a){if(n||(n=new Gt),_t(r))Hd(i,t,a,e,qr,s,n);else{var o=s?s(es(i,a),r,a+"",i,t,n):void 0;o===void 0&&(o=r),ts(i,a,o)}},li)}function $d(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var Bd="[object String]";function Ft(i){return typeof i=="string"||!ft(i)&&Lt(i)&&Ut(i)==Bd}function Ud(i,t){return t.length<2?i:ps(i,ul(t,0,-1))}var Wd="[object Boolean]";function Gi(i){return i===!0||i===!1||Lt(i)&&Ut(i)==Wd}var zd="[object Number]";function an(i){return typeof i=="number"||Lt(i)&&Ut(i)==zd}var _i=Da(function(i,t,e){qr(i,t,e)}),Vd=Object.prototype,Yd=Vd.hasOwnProperty;function Qr(i,t){t=Mi(t,i);var e=-1,s=t.length;if(!s)return!0;for(;++e<s;){var n=he(t[e]);if(n==="__proto__"&&!Yd.call(i,"__proto__")||(n==="constructor"||n==="prototype")&&e<s-1)return!1}var r=Ud(i,t);return r==null||delete r[he($d(t))]}function jd(i){return Pr(i)?void 0:i}var Kd=1,Xd=2,qd=4,hn=ol(function(i,t){var e={};if(i==null)return e;var s=!1;t=wr(t,function(r){return r=Mi(r,i),s||(s=r.length>1),r}),ce(i,$r(i),e),s&&(e=ii(e,Kd|Xd|qd,jd));for(var n=t.length;n--;)Qr(e,t[n]);return e}),Qd=Array.prototype,Jd=Qd.splice;function Zd(i,t){for(var e=i?t.length:0,s=e-1;e--;){var n=t[e];if(e==s||n!==r){var r=n;Si(n)?Jd.call(i,n,1):Qr(i,n)}}return i}function ui(i,t){var e=[];if(!(i&&i.length))return e;var s=-1,n=[],r=i.length;for(t=Ad(t);++s<r;){var a=i[s];t(a,s,i)&&(e.push(a),n.push(s))}return Zd(i,n),e}var tu="Expected a function";function ln(i,t,e){var s=!0,n=!0;if(typeof i!="function")throw new TypeError(tu);return _t(e)&&(s="leading"in e?!!e.leading:s,n="trailing"in e?!!e.trailing:n),Xr(i,t,{leading:s,maxWait:t,trailing:n})}var pi={exports:{}},ge={},Fi={},Ni={},cn;function it(){return cn||(cn=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i._registerNode=i.Konva=i.glob=void 0;const t=Math.PI/180;function e(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}i.glob=typeof Ms<"u"?Ms:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},i.Konva={_global:i.glob,version:"9.3.22",isBrowser:e(),isUnminified:/param/.test((function(n){}).toString()),dblClickWindow:400,getAngle(n){return i.Konva.angleDeg?n*t:n},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return i.Konva.DD.isDragging},isTransforming(){var n;return(n=i.Konva.Transformer)===null||n===void 0?void 0:n.isTransforming()},isDragReady(){return!!i.Konva.DD.node},releaseCanvasOnDestroy:!0,document:i.glob.document,_injectGlobal(n){i.glob.Konva=n}};const s=n=>{i.Konva[n.prototype.getClassName()]=n};i._registerNode=s,i.Konva._injectGlobal(i.Konva)})(Ni)),Ni}var Hi={},dn;function gt(){return dn||(dn=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Util=i.Transform=void 0;const t=it();class e{constructor(v=[1,0,0,1,0,0]){this.dirty=!1,this.m=v&&v.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(v){v.m[0]=this.m[0],v.m[1]=this.m[1],v.m[2]=this.m[2],v.m[3]=this.m[3],v.m[4]=this.m[4],v.m[5]=this.m[5]}point(v){const x=this.m;return{x:x[0]*v.x+x[2]*v.y+x[4],y:x[1]*v.x+x[3]*v.y+x[5]}}translate(v,x){return this.m[4]+=this.m[0]*v+this.m[2]*x,this.m[5]+=this.m[1]*v+this.m[3]*x,this}scale(v,x){return this.m[0]*=v,this.m[1]*=v,this.m[2]*=x,this.m[3]*=x,this}rotate(v){const x=Math.cos(v),T=Math.sin(v),O=this.m[0]*x+this.m[2]*T,_=this.m[1]*x+this.m[3]*T,C=this.m[0]*-T+this.m[2]*x,k=this.m[1]*-T+this.m[3]*x;return this.m[0]=O,this.m[1]=_,this.m[2]=C,this.m[3]=k,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(v,x){const T=this.m[0]+this.m[2]*x,O=this.m[1]+this.m[3]*x,_=this.m[2]+this.m[0]*v,C=this.m[3]+this.m[1]*v;return this.m[0]=T,this.m[1]=O,this.m[2]=_,this.m[3]=C,this}multiply(v){const x=this.m[0]*v.m[0]+this.m[2]*v.m[1],T=this.m[1]*v.m[0]+this.m[3]*v.m[1],O=this.m[0]*v.m[2]+this.m[2]*v.m[3],_=this.m[1]*v.m[2]+this.m[3]*v.m[3],C=this.m[0]*v.m[4]+this.m[2]*v.m[5]+this.m[4],k=this.m[1]*v.m[4]+this.m[3]*v.m[5]+this.m[5];return this.m[0]=x,this.m[1]=T,this.m[2]=O,this.m[3]=_,this.m[4]=C,this.m[5]=k,this}invert(){const v=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),x=this.m[3]*v,T=-this.m[1]*v,O=-this.m[2]*v,_=this.m[0]*v,C=v*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),k=v*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=x,this.m[1]=T,this.m[2]=O,this.m[3]=_,this.m[4]=C,this.m[5]=k,this}getMatrix(){return this.m}decompose(){const v=this.m[0],x=this.m[1],T=this.m[2],O=this.m[3],_=this.m[4],C=this.m[5],k=v*O-x*T,L={x:_,y:C,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(v!=0||x!=0){const F=Math.sqrt(v*v+x*x);L.rotation=x>0?Math.acos(v/F):-Math.acos(v/F),L.scaleX=F,L.scaleY=k/F,L.skewX=(v*T+x*O)/k,L.skewY=0}else if(T!=0||O!=0){const F=Math.sqrt(T*T+O*O);L.rotation=Math.PI/2-(O>0?Math.acos(-T/F):-Math.acos(T/F)),L.scaleX=k/F,L.scaleY=F,L.skewX=0,L.skewY=(v*T+x*O)/k}return L.rotation=i.Util._getRotation(L.rotation),L}}i.Transform=e;const s="[object Array]",n="[object Number]",r="[object String]",a="[object Boolean]",o=Math.PI/180,h=180/Math.PI,l="#",d="",p="0",u="Konva warning: ",g="Konva error: ",f="rgb(",m={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},b=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let S=[];const y=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(c){setTimeout(c,60)};i.Util={_isElement(c){return!!(c&&c.nodeType==1)},_isFunction(c){return!!(c&&c.constructor&&c.call&&c.apply)},_isPlainObject(c){return!!c&&c.constructor===Object},_isArray(c){return Object.prototype.toString.call(c)===s},_isNumber(c){return Object.prototype.toString.call(c)===n&&!isNaN(c)&&isFinite(c)},_isString(c){return Object.prototype.toString.call(c)===r},_isBoolean(c){return Object.prototype.toString.call(c)===a},isObject(c){return c instanceof Object},isValidSelector(c){if(typeof c!="string")return!1;const v=c[0];return v==="#"||v==="."||v===v.toUpperCase()},_sign(c){return c===0||c>0?1:-1},requestAnimFrame(c){S.push(c),S.length===1&&y(function(){const v=S;S=[],v.forEach(function(x){x()})})},createCanvasElement(){const c=document.createElement("canvas");try{c.style=c.style||{}}catch{}return c},createImageElement(){return document.createElement("img")},_isInDocument(c){for(;c=c.parentNode;)if(c==document)return!0;return!1},_urlToImage(c,v){const x=i.Util.createImageElement();x.onload=function(){v(x)},x.src=c},_rgbToHex(c,v,x){return((1<<24)+(c<<16)+(v<<8)+x).toString(16).slice(1)},_hexToRgb(c){c=c.replace(l,d);const v=parseInt(c,16);return{r:v>>16&255,g:v>>8&255,b:v&255}},getRandomColor(){let c=(Math.random()*16777215<<0).toString(16);for(;c.length<6;)c=p+c;return l+c},getRGB(c){let v;return c in m?(v=m[c],{r:v[0],g:v[1],b:v[2]}):c[0]===l?this._hexToRgb(c.substring(1)):c.substr(0,4)===f?(v=b.exec(c.replace(/ /g,"")),{r:parseInt(v[1],10),g:parseInt(v[2],10),b:parseInt(v[3],10)}):{r:0,g:0,b:0}},colorToRGBA(c){return c=c||"black",i.Util._namedColorToRBA(c)||i.Util._hex3ColorToRGBA(c)||i.Util._hex4ColorToRGBA(c)||i.Util._hex6ColorToRGBA(c)||i.Util._hex8ColorToRGBA(c)||i.Util._rgbColorToRGBA(c)||i.Util._rgbaColorToRGBA(c)||i.Util._hslColorToRGBA(c)},_namedColorToRBA(c){const v=m[c.toLowerCase()];return v?{r:v[0],g:v[1],b:v[2],a:1}:null},_rgbColorToRGBA(c){if(c.indexOf("rgb(")===0){c=c.match(/rgb\(([^)]+)\)/)[1];const v=c.split(/ *, */).map(Number);return{r:v[0],g:v[1],b:v[2],a:1}}},_rgbaColorToRGBA(c){if(c.indexOf("rgba(")===0){c=c.match(/rgba\(([^)]+)\)/)[1];const v=c.split(/ *, */).map((x,T)=>x.slice(-1)==="%"?T===3?parseInt(x)/100:parseInt(x)/100*255:Number(x));return{r:v[0],g:v[1],b:v[2],a:v[3]}}},_hex8ColorToRGBA(c){if(c[0]==="#"&&c.length===9)return{r:parseInt(c.slice(1,3),16),g:parseInt(c.slice(3,5),16),b:parseInt(c.slice(5,7),16),a:parseInt(c.slice(7,9),16)/255}},_hex6ColorToRGBA(c){if(c[0]==="#"&&c.length===7)return{r:parseInt(c.slice(1,3),16),g:parseInt(c.slice(3,5),16),b:parseInt(c.slice(5,7),16),a:1}},_hex4ColorToRGBA(c){if(c[0]==="#"&&c.length===5)return{r:parseInt(c[1]+c[1],16),g:parseInt(c[2]+c[2],16),b:parseInt(c[3]+c[3],16),a:parseInt(c[4]+c[4],16)/255}},_hex3ColorToRGBA(c){if(c[0]==="#"&&c.length===4)return{r:parseInt(c[1]+c[1],16),g:parseInt(c[2]+c[2],16),b:parseInt(c[3]+c[3],16),a:1}},_hslColorToRGBA(c){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(c)){const[v,...x]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(c),T=Number(x[0])/360,O=Number(x[1])/100,_=Number(x[2])/100;let C,k,L;if(O===0)return L=_*255,{r:Math.round(L),g:Math.round(L),b:Math.round(L),a:1};_<.5?C=_*(1+O):C=_+O-_*O;const F=2*_-C,N=[0,0,0];for(let P=0;P<3;P++)k=T+1/3*-(P-1),k<0&&k++,k>1&&k--,6*k<1?L=F+(C-F)*6*k:2*k<1?L=C:3*k<2?L=F+(C-F)*(2/3-k)*6:L=F,N[P]=L*255;return{r:Math.round(N[0]),g:Math.round(N[1]),b:Math.round(N[2]),a:1}}},haveIntersection(c,v){return!(v.x>c.x+c.width||v.x+v.width<c.x||v.y>c.y+c.height||v.y+v.height<c.y)},cloneObject(c){const v={};for(const x in c)this._isPlainObject(c[x])?v[x]=this.cloneObject(c[x]):this._isArray(c[x])?v[x]=this.cloneArray(c[x]):v[x]=c[x];return v},cloneArray(c){return c.slice(0)},degToRad(c){return c*o},radToDeg(c){return c*h},_degToRad(c){return i.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),i.Util.degToRad(c)},_radToDeg(c){return i.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),i.Util.radToDeg(c)},_getRotation(c){return t.Konva.angleDeg?i.Util.radToDeg(c):c},_capitalize(c){return c.charAt(0).toUpperCase()+c.slice(1)},throw(c){throw new Error(g+c)},error(c){console.error(g+c)},warn(c){t.Konva.showWarnings&&console.warn(u+c)},each(c,v){for(const x in c)v(x,c[x])},_inRange(c,v,x){return v<=c&&c<x},_getProjectionToSegment(c,v,x,T,O,_){let C,k,L;const F=(c-x)*(c-x)+(v-T)*(v-T);if(F==0)C=c,k=v,L=(O-x)*(O-x)+(_-T)*(_-T);else{const N=((O-c)*(x-c)+(_-v)*(T-v))/F;N<0?(C=c,k=v,L=(c-O)*(c-O)+(v-_)*(v-_)):N>1?(C=x,k=T,L=(x-O)*(x-O)+(T-_)*(T-_)):(C=c+N*(x-c),k=v+N*(T-v),L=(C-O)*(C-O)+(k-_)*(k-_))}return[C,k,L]},_getProjectionToLine(c,v,x){const T=i.Util.cloneObject(c);let O=Number.MAX_VALUE;return v.forEach(function(_,C){if(!x&&C===v.length-1)return;const k=v[(C+1)%v.length],L=i.Util._getProjectionToSegment(_.x,_.y,k.x,k.y,c.x,c.y),F=L[0],N=L[1],P=L[2];P<O&&(T.x=F,T.y=N,O=P)}),T},_prepareArrayForTween(c,v,x){const T=[],O=[];if(c.length>v.length){const C=v;v=c,c=C}for(let C=0;C<c.length;C+=2)T.push({x:c[C],y:c[C+1]});for(let C=0;C<v.length;C+=2)O.push({x:v[C],y:v[C+1]});const _=[];return O.forEach(function(C){const k=i.Util._getProjectionToLine(C,T,x);_.push(k.x),_.push(k.y)}),_},_prepareToStringify(c){let v;c.visitedByCircularReferenceRemoval=!0;for(const x in c)if(c.hasOwnProperty(x)&&c[x]&&typeof c[x]=="object"){if(v=Object.getOwnPropertyDescriptor(c,x),c[x].visitedByCircularReferenceRemoval||i.Util._isElement(c[x]))if(v.configurable)delete c[x];else return null;else if(i.Util._prepareToStringify(c[x])===null)if(v.configurable)delete c[x];else return null}return delete c.visitedByCircularReferenceRemoval,c},_assign(c,v){for(const x in v)c[x]=v[x];return c},_getFirstPointerId(c){return c.touches?c.changedTouches[0].identifier:c.pointerId||999},releaseCanvas(...c){t.Konva.releaseCanvasOnDestroy&&c.forEach(v=>{v.width=0,v.height=0})},drawRoundedRectPath(c,v,x,T){let O=0,_=0,C=0,k=0;typeof T=="number"?O=_=C=k=Math.min(T,v/2,x/2):(O=Math.min(T[0]||0,v/2,x/2),_=Math.min(T[1]||0,v/2,x/2),k=Math.min(T[2]||0,v/2,x/2),C=Math.min(T[3]||0,v/2,x/2)),c.moveTo(O,0),c.lineTo(v-_,0),c.arc(v-_,_,_,Math.PI*3/2,0,!1),c.lineTo(v,x-k),c.arc(v-k,x-k,k,0,Math.PI/2,!1),c.lineTo(C,x),c.arc(C,x-C,C,Math.PI/2,Math.PI,!1),c.lineTo(0,O),c.arc(O,O,O,Math.PI,Math.PI*3/2,!1)}}})(Hi)),Hi}var pe={},Wt={},zt={},un;function Jr(){if(un)return zt;un=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.HitContext=zt.SceneContext=zt.Context=void 0;const i=gt(),t=it();function e(S){const y=[],c=S.length,v=i.Util;for(let x=0;x<c;x++){let T=S[x];v._isNumber(T)?T=Math.round(T*1e3)/1e3:v._isString(T)||(T=T+""),y.push(T)}return y}const s=",",n="(",r=")",a="([",o="])",h=";",l="()",d="=",p=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],u=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"],g=100;let f=class{constructor(y){this.canvas=y,t.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(y){y.fillEnabled()&&this._fill(y)}_fill(y){}strokeShape(y){y.hasStroke()&&this._stroke(y)}_stroke(y){}fillStrokeShape(y){y.attrs.fillAfterStrokeEnabled?(this.strokeShape(y),this.fillShape(y)):(this.fillShape(y),this.strokeShape(y))}getTrace(y,c){let v=this.traceArr,x=v.length,T="",O,_,C,k;for(O=0;O<x;O++)_=v[O],C=_.method,C?(k=_.args,T+=C,y?T+=l:i.Util._isArray(k[0])?T+=a+k.join(s)+o:(c&&(k=k.map(L=>typeof L=="number"?Math.floor(L):L)),T+=n+k.join(s)+r)):(T+=_.property,y||(T+=d+_.val)),T+=h;return T}clearTrace(){this.traceArr=[]}_trace(y){let c=this.traceArr,v;c.push(y),v=c.length,v>=g&&c.shift()}reset(){const y=this.getCanvas().getPixelRatio();this.setTransform(1*y,0,0,1*y,0,0)}getCanvas(){return this.canvas}clear(y){const c=this.getCanvas();y?this.clearRect(y.x||0,y.y||0,y.width||0,y.height||0):this.clearRect(0,0,c.getWidth()/c.pixelRatio,c.getHeight()/c.pixelRatio)}_applyLineCap(y){const c=y.attrs.lineCap;c&&this.setAttr("lineCap",c)}_applyOpacity(y){const c=y.getAbsoluteOpacity();c!==1&&this.setAttr("globalAlpha",c)}_applyLineJoin(y){const c=y.attrs.lineJoin;c&&this.setAttr("lineJoin",c)}setAttr(y,c){this._context[y]=c}arc(y,c,v,x,T,O){this._context.arc(y,c,v,x,T,O)}arcTo(y,c,v,x,T){this._context.arcTo(y,c,v,x,T)}beginPath(){this._context.beginPath()}bezierCurveTo(y,c,v,x,T,O){this._context.bezierCurveTo(y,c,v,x,T,O)}clearRect(y,c,v,x){this._context.clearRect(y,c,v,x)}clip(...y){this._context.clip.apply(this._context,y)}closePath(){this._context.closePath()}createImageData(y,c){const v=arguments;if(v.length===2)return this._context.createImageData(y,c);if(v.length===1)return this._context.createImageData(y)}createLinearGradient(y,c,v,x){return this._context.createLinearGradient(y,c,v,x)}createPattern(y,c){return this._context.createPattern(y,c)}createRadialGradient(y,c,v,x,T,O){return this._context.createRadialGradient(y,c,v,x,T,O)}drawImage(y,c,v,x,T,O,_,C,k){const L=arguments,F=this._context;L.length===3?F.drawImage(y,c,v):L.length===5?F.drawImage(y,c,v,x,T):L.length===9&&F.drawImage(y,c,v,x,T,O,_,C,k)}ellipse(y,c,v,x,T,O,_,C){this._context.ellipse(y,c,v,x,T,O,_,C)}isPointInPath(y,c,v,x){return v?this._context.isPointInPath(v,y,c,x):this._context.isPointInPath(y,c,x)}fill(...y){this._context.fill.apply(this._context,y)}fillRect(y,c,v,x){this._context.fillRect(y,c,v,x)}strokeRect(y,c,v,x){this._context.strokeRect(y,c,v,x)}fillText(y,c,v,x){x?this._context.fillText(y,c,v,x):this._context.fillText(y,c,v)}measureText(y){return this._context.measureText(y)}getImageData(y,c,v,x){return this._context.getImageData(y,c,v,x)}lineTo(y,c){this._context.lineTo(y,c)}moveTo(y,c){this._context.moveTo(y,c)}rect(y,c,v,x){this._context.rect(y,c,v,x)}roundRect(y,c,v,x,T){this._context.roundRect(y,c,v,x,T)}putImageData(y,c,v){this._context.putImageData(y,c,v)}quadraticCurveTo(y,c,v,x){this._context.quadraticCurveTo(y,c,v,x)}restore(){this._context.restore()}rotate(y){this._context.rotate(y)}save(){this._context.save()}scale(y,c){this._context.scale(y,c)}setLineDash(y){this._context.setLineDash?this._context.setLineDash(y):"mozDash"in this._context?this._context.mozDash=y:"webkitLineDash"in this._context&&(this._context.webkitLineDash=y)}getLineDash(){return this._context.getLineDash()}setTransform(y,c,v,x,T,O){this._context.setTransform(y,c,v,x,T,O)}stroke(y){y?this._context.stroke(y):this._context.stroke()}strokeText(y,c,v,x){this._context.strokeText(y,c,v,x)}transform(y,c,v,x,T,O){this._context.transform(y,c,v,x,T,O)}translate(y,c){this._context.translate(y,c)}_enableTrace(){let y=this,c=p.length,v=this.setAttr,x,T;const O=function(_){let C=y[_],k;y[_]=function(){return T=e(Array.prototype.slice.call(arguments,0)),k=C.apply(y,arguments),y._trace({method:_,args:T}),k}};for(x=0;x<c;x++)O(p[x]);y.setAttr=function(){v.apply(y,arguments);const _=arguments[0];let C=arguments[1];(_==="shadowOffsetX"||_==="shadowOffsetY"||_==="shadowBlur")&&(C=C/this.canvas.getPixelRatio()),y._trace({property:_,val:C})}}_applyGlobalCompositeOperation(y){const c=y.attrs.globalCompositeOperation;!c||c==="source-over"||this.setAttr("globalCompositeOperation",c)}};zt.Context=f,u.forEach(function(S){Object.defineProperty(f.prototype,S,{get(){return this._context[S]},set(y){this._context[S]=y}})});class m extends f{constructor(y,{willReadFrequently:c=!1}={}){super(y),this._context=y._canvas.getContext("2d",{willReadFrequently:c})}_fillColor(y){const c=y.fill();this.setAttr("fillStyle",c),y._fillFunc(this)}_fillPattern(y){this.setAttr("fillStyle",y._getFillPattern()),y._fillFunc(this)}_fillLinearGradient(y){const c=y._getLinearGradient();c&&(this.setAttr("fillStyle",c),y._fillFunc(this))}_fillRadialGradient(y){const c=y._getRadialGradient();c&&(this.setAttr("fillStyle",c),y._fillFunc(this))}_fill(y){const c=y.fill(),v=y.getFillPriority();if(c&&v==="color"){this._fillColor(y);return}const x=y.getFillPatternImage();if(x&&v==="pattern"){this._fillPattern(y);return}const T=y.getFillLinearGradientColorStops();if(T&&v==="linear-gradient"){this._fillLinearGradient(y);return}const O=y.getFillRadialGradientColorStops();if(O&&v==="radial-gradient"){this._fillRadialGradient(y);return}c?this._fillColor(y):x?this._fillPattern(y):T?this._fillLinearGradient(y):O&&this._fillRadialGradient(y)}_strokeLinearGradient(y){const c=y.getStrokeLinearGradientStartPoint(),v=y.getStrokeLinearGradientEndPoint(),x=y.getStrokeLinearGradientColorStops(),T=this.createLinearGradient(c.x,c.y,v.x,v.y);if(x){for(let O=0;O<x.length;O+=2)T.addColorStop(x[O],x[O+1]);this.setAttr("strokeStyle",T)}}_stroke(y){const c=y.dash(),v=y.getStrokeScaleEnabled();if(y.hasStroke()){if(!v){this.save();const T=this.getCanvas().getPixelRatio();this.setTransform(T,0,0,T,0,0)}this._applyLineCap(y),c&&y.dashEnabled()&&(this.setLineDash(c),this.setAttr("lineDashOffset",y.dashOffset())),this.setAttr("lineWidth",y.strokeWidth()),y.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),y.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(y):this.setAttr("strokeStyle",y.stroke()),y._strokeFunc(this),v||this.restore()}}_applyShadow(y){var c,v,x;const T=(c=y.getShadowRGBA())!==null&&c!==void 0?c:"black",O=(v=y.getShadowBlur())!==null&&v!==void 0?v:5,_=(x=y.getShadowOffset())!==null&&x!==void 0?x:{x:0,y:0},C=y.getAbsoluteScale(),k=this.canvas.getPixelRatio(),L=C.x*k,F=C.y*k;this.setAttr("shadowColor",T),this.setAttr("shadowBlur",O*Math.min(Math.abs(L),Math.abs(F))),this.setAttr("shadowOffsetX",_.x*L),this.setAttr("shadowOffsetY",_.y*F)}}zt.SceneContext=m;class b extends f{constructor(y){super(y),this._context=y._canvas.getContext("2d",{willReadFrequently:!0})}_fill(y){this.save(),this.setAttr("fillStyle",y.colorKey),y._fillFuncHit(this),this.restore()}strokeShape(y){y.hasHitStroke()&&this._stroke(y)}_stroke(y){if(y.hasHitStroke()){const c=y.getStrokeScaleEnabled();if(!c){this.save();const T=this.getCanvas().getPixelRatio();this.setTransform(T,0,0,T,0,0)}this._applyLineCap(y);const v=y.hitStrokeWidth(),x=v==="auto"?y.strokeWidth():v;this.setAttr("lineWidth",x),this.setAttr("strokeStyle",y.colorKey),y._strokeFuncHit(this),c||this.restore()}}}return zt.HitContext=b,zt}var fn;function Oi(){if(fn)return Wt;fn=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.HitCanvas=Wt.SceneCanvas=Wt.Canvas=void 0;const i=gt(),t=Jr(),e=it();let s;function n(){if(s)return s;const h=i.Util.createCanvasElement(),l=h.getContext("2d");return s=(function(){const d=e.Konva._global.devicePixelRatio||1,p=l.webkitBackingStorePixelRatio||l.mozBackingStorePixelRatio||l.msBackingStorePixelRatio||l.oBackingStorePixelRatio||l.backingStorePixelRatio||1;return d/p})(),i.Util.releaseCanvas(h),s}let r=class{constructor(l){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const p=(l||{}).pixelRatio||e.Konva.pixelRatio||n();this.pixelRatio=p,this._canvas=i.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(l){const d=this.pixelRatio;this.pixelRatio=l,this.setSize(this.getWidth()/d,this.getHeight()/d)}setWidth(l){this.width=this._canvas.width=l*this.pixelRatio,this._canvas.style.width=l+"px";const d=this.pixelRatio;this.getContext()._context.scale(d,d)}setHeight(l){this.height=this._canvas.height=l*this.pixelRatio,this._canvas.style.height=l+"px";const d=this.pixelRatio;this.getContext()._context.scale(d,d)}getWidth(){return this.width}getHeight(){return this.height}setSize(l,d){this.setWidth(l||0),this.setHeight(d||0)}toDataURL(l,d){try{return this._canvas.toDataURL(l,d)}catch{try{return this._canvas.toDataURL()}catch(u){return i.Util.error("Unable to get data URL. "+u.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};Wt.Canvas=r;class a extends r{constructor(l={width:0,height:0,willReadFrequently:!1}){super(l),this.context=new t.SceneContext(this,{willReadFrequently:l.willReadFrequently}),this.setSize(l.width,l.height)}}Wt.SceneCanvas=a;class o extends r{constructor(l={width:0,height:0}){super(l),this.hitCanvas=!0,this.context=new t.HitContext(this),this.setSize(l.width,l.height)}}return Wt.HitCanvas=o,Wt}var $i={},gn;function _s(){return gn||(gn=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.DD=void 0;const t=it(),e=gt();i.DD={get isDragging(){let s=!1;return i.DD._dragElements.forEach(n=>{n.dragStatus==="dragging"&&(s=!0)}),s},justDragged:!1,get node(){let s;return i.DD._dragElements.forEach(n=>{s=n.node}),s},_dragElements:new Map,_drag(s){const n=[];i.DD._dragElements.forEach((r,a)=>{const{node:o}=r,h=o.getStage();h.setPointersPositions(s),r.pointerId===void 0&&(r.pointerId=e.Util._getFirstPointerId(s));const l=h._changedPointerPositions.find(d=>d.id===r.pointerId);if(l){if(r.dragStatus!=="dragging"){const d=o.dragDistance();if(Math.max(Math.abs(l.x-r.startPointerPos.x),Math.abs(l.y-r.startPointerPos.y))<d||(o.startDrag({evt:s}),!o.isDragging()))return}o._setDragPosition(s,r),n.push(o)}}),n.forEach(r=>{r.fire("dragmove",{type:"dragmove",target:r,evt:s},!0)})},_endDragBefore(s){const n=[];i.DD._dragElements.forEach(r=>{const{node:a}=r,o=a.getStage();if(s&&o.setPointersPositions(s),!o._changedPointerPositions.find(d=>d.id===r.pointerId))return;(r.dragStatus==="dragging"||r.dragStatus==="stopped")&&(i.DD.justDragged=!0,t.Konva._mouseListenClick=!1,t.Konva._touchListenClick=!1,t.Konva._pointerListenClick=!1,r.dragStatus="stopped");const l=r.node.getLayer()||r.node instanceof t.Konva.Stage&&r.node;l&&n.indexOf(l)===-1&&n.push(l)}),n.forEach(r=>{r.draw()})},_endDragAfter(s){i.DD._dragElements.forEach((n,r)=>{n.dragStatus==="stopped"&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:s},!0),n.dragStatus!=="dragging"&&i.DD._dragElements.delete(r)})}},t.Konva.isBrowser&&(window.addEventListener("mouseup",i.DD._endDragBefore,!0),window.addEventListener("touchend",i.DD._endDragBefore,!0),window.addEventListener("touchcancel",i.DD._endDragBefore,!0),window.addEventListener("mousemove",i.DD._drag),window.addEventListener("touchmove",i.DD._drag),window.addEventListener("mouseup",i.DD._endDragAfter,!1),window.addEventListener("touchend",i.DD._endDragAfter,!1),window.addEventListener("touchcancel",i.DD._endDragAfter,!1))})($i)),$i}var Bi={},kt={},pn;function nt(){if(pn)return kt;pn=1,Object.defineProperty(kt,"__esModule",{value:!0}),kt.RGBComponent=s,kt.alphaComponent=n,kt.getNumberValidator=r,kt.getNumberOrArrayOfNumbersValidator=a,kt.getNumberOrAutoValidator=o,kt.getStringValidator=h,kt.getStringOrGradientValidator=l,kt.getFunctionValidator=d,kt.getNumberArrayValidator=p,kt.getBooleanValidator=u,kt.getComponentValidator=g;const i=it(),t=gt();function e(f){return t.Util._isString(f)?'"'+f+'"':Object.prototype.toString.call(f)==="[object Number]"||t.Util._isBoolean(f)?f:Object.prototype.toString.call(f)}function s(f){return f>255?255:f<0?0:Math.round(f)}function n(f){return f>1?1:f<1e-4?1e-4:f}function r(){if(i.Konva.isUnminified)return function(f,m){return t.Util._isNumber(f)||t.Util.warn(e(f)+' is a not valid value for "'+m+'" attribute. The value should be a number.'),f}}function a(f){if(i.Konva.isUnminified)return function(m,b){let S=t.Util._isNumber(m),y=t.Util._isArray(m)&&m.length==f;return!S&&!y&&t.Util.warn(e(m)+' is a not valid value for "'+b+'" attribute. The value should be a number or Array<number>('+f+")"),m}}function o(){if(i.Konva.isUnminified)return function(f,m){return t.Util._isNumber(f)||f==="auto"||t.Util.warn(e(f)+' is a not valid value for "'+m+'" attribute. The value should be a number or "auto".'),f}}function h(){if(i.Konva.isUnminified)return function(f,m){return t.Util._isString(f)||t.Util.warn(e(f)+' is a not valid value for "'+m+'" attribute. The value should be a string.'),f}}function l(){if(i.Konva.isUnminified)return function(f,m){const b=t.Util._isString(f),S=Object.prototype.toString.call(f)==="[object CanvasGradient]"||f&&f.addColorStop;return b||S||t.Util.warn(e(f)+' is a not valid value for "'+m+'" attribute. The value should be a string or a native gradient.'),f}}function d(){if(i.Konva.isUnminified)return function(f,m){return t.Util._isFunction(f)||t.Util.warn(e(f)+' is a not valid value for "'+m+'" attribute. The value should be a function.'),f}}function p(){if(i.Konva.isUnminified)return function(f,m){const b=Int8Array?Object.getPrototypeOf(Int8Array):null;return b&&f instanceof b||(t.Util._isArray(f)?f.forEach(function(S){t.Util._isNumber(S)||t.Util.warn('"'+m+'" attribute has non numeric element '+S+". Make sure that all elements are numbers.")}):t.Util.warn(e(f)+' is a not valid value for "'+m+'" attribute. The value should be a array of numbers.')),f}}function u(){if(i.Konva.isUnminified)return function(f,m){return f===!0||f===!1||t.Util.warn(e(f)+' is a not valid value for "'+m+'" attribute. The value should be a boolean.'),f}}function g(f){if(i.Konva.isUnminified)return function(m,b){return m==null||t.Util.isObject(m)||t.Util.warn(e(m)+' is a not valid value for "'+b+'" attribute. The value should be an object with properties '+f),m}}return kt}var mn;function st(){return mn||(mn=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Factory=void 0;const t=gt(),e=nt(),s="get",n="set";i.Factory={addGetterSetter(r,a,o,h,l){i.Factory.addGetter(r,a,o),i.Factory.addSetter(r,a,h,l),i.Factory.addOverloadedGetterSetter(r,a)},addGetter(r,a,o){const h=s+t.Util._capitalize(a);r.prototype[h]=r.prototype[h]||function(){const l=this.attrs[a];return l===void 0?o:l}},addSetter(r,a,o,h){const l=n+t.Util._capitalize(a);r.prototype[l]||i.Factory.overWriteSetter(r,a,o,h)},overWriteSetter(r,a,o,h){const l=n+t.Util._capitalize(a);r.prototype[l]=function(d){return o&&d!==void 0&&d!==null&&(d=o.call(this,d,a)),this._setAttr(a,d),h&&h.call(this),this}},addComponentsGetterSetter(r,a,o,h,l){const d=o.length,p=t.Util._capitalize,u=s+p(a),g=n+p(a);r.prototype[u]=function(){const m={};for(let b=0;b<d;b++){const S=o[b];m[S]=this.getAttr(a+p(S))}return m};const f=(0,e.getComponentValidator)(o);r.prototype[g]=function(m){const b=this.attrs[a];h&&(m=h.call(this,m,a)),f&&f.call(this,m,a);for(const S in m)m.hasOwnProperty(S)&&this._setAttr(a+p(S),m[S]);return m||o.forEach(S=>{this._setAttr(a+p(S),void 0)}),this._fireChangeEvent(a,b,m),l&&l.call(this),this},i.Factory.addOverloadedGetterSetter(r,a)},addOverloadedGetterSetter(r,a){const o=t.Util._capitalize(a),h=n+o,l=s+o;r.prototype[a]=function(){return arguments.length?(this[h](arguments[0]),this):this[l]()}},addDeprecatedGetterSetter(r,a,o,h){t.Util.error("Adding deprecated "+a);const l=s+t.Util._capitalize(a),d=a+" property is deprecated and will be removed soon. Look at Konva change log for more information.";r.prototype[l]=function(){t.Util.error(d);const p=this.attrs[a];return p===void 0?o:p},i.Factory.addSetter(r,a,h,function(){t.Util.error(d)}),i.Factory.addOverloadedGetterSetter(r,a)},backCompat(r,a){t.Util.each(a,function(o,h){const l=r.prototype[h],d=s+t.Util._capitalize(o),p=n+t.Util._capitalize(o);function u(){l.apply(this,arguments),t.Util.error('"'+o+'" method is deprecated and will be removed soon. Use ""'+h+'" instead.')}r.prototype[o]=u,r.prototype[d]=u,r.prototype[p]=u})},afterSetFilter(){this._filterUpToDate=!1}}})(Bi)),Bi}var yn;function mt(){if(yn)return pe;yn=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.Node=void 0;const i=Oi(),t=_s(),e=st(),s=it(),n=gt(),r=nt(),a="absoluteOpacity",o="allEventListeners",h="absoluteTransform",l="absoluteScale",d="canvas",p="Change",u="children",g="konva",f="listening",m="mouseenter",b="mouseleave",S="pointerenter",y="pointerleave",c="touchenter",v="touchleave",x="set",T="Shape",O=" ",_="stage",C="transform",k="Stage",L="visible",F=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(O);let N=1,P=class is{constructor(w){this._id=N++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(w),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(w){(w===C||w===h)&&this._cache.get(w)?this._cache.get(w).dirty=!0:w?this._cache.delete(w):this._cache.clear()}_getCache(w,E){let R=this._cache.get(w);return(R===void 0||(w===C||w===h)&&R.dirty===!0)&&(R=E.call(this),this._cache.set(w,R)),R}_calculate(w,E,R){if(!this._attachedDepsListeners.get(w)){const D=E.map(G=>G+"Change.konva").join(O);this.on(D,()=>{this._clearCache(w)}),this._attachedDepsListeners.set(w,!0)}return this._getCache(w,R)}_getCanvasCache(){return this._cache.get(d)}_clearSelfAndDescendantCache(w){this._clearCache(w),w===h&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(d)){const{scene:w,filter:E,hit:R,buffer:D}=this._cache.get(d);n.Util.releaseCanvas(w,E,R,D),this._cache.delete(d)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(w){const E=w||{};let R={};(E.x===void 0||E.y===void 0||E.width===void 0||E.height===void 0)&&(R=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let D=Math.ceil(E.width||R.width),G=Math.ceil(E.height||R.height),B=E.pixelRatio,H=E.x===void 0?Math.floor(R.x):E.x,U=E.y===void 0?Math.floor(R.y):E.y,j=E.offset||0,z=E.drawBorder||!1,I=E.hitCanvasPixelRatio||1;if(!D||!G){n.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const W=Math.abs(Math.round(R.x)-H)>.5?1:0,K=Math.abs(Math.round(R.y)-U)>.5?1:0;D+=j*2+W,G+=j*2+K,H-=j,U-=j;const X=new i.SceneCanvas({pixelRatio:B,width:D,height:G}),q=new i.SceneCanvas({pixelRatio:B,width:0,height:0,willReadFrequently:!0}),J=new i.HitCanvas({pixelRatio:I,width:D,height:G}),Z=X.getContext(),ot=J.getContext(),tt=new i.SceneCanvas({width:X.width/X.pixelRatio+Math.abs(H),height:X.height/X.pixelRatio+Math.abs(U),pixelRatio:X.pixelRatio}),vt=tt.getContext();return J.isCache=!0,X.isCache=!0,this._cache.delete(d),this._filterUpToDate=!1,E.imageSmoothingEnabled===!1&&(X.getContext()._context.imageSmoothingEnabled=!1,q.getContext()._context.imageSmoothingEnabled=!1),Z.save(),ot.save(),vt.save(),Z.translate(-H,-U),ot.translate(-H,-U),vt.translate(-H,-U),tt.x=H,tt.y=U,this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(l),this.drawScene(X,this,tt),this.drawHit(J,this),this._isUnderCache=!1,Z.restore(),ot.restore(),z&&(Z.save(),Z.beginPath(),Z.rect(0,0,D,G),Z.closePath(),Z.setAttr("strokeStyle","red"),Z.setAttr("lineWidth",5),Z.stroke(),Z.restore()),this._cache.set(d,{scene:X,filter:q,hit:J,buffer:tt,x:H,y:U}),this._requestDraw(),this}isCached(){return this._cache.has(d)}getClientRect(w){throw new Error('abstract "getClientRect" method call')}_transformedRect(w,E){const R=[{x:w.x,y:w.y},{x:w.x+w.width,y:w.y},{x:w.x+w.width,y:w.y+w.height},{x:w.x,y:w.y+w.height}];let D=1/0,G=1/0,B=-1/0,H=-1/0;const U=this.getAbsoluteTransform(E);return R.forEach(function(j){const z=U.point(j);D===void 0&&(D=B=z.x,G=H=z.y),D=Math.min(D,z.x),G=Math.min(G,z.y),B=Math.max(B,z.x),H=Math.max(H,z.y)}),{x:D,y:G,width:B-D,height:H-G}}_drawCachedSceneCanvas(w){w.save(),w._applyOpacity(this),w._applyGlobalCompositeOperation(this);const E=this._getCanvasCache();w.translate(E.x,E.y);const R=this._getCachedSceneCanvas(),D=R.pixelRatio;w.drawImage(R._canvas,0,0,R.width/D,R.height/D),w.restore()}_drawCachedHitCanvas(w){const E=this._getCanvasCache(),R=E.hit;w.save(),w.translate(E.x,E.y),w.drawImage(R._canvas,0,0,R.width/R.pixelRatio,R.height/R.pixelRatio),w.restore()}_getCachedSceneCanvas(){let w=this.filters(),E=this._getCanvasCache(),R=E.scene,D=E.filter,G=D.getContext(),B,H,U,j;if(w){if(!this._filterUpToDate){const z=R.pixelRatio;D.setSize(R.width/R.pixelRatio,R.height/R.pixelRatio);try{for(B=w.length,G.clear(),G.drawImage(R._canvas,0,0,R.getWidth()/z,R.getHeight()/z),H=G.getImageData(0,0,D.getWidth(),D.getHeight()),U=0;U<B;U++){if(j=w[U],typeof j!="function"){n.Util.error("Filter should be type of function, but got "+typeof j+" instead. Please check correct filters");continue}j.call(this,H),G.putImageData(H,0,0)}}catch(I){n.Util.error("Unable to apply filter. "+I.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return D}return R}on(w,E){if(this._cache&&this._cache.delete(o),arguments.length===3)return this._delegate.apply(this,arguments);const R=w.split(O);for(let D=0;D<R.length;D++){const B=R[D].split("."),H=B[0],U=B[1]||"";this.eventListeners[H]||(this.eventListeners[H]=[]),this.eventListeners[H].push({name:U,handler:E})}return this}off(w,E){let R=(w||"").split(O),D=R.length,G,B,H,U,j,z;if(this._cache&&this._cache.delete(o),!w)for(B in this.eventListeners)this._off(B);for(G=0;G<D;G++)if(H=R[G],U=H.split("."),j=U[0],z=U[1],j)this.eventListeners[j]&&this._off(j,z,E);else for(B in this.eventListeners)this._off(B,z,E);return this}dispatchEvent(w){const E={target:this,type:w.type,evt:w};return this.fire(w.type,E),this}addEventListener(w,E){return this.on(w,function(R){E.call(this,R.evt)}),this}removeEventListener(w){return this.off(w),this}_delegate(w,E,R){const D=this;this.on(w,function(G){const B=G.target.findAncestors(E,!0,D);for(let H=0;H<B.length;H++)G=n.Util.cloneObject(G),G.currentTarget=B[H],R.call(B[H],G)})}remove(){return this.isDragging()&&this.stopDrag(),t.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(_),this._clearSelfAndDescendantCache(L),this._clearSelfAndDescendantCache(f)}_remove(){this._clearCaches();const w=this.getParent();w&&w.children&&(w.children.splice(this.index,1),w._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(w){const E="get"+n.Util._capitalize(w);return n.Util._isFunction(this[E])?this[E]():this.attrs[w]}getAncestors(){let w=this.getParent(),E=[];for(;w;)E.push(w),w=w.getParent();return E}getAttrs(){return this.attrs||{}}setAttrs(w){return this._batchTransformChanges(()=>{let E,R;if(!w)return this;for(E in w)E!==u&&(R=x+n.Util._capitalize(E),n.Util._isFunction(this[R])?this[R](w[E]):this._setAttr(E,w[E]))}),this}isListening(){return this._getCache(f,this._isListening)}_isListening(w){if(!this.listening())return!1;const R=this.getParent();return R&&R!==w&&this!==w?R._isListening(w):!0}isVisible(){return this._getCache(L,this._isVisible)}_isVisible(w){if(!this.visible())return!1;const R=this.getParent();return R&&R!==w&&this!==w?R._isVisible(w):!0}shouldDrawHit(w,E=!1){if(w)return this._isVisible(w)&&this._isListening(w);const R=this.getLayer();let D=!1;t.DD._dragElements.forEach(B=>{B.dragStatus==="dragging"&&(B.node.nodeType==="Stage"||B.node.getLayer()===R)&&(D=!0)});const G=!E&&!s.Konva.hitOnDragEnabled&&(D||s.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!G}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let w=this.getDepth(),E=this,R=0,D,G,B,H;function U(z){for(D=[],G=z.length,B=0;B<G;B++)H=z[B],R++,H.nodeType!==T&&(D=D.concat(H.getChildren().slice())),H._id===E._id&&(B=G);D.length>0&&D[0].getDepth()<=w&&U(D)}const j=this.getStage();return E.nodeType!==k&&j&&U(j.getChildren()),R}getDepth(){let w=0,E=this.parent;for(;E;)w++,E=E.parent;return w}_batchTransformChanges(w){this._batchingTransformChange=!0,w(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(C),this._clearSelfAndDescendantCache(h)),this._needClearTransformCache=!1}setPosition(w){return this._batchTransformChanges(()=>{this.x(w.x),this.y(w.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const w=this.getStage();if(!w)return null;const E=w.getPointerPosition();if(!E)return null;const R=this.getAbsoluteTransform().copy();return R.invert(),R.point(E)}getAbsolutePosition(w){let E=!1,R=this.parent;for(;R;){if(R.isCached()){E=!0;break}R=R.parent}E&&!w&&(w=!0);const D=this.getAbsoluteTransform(w).getMatrix(),G=new n.Transform,B=this.offset();return G.m=D.slice(),G.translate(B.x,B.y),G.getTranslation()}setAbsolutePosition(w){const{x:E,y:R,...D}=this._clearTransform();this.attrs.x=E,this.attrs.y=R,this._clearCache(C);const G=this._getAbsoluteTransform().copy();return G.invert(),G.translate(w.x,w.y),w={x:this.attrs.x+G.getTranslation().x,y:this.attrs.y+G.getTranslation().y},this._setTransform(D),this.setPosition({x:w.x,y:w.y}),this._clearCache(C),this._clearSelfAndDescendantCache(h),this}_setTransform(w){let E;for(E in w)this.attrs[E]=w[E]}_clearTransform(){const w={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,w}move(w){let E=w.x,R=w.y,D=this.x(),G=this.y();return E!==void 0&&(D+=E),R!==void 0&&(G+=R),this.setPosition({x:D,y:G}),this}_eachAncestorReverse(w,E){let R=[],D=this.getParent(),G,B;if(!(E&&E._id===this._id)){for(R.unshift(this);D&&(!E||D._id!==E._id);)R.unshift(D),D=D.parent;for(G=R.length,B=0;B<G;B++)w(R[B])}}rotate(w){return this.rotation(this.rotation()+w),this}moveToTop(){if(!this.parent)return n.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const w=this.index,E=this.parent.getChildren().length;return w<E-1?(this.parent.children.splice(w,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return n.Util.warn("Node has no parent. moveUp function is ignored."),!1;const w=this.index,E=this.parent.getChildren().length;return w<E-1?(this.parent.children.splice(w,1),this.parent.children.splice(w+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return n.Util.warn("Node has no parent. moveDown function is ignored."),!1;const w=this.index;return w>0?(this.parent.children.splice(w,1),this.parent.children.splice(w-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return n.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const w=this.index;return w>0?(this.parent.children.splice(w,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(w){if(!this.parent)return n.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(w<0||w>=this.parent.children.length)&&n.Util.warn("Unexpected value "+w+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const E=this.index;return this.parent.children.splice(E,1),this.parent.children.splice(w,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(a,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let w=this.opacity();const E=this.getParent();return E&&!E._isUnderCache&&(w*=E.getAbsoluteOpacity()),w}moveTo(w){return this.getParent()!==w&&(this._remove(),w.add(this)),this}toObject(){let w=this.getAttrs(),E,R,D,G,B;const H={attrs:{},className:this.getClassName()};for(E in w)R=w[E],B=n.Util.isObject(R)&&!n.Util._isPlainObject(R)&&!n.Util._isArray(R),!B&&(D=typeof this[E]=="function"&&this[E],delete w[E],G=D?D.call(this):null,w[E]=R,G!==R&&(H.attrs[E]=R));return n.Util._prepareToStringify(H)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(w,E,R){const D=[];E&&this._isMatch(w)&&D.push(this);let G=this.parent;for(;G;){if(G===R)return D;G._isMatch(w)&&D.push(G),G=G.parent}return D}isAncestorOf(w){return!1}findAncestor(w,E,R){return this.findAncestors(w,E,R)[0]}_isMatch(w){if(!w)return!1;if(typeof w=="function")return w(this);let E=w.replace(/ /g,"").split(","),R=E.length,D,G;for(D=0;D<R;D++)if(G=E[D],n.Util.isValidSelector(G)||(n.Util.warn('Selector "'+G+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),n.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),n.Util.warn("Konva is awesome, right?")),G.charAt(0)==="#"){if(this.id()===G.slice(1))return!0}else if(G.charAt(0)==="."){if(this.hasName(G.slice(1)))return!0}else if(this.className===G||this.nodeType===G)return!0;return!1}getLayer(){const w=this.getParent();return w?w.getLayer():null}getStage(){return this._getCache(_,this._getStage)}_getStage(){const w=this.getParent();return w?w.getStage():null}fire(w,E={},R){return E.target=E.target||this,R?this._fireAndBubble(w,E):this._fire(w,E),this}getAbsoluteTransform(w){return w?this._getAbsoluteTransform(w):this._getCache(h,this._getAbsoluteTransform)}_getAbsoluteTransform(w){let E;if(w)return E=new n.Transform,this._eachAncestorReverse(function(R){const D=R.transformsEnabled();D==="all"?E.multiply(R.getTransform()):D==="position"&&E.translate(R.x()-R.offsetX(),R.y()-R.offsetY())},w),E;{E=this._cache.get(h)||new n.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(E):E.reset();const R=this.transformsEnabled();if(R==="all")E.multiply(this.getTransform());else if(R==="position"){const D=this.attrs.x||0,G=this.attrs.y||0,B=this.attrs.offsetX||0,H=this.attrs.offsetY||0;E.translate(D-B,G-H)}return E.dirty=!1,E}}getAbsoluteScale(w){let E=this;for(;E;)E._isUnderCache&&(w=E),E=E.getParent();const D=this.getAbsoluteTransform(w).decompose();return{x:D.scaleX,y:D.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(C,this._getTransform)}_getTransform(){var w,E;const R=this._cache.get(C)||new n.Transform;R.reset();const D=this.x(),G=this.y(),B=s.Konva.getAngle(this.rotation()),H=(w=this.attrs.scaleX)!==null&&w!==void 0?w:1,U=(E=this.attrs.scaleY)!==null&&E!==void 0?E:1,j=this.attrs.skewX||0,z=this.attrs.skewY||0,I=this.attrs.offsetX||0,W=this.attrs.offsetY||0;return(D!==0||G!==0)&&R.translate(D,G),B!==0&&R.rotate(B),(j!==0||z!==0)&&R.skew(j,z),(H!==1||U!==1)&&R.scale(H,U),(I!==0||W!==0)&&R.translate(-1*I,-1*W),R.dirty=!1,R}clone(w){let E=n.Util.cloneObject(this.attrs),R,D,G,B,H;for(R in w)E[R]=w[R];const U=new this.constructor(E);for(R in this.eventListeners)for(D=this.eventListeners[R],G=D.length,B=0;B<G;B++)H=D[B],H.name.indexOf(g)<0&&(U.eventListeners[R]||(U.eventListeners[R]=[]),U.eventListeners[R].push(H));return U}_toKonvaCanvas(w){w=w||{};const E=this.getClientRect(),R=this.getStage(),D=w.x!==void 0?w.x:Math.floor(E.x),G=w.y!==void 0?w.y:Math.floor(E.y),B=w.pixelRatio||1,H=new i.SceneCanvas({width:w.width||Math.ceil(E.width)||(R?R.width():0),height:w.height||Math.ceil(E.height)||(R?R.height():0),pixelRatio:B}),U=H.getContext(),j=new i.SceneCanvas({width:H.width/H.pixelRatio+Math.abs(D),height:H.height/H.pixelRatio+Math.abs(G),pixelRatio:H.pixelRatio});return w.imageSmoothingEnabled===!1&&(U._context.imageSmoothingEnabled=!1),U.save(),(D||G)&&U.translate(-1*D,-1*G),this.drawScene(H,void 0,j),U.restore(),H}toCanvas(w){return this._toKonvaCanvas(w)._canvas}toDataURL(w){w=w||{};const E=w.mimeType||null,R=w.quality||null,D=this._toKonvaCanvas(w).toDataURL(E,R);return w.callback&&w.callback(D),D}toImage(w){return new Promise((E,R)=>{try{const D=w==null?void 0:w.callback;D&&delete w.callback,n.Util._urlToImage(this.toDataURL(w),function(G){E(G),D==null||D(G)})}catch(D){R(D)}})}toBlob(w){return new Promise((E,R)=>{try{const D=w==null?void 0:w.callback;D&&delete w.callback,this.toCanvas(w).toBlob(G=>{E(G),D==null||D(G)},w==null?void 0:w.mimeType,w==null?void 0:w.quality)}catch(D){R(D)}})}setSize(w){return this.width(w.width),this.height(w.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():s.Konva.dragDistance}_off(w,E,R){let D=this.eventListeners[w],G,B,H;for(G=0;G<D.length;G++)if(B=D[G].name,H=D[G].handler,(B!=="konva"||E==="konva")&&(!E||B===E)&&(!R||R===H)){if(D.splice(G,1),D.length===0){delete this.eventListeners[w];break}G--}}_fireChangeEvent(w,E,R){this._fire(w+p,{oldVal:E,newVal:R})}addName(w){if(!this.hasName(w)){const E=this.name(),R=E?E+" "+w:w;this.name(R)}return this}hasName(w){if(!w)return!1;const E=this.name();return E?(E||"").split(/\s/g).indexOf(w)!==-1:!1}removeName(w){const E=(this.name()||"").split(/\s/g),R=E.indexOf(w);return R!==-1&&(E.splice(R,1),this.name(E.join(" "))),this}setAttr(w,E){const R=this[x+n.Util._capitalize(w)];return n.Util._isFunction(R)?R.call(this,E):this._setAttr(w,E),this}_requestDraw(){if(s.Konva.autoDrawEnabled){const w=this.getLayer()||this.getStage();w==null||w.batchDraw()}}_setAttr(w,E){const R=this.attrs[w];R===E&&!n.Util.isObject(E)||(E==null?delete this.attrs[w]:this.attrs[w]=E,this._shouldFireChangeEvents&&this._fireChangeEvent(w,R,E),this._requestDraw())}_setComponentAttr(w,E,R){let D;R!==void 0&&(D=this.attrs[w],D||(this.attrs[w]=this.getAttr(w)),this.attrs[w][E]=R,this._fireChangeEvent(w,D,R))}_fireAndBubble(w,E,R){E&&this.nodeType===T&&(E.target=this);const D=[m,b,S,y,c,v];if(!(D.indexOf(w)!==-1&&(R&&(this===R||this.isAncestorOf&&this.isAncestorOf(R))||this.nodeType==="Stage"&&!R))){this._fire(w,E);const B=D.indexOf(w)!==-1&&R&&R.isAncestorOf&&R.isAncestorOf(this)&&!R.isAncestorOf(this.parent);(E&&!E.cancelBubble||!E)&&this.parent&&this.parent.isListening()&&!B&&(R&&R.parent?this._fireAndBubble.call(this.parent,w,E,R):this._fireAndBubble.call(this.parent,w,E))}}_getProtoListeners(w){var E,R,D;const G=(E=this._cache.get(o))!==null&&E!==void 0?E:{};let B=G==null?void 0:G[w];if(B===void 0){B=[];let H=Object.getPrototypeOf(this);for(;H;){const U=(D=(R=H.eventListeners)===null||R===void 0?void 0:R[w])!==null&&D!==void 0?D:[];B.push(...U),H=Object.getPrototypeOf(H)}G[w]=B,this._cache.set(o,G)}return B}_fire(w,E){E=E||{},E.currentTarget=this,E.type=w;const R=this._getProtoListeners(w);if(R)for(let G=0;G<R.length;G++)R[G].handler.call(this,E);const D=this.eventListeners[w];if(D)for(let G=0;G<D.length;G++)D[G].handler.call(this,E)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(w){const E=w?w.pointerId:void 0,R=this.getStage(),D=this.getAbsolutePosition();if(!R)return;const G=R._getPointerById(E)||R._changedPointerPositions[0]||D;t.DD._dragElements.set(this._id,{node:this,startPointerPos:G,offset:{x:G.x-D.x,y:G.y-D.y},dragStatus:"ready",pointerId:E})}startDrag(w,E=!0){t.DD._dragElements.has(this._id)||this._createDragElement(w);const R=t.DD._dragElements.get(this._id);R.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:w&&w.evt},E)}_setDragPosition(w,E){const R=this.getStage()._getPointerById(E.pointerId);if(!R)return;let D={x:R.x-E.offset.x,y:R.y-E.offset.y};const G=this.dragBoundFunc();if(G!==void 0){const B=G.call(this,D,w);B?D=B:n.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==D.x||this._lastPos.y!==D.y)&&(this.setAbsolutePosition(D),this._requestDraw()),this._lastPos=D}stopDrag(w){const E=t.DD._dragElements.get(this._id);E&&(E.dragStatus="stopped"),t.DD._endDragBefore(w),t.DD._endDragAfter(w)}setDraggable(w){this._setAttr("draggable",w),this._dragChange()}isDragging(){const w=t.DD._dragElements.get(this._id);return w?w.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(w){if(!(!(w.evt.button!==void 0)||s.Konva.dragButtons.indexOf(w.evt.button)>=0)||this.isDragging())return;let D=!1;t.DD._dragElements.forEach(G=>{this.isAncestorOf(G.node)&&(D=!0)}),D||this._createDragElement(w)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const E=t.DD._dragElements.get(this._id),R=E&&E.dragStatus==="dragging",D=E&&E.dragStatus==="ready";R?this.stopDrag():D&&t.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(w={x:0,y:0}){const E=this.getStage();if(!E)return!1;const R={x:-w.x,y:-w.y,width:E.width()+2*w.x,height:E.height()+2*w.y};return n.Util.haveIntersection(R,this.getClientRect())}static create(w,E){return n.Util._isString(w)&&(w=JSON.parse(w)),this._createNode(w,E)}static _createNode(w,E){let R=is.prototype.getClassName.call(w),D=w.children,G,B,H;E&&(w.attrs.container=E),s.Konva[R]||(n.Util.warn('Can not find a node with class name "'+R+'". Fallback to "Shape".'),R="Shape");const U=s.Konva[R];if(G=new U(w.attrs),D)for(B=D.length,H=0;H<B;H++)G.add(is._createNode(D[H]));return G}};pe.Node=P,P.prototype.nodeType="Node",P.prototype._attrsAffectingSize=[],P.prototype.eventListeners={},P.prototype.on.call(P.prototype,F,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(C),this._clearSelfAndDescendantCache(h)}),P.prototype.on.call(P.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(L)}),P.prototype.on.call(P.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(f)}),P.prototype.on.call(P.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(a)});const A=e.Factory.addGetterSetter;return A(P,"zIndex"),A(P,"absolutePosition"),A(P,"position"),A(P,"x",0,(0,r.getNumberValidator)()),A(P,"y",0,(0,r.getNumberValidator)()),A(P,"globalCompositeOperation","source-over",(0,r.getStringValidator)()),A(P,"opacity",1,(0,r.getNumberValidator)()),A(P,"name","",(0,r.getStringValidator)()),A(P,"id","",(0,r.getStringValidator)()),A(P,"rotation",0,(0,r.getNumberValidator)()),e.Factory.addComponentsGetterSetter(P,"scale",["x","y"]),A(P,"scaleX",1,(0,r.getNumberValidator)()),A(P,"scaleY",1,(0,r.getNumberValidator)()),e.Factory.addComponentsGetterSetter(P,"skew",["x","y"]),A(P,"skewX",0,(0,r.getNumberValidator)()),A(P,"skewY",0,(0,r.getNumberValidator)()),e.Factory.addComponentsGetterSetter(P,"offset",["x","y"]),A(P,"offsetX",0,(0,r.getNumberValidator)()),A(P,"offsetY",0,(0,r.getNumberValidator)()),A(P,"dragDistance",void 0,(0,r.getNumberValidator)()),A(P,"width",0,(0,r.getNumberValidator)()),A(P,"height",0,(0,r.getNumberValidator)()),A(P,"listening",!0,(0,r.getBooleanValidator)()),A(P,"preventDefault",!0,(0,r.getBooleanValidator)()),A(P,"filters",void 0,function($){return this._filterUpToDate=!1,$}),A(P,"visible",!0,(0,r.getBooleanValidator)()),A(P,"transformsEnabled","all",(0,r.getStringValidator)()),A(P,"size"),A(P,"dragBoundFunc"),A(P,"draggable",!1,(0,r.getBooleanValidator)()),e.Factory.backCompat(P,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),pe}var me={},vn;function Li(){if(vn)return me;vn=1,Object.defineProperty(me,"__esModule",{value:!0}),me.Container=void 0;const i=st(),t=mt(),e=nt();let s=class extends t.Node{constructor(){super(...arguments),this.children=[]}getChildren(r){const a=this.children||[];return r?a.filter(r):a}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(r=>{r.parent=null,r.index=0,r.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(r=>{r.parent=null,r.index=0,r.destroy()}),this.children=[],this._requestDraw(),this}add(...r){if(r.length===0)return this;if(r.length>1){for(let o=0;o<r.length;o++)this.add(r[o]);return this}const a=r[0];return a.getParent()?(a.moveTo(this),this):(this._validateAdd(a),a.index=this.getChildren().length,a.parent=this,a._clearCaches(),this.getChildren().push(a),this._fire("add",{child:a}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(r){return this._generalFind(r,!1)}findOne(r){const a=this._generalFind(r,!0);return a.length>0?a[0]:void 0}_generalFind(r,a){const o=[];return this._descendants(h=>{const l=h._isMatch(r);return l&&o.push(h),!!(l&&a)}),o}_descendants(r){let a=!1;const o=this.getChildren();for(const h of o){if(a=r(h),a)return!0;if(h.hasChildren()&&(a=h._descendants(r),a))return!0}return!1}toObject(){const r=t.Node.prototype.toObject.call(this);return r.children=[],this.getChildren().forEach(a=>{r.children.push(a.toObject())}),r}isAncestorOf(r){let a=r.getParent();for(;a;){if(a._id===this._id)return!0;a=a.getParent()}return!1}clone(r){const a=t.Node.prototype.clone.call(this,r);return this.getChildren().forEach(function(o){a.add(o.clone())}),a}getAllIntersections(r){const a=[];return this.find("Shape").forEach(o=>{o.isVisible()&&o.intersects(r)&&a.push(o)}),a}_clearSelfAndDescendantCache(r){var a;super._clearSelfAndDescendantCache(r),!this.isCached()&&((a=this.children)===null||a===void 0||a.forEach(function(o){o._clearSelfAndDescendantCache(r)}))}_setChildrenIndices(){var r;(r=this.children)===null||r===void 0||r.forEach(function(a,o){a.index=o}),this._requestDraw()}drawScene(r,a,o){const h=this.getLayer(),l=r||h&&h.getCanvas(),d=l&&l.getContext(),p=this._getCanvasCache(),u=p&&p.scene,g=l&&l.isCache;if(!this.isVisible()&&!g)return this;if(u){d.save();const f=this.getAbsoluteTransform(a).getMatrix();d.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedSceneCanvas(d),d.restore()}else this._drawChildren("drawScene",l,a,o);return this}drawHit(r,a){if(!this.shouldDrawHit(a))return this;const o=this.getLayer(),h=r||o&&o.hitCanvas,l=h&&h.getContext(),d=this._getCanvasCache();if(d&&d.hit){l.save();const u=this.getAbsoluteTransform(a).getMatrix();l.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedHitCanvas(l),l.restore()}else this._drawChildren("drawHit",h,a);return this}_drawChildren(r,a,o,h){var l;const d=a&&a.getContext(),p=this.clipWidth(),u=this.clipHeight(),g=this.clipFunc(),f=typeof p=="number"&&typeof u=="number"||g,m=o===this;if(f){d.save();const S=this.getAbsoluteTransform(o);let y=S.getMatrix();d.transform(y[0],y[1],y[2],y[3],y[4],y[5]),d.beginPath();let c;if(g)c=g.call(this,d,this);else{const v=this.clipX(),x=this.clipY();d.rect(v||0,x||0,p,u)}d.clip.apply(d,c),y=S.copy().invert().getMatrix(),d.transform(y[0],y[1],y[2],y[3],y[4],y[5])}const b=!m&&this.globalCompositeOperation()!=="source-over"&&r==="drawScene";b&&(d.save(),d._applyGlobalCompositeOperation(this)),(l=this.children)===null||l===void 0||l.forEach(function(S){S[r](a,o,h)}),b&&d.restore(),f&&d.restore()}getClientRect(r={}){var a;const o=r.skipTransform,h=r.relativeTo;let l,d,p,u,g={x:1/0,y:1/0,width:0,height:0};const f=this;(a=this.children)===null||a===void 0||a.forEach(function(S){if(!S.visible())return;const y=S.getClientRect({relativeTo:f,skipShadow:r.skipShadow,skipStroke:r.skipStroke});y.width===0&&y.height===0||(l===void 0?(l=y.x,d=y.y,p=y.x+y.width,u=y.y+y.height):(l=Math.min(l,y.x),d=Math.min(d,y.y),p=Math.max(p,y.x+y.width),u=Math.max(u,y.y+y.height)))});const m=this.find("Shape");let b=!1;for(let S=0;S<m.length;S++)if(m[S]._isVisible(this)){b=!0;break}return b&&l!==void 0?g={x:l,y:d,width:p-l,height:u-d}:g={x:0,y:0,width:0,height:0},o?g:this._transformedRect(g,h)}};return me.Container=s,i.Factory.addComponentsGetterSetter(s,"clip",["x","y","width","height"]),i.Factory.addGetterSetter(s,"clipX",void 0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(s,"clipY",void 0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(s,"clipWidth",void 0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(s,"clipHeight",void 0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(s,"clipFunc"),me}var Ui={},Kt={},bn;function Zr(){if(bn)return Kt;bn=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.getCapturedShape=s,Kt.createEvent=n,Kt.hasPointerCapture=r,Kt.setPointerCapture=a,Kt.releaseCapture=o;const i=it(),t=new Map,e=i.Konva._global.PointerEvent!==void 0;function s(h){return t.get(h)}function n(h){return{evt:h,pointerId:h.pointerId}}function r(h,l){return t.get(h)===l}function a(h,l){o(h),l.getStage()&&(t.set(h,l),e&&l._fire("gotpointercapture",n(new PointerEvent("gotpointercapture"))))}function o(h,l){const d=t.get(h);if(!d)return;const p=d.getStage();p&&p.content,t.delete(h),e&&d._fire("lostpointercapture",n(new PointerEvent("lostpointercapture")))}return Kt}var xn;function eu(){return xn||(xn=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Stage=i.stages=void 0;const t=gt(),e=st(),s=Li(),n=it(),r=Oi(),a=_s(),o=it(),h=Zr(),l="Stage",d="string",p="px",u="mouseout",g="mouseleave",f="mouseover",m="mouseenter",b="mousemove",S="mousedown",y="mouseup",c="pointermove",v="pointerdown",x="pointerup",T="pointercancel",O="lostpointercapture",_="pointerout",C="pointerleave",k="pointerover",L="pointerenter",F="contextmenu",N="touchstart",P="touchend",A="touchmove",$="touchcancel",w="wheel",E=5,R=[[m,"_pointerenter"],[S,"_pointerdown"],[b,"_pointermove"],[y,"_pointerup"],[g,"_pointerleave"],[N,"_pointerdown"],[A,"_pointermove"],[P,"_pointerup"],[$,"_pointercancel"],[f,"_pointerover"],[w,"_wheel"],[F,"_contextmenu"],[v,"_pointerdown"],[c,"_pointermove"],[x,"_pointerup"],[T,"_pointercancel"],[C,"_pointerleave"],[O,"_lostpointercapture"]],D={mouse:{[_]:u,[C]:g,[k]:f,[L]:m,[c]:b,[v]:S,[x]:y,[T]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[_]:"touchout",[C]:"touchleave",[k]:"touchover",[L]:"touchenter",[c]:A,[v]:N,[x]:P,[T]:$,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[_]:_,[C]:C,[k]:k,[L]:L,[c]:c,[v]:v,[x]:x,[T]:T,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},G=z=>z.indexOf("pointer")>=0?"pointer":z.indexOf("touch")>=0?"touch":"mouse",B=z=>{const I=G(z);if(I==="pointer")return n.Konva.pointerEventsEnabled&&D.pointer;if(I==="touch")return D.touch;if(I==="mouse")return D.mouse};function H(z={}){return(z.clipFunc||z.clipWidth||z.clipHeight)&&t.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),z}const U="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";i.stages=[];class j extends s.Container{constructor(I){super(H(I)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),i.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{H(this.attrs)}),this._checkVisibility()}_validateAdd(I){const W=I.getType()==="Layer",K=I.getType()==="FastLayer";W||K||t.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const I=this.visible()?"":"none";this.content.style.display=I}setContainer(I){if(typeof I===d){let W;if(I.charAt(0)==="."){const K=I.slice(1);I=document.getElementsByClassName(K)[0]}else I.charAt(0)!=="#"?W=I:W=I.slice(1),I=document.getElementById(W);if(!I)throw"Can not find container in document with id "+W}return this._setAttr("container",I),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),I.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const I=this.children,W=I.length;for(let K=0;K<W;K++)I[K].clear();return this}clone(I){return I||(I={}),I.container=typeof document<"u"&&document.createElement("div"),s.Container.prototype.clone.call(this,I)}destroy(){super.destroy();const I=this.content;I&&t.Util._isInDocument(I)&&this.container().removeChild(I);const W=i.stages.indexOf(this);return W>-1&&i.stages.splice(W,1),t.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const I=this._pointerPositions[0]||this._changedPointerPositions[0];return I?{x:I.x,y:I.y}:(t.Util.warn(U),null)}_getPointerById(I){return this._pointerPositions.find(W=>W.id===I)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(I){I=I||{},I.x=I.x||0,I.y=I.y||0,I.width=I.width||this.width(),I.height=I.height||this.height();const W=new r.SceneCanvas({width:I.width,height:I.height,pixelRatio:I.pixelRatio||1}),K=W.getContext()._context,X=this.children;return(I.x||I.y)&&K.translate(-1*I.x,-1*I.y),X.forEach(function(q){if(!q.isVisible())return;const J=q._toKonvaCanvas(I);K.drawImage(J._canvas,I.x,I.y,J.getWidth()/J.getPixelRatio(),J.getHeight()/J.getPixelRatio())}),W}getIntersection(I){if(!I)return null;const W=this.children,K=W.length,X=K-1;for(let q=X;q>=0;q--){const J=W[q].getIntersection(I);if(J)return J}return null}_resizeDOM(){const I=this.width(),W=this.height();this.content&&(this.content.style.width=I+p,this.content.style.height=W+p),this.bufferCanvas.setSize(I,W),this.bufferHitCanvas.setSize(I,W),this.children.forEach(K=>{K.setSize({width:I,height:W}),K.draw()})}add(I,...W){if(arguments.length>1){for(let X=0;X<arguments.length;X++)this.add(arguments[X]);return this}super.add(I);const K=this.children.length;return K>E&&t.Util.warn("The stage has "+K+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),I.setSize({width:this.width(),height:this.height()}),I.draw(),n.Konva.isBrowser&&this.content.appendChild(I.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(I){return h.hasPointerCapture(I,this)}setPointerCapture(I){h.setPointerCapture(I,this)}releaseCapture(I){h.releaseCapture(I,this)}getLayers(){return this.children}_bindContentEvents(){n.Konva.isBrowser&&R.forEach(([I,W])=>{this.content.addEventListener(I,K=>{this[W](K)},{passive:!1})})}_pointerenter(I){this.setPointersPositions(I);const W=B(I.type);W&&this._fire(W.pointerenter,{evt:I,target:this,currentTarget:this})}_pointerover(I){this.setPointersPositions(I);const W=B(I.type);W&&this._fire(W.pointerover,{evt:I,target:this,currentTarget:this})}_getTargetShape(I){let W=this[I+"targetShape"];return W&&!W.getStage()&&(W=null),W}_pointerleave(I){const W=B(I.type),K=G(I.type);if(!W)return;this.setPointersPositions(I);const X=this._getTargetShape(K),q=!(n.Konva.isDragging()||n.Konva.isTransforming())||n.Konva.hitOnDragEnabled;X&&q?(X._fireAndBubble(W.pointerout,{evt:I}),X._fireAndBubble(W.pointerleave,{evt:I}),this._fire(W.pointerleave,{evt:I,target:this,currentTarget:this}),this[K+"targetShape"]=null):q&&(this._fire(W.pointerleave,{evt:I,target:this,currentTarget:this}),this._fire(W.pointerout,{evt:I,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(I){const W=B(I.type),K=G(I.type);if(!W)return;this.setPointersPositions(I);let X=!1;this._changedPointerPositions.forEach(q=>{const J=this.getIntersection(q);if(a.DD.justDragged=!1,n.Konva["_"+K+"ListenClick"]=!0,!J||!J.isListening()){this[K+"ClickStartShape"]=void 0;return}n.Konva.capturePointerEventsEnabled&&J.setPointerCapture(q.id),this[K+"ClickStartShape"]=J,J._fireAndBubble(W.pointerdown,{evt:I,pointerId:q.id}),X=!0;const Z=I.type.indexOf("touch")>=0;J.preventDefault()&&I.cancelable&&Z&&I.preventDefault()}),X||this._fire(W.pointerdown,{evt:I,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(I){const W=B(I.type),K=G(I.type);if(!W||(n.Konva.isDragging()&&a.DD.node.preventDefault()&&I.cancelable&&I.preventDefault(),this.setPointersPositions(I),!(!(n.Konva.isDragging()||n.Konva.isTransforming())||n.Konva.hitOnDragEnabled)))return;const q={};let J=!1;const Z=this._getTargetShape(K);this._changedPointerPositions.forEach(ot=>{const tt=h.getCapturedShape(ot.id)||this.getIntersection(ot),vt=ot.id,ht={evt:I,pointerId:vt},pt=Z!==tt;if(pt&&Z&&(Z._fireAndBubble(W.pointerout,{...ht},tt),Z._fireAndBubble(W.pointerleave,{...ht},tt)),tt){if(q[tt._id])return;q[tt._id]=!0}tt&&tt.isListening()?(J=!0,pt&&(tt._fireAndBubble(W.pointerover,{...ht},Z),tt._fireAndBubble(W.pointerenter,{...ht},Z),this[K+"targetShape"]=tt),tt._fireAndBubble(W.pointermove,{...ht})):Z&&(this._fire(W.pointerover,{evt:I,target:this,currentTarget:this,pointerId:vt}),this[K+"targetShape"]=null)}),J||this._fire(W.pointermove,{evt:I,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(I){const W=B(I.type),K=G(I.type);if(!W)return;this.setPointersPositions(I);const X=this[K+"ClickStartShape"],q=this[K+"ClickEndShape"],J={};let Z=!1;this._changedPointerPositions.forEach(ot=>{const tt=h.getCapturedShape(ot.id)||this.getIntersection(ot);if(tt){if(tt.releaseCapture(ot.id),J[tt._id])return;J[tt._id]=!0}const vt=ot.id,ht={evt:I,pointerId:vt};let pt=!1;n.Konva["_"+K+"InDblClickWindow"]?(pt=!0,clearTimeout(this[K+"DblTimeout"])):a.DD.justDragged||(n.Konva["_"+K+"InDblClickWindow"]=!0,clearTimeout(this[K+"DblTimeout"])),this[K+"DblTimeout"]=setTimeout(function(){n.Konva["_"+K+"InDblClickWindow"]=!1},n.Konva.dblClickWindow),tt&&tt.isListening()?(Z=!0,this[K+"ClickEndShape"]=tt,tt._fireAndBubble(W.pointerup,{...ht}),n.Konva["_"+K+"ListenClick"]&&X&&X===tt&&(tt._fireAndBubble(W.pointerclick,{...ht}),pt&&q&&q===tt&&tt._fireAndBubble(W.pointerdblclick,{...ht}))):(this[K+"ClickEndShape"]=null,n.Konva["_"+K+"ListenClick"]&&this._fire(W.pointerclick,{evt:I,target:this,currentTarget:this,pointerId:vt}),pt&&this._fire(W.pointerdblclick,{evt:I,target:this,currentTarget:this,pointerId:vt}))}),Z||this._fire(W.pointerup,{evt:I,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),n.Konva["_"+K+"ListenClick"]=!1,I.cancelable&&K!=="touch"&&K!=="pointer"&&I.preventDefault()}_contextmenu(I){this.setPointersPositions(I);const W=this.getIntersection(this.getPointerPosition());W&&W.isListening()?W._fireAndBubble(F,{evt:I}):this._fire(F,{evt:I,target:this,currentTarget:this})}_wheel(I){this.setPointersPositions(I);const W=this.getIntersection(this.getPointerPosition());W&&W.isListening()?W._fireAndBubble(w,{evt:I}):this._fire(w,{evt:I,target:this,currentTarget:this})}_pointercancel(I){this.setPointersPositions(I);const W=h.getCapturedShape(I.pointerId)||this.getIntersection(this.getPointerPosition());W&&W._fireAndBubble(x,h.createEvent(I)),h.releaseCapture(I.pointerId)}_lostpointercapture(I){h.releaseCapture(I.pointerId)}setPointersPositions(I){const W=this._getContentPosition();let K=null,X=null;I=I||window.event,I.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(I.touches,q=>{this._pointerPositions.push({id:q.identifier,x:(q.clientX-W.left)/W.scaleX,y:(q.clientY-W.top)/W.scaleY})}),Array.prototype.forEach.call(I.changedTouches||I.touches,q=>{this._changedPointerPositions.push({id:q.identifier,x:(q.clientX-W.left)/W.scaleX,y:(q.clientY-W.top)/W.scaleY})})):(K=(I.clientX-W.left)/W.scaleX,X=(I.clientY-W.top)/W.scaleY,this.pointerPos={x:K,y:X},this._pointerPositions=[{x:K,y:X,id:t.Util._getFirstPointerId(I)}],this._changedPointerPositions=[{x:K,y:X,id:t.Util._getFirstPointerId(I)}])}_setPointerPosition(I){t.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(I)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const I=this.content.getBoundingClientRect();return{top:I.top,left:I.left,scaleX:I.width/this.content.clientWidth||1,scaleY:I.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new r.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new r.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!n.Konva.isBrowser)return;const I=this.container();if(!I)throw"Stage has no container. A container is required.";I.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),I.appendChild(this.content),this._resizeDOM()}cache(){return t.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(I){I.batchDraw()}),this}}i.Stage=j,j.prototype.nodeType=l,(0,o._registerNode)(j),e.Factory.addGetterSetter(j,"container"),n.Konva.isBrowser&&document.addEventListener("visibilitychange",()=>{i.stages.forEach(z=>{z.batchDraw()})})})(Ui)),Ui}var ye={},Wi={},_n;function yt(){return _n||(_n=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Shape=i.shapes=void 0;const t=it(),e=gt(),s=st(),n=mt(),r=nt(),a=it(),o=Zr(),h="hasShadow",l="shadowRGBA",d="patternImage",p="linearGradient",u="radialGradient";let g;function f(){return g||(g=e.Util.createCanvasElement().getContext("2d"),g)}i.shapes={};function m(C){const k=this.attrs.fillRule;k?C.fill(k):C.fill()}function b(C){C.stroke()}function S(C){const k=this.attrs.fillRule;k?C.fill(k):C.fill()}function y(C){C.stroke()}function c(){this._clearCache(h)}function v(){this._clearCache(l)}function x(){this._clearCache(d)}function T(){this._clearCache(p)}function O(){this._clearCache(u)}class _ extends n.Node{constructor(k){super(k);let L;for(;L=e.Util.getRandomColor(),!(L&&!(L in i.shapes)););this.colorKey=L,i.shapes[L]=this}getContext(){return e.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return e.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(d,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const L=f().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(L&&L.setTransform){const F=new e.Transform;F.translate(this.fillPatternX(),this.fillPatternY()),F.rotate(t.Konva.getAngle(this.fillPatternRotation())),F.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),F.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const N=F.getMatrix(),P=typeof DOMMatrix>"u"?{a:N[0],b:N[1],c:N[2],d:N[3],e:N[4],f:N[5]}:new DOMMatrix(N);L.setTransform(P)}return L}}_getLinearGradient(){return this._getCache(p,this.__getLinearGradient)}__getLinearGradient(){const k=this.fillLinearGradientColorStops();if(k){const L=f(),F=this.fillLinearGradientStartPoint(),N=this.fillLinearGradientEndPoint(),P=L.createLinearGradient(F.x,F.y,N.x,N.y);for(let A=0;A<k.length;A+=2)P.addColorStop(k[A],k[A+1]);return P}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){const k=this.fillRadialGradientColorStops();if(k){const L=f(),F=this.fillRadialGradientStartPoint(),N=this.fillRadialGradientEndPoint(),P=L.createRadialGradient(F.x,F.y,this.fillRadialGradientStartRadius(),N.x,N.y,this.fillRadialGradientEndRadius());for(let A=0;A<k.length;A+=2)P.addColorStop(k[A],k[A+1]);return P}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const k=e.Util.colorToRGBA(this.shadowColor());if(k)return"rgba("+k.r+","+k.g+","+k.b+","+k.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const k=this.hitStrokeWidth();return k==="auto"?this.hasStroke():this.strokeEnabled()&&!!k}intersects(k){const L=this.getStage();if(!L)return!1;const F=L.bufferHitCanvas;return F.getContext().clear(),this.drawHit(F,void 0,!0),F.context.getImageData(Math.round(k.x),Math.round(k.y),1,1).data[3]>0}destroy(){return n.Node.prototype.destroy.call(this),delete i.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(k){var L;if(!((L=this.attrs.perfectDrawEnabled)!==null&&L!==void 0?L:!0))return!1;const N=k||this.hasFill(),P=this.hasStroke(),A=this.getAbsoluteOpacity()!==1;if(N&&P&&A)return!0;const $=this.hasShadow(),w=this.shadowForStrokeEnabled();return!!(N&&P&&$&&w)}setStrokeHitEnabled(k){e.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),k?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){const k=this.size();return{x:this._centroid?-k.width/2:0,y:this._centroid?-k.height/2:0,width:k.width,height:k.height}}getClientRect(k={}){let L=!1,F=this.getParent();for(;F;){if(F.isCached()){L=!0;break}F=F.getParent()}const N=k.skipTransform,P=k.relativeTo||L&&this.getStage()||void 0,A=this.getSelfRect(),w=!k.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,E=A.width+w,R=A.height+w,D=!k.skipShadow&&this.hasShadow(),G=D?this.shadowOffsetX():0,B=D?this.shadowOffsetY():0,H=E+Math.abs(G),U=R+Math.abs(B),j=D&&this.shadowBlur()||0,z=H+j*2,I=U+j*2,W={width:z,height:I,x:-(w/2+j)+Math.min(G,0)+A.x,y:-(w/2+j)+Math.min(B,0)+A.y};return N?W:this._transformedRect(W,P)}drawScene(k,L,F){const N=this.getLayer(),P=k||N.getCanvas(),A=P.getContext(),$=this._getCanvasCache(),w=this.getSceneFunc(),E=this.hasShadow();let R;const D=L===this;if(!this.isVisible()&&!D)return this;if($){A.save();const G=this.getAbsoluteTransform(L).getMatrix();return A.transform(G[0],G[1],G[2],G[3],G[4],G[5]),this._drawCachedSceneCanvas(A),A.restore(),this}if(!w)return this;if(A.save(),this._useBufferCanvas()){R=this.getStage();const G=F||R.bufferCanvas,B=G.getContext();B.clear(),B.save(),B._applyLineJoin(this);const H=this.getAbsoluteTransform(L).getMatrix();B.transform(H[0],H[1],H[2],H[3],H[4],H[5]),w.call(this,B,this),B.restore();const U=G.pixelRatio;E&&A._applyShadow(this),A._applyOpacity(this),A._applyGlobalCompositeOperation(this),A.drawImage(G._canvas,G.x||0,G.y||0,G.width/U,G.height/U)}else{if(A._applyLineJoin(this),!D){const G=this.getAbsoluteTransform(L).getMatrix();A.transform(G[0],G[1],G[2],G[3],G[4],G[5]),A._applyOpacity(this),A._applyGlobalCompositeOperation(this)}E&&A._applyShadow(this),w.call(this,A,this)}return A.restore(),this}drawHit(k,L,F=!1){if(!this.shouldDrawHit(L,F))return this;const N=this.getLayer(),P=k||N.hitCanvas,A=P&&P.getContext(),$=this.hitFunc()||this.sceneFunc(),w=this._getCanvasCache(),E=w&&w.hit;if(this.colorKey||e.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),E){A.save();const D=this.getAbsoluteTransform(L).getMatrix();return A.transform(D[0],D[1],D[2],D[3],D[4],D[5]),this._drawCachedHitCanvas(A),A.restore(),this}if(!$)return this;if(A.save(),A._applyLineJoin(this),!(this===L)){const D=this.getAbsoluteTransform(L).getMatrix();A.transform(D[0],D[1],D[2],D[3],D[4],D[5])}return $.call(this,A,this),A.restore(),this}drawHitFromCache(k=0){const L=this._getCanvasCache(),F=this._getCachedSceneCanvas(),N=L.hit,P=N.getContext(),A=N.getWidth(),$=N.getHeight();P.clear(),P.drawImage(F._canvas,0,0,A,$);try{const w=P.getImageData(0,0,A,$),E=w.data,R=E.length,D=e.Util._hexToRgb(this.colorKey);for(let G=0;G<R;G+=4)E[G+3]>k?(E[G]=D.r,E[G+1]=D.g,E[G+2]=D.b,E[G+3]=255):E[G+3]=0;P.putImageData(w,0,0)}catch(w){e.Util.error("Unable to draw hit graph from cached scene canvas. "+w.message)}return this}hasPointerCapture(k){return o.hasPointerCapture(k,this)}setPointerCapture(k){o.setPointerCapture(k,this)}releaseCapture(k){o.releaseCapture(k,this)}}i.Shape=_,_.prototype._fillFunc=m,_.prototype._strokeFunc=b,_.prototype._fillFuncHit=S,_.prototype._strokeFuncHit=y,_.prototype._centroid=!1,_.prototype.nodeType="Shape",(0,a._registerNode)(_),_.prototype.eventListeners={},_.prototype.on.call(_.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",c),_.prototype.on.call(_.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",v),_.prototype.on.call(_.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",x),_.prototype.on.call(_.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",T),_.prototype.on.call(_.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",O),s.Factory.addGetterSetter(_,"stroke",void 0,(0,r.getStringOrGradientValidator)()),s.Factory.addGetterSetter(_,"strokeWidth",2,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"fillAfterStrokeEnabled",!1),s.Factory.addGetterSetter(_,"hitStrokeWidth","auto",(0,r.getNumberOrAutoValidator)()),s.Factory.addGetterSetter(_,"strokeHitEnabled",!0,(0,r.getBooleanValidator)()),s.Factory.addGetterSetter(_,"perfectDrawEnabled",!0,(0,r.getBooleanValidator)()),s.Factory.addGetterSetter(_,"shadowForStrokeEnabled",!0,(0,r.getBooleanValidator)()),s.Factory.addGetterSetter(_,"lineJoin"),s.Factory.addGetterSetter(_,"lineCap"),s.Factory.addGetterSetter(_,"sceneFunc"),s.Factory.addGetterSetter(_,"hitFunc"),s.Factory.addGetterSetter(_,"dash"),s.Factory.addGetterSetter(_,"dashOffset",0,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"shadowColor",void 0,(0,r.getStringValidator)()),s.Factory.addGetterSetter(_,"shadowBlur",0,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"shadowOpacity",1,(0,r.getNumberValidator)()),s.Factory.addComponentsGetterSetter(_,"shadowOffset",["x","y"]),s.Factory.addGetterSetter(_,"shadowOffsetX",0,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"shadowOffsetY",0,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"fillPatternImage"),s.Factory.addGetterSetter(_,"fill",void 0,(0,r.getStringOrGradientValidator)()),s.Factory.addGetterSetter(_,"fillPatternX",0,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"fillPatternY",0,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"fillLinearGradientColorStops"),s.Factory.addGetterSetter(_,"strokeLinearGradientColorStops"),s.Factory.addGetterSetter(_,"fillRadialGradientStartRadius",0),s.Factory.addGetterSetter(_,"fillRadialGradientEndRadius",0),s.Factory.addGetterSetter(_,"fillRadialGradientColorStops"),s.Factory.addGetterSetter(_,"fillPatternRepeat","repeat"),s.Factory.addGetterSetter(_,"fillEnabled",!0),s.Factory.addGetterSetter(_,"strokeEnabled",!0),s.Factory.addGetterSetter(_,"shadowEnabled",!0),s.Factory.addGetterSetter(_,"dashEnabled",!0),s.Factory.addGetterSetter(_,"strokeScaleEnabled",!0),s.Factory.addGetterSetter(_,"fillPriority","color"),s.Factory.addComponentsGetterSetter(_,"fillPatternOffset",["x","y"]),s.Factory.addGetterSetter(_,"fillPatternOffsetX",0,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"fillPatternOffsetY",0,(0,r.getNumberValidator)()),s.Factory.addComponentsGetterSetter(_,"fillPatternScale",["x","y"]),s.Factory.addGetterSetter(_,"fillPatternScaleX",1,(0,r.getNumberValidator)()),s.Factory.addGetterSetter(_,"fillPatternScaleY",1,(0,r.getNumberValidator)()),s.Factory.addComponentsGetterSetter(_,"fillLinearGradientStartPoint",["x","y"]),s.Factory.addComponentsGetterSetter(_,"strokeLinearGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillLinearGradientStartPointX",0),s.Factory.addGetterSetter(_,"strokeLinearGradientStartPointX",0),s.Factory.addGetterSetter(_,"fillLinearGradientStartPointY",0),s.Factory.addGetterSetter(_,"strokeLinearGradientStartPointY",0),s.Factory.addComponentsGetterSetter(_,"fillLinearGradientEndPoint",["x","y"]),s.Factory.addComponentsGetterSetter(_,"strokeLinearGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillLinearGradientEndPointX",0),s.Factory.addGetterSetter(_,"strokeLinearGradientEndPointX",0),s.Factory.addGetterSetter(_,"fillLinearGradientEndPointY",0),s.Factory.addGetterSetter(_,"strokeLinearGradientEndPointY",0),s.Factory.addComponentsGetterSetter(_,"fillRadialGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillRadialGradientStartPointX",0),s.Factory.addGetterSetter(_,"fillRadialGradientStartPointY",0),s.Factory.addComponentsGetterSetter(_,"fillRadialGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillRadialGradientEndPointX",0),s.Factory.addGetterSetter(_,"fillRadialGradientEndPointY",0),s.Factory.addGetterSetter(_,"fillPatternRotation",0),s.Factory.addGetterSetter(_,"fillRule",void 0,(0,r.getStringValidator)()),s.Factory.backCompat(_,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})})(Wi)),Wi}var wn;function to(){if(wn)return ye;wn=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.Layer=void 0;const i=gt(),t=Li(),e=mt(),s=st(),n=Oi(),r=nt(),a=yt(),o=it(),h="#",l="beforeDraw",d="draw",p=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],u=p.length;let g=class extends t.Container{constructor(m){super(m),this.canvas=new n.SceneCanvas,this.hitCanvas=new n.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(m){return this.getContext().clear(m),this.getHitCanvas().getContext().clear(m),this}setZIndex(m){super.setZIndex(m);const b=this.getStage();return b&&b.content&&(b.content.removeChild(this.getNativeCanvasElement()),m<b.children.length-1?b.content.insertBefore(this.getNativeCanvasElement(),b.children[m+1].getCanvas()._canvas):b.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){e.Node.prototype.moveToTop.call(this);const m=this.getStage();return m&&m.content&&(m.content.removeChild(this.getNativeCanvasElement()),m.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!e.Node.prototype.moveUp.call(this))return!1;const b=this.getStage();return!b||!b.content?!1:(b.content.removeChild(this.getNativeCanvasElement()),this.index<b.children.length-1?b.content.insertBefore(this.getNativeCanvasElement(),b.children[this.index+1].getCanvas()._canvas):b.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(e.Node.prototype.moveDown.call(this)){const m=this.getStage();if(m){const b=m.children;m.content&&(m.content.removeChild(this.getNativeCanvasElement()),m.content.insertBefore(this.getNativeCanvasElement(),b[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(e.Node.prototype.moveToBottom.call(this)){const m=this.getStage();if(m){const b=m.children;m.content&&(m.content.removeChild(this.getNativeCanvasElement()),m.content.insertBefore(this.getNativeCanvasElement(),b[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const m=this.getNativeCanvasElement();return e.Node.prototype.remove.call(this),m&&m.parentNode&&i.Util._isInDocument(m)&&m.parentNode.removeChild(m),this}getStage(){return this.parent}setSize({width:m,height:b}){return this.canvas.setSize(m,b),this.hitCanvas.setSize(m,b),this._setSmoothEnabled(),this}_validateAdd(m){const b=m.getType();b!=="Group"&&b!=="Shape"&&i.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(m){return m=m||{},m.width=m.width||this.getWidth(),m.height=m.height||this.getHeight(),m.x=m.x!==void 0?m.x:this.x(),m.y=m.y!==void 0?m.y:this.y(),e.Node.prototype._toKonvaCanvas.call(this,m)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){i.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){i.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,i.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(m){if(!this.isListening()||!this.isVisible())return null;let b=1,S=!1;for(;;){for(let y=0;y<u;y++){const c=p[y],v=this._getIntersection({x:m.x+c.x*b,y:m.y+c.y*b}),x=v.shape;if(x)return x;if(S=!!v.antialiased,!v.antialiased)break}if(S)b+=1;else return null}}_getIntersection(m){const b=this.hitCanvas.pixelRatio,S=this.hitCanvas.context.getImageData(Math.round(m.x*b),Math.round(m.y*b),1,1).data,y=S[3];if(y===255){const c=i.Util._rgbToHex(S[0],S[1],S[2]),v=a.shapes[h+c];return v?{shape:v}:{antialiased:!0}}else if(y>0)return{antialiased:!0};return{}}drawScene(m,b,S){const y=this.getLayer(),c=m||y&&y.getCanvas();return this._fire(l,{node:this}),this.clearBeforeDraw()&&c.getContext().clear(),t.Container.prototype.drawScene.call(this,c,b,S),this._fire(d,{node:this}),this}drawHit(m,b){const S=this.getLayer(),y=m||S&&S.hitCanvas;return S&&S.clearBeforeDraw()&&S.getHitCanvas().getContext().clear(),t.Container.prototype.drawHit.call(this,y,b),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(m){i.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(m)}getHitGraphEnabled(m){return i.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const m=this.parent;!!this.hitCanvas._canvas.parentNode?m.content.removeChild(this.hitCanvas._canvas):m.content.appendChild(this.hitCanvas._canvas)}destroy(){return i.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return ye.Layer=g,g.prototype.nodeType="Layer",(0,o._registerNode)(g),s.Factory.addGetterSetter(g,"imageSmoothingEnabled",!0),s.Factory.addGetterSetter(g,"clearBeforeDraw",!0),s.Factory.addGetterSetter(g,"hitGraphEnabled",!0,(0,r.getBooleanValidator)()),ye}var ve={},Sn;function iu(){if(Sn)return ve;Sn=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.FastLayer=void 0;const i=gt(),t=to(),e=it();let s=class extends t.Layer{constructor(r){super(r),this.listening(!1),i.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return ve.FastLayer=s,s.prototype.nodeType="FastLayer",(0,e._registerNode)(s),ve}var be={},Tn;function ws(){if(Tn)return be;Tn=1,Object.defineProperty(be,"__esModule",{value:!0}),be.Group=void 0;const i=gt(),t=Li(),e=it();let s=class extends t.Container{_validateAdd(r){const a=r.getType();a!=="Group"&&a!=="Shape"&&i.Util.throw("You may only add groups and shapes to groups.")}};return be.Group=s,s.prototype.nodeType="Group",(0,e._registerNode)(s),be}var xe={},Cn;function Ss(){if(Cn)return xe;Cn=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.Animation=void 0;const i=it(),t=gt(),e=(function(){return i.glob.performance&&i.glob.performance.now?function(){return i.glob.performance.now()}:function(){return new Date().getTime()}})();let s=class re{constructor(r,a){this.id=re.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:e(),frameRate:0},this.func=r,this.setLayers(a)}setLayers(r){let a=[];return r&&(a=Array.isArray(r)?r:[r]),this.layers=a,this}getLayers(){return this.layers}addLayer(r){const a=this.layers,o=a.length;for(let h=0;h<o;h++)if(a[h]._id===r._id)return!1;return this.layers.push(r),!0}isRunning(){const a=re.animations,o=a.length;for(let h=0;h<o;h++)if(a[h].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=e(),re._addAnimation(this),this}stop(){return re._removeAnimation(this),this}_updateFrameObject(r){this.frame.timeDiff=r-this.frame.lastTime,this.frame.lastTime=r,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(r){this.animations.push(r),this._handleAnimation()}static _removeAnimation(r){const a=r.id,o=this.animations,h=o.length;for(let l=0;l<h;l++)if(o[l].id===a){this.animations.splice(l,1);break}}static _runFrames(){const r={},a=this.animations;for(let o=0;o<a.length;o++){const h=a[o],l=h.layers,d=h.func;h._updateFrameObject(e());const p=l.length;let u;if(d?u=d.call(h,h.frame)!==!1:u=!0,!!u)for(let g=0;g<p;g++){const f=l[g];f._id!==void 0&&(r[f._id]=f)}}for(const o in r)r.hasOwnProperty(o)&&r[o].batchDraw()}static _animationLoop(){const r=re;r.animations.length?(r._runFrames(),t.Util.requestAnimFrame(r._animationLoop)):r.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,t.Util.requestAnimFrame(this._animationLoop))}};return xe.Animation=s,s.animations=[],s.animIdCounter=0,s.animRunning=!1,xe}var zi={},kn;function su(){return kn||(kn=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Easings=i.Tween=void 0;const t=gt(),e=Ss(),s=mt(),n=it(),r={node:1,duration:1,easing:1,onFinish:1,yoyo:1},a=1,o=2,h=3,l=["fill","stroke","shadowColor"];let d=0;class p{constructor(f,m,b,S,y,c,v){this.prop=f,this.propFunc=m,this.begin=S,this._pos=S,this.duration=c,this._change=0,this.prevPos=0,this.yoyo=v,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=b,this._change=y-this.begin,this.pause()}fire(f){const m=this[f];m&&m()}setTime(f){f>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():f<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=f,this.update())}getTime(){return this._time}setPosition(f){this.prevPos=this._pos,this.propFunc(f),this._pos=f}getPosition(f){return f===void 0&&(f=this._time),this.func(f,this.begin,this._change,this.duration)}play(){this.state=o,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=h,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(f){this.pause(),this._time=f,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const f=this.getTimer()-this._startTime;this.state===o?this.setTime(f):this.state===h&&this.setTime(this.duration-f)}pause(){this.state=a,this.fire("onPause")}getTimer(){return new Date().getTime()}}class u{constructor(f){const m=this,b=f.node,S=b._id,y=f.easing||i.Easings.Linear,c=!!f.yoyo;let v,x;typeof f.duration>"u"?v=.3:f.duration===0?v=.001:v=f.duration,this.node=b,this._id=d++;const T=b.getLayer()||(b instanceof n.Konva.Stage?b.getLayers():null);T||t.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new e.Animation(function(){m.tween.onEnterFrame()},T),this.tween=new p(x,function(O){m._tweenFunc(O)},y,0,1,v*1e3,c),this._addListeners(),u.attrs[S]||(u.attrs[S]={}),u.attrs[S][this._id]||(u.attrs[S][this._id]={}),u.tweens[S]||(u.tweens[S]={});for(x in f)r[x]===void 0&&this._addAttr(x,f[x]);this.reset(),this.onFinish=f.onFinish,this.onReset=f.onReset,this.onUpdate=f.onUpdate}_addAttr(f,m){const b=this.node,S=b._id;let y,c,v,x,T;const O=u.tweens[S][f];O&&delete u.attrs[S][O][f];let _=b.getAttr(f);if(t.Util._isArray(m))if(y=[],c=Math.max(m.length,_.length),f==="points"&&m.length!==_.length&&(m.length>_.length?(x=_,_=t.Util._prepareArrayForTween(_,m,b.closed())):(v=m,m=t.Util._prepareArrayForTween(m,_,b.closed()))),f.indexOf("fill")===0)for(let C=0;C<c;C++)if(C%2===0)y.push(m[C]-_[C]);else{const k=t.Util.colorToRGBA(_[C]);T=t.Util.colorToRGBA(m[C]),_[C]=k,y.push({r:T.r-k.r,g:T.g-k.g,b:T.b-k.b,a:T.a-k.a})}else for(let C=0;C<c;C++)y.push(m[C]-_[C]);else l.indexOf(f)!==-1?(_=t.Util.colorToRGBA(_),T=t.Util.colorToRGBA(m),y={r:T.r-_.r,g:T.g-_.g,b:T.b-_.b,a:T.a-_.a}):y=m-_;u.attrs[S][this._id][f]={start:_,diff:y,end:m,trueEnd:v,trueStart:x},u.tweens[S][f]=this._id}_tweenFunc(f){const m=this.node,b=u.attrs[m._id][this._id];let S,y,c,v,x,T,O,_;for(S in b){if(y=b[S],c=y.start,v=y.diff,_=y.end,t.Util._isArray(c))if(x=[],O=Math.max(c.length,_.length),S.indexOf("fill")===0)for(T=0;T<O;T++)T%2===0?x.push((c[T]||0)+v[T]*f):x.push("rgba("+Math.round(c[T].r+v[T].r*f)+","+Math.round(c[T].g+v[T].g*f)+","+Math.round(c[T].b+v[T].b*f)+","+(c[T].a+v[T].a*f)+")");else for(T=0;T<O;T++)x.push((c[T]||0)+v[T]*f);else l.indexOf(S)!==-1?x="rgba("+Math.round(c.r+v.r*f)+","+Math.round(c.g+v.g*f)+","+Math.round(c.b+v.b*f)+","+(c.a+v.a*f)+")":x=c+v*f;m.setAttr(S,x)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const f=this.node,m=u.attrs[f._id][this._id];m.points&&m.points.trueEnd&&f.setAttr("points",m.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const f=this.node,m=u.attrs[f._id][this._id];m.points&&m.points.trueStart&&f.points(m.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(f){return this.tween.seek(f*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const f=this.node._id,m=this._id,b=u.tweens[f];this.pause(),this.anim&&this.anim.stop();for(const S in b)delete u.tweens[f][S];delete u.attrs[f][m],u.tweens[f]&&(Object.keys(u.tweens[f]).length===0&&delete u.tweens[f],Object.keys(u.attrs[f]).length===0&&delete u.attrs[f])}}i.Tween=u,u.attrs={},u.tweens={},s.Node.prototype.to=function(g){const f=g.onFinish;g.node=this,g.onFinish=function(){this.destroy(),f&&f()},new u(g).play()},i.Easings={BackEaseIn(g,f,m,b){return m*(g/=b)*g*((1.70158+1)*g-1.70158)+f},BackEaseOut(g,f,m,b){return m*((g=g/b-1)*g*((1.70158+1)*g+1.70158)+1)+f},BackEaseInOut(g,f,m,b){let S=1.70158;return(g/=b/2)<1?m/2*(g*g*(((S*=1.525)+1)*g-S))+f:m/2*((g-=2)*g*(((S*=1.525)+1)*g+S)+2)+f},ElasticEaseIn(g,f,m,b,S,y){let c=0;return g===0?f:(g/=b)===1?f+m:(y||(y=b*.3),!S||S<Math.abs(m)?(S=m,c=y/4):c=y/(2*Math.PI)*Math.asin(m/S),-(S*Math.pow(2,10*(g-=1))*Math.sin((g*b-c)*(2*Math.PI)/y))+f)},ElasticEaseOut(g,f,m,b,S,y){let c=0;return g===0?f:(g/=b)===1?f+m:(y||(y=b*.3),!S||S<Math.abs(m)?(S=m,c=y/4):c=y/(2*Math.PI)*Math.asin(m/S),S*Math.pow(2,-10*g)*Math.sin((g*b-c)*(2*Math.PI)/y)+m+f)},ElasticEaseInOut(g,f,m,b,S,y){let c=0;return g===0?f:(g/=b/2)===2?f+m:(y||(y=b*(.3*1.5)),!S||S<Math.abs(m)?(S=m,c=y/4):c=y/(2*Math.PI)*Math.asin(m/S),g<1?-.5*(S*Math.pow(2,10*(g-=1))*Math.sin((g*b-c)*(2*Math.PI)/y))+f:S*Math.pow(2,-10*(g-=1))*Math.sin((g*b-c)*(2*Math.PI)/y)*.5+m+f)},BounceEaseOut(g,f,m,b){return(g/=b)<1/2.75?m*(7.5625*g*g)+f:g<2/2.75?m*(7.5625*(g-=1.5/2.75)*g+.75)+f:g<2.5/2.75?m*(7.5625*(g-=2.25/2.75)*g+.9375)+f:m*(7.5625*(g-=2.625/2.75)*g+.984375)+f},BounceEaseIn(g,f,m,b){return m-i.Easings.BounceEaseOut(b-g,0,m,b)+f},BounceEaseInOut(g,f,m,b){return g<b/2?i.Easings.BounceEaseIn(g*2,0,m,b)*.5+f:i.Easings.BounceEaseOut(g*2-b,0,m,b)*.5+m*.5+f},EaseIn(g,f,m,b){return m*(g/=b)*g+f},EaseOut(g,f,m,b){return-m*(g/=b)*(g-2)+f},EaseInOut(g,f,m,b){return(g/=b/2)<1?m/2*g*g+f:-m/2*(--g*(g-2)-1)+f},StrongEaseIn(g,f,m,b){return m*(g/=b)*g*g*g*g+f},StrongEaseOut(g,f,m,b){return m*((g=g/b-1)*g*g*g*g+1)+f},StrongEaseInOut(g,f,m,b){return(g/=b/2)<1?m/2*g*g*g*g*g+f:m/2*((g-=2)*g*g*g*g+2)+f},Linear(g,f,m,b){return m*g/b+f}}})(zi)),zi}var En;function nu(){return En||(En=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Konva=void 0;const t=it(),e=gt(),s=mt(),n=Li(),r=eu(),a=to(),o=iu(),h=ws(),l=_s(),d=yt(),p=Ss(),u=su(),g=Jr(),f=Oi();i.Konva=e.Util._assign(t.Konva,{Util:e.Util,Transform:e.Transform,Node:s.Node,Container:n.Container,Stage:r.Stage,stages:r.stages,Layer:a.Layer,FastLayer:o.FastLayer,Group:h.Group,DD:l.DD,Shape:d.Shape,shapes:d.shapes,Animation:p.Animation,Tween:u.Tween,Easings:u.Easings,Context:g.Context,Canvas:f.Canvas}),i.default=i.Konva})(Fi)),Fi}var _e={},Mn;function ru(){if(Mn)return _e;Mn=1,Object.defineProperty(_e,"__esModule",{value:!0}),_e.Arc=void 0;const i=st(),t=yt(),e=it(),s=nt(),n=it();let r=class extends t.Shape{_sceneFunc(o){const h=e.Konva.getAngle(this.angle()),l=this.clockwise();o.beginPath(),o.arc(0,0,this.outerRadius(),0,h,l),o.arc(0,0,this.innerRadius(),h,0,!l),o.closePath(),o.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(o){this.outerRadius(o/2)}setHeight(o){this.outerRadius(o/2)}getSelfRect(){const o=this.innerRadius(),h=this.outerRadius(),l=this.clockwise(),d=e.Konva.getAngle(l?360-this.angle():this.angle()),p=Math.cos(Math.min(d,Math.PI)),u=1,g=Math.sin(Math.min(Math.max(Math.PI,d),3*Math.PI/2)),f=Math.sin(Math.min(d,Math.PI/2)),m=p*(p>0?o:h),b=u*h,S=g*(g>0?o:h),y=f*(f>0?h:o);return{x:m,y:l?-1*y:S,width:b-m,height:y-S}}};return _e.Arc=r,r.prototype._centroid=!0,r.prototype.className="Arc",r.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],(0,n._registerNode)(r),i.Factory.addGetterSetter(r,"innerRadius",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(r,"outerRadius",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(r,"angle",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(r,"clockwise",!1,(0,s.getBooleanValidator)()),_e}var we={},Se={},On;function eo(){if(On)return Se;On=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.Line=void 0;const i=st(),t=it(),e=yt(),s=nt();function n(o,h,l,d,p,u,g){const f=Math.sqrt(Math.pow(l-o,2)+Math.pow(d-h,2)),m=Math.sqrt(Math.pow(p-l,2)+Math.pow(u-d,2)),b=g*f/(f+m),S=g*m/(f+m),y=l-b*(p-o),c=d-b*(u-h),v=l+S*(p-o),x=d+S*(u-h);return[y,c,v,x]}function r(o,h){const l=o.length,d=[];for(let p=2;p<l-2;p+=2){const u=n(o[p-2],o[p-1],o[p],o[p+1],o[p+2],o[p+3],h);isNaN(u[0])||(d.push(u[0]),d.push(u[1]),d.push(o[p]),d.push(o[p+1]),d.push(u[2]),d.push(u[3]))}return d}let a=class extends e.Shape{constructor(h){super(h),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(h){const l=this.points(),d=l.length,p=this.tension(),u=this.closed(),g=this.bezier();if(!d)return;let f=0;if(h.beginPath(),h.moveTo(l[0],l[1]),p!==0&&d>4){const m=this.getTensionPoints(),b=m.length;for(f=u?0:4,u||h.quadraticCurveTo(m[0],m[1],m[2],m[3]);f<b-2;)h.bezierCurveTo(m[f++],m[f++],m[f++],m[f++],m[f++],m[f++]);u||h.quadraticCurveTo(m[b-2],m[b-1],l[d-2],l[d-1])}else if(g)for(f=2;f<d;)h.bezierCurveTo(l[f++],l[f++],l[f++],l[f++],l[f++],l[f++]);else for(f=2;f<d;f+=2)h.lineTo(l[f],l[f+1]);u?(h.closePath(),h.fillStrokeShape(this)):h.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():r(this.points(),this.tension())}_getTensionPointsClosed(){const h=this.points(),l=h.length,d=this.tension(),p=n(h[l-2],h[l-1],h[0],h[1],h[2],h[3],d),u=n(h[l-4],h[l-3],h[l-2],h[l-1],h[0],h[1],d),g=r(h,d);return[p[2],p[3]].concat(g).concat([u[0],u[1],h[l-2],h[l-1],u[2],u[3],p[0],p[1],h[0],h[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let h=this.points();if(h.length<4)return{x:h[0]||0,y:h[1]||0,width:0,height:0};this.tension()!==0?h=[h[0],h[1],...this._getTensionPoints(),h[h.length-2],h[h.length-1]]:h=this.points();let l=h[0],d=h[0],p=h[1],u=h[1],g,f;for(let m=0;m<h.length/2;m++)g=h[m*2],f=h[m*2+1],l=Math.min(l,g),d=Math.max(d,g),p=Math.min(p,f),u=Math.max(u,f);return{x:l,y:p,width:d-l,height:u-p}}};return Se.Line=a,a.prototype.className="Line",a.prototype._attrsAffectingSize=["points","bezier","tension"],(0,t._registerNode)(a),i.Factory.addGetterSetter(a,"closed",!1),i.Factory.addGetterSetter(a,"bezier",!1),i.Factory.addGetterSetter(a,"tension",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(a,"points",[],(0,s.getNumberArrayValidator)()),Se}var Te={},Vi={},Ln;function ou(){return Ln||(Ln=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.t2length=i.getQuadraticArcLength=i.getCubicArcLength=i.binomialCoefficients=i.cValues=i.tValues=void 0,i.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],i.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],i.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];const t=(a,o,h)=>{let l,d;const u=h/2;l=0;for(let g=0;g<20;g++)d=u*i.tValues[20][g]+u,l+=i.cValues[20][g]*s(a,o,d);return u*l};i.getCubicArcLength=t;const e=(a,o,h)=>{h===void 0&&(h=1);const l=a[0]-2*a[1]+a[2],d=o[0]-2*o[1]+o[2],p=2*a[1]-2*a[0],u=2*o[1]-2*o[0],g=4*(l*l+d*d),f=4*(l*p+d*u),m=p*p+u*u;if(g===0)return h*Math.sqrt(Math.pow(a[2]-a[0],2)+Math.pow(o[2]-o[0],2));const b=f/(2*g),S=m/g,y=h+b,c=S-b*b,v=y*y+c>0?Math.sqrt(y*y+c):0,x=b*b+c>0?Math.sqrt(b*b+c):0,T=b+Math.sqrt(b*b+c)!==0?c*Math.log(Math.abs((y+v)/(b+x))):0;return Math.sqrt(g)/2*(y*v-b*x+T)};i.getQuadraticArcLength=e;function s(a,o,h){const l=n(1,h,a),d=n(1,h,o),p=l*l+d*d;return Math.sqrt(p)}const n=(a,o,h)=>{const l=h.length-1;let d,p;if(l===0)return 0;if(a===0){p=0;for(let u=0;u<=l;u++)p+=i.binomialCoefficients[l][u]*Math.pow(1-o,l-u)*Math.pow(o,u)*h[u];return p}else{d=new Array(l);for(let u=0;u<l;u++)d[u]=l*(h[u+1]-h[u]);return n(a-1,o,d)}},r=(a,o,h)=>{let l=1,d=a/o,p=(a-h(d))/o,u=0;for(;l>.001;){const g=h(d+p),f=Math.abs(a-g)/o;if(f<l)l=f,d+=p;else{const m=h(d-p),b=Math.abs(a-m)/o;b<l?(l=b,d-=p):p/=2}if(u++,u>500)break}return d};i.t2length=r})(Vi)),Vi}var An;function Ts(){if(An)return Te;An=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.Path=void 0;const i=st(),t=it(),e=yt(),s=ou();let n=class Et extends e.Shape{constructor(a){super(a),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Et.parsePathData(this.data()),this.pathLength=Et.getPathLength(this.dataArray)}_sceneFunc(a){const o=this.dataArray;a.beginPath();let h=!1;for(let l=0;l<o.length;l++){const d=o[l].command,p=o[l].points;switch(d){case"L":a.lineTo(p[0],p[1]);break;case"M":a.moveTo(p[0],p[1]);break;case"C":a.bezierCurveTo(p[0],p[1],p[2],p[3],p[4],p[5]);break;case"Q":a.quadraticCurveTo(p[0],p[1],p[2],p[3]);break;case"A":const u=p[0],g=p[1],f=p[2],m=p[3],b=p[4],S=p[5],y=p[6],c=p[7],v=f>m?f:m,x=f>m?1:f/m,T=f>m?m/f:1;a.translate(u,g),a.rotate(y),a.scale(x,T),a.arc(0,0,v,b,b+S,1-c),a.scale(1/x,1/T),a.rotate(-y),a.translate(-u,-g);break;case"z":h=!0,a.closePath();break}}!h&&!this.hasFill()?a.strokeShape(this):a.fillStrokeShape(this)}getSelfRect(){let a=[];this.dataArray.forEach(function(g){if(g.command==="A"){const f=g.points[4],m=g.points[5],b=g.points[4]+m;let S=Math.PI/180;if(Math.abs(f-b)<S&&(S=Math.abs(f-b)),m<0)for(let y=f-S;y>b;y-=S){const c=Et.getPointOnEllipticalArc(g.points[0],g.points[1],g.points[2],g.points[3],y,0);a.push(c.x,c.y)}else for(let y=f+S;y<b;y+=S){const c=Et.getPointOnEllipticalArc(g.points[0],g.points[1],g.points[2],g.points[3],y,0);a.push(c.x,c.y)}}else if(g.command==="C")for(let f=0;f<=1;f+=.01){const m=Et.getPointOnCubicBezier(f,g.start.x,g.start.y,g.points[0],g.points[1],g.points[2],g.points[3],g.points[4],g.points[5]);a.push(m.x,m.y)}else a=a.concat(g.points)});let o=a[0],h=a[0],l=a[1],d=a[1],p,u;for(let g=0;g<a.length/2;g++)p=a[g*2],u=a[g*2+1],isNaN(p)||(o=Math.min(o,p),h=Math.max(h,p)),isNaN(u)||(l=Math.min(l,u),d=Math.max(d,u));return{x:o,y:l,width:h-o,height:d-l}}getLength(){return this.pathLength}getPointAtLength(a){return Et.getPointAtLengthOfDataArray(a,this.dataArray)}static getLineLength(a,o,h,l){return Math.sqrt((h-a)*(h-a)+(l-o)*(l-o))}static getPathLength(a){let o=0;for(let h=0;h<a.length;++h)o+=a[h].pathLength;return o}static getPointAtLengthOfDataArray(a,o){let h,l=0,d=o.length;if(!d)return null;for(;l<d&&a>o[l].pathLength;)a-=o[l].pathLength,++l;if(l===d)return h=o[l-1].points.slice(-2),{x:h[0],y:h[1]};if(a<.01)return o[l].command==="M"?(h=o[l].points.slice(0,2),{x:h[0],y:h[1]}):{x:o[l].start.x,y:o[l].start.y};const p=o[l],u=p.points;switch(p.command){case"L":return Et.getPointOnLine(a,p.start.x,p.start.y,u[0],u[1]);case"C":return Et.getPointOnCubicBezier((0,s.t2length)(a,Et.getPathLength(o),v=>(0,s.getCubicArcLength)([p.start.x,u[0],u[2],u[4]],[p.start.y,u[1],u[3],u[5]],v)),p.start.x,p.start.y,u[0],u[1],u[2],u[3],u[4],u[5]);case"Q":return Et.getPointOnQuadraticBezier((0,s.t2length)(a,Et.getPathLength(o),v=>(0,s.getQuadraticArcLength)([p.start.x,u[0],u[2]],[p.start.y,u[1],u[3]],v)),p.start.x,p.start.y,u[0],u[1],u[2],u[3]);case"A":const g=u[0],f=u[1],m=u[2],b=u[3],S=u[5],y=u[6];let c=u[4];return c+=S*a/p.pathLength,Et.getPointOnEllipticalArc(g,f,m,b,c,y)}return null}static getPointOnLine(a,o,h,l,d,p,u){p=p??o,u=u??h;const g=this.getLineLength(o,h,l,d);if(g<1e-10)return{x:o,y:h};if(l===o)return{x:p,y:u+(d>h?a:-a)};const f=(d-h)/(l-o),m=Math.sqrt(a*a/(1+f*f))*(l<o?-1:1),b=f*m;if(Math.abs(u-h-f*(p-o))<1e-10)return{x:p+m,y:u+b};const S=((p-o)*(l-o)+(u-h)*(d-h))/(g*g),y=o+S*(l-o),c=h+S*(d-h),v=this.getLineLength(p,u,y,c),x=Math.sqrt(a*a-v*v),T=Math.sqrt(x*x/(1+f*f))*(l<o?-1:1),O=f*T;return{x:y+T,y:c+O}}static getPointOnCubicBezier(a,o,h,l,d,p,u,g,f){function m(x){return x*x*x}function b(x){return 3*x*x*(1-x)}function S(x){return 3*x*(1-x)*(1-x)}function y(x){return(1-x)*(1-x)*(1-x)}const c=g*m(a)+p*b(a)+l*S(a)+o*y(a),v=f*m(a)+u*b(a)+d*S(a)+h*y(a);return{x:c,y:v}}static getPointOnQuadraticBezier(a,o,h,l,d,p,u){function g(y){return y*y}function f(y){return 2*y*(1-y)}function m(y){return(1-y)*(1-y)}const b=p*g(a)+l*f(a)+o*m(a),S=u*g(a)+d*f(a)+h*m(a);return{x:b,y:S}}static getPointOnEllipticalArc(a,o,h,l,d,p){const u=Math.cos(p),g=Math.sin(p),f={x:h*Math.cos(d),y:l*Math.sin(d)};return{x:a+(f.x*u-f.y*g),y:o+(f.x*g+f.y*u)}}static parsePathData(a){if(!a)return[];let o=a;const h=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];o=o.replace(new RegExp(" ","g"),",");for(let b=0;b<h.length;b++)o=o.replace(new RegExp(h[b],"g"),"|"+h[b]);const l=o.split("|"),d=[],p=[];let u=0,g=0;const f=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let m;for(let b=1;b<l.length;b++){let S=l[b],y=S.charAt(0);for(S=S.slice(1),p.length=0;m=f.exec(S);)p.push(m[0]);const c=[];for(let v=0,x=p.length;v<x;v++){if(p[v]==="00"){c.push(0,0);continue}const T=parseFloat(p[v]);isNaN(T)?c.push(0):c.push(T)}for(;c.length>0&&!isNaN(c[0]);){let v="",x=[];const T=u,O=g;let _,C,k,L,F,N,P,A,$,w;switch(y){case"l":u+=c.shift(),g+=c.shift(),v="L",x.push(u,g);break;case"L":u=c.shift(),g=c.shift(),x.push(u,g);break;case"m":const E=c.shift(),R=c.shift();if(u+=E,g+=R,v="M",d.length>2&&d[d.length-1].command==="z"){for(let D=d.length-2;D>=0;D--)if(d[D].command==="M"){u=d[D].points[0]+E,g=d[D].points[1]+R;break}}x.push(u,g),y="l";break;case"M":u=c.shift(),g=c.shift(),v="M",x.push(u,g),y="L";break;case"h":u+=c.shift(),v="L",x.push(u,g);break;case"H":u=c.shift(),v="L",x.push(u,g);break;case"v":g+=c.shift(),v="L",x.push(u,g);break;case"V":g=c.shift(),v="L",x.push(u,g);break;case"C":x.push(c.shift(),c.shift(),c.shift(),c.shift()),u=c.shift(),g=c.shift(),x.push(u,g);break;case"c":x.push(u+c.shift(),g+c.shift(),u+c.shift(),g+c.shift()),u+=c.shift(),g+=c.shift(),v="C",x.push(u,g);break;case"S":C=u,k=g,_=d[d.length-1],_.command==="C"&&(C=u+(u-_.points[2]),k=g+(g-_.points[3])),x.push(C,k,c.shift(),c.shift()),u=c.shift(),g=c.shift(),v="C",x.push(u,g);break;case"s":C=u,k=g,_=d[d.length-1],_.command==="C"&&(C=u+(u-_.points[2]),k=g+(g-_.points[3])),x.push(C,k,u+c.shift(),g+c.shift()),u+=c.shift(),g+=c.shift(),v="C",x.push(u,g);break;case"Q":x.push(c.shift(),c.shift()),u=c.shift(),g=c.shift(),x.push(u,g);break;case"q":x.push(u+c.shift(),g+c.shift()),u+=c.shift(),g+=c.shift(),v="Q",x.push(u,g);break;case"T":C=u,k=g,_=d[d.length-1],_.command==="Q"&&(C=u+(u-_.points[0]),k=g+(g-_.points[1])),u=c.shift(),g=c.shift(),v="Q",x.push(C,k,u,g);break;case"t":C=u,k=g,_=d[d.length-1],_.command==="Q"&&(C=u+(u-_.points[0]),k=g+(g-_.points[1])),u+=c.shift(),g+=c.shift(),v="Q",x.push(C,k,u,g);break;case"A":L=c.shift(),F=c.shift(),N=c.shift(),P=c.shift(),A=c.shift(),$=u,w=g,u=c.shift(),g=c.shift(),v="A",x=this.convertEndpointToCenterParameterization($,w,u,g,P,A,L,F,N);break;case"a":L=c.shift(),F=c.shift(),N=c.shift(),P=c.shift(),A=c.shift(),$=u,w=g,u+=c.shift(),g+=c.shift(),v="A",x=this.convertEndpointToCenterParameterization($,w,u,g,P,A,L,F,N);break}d.push({command:v||y,points:x,start:{x:T,y:O},pathLength:this.calcLength(T,O,v||y,x)})}(y==="z"||y==="Z")&&d.push({command:"z",points:[],start:void 0,pathLength:0})}return d}static calcLength(a,o,h,l){let d,p,u,g;const f=Et;switch(h){case"L":return f.getLineLength(a,o,l[0],l[1]);case"C":return(0,s.getCubicArcLength)([a,l[0],l[2],l[4]],[o,l[1],l[3],l[5]],1);case"Q":return(0,s.getQuadraticArcLength)([a,l[0],l[2]],[o,l[1],l[3]],1);case"A":d=0;const m=l[4],b=l[5],S=l[4]+b;let y=Math.PI/180;if(Math.abs(m-S)<y&&(y=Math.abs(m-S)),p=f.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],m,0),b<0)for(g=m-y;g>S;g-=y)u=f.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],g,0),d+=f.getLineLength(p.x,p.y,u.x,u.y),p=u;else for(g=m+y;g<S;g+=y)u=f.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],g,0),d+=f.getLineLength(p.x,p.y,u.x,u.y),p=u;return u=f.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],S,0),d+=f.getLineLength(p.x,p.y,u.x,u.y),d}return 0}static convertEndpointToCenterParameterization(a,o,h,l,d,p,u,g,f){const m=f*(Math.PI/180),b=Math.cos(m)*(a-h)/2+Math.sin(m)*(o-l)/2,S=-1*Math.sin(m)*(a-h)/2+Math.cos(m)*(o-l)/2,y=b*b/(u*u)+S*S/(g*g);y>1&&(u*=Math.sqrt(y),g*=Math.sqrt(y));let c=Math.sqrt((u*u*(g*g)-u*u*(S*S)-g*g*(b*b))/(u*u*(S*S)+g*g*(b*b)));d===p&&(c*=-1),isNaN(c)&&(c=0);const v=c*u*S/g,x=c*-g*b/u,T=(a+h)/2+Math.cos(m)*v-Math.sin(m)*x,O=(o+l)/2+Math.sin(m)*v+Math.cos(m)*x,_=function(A){return Math.sqrt(A[0]*A[0]+A[1]*A[1])},C=function(A,$){return(A[0]*$[0]+A[1]*$[1])/(_(A)*_($))},k=function(A,$){return(A[0]*$[1]<A[1]*$[0]?-1:1)*Math.acos(C(A,$))},L=k([1,0],[(b-v)/u,(S-x)/g]),F=[(b-v)/u,(S-x)/g],N=[(-1*b-v)/u,(-1*S-x)/g];let P=k(F,N);return C(F,N)<=-1&&(P=Math.PI),C(F,N)>=1&&(P=0),p===0&&P>0&&(P=P-2*Math.PI),p===1&&P<0&&(P=P+2*Math.PI),[T,O,u,g,L,P,m,p]}};return Te.Path=n,n.prototype.className="Path",n.prototype._attrsAffectingSize=["data"],(0,t._registerNode)(n),i.Factory.addGetterSetter(n,"data"),Te}var Dn;function au(){if(Dn)return we;Dn=1,Object.defineProperty(we,"__esModule",{value:!0}),we.Arrow=void 0;const i=st(),t=eo(),e=nt(),s=it(),n=Ts();let r=class extends t.Line{_sceneFunc(o){super._sceneFunc(o);const h=Math.PI*2,l=this.points();let d=l;const p=this.tension()!==0&&l.length>4;p&&(d=this.getTensionPoints());const u=this.pointerLength(),g=l.length;let f,m;if(p){const y=[d[d.length-4],d[d.length-3],d[d.length-2],d[d.length-1],l[g-2],l[g-1]],c=n.Path.calcLength(d[d.length-4],d[d.length-3],"C",y),v=n.Path.getPointOnQuadraticBezier(Math.min(1,1-u/c),y[0],y[1],y[2],y[3],y[4],y[5]);f=l[g-2]-v.x,m=l[g-1]-v.y}else f=l[g-2]-l[g-4],m=l[g-1]-l[g-3];const b=(Math.atan2(m,f)+h)%h,S=this.pointerWidth();this.pointerAtEnding()&&(o.save(),o.beginPath(),o.translate(l[g-2],l[g-1]),o.rotate(b),o.moveTo(0,0),o.lineTo(-u,S/2),o.lineTo(-u,-S/2),o.closePath(),o.restore(),this.__fillStroke(o)),this.pointerAtBeginning()&&(o.save(),o.beginPath(),o.translate(l[0],l[1]),p?(f=(d[0]+d[2])/2-l[0],m=(d[1]+d[3])/2-l[1]):(f=l[2]-l[0],m=l[3]-l[1]),o.rotate((Math.atan2(-m,-f)+h)%h),o.moveTo(0,0),o.lineTo(-u,S/2),o.lineTo(-u,-S/2),o.closePath(),o.restore(),this.__fillStroke(o))}__fillStroke(o){const h=this.dashEnabled();h&&(this.attrs.dashEnabled=!1,o.setLineDash([])),o.fillStrokeShape(this),h&&(this.attrs.dashEnabled=!0)}getSelfRect(){const o=super.getSelfRect(),h=this.pointerWidth()/2;return{x:o.x,y:o.y-h,width:o.width,height:o.height+h*2}}};return we.Arrow=r,r.prototype.className="Arrow",(0,s._registerNode)(r),i.Factory.addGetterSetter(r,"pointerLength",10,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(r,"pointerWidth",10,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(r,"pointerAtBeginning",!1),i.Factory.addGetterSetter(r,"pointerAtEnding",!0),we}var Ce={},Rn;function hu(){if(Rn)return Ce;Rn=1,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.Circle=void 0;const i=st(),t=yt(),e=nt(),s=it();let n=class extends t.Shape{_sceneFunc(a){a.beginPath(),a.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),a.closePath(),a.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(a){this.radius()!==a/2&&this.radius(a/2)}setHeight(a){this.radius()!==a/2&&this.radius(a/2)}};return Ce.Circle=n,n.prototype._centroid=!0,n.prototype.className="Circle",n.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(n),i.Factory.addGetterSetter(n,"radius",0,(0,e.getNumberValidator)()),Ce}var ke={},Pn;function lu(){if(Pn)return ke;Pn=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.Ellipse=void 0;const i=st(),t=yt(),e=nt(),s=it();let n=class extends t.Shape{_sceneFunc(a){const o=this.radiusX(),h=this.radiusY();a.beginPath(),a.save(),o!==h&&a.scale(1,h/o),a.arc(0,0,o,0,Math.PI*2,!1),a.restore(),a.closePath(),a.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(a){this.radiusX(a/2)}setHeight(a){this.radiusY(a/2)}};return ke.Ellipse=n,n.prototype.className="Ellipse",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,s._registerNode)(n),i.Factory.addComponentsGetterSetter(n,"radius",["x","y"]),i.Factory.addGetterSetter(n,"radiusX",0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(n,"radiusY",0,(0,e.getNumberValidator)()),ke}var Ee={},In;function cu(){if(In)return Ee;In=1,Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.Image=void 0;const i=gt(),t=st(),e=yt(),s=it(),n=nt();class r extends e.Shape{constructor(o){super(o),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",h=>{this._removeImageLoad(h.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const o=this.image();o&&o.complete||o&&o.readyState===4||o&&o.addEventListener&&o.addEventListener("load",this._loadListener)}_removeImageLoad(o){o&&o.removeEventListener&&o.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const o=!!this.cornerRadius(),h=this.hasShadow();return o&&h?!0:super._useBufferCanvas(!0)}_sceneFunc(o){const h=this.getWidth(),l=this.getHeight(),d=this.cornerRadius(),p=this.attrs.image;let u;if(p){const g=this.attrs.cropWidth,f=this.attrs.cropHeight;g&&f?u=[p,this.cropX(),this.cropY(),g,f,0,0,h,l]:u=[p,0,0,h,l]}(this.hasFill()||this.hasStroke()||d)&&(o.beginPath(),d?i.Util.drawRoundedRectPath(o,h,l,d):o.rect(0,0,h,l),o.closePath(),o.fillStrokeShape(this)),p&&(d&&o.clip(),o.drawImage.apply(o,u))}_hitFunc(o){const h=this.width(),l=this.height(),d=this.cornerRadius();o.beginPath(),d?i.Util.drawRoundedRectPath(o,h,l,d):o.rect(0,0,h,l),o.closePath(),o.fillStrokeShape(this)}getWidth(){var o,h;return(o=this.attrs.width)!==null&&o!==void 0?o:(h=this.image())===null||h===void 0?void 0:h.width}getHeight(){var o,h;return(o=this.attrs.height)!==null&&o!==void 0?o:(h=this.image())===null||h===void 0?void 0:h.height}static fromURL(o,h,l=null){const d=i.Util.createImageElement();d.onload=function(){const p=new r({image:d});h(p)},d.onerror=l,d.crossOrigin="Anonymous",d.src=o}}return Ee.Image=r,r.prototype.className="Image",(0,s._registerNode)(r),t.Factory.addGetterSetter(r,"cornerRadius",0,(0,n.getNumberOrArrayOfNumbersValidator)(4)),t.Factory.addGetterSetter(r,"image"),t.Factory.addComponentsGetterSetter(r,"crop",["x","y","width","height"]),t.Factory.addGetterSetter(r,"cropX",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"cropY",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"cropWidth",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"cropHeight",0,(0,n.getNumberValidator)()),Ee}var Jt={},Gn;function du(){if(Gn)return Jt;Gn=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Tag=Jt.Label=void 0;const i=st(),t=yt(),e=ws(),s=nt(),n=it(),r=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],a="Change.konva",o="none",h="up",l="right",d="down",p="left",u=r.length;let g=class extends e.Group{constructor(b){super(b),this.on("add.konva",function(S){this._addListeners(S.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(b){let S=this,y;const c=function(){S._sync()};for(y=0;y<u;y++)b.on(r[y]+a,c)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let b=this.getText(),S=this.getTag(),y,c,v,x,T,O,_;if(b&&S){switch(y=b.width(),c=b.height(),v=S.pointerDirection(),x=S.pointerWidth(),_=S.pointerHeight(),T=0,O=0,v){case h:T=y/2,O=-1*_;break;case l:T=y+x,O=c/2;break;case d:T=y/2,O=c+_;break;case p:T=-1*x,O=c/2;break}S.setAttrs({x:-1*T,y:-1*O,width:y,height:c}),b.setAttrs({x:-1*T,y:-1*O})}}};Jt.Label=g,g.prototype.className="Label",(0,n._registerNode)(g);class f extends t.Shape{_sceneFunc(b){const S=this.width(),y=this.height(),c=this.pointerDirection(),v=this.pointerWidth(),x=this.pointerHeight(),T=this.cornerRadius();let O=0,_=0,C=0,k=0;typeof T=="number"?O=_=C=k=Math.min(T,S/2,y/2):(O=Math.min(T[0]||0,S/2,y/2),_=Math.min(T[1]||0,S/2,y/2),k=Math.min(T[2]||0,S/2,y/2),C=Math.min(T[3]||0,S/2,y/2)),b.beginPath(),b.moveTo(O,0),c===h&&(b.lineTo((S-v)/2,0),b.lineTo(S/2,-1*x),b.lineTo((S+v)/2,0)),b.lineTo(S-_,0),b.arc(S-_,_,_,Math.PI*3/2,0,!1),c===l&&(b.lineTo(S,(y-x)/2),b.lineTo(S+v,y/2),b.lineTo(S,(y+x)/2)),b.lineTo(S,y-k),b.arc(S-k,y-k,k,0,Math.PI/2,!1),c===d&&(b.lineTo((S+v)/2,y),b.lineTo(S/2,y+x),b.lineTo((S-v)/2,y)),b.lineTo(C,y),b.arc(C,y-C,C,Math.PI/2,Math.PI,!1),c===p&&(b.lineTo(0,(y+x)/2),b.lineTo(-1*v,y/2),b.lineTo(0,(y-x)/2)),b.lineTo(0,O),b.arc(O,O,O,Math.PI,Math.PI*3/2,!1),b.closePath(),b.fillStrokeShape(this)}getSelfRect(){let b=0,S=0,y=this.pointerWidth(),c=this.pointerHeight(),v=this.pointerDirection(),x=this.width(),T=this.height();return v===h?(S-=c,T+=c):v===d?T+=c:v===p?(b-=y*1.5,x+=y):v===l&&(x+=y*1.5),{x:b,y:S,width:x,height:T}}}return Jt.Tag=f,f.prototype.className="Tag",(0,n._registerNode)(f),i.Factory.addGetterSetter(f,"pointerDirection",o),i.Factory.addGetterSetter(f,"pointerWidth",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(f,"pointerHeight",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(f,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),Jt}var Me={},Fn;function io(){if(Fn)return Me;Fn=1,Object.defineProperty(Me,"__esModule",{value:!0}),Me.Rect=void 0;const i=st(),t=yt(),e=it(),s=gt(),n=nt();let r=class extends t.Shape{_sceneFunc(o){const h=this.cornerRadius(),l=this.width(),d=this.height();o.beginPath(),h?s.Util.drawRoundedRectPath(o,l,d,h):o.rect(0,0,l,d),o.closePath(),o.fillStrokeShape(this)}};return Me.Rect=r,r.prototype.className="Rect",(0,e._registerNode)(r),i.Factory.addGetterSetter(r,"cornerRadius",0,(0,n.getNumberOrArrayOfNumbersValidator)(4)),Me}var Oe={},Nn;function uu(){if(Nn)return Oe;Nn=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.RegularPolygon=void 0;const i=st(),t=yt(),e=nt(),s=it();let n=class extends t.Shape{_sceneFunc(a){const o=this._getPoints();a.beginPath(),a.moveTo(o[0].x,o[0].y);for(let h=1;h<o.length;h++)a.lineTo(o[h].x,o[h].y);a.closePath(),a.fillStrokeShape(this)}_getPoints(){const a=this.attrs.sides,o=this.attrs.radius||0,h=[];for(let l=0;l<a;l++)h.push({x:o*Math.sin(l*2*Math.PI/a),y:-1*o*Math.cos(l*2*Math.PI/a)});return h}getSelfRect(){const a=this._getPoints();let o=a[0].x,h=a[0].y,l=a[0].x,d=a[0].y;return a.forEach(p=>{o=Math.min(o,p.x),h=Math.max(h,p.x),l=Math.min(l,p.y),d=Math.max(d,p.y)}),{x:o,y:l,width:h-o,height:d-l}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(a){this.radius(a/2)}setHeight(a){this.radius(a/2)}};return Oe.RegularPolygon=n,n.prototype.className="RegularPolygon",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(n),i.Factory.addGetterSetter(n,"radius",0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(n,"sides",0,(0,e.getNumberValidator)()),Oe}var Le={},Hn;function fu(){if(Hn)return Le;Hn=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.Ring=void 0;const i=st(),t=yt(),e=nt(),s=it(),n=Math.PI*2;let r=class extends t.Shape{_sceneFunc(o){o.beginPath(),o.arc(0,0,this.innerRadius(),0,n,!1),o.moveTo(this.outerRadius(),0),o.arc(0,0,this.outerRadius(),n,0,!0),o.closePath(),o.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(o){this.outerRadius(o/2)}setHeight(o){this.outerRadius(o/2)}};return Le.Ring=r,r.prototype.className="Ring",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,s._registerNode)(r),i.Factory.addGetterSetter(r,"innerRadius",0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(r,"outerRadius",0,(0,e.getNumberValidator)()),Le}var Ae={},$n;function gu(){if($n)return Ae;$n=1,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.Sprite=void 0;const i=st(),t=yt(),e=Ss(),s=nt(),n=it();let r=class extends t.Shape{constructor(o){super(o),this._updated=!0,this.anim=new e.Animation(()=>{const h=this._updated;return this._updated=!1,h}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(o){const h=this.animation(),l=this.frameIndex(),d=l*4,p=this.animations()[h],u=this.frameOffsets(),g=p[d+0],f=p[d+1],m=p[d+2],b=p[d+3],S=this.image();if((this.hasFill()||this.hasStroke())&&(o.beginPath(),o.rect(0,0,m,b),o.closePath(),o.fillStrokeShape(this)),S)if(u){const y=u[h],c=l*2;o.drawImage(S,g,f,m,b,y[c+0],y[c+1],m,b)}else o.drawImage(S,g,f,m,b,0,0,m,b)}_hitFunc(o){const h=this.animation(),l=this.frameIndex(),d=l*4,p=this.animations()[h],u=this.frameOffsets(),g=p[d+2],f=p[d+3];if(o.beginPath(),u){const m=u[h],b=l*2;o.rect(m[b+0],m[b+1],g,f)}else o.rect(0,0,g,f);o.closePath(),o.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const o=this;this.interval=setInterval(function(){o._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const o=this.getLayer();this.anim.setLayers(o),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const o=this.frameIndex(),h=this.animation(),l=this.animations(),d=l[h],p=d.length/4;o<p-1?this.frameIndex(o+1):this.frameIndex(0)}};return Ae.Sprite=r,r.prototype.className="Sprite",(0,n._registerNode)(r),i.Factory.addGetterSetter(r,"animation"),i.Factory.addGetterSetter(r,"animations"),i.Factory.addGetterSetter(r,"frameOffsets"),i.Factory.addGetterSetter(r,"image"),i.Factory.addGetterSetter(r,"frameIndex",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(r,"frameRate",17,(0,s.getNumberValidator)()),i.Factory.backCompat(r,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Ae}var De={},Bn;function pu(){if(Bn)return De;Bn=1,Object.defineProperty(De,"__esModule",{value:!0}),De.Star=void 0;const i=st(),t=yt(),e=nt(),s=it();let n=class extends t.Shape{_sceneFunc(a){const o=this.innerRadius(),h=this.outerRadius(),l=this.numPoints();a.beginPath(),a.moveTo(0,0-h);for(let d=1;d<l*2;d++){const p=d%2===0?h:o,u=p*Math.sin(d*Math.PI/l),g=-1*p*Math.cos(d*Math.PI/l);a.lineTo(u,g)}a.closePath(),a.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(a){this.outerRadius(a/2)}setHeight(a){this.outerRadius(a/2)}};return De.Star=n,n.prototype.className="Star",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,s._registerNode)(n),i.Factory.addGetterSetter(n,"numPoints",5,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(n,"innerRadius",0,(0,e.getNumberValidator)()),i.Factory.addGetterSetter(n,"outerRadius",0,(0,e.getNumberValidator)()),De}var ne={},Un;function so(){if(Un)return ne;Un=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.Text=void 0,ne.stringToArray=a;const i=gt(),t=st(),e=yt(),s=it(),n=nt(),r=it();function a(B){return[...B].reduce((H,U,j,z)=>{if(new RegExp("\\p{Emoji}","u").test(U)){const I=z[j+1];I&&new RegExp("\\p{Emoji_Modifier}|\\u200D","u").test(I)?(H.push(U+I),z[j+1]=""):H.push(U)}else new RegExp("\\p{Regional_Indicator}{2}","u").test(U+(z[j+1]||""))?H.push(U+z[j+1]):j>0&&new RegExp("\\p{Mn}|\\p{Me}|\\p{Mc}","u").test(U)?H[H.length-1]+=U:U&&H.push(U);return H},[])}const o="auto",h="center",l="inherit",d="justify",p="Change.konva",u="2d",g="-",f="left",m="text",b="Text",S="top",y="bottom",c="middle",v="normal",x="px ",T=" ",O="right",_="rtl",C="word",k="char",L="none",F="…",N=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],P=N.length;function A(B){return B.split(",").map(H=>{H=H.trim();const U=H.indexOf(" ")>=0,j=H.indexOf('"')>=0||H.indexOf("'")>=0;return U&&!j&&(H=`"${H}"`),H}).join(", ")}let $;function w(){return $||($=i.Util.createCanvasElement().getContext(u),$)}function E(B){B.fillText(this._partialText,this._partialTextX,this._partialTextY)}function R(B){B.setAttr("miterLimit",2),B.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function D(B){return B=B||{},!B.fillLinearGradientColorStops&&!B.fillRadialGradientColorStops&&!B.fillPatternImage&&(B.fill=B.fill||"black"),B}let G=class extends e.Shape{constructor(H){super(D(H)),this._partialTextX=0,this._partialTextY=0;for(let U=0;U<P;U++)this.on(N[U]+p,this._setTextData);this._setTextData()}_sceneFunc(H){const U=this.textArr,j=U.length;if(!this.text())return;let z=this.padding(),I=this.fontSize(),W=this.lineHeight()*I,K=this.verticalAlign(),X=this.direction(),q=0,J=this.align(),Z=this.getWidth(),ot=this.letterSpacing(),tt=this.fill(),vt=this.textDecoration(),ht=vt.indexOf("underline")!==-1,pt=vt.indexOf("line-through")!==-1,se;X=X===l?H.direction:X;let At=W/2,de=c;if(s.Konva._fixTextRendering){const ut=this.measureSize("M");de="alphabetic",At=(ut.fontBoundingBoxAscent-ut.fontBoundingBoxDescent)/2+W/2}for(X===_&&H.setAttr("direction",X),H.setAttr("font",this._getContextFont()),H.setAttr("textBaseline",de),H.setAttr("textAlign",f),K===c?q=(this.getHeight()-j*W-z*2)/2:K===y&&(q=this.getHeight()-j*W-z*2),H.translate(z,q+z),se=0;se<j;se++){let ut=0,Rt=0;const Ht=U[se],Qt=Ht.text,St=Ht.width,jt=Ht.lastInParagraph;if(H.save(),J===O?ut+=Z-St-z*2:J===h&&(ut+=(Z-St-z*2)/2),ht){H.save(),H.beginPath();const Pt=s.Konva._fixTextRendering?Math.round(I/4):Math.round(I/2),$t=ut,Tt=At+Rt+Pt;H.moveTo($t,Tt);const Ct=J===d&&!jt?Z-z*2:St;H.lineTo($t+Math.round(Ct),Tt),H.lineWidth=I/15;const ue=this._getLinearGradient();H.strokeStyle=ue||tt,H.stroke(),H.restore()}if(pt){H.save(),H.beginPath();const Pt=s.Konva._fixTextRendering?-Math.round(I/4):0;H.moveTo(ut,At+Rt+Pt);const $t=J===d&&!jt?Z-z*2:St;H.lineTo(ut+Math.round($t),At+Rt+Pt),H.lineWidth=I/15;const Tt=this._getLinearGradient();H.strokeStyle=Tt||tt,H.stroke(),H.restore()}if(X!==_&&(ot!==0||J===d)){const Pt=Qt.split(" ").length-1,$t=a(Qt);for(let Tt=0;Tt<$t.length;Tt++){const Ct=$t[Tt];Ct===" "&&!jt&&J===d&&(ut+=(Z-z*2-St)/Pt),this._partialTextX=ut,this._partialTextY=At+Rt,this._partialText=Ct,H.fillStrokeShape(this),ut+=this.measureSize(Ct).width+ot}}else ot!==0&&H.setAttr("letterSpacing",`${ot}px`),this._partialTextX=ut,this._partialTextY=At+Rt,this._partialText=Qt,H.fillStrokeShape(this);H.restore(),j>1&&(At+=W)}}_hitFunc(H){const U=this.getWidth(),j=this.getHeight();H.beginPath(),H.rect(0,0,U,j),H.closePath(),H.fillStrokeShape(this)}setText(H){const U=i.Util._isString(H)?H:H==null?"":H+"";return this._setAttr(m,U),this}getWidth(){return this.attrs.width===o||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===o||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return i.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(H){var U,j,z,I,W,K,X,q,J,Z,ot;let tt=w(),vt=this.fontSize(),ht;tt.save(),tt.font=this._getContextFont(),ht=tt.measureText(H),tt.restore();const pt=vt/100;return{actualBoundingBoxAscent:(U=ht.actualBoundingBoxAscent)!==null&&U!==void 0?U:71.58203125*pt,actualBoundingBoxDescent:(j=ht.actualBoundingBoxDescent)!==null&&j!==void 0?j:0,actualBoundingBoxLeft:(z=ht.actualBoundingBoxLeft)!==null&&z!==void 0?z:-7.421875*pt,actualBoundingBoxRight:(I=ht.actualBoundingBoxRight)!==null&&I!==void 0?I:75.732421875*pt,alphabeticBaseline:(W=ht.alphabeticBaseline)!==null&&W!==void 0?W:0,emHeightAscent:(K=ht.emHeightAscent)!==null&&K!==void 0?K:100*pt,emHeightDescent:(X=ht.emHeightDescent)!==null&&X!==void 0?X:-20*pt,fontBoundingBoxAscent:(q=ht.fontBoundingBoxAscent)!==null&&q!==void 0?q:91*pt,fontBoundingBoxDescent:(J=ht.fontBoundingBoxDescent)!==null&&J!==void 0?J:21*pt,hangingBaseline:(Z=ht.hangingBaseline)!==null&&Z!==void 0?Z:72.80000305175781*pt,ideographicBaseline:(ot=ht.ideographicBaseline)!==null&&ot!==void 0?ot:-21*pt,width:ht.width,height:vt}}_getContextFont(){return this.fontStyle()+T+this.fontVariant()+T+(this.fontSize()+x)+A(this.fontFamily())}_addTextLine(H){this.align()===d&&(H=H.trim());const j=this._getTextWidth(H);return this.textArr.push({text:H,width:j,lastInParagraph:!1})}_getTextWidth(H){const U=this.letterSpacing(),j=H.length;return w().measureText(H).width+U*j}_setTextData(){let H=this.text().split(`
|
|
2
|
+
`),U=+this.fontSize(),j=0,z=this.lineHeight()*U,I=this.attrs.width,W=this.attrs.height,K=I!==o&&I!==void 0,X=W!==o&&W!==void 0,q=this.padding(),J=I-q*2,Z=W-q*2,ot=0,tt=this.wrap(),vt=tt!==L,ht=tt!==k&&vt,pt=this.ellipsis();this.textArr=[],w().font=this._getContextFont();const se=pt?this._getTextWidth(F):0;for(let At=0,de=H.length;At<de;++At){let ut=H[At],Rt=this._getTextWidth(ut);if(K&&Rt>J)for(;ut.length>0;){let Ht=0,Qt=a(ut).length,St="",jt=0;for(;Ht<Qt;){const Pt=Ht+Qt>>>1,$t=a(ut),Tt=$t.slice(0,Pt+1).join(""),Ct=this._getTextWidth(Tt);(pt&&X&&ot+z>Z?Ct+se:Ct)<=J?(Ht=Pt+1,St=Tt,jt=Ct):Qt=Pt}if(St){if(ht){const Tt=a(ut),Ct=a(St),ue=Tt[Ct.length],Es=ue===T||ue===g;let ci;if(Es&&jt<=J)ci=Ct.length;else{const Mo=Ct.lastIndexOf(T),Oo=Ct.lastIndexOf(g);ci=Math.max(Mo,Oo)+1}ci>0&&(Ht=ci,St=Tt.slice(0,Ht).join(""),jt=this._getTextWidth(St))}if(St=St.trimRight(),this._addTextLine(St),j=Math.max(j,jt),ot+=z,this._shouldHandleEllipsis(ot)){this._tryToAddEllipsisToLastLine();break}if(ut=a(ut).slice(Ht).join("").trimLeft(),ut.length>0&&(Rt=this._getTextWidth(ut),Rt<=J)){this._addTextLine(ut),ot+=z,j=Math.max(j,Rt);break}}else break}else this._addTextLine(ut),ot+=z,j=Math.max(j,Rt),this._shouldHandleEllipsis(ot)&&At<de-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),X&&ot+z>Z)break}this.textHeight=U,this.textWidth=j}_shouldHandleEllipsis(H){const U=+this.fontSize(),j=this.lineHeight()*U,z=this.attrs.height,I=z!==o&&z!==void 0,W=this.padding(),K=z-W*2;return!(this.wrap()!==L)||I&&H+j>K}_tryToAddEllipsisToLastLine(){const H=this.attrs.width,U=H!==o&&H!==void 0,j=this.padding(),z=H-j*2,I=this.ellipsis(),W=this.textArr[this.textArr.length-1];!W||!I||(U&&(this._getTextWidth(W.text+F)<z||(W.text=W.text.slice(0,W.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(W.text+F))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const H=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,U=this.hasShadow();return H&&U?!0:super._useBufferCanvas()}};return ne.Text=G,G.prototype._fillFunc=E,G.prototype._strokeFunc=R,G.prototype.className=b,G.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,r._registerNode)(G),t.Factory.overWriteSetter(G,"width",(0,n.getNumberOrAutoValidator)()),t.Factory.overWriteSetter(G,"height",(0,n.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(G,"direction",l),t.Factory.addGetterSetter(G,"fontFamily","Arial"),t.Factory.addGetterSetter(G,"fontSize",12,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(G,"fontStyle",v),t.Factory.addGetterSetter(G,"fontVariant",v),t.Factory.addGetterSetter(G,"padding",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(G,"align",f),t.Factory.addGetterSetter(G,"verticalAlign",S),t.Factory.addGetterSetter(G,"lineHeight",1,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(G,"wrap",C),t.Factory.addGetterSetter(G,"ellipsis",!1,(0,n.getBooleanValidator)()),t.Factory.addGetterSetter(G,"letterSpacing",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(G,"text","",(0,n.getStringValidator)()),t.Factory.addGetterSetter(G,"textDecoration",""),ne}var Re={},Wn;function mu(){if(Wn)return Re;Wn=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.TextPath=void 0;const i=gt(),t=st(),e=yt(),s=Ts(),n=so(),r=nt(),a=it(),o="",h="normal";function l(u){u.fillText(this.partialText,0,0)}function d(u){u.strokeText(this.partialText,0,0)}let p=class extends e.Shape{constructor(g){super(g),this.dummyCanvas=i.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return s.Path.getPathLength(this.dataArray)}_getPointAtLength(g){if(!this.attrs.data)return null;const f=this.pathLength;return g-1>f?null:s.Path.getPointAtLengthOfDataArray(g,this.dataArray)}_readDataAttribute(){this.dataArray=s.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(g){g.setAttr("font",this._getContextFont()),g.setAttr("textBaseline",this.textBaseline()),g.setAttr("textAlign","left"),g.save();const f=this.textDecoration(),m=this.fill(),b=this.fontSize(),S=this.glyphInfo;f==="underline"&&g.beginPath();for(let y=0;y<S.length;y++){g.save();const c=S[y].p0;g.translate(c.x,c.y),g.rotate(S[y].rotation),this.partialText=S[y].text,g.fillStrokeShape(this),f==="underline"&&(y===0&&g.moveTo(0,b/2+1),g.lineTo(b,b/2+1)),g.restore()}f==="underline"&&(g.strokeStyle=m,g.lineWidth=b/20,g.stroke()),g.restore()}_hitFunc(g){g.beginPath();const f=this.glyphInfo;if(f.length>=1){const m=f[0].p0;g.moveTo(m.x,m.y)}for(let m=0;m<f.length;m++){const b=f[m].p1;g.lineTo(b.x,b.y)}g.setAttr("lineWidth",this.fontSize()),g.setAttr("strokeStyle",this.colorKey),g.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return i.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(g){return n.Text.prototype.setText.call(this,g)}_getContextFont(){return n.Text.prototype._getContextFont.call(this)}_getTextSize(g){const m=this.dummyCanvas.getContext("2d");m.save(),m.font=this._getContextFont();const b=m.measureText(g);return m.restore(),{width:b.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:g,height:f}=this._getTextSize(this.attrs.text);if(this.textWidth=g,this.textHeight=f,this.glyphInfo=[],!this.attrs.data)return null;const m=this.letterSpacing(),b=this.align(),S=this.kerningFunc(),y=Math.max(this.textWidth+((this.attrs.text||"").length-1)*m,0);let c=0;b==="center"&&(c=Math.max(0,this.pathLength/2-y/2)),b==="right"&&(c=Math.max(0,this.pathLength-y));const v=(0,n.stringToArray)(this.text());let x=c;for(let T=0;T<v.length;T++){const O=this._getPointAtLength(x);if(!O)return;let _=this._getTextSize(v[T]).width+m;if(v[T]===" "&&b==="justify"){const P=this.text().split(" ").length-1;_+=(this.pathLength-y)/P}const C=this._getPointAtLength(x+_);if(!C)return;const k=s.Path.getLineLength(O.x,O.y,C.x,C.y);let L=0;if(S)try{L=S(v[T-1],v[T])*this.fontSize()}catch{L=0}O.x+=L,C.x+=L,this.textWidth+=L;const F=s.Path.getPointOnLine(L+k/2,O.x,O.y,C.x,C.y),N=Math.atan2(C.y-O.y,C.x-O.x);this.glyphInfo.push({transposeX:F.x,transposeY:F.y,text:v[T],rotation:N,p0:O,p1:C}),x+=_}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const g=[];this.glyphInfo.forEach(function(x){g.push(x.p0.x),g.push(x.p0.y),g.push(x.p1.x),g.push(x.p1.y)});let f=g[0]||0,m=g[0]||0,b=g[1]||0,S=g[1]||0,y,c;for(let x=0;x<g.length/2;x++)y=g[x*2],c=g[x*2+1],f=Math.min(f,y),m=Math.max(m,y),b=Math.min(b,c),S=Math.max(S,c);const v=this.fontSize();return{x:f-v/2,y:b-v/2,width:m-f+v,height:S-b+v}}destroy(){return i.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return Re.TextPath=p,p.prototype._fillFunc=l,p.prototype._strokeFunc=d,p.prototype._fillFuncHit=l,p.prototype._strokeFuncHit=d,p.prototype.className="TextPath",p.prototype._attrsAffectingSize=["text","fontSize","data"],(0,a._registerNode)(p),t.Factory.addGetterSetter(p,"data"),t.Factory.addGetterSetter(p,"fontFamily","Arial"),t.Factory.addGetterSetter(p,"fontSize",12,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(p,"fontStyle",h),t.Factory.addGetterSetter(p,"align","left"),t.Factory.addGetterSetter(p,"letterSpacing",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(p,"textBaseline","middle"),t.Factory.addGetterSetter(p,"fontVariant",h),t.Factory.addGetterSetter(p,"text",o),t.Factory.addGetterSetter(p,"textDecoration",""),t.Factory.addGetterSetter(p,"kerningFunc",void 0),Re}var Pe={},zn;function yu(){if(zn)return Pe;zn=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.Transformer=void 0;const i=gt(),t=st(),e=mt(),s=yt(),n=io(),r=ws(),a=it(),o=nt(),h=it(),l="tr-konva",d=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(_=>_+`.${l}`).join(" "),p="nodesRect",u=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],g={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},f="ontouchstart"in a.Konva._global;function m(_,C,k){if(_==="rotater")return k;C+=i.Util.degToRad(g[_]||0);const L=(i.Util.radToDeg(C)%360+360)%360;return i.Util._inRange(L,315+22.5,360)||i.Util._inRange(L,0,22.5)?"ns-resize":i.Util._inRange(L,45-22.5,45+22.5)?"nesw-resize":i.Util._inRange(L,90-22.5,90+22.5)?"ew-resize":i.Util._inRange(L,135-22.5,135+22.5)?"nwse-resize":i.Util._inRange(L,180-22.5,180+22.5)?"ns-resize":i.Util._inRange(L,225-22.5,225+22.5)?"nesw-resize":i.Util._inRange(L,270-22.5,270+22.5)?"ew-resize":i.Util._inRange(L,315-22.5,315+22.5)?"nwse-resize":(i.Util.error("Transformer has unknown angle for cursor detection: "+L),"pointer")}const b=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function S(_){return{x:_.x+_.width/2*Math.cos(_.rotation)+_.height/2*Math.sin(-_.rotation),y:_.y+_.height/2*Math.cos(_.rotation)+_.width/2*Math.sin(_.rotation)}}function y(_,C,k){const L=k.x+(_.x-k.x)*Math.cos(C)-(_.y-k.y)*Math.sin(C),F=k.y+(_.x-k.x)*Math.sin(C)+(_.y-k.y)*Math.cos(C);return{..._,rotation:_.rotation+C,x:L,y:F}}function c(_,C){const k=S(_);return y(_,C,k)}function v(_,C,k){let L=C;for(let F=0;F<_.length;F++){const N=a.Konva.getAngle(_[F]),P=Math.abs(N-C)%(Math.PI*2);Math.min(P,Math.PI*2-P)<k&&(L=N)}return L}let x=0,T=class extends r.Group{constructor(C){super(C),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(d,this.update),this.getNode()&&this.update()}attachTo(C){return this.setNode(C),this}setNode(C){return i.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([C])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return l+this._id}setNodes(C=[]){this._nodes&&this._nodes.length&&this.detach();const k=C.filter(F=>F.isAncestorOf(this)?(i.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);return this._nodes=C=k,C.length===1&&this.useSingleNodeRotation()?this.rotation(C[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(F=>{const N=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(F._attrsAffectingSize.length){const P=F._attrsAffectingSize.map(A=>A+"Change."+this._getEventNamespace()).join(" ");F.on(P,N)}F.on(u.map(P=>P+`.${this._getEventNamespace()}`).join(" "),N),F.on(`absoluteTransformChange.${this._getEventNamespace()}`,N),this._proxyDrag(F)}),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(C){let k;C.on(`dragstart.${this._getEventNamespace()}`,L=>{k=C.getAbsolutePosition(),!this.isDragging()&&C!==this.findOne(".back")&&this.startDrag(L,!1)}),C.on(`dragmove.${this._getEventNamespace()}`,L=>{if(!k)return;const F=C.getAbsolutePosition(),N=F.x-k.x,P=F.y-k.y;this.nodes().forEach(A=>{if(A===C||A.isDragging())return;const $=A.getAbsolutePosition();A.setAbsolutePosition({x:$.x+N,y:$.y+P}),A.startDrag(L)}),k=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(C=>{C.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(p),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(p,this.__getNodeRect)}__getNodeShape(C,k=this.rotation(),L){const F=C.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),N=C.getAbsoluteScale(L),P=C.getAbsolutePosition(L),A=F.x*N.x-C.offsetX()*N.x,$=F.y*N.y-C.offsetY()*N.y,w=(a.Konva.getAngle(C.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),E={x:P.x+A*Math.cos(w)+$*Math.sin(-w),y:P.y+$*Math.cos(w)+A*Math.sin(w),width:F.width*N.x,height:F.height*N.y,rotation:w};return y(E,-a.Konva.getAngle(k),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const k=[];this.nodes().map(w=>{const E=w.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),R=[{x:E.x,y:E.y},{x:E.x+E.width,y:E.y},{x:E.x+E.width,y:E.y+E.height},{x:E.x,y:E.y+E.height}],D=w.getAbsoluteTransform();R.forEach(function(G){const B=D.point(G);k.push(B)})});const L=new i.Transform;L.rotate(-a.Konva.getAngle(this.rotation()));let F=1/0,N=1/0,P=-1/0,A=-1/0;k.forEach(function(w){const E=L.point(w);F===void 0&&(F=P=E.x,N=A=E.y),F=Math.min(F,E.x),N=Math.min(N,E.y),P=Math.max(P,E.x),A=Math.max(A,E.y)}),L.invert();const $=L.point({x:F,y:N});return{x:$.x,y:$.y,width:P-F,height:A-N,rotation:a.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),b.forEach(C=>{this._createAnchor(C)}),this._createAnchor("rotater")}_createAnchor(C){const k=new n.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:C+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:f?10:"auto"}),L=this;k.on("mousedown touchstart",function(F){L._handleMouseDown(F)}),k.on("dragstart",F=>{k.stopDrag(),F.cancelBubble=!0}),k.on("dragend",F=>{F.cancelBubble=!0}),k.on("mouseenter",()=>{const F=a.Konva.getAngle(this.rotation()),N=this.rotateAnchorCursor(),P=m(C,F,N);k.getStage().content&&(k.getStage().content.style.cursor=P),this._cursorChange=!0}),k.on("mouseout",()=>{k.getStage().content&&(k.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(k)}_createBack(){const C=new s.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(k,L){const F=L.getParent(),N=F.padding();k.beginPath(),k.rect(-N,-N,L.width()+N*2,L.height()+N*2),k.moveTo(L.width()/2,-N),F.rotateEnabled()&&F.rotateLineVisible()&&k.lineTo(L.width()/2,-F.rotateAnchorOffset()*i.Util._sign(L.height())-N),k.fillStrokeShape(L)},hitFunc:(k,L)=>{if(!this.shouldOverdrawWholeArea())return;const F=this.padding();k.beginPath(),k.rect(-F,-F,L.width()+F*2,L.height()+F*2),k.fillStrokeShape(L)}});this.add(C),this._proxyDrag(C),C.on("dragstart",k=>{k.cancelBubble=!0}),C.on("dragmove",k=>{k.cancelBubble=!0}),C.on("dragend",k=>{k.cancelBubble=!0}),this.on("dragmove",k=>{this.update()})}_handleMouseDown(C){if(this._transforming)return;this._movingAnchorName=C.target.name().split(" ")[0];const k=this._getNodeRect(),L=k.width,F=k.height,N=Math.sqrt(Math.pow(L,2)+Math.pow(F,2));this.sin=Math.abs(F/N),this.cos=Math.abs(L/N),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const P=C.target.getAbsolutePosition(),A=C.target.getStage().getPointerPosition();this._anchorDragOffset={x:A.x-P.x,y:A.y-P.y},x++,this._fire("transformstart",{evt:C.evt,target:this.getNode()}),this._nodes.forEach($=>{$._fire("transformstart",{evt:C.evt,target:$})})}_handleMouseMove(C){let k,L,F;const N=this.findOne("."+this._movingAnchorName),P=N.getStage();P.setPointersPositions(C);const A=P.getPointerPosition();let $={x:A.x-this._anchorDragOffset.x,y:A.y-this._anchorDragOffset.y};const w=N.getAbsolutePosition();this.anchorDragBoundFunc()&&($=this.anchorDragBoundFunc()(w,$,C)),N.setAbsolutePosition($);const E=N.getAbsolutePosition();if(w.x===E.x&&w.y===E.y)return;if(this._movingAnchorName==="rotater"){const z=this._getNodeRect();k=N.x()-z.width/2,L=-N.y()+z.height/2;let I=Math.atan2(-L,k)+Math.PI/2;z.height<0&&(I-=Math.PI);const K=a.Konva.getAngle(this.rotation())+I,X=a.Konva.getAngle(this.rotationSnapTolerance()),J=v(this.rotationSnaps(),K,X)-z.rotation,Z=c(z,J);this._fitNodesInto(Z,C);return}const R=this.shiftBehavior();let D;R==="inverted"?D=this.keepRatio()&&!C.shiftKey:R==="none"?D=this.keepRatio():D=this.keepRatio()||C.shiftKey;let G=this.centeredScaling()||C.altKey;if(this._movingAnchorName==="top-left"){if(D){const z=G?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};F=Math.sqrt(Math.pow(z.x-N.x(),2)+Math.pow(z.y-N.y(),2));const I=this.findOne(".top-left").x()>z.x?-1:1,W=this.findOne(".top-left").y()>z.y?-1:1;k=F*this.cos*I,L=F*this.sin*W,this.findOne(".top-left").x(z.x-k),this.findOne(".top-left").y(z.y-L)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(N.y());else if(this._movingAnchorName==="top-right"){if(D){const z=G?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};F=Math.sqrt(Math.pow(N.x()-z.x,2)+Math.pow(z.y-N.y(),2));const I=this.findOne(".top-right").x()<z.x?-1:1,W=this.findOne(".top-right").y()>z.y?-1:1;k=F*this.cos*I,L=F*this.sin*W,this.findOne(".top-right").x(z.x+k),this.findOne(".top-right").y(z.y-L)}var B=N.position();this.findOne(".top-left").y(B.y),this.findOne(".bottom-right").x(B.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(N.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(N.x());else if(this._movingAnchorName==="bottom-left"){if(D){const z=G?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};F=Math.sqrt(Math.pow(z.x-N.x(),2)+Math.pow(N.y()-z.y,2));const I=z.x<N.x()?-1:1,W=N.y()<z.y?-1:1;k=F*this.cos*I,L=F*this.sin*W,N.x(z.x-k),N.y(z.y+L)}B=N.position(),this.findOne(".top-left").x(B.x),this.findOne(".bottom-right").y(B.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(N.y());else if(this._movingAnchorName==="bottom-right"){if(D){const z=G?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};F=Math.sqrt(Math.pow(N.x()-z.x,2)+Math.pow(N.y()-z.y,2));const I=this.findOne(".bottom-right").x()<z.x?-1:1,W=this.findOne(".bottom-right").y()<z.y?-1:1;k=F*this.cos*I,L=F*this.sin*W,this.findOne(".bottom-right").x(z.x+k),this.findOne(".bottom-right").y(z.y+L)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(G=this.centeredScaling()||C.altKey,G){const z=this.findOne(".top-left"),I=this.findOne(".bottom-right"),W=z.x(),K=z.y(),X=this.getWidth()-I.x(),q=this.getHeight()-I.y();I.move({x:-W,y:-K}),z.move({x:X,y:q})}const H=this.findOne(".top-left").getAbsolutePosition();k=H.x,L=H.y;const U=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),j=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:k,y:L,width:U,height:j,rotation:a.Konva.getAngle(this.rotation())},C)}_handleMouseUp(C){this._removeEvents(C)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(C){var k;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const L=this.getNode();x--,this._fire("transformend",{evt:C,target:L}),(k=this.getLayer())===null||k===void 0||k.batchDraw(),L&&this._nodes.forEach(F=>{var N;F._fire("transformend",{evt:C,target:F}),(N=F.getLayer())===null||N===void 0||N.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(C,k){const L=this._getNodeRect(),F=1;if(i.Util._inRange(C.width,-this.padding()*2-F,F)){this.update();return}if(i.Util._inRange(C.height,-this.padding()*2-F,F)){this.update();return}const N=new i.Transform;if(N.rotate(a.Konva.getAngle(this.rotation())),this._movingAnchorName&&C.width<0&&this._movingAnchorName.indexOf("left")>=0){const D=N.point({x:-this.padding()*2,y:0});C.x+=D.x,C.y+=D.y,C.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=D.x,this._anchorDragOffset.y-=D.y}else if(this._movingAnchorName&&C.width<0&&this._movingAnchorName.indexOf("right")>=0){const D=N.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=D.x,this._anchorDragOffset.y-=D.y,C.width+=this.padding()*2}if(this._movingAnchorName&&C.height<0&&this._movingAnchorName.indexOf("top")>=0){const D=N.point({x:0,y:-this.padding()*2});C.x+=D.x,C.y+=D.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=D.x,this._anchorDragOffset.y-=D.y,C.height+=this.padding()*2}else if(this._movingAnchorName&&C.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const D=N.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=D.x,this._anchorDragOffset.y-=D.y,C.height+=this.padding()*2}if(this.boundBoxFunc()){const D=this.boundBoxFunc()(L,C);D?C=D:i.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const P=1e7,A=new i.Transform;A.translate(L.x,L.y),A.rotate(L.rotation),A.scale(L.width/P,L.height/P);const $=new i.Transform,w=C.width/P,E=C.height/P;this.flipEnabled()===!1?($.translate(C.x,C.y),$.rotate(C.rotation),$.translate(C.width<0?C.width:0,C.height<0?C.height:0),$.scale(Math.abs(w),Math.abs(E))):($.translate(C.x,C.y),$.rotate(C.rotation),$.scale(w,E));const R=$.multiply(A.invert());this._nodes.forEach(D=>{var G;const B=D.getParent().getAbsoluteTransform(),H=D.getTransform().copy();H.translate(D.offsetX(),D.offsetY());const U=new i.Transform;U.multiply(B.copy().invert()).multiply(R).multiply(B).multiply(H);const j=U.decompose();D.setAttrs(j),(G=D.getLayer())===null||G===void 0||G.batchDraw()}),this.rotation(i.Util._getRotation(C.rotation)),this._nodes.forEach(D=>{this._fire("transform",{evt:k,target:D}),D._fire("transform",{evt:k,target:D})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(C,k){this.findOne(C).setAttrs(k)}update(){var C;const k=this._getNodeRect();this.rotation(i.Util._getRotation(k.rotation));const L=k.width,F=k.height,N=this.enabledAnchors(),P=this.resizeEnabled(),A=this.padding(),$=this.anchorSize(),w=this.find("._anchor");w.forEach(R=>{R.setAttrs({width:$,height:$,offsetX:$/2,offsetY:$/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:$/2+A,offsetY:$/2+A,visible:P&&N.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:L/2,y:0,offsetY:$/2+A,visible:P&&N.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:L,y:0,offsetX:$/2-A,offsetY:$/2+A,visible:P&&N.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:F/2,offsetX:$/2+A,visible:P&&N.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:L,y:F/2,offsetX:$/2-A,visible:P&&N.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:F,offsetX:$/2+A,offsetY:$/2-A,visible:P&&N.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:L/2,y:F,offsetY:$/2-A,visible:P&&N.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:L,y:F,offsetX:$/2-A,offsetY:$/2-A,visible:P&&N.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:L/2,y:-this.rotateAnchorOffset()*i.Util._sign(F)-A,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:L,height:F,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const E=this.anchorStyleFunc();E&&w.forEach(R=>{E(R)}),(C=this.getLayer())===null||C===void 0||C.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const C=this.findOne("."+this._movingAnchorName);C&&C.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),r.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return e.Node.prototype.toObject.call(this)}clone(C){return e.Node.prototype.clone.call(this,C)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};Pe.Transformer=T,T.isTransforming=()=>x>0;function O(_){return _ instanceof Array||i.Util.warn("enabledAnchors value should be an array"),_ instanceof Array&&_.forEach(function(C){b.indexOf(C)===-1&&i.Util.warn("Unknown anchor name: "+C+". Available names are: "+b.join(", "))}),_||[]}return T.prototype.className="Transformer",(0,h._registerNode)(T),t.Factory.addGetterSetter(T,"enabledAnchors",b,O),t.Factory.addGetterSetter(T,"flipEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(T,"resizeEnabled",!0),t.Factory.addGetterSetter(T,"anchorSize",10,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(T,"rotateEnabled",!0),t.Factory.addGetterSetter(T,"rotateLineVisible",!0),t.Factory.addGetterSetter(T,"rotationSnaps",[]),t.Factory.addGetterSetter(T,"rotateAnchorOffset",50,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(T,"rotateAnchorCursor","crosshair"),t.Factory.addGetterSetter(T,"rotationSnapTolerance",5,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(T,"borderEnabled",!0),t.Factory.addGetterSetter(T,"anchorStroke","rgb(0, 161, 255)"),t.Factory.addGetterSetter(T,"anchorStrokeWidth",1,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(T,"anchorFill","white"),t.Factory.addGetterSetter(T,"anchorCornerRadius",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(T,"borderStroke","rgb(0, 161, 255)"),t.Factory.addGetterSetter(T,"borderStrokeWidth",1,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(T,"borderDash"),t.Factory.addGetterSetter(T,"keepRatio",!0),t.Factory.addGetterSetter(T,"shiftBehavior","default"),t.Factory.addGetterSetter(T,"centeredScaling",!1),t.Factory.addGetterSetter(T,"ignoreStroke",!1),t.Factory.addGetterSetter(T,"padding",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(T,"nodes"),t.Factory.addGetterSetter(T,"node"),t.Factory.addGetterSetter(T,"boundBoxFunc"),t.Factory.addGetterSetter(T,"anchorDragBoundFunc"),t.Factory.addGetterSetter(T,"anchorStyleFunc"),t.Factory.addGetterSetter(T,"shouldOverdrawWholeArea",!1),t.Factory.addGetterSetter(T,"useSingleNodeRotation",!0),t.Factory.backCompat(T,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),Pe}var Ie={},Vn;function vu(){if(Vn)return Ie;Vn=1,Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.Wedge=void 0;const i=st(),t=yt(),e=it(),s=nt(),n=it();let r=class extends t.Shape{_sceneFunc(o){o.beginPath(),o.arc(0,0,this.radius(),0,e.Konva.getAngle(this.angle()),this.clockwise()),o.lineTo(0,0),o.closePath(),o.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(o){this.radius(o/2)}setHeight(o){this.radius(o/2)}};return Ie.Wedge=r,r.prototype.className="Wedge",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radius"],(0,n._registerNode)(r),i.Factory.addGetterSetter(r,"radius",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(r,"angle",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(r,"clockwise",!1),i.Factory.backCompat(r,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),Ie}var Ge={},Yn;function bu(){if(Yn)return Ge;Yn=1,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.Blur=void 0;const i=st(),t=mt(),e=nt();function s(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const n=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],r=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function a(h,l){const d=h.data,p=h.width,u=h.height;let g,f,m,b,S,y,c,v,x,T,O,_,C,k,L,F,N,P,A,$;const w=l+l+1,E=p-1,R=u-1,D=l+1,G=D*(D+1)/2,B=new s,H=n[l],U=r[l];let j=null,z=B,I=null,W=null;for(let K=1;K<w;K++)z=z.next=new s,K===D&&(j=z);z.next=B,m=f=0;for(let K=0;K<u;K++){_=C=k=L=b=S=y=c=0,v=D*(F=d[f]),x=D*(N=d[f+1]),T=D*(P=d[f+2]),O=D*(A=d[f+3]),b+=G*F,S+=G*N,y+=G*P,c+=G*A,z=B;for(let X=0;X<D;X++)z.r=F,z.g=N,z.b=P,z.a=A,z=z.next;for(let X=1;X<D;X++)g=f+((E<X?E:X)<<2),b+=(z.r=F=d[g])*($=D-X),S+=(z.g=N=d[g+1])*$,y+=(z.b=P=d[g+2])*$,c+=(z.a=A=d[g+3])*$,_+=F,C+=N,k+=P,L+=A,z=z.next;I=B,W=j;for(let X=0;X<p;X++)d[f+3]=A=c*H>>U,A!==0?(A=255/A,d[f]=(b*H>>U)*A,d[f+1]=(S*H>>U)*A,d[f+2]=(y*H>>U)*A):d[f]=d[f+1]=d[f+2]=0,b-=v,S-=x,y-=T,c-=O,v-=I.r,x-=I.g,T-=I.b,O-=I.a,g=m+((g=X+l+1)<E?g:E)<<2,_+=I.r=d[g],C+=I.g=d[g+1],k+=I.b=d[g+2],L+=I.a=d[g+3],b+=_,S+=C,y+=k,c+=L,I=I.next,v+=F=W.r,x+=N=W.g,T+=P=W.b,O+=A=W.a,_-=F,C-=N,k-=P,L-=A,W=W.next,f+=4;m+=p}for(let K=0;K<p;K++){C=k=L=_=S=y=c=b=0,f=K<<2,v=D*(F=d[f]),x=D*(N=d[f+1]),T=D*(P=d[f+2]),O=D*(A=d[f+3]),b+=G*F,S+=G*N,y+=G*P,c+=G*A,z=B;for(let q=0;q<D;q++)z.r=F,z.g=N,z.b=P,z.a=A,z=z.next;let X=p;for(let q=1;q<=l;q++)f=X+K<<2,b+=(z.r=F=d[f])*($=D-q),S+=(z.g=N=d[f+1])*$,y+=(z.b=P=d[f+2])*$,c+=(z.a=A=d[f+3])*$,_+=F,C+=N,k+=P,L+=A,z=z.next,q<R&&(X+=p);f=K,I=B,W=j;for(let q=0;q<u;q++)g=f<<2,d[g+3]=A=c*H>>U,A>0?(A=255/A,d[g]=(b*H>>U)*A,d[g+1]=(S*H>>U)*A,d[g+2]=(y*H>>U)*A):d[g]=d[g+1]=d[g+2]=0,b-=v,S-=x,y-=T,c-=O,v-=I.r,x-=I.g,T-=I.b,O-=I.a,g=K+((g=q+D)<R?g:R)*p<<2,b+=_+=I.r=d[g],S+=C+=I.g=d[g+1],y+=k+=I.b=d[g+2],c+=L+=I.a=d[g+3],I=I.next,v+=F=W.r,x+=N=W.g,T+=P=W.b,O+=A=W.a,_-=F,C-=N,k-=P,L-=A,W=W.next,f+=p}}const o=function(l){const d=Math.round(this.blurRadius());d>0&&a(l,d)};return Ge.Blur=o,i.Factory.addGetterSetter(t.Node,"blurRadius",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),Ge}var Fe={},jn;function xu(){if(jn)return Fe;jn=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.Brighten=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=this.brightness()*255,a=n.data,o=a.length;for(let h=0;h<o;h+=4)a[h]+=r,a[h+1]+=r,a[h+2]+=r};return Fe.Brighten=s,i.Factory.addGetterSetter(t.Node,"brightness",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),Fe}var Ne={},Kn;function _u(){if(Kn)return Ne;Kn=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.Contrast=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=Math.pow((this.contrast()+100)/100,2),a=n.data,o=a.length;let h=150,l=150,d=150;for(let p=0;p<o;p+=4)h=a[p],l=a[p+1],d=a[p+2],h/=255,h-=.5,h*=r,h+=.5,h*=255,l/=255,l-=.5,l*=r,l+=.5,l*=255,d/=255,d-=.5,d*=r,d+=.5,d*=255,h=h<0?0:h>255?255:h,l=l<0?0:l>255?255:l,d=d<0?0:d>255?255:d,a[p]=h,a[p+1]=l,a[p+2]=d};return Ne.Contrast=s,i.Factory.addGetterSetter(t.Node,"contrast",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),Ne}var He={},Xn;function wu(){if(Xn)return He;Xn=1,Object.defineProperty(He,"__esModule",{value:!0}),He.Emboss=void 0;const i=st(),t=mt(),e=gt(),s=nt(),n=function(r){const a=this.embossStrength()*10,o=this.embossWhiteLevel()*255,h=this.embossDirection(),l=this.embossBlend(),d=r.data,p=r.width,u=r.height,g=p*4;let f=0,m=0,b=u;switch(h){case"top-left":f=-1,m=-1;break;case"top":f=-1,m=0;break;case"top-right":f=-1,m=1;break;case"right":f=0,m=1;break;case"bottom-right":f=1,m=1;break;case"bottom":f=1,m=0;break;case"bottom-left":f=1,m=-1;break;case"left":f=0,m=-1;break;default:e.Util.error("Unknown emboss direction: "+h)}do{const S=(b-1)*g;let y=f;b+y<1&&(y=0),b+y>u&&(y=0);const c=(b-1+y)*p*4;let v=p;do{const x=S+(v-1)*4;let T=m;v+T<1&&(T=0),v+T>p&&(T=0);const O=c+(v-1+T)*4,_=d[x]-d[O],C=d[x+1]-d[O+1],k=d[x+2]-d[O+2];let L=_;const F=L>0?L:-L,N=C>0?C:-C,P=k>0?k:-k;if(N>F&&(L=C),P>F&&(L=k),L*=a,l){const A=d[x]+L,$=d[x+1]+L,w=d[x+2]+L;d[x]=A>255?255:A<0?0:A,d[x+1]=$>255?255:$<0?0:$,d[x+2]=w>255?255:w<0?0:w}else{let A=o-L;A<0?A=0:A>255&&(A=255),d[x]=d[x+1]=d[x+2]=A}}while(--v)}while(--b)};return He.Emboss=n,i.Factory.addGetterSetter(t.Node,"embossStrength",.5,(0,s.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"embossWhiteLevel",.5,(0,s.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"embossDirection","top-left",void 0,i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"embossBlend",!1,void 0,i.Factory.afterSetFilter),He}var $e={},qn;function Su(){if(qn)return $e;qn=1,Object.defineProperty($e,"__esModule",{value:!0}),$e.Enhance=void 0;const i=st(),t=mt(),e=nt();function s(r,a,o,h,l){const d=o-a,p=l-h;if(d===0)return h+p/2;if(p===0)return h;let u=(r-a)/d;return u=p*u+h,u}const n=function(r){const a=r.data,o=a.length;let h=a[0],l=h,d,p=a[1],u=p,g,f=a[2],m=f,b;const S=this.enhance();if(S===0)return;for(let _=0;_<o;_+=4)d=a[_+0],d<h?h=d:d>l&&(l=d),g=a[_+1],g<p?p=g:g>u&&(u=g),b=a[_+2],b<f?f=b:b>m&&(m=b);l===h&&(l=255,h=0),u===p&&(u=255,p=0),m===f&&(m=255,f=0);let y,c,v,x,T,O;if(S>0)y=l+S*(255-l),c=h-S*(h-0),v=u+S*(255-u),x=p-S*(p-0),T=m+S*(255-m),O=f-S*(f-0);else{const _=(l+h)*.5;y=l+S*(l-_),c=h+S*(h-_);const C=(u+p)*.5;v=u+S*(u-C),x=p+S*(p-C);const k=(m+f)*.5;T=m+S*(m-k),O=f+S*(f-k)}for(let _=0;_<o;_+=4)a[_+0]=s(a[_+0],h,l,c,y),a[_+1]=s(a[_+1],p,u,x,v),a[_+2]=s(a[_+2],f,m,O,T)};return $e.Enhance=n,i.Factory.addGetterSetter(t.Node,"enhance",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),$e}var Be={},Qn;function Tu(){if(Qn)return Be;Qn=1,Object.defineProperty(Be,"__esModule",{value:!0}),Be.Grayscale=void 0;const i=function(t){const e=t.data,s=e.length;for(let n=0;n<s;n+=4){const r=.34*e[n]+.5*e[n+1]+.16*e[n+2];e[n]=r,e[n+1]=r,e[n+2]=r}};return Be.Grayscale=i,Be}var Ue={},Jn;function Cu(){if(Jn)return Ue;Jn=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.HSL=void 0;const i=st(),t=mt(),e=nt();i.Factory.addGetterSetter(t.Node,"hue",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"saturation",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"luminance",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter);const s=function(n){const r=n.data,a=r.length,o=1,h=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,d=this.luminance()*127,p=o*h*Math.cos(l*Math.PI/180),u=o*h*Math.sin(l*Math.PI/180),g=.299*o+.701*p+.167*u,f=.587*o-.587*p+.33*u,m=.114*o-.114*p-.497*u,b=.299*o-.299*p-.328*u,S=.587*o+.413*p+.035*u,y=.114*o-.114*p+.293*u,c=.299*o-.3*p+1.25*u,v=.587*o-.586*p-1.05*u,x=.114*o+.886*p-.2*u;let T,O,_,C;for(let k=0;k<a;k+=4)T=r[k+0],O=r[k+1],_=r[k+2],C=r[k+3],r[k+0]=g*T+f*O+m*_+d,r[k+1]=b*T+S*O+y*_+d,r[k+2]=c*T+v*O+x*_+d,r[k+3]=C};return Ue.HSL=s,Ue}var We={},Zn;function ku(){if(Zn)return We;Zn=1,Object.defineProperty(We,"__esModule",{value:!0}),We.HSV=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=n.data,a=r.length,o=Math.pow(2,this.value()),h=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,d=o*h*Math.cos(l*Math.PI/180),p=o*h*Math.sin(l*Math.PI/180),u=.299*o+.701*d+.167*p,g=.587*o-.587*d+.33*p,f=.114*o-.114*d-.497*p,m=.299*o-.299*d-.328*p,b=.587*o+.413*d+.035*p,S=.114*o-.114*d+.293*p,y=.299*o-.3*d+1.25*p,c=.587*o-.586*d-1.05*p,v=.114*o+.886*d-.2*p;for(let x=0;x<a;x+=4){const T=r[x+0],O=r[x+1],_=r[x+2],C=r[x+3];r[x+0]=u*T+g*O+f*_,r[x+1]=m*T+b*O+S*_,r[x+2]=y*T+c*O+v*_,r[x+3]=C}};return We.HSV=s,i.Factory.addGetterSetter(t.Node,"hue",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"saturation",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"value",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),We}var ze={},tr;function Eu(){if(tr)return ze;tr=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.Invert=void 0;const i=function(t){const e=t.data,s=e.length;for(let n=0;n<s;n+=4)e[n]=255-e[n],e[n+1]=255-e[n+1],e[n+2]=255-e[n+2]};return ze.Invert=i,ze}var Ve={},er;function Mu(){if(er)return Ve;er=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Kaleidoscope=void 0;const i=st(),t=mt(),e=gt(),s=nt(),n=function(o,h,l){const d=o.data,p=h.data,u=o.width,g=o.height,f=l.polarCenterX||u/2,m=l.polarCenterY||g/2;let b=Math.sqrt(f*f+m*m),S=u-f,y=g-m;const c=Math.sqrt(S*S+y*y);b=c>b?c:b;const v=g,x=u,T=360/x*Math.PI/180;for(let O=0;O<x;O+=1){const _=Math.sin(O*T),C=Math.cos(O*T);for(let k=0;k<v;k+=1){S=Math.floor(f+b*k/v*C),y=Math.floor(m+b*k/v*_);let L=(y*u+S)*4;const F=d[L+0],N=d[L+1],P=d[L+2],A=d[L+3];L=(O+k*u)*4,p[L+0]=F,p[L+1]=N,p[L+2]=P,p[L+3]=A}}},r=function(o,h,l){const d=o.data,p=h.data,u=o.width,g=o.height,f=l.polarCenterX||u/2,m=l.polarCenterY||g/2;let b=Math.sqrt(f*f+m*m),S=u-f,y=g-m;const c=Math.sqrt(S*S+y*y);b=c>b?c:b;const v=g,x=u,T=0;let O,_;for(S=0;S<u;S+=1)for(y=0;y<g;y+=1){const C=S-f,k=y-m,L=Math.sqrt(C*C+k*k)*v/b;let F=(Math.atan2(k,C)*180/Math.PI+360+T)%360;F=F*x/360,O=Math.floor(F),_=Math.floor(L);let N=(_*u+O)*4;const P=d[N+0],A=d[N+1],$=d[N+2],w=d[N+3];N=(y*u+S)*4,p[N+0]=P,p[N+1]=A,p[N+2]=$,p[N+3]=w}},a=function(o){const h=o.width,l=o.height;let d,p,u,g,f,m,b,S,y,c,v=Math.round(this.kaleidoscopePower());const x=Math.round(this.kaleidoscopeAngle()),T=Math.floor(h*(x%360)/360);if(v<1)return;const O=e.Util.createCanvasElement();O.width=h,O.height=l;const _=O.getContext("2d").getImageData(0,0,h,l);e.Util.releaseCanvas(O),n(o,_,{polarCenterX:h/2,polarCenterY:l/2});let C=h/Math.pow(2,v);for(;C<=8;)C=C*2,v-=1;C=Math.ceil(C);let k=C,L=0,F=k,N=1;for(T+C>h&&(L=k,F=0,N=-1),p=0;p<l;p+=1)for(d=L;d!==F;d+=N)u=Math.round(d+T)%h,y=(h*p+u)*4,f=_.data[y+0],m=_.data[y+1],b=_.data[y+2],S=_.data[y+3],c=(h*p+d)*4,_.data[c+0]=f,_.data[c+1]=m,_.data[c+2]=b,_.data[c+3]=S;for(p=0;p<l;p+=1)for(k=Math.floor(C),g=0;g<v;g+=1){for(d=0;d<k+1;d+=1)y=(h*p+d)*4,f=_.data[y+0],m=_.data[y+1],b=_.data[y+2],S=_.data[y+3],c=(h*p+k*2-d-1)*4,_.data[c+0]=f,_.data[c+1]=m,_.data[c+2]=b,_.data[c+3]=S;k*=2}r(_,o,{})};return Ve.Kaleidoscope=a,i.Factory.addGetterSetter(t.Node,"kaleidoscopePower",2,(0,s.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"kaleidoscopeAngle",0,(0,s.getNumberValidator)(),i.Factory.afterSetFilter),Ve}var Ye={},ir;function Ou(){if(ir)return Ye;ir=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.Mask=void 0;const i=st(),t=mt(),e=nt();function s(u,g,f){let m=(f*u.width+g)*4;const b=[];return b.push(u.data[m++],u.data[m++],u.data[m++],u.data[m++]),b}function n(u,g){return Math.sqrt(Math.pow(u[0]-g[0],2)+Math.pow(u[1]-g[1],2)+Math.pow(u[2]-g[2],2))}function r(u){const g=[0,0,0];for(let f=0;f<u.length;f++)g[0]+=u[f][0],g[1]+=u[f][1],g[2]+=u[f][2];return g[0]/=u.length,g[1]/=u.length,g[2]/=u.length,g}function a(u,g){const f=s(u,0,0),m=s(u,u.width-1,0),b=s(u,0,u.height-1),S=s(u,u.width-1,u.height-1),y=g||10;if(n(f,m)<y&&n(m,S)<y&&n(S,b)<y&&n(b,f)<y){const c=r([m,f,S,b]),v=[];for(let x=0;x<u.width*u.height;x++){const T=n(c,[u.data[x*4],u.data[x*4+1],u.data[x*4+2]]);v[x]=T<y?0:255}return v}}function o(u,g){for(let f=0;f<u.width*u.height;f++)u.data[4*f+3]=g[f]}function h(u,g,f){const m=[1,1,1,1,0,1,1,1,1],b=Math.round(Math.sqrt(m.length)),S=Math.floor(b/2),y=[];for(let c=0;c<f;c++)for(let v=0;v<g;v++){const x=c*g+v;let T=0;for(let O=0;O<b;O++)for(let _=0;_<b;_++){const C=c+O-S,k=v+_-S;if(C>=0&&C<f&&k>=0&&k<g){const L=C*g+k,F=m[O*b+_];T+=u[L]*F}}y[x]=T===2040?255:0}return y}function l(u,g,f){const m=[1,1,1,1,1,1,1,1,1],b=Math.round(Math.sqrt(m.length)),S=Math.floor(b/2),y=[];for(let c=0;c<f;c++)for(let v=0;v<g;v++){const x=c*g+v;let T=0;for(let O=0;O<b;O++)for(let _=0;_<b;_++){const C=c+O-S,k=v+_-S;if(C>=0&&C<f&&k>=0&&k<g){const L=C*g+k,F=m[O*b+_];T+=u[L]*F}}y[x]=T>=1020?255:0}return y}function d(u,g,f){const m=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],b=Math.round(Math.sqrt(m.length)),S=Math.floor(b/2),y=[];for(let c=0;c<f;c++)for(let v=0;v<g;v++){const x=c*g+v;let T=0;for(let O=0;O<b;O++)for(let _=0;_<b;_++){const C=c+O-S,k=v+_-S;if(C>=0&&C<f&&k>=0&&k<g){const L=C*g+k,F=m[O*b+_];T+=u[L]*F}}y[x]=T}return y}const p=function(u){const g=this.threshold();let f=a(u,g);return f&&(f=h(f,u.width,u.height),f=l(f,u.width,u.height),f=d(f,u.width,u.height),o(u,f)),u};return Ye.Mask=p,i.Factory.addGetterSetter(t.Node,"threshold",0,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),Ye}var je={},sr;function Lu(){if(sr)return je;sr=1,Object.defineProperty(je,"__esModule",{value:!0}),je.Noise=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=this.noise()*255,a=n.data,o=a.length,h=r/2;for(let l=0;l<o;l+=4)a[l+0]+=h-2*h*Math.random(),a[l+1]+=h-2*h*Math.random(),a[l+2]+=h-2*h*Math.random()};return je.Noise=s,i.Factory.addGetterSetter(t.Node,"noise",.2,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),je}var Ke={},nr;function Au(){if(nr)return Ke;nr=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.Pixelate=void 0;const i=st(),t=gt(),e=mt(),s=nt(),n=function(r){let a=Math.ceil(this.pixelSize()),o=r.width,h=r.height,l=Math.ceil(o/a),d=Math.ceil(h/a),p=r.data;if(a<=0){t.Util.error("pixelSize value can not be <= 0");return}for(let u=0;u<l;u+=1)for(let g=0;g<d;g+=1){let f=0,m=0,b=0,S=0;const y=u*a,c=y+a,v=g*a,x=v+a;let T=0;for(let O=y;O<c;O+=1)if(!(O>=o))for(let _=v;_<x;_+=1){if(_>=h)continue;const C=(o*_+O)*4;f+=p[C+0],m+=p[C+1],b+=p[C+2],S+=p[C+3],T+=1}f=f/T,m=m/T,b=b/T,S=S/T;for(let O=y;O<c;O+=1)if(!(O>=o))for(let _=v;_<x;_+=1){if(_>=h)continue;const C=(o*_+O)*4;p[C+0]=f,p[C+1]=m,p[C+2]=b,p[C+3]=S}}};return Ke.Pixelate=n,i.Factory.addGetterSetter(e.Node,"pixelSize",8,(0,s.getNumberValidator)(),i.Factory.afterSetFilter),Ke}var Xe={},rr;function Du(){if(rr)return Xe;rr=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.Posterize=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=Math.round(this.levels()*254)+1,a=n.data,o=a.length,h=255/r;for(let l=0;l<o;l+=1)a[l]=Math.floor(a[l]/h)*h};return Xe.Posterize=s,i.Factory.addGetterSetter(t.Node,"levels",.5,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),Xe}var qe={},or;function Ru(){if(or)return qe;or=1,Object.defineProperty(qe,"__esModule",{value:!0}),qe.RGB=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=n.data,a=r.length,o=this.red(),h=this.green(),l=this.blue();for(let d=0;d<a;d+=4){const p=(.34*r[d]+.5*r[d+1]+.16*r[d+2])/255;r[d]=p*o,r[d+1]=p*h,r[d+2]=p*l,r[d+3]=r[d+3]}};return qe.RGB=s,i.Factory.addGetterSetter(t.Node,"red",0,function(n){return this._filterUpToDate=!1,n>255?255:n<0?0:Math.round(n)}),i.Factory.addGetterSetter(t.Node,"green",0,function(n){return this._filterUpToDate=!1,n>255?255:n<0?0:Math.round(n)}),i.Factory.addGetterSetter(t.Node,"blue",0,e.RGBComponent,i.Factory.afterSetFilter),qe}var Qe={},ar;function Pu(){if(ar)return Qe;ar=1,Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.RGBA=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=n.data,a=r.length,o=this.red(),h=this.green(),l=this.blue(),d=this.alpha();for(let p=0;p<a;p+=4){const u=1-d;r[p]=o*d+r[p]*u,r[p+1]=h*d+r[p+1]*u,r[p+2]=l*d+r[p+2]*u}};return Qe.RGBA=s,i.Factory.addGetterSetter(t.Node,"red",0,function(n){return this._filterUpToDate=!1,n>255?255:n<0?0:Math.round(n)}),i.Factory.addGetterSetter(t.Node,"green",0,function(n){return this._filterUpToDate=!1,n>255?255:n<0?0:Math.round(n)}),i.Factory.addGetterSetter(t.Node,"blue",0,e.RGBComponent,i.Factory.afterSetFilter),i.Factory.addGetterSetter(t.Node,"alpha",1,function(n){return this._filterUpToDate=!1,n>1?1:n<0?0:n}),Qe}var Je={},hr;function Iu(){if(hr)return Je;hr=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.Sepia=void 0;const i=function(t){const e=t.data,s=e.length;for(let n=0;n<s;n+=4){const r=e[n+0],a=e[n+1],o=e[n+2];e[n+0]=Math.min(255,r*.393+a*.769+o*.189),e[n+1]=Math.min(255,r*.349+a*.686+o*.168),e[n+2]=Math.min(255,r*.272+a*.534+o*.131)}};return Je.Sepia=i,Je}var Ze={},lr;function Gu(){if(lr)return Ze;lr=1,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.Solarize=void 0;const i=function(t){const e=t.data,s=t.width,n=t.height,r=s*4;let a=n;do{const o=(a-1)*r;let h=s;do{const l=o+(h-1)*4;let d=e[l],p=e[l+1],u=e[l+2];d>127&&(d=255-d),p>127&&(p=255-p),u>127&&(u=255-u),e[l]=d,e[l+1]=p,e[l+2]=u}while(--h)}while(--a)};return Ze.Solarize=i,Ze}var ti={},cr;function Fu(){if(cr)return ti;cr=1,Object.defineProperty(ti,"__esModule",{value:!0}),ti.Threshold=void 0;const i=st(),t=mt(),e=nt(),s=function(n){const r=this.threshold()*255,a=n.data,o=a.length;for(let h=0;h<o;h+=1)a[h]=a[h]<r?0:255};return ti.Threshold=s,i.Factory.addGetterSetter(t.Node,"threshold",.5,(0,e.getNumberValidator)(),i.Factory.afterSetFilter),ti}var dr;function Nu(){if(dr)return ge;dr=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.Konva=void 0;const i=nu(),t=ru(),e=au(),s=hu(),n=lu(),r=cu(),a=du(),o=eo(),h=Ts(),l=io(),d=uu(),p=fu(),u=gu(),g=pu(),f=so(),m=mu(),b=yu(),S=vu(),y=bu(),c=xu(),v=_u(),x=wu(),T=Su(),O=Tu(),_=Cu(),C=ku(),k=Eu(),L=Mu(),F=Ou(),N=Lu(),P=Au(),A=Du(),$=Ru(),w=Pu(),E=Iu(),R=Gu(),D=Fu();return ge.Konva=i.Konva.Util._assign(i.Konva,{Arc:t.Arc,Arrow:e.Arrow,Circle:s.Circle,Ellipse:n.Ellipse,Image:r.Image,Label:a.Label,Tag:a.Tag,Line:o.Line,Path:h.Path,Rect:l.Rect,RegularPolygon:d.RegularPolygon,Ring:p.Ring,Sprite:u.Sprite,Star:g.Star,Text:f.Text,TextPath:m.TextPath,Transformer:b.Transformer,Wedge:S.Wedge,Filters:{Blur:y.Blur,Brighten:c.Brighten,Contrast:v.Contrast,Emboss:x.Emboss,Enhance:T.Enhance,Grayscale:O.Grayscale,HSL:_.HSL,HSV:C.HSV,Invert:k.Invert,Kaleidoscope:L.Kaleidoscope,Mask:F.Mask,Noise:N.Noise,Pixelate:P.Pixelate,Posterize:A.Posterize,RGB:$.RGB,RGBA:w.RGBA,Sepia:E.Sepia,Solarize:R.Solarize,Threshold:D.Threshold}}),ge}var Hu=pi.exports,ur;function $u(){if(ur)return pi.exports;ur=1,Object.defineProperty(Hu,"__esModule",{value:!0});const i=Nu();return pi.exports=i.Konva,pi.exports}var Bu=$u();const Y=br(Bu);var Uu=Object.defineProperty,Wu=(i,t,e)=>t in i?Uu(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,M=(i,t,e)=>Wu(i,typeof t!="symbol"?t+"":t,e);const zu="0.1.0";function Vu(){const i="#eca710";[" __ __ _____ _____ _____ _____ _____ ","| | || __|| _ || | ||_ _||_ _|","|- -|| | || || | | | | | | | ","|__|__||_____||__|__||_|___| |_| |_| "].forEach(r=>{console.log(`%c${r}`,`color: ${i}; font-weight: bold; font-family: monospace;`)}),console.log(`%c 🚀 欢迎使用 XGantt %c Version: ${zu} `,"background-color: #e7209e; color: #ffffff; padding: 2px 4px; border-radius: 6px 0 0 6px; font-weight: bold; margin: 4px 0;","background-color: #1c42e8; color: #ffffff; padding: 2px 4px; border-radius: 0 6px 6px 0; font-weight: normal; margin: 4px 0;")}const ss=class bt{static setOptions(t){bt.options={...bt.options,...t}}static getLevel(){return bt.options.level}static debug(...t){bt.logWithLevel(1,console.debug,...t)}static info(...t){bt.logWithLevel(2,console.info,...t)}static warn(...t){bt.logWithLevel(3,console.warn,...t)}static error(...t){bt.logWithLevel(4,console.error,...t)}static assert(t,...e){if(!t&&bt.options.level<=4){const s=bt.formatArgs("Assertion failed:",...e);console.error(...s)}}static getMessage(...t){return bt.formatArgs(...t).join("")}static exception(...t){return new Error(bt.getMessage(...t))}static logWithLevel(t,e,...s){if(bt.options.level<=t){const n=bt.formatArgs(...s);e(...n)}}static formatArgs(...t){const e=[bt.Prefix];return bt.options.showTimestamp&&e.unshift(`[${et().format("YYYY-MM-DD HH:mm:ss.SSS")}]`),[e.join(""),...t]}};M(ss,"Prefix","[XGantt]"),M(ss,"options",{level:2,showTimestamp:!1});let Q=ss;const Yi=()=>({data:[],links:{show:!1,key:"id",data:[],distance:20,dash:[0],width:1,gap:5,arrow:{width:6,height:8},radius:3,create:{enabled:!1,mode:"hover",radius:3,width:2,from:!0,to:!0},move:{enabled:!1},enableCycleDetection:!0},baselines:{data:[],taskKey:"taskId",show:!1,fields:{startTime:"startTime",endTime:"endTime",name:"name",id:"id",target:"target",highlight:"highlight"},mode:"line",position:"bottom",backgroundColor:"#999",opacity:.6,radius:2,label:{show:!1,forceDisplay:!1,color:"#666",fontSize:10,position:"right",fontFamily:"Arial"},compare:{enabled:!1,tolerance:.5,mode:"both",target:"end",delayed:{backgroundColor:"#ff4444",opacity:.8},ahead:{backgroundColor:"#44ff44",opacity:.8},indicator:{show:!0,position:"top",fontFamily:"Arial",fontSize:10,size:6,delayed:{show:!0,color:"#af1b1b",opacity:1},ahead:{show:!0,color:"#1baf1b",opacity:1},ontime:{show:!1,color:"#999",opacity:1}}}},milestone:{show:!1,shape:"diamond",border:{width:1},label:{show:!0,text:"",fontSize:10,fontFamily:"Arial",position:"top-right"}},summary:{show:!1,mode:"expand",move:{enabled:!1}},fields:{id:"id",startTime:"startTime",endTime:"endTime",name:"name",progress:"progress",children:"children",type:"type"},selection:{enabled:!1,includeSelf:!0},expand:{show:!0,enabled:!0},drag:{enabled:!1,color:"#999",targetOpacity:.2},dateFormat:"YYYY-MM-DD HH:mm:ss",locale:"en",unit:"day",table:{width:100,ellipsis:!0,align:"left",headerAlign:"center",emptyText:"-"},chart:{autoCellWidth:!1,cellWidth:"normal",showVerticalLine:!1},primaryColor:"#eca710",border:{color:"#e5e5e5"},collapse:{show:!0,backgroundColor:"#fff",radius:6},header:{height:80,color:"auto",fontSize:14,fontWeight:600,fontFamily:"Arial"},row:{height:30,indent:16,hover:{backgroundColor:"#000",opacity:.05},select:{backgroundColor:"#000",opacity:.1}},bar:{height:20,show:!0,move:{byUnit:!1,link:{child:"none",parent:"none"}}},today:{show:!0,type:"line",backgroundColor:"lightblue",opacity:1,width:1},weekend:{show:!0,backgroundColor:"#c9c9c9",opacity:.1},holiday:{opacity:.1}});class Yu{constructor(){M(this,"options",Yi())}getOptions(){return this.options}setOptions(t,e={merge:!0}){var s,n;if(this.options=e.merge?_i(Yi(),this.options,t):_i(Yi(),t),(s=t.holiday)!=null&&s.holidays&&t.holiday.holidays.length>0){const r=[];t.holiday.holidays.forEach(a=>{if(ft(a.date)){const o=a.date.map(h=>et(h)).sort((h,l)=>h.diff(l));for(let h=1;h<o.length;h++)if(o[h].diff(o[h-1],"day")>1){r.push({...a,date:o.slice(0,h).map(l=>l.valueOf())}),o.splice(0,h);break}o.length>0&&r.push({...a,date:o.map(h=>h.valueOf())})}else r.push(a)}),this.options.holiday.holidays=r}if(((n=t.chart)==null?void 0:n.showVerticalLine)===void 0&&!this.options.scaleUnit){const r=this.options.unit;(r==="day"||r==="hour")&&(this.options.chart.showVerticalLine=!0)}}update(t){this.setOptions(t)}getRowBackgroundColor(t){var e;let s="";const n=(e=this.options.row)==null?void 0:e.backgroundColor;return Ft(n)?s=n:ft(n)&&n.length>0?s=n[t.level]:Bt(n)&&(s=n(t.getEmitData())),s}unpackFunc(t,e){return Bt(t)?t(e.getEmitData()):t}}class ju{constructor(){M(this,"events",new Map)}on(t,e){var s;this.events.has(t)||this.events.set(t,[]),(s=this.events.get(t))==null||s.push(e)}emit(t,...e){var s;this.events.has(t)&&((s=this.events.get(t))==null||s.forEach(n=>n(...e)))}off(t,e){var s;this.events.has(t)&&this.events.set(t,((s=this.events.get(t))==null?void 0:s.filter(n=>n!==e))||[])}offAll(){this.events.clear()}}var V=(i=>(i.LOADED="loaded",i.COLUMN_WIDTH_CHANGE="column-width-change",i.MOVE_GUIDELINE="move-guideline",i.SHOW_GUIDELINE="show-guideline",i.HIDE_GUIDELINE="hide-guideline",i.TOGGLE_COLLAPSE="toggle-collapse",i.SCROLL="scroll",i.CHART_OFFSET_CHANGE="chart_offset_change",i.DATA_UPDATE="data-update",i.VIEW_UPDATE="view-update",i.OPTIONS_UPDATE="options-update",i.UPDATE_TABLE_HEADER="update_table_header",i.UPDATE_TABLE_BODY="update_table_body",i.UPDATE_CHART_HEADER="update_chart_header",i.UPDATE_TASK="update_task",i.UPDATE_LINK="update_link",i.CREATE_LINK="create_link",i.TASK_SELECTED="task_selected",i.TASK_UNSELECTED="task_unselected",i.SELECT_LINK="select_link",i.CHECK_TASK="check_task",i.CONTEXT_LINK="context_link",i.ROW_CLICK="row-click",i.ROW_DBL_CLICK="row-dbl-click",i.ROW_CONTEXTMENU="row-contextmenu",i.SLIDER_CLICK="slider-click",i.SLIDER_DBL_CLICK="slider-dbl-click",i.SLIDER_CONTEXTMENU="slider-contextmenu",i.SLIDER_DRAGGING="slider-dragging",i.SLIDER_ENTER="slider-enter",i.SLIDER_HOVER="slider-hover",i.SLIDER_LEAVE="slider-leave",i.SLIDER_BLINK="slider-blink",i.LINK_BLINK="link-blink",i.ROW_HIGHLIGHT="row-highlight",i.ROW_UNHIGHLIGHT="row-unhighlight",i.TASK_DRAG_START="task-drag-start",i.TASK_DRAG_MOVE="task-drag-move",i.TASK_DRAG_END="task-drag-end",i.BASELINE_CLICK="baseline-click",i.BASELINE_CONTEXTMENU="baseline-contextmenu",i.BASELINE_MOUSEENTER="baseline-mouseenter",i.BASELINE_MOUSEMOVE="baseline-mousemove",i.BASELINE_MOUSEOUT="baseline-mouseout",i.ROW_DRAG_START="row-drag-start",i.ROW_DRAGGING="row-dragging",i.ROW_DRAG_END="row-drag-end",i.ERROR="error",i))(V||{}),xt=(i=>(i.INVALID_TYPE="INVALID_TYPE",i.TASK_NOT_FOUND="TASK_NOT_FOUND",i.LINK_NOT_ALLOWED="LINK_NOT_ALLOWED",i.LINK_SAME="LINK_SAME",i.LINK_EXIST="LINK_EXIST",i.LINK_INVALID_ARG="LINK_INVALID_ARG",i.LINK_CYCLE="LINK_CYCLE",i.MOVE_INVALID_TARGET="MOVE_INVALID_TARGET",i.MOVE_CIRCULAR_DEPENDENCY="MOVE_CIRCULAR_DEPENDENCY",i.MOVE_INVALID_HIERARCHY="MOVE_INVALID_HIERARCHY",i))(xt||{});function te(){return Math.random().toString(36).substring(2,15)}function at(i,t,e){if(!Number.isFinite(i)||!Number.isFinite(t)||!Number.isFinite(e))return Number.isFinite(t)?t:0;const s=Math.min(t,e),n=Math.max(t,e);return Math.min(Math.max(s,i),n)}function mi(i,t){let e=i;return Ft(e)&&(/%$/.test(e)?e=t*parseFloat(e)/100:e=parseFloat(e)),isNaN(e)?0:e}function ji(i,t,e="round"){if(t===0)throw new Error("基准值不能为0");if(Math.abs(i)<=t/2)return 0;const s=Math.floor(i/t),n=Math.ceil(i/t),r=s*t,a=n*t,o=Math.abs(i-r),h=Math.abs(i-a);return e==="floor"?r:e==="ceil"?a:o<=h?r:a}function yi(i,t=4){return typeof i=="number"?[i,i,i,i]:Array.isArray(i)?[i[0]??t,i[1]??t,i[2]??t,i[3]??t]:[t,t,t,t]}function Ku(i,t=100){if(!Number.isFinite(i)||!Number.isFinite(t)||t===0||i<0)return 0;const e=i/Math.abs(t);return Math.min(e,1)}function ns(i,t=2,e=!1){const s=i.toFixed(t);return e?s:s.replace(/\.?0+$/,"")}const Ki=new Map;function fr(i,t=16,e=16){const s=Ki.get(i);if(s)return s;const n=new Promise((r,a)=>{let o=i;if(!/viewBox\s*=\s*["'][^"']*["']/.test(o)){const p=o.match(/width\s*=\s*["']([^"']*)["']/),u=o.match(/height\s*=\s*["']([^"']*)["']/),g=p?parseFloat(p[1]):t,f=u?parseFloat(u[1]):e;o=o.replace(/<svg([^>]*)>/,`<svg$1 viewBox="0 0 ${g} ${f}">`)}o=o.replace(/width\s*=\s*["'][^"']*["']/,`width="${t}"`),o=o.replace(/height\s*=\s*["'][^"']*["']/,`height="${e}"`),/width\s*=/.test(o)||(o=o.replace(/<svg/,`<svg width="${t}"`)),/height\s*=/.test(o)||(o=o.replace(/<svg/,`<svg height="${e}"`)),/preserveAspectRatio\s*=/.test(o)||(o=o.replace(/<svg([^>]*)>/,'<svg$1 preserveAspectRatio="xMidYMid meet">'));const h=new Image;h.onload=()=>{URL.revokeObjectURL(h.src),r(h)},h.onerror=p=>{URL.revokeObjectURL(h.src),Ki.delete(i),a(p)};const l=new Blob([o],{type:"image/svg+xml"}),d=URL.createObjectURL(l);h.src=d});return Ki.set(i,n),n}class Cs{constructor(t,e,s,n,r){M(this,"__key__",te()),M(this,"id"),M(this,"name"),M(this,"startTime"),M(this,"endTime"),M(this,"progress"),M(this,"type"),M(this,"expanded"),M(this,"children"),M(this,"parent"),M(this,"level"),M(this,"flatIndex"),M(this,"duration",0),M(this,"data"),M(this,"fields"),this.store=t,this.event=e,this.fields=this.store.getOptionManager().getOptions().fields,this.id=r||s[this.fields.id]||te(),this.data=s,this.name=s[this.fields.name]||"",this.type=s[this.fields.type]||"task",this.updateMode(),this.progress=s[this.fields.progress],this.expanded=this.store.getOptionManager().getOptions().expand.show?this.store.getOptionManager().getOptions().expand.enabled:!0,this.children=[],this.level=n&&n.level!==void 0?n.level+1:0,this.parent=n,this.flatIndex=0,this.store.updateTime(this.startTime,this.endTime)}getField(t){if(!t||Ft(t)&&t.trim()==="")return;if(!t.includes("."))return this.data[t];const e=t.split(".");let s=this.data;for(let n=0;n<e.length;n++){const r=e[n];if(s==null||typeof s!="object"||!(r in s))return;s=s[r]}return _t(s)?le(s):s}updateMode(){let t=!1,e=!1;return this.data[this.fields.startTime]&&(!this.startTime||!this.startTime.isSame(et(this.data[this.fields.startTime])))&&(this.startTime=et(this.data[this.fields.startTime]),t=!0,e=!0),this.data[this.fields.endTime]&&(!this.endTime||!this.endTime.isSame(et(this.data[this.fields.endTime])))&&(this.endTime=et(this.data[this.fields.endTime]),t=!0,e=!0),e&&this.store.updateTime(this.startTime,this.endTime),this.startTime&&this.endTime&&this.duration===0&&(this.duration=this.endTime.diff(this.startTime)),this.isMilestone()&&(!this.endTime||!this.endTime.isSame(this.startTime))&&(this.endTime=this.startTime,t=!0),t}updateData(t){this.data=t;let e=!1;t[this.fields.name]&&this.name!==t[this.fields.name]&&(this.name=t[this.fields.name],e=!0),t[this.fields.type]&&this.type!==t[this.fields.type]&&(this.type=t[this.fields.type],e=!0),e=this.updateMode(),t[this.fields.progress]!==void 0&&(this.progress!==t[this.fields.progress]&&(e=!0),this.progress=at(t[this.fields.progress],0,100)),e&&this.event.emit(V.UPDATE_TASK,this)}updateTime(t,e){var s,n;this.startTime=t,this.endTime=this.isMilestone()?t:e;const r=(n=(s=this.store)==null?void 0:s.getOptionManager().getOptions())==null?void 0:n.dateFormat;this.data[this.fields.startTime||"startTime"]=this.startTime.format(r),this.isMilestone()?this.data[this.fields.endTime||"endTime"]=this.startTime.add(this.duration).format(r):this.data[this.fields.endTime||"endTime"]=this.endTime.format(r),this.event.emit(V.UPDATE_TASK,this)}clone(){return new Cs(this.store,this.event,le(this.data),this.parent,this.id)}getEmitData(){return{data:this.data,$index:this.flatIndex,level:this.level+1}}getAllChildren(){const t=[],e=s=>{s.forEach(n=>{t.push(n),ft(n.children)&&n.children.length>0&&e(n.children)})};return e(this.children),t}isMilestone(){return this.store.getOptionManager().getOptions().milestone.show?this.type==="milestone":!1}isSummary(){return this.store.getOptionManager().getOptions().summary.show?this.type==="summary":!1}isSomeoneChildren(t){let e=t;for(;e;){if(e.id===this.id)return!0;e=e.parent}return!1}}class Xu{constructor(t,e,s){M(this,"id"),M(this,"taskId"),M(this,"startTime"),M(this,"endTime"),M(this,"name"),M(this,"data"),M(this,"highlight",!0),M(this,"target",!1),this.store=t,this.event=e;const n=this.store.getOptionManager().getOptions().fields,r=this.store.getOptionManager().getOptions().baselines.fields;this.taskId=s[t.getOptionManager().getOptions().baselines.taskKey],this.id=s[n.id]||s[r.id]||te(),this.name=s[n.name]||s[r.name]||"",this.highlight=s[r.highlight]!==!1,this.target=s[r.target]===!0;const a=s[n.startTime]||s[r.startTime];a&&(this.startTime=et(a));const o=s[n.endTime]||s[r.endTime];o&&(this.endTime=et(o)),this.data=s}getField(t){return this.data[t]}validate(){return!this.taskId||!this.startTime||!this.endTime?!1:this.startTime.isBefore(this.endTime)}getTimeDiff(){if(!this.validate())return null;const t=this.store.getDataManager().getTaskById(this.taskId);if(!t||!t.startTime||!t.endTime)return null;const e=this.store.getTimeAxis().getCellUnit(),s=this.startTime.diff(t.startTime,e,!0),n=this.endTime.diff(t.endTime,e,!0),r=this.store.getOptionManager().getOptions().baselines.compare.tolerance,a=s<-r?"delayed":s>r?"ahead":"ontime",o=n<-r?"delayed":n>r?"ahead":"ontime",h=this.endTime.diff(this.startTime,e,!0),l=t.endTime.diff(t.startTime,e,!0),d=h>0?(l-h)/h*100:0;return{startDiff:s,endDiff:n,startStatus:a,endStatus:o,progressDiff:d,unit:e}}}class qu{constructor(t,e){M(this,"rawData",[]),M(this,"tasks",[]),M(this,"taskMap",new Map),M(this,"visibleTasksCache",[]),M(this,"isDirty",!0),M(this,"collapsedTaskIds",new Set),M(this,"selectedTaskId",null),M(this,"checkedList",[]),M(this,"baselines",[]),M(this,"baselineMap",new Map),M(this,"baselineTaskMap",new Map),M(this,"dataLevel",0),this.store=t,this.event=e}setData(t,e=!1){this.rawData=t,this.initTasks(e),this.invalidateCache(),this.event.emit(V.DATA_UPDATE)}initTasks(t=!1){t?(this.dataLevel=0,this.tasks=[],this.taskMap.clear(),this.collapsedTaskIds.clear(),this.rawData.forEach(e=>{this.tasks.push(this.createTask(e))})):this.rawData.length>0?(this.dataLevel=0,this.updateTask(this.rawData,this.tasks)):(this.tasks=[],this.taskMap.clear(),this.collapsedTaskIds.clear(),this.dataLevel=0)}createTask(t,e,s=!0){const n=this.store.getOptionManager().getOptions().fields,r=new Cs(this.store,this.event,t,e);return s&&Array.isArray(t[n.children])&&(r.children=t[n.children].map(a=>this.createTask(a,r))),this.taskMap.set(r.id,r),this.dataLevel=Math.max(this.dataLevel,r.level),r}updateTask(t,e,s){const n=this.store.getOptionManager().getOptions(),r=n.fields.id,a=n.fields.children,o=new Map;e.forEach(h=>o.set(h.id,h)),e.length=0;for(const h of t){const l=h[r];let d=o.get(l);d?(d.updateData(h),d.parent=s,o.delete(l)):d=this.createTask(h,s,!1),d.level=s?s.level+1:0,this.dataLevel=Math.max(this.dataLevel,d.level);const p=h[a];Array.isArray(p)&&p.length>0?(d.children||(d.children=[]),this.updateTask(p,d.children,d)):d.children&&d.children.length>0&&(this.removeTasksRecursive(d.children),d.children=[]),e.push(d)}o.size>0&&this.removeTasksRecursive(Array.from(o.values()))}removeTasksRecursive(t){t.forEach(e=>{this.taskMap.delete(e.id),this.collapsedTaskIds.delete(e.id),this.selectedTaskId===e.id&&(this.selectedTaskId=null,this.event.emit(V.TASK_UNSELECTED,e.id));const s=this.checkedList.findIndex(n=>n.id===e.id);s!==-1&&this.checkedList.splice(s,1),e.children&&e.children.length>0&&this.removeTasksRecursive(e.children)})}getData(){return this.rawData}getTasks(t=!0){return t?this.tasks:Array.from(this.taskMap.values())}getDataSize(){return this.taskMap.size}getTaskById(t){return this.taskMap.get(t)}deleteTaskById(t){var e;const s=this.getTaskById(t);if(!s)return!1;let n=!1;const r=this.store.getOptionManager().getOptions().fields.id,a=(e=s.parent)==null?void 0:e.children.findIndex(o=>o.id===t);if(a!==void 0&&a>-1&&s.parent){s.parent.children.splice(a,1);const o=this.store.getOptionManager().getOptions().fields.children,h=s.parent.data[o]||[],l=h.findIndex(d=>d[r]===t);l!==-1&&(h.splice(l,1),n=!0)}else{const o=this.tasks.findIndex(h=>h.id===t);if(o!==-1){this.tasks.splice(o,1);const h=this.rawData.findIndex(l=>l[r]===t);h!==-1&&(this.rawData.splice(h,1),n=!0)}}if(this.selectedTaskId===t&&this.unselectTask(),this.checkedList.length>0){const o=this.checkedList.findIndex(h=>h.id===t);o!==-1&&this.checkedList.splice(o,1)}return s.children&&s.children.length>0&&this.removeTasksRecursive(s.children),this.taskMap.delete(t),this.collapsedTaskIds.delete(t),this.invalidateCache(),this.event.emit(V.DATA_UPDATE),n}moveTask(t,e,s){var n;const r=this.getVisibleTasks()[s];if(!e||!r){Q.warn("moveTask: invalid task or target index",{taskId:e==null?void 0:e.id,targetIndex:s}),this.event.emit(V.ERROR,xt.MOVE_INVALID_TARGET,`Invalid task or target index: ${s}`);return}if(t==="inside"&&e.isSomeoneChildren(r)){Q.warn("moveTask: cannot move task inside its own descendant",{taskId:e.id,targetId:r.id}),this.event.emit(V.ERROR,xt.MOVE_CIRCULAR_DEPENDENCY,`Cannot move task ${e.id} inside its own descendant ${r.id}`);return}if(t!=="inside"&&e.isSomeoneChildren(r.parent)){Q.warn("moveTask: cannot move task to invalid hierarchy",{taskId:e.id,targetId:r.id}),this.event.emit(V.ERROR,xt.MOVE_INVALID_HIERARCHY,`Cannot move task ${e.id} to invalid hierarchy position`);return}const a=this.store.getOptionManager().getOptions().fields.id,o=this.store.getOptionManager().getOptions().fields.children;if(e.parent&&e.parent.children){ui(e.parent.children,l=>(l==null?void 0:l.id)===e.id);const h=(n=e.parent.data)==null?void 0:n[o];ui(h,l=>(l==null?void 0:l[a])===e.id)}else ui(this.tasks,h=>(h==null?void 0:h.id)===e.id),ui(this.rawData,h=>(h==null?void 0:h[a])===e.id);if(t==="inside")r.children=r.children||[],r.children.push(e),e.parent=r,r.data[o]=r.data[o]||[],r.data[o].push(e.data);else{const h=r.parent?r.parent.children:this.tasks,l=h.findIndex(u=>u.id===r.id),d=r.parent?r.parent.data[o]||[]:this.rawData,p=d.findIndex(u=>u[a]===r.id);t==="before"?(h.splice(l,0,e),d.splice(p,0,e.data)):t==="after"&&(h.splice(l+1,0,e),d.splice(p+1,0,e.data)),e.parent=r.parent}e.parent?e.level=e.parent.level+1:e.level=0,this.updateChildrenLevel(e),this.recalculateDataLevel(),this.invalidateCache(),this.event.emit(V.VIEW_UPDATE),this.event.emit(V.ROW_DRAG_END,r,e)}expandTask(t,e=!1){const s=this.getTaskById(t);return s?(s.expanded=!s.expanded,s.expanded?this.collapsedTaskIds.delete(s.id):this.collapsedTaskIds.add(s.id),e&&s.children&&s.children.length>0&&s.children.forEach(n=>{this.expandTask(n.id,e)}),this.invalidateCache(),this.event.emit(V.VIEW_UPDATE),!0):!1}getVisibleTasks(){if(!this.isDirty&&this.visibleTasksCache.length>0)return this.visibleTasksCache;const t=[];let e=0;const s=(n,r)=>{this.collapsedTaskIds.has(n.id)&&n.expanded&&(n.expanded=!1),n.flatIndex=e++,t.push(n),n.expanded&&n.children&&n.children.length>0&&n.children.forEach(a=>s(a))};return this.tasks.forEach(n=>s(n)),this.visibleTasksCache=t,this.isDirty=!1,t}isTaskVisible(t){let e=t.parent;for(;e;){if(this.collapsedTaskIds.has(e.id))return!1;e=e.parent}return!0}getVisibleSize(){return this.getVisibleTasks().length}clear(){this.rawData=[],this.tasks=[],this.taskMap.clear(),this.visibleTasksCache=[],this.isDirty=!0,this.collapsedTaskIds.clear(),this.event.emit(V.DATA_UPDATE)}updateChildrenLevel(t){if(!t.children||t.children.length===0)return;const e=t.level!==void 0?t.level:0;t.children.forEach(s=>{s.level=e+1,this.updateChildrenLevel(s)})}recalculateDataLevel(){this.dataLevel=0,this.taskMap.forEach(t=>{this.dataLevel=Math.max(this.dataLevel,t.level)})}invalidateCache(){this.isDirty=!0}selectTask(t){const e=this.getTaskById(t);return e?(this.selectedTaskId===t||(this.unselectTask(),this.selectedTaskId=t,this.event.emit(V.TASK_SELECTED,e)),!0):!1}unselectTask(){if(this.selectedTaskId){const t=this.selectedTaskId;this.selectedTaskId=null,this.event.emit(V.TASK_UNSELECTED,t)}}isTaskSelected(t){return this.selectedTaskId===t}getSelectedTask(){return this.selectedTaskId?this.getTaskById(this.selectedTaskId):void 0}getCheckedList(){return this.checkedList}updateCheckedList(t,e){const s=this.checkedList.findIndex(n=>n.id===e.id);t?s===-1?this.checkedList.push(e):this.checkedList.splice(s,1,e):s!==-1&&this.checkedList.splice(s,1)}toggleAllChecked(t){t?this.checkedList=this.getVisibleTasks().slice():this.checkedList=[]}isTaskChecked(t){return this.checkedList.findIndex(e=>e.id===t.id)!==-1}updateTaskTime(t,e,s,n,r=[]){let a=e,o=s;const h=this.store.getOptionManager().getOptions().bar.move.link.child,l=this.store.getOptionManager().getOptions().bar.move.link.parent,d=this.store.getTimeAxis().getCellUnit();let p=t.parent;for(;l!=="none"&&p;){if(l==="expand"){let g=p.startTime||a,f=p.endTime||o;(!p.startTime||a.isBefore(p.startTime))&&(g=a),(!p.endTime||o.isAfter(p.endTime))&&(f=o),(p.startTime===void 0||p.endTime===void 0||!g.isSame(p.startTime)||!f.isSame(p.endTime))&&(r.findIndex(m=>m.id===p.id)===-1&&r.push(p.clone()),p.updateTime(g,f))}else l==="strict"&&(p.startTime&&a.isBefore(p.startTime)&&(a=p.startTime,o.isSameOrBefore(a)&&(o=a.add(1,d))),p.endTime&&o.isAfter(p.endTime)&&(o=p.endTime,a.isAfter(o)&&(a=o.subtract(1,d))));p=p.parent}let u=t.children||[];for(;h!=="none"&&u.length>0;){const g=[];u.forEach(f=>{let m=f.startTime||a,b=f.endTime||o,S=a.diff(t.startTime),y=o.diff(t.endTime);h==="scale"?n==="both"?(r.findIndex(c=>c.id===f.id)===-1&&r.push(f.clone()),f.updateTime(m.add(S),b.add(y))):n==="left"?(m=m.add(S),m.isSameOrAfter(b.subtract(1,d))&&(b.isBefore(t.endTime)?b=m.add(1,d):m=b.subtract(1,d),m.isSameOrBefore(a)&&(a=m)),r.findIndex(c=>c.id===f.id)===-1&&r.push(f.clone()),f.updateTime(m,b)):n==="right"&&(b=b.add(y),b.isSameOrBefore(m.add(1,d))&&(m.isAfter(t.startTime)?m=b.subtract(1,d):b=m.add(1,d)),b.isSameOrAfter(o)&&(o=b),r.findIndex(c=>c.id===f.id)===-1&&r.push(f.clone()),f.updateTime(m,b)):h==="fixed"&&(n==="both"?(r.findIndex(c=>c.id===f.id)===-1&&r.push(f.clone()),f.updateTime(m.add(S),b.add(y))):n==="left"?m.isSameOrBefore(a)&&(m=a,m.isSameOrAfter(b.subtract(1,d))&&(b.isBefore(t.endTime)?b=m.add(1,d):m=b.subtract(1,d),m.isSameOrBefore(a)&&(a=m)),r.findIndex(c=>c.id===f.id)===-1&&r.push(f.clone()),f.updateTime(m,b)):n==="right"&&b.isSameOrAfter(o)&&(b=o,b.isSameOrBefore(m.add(1,d))&&(m.isAfter(t.startTime)?m=b.subtract(1,d):b=m.add(1,d)),b.isSameOrAfter(o)&&(o=b),r.findIndex(c=>c.id===f.id)===-1&&r.push(f.clone()),f.updateTime(m,b))),f.children&&f.children.length>0&&g.push(...f.children)}),u=g}r.findIndex(g=>g.id===t.id)===-1&&r.push(t.clone()),t.updateTime(a,o)}setBaselines(t){this.baselines=[],this.baselineMap.clear(),this.baselineTaskMap.clear(),t.forEach(e=>{var s,n;const r=new Xu(this.store,this.event,e);this.baselines.push(r),this.baselineMap.set(r.id,r),this.baselineTaskMap.has(r.taskId)||this.baselineTaskMap.set(r.taskId,[]),r.target?(s=this.baselineTaskMap.get(r.taskId))==null||s.unshift(r):(n=this.baselineTaskMap.get(r.taskId))==null||n.push(r)})}getBaselines(){return this.baselines}getBaselineById(t){return this.baselineMap.get(t)}getBaselinesByTaskId(t){return this.baselineTaskMap.get(t)||[]}}function Qu(i){var t;if(typeof i=="object"&&i!==null)return{r:at(i.r??0,0,255),g:at(i.g??0,0,255),b:at(i.b??0,0,255),a:at(i.a??1,0,1)};if(typeof i!="string")return Q.warn(`Invalid color value type: ${typeof i}`),null;let e=i.trim();const s=(t=document==null?void 0:document.createElement("canvas"))==null?void 0:t.getContext("2d");if(s&&(s.fillStyle=e,e=s.fillStyle),e.startsWith("#")){const r=e.slice(1);let a,o,h,l,d=1;try{a=parseInt(r,16)}catch{return Q.warn(`Invalid hex color: ${i}`),null}if(r.length===3)o=(a>>8&15)*17,h=(a>>4&15)*17,l=(a&15)*17;else if(r.length===6)o=a>>16&255,h=a>>8&255,l=a&255;else if(r.length===8)o=a>>24&255,h=a>>16&255,l=a>>8&255,d=(a&255)/255;else return Q.warn(`Invalid hex color length: ${i}`),null;return{r:o,g:h,b:l,a:d}}let n=e.match(/rgba?\(\s*(\d+%?)\s*,\s*(\d+%?)\s*,\s*(\d+%?)\s*(?:,\s*([\d.]+)\s*)?\)/i);if(n){const r=a=>a.endsWith("%")?at(parseFloat(a)/100*255,0,255):at(parseInt(a,10),0,255);return{r:r(n[1]),g:r(n[2]),b:r(n[3]),a:n[4]!==void 0?at(parseFloat(n[4]),0,1):1}}return Q.warn(`Could not parse color: ${i}`),null}function Ju(i,t,e,s,n=!1,r=!1){const a=u=>{const g=Math.round(at(u,0,255)).toString(16);return g.length===1?"0"+g:g},o=a(i),h=a(t),l=a(e),d=a(s*255);if(n&&o[0]===o[1]&&h[0]===h[1]&&l[0]===l[1]&&s===1&&!r)return`#${o[0]}${h[0]}${l[0]}`;const p=`#${o}${h}${l}`;return r||s<1?`${p}${d}`:p}class ai{constructor(t){M(this,"_r"),M(this,"_g"),M(this,"_b"),M(this,"_a");const e=Qu(t);e===null?(Q.error(`Failed to parse color: ${t}. Using default black.`),this._r=0,this._g=0,this._b=0,this._a=1):(this._r=Math.round(e.r),this._g=Math.round(e.g),this._b=Math.round(e.b),this._a=e.a)}get R(){return this._r}get G(){return this._g}get B(){return this._b}get A(){return this._a}red(t){return t===void 0?this._r:(this._r=Math.round(at(t,0,255)),this)}green(t){return t===void 0?this._g:(this._g=Math.round(at(t,0,255)),this)}blue(t){return t===void 0?this._b:(this._b=Math.round(at(t,0,255)),this)}alpha(t){return t===void 0?this._a:(this._a=at(t,0,1),this)}toHex(t=!1,e=!1){return Ju(this._r,this._g,this._b,this._a,t,e)}toRgb(){const t=Math.round(this._r),e=Math.round(this._g),s=Math.round(this._b);if(this._a===1)return`rgb(${t}, ${e}, ${s})`;{const n=parseFloat(this._a.toFixed(2));return`rgba(${t}, ${e}, ${s}, ${n})`}}toObject(){return{r:this._r,g:this._g,b:this._b,a:this._a}}toString(){return this.toRgb()}brighten(t=10){if(t<0)return this.darken(-t);const e=at(t,0,100)/100;return this._r=Math.round(at(this._r+(255-this._r)*e,0,255)),this._g=Math.round(at(this._g+(255-this._g)*e,0,255)),this._b=Math.round(at(this._b+(255-this._b)*e,0,255)),this}darken(t=10){if(t<0)return this.brighten(-t);const e=at(t,0,100)/100;return this._r=Math.round(at(this._r*(1-e),0,255)),this._g=Math.round(at(this._g*(1-e),0,255)),this._b=Math.round(at(this._b*(1-e),0,255)),this}isLight(){return(this._r*299+this._g*587+this._b*114)/1e3>128}isDark(){return!this.isLight()}mix(t,e=50){const s=at(e,0,100)/100,n=lt(t);return this._r=Math.round(at(this._r*(1-s)+n.R*s,0,255)),this._g=Math.round(at(this._g*(1-s)+n.G*s,0,255)),this._b=Math.round(at(this._b*(1-s)+n.B*s,0,255)),this._a=at(this._a*(1-s)+n.A*s,0,1),this}clone(){return new ai({r:this._r,g:this._g,b:this._b,a:this._a})}static extend(t,e){typeof t=="function"?t(e,ai,lt):Q.warn("Invalid plugin provided to Colorjs.extend. Expected a function.")}}const lt=i=>i instanceof ai?i:new ai(i),Ai=(i,t)=>i.toLowerCase()==="auto"?lt(t).isLight()?"#000000":"#FFFFFF":i;class no{constructor(t,e,s){M(this,"element"),M(this,"iconElement"),M(this,"_state",0),M(this,"options");var n;this.context=t,this.container=e,this.task=s;const r=this.task&&this.context.store.getDataManager().isTaskChecked(this.task)?1:0;this.options={initialState:r,size:14},this.element=document.createElement("div"),this.iconElement=document.createElement("div"),this._state=this.options.initialState,this.createElement(),this.updateIcon(),this.bindEvents(),this.registerEvents(),(n=this.container)==null||n.appendChild(this.element)}createElement(){this.element.className="x-gantt-checkbox",this.element.style.width=`${this.options.size}px`,this.element.style.height=`${this.options.size}px`,this.element.style.setProperty("border",`1px solid ${this.context.store.getOptionManager().getOptions().border.color}`,"important"),this.iconElement.className="x-gantt-checkbox__icon",this.iconElement.style.cssText=`
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
color: #ffffff;
|
|
9
|
+
font-size: ${Math.floor(this.options.size*.75)}px;
|
|
10
|
+
line-height: 1;
|
|
11
|
+
`,this.element.appendChild(this.iconElement),this.element.addEventListener("mouseenter",()=>{this._state===0&&this.element.classList.add("hover")}),this.element.addEventListener("mouseleave",()=>{this._state===0&&this.element.classList.remove("hover")})}updateIcon(){const t=this.context.store.getOptionManager().getOptions().primaryColor;this.iconElement.innerHTML="";let e="#ffffff",s=lt(t).alpha(.5).toHex();switch(this._state){case 0:e="#ffffff",s=s;break;case 1:e=t,s=t,this.iconElement.innerHTML=`
|
|
12
|
+
<svg width="12" height="9" viewBox="0 0 12 9" fill="none">
|
|
13
|
+
<path d="M10.5 1.5L4.5 7.5L1.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
14
|
+
</svg>
|
|
15
|
+
`;break;case 2:e=t,s=t,this.iconElement.innerHTML=`
|
|
16
|
+
<svg width="8" height="2" viewBox="0 0 8 2" fill="none">
|
|
17
|
+
<rect width="8" height="2" fill="currentColor" rx="1"/>
|
|
18
|
+
</svg>
|
|
19
|
+
`;break}this.iconElement.style.setProperty("background-color",e,"important"),this.iconElement.style.setProperty("border-color",s,"important")}bindEvents(){this.element.addEventListener("click",t=>{if(t.preventDefault(),t.stopPropagation(),this.task){const e=this.context.store.getDataManager().isTaskChecked(this.task);e?(this.context.store.getDataManager().updateCheckedList(!1,this.task),this.setState(0)):(this.context.store.getDataManager().updateCheckedList(!0,this.task),this.setState(1)),this.context.event.emit(V.CHECK_TASK,[this.task],!e)}else{const e=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(e?1:0),this.context.store.getDataManager().toggleAllChecked(!e),this.context.event.emit(V.CHECK_TASK,this.context.store.getDataManager().getVisibleTasks(),!e)}}),this.element.addEventListener("contextmenu",t=>{if(t.preventDefault(),t.stopPropagation(),this.task){const e=this.task.getAllChildren();if(e.length===0)return;this.context.store.getOptionManager().getOptions().selection.includeSelf&&e.unshift(this.task);const s=e.every(n=>this.context.store.getDataManager().isTaskChecked(n));s?(e.forEach(n=>{this.context.store.getDataManager().updateCheckedList(!1,n)}),this.setState(0)):(e.forEach(n=>{this.context.store.getDataManager().updateCheckedList(!0,n)}),this.setState(1)),this.context.event.emit(V.CHECK_TASK,e,!s)}else{const e=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(e?1:0),this.context.store.getDataManager().toggleAllChecked(!e),this.context.event.emit(V.CHECK_TASK,this.context.store.getDataManager().getVisibleTasks(),!e)}})}registerEvents(){this.context.event.on(V.CHECK_TASK,this.updateState.bind(this))}getElement(){return this.element}setState(t){this._state!==t&&(this._state=t,this.updateIcon())}updateState(){if(this.task){const t=this.context.store.getDataManager().isTaskChecked(this.task);this.setState(t?1:0)}else{const t=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(t?1:0)}}destroy(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}const gr="handler_column";class Zu{constructor(t){M(this,"sourceColumns",[]),M(this,"columns",[]),M(this,"leafColumns",[]),M(this,"temporaryLeafColumns",[]),M(this,"columnWidths",new Map),M(this,"mergeInfo",new Map),M(this,"collapseTable",!1),this.context=t}init(t){t!=null&&t.length&&(this.sourceColumns=t),this.columns=[],this.leafColumns=[],this.processColumns(this.sourceColumns,this.columns)}processColumns(t,e=[],s,n=1){t.forEach((r,a)=>{var o;const h="children"in r&&Array.isArray(r.children)&&r.children.length>0,l=!h;let d="";h?d=`group-${a}`:d=`field-${r.field}`;const p=[...(s==null?void 0:s.path)||[],d];d="column-"+a+"-"+p.join("-");const u=r.label||(l?r.field:""),g=this.columnWidths.get(d)??(l?((o=this.temporaryLeafColumns.find(m=>m.key===d))==null?void 0:o.width)||r.width||100:"auto"),f={label:u,level:n,maxLevel:n,column:r,children:[],path:p,key:d,isLeaf:l,width:g};if(e.push(f),l)this.leafColumns.push(f);else if(h){const m=r.children;this.processColumns(m,f.children,f,n+1),f.maxLevel=Math.max(f.maxLevel,f.children.reduce((b,S)=>Math.max(b,S.maxLevel),0))}}),this.temporaryLeafColumns=le(this.leafColumns)}findColumnByKey(t){return this.columns.find(e=>e.key===t)}update(t){this.init(t),this.clearMergeInfo()}getColumns(){return this.columns}getColumn(t){return this.leafColumns.find(e=>e.key===t)}getLeafColumns(){return this.leafColumns}getTotalWidth(){return this.isCollapsed()?0:this.leafColumns.reduce((t,e)=>t+e.width,this.getHandlerColumn().width)}getColumnWidth(t){if(t===gr)return this.getHandlerColumn().width;const e=this.leafColumns.find(s=>s.key===t);return typeof(e==null?void 0:e.width)=="number"?e.width:0}setColumnWidth(t,e){const s=this.leafColumns.find(n=>n.key===t);s&&(s.width=e,this.columnWidths.set(t,e)),this.context.event.emit(V.COLUMN_WIDTH_CHANGE,t,e)}isLastColumn(t){return this.leafColumns.findIndex(e=>e.key===t)===this.leafColumns.length-1}addMergeInfo(t,e,s){this.mergeInfo.has(t)||this.mergeInfo.set(t,new Map),this.mergeInfo.get(t).set(e,s)}getMergeInfo(t,e){var s;return(s=this.mergeInfo.get(t))==null?void 0:s.get(e)}clearMergeInfo(){this.mergeInfo.clear()}getHandlerColumn(){let t=0;const e=this.context.store.getOptionManager().getOptions().drag.enabled;e&&(t+=40);const s=this.context.store.getOptionManager().getOptions().selection.enabled;s&&(t+=40);const n=this.context.store.getOptionManager().getOptions().expand.show;return this.context.store.getDataManager().dataLevel>0&&n&&(t+=40),{label:"",level:1,maxLevel:1,column:{field:"",resizable:!1,align:"left",headerAlign:"left",customStyle:{paddingLeft:n?`${e?40:8}px`:0},headerRender:()=>s?new no(this.context).getElement():null,ellipsis:!1},children:[],path:[],key:gr,isLeaf:!0,width:t}}isMultiHeader(){return this.columns.some(t=>t.maxLevel>1)}collapse(){this.collapseTable=!this.collapseTable,this.context.event.emit(V.TOGGLE_COLLAPSE)}isCollapsed(){return this.collapseTable}}const Xt=1e3,ro=class rs{constructor(t,e){M(this,"links",[]),M(this,"fromLinksMap",new Map),M(this,"toLinksMap",new Map),M(this,"topoOrder",null),M(this,"topoIndex",new Map),M(this,"lastCycleReport",null),M(this,"directConnectionCache",new Map),M(this,"forwardMemo",new Map),M(this,"backwardMemo",new Map),M(this,"cacheDependencies",new Map),M(this,"cacheAccessStats",new Map),M(this,"MAX_CACHE_SIZE",1e3),M(this,"CACHE_TTL",300*1e3),M(this,"enableCycleDetection",!0),this.store=t,this.event=e}setCycleDetection(t){this.enableCycleDetection=!!t}getLinks(){return this.links}getLinksByTaskId(t){return this.links.filter(e=>e.from===t||e.to===t)}setLinks(t,e=!1){const s=new Set,n=new Set;this.links.forEach(o=>{s.add(o.from),s.add(o.to)}),t.forEach(o=>{n.add(o.from),n.add(o.to)});const r=Array.from(new Set([...s,...n]));let a="BATCH";this.links.length===0?a="ADD":t.length===0?a="REMOVE":Math.abs(t.length-this.links.length)===1&&(a=t.length>this.links.length?"ADD":"REMOVE"),this.links=t||[],this.rebuildAdjacency(),this.invalidateSmartCaches(r,a),e&&this.enableCycleDetection?this.detectAllCycles():this.lastCycleReport=null}update(){this.setLinks(this.links,!0)}isLinkExist(t,e,s){return this.links.some(n=>n.from===t&&n.to===e&&(n.type||"FS")===(s||"FS"))}validateLinkType(t){return Object.keys(rs.LINK_TYPE_MAP).includes(t)}convertPointsToLinkType(t,e){return`${t}${e}`}validateLink(t){return!t||t.from==null||t.to==null?{ok:!1,reason:xt.LINK_INVALID_ARG,message:Q.getMessage("Missing endpoint")}:t.from===t.to?{ok:!1,reason:xt.LINK_SAME,message:Q.getMessage("Cannot link task to itself")}:!this.getTask(t.from)||!this.getTask(t.to)?{ok:!1,reason:xt.TASK_NOT_FOUND,message:Q.getMessage("Task not found")}:t.type&&!this.validateLinkType(t.type)?{ok:!1,reason:xt.INVALID_TYPE,message:Q.getMessage(`Invalid link type: ${t.type}. It must be one of: ${Object.keys(rs.LINK_TYPE_MAP).join(", ")}`)}:this.isLinkExist(t.from,t.to,t.type)?{ok:!1,reason:xt.LINK_EXIST,message:Q.getMessage("Link already exists")}:{ok:!0}}validateChain(t,e,s){const n={from:t,to:e,type:s},r=this.validateLink(n);if(!r.ok)return r;if(this.enableCycleDetection){const a=this.willCreateCycle(t,e);if(a)return{ok:!1,reason:xt.LINK_CYCLE,message:Q.getMessage("Adding this link would create a cycle"),cycleInfo:a}}return{ok:!0}}validateLinks(t){const e=[],s=[];for(const n of t){const r=this.validateLink(n);r.ok?s.push(n):e.push({link:n,reason:r.reason,message:r.message||""})}return{invalid:e,valid:s,totalCount:t.length}}getTaskLinks(t){const e=this.toLinksMap.get(t)||[],s=this.fromLinksMap.get(t)||[],n=[...e,...s];return{incoming:e,outgoing:s,all:n}}getTaskPredecessors(t){const e=this.toLinksMap.get(t)||[];return{tasks:e.map(s=>this.getTask(s.from)).filter(s=>!!s),links:e}}getTaskSuccessors(t){const e=this.fromLinksMap.get(t)||[];return{tasks:e.map(s=>this.getTask(s.to)).filter(s=>!!s),links:e}}getDirectlyConnectedTasks(t){const e=this.getTaskPredecessors(t).tasks,s=this.getTaskSuccessors(t).tasks,n=new Map;return[...e,...s].forEach(r=>{n.set(r.id,r)}),Array.from(n.values())}hasConnectionPath(t,e){if(t===e)return!0;const s=new Set,n=[t];for(;n.length;){const r=n.pop();if(r===e)return!0;if(s.has(r))continue;s.add(r);const a=this.getTaskSuccessors(r).tasks;for(const o of a)s.has(o.id)||n.push(o.id)}return!1}getDataChain(t){const e=this.getTask(t);if(!e)return{prev:{chain:[],nodes:[],links:[]},next:{chain:[],nodes:[],links:[]},allNodes:[],allLinks:[],current:void 0};const s=this.forwardMemo.get(t),n=this.backwardMemo.get(t);this.recordCacheAccess(t,!!(s&&n));const r=b=>(this.fromLinksMap.get(b)||[]).map(S=>this.getTask(S.to)).filter(S=>!!S),a=b=>(this.toLinksMap.get(b)||[]).map(S=>this.getTask(S.from)).filter(S=>!!S),o=(b,S,y=new Set)=>{const c=b.id;if(this.forwardMemo.has(c))return this.recordCacheAccess(c,!0),this.forwardMemo.get(c);if(S.has(b.id)||y.has(b.id))return[];S.add(b.id),y.add(b.id);const v=r(b.id);let x=[];if(v.length===0)x=[[b]];else{for(const T of v){const O=o(T,S,y);for(const _ of O)if(x.push([b,..._]),x.length>=Xt){Q.warn(`getDataChain: forward paths reached limit (${Xt}), truncated`);break}if(x.length>=Xt)break}x.length===0&&(x=[[b]])}return S.delete(b.id),x.length<Xt&&(this.forwardMemo.set(c,x),this.recordCacheAccess(c,!1)),x},h=(b,S,y=new Set)=>{const c=b.id;if(this.backwardMemo.has(c))return this.recordCacheAccess(c,!0),this.backwardMemo.get(c);if(S.has(b.id)||y.has(b.id))return[];S.add(b.id),y.add(b.id);const v=a(b.id);let x=[];if(v.length===0)x=[[b]];else{for(const T of v){const O=h(T,S,y);for(const _ of O)if(x.push([..._,b]),x.length>=Xt){Q.warn(`getDataChain: backward paths reached limit (${Xt}), truncated`);break}if(x.length>=Xt)break}x.length===0&&(x=[[b]])}return S.delete(b.id),x.length<Xt&&(this.backwardMemo.set(c,x),this.recordCacheAccess(c,!1)),x},l=h(e,new Set),d=o(e,new Set);this.getDirectlyConnectedTasks(t).forEach(b=>{this.establishCacheDependency(t,b.id),this.establishCacheDependency(b.id,t)});const p=new Map,u=new Map,g=(b,S)=>{const y=[];for(const c of b){c.forEach(v=>p.set(v.id,v));for(let v=0;v<c.length-1;v++){const x=c[v].id,T=c[v+1].id,O=this.findLinkFast(x,T);if(O){const _=`${O.from}-${O.to}-${O.type||"default"}`;u.has(_)||(y.push(O),u.set(_,O))}}}return y},f=g(l),m=g(d);return{prev:{chain:l.map(b=>b.map(S=>S.getEmitData().data)),nodes:l.flat().filter((b,S,y)=>y.findIndex(c=>c.id===b.id)===S).map(b=>b.getEmitData().data),links:f},next:{chain:d.map(b=>b.map(S=>S.getEmitData().data)),nodes:d.flat().filter((b,S,y)=>y.findIndex(c=>c.id===b.id)===S).map(b=>b.getEmitData().data),links:m},allNodes:Array.from(p.values()).map(b=>b.getEmitData().data),allLinks:Array.from(u.values()),current:e.getEmitData().data}}hasCycle(){return this.lastCycleReport?this.lastCycleReport.hasCycle:this.detectAllCycles(!1).hasCycle}detectAllCycles(t=!0){const e=new Map,s=new Map,n=new Set,r=[];let a=0;const o=[],h=u=>{e.set(u,a),s.set(u,a),a++,r.push(u),n.add(u);const g=this.fromLinksMap.get(u)||[];for(const f of g)e.has(f.to)?n.has(f.to)&&s.set(u,Math.min(s.get(u),e.get(f.to))):(h(f.to),s.set(u,Math.min(s.get(u),s.get(f.to))));if(s.get(u)===e.get(u)){const f=[];for(;;){const m=r.pop();if(n.delete(m),f.push(m),m===u)break}o.push(f)}};this.store.getDataManager().getTasks(!1).forEach(u=>{e.has(u.id)||h(u.id)});const l=o.filter(u=>u.length>1||this.hasSelfLoop(u[0])),d=l.map(u=>u.slice()),p={hasCycle:l.length>0,sccs:l,cycles:d,nodes:Array.from(new Set(l.flat()))};return this.lastCycleReport=p,t&&p.hasCycle&&Q.warn("Cycle detected in task dependencies",p),p}getCycleReport(){return this.lastCycleReport}detectLinkConflicts(t,e){const s=this.links.filter(p=>p.from===t&&p.to===e),n=this.links.filter(p=>p.from===e&&p.to===t),r=[...s,...n],a=[],o=[],h=new Map;r.forEach(p=>{p.type&&h.set(p.type,(h.get(p.type)||0)+1)});const l=h.has("FS"),d=h.has("SF");return l&&d&&(a.push(...r.filter(p=>p.type==="FS"||p.type==="SF")),o.push("FS-SF conflict")),{hasConflict:a.length>0,conflicts:a,conflictTypes:o}}hasConflictingLinks(t,e){return this.detectLinkConflicts(t,e).hasConflict}computeTopo(){if(this.topoOrder)return this.topoOrder;const t=new Map;this.store.getDataManager().getTasks(!1).forEach(n=>t.set(n.id,0));for(const n of this.links)t.has(n.to)&&t.set(n.to,(t.get(n.to)||0)+1);const e=[];t.forEach((n,r)=>{n===0&&e.push(r)});const s=[];for(;e.length;){const n=e.shift();s.push(n);const r=this.fromLinksMap.get(n)||[];for(const a of r){const o=(t.get(a.to)||0)-1;t.set(a.to,o),o===0&&e.push(a.to)}}return s.length!==this.store.getDataManager().getTasks(!1).length?null:(s.forEach((n,r)=>this.topoIndex.set(n,r)),this.topoOrder=s,s)}willCreateCycle(t,e){if(this.computeTopo()){const a=this.topoIndex.get(t),o=this.topoIndex.get(e);if(a!=null&&o!=null&&a<o)return null}const s=[e],n=new Set,r=new Map;for(;s.length;){const a=s.pop();if(n.has(a))continue;n.add(a);const o=this.fromLinksMap.get(a)||[];for(const h of o){const l=h.to;if(!n.has(l)&&!r.has(l)&&r.set(l,a),l===t){r.has(l)||r.set(l,a);const d=[];let p=t;for(;p!==void 0;)d.push(p),p=r.get(p);const u=d.slice().reverse(),g=[t,...u];return{cycles:[g],nodes:Array.from(new Set(g)),sccs:[]}}s.push(l)}}return null}rebuildAdjacency(){this.fromLinksMap.clear(),this.toLinksMap.clear();for(const t of this.links)this.fromLinksMap.has(t.from)||this.fromLinksMap.set(t.from,[]),this.toLinksMap.has(t.to)||this.toLinksMap.set(t.to,[]),this.fromLinksMap.get(t.from).push(t),this.toLinksMap.get(t.to).push(t)}invalidateAllCaches(){this.topoOrder=null,this.topoIndex.clear(),this.directConnectionCache.clear(),this.forwardMemo.clear(),this.backwardMemo.clear(),this.cacheDependencies.clear(),this.cacheAccessStats.clear()}invalidateConnectionCache(t){t?t.forEach(e=>this.directConnectionCache.delete(e)):this.directConnectionCache.clear()}findLinkFast(t,e){const s=this.fromLinksMap.get(t);if(s)return s.find(n=>n.to===e)}getTask(t){return this.store.getDataManager().getTaskById(t)}hasSelfLoop(t){return(this.fromLinksMap.get(t)||[]).some(e=>e.to===t)}buildSimpleCycleInfo(t,e){const s=[t,e];return{cycles:[s],nodes:Array.from(new Set(s)),sccs:[]}}invalidateSmartCaches(t,e="UPDATE"){if(!t||t.length===0){this.invalidateAllCaches();return}switch(e){case"ADD":this.handleAddLinkInvalidation(t);break;case"REMOVE":this.handleRemoveLinkInvalidation(t);break;case"UPDATE":this.handleUpdateLinkInvalidation(t);break;case"BATCH":this.handleBatchOperationInvalidation(t);break}this.cleanupExpiredCaches(),this.limitCacheSize()}handleAddLinkInvalidation(t){const e=new Set;for(const s of t)e.add(s),this.getUpstreamTasksRecursive(s,3).forEach(n=>e.add(n)),this.getDownstreamTasksRecursive(s,3).forEach(n=>e.add(n));this.invalidateSpecificCaches(Array.from(e))}handleRemoveLinkInvalidation(t){const e=new Set;for(const s of t)e.add(s),this.getConnectedComponent(s).forEach(n=>e.add(n));this.invalidateSpecificCaches(Array.from(e))}handleUpdateLinkInvalidation(t){const e=new Set;for(const s of t){e.add(s),this.getDirectlyConnectedTasks(s).forEach(r=>e.add(r.id));const n=this.cacheDependencies.get(s);n&&n.forEach(r=>e.add(r))}this.invalidateSpecificCaches(Array.from(e))}handleBatchOperationInvalidation(t){if(t.length>50){this.invalidateAllCaches();return}const e=new Set(t);for(const s of t)this.getDirectlyConnectedTasks(s).forEach(n=>e.add(n.id));this.invalidateSpecificCaches(Array.from(e))}invalidateSpecificCaches(t){for(const e of t)this.forwardMemo.delete(e),this.backwardMemo.delete(e),this.directConnectionCache.delete(e),this.cacheAccessStats.delete(e),this.cacheDependencies.delete(e),this.cacheDependencies.forEach((s,n)=>{s.delete(e)});t.length>5&&(this.topoOrder=null,this.topoIndex.clear())}getUpstreamTasksRecursive(t,e){const s=new Set,n=new Set,r=(a,o)=>{if(o>=e||n.has(a))return;n.add(a);const h=this.getTaskPredecessors(a).tasks;for(const l of h)s.add(l.id),r(l.id,o+1)};return r(t,0),Array.from(s)}getDownstreamTasksRecursive(t,e){const s=new Set,n=new Set,r=(a,o)=>{if(o>=e||n.has(a))return;n.add(a);const h=this.getTaskSuccessors(a).tasks;for(const l of h)s.add(l.id),r(l.id,o+1)};return r(t,0),Array.from(s)}getConnectedComponent(t){const e=new Set,s=new Set,n=[t];for(;n.length>0;){const r=n.pop();if(s.has(r))continue;s.add(r),e.add(r);const a=this.getDirectlyConnectedTasks(r);for(const o of a)s.has(o.id)||n.push(o.id)}return Array.from(e)}cleanupExpiredCaches(){const t=Date.now(),e=[];this.cacheAccessStats.forEach((s,n)=>{t-s.lastAccess>this.CACHE_TTL&&e.push(n)}),this.invalidateSpecificCaches(e)}limitCacheSize(){const t=this.forwardMemo.size+this.backwardMemo.size;if(t>this.MAX_CACHE_SIZE){const e=Array.from(this.cacheAccessStats.entries()).sort((r,a)=>r[1].lastAccess-a[1].lastAccess),s=Math.ceil(t*.2),n=e.slice(0,s).map(([r])=>r);this.invalidateSpecificCaches(n)}}recordCacheAccess(t,e){const s=this.cacheAccessStats.get(t)||{hits:0,lastAccess:0};e&&(s.hits+=1),s.lastAccess=Date.now(),this.cacheAccessStats.set(t,s)}establishCacheDependency(t,e){this.cacheDependencies.has(t)||this.cacheDependencies.set(t,new Set),this.cacheDependencies.get(t).add(e)}getDebugInfo(){const t=this.store.getDataManager().getTasks(!1),e=t.filter(s=>{const n=this.toLinksMap.has(s.id)&&this.toLinksMap.get(s.id).length>0,r=this.fromLinksMap.has(s.id)&&this.fromLinksMap.get(s.id).length>0;return!n&&!r}).map(s=>s.id);return{totalLinks:this.links.length,totalTasks:t.length,connectionComponents:this.countConnectionComponents(),hasCycle:this.hasCycle(),topologicalOrder:this.computeTopo(),isolatedTasks:e}}countConnectionComponents(){const t=this.store.getDataManager().getTasks(!1),e=new Set;let s=0;const n=r=>{if(e.has(r))return;e.add(r);const a=this.getDirectlyConnectedTasks(r);for(const o of a)e.has(o.id)||n(o.id)};for(const r of t)e.has(r.id)||(n(r.id),s++);return s}getCachePerformanceStats(){const t=Array.from(this.cacheAccessStats.values()).reduce((r,a)=>r+a.hits,0),e=this.cacheAccessStats.size,s=Date.now(),n=Array.from(this.cacheAccessStats.values()).filter(r=>s-r.lastAccess>this.CACHE_TTL).length;return{totalCacheSize:this.forwardMemo.size+this.backwardMemo.size,hitRate:e>0?t/e*100:0,memoryUsage:this.estimateMemoryUsage(),expiredEntries:n,dependencyCount:this.cacheDependencies.size}}estimateMemoryUsage(){const t=this.links.length*100,e=this.forwardMemo.size*300,s=this.backwardMemo.size*300,n=this.cacheDependencies.size*50,r=this.cacheAccessStats.size*50,a=t+e+s+n+r;return a>1024*1024?`${(a/1024/1024).toFixed(2)} MB`:a>1024?`${(a/1024).toFixed(2)} KB`:`${a} B`}};M(ro,"LINK_TYPE_MAP",{FS:{from:"F",to:"S",description:"结束到开始"},SF:{from:"S",to:"F",description:"开始到结束"},FF:{from:"F",to:"F",description:"结束到结束"},SS:{from:"S",to:"S",description:"开始到开始"}});let tf=ro;var wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var oo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){var e,s,n=1e3,r=6e4,a=36e5,o=864e5,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,l=31536e6,d=2628e6,p=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,u={years:l,months:d,days:o,hours:a,minutes:r,seconds:n,milliseconds:1,weeks:6048e5},g=function(T){return T instanceof v},f=function(T,O,_){return new v(T,_,O.$l)},m=function(T){return s.p(T)+"s"},b=function(T){return T<0},S=function(T){return b(T)?Math.ceil(T):Math.floor(T)},y=function(T){return Math.abs(T)},c=function(T,O){return T?b(T)?{negative:!0,format:""+y(T)+O}:{negative:!1,format:""+T+O}:{negative:!1,format:""}},v=(function(){function T(_,C,k){var L=this;if(this.$d={},this.$l=k,_===void 0&&(this.$ms=0,this.parseFromMilliseconds()),C)return f(_*u[m(C)],this);if(typeof _=="number")return this.$ms=_,this.parseFromMilliseconds(),this;if(typeof _=="object")return Object.keys(_).forEach(function(P){L.$d[m(P)]=_[P]}),this.calMilliseconds(),this;if(typeof _=="string"){var F=_.match(p);if(F){var N=F.slice(2).map(function(P){return P!=null?Number(P):0});return this.$d.years=N[0],this.$d.months=N[1],this.$d.weeks=N[2],this.$d.days=N[3],this.$d.hours=N[4],this.$d.minutes=N[5],this.$d.seconds=N[6],this.calMilliseconds(),this}}return this}var O=T.prototype;return O.calMilliseconds=function(){var _=this;this.$ms=Object.keys(this.$d).reduce(function(C,k){return C+(_.$d[k]||0)*u[k]},0)},O.parseFromMilliseconds=function(){var _=this.$ms;this.$d.years=S(_/l),_%=l,this.$d.months=S(_/d),_%=d,this.$d.days=S(_/o),_%=o,this.$d.hours=S(_/a),_%=a,this.$d.minutes=S(_/r),_%=r,this.$d.seconds=S(_/n),_%=n,this.$d.milliseconds=_},O.toISOString=function(){var _=c(this.$d.years,"Y"),C=c(this.$d.months,"M"),k=+this.$d.days||0;this.$d.weeks&&(k+=7*this.$d.weeks);var L=c(k,"D"),F=c(this.$d.hours,"H"),N=c(this.$d.minutes,"M"),P=this.$d.seconds||0;this.$d.milliseconds&&(P+=this.$d.milliseconds/1e3,P=Math.round(1e3*P)/1e3);var A=c(P,"S"),$=_.negative||C.negative||L.negative||F.negative||N.negative||A.negative,w=F.format||N.format||A.format?"T":"",E=($?"-":"")+"P"+_.format+C.format+L.format+w+F.format+N.format+A.format;return E==="P"||E==="-P"?"P0D":E},O.toJSON=function(){return this.toISOString()},O.format=function(_){var C=_||"YYYY-MM-DDTHH:mm:ss",k={Y:this.$d.years,YY:s.s(this.$d.years,2,"0"),YYYY:s.s(this.$d.years,4,"0"),M:this.$d.months,MM:s.s(this.$d.months,2,"0"),D:this.$d.days,DD:s.s(this.$d.days,2,"0"),H:this.$d.hours,HH:s.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:s.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:s.s(this.$d.seconds,2,"0"),SSS:s.s(this.$d.milliseconds,3,"0")};return C.replace(h,function(L,F){return F||String(k[L])})},O.as=function(_){return this.$ms/u[m(_)]},O.get=function(_){var C=this.$ms,k=m(_);return k==="milliseconds"?C%=1e3:C=k==="weeks"?S(C/u[k]):this.$d[k],C||0},O.add=function(_,C,k){var L;return L=C?_*u[m(C)]:g(_)?_.$ms:f(_,this).$ms,f(this.$ms+L*(k?-1:1),this)},O.subtract=function(_,C){return this.add(_,C,!0)},O.locale=function(_){var C=this.clone();return C.$l=_,C},O.clone=function(){return f(this.$ms,this)},O.humanize=function(_){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!_)},O.valueOf=function(){return this.asMilliseconds()},O.milliseconds=function(){return this.get("milliseconds")},O.asMilliseconds=function(){return this.as("milliseconds")},O.seconds=function(){return this.get("seconds")},O.asSeconds=function(){return this.as("seconds")},O.minutes=function(){return this.get("minutes")},O.asMinutes=function(){return this.as("minutes")},O.hours=function(){return this.get("hours")},O.asHours=function(){return this.as("hours")},O.days=function(){return this.get("days")},O.asDays=function(){return this.as("days")},O.weeks=function(){return this.get("weeks")},O.asWeeks=function(){return this.as("weeks")},O.months=function(){return this.get("months")},O.asMonths=function(){return this.as("months")},O.years=function(){return this.get("years")},O.asYears=function(){return this.as("years")},T})(),x=function(T,O,_){return T.add(O.years()*_,"y").add(O.months()*_,"M").add(O.days()*_,"d").add(O.hours()*_,"h").add(O.minutes()*_,"m").add(O.seconds()*_,"s").add(O.milliseconds()*_,"ms")};return function(T,O,_){e=_,s=_().$utils(),_.duration=function(L,F){var N=_.locale();return f(L,{$l:N},F)},_.isDuration=g;var C=O.prototype.add,k=O.prototype.subtract;O.prototype.add=function(L,F){return g(L)?x(this,L,1):C.bind(this)(L,F)},O.prototype.subtract=function(L,F){return g(L)?x(this,L,-1):k.bind(this)(L,F)}}})})(oo);var ef=oo.exports;const sf=Mt(ef);var ao={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s,n){s.prototype.isBetween=function(r,a,o,h){var l=n(r),d=n(a),p=(h=h||"()")[0]==="(",u=h[1]===")";return(p?this.isAfter(l,o):!this.isBefore(l,o))&&(u?this.isBefore(d,o):!this.isAfter(d,o))||(p?this.isBefore(l,o):!this.isAfter(l,o))&&(u?this.isAfter(d,o):!this.isBefore(d,o))}}})})(ao);var nf=ao.exports;const rf=Mt(nf);var ho={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s){s.prototype.isSameOrBefore=function(n,r){return this.isSame(n,r)||this.isBefore(n,r)}}})})(ho);var of=ho.exports;const af=Mt(of);var lo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s){s.prototype.isSameOrAfter=function(n,r){return this.isSame(n,r)||this.isAfter(n,r)}}})})(lo);var hf=lo.exports;const lf=Mt(hf);var co={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s,n){var r=s.prototype,a=function(p){return p&&(p.indexOf?p:p.s)},o=function(p,u,g,f,m){var b=p.name?p:p.$locale(),S=a(b[u]),y=a(b[g]),c=S||y.map(function(x){return x.slice(0,f)});if(!m)return c;var v=b.weekStart;return c.map(function(x,T){return c[(T+(v||0))%7]})},h=function(){return n.Ls[n.locale()]},l=function(p,u){return p.formats[u]||(function(g){return g.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(f,m,b){return m||b.slice(1)})})(p.formats[u.toUpperCase()])},d=function(){var p=this;return{months:function(u){return u?u.format("MMMM"):o(p,"months")},monthsShort:function(u){return u?u.format("MMM"):o(p,"monthsShort","months",3)},firstDayOfWeek:function(){return p.$locale().weekStart||0},weekdays:function(u){return u?u.format("dddd"):o(p,"weekdays")},weekdaysMin:function(u){return u?u.format("dd"):o(p,"weekdaysMin","weekdays",2)},weekdaysShort:function(u){return u?u.format("ddd"):o(p,"weekdaysShort","weekdays",3)},longDateFormat:function(u){return l(p.$locale(),u)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};r.localeData=function(){return d.bind(this)()},n.localeData=function(){var p=h();return{firstDayOfWeek:function(){return p.weekStart||0},weekdays:function(){return n.weekdays()},weekdaysShort:function(){return n.weekdaysShort()},weekdaysMin:function(){return n.weekdaysMin()},months:function(){return n.months()},monthsShort:function(){return n.monthsShort()},longDateFormat:function(u){return l(p,u)},meridiem:p.meridiem,ordinal:p.ordinal}},n.months=function(){return o(h(),"months")},n.monthsShort=function(){return o(h(),"monthsShort","months",3)},n.weekdays=function(p){return o(h(),"weekdays",null,null,p)},n.weekdaysShort=function(p){return o(h(),"weekdaysShort","weekdays",3,p)},n.weekdaysMin=function(p){return o(h(),"weekdaysMin","weekdays",2,p)}}})})(co);var cf=co.exports;const df=Mt(cf);var uo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){var e="week",s="year";return function(n,r,a){var o=r.prototype;o.week=function(h){if(h===void 0&&(h=null),h!==null)return this.add(7*(h-this.week()),"day");var l=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=a(this).startOf(s).add(1,s).date(l),p=a(this).endOf(e);if(d.isBefore(p))return 1}var u=a(this).startOf(s).date(l).startOf(e).subtract(1,"millisecond"),g=this.diff(u,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},o.weeks=function(h){return h===void 0&&(h=null),this.week(h)}}})})(uo);var uf=uo.exports;const ff=Mt(uf);var fo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s){s.prototype.weekYear=function(){var n=this.month(),r=this.week(),a=this.year();return r===1&&n===11?a+1:n===0&&r>=52?a-1:a}}})})(fo);var gf=fo.exports;const pf=Mt(gf);var go={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s){var n=s.prototype,r=n.format;n.format=function(a){var o=this,h=this.$locale();if(!this.isValid())return r.bind(this)(a);var l=this.$utils(),d=(a||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(p){switch(p){case"Q":return Math.ceil((o.$M+1)/3);case"Do":return h.ordinal(o.$D);case"gggg":return o.weekYear();case"GGGG":return o.isoWeekYear();case"wo":return h.ordinal(o.week(),"W");case"w":case"ww":return l.s(o.week(),p==="w"?1:2,"0");case"W":case"WW":return l.s(o.isoWeek(),p==="W"?1:2,"0");case"k":case"kk":return l.s(String(o.$H===0?24:o.$H),p==="k"?1:2,"0");case"X":return Math.floor(o.$d.getTime()/1e3);case"x":return o.$d.getTime();case"z":return"["+o.offsetName()+"]";case"zzz":return"["+o.offsetName("long")+"]";default:return p}});return r.bind(this)(d)}}})})(go);var mf=go.exports;const yf=Mt(mf);var po={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s,n){n.updateLocale=function(r,a){var o=n.Ls[r];if(o)return(a?Object.keys(a):[]).forEach(function(h){o[h]=a[h]}),o}}})})(po);var vf=po.exports;const bf=Mt(vf);var mo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){var e="day";return function(s,n,r){var a=function(l){return l.add(4-l.isoWeekday(),e)},o=n.prototype;o.isoWeekYear=function(){return a(this).year()},o.isoWeek=function(l){if(!this.$utils().u(l))return this.add(7*(l-this.isoWeek()),e);var d,p,u,g,f=a(this),m=(d=this.isoWeekYear(),p=this.$u,u=(p?r.utc:r)().year(d).startOf("year"),g=4-u.isoWeekday(),u.isoWeekday()>4&&(g+=7),u.add(g,e));return f.diff(m,"week")+1},o.isoWeekday=function(l){return this.$utils().u(l)?this.day()||7:this.day(this.day()%7?l:l-7)};var h=o.startOf;o.startOf=function(l,d){var p=this.$utils(),u=!!p.u(d)||d;return p.p(l)==="isoweek"?u?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):h.bind(this)(l,d)}}})})(mo);var xf=mo.exports;const _f=Mt(xf);var yo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return function(e,s){s.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(yo);var wf=yo.exports;const Sf=Mt(wf);var vo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){var e="month",s="quarter";return function(n,r){var a=r.prototype;a.quarter=function(l){return this.$utils().u(l)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(l-1))};var o=a.add;a.add=function(l,d){return l=Number(l),this.$utils().p(d)===s?this.add(3*l,e):o.bind(this)(l,d)};var h=a.startOf;a.startOf=function(l,d){var p=this.$utils(),u=!!p.u(d)||d;if(p.p(l)===s){var g=this.quarter()-1;return u?this.month(3*g).startOf(e).startOf("day"):this.month(3*g+2).endOf(e).endOf("day")}return h.bind(this)(l,d)}}})})(vo);var Tf=vo.exports;const Cf=Mt(Tf);var bo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},s={};return function(n,r,a){var o,h=function(u,g,f){f===void 0&&(f={});var m=new Date(u),b=(function(S,y){y===void 0&&(y={});var c=y.timeZoneName||"short",v=S+"|"+c,x=s[v];return x||(x=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:S,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:c}),s[v]=x),x})(g,f);return b.formatToParts(m)},l=function(u,g){for(var f=h(u,g),m=[],b=0;b<f.length;b+=1){var S=f[b],y=S.type,c=S.value,v=e[y];v>=0&&(m[v]=parseInt(c,10))}var x=m[3],T=x===24?0:x,O=m[0]+"-"+m[1]+"-"+m[2]+" "+T+":"+m[4]+":"+m[5]+":000",_=+u;return(a.utc(O).valueOf()-(_-=_%1e3))/6e4},d=r.prototype;d.tz=function(u,g){u===void 0&&(u=o);var f,m=this.utcOffset(),b=this.toDate(),S=b.toLocaleString("en-US",{timeZone:u}),y=Math.round((b-new Date(S))/1e3/60),c=15*-Math.round(b.getTimezoneOffset()/15)-y;if(!Number(c))f=this.utcOffset(0,g);else if(f=a(S,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(c,!0),g){var v=f.utcOffset();f=f.add(m-v,"minute")}return f.$x.$timezone=u,f},d.offsetName=function(u){var g=this.$x.$timezone||a.tz.guess(),f=h(this.valueOf(),g,{timeZoneName:u}).find(function(m){return m.type.toLowerCase()==="timezonename"});return f&&f.value};var p=d.startOf;d.startOf=function(u,g){if(!this.$x||!this.$x.$timezone)return p.call(this,u,g);var f=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return p.call(f,u,g).tz(this.$x.$timezone,!0)},a.tz=function(u,g,f){var m=f&&g,b=f||g||o,S=l(+a(),b);if(typeof u!="string")return a(u).tz(b);var y=(function(T,O,_){var C=T-60*O*1e3,k=l(C,_);if(O===k)return[C,O];var L=l(C-=60*(k-O)*1e3,_);return k===L?[C,k]:[T-60*Math.min(k,L)*1e3,Math.max(k,L)]})(a.utc(u,m).valueOf(),S,b),c=y[0],v=y[1],x=a(c).utcOffset(v);return x.$x.$timezone=b,x},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(u){o=u}}})})(bo);var kf=bo.exports;const Ef=Mt(kf);var xo={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){var e="minute",s=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,a,o){var h=a.prototype;o.utc=function(m){var b={date:m,utc:!0,args:arguments};return new a(b)},h.utc=function(m){var b=o(this.toDate(),{locale:this.$L,utc:!0});return m?b.add(this.utcOffset(),e):b},h.local=function(){return o(this.toDate(),{locale:this.$L,utc:!1})};var l=h.parse;h.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),l.call(this,m)};var d=h.init;h.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else d.call(this)};var p=h.utcOffset;h.utcOffset=function(m,b){var S=this.$utils().u;if(S(m))return this.$u?0:S(this.$offset)?p.call(this):this.$offset;if(typeof m=="string"&&(m=(function(x){x===void 0&&(x="");var T=x.match(s);if(!T)return null;var O=(""+T[0]).match(n)||["-",0,0],_=O[0],C=60*+O[1]+ +O[2];return C===0?0:_==="+"?C:-C})(m),m===null))return this;var y=Math.abs(m)<=16?60*m:m,c=this;if(b)return c.$offset=y,c.$u=m===0,c;if(m!==0){var v=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(c=this.local().add(y+v,e)).$offset=y,c.$x.$localOffset=v}else c=this.utc();return c};var u=h.format;h.format=function(m){var b=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return u.call(this,b)},h.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},h.isUTC=function(){return!!this.$u},h.toISOString=function(){return this.toDate().toISOString()},h.toString=function(){return this.toDate().toUTCString()};var g=h.toDate;h.toDate=function(m){return m==="s"&&this.$offset?o(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var f=h.diff;h.diff=function(m,b,S){if(m&&this.$u===m.$u)return f.call(this,m,b,S);var y=this.local(),c=o(m).local();return f.call(y,c,b,S)}}})})(xo);var Mf=xo.exports;const Of=Mt(Mf);var Lf={exports:{}};(function(i,t){(function(e,s){i.exports=s()})(wt,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var s=["th","st","nd","rd"],n=e%100;return"["+e+(s[(n-20)%10]||s[n]||s[0])+"]"}}})})(Lf);var Af={exports:{}};(function(i,t){(function(e,s){i.exports=s(et)})(wt,function(e){function s(a){return a&&typeof a=="object"&&"default"in a?a:{default:a}}var n=s(e),r={name:"zh",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(a,o){return o==="W"?a+"周":a+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s后",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(a,o){var h=100*a+o;return h<600?"凌晨":h<900?"早上":h<1100?"上午":h<1300?"中午":h<1800?"下午":"晚上"}};return n.default.locale(r,null,!0),r})})(Af);const Df=(i,t)=>{const e=t.prototype;e.setLocale=function(n){return this.$locale=n||et().locale(),this.$L=this.$locale,this};const s=e.format;e.format=function(n){return this.$L=et().locale(),s.bind(this)(n)}};et.extend(sf);et.extend(rf);et.extend(af);et.extend(lf);et.extend(ff);et.extend(df);et.extend(pf);et.extend(yf);et.extend(bf);et.extend(_f);et.extend(Sf);et.extend(Cf);et.extend(Ef);et.extend(Of);et.extend(Df);function pr(i){try{if(et.locale()===i)return;if(et.locale(i)!==i)throw Error();Q.info(`Locale set to ${i}`)}catch{Q.warn(`Failed to set locale ${i}, fallback to en`),et.locale("en")}}const qt=()=>({small:{hour:15,day:15,week:5,month:3,quarter:3},normal:{hour:30,day:30,week:10,month:7,quarter:7},large:{hour:60,day:60,week:20,month:14,quarter:14}}),_o=class wo{constructor(){M(this,"startTime",et().startOf("day")),M(this,"endTime",et().endOf("day")),M(this,"targetEnd",et().endOf("day")),M(this,"strictStart",!1),M(this,"strictEnd",!1),M(this,"isAuto",!1),M(this,"timelineLayers",[]),M(this,"isDirty",!0),M(this,"isFirstTime",!0),M(this,"allWidth",0),M(this,"scales",[]),M(this,"isLegacyMode",!0),M(this,"legacyCellWidthMap"),M(this,"_resolvedCellWidth",30),M(this,"_resolvedLayerHeights",[]),M(this,"_resolvedHeaderHeight",80),M(this,"unit","day"),M(this,"headerGroupFormat"),M(this,"headerCellFormat"),this.legacyCellWidthMap=le(qt().normal)}getStartTime(){return this.startTime}getEndTime(){return this.endTime}getCellWidth(){const t=this.isLegacyMode?this.legacyCellWidthMap[this.unit]:this._resolvedCellWidth;if(this.isAuto){const e=this.allWidth/this.getCellCount();return Math.max(isNaN(e)?0:e,t)}return t}getCellCount(){const t=this.getTimeline();return t.length===0?0:t[t.length-1].items.length}getCellUnit(){return this.getMinimumUnit()}getScales(){return this.scales}getBottomScale(){return this.scales[this.scales.length-1]}getLayerHeights(){return this._resolvedLayerHeights}getResolvedHeaderHeight(){return this._resolvedHeaderHeight}getBottomCellWidth(t){const e=this.getBottomScale();return this.getUnitsPerCell(e,t)*this.getCellWidth()}setAllWidth(t){if(this.allWidth=t,!this.strictEnd){const e=this.getCellWidth(),s=this.targetEnd.diff(this.startTime,this.getMinimumUnit());if(e*s<this.allWidth){const n=this.allWidth-e*s,r=Math.ceil(n/e);this.endTime=this.targetEnd.add(r,this.getMinimumUnit()),this.invalidateCache()}}}getTimeLeft(t){const e=this.getCellWidth(),s=this.getMinimumUnit(),n=3600*(s==="day"?24:1)/e;return t.diff(this.startTime,"second")/n}getTimeByLeft(t){const e=this.getCellWidth(),s=this.getMinimumUnit(),n=3600*(s==="day"?24:1)/e,r=t*n;return this.startTime.add(r,"second")}init(t,e=!0){this.isDirty=!0,this.isFirstTime=e;const{unit:s,chart:n,scaleUnit:r}=t;if(this.isAuto=!!n.autoCellWidth,r&&r.length>0){this.isLegacyMode=!1,this.scales=r.map(o=>({unit:o.unit,step:o.step??1,format:o.format,cellWidth:o.cellWidth,height:o.height}));const a=this.scales[this.scales.length-1];if(a.cellWidth){const o=this.getUnitsPerCell(a);this._resolvedCellWidth=o>0?a.cellWidth/o:30}else this._resolvedCellWidth=this.resolveCellWidthFromChart(n);this.resolveLayerHeights(t.header.height)}else{this.isLegacyMode=!0;const a={hour:"hour",day:"day",week:"week",month:"month",quarter:"quarter"}[s];a||Q.warn(`Unknown unit: [${s}]. Falling back to "day".`),this.unit=a||"day",this.scales=this.legacyUnitToScales(this.unit),n.cellWidth&&(an(n.cellWidth)?this.legacyCellWidthMap={hour:n.cellWidth,day:n.cellWidth,week:n.cellWidth,month:n.cellWidth,quarter:n.cellWidth}:Ft(n.cellWidth)?this.legacyCellWidthMap=le(qt()[n.cellWidth]||qt().normal):_t(n.cellWidth)&&(this.legacyCellWidthMap=Object.assign(this.legacyCellWidthMap,n.cellWidth))),this.headerCellFormat=n.headerCellFormat,this.headerGroupFormat=n.headerGroupFormat,this.resolveLayerHeights(t.header.height)}n.startTime&&(this.startTime=et(n.startTime).startOf(this.getMinimumUnit()),this.strictStart=!0),n.endTime&&(this.endTime=et(n.endTime).endOf(this.getMinimumUnit()),this.strictEnd=!0)}update(t){this.init(t,!1),this.endTime=this.targetEnd.clone()}setDate(t,e){this.strictStart||t&&(this.isFirstTime||t.isBefore(this.startTime))&&(this.startTime=t.startOf(this.getMinimumUnit())),this.strictEnd||e&&(this.isFirstTime||e.isAfter(this.endTime))&&(this.endTime=e.endOf(this.getMinimumUnit())),this.targetEnd=this.endTime.clone(),this.isFirstTime=!1,this.invalidateCache()}getTimeline(){if(!this.isDirty&&this.timelineLayers.length>0)return this.timelineLayers;const t=[];for(let e=0;e<this.scales.length;e++){const s=this.scales[e],n=[];let r=this.startTime.clone();for(r=this.alignToScaleStart(r,s);r.isSameOrBefore(this.endTime,this.getMinimumUnit());){const a=this.advanceCursor(r,s),o=this.calculateSpan(r,a),h=this.formatLabel(r,s,e===0&&this.scales.length===1);o>0&&n.push({date:r,label:h,span:o}),r=a}t.push({scale:s,items:n})}return this.isDirty=!1,this.timelineLayers=t,t}clear(){this.isDirty=!0,this.isFirstTime=!0}getTotalWidth(){const t=this.getTimeline();return t.length===0?0:t[t.length-1].items.reduce((e,s)=>e+s.span*this.getCellWidth(),0)}expand(t,e=1){t==="left"?this.startTime=this.startTime.subtract(e,this.getMinimumUnit()):t==="right"?this.endTime=this.endTime.add(e,this.getMinimumUnit()):t==="all"&&(this.startTime=this.startTime.subtract(e,this.getMinimumUnit()),this.endTime=this.endTime.add(e,this.getMinimumUnit())),this.targetEnd=this.endTime.clone(),this.invalidateCache()}isInTimeAxis(t){return t.isSameOrAfter(this.startTime)&&t.isSameOrBefore(this.endTime)}getUnitsPerCell(t,e){if(this.getMinimumUnit()==="hour")switch(t.unit){case"minute":return t.step/60;case"hour":return t.step;case"day":return t.step*24;case"week":return t.step*7*24;case"month":return(e?e.daysInMonth():30)*t.step*24;case"quarter":return this.getQuarterDays(e)*t.step*24;case"year":return(e!=null&&e.isLeapYear()?366:365)*t.step*24;default:return t.step}else switch(t.unit){case"minute":case"hour":return t.step;case"day":return t.step;case"week":return t.step*7;case"month":return(e?e.daysInMonth():30)*t.step;case"quarter":return this.getQuarterDays(e)*t.step;case"year":return(e!=null&&e.isLeapYear()?366:365)*t.step;default:return t.step}}invalidateCache(){this.isDirty=!0}getMinimumUnit(){for(const t of this.scales)if(t.unit==="hour"||t.unit==="minute")return"hour";return"day"}legacyUnitToScales(t){const e=this.headerGroupFormat,s=this.headerCellFormat;switch(t){case"hour":return[{unit:"day",step:1,format:e},{unit:"hour",step:1,format:s}];case"day":return[{unit:"month",step:1,format:e},{unit:"day",step:1,format:s}];case"week":return[{unit:"month",step:1,format:e},{unit:"week",step:1,format:s}];case"month":return[{unit:"year",step:1,format:e},{unit:"month",step:1,format:s}];case"quarter":return[{unit:"year",step:1,format:e},{unit:"quarter",step:1,format:s}];default:return[{unit:"month",step:1},{unit:"day",step:1}]}}resolveLayerHeights(t){const e=this.scales.length;if(e===0){this._resolvedLayerHeights=[],this._resolvedHeaderHeight=t;return}const s=wo.MIN_SCALE_ROW_HEIGHT,n=new Array(e).fill(0),r=new Array(e).fill(!1);let a=0,o=0;for(let l=0;l<e;l++){const d=this.scales[l].height;d!=null?(n[l]=Math.max(Math.floor(d),s),a+=n[l],r[l]=!0):o++}if(o>0){const l=t-a,d=Math.floor(l/o);if(d>=s){let p=0,u=0;for(let g=0;g<e;g++)r[g]||(u++,n[g]=u===o?l-p:d,p+=n[g])}else for(let p=0;p<e;p++)r[p]||(n[p]=s)}const h=n.reduce((l,d)=>l+d,0);this._resolvedHeaderHeight=Math.max(t,h),this._resolvedLayerHeights=n}resolveCellWidthFromChart(t){const e=this.getMinimumUnit()==="hour"?"hour":"day";if(!t.cellWidth)return qt().normal[e];if(an(t.cellWidth))return t.cellWidth;if(Ft(t.cellWidth)){const s=qt()[t.cellWidth];return s?s[e]:qt().normal[e]}return _t(t.cellWidth)?t.cellWidth[e]??qt().normal[e]:qt().normal[e]}alignToScaleStart(t,e){if(e.step<=1)return e.unit==="quarter"?t.startOf("quarter"):t.startOf(e.unit);switch(e.unit){case"minute":{const s=t.startOf("hour"),n=t.minute();return s.add(Math.floor(n/e.step)*e.step,"minute")}case"hour":{const s=t.startOf("day"),n=t.hour();return s.add(Math.floor(n/e.step)*e.step,"hour")}case"day":{const s=t.startOf("month"),n=t.date()-1;return s.add(Math.floor(n/e.step)*e.step,"day")}case"week":{const s=t.startOf("year").startOf("week"),n=t.startOf("week").diff(s,"week");return s.add(Math.floor(n/e.step)*e.step,"week")}case"month":{const s=t.startOf("year"),n=t.month();return s.add(Math.floor(n/e.step)*e.step,"month")}case"quarter":{const s=t.startOf("year"),n=Math.floor(t.month()/3);return s.add(Math.floor(n/e.step)*e.step*3,"month")}case"year":{const s=t.year()-2e3,n=Math.floor(s/e.step)*e.step+2e3;return t.year(n).startOf("year")}default:return t.startOf(e.unit)}}advanceCursor(t,e){return e.unit==="quarter"?t.add(e.step,"quarter"):t.add(e.step,e.unit)}calculateSpan(t,e){const s=this.getMinimumUnit(),n=e.isAfter(this.endTime.add(1,s))?this.endTime.add(1,s):e,r=t.isBefore(this.startTime)?this.startTime:t,a=n.diff(r,s);return Math.max(0,a)}formatLabel(t,e,s){if(Bt(e.format)){const n=e.format(t.toDate(),e.unit,e.step);if(n)return n}return Ft(e.format)?t.format(e.format):this.getDefaultFormat(t,e.unit,s)}getDefaultFormat(t,e,s){switch(e){case"year":return t.format("YYYY");case"quarter":return t.format("[Q]Q");case"month":return s?t.format("YYYY-MM"):t.format("MMM");case"week":return t.format("wo");case"day":return s?t.format("YYYY-MM-DD"):t.format("Do");case"hour":return s?t.format("HH:mm"):t.format("H");case"minute":return t.format("HH:mm");default:return t.format("YYYY-MM-DD")}}getQuarterDays(t){if(!t)return 91;const e=t.startOf("quarter");return e.add(1,"quarter").diff(e,"day")}};M(_o,"MIN_SCALE_ROW_HEIGHT",20);let Rf=_o;class Pf{constructor(t,e){M(this,"optionManager"),M(this,"dataManager"),M(this,"columnManager"),M(this,"linkManager"),M(this,"timeAxis");var s,n,r;this.context=t;const a=hn(e,["data"]),o=e==null?void 0:e.data;if(o&&!ft(o))throw Q.exception("Data should be a array.");this.optionManager=new Yu,this.optionManager.setOptions(a),a.locale&&pr(a.locale),this.timeAxis=new Rf,this.timeAxis.init(this.optionManager.getOptions());const h=this.timeAxis.getResolvedHeaderHeight();h!==this.optionManager.getOptions().header.height&&(this.optionManager.getOptions().header.height=h),this.columnManager=new Zu(this.context),a.table&&a.table.columns&&this.columnManager.init(a.table.columns),this.dataManager=new qu(this,this.context.event),o&&this.dataManager.setData(o,!0),(s=e==null?void 0:e.baselines)!=null&&s.data&&this.dataManager.setBaselines(e.baselines.data),this.linkManager=new tf(this,this.context.event),ft((n=e==null?void 0:e.links)==null?void 0:n.data)&&this.linkManager.setLinks(e.links.data,!0),this.linkManager.setCycleDetection(((r=e==null?void 0:e.links)==null?void 0:r.enableCycleDetection)??!0)}getOptionManager(){return this.optionManager}getDataManager(){return this.dataManager}getColumnManager(){return this.columnManager}getLinkManager(){return this.linkManager}getTimeAxis(){return this.timeAxis}setOption(t,e={merge:!0}){var s,n,r,a;const o=hn(t,["data"]),h=t==null?void 0:t.data;this.optionManager.setOptions(o,e),((s=o.milestone)==null?void 0:s.show)!==void 0&&this.dataManager.getVisibleTasks().forEach(d=>{d.updateMode()}),this.context.getScrollbar().updateOptions(this.context.store.getOptionManager().getOptions().scrollbar||{}),this.context.event.emit(V.OPTIONS_UPDATE),ft(h)&&this.dataManager.setData(h,!1),ft((n=t.baselines)==null?void 0:n.data)&&this.dataManager.setBaselines(t.baselines.data),ft((r=t.links)==null?void 0:r.data)&&this.linkManager.setLinks(t.links.data,!0),this.linkManager.setCycleDetection(((a=t.links)==null?void 0:a.enableCycleDetection)??!0),o.locale&&pr(o.locale),o.table&&o.table.columns&&this.columnManager.update(o.table.columns),this.timeAxis.update(this.optionManager.getOptions());const l=this.timeAxis.getResolvedHeaderHeight();l!==this.optionManager.getOptions().header.height&&(this.optionManager.getOptions().header.height=l)}updateTime(t,e){this.timeAxis.setDate(t,e)}}class If{constructor(t,e,s){M(this,"rootElement"),M(this,"options"),M(this,"hScrollbar"),M(this,"vScrollbar"),M(this,"hScrollThumb"),M(this,"vScrollThumb"),M(this,"scrollbarContainer"),M(this,"viewportWidth",0),M(this,"viewportHeight",0),M(this,"contentWidth",0),M(this,"contentHeight",0),M(this,"scrollLeft",0),M(this,"scrollTop",0),M(this,"isDraggingHScroll",!1),M(this,"isDraggingVScroll",!1),M(this,"isMouseOverRoot",!1),M(this,"isMouseOverScrollbar",!1),M(this,"hideTimeout",null),M(this,"showTimeout",null),M(this,"isVisible",!1),M(this,"dragStartX",0),M(this,"dragStartY",0),M(this,"thumbStartScrollLeft",0),M(this,"thumbStartScrollTop",0),M(this,"isAnimating",!1),M(this,"animationFrameId",null),M(this,"animationStartTime",0),M(this,"animationStartScrollLeft",0),M(this,"animationStartScrollTop",0),M(this,"animationTargetScrollLeft",0),M(this,"animationTargetScrollTop",0),M(this,"animationSource","api"),M(this,"throttledHandleMouseMove"),M(this,"throttledHandleWheel"),M(this,"handleRootMouseMove",()=>{!this.isVisible&&this.isMouseOverRoot?this.scheduleShow():this.isVisible&&!this.isMouseOverScrollbar&&this.scheduleHide()}),M(this,"handleScrollbarMouseEnter",()=>{this.isMouseOverScrollbar=!0,this.scheduleShow()}),M(this,"handleScrollbarMouseLeave",()=>{this.isMouseOverScrollbar=!1,this.isMouseOverRoot&&this.scheduleHide()}),M(this,"handleMouseEnter",()=>{this.isMouseOverRoot=!0,this.scheduleShow()}),M(this,"handleMouseLeave",()=>{this.isMouseOverRoot=!1,!this.isDraggingHScroll&&!this.isDraggingVScroll&&!this.isMouseOverScrollbar&&(this.clearTimeouts(!0,!1),this.scheduleHide())}),M(this,"handleHorizontalThumbMouseDown",n=>{n.preventDefault(),n.stopPropagation(),this.isDraggingHScroll=!0,this.dragStartX=n.clientX,this.thumbStartScrollLeft=this.scrollLeft,this.hScrollThumb.style.backgroundColor=this.options.thumb.color,this.scheduleShow(),document.addEventListener("mousemove",this.throttledHandleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}),M(this,"handleVerticalThumbMouseDown",n=>{n.preventDefault(),n.stopPropagation(),this.isDraggingVScroll=!0,this.dragStartY=n.clientY,this.thumbStartScrollTop=this.scrollTop,this.vScrollThumb.style.backgroundColor=this.options.thumb.color,this.scheduleShow(),document.addEventListener("mousemove",this.throttledHandleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}),M(this,"handleHorizontalTrackMouseDown",n=>{if(n.target!==this.hScrollbar)return;n.preventDefault();const r=this.hScrollbar.getBoundingClientRect(),a=this.hScrollThumb.offsetWidth,o=n.clientX-r.left,h=this.hScrollbar.clientWidth,l=this.contentWidth-this.viewportWidth,d=h-a,p=(o-a/2)/d*l;this.scrollTo({x:p,y:this.scrollTop},"track")}),M(this,"handleVerticalTrackMouseDown",n=>{if(n.target!==this.vScrollbar)return;n.preventDefault();const r=this.vScrollbar.getBoundingClientRect(),a=this.vScrollThumb.offsetHeight,o=n.clientY-r.top,h=this.vScrollbar.clientHeight,l=this.contentHeight-this.viewportHeight,d=h-a,p=(o-a/2)/d*l;this.scrollTo({x:this.scrollLeft,y:p},"track")}),M(this,"handleMouseUp",()=>{if(this.isDraggingHScroll||this.isDraggingVScroll){const n=this.isDraggingHScroll,r=this.isDraggingVScroll;this.isDraggingHScroll=!1,this.isDraggingVScroll=!1,n&&(this.hScrollThumb.style.backgroundColor=this.options.thumb.color),r&&(this.vScrollThumb.style.backgroundColor=this.options.thumb.color),document.removeEventListener("mousemove",this.throttledHandleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),!this.isMouseOverRoot&&!this.isMouseOverScrollbar?this.scheduleHide():this.scheduleHide()}}),M(this,"animationStep",n=>{if(!this.isAnimating)return;const r=n-this.animationStartTime,a=this.options.animationDuration,o=Math.min(1,r/a),h=o*(2-o),l=this.animationStartScrollLeft+(this.animationTargetScrollLeft-this.animationStartScrollLeft)*h,d=this.animationStartScrollTop+(this.animationTargetScrollTop-this.animationStartScrollTop)*h,p=this.scrollLeft!==l,u=this.scrollTop!==d;(p||u)&&this.emit(this.animationSource,l,d),o<1?this.animationFrameId=requestAnimationFrame(this.animationStep):(this.isAnimating=!1,this.animationFrameId=null,(this.scrollLeft!==this.animationTargetScrollLeft||this.scrollTop!==this.animationTargetScrollTop)&&this.emit(this.animationSource,this.animationTargetScrollLeft,this.animationTargetScrollTop),this.scheduleHide())}),this.root=t,this.rootElement=e,this.createElements(),this.updateOptions(s),this.throttledHandleMouseMove=ln(this.handleMouseMove.bind(this),16),this.throttledHandleWheel=ln(this.handleWheel.bind(this),16,{leading:!0,trailing:!1}),this.bindEvents(),this.rootElement.matches(":hover")?this.handleMouseEnter():(this.clearTimeouts(),this.hideScrollbars(!0))}updateOptions(t){this.options=_i({showHorizontal:!0,showVertical:!0,track:{size:8,radius:4,color:"transparent"},thumb:{size:30,radius:4,color:"rgba(0, 0, 0, 0.4)"},showDelay:0,hideDelay:500,animationDuration:100,showDuration:200,hideDuration:200},t),this.applyStyles()}createElements(){this.scrollbarContainer=document.createElement("div"),this.scrollbarContainer.className="x-gantt-scrollbar-container",this.rootElement.appendChild(this.scrollbarContainer),this.hScrollbar=this.createScrollbarElement("horizontal"),this.hScrollThumb=this.createScrollThumbElement("horizontal"),this.hScrollbar.appendChild(this.hScrollThumb),this.vScrollbar=this.createScrollbarElement("vertical"),this.vScrollThumb=this.createScrollThumbElement("vertical"),this.vScrollbar.appendChild(this.vScrollThumb),this.scrollbarContainer.appendChild(this.hScrollbar),this.scrollbarContainer.appendChild(this.vScrollbar)}createScrollbarElement(t){const e=document.createElement("div");return e.className=`x-gantt-scrollbar x-gantt-${t}-scrollbar`,e}createScrollThumbElement(t){const e=document.createElement("div");return e.className=`x-gantt-scrollbar-thumb x-gantt-${t}-thumb`,e}applyStyles(){const t=this.scrollbarContainer.style;t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="none",t.zIndex="100",this.applyScrollbarStyles(this.hScrollbar,"horizontal"),this.applyScrollbarStyles(this.vScrollbar,"vertical"),this.applyThumbStyles(this.hScrollThumb,"horizontal"),this.applyThumbStyles(this.vScrollThumb,"vertical")}applyScrollbarStyles(t,e){const s=t.style;s.position="absolute",s.backgroundColor=this.options.track.color,s.borderRadius=`${this.options.track.size/2}px`,s.opacity="0",s.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`,s.pointerEvents="auto",e==="horizontal"?(s.bottom="0px",s.left="0px",s.height=`${this.options.track.size}px`,s.width="0px"):(s.right="0px",s.top="0px",s.width=`${this.options.track.size}px`,s.height="0px")}applyThumbStyles(t,e){const s=t.style;s.position="absolute",s.backgroundColor=this.options.thumb.color,s.borderRadius=`${this.options.thumb.radius}px`,s.cursor="pointer",s.transition="background-color 0.2s",s.pointerEvents="auto",e==="horizontal"?(s.height="100%",s.top="0",s.left="0"):(s.width="100%",s.left="0",s.top="0")}bindEvents(){this.rootElement.addEventListener("mouseenter",this.handleMouseEnter),this.rootElement.addEventListener("mouseleave",this.handleMouseLeave),this.rootElement.addEventListener("mousemove",this.handleRootMouseMove),this.hScrollThumb.addEventListener("mousedown",this.handleHorizontalThumbMouseDown),this.vScrollThumb.addEventListener("mousedown",this.handleVerticalThumbMouseDown),this.hScrollbar.addEventListener("mousedown",this.handleHorizontalTrackMouseDown),this.vScrollbar.addEventListener("mousedown",this.handleVerticalTrackMouseDown),this.hScrollbar.addEventListener("mouseenter",this.handleScrollbarMouseEnter),this.vScrollbar.addEventListener("mouseenter",this.handleScrollbarMouseEnter),this.hScrollbar.addEventListener("mouseleave",this.handleScrollbarMouseLeave),this.vScrollbar.addEventListener("mouseleave",this.handleScrollbarMouseLeave),this.rootElement.addEventListener("wheel",this.throttledHandleWheel,{passive:!1})}unbindEvents(){this.rootElement.removeEventListener("mouseenter",this.handleMouseEnter),this.rootElement.removeEventListener("mouseleave",this.handleMouseLeave),this.rootElement.removeEventListener("mousemove",this.handleRootMouseMove),this.hScrollThumb.removeEventListener("mousedown",this.handleHorizontalThumbMouseDown),this.vScrollThumb.removeEventListener("mousedown",this.handleVerticalThumbMouseDown),this.hScrollbar.removeEventListener("mousedown",this.handleHorizontalTrackMouseDown),this.vScrollbar.removeEventListener("mousedown",this.handleVerticalTrackMouseDown),this.hScrollbar.removeEventListener("mouseenter",this.handleScrollbarMouseEnter),this.vScrollbar.removeEventListener("mouseenter",this.handleScrollbarMouseEnter),this.hScrollbar.removeEventListener("mouseleave",this.handleScrollbarMouseLeave),this.vScrollbar.removeEventListener("mouseleave",this.handleScrollbarMouseLeave),this.rootElement.removeEventListener("wheel",this.throttledHandleWheel),document.removeEventListener("mousemove",this.throttledHandleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}emit(t,e,s){this.scrollLeft=at(e,0,this.contentWidth-this.viewportWidth),this.scrollTop=at(s,0,this.contentHeight-this.viewportHeight),this.updateThumbStyles(),this.root.event.emit(V.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:t})}handleMouseMove(t){if(!(!this.isDraggingHScroll&&!this.isDraggingVScroll)){if(this.scheduleShow(),this.isDraggingHScroll){const e=t.clientX-this.dragStartX,s=this.hScrollbar.clientWidth,n=this.hScrollThumb.offsetWidth,r=Math.max(0,s-n),a=Math.max(0,this.contentWidth-this.viewportWidth);if(r===0||a===0)return;const o=e/r*a,h=this.thumbStartScrollLeft+o;this.scrollTo({x:h,y:this.scrollTop},"drag")}if(this.isDraggingVScroll){const e=t.clientY-this.dragStartY,s=this.vScrollbar.clientHeight,n=this.vScrollThumb.offsetHeight,r=Math.max(0,s-n),a=Math.max(0,this.contentHeight-this.viewportHeight);if(r===0||a===0)return;const o=e/r*a,h=this.thumbStartScrollTop+o;this.scrollTo({x:this.scrollLeft,y:h},"drag")}}}handleWheel(t){if(t.target!==this.rootElement&&!this.rootElement.contains(t.target)&&Q.debug("Wheel event ignored, target not root or descendant:",t.target),!this.isMouseOverRoot&&!this.isMouseOverScrollbar){Q.debug("Wheel event ignored, mouse not over root or scrollbar");return}const e=this.canScrollHorizontal(),s=this.canScrollVertical();if(!e&&!s)return;t.preventDefault();let n=t.deltaX,r=t.deltaY;Math.abs(t.deltaX)<Math.abs(t.deltaY)&&t.shiftKey&&e&&(n=r,r=0);const a=this.scrollLeft+n,o=this.scrollTop+r;this.emit("wheel",a,o)}animateWheelScroll(t,e){this.cancelAnimation();const s=this.clampScroll({x:t,y:e});if(this.scrollLeft===s.x&&this.scrollTop===s.y)return;this.isAnimating=!0,this.animationStartTime=performance.now(),this.animationStartScrollLeft=this.scrollLeft,this.animationStartScrollTop=this.scrollTop,this.animationTargetScrollLeft=s.x,this.animationTargetScrollTop=s.y,this.animationSource="wheel";const n=150,r=a=>{if(!this.isAnimating)return;const o=a-this.animationStartTime,h=Math.min(1,o/n),l=h*(2-h),d=this.animationStartScrollLeft+(this.animationTargetScrollLeft-this.animationStartScrollLeft)*l,p=this.animationStartScrollTop+(this.animationTargetScrollTop-this.animationStartScrollTop)*l,u=this.scrollLeft!==d,g=this.scrollTop!==p;(u||g)&&this.emit("wheel",d,p),h<1?this.animationFrameId=requestAnimationFrame(r):(this.isAnimating=!1,this.animationFrameId=null,(this.scrollLeft!==this.animationTargetScrollLeft||this.scrollTop!==this.animationTargetScrollTop)&&this.emit("wheel",this.animationTargetScrollLeft,this.animationTargetScrollTop),this.scheduleHide())};this.animationFrameId=requestAnimationFrame(r)}clearTimeouts(t=!0,e=!0){t&&this.showTimeout!==null&&(window.clearTimeout(this.showTimeout),this.showTimeout=null),e&&this.hideTimeout!==null&&(window.clearTimeout(this.hideTimeout),this.hideTimeout=null)}scheduleShow(){if(this.isVisible||this.showTimeout!==null){this.hideTimeout!==null&&this.clearTimeouts(!1,!0);return}this.clearTimeouts(!0,!0),this.options.showDelay<=0?this.showScrollbars():this.showTimeout=window.setTimeout(()=>{this.showScrollbars(),this.showTimeout=null},this.options.showDelay)}showScrollbars(){this.clearTimeouts(),this.isVisible=!0,this.hScrollbar.style.transition=`opacity ${this.options.showDuration/1e3}s ease-in`,this.vScrollbar.style.transition=`opacity ${this.options.showDuration/1e3}s ease-in`,requestAnimationFrame(()=>{this.canScrollHorizontal()&&this.options.showHorizontal?this.hScrollbar.style.opacity="1":this.hScrollbar.style.opacity="0",this.canScrollVertical()&&this.options.showVertical?this.vScrollbar.style.opacity="1":this.vScrollbar.style.opacity="0",setTimeout(()=>{this.isVisible&&(this.hScrollbar.style.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`,this.vScrollbar.style.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`)},this.options.showDuration)}),this.scheduleHide()}scheduleHide(){if(this.isDraggingHScroll||this.isDraggingVScroll||this.isMouseOverScrollbar){this.clearTimeouts(!0,!0);return}this.hideTimeout===null&&(this.clearTimeouts(!0,!1),this.hideTimeout=window.setTimeout(()=>{!this.isMouseOverRoot&&!this.isDraggingHScroll&&!this.isDraggingVScroll&&!this.isMouseOverScrollbar&&this.hideScrollbars(),this.hideTimeout=null},this.options.hideDelay))}hideScrollbars(t=!1){!t&&(this.isDraggingHScroll||this.isDraggingVScroll||this.isMouseOverScrollbar)||(this.clearTimeouts(!0,!0),this.isVisible=!1,this.hScrollbar.style.opacity="0",this.vScrollbar.style.opacity="0")}updateSize(t,e,s,n,r=0,a=0){this.viewportWidth=Math.max(0,t),this.viewportHeight=Math.max(0,e),this.contentWidth=Math.max(this.viewportWidth,s),this.contentHeight=Math.max(this.viewportHeight,n);const o=this.canScrollHorizontal()&&this.options.showHorizontal,h=this.canScrollVertical()&&this.options.showVertical;if(o){const d=this.viewportWidth-(h?this.options.track.size:0);this.hScrollbar.style.display="block",this.hScrollbar.style.transform=`translateX(${r}px)`,this.hScrollbar.style.width=`${Math.max(0,d)}px`,this.hScrollbar.style.bottom="0px",this.hScrollbar.style.right=h?`${this.options.track.size}px`:"0px"}else this.hScrollbar.style.display="none";if(h){const d=this.viewportHeight-a-(o?this.options.track.size:0);this.vScrollbar.style.display="block",this.vScrollbar.style.transform=`translateY(${a}px)`,this.vScrollbar.style.height=`${Math.max(0,d)}px`,this.vScrollbar.style.right="0px",this.vScrollbar.style.bottom=o?`${this.options.track.size}px`:"0px"}else this.vScrollbar.style.display="none";this.updateThumbStyles();const l=this.clampScroll({x:this.scrollLeft,y:this.scrollTop});(l.x!==this.scrollLeft||l.y!==this.scrollTop)&&this.emit("api",l.x,l.y),this.isMouseOverRoot||this.isDraggingHScroll||this.isDraggingVScroll?this.scheduleShow():!o&&!h?this.hideScrollbars(!0):this.isVisible?this.scheduleShow():this.hideScrollbars(!0)}updateThumbStyles(){if(this.canScrollHorizontal()&&this.options.showHorizontal){const t=this.hScrollbar.clientWidth,e=Math.max(this.options.thumb.size,t*(this.viewportWidth/this.contentWidth)),s=Math.min(t,e);this.hScrollThumb.style.width=`${s}px`;const n=this.contentWidth-this.viewportWidth,r=t-s,a=n>0?this.scrollLeft/n*r:0;this.hScrollThumb.style.transform=`translateX(${Math.max(0,Math.min(a,r))}px)`,this.hScrollThumb.style.left="0px"}else this.hScrollThumb.style.width="0px";if(this.canScrollVertical()&&this.options.showVertical){const t=this.vScrollbar.clientHeight,e=Math.max(this.options.thumb.size,t*(this.viewportHeight/this.contentHeight)),s=Math.min(t,e);this.vScrollThumb.style.height=`${s}px`;const n=this.contentHeight-this.viewportHeight,r=t-s,a=n>0?this.scrollTop/n*r:0;this.vScrollThumb.style.transform=`translateY(${Math.max(0,Math.min(a,r))}px)`,this.vScrollThumb.style.top="0px"}else this.vScrollThumb.style.height="0px"}canScrollHorizontal(){return this.contentWidth>this.viewportWidth}canScrollVertical(){return this.contentHeight>this.viewportHeight}clampScroll(t){const e=Math.max(0,this.contentWidth-this.viewportWidth),s=Math.max(0,this.contentHeight-this.viewportHeight);return{x:Math.max(0,Math.min(t.x,e)),y:Math.max(0,Math.min(t.y,s))}}scrollTo(t,e="api"){this.scheduleShow();const s=this.clampScroll(_i(this.getScrollPosition(),t));if(this.scrollLeft===s.x&&this.scrollTop===s.y){if(this.isAnimating&&this.animationTargetScrollLeft===s.x&&this.animationTargetScrollTop===s.y)return;this.cancelAnimation();return}const n=(e==="api"||e==="track")&&this.options.animationDuration>0;if(this.cancelAnimation(),n)this.isAnimating=!0,this.animationStartTime=performance.now(),this.animationStartScrollLeft=this.scrollLeft,this.animationStartScrollTop=this.scrollTop,this.animationTargetScrollLeft=s.x,this.animationTargetScrollTop=s.y,this.animationSource=e,this.animationFrameId=requestAnimationFrame(this.animationStep);else{this.isAnimating=!1;const r=this.scrollLeft!==s.x,a=this.scrollTop!==s.y;(r||a)&&this.emit(e,s.x,s.y)}}cancelAnimation(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isAnimating=!1}getScrollPosition(){return{x:this.scrollLeft,y:this.scrollTop}}destroy(){this.unbindEvents(),this.clearTimeouts(),this.cancelAnimation(),this.scrollbarContainer.parentNode&&this.scrollbarContainer.parentNode.removeChild(this.scrollbarContainer),this.rootElement=null,this.eventManager=null,this.hScrollbar=null,this.vScrollbar=null,this.hScrollThumb=null,this.vScrollThumb=null,this.scrollbarContainer=null,Q.debug("Scrollbar destroyed")}}function oe(i,t=""){const e=["px","%","vh","vw","rem","em"];if(i==null)return t;if(typeof i=="number")return isFinite(i)?`${i}px`:t;if(typeof i=="string"){const s=i.trim();if(s==="")return t;for(const r of e)if(s.endsWith(r)){const a=s.substring(0,s.length-r.length).trim(),o=Number(a);if(!isNaN(o)&&isFinite(o))return`${o}${r}`;break}const n=Number(s);if(!isNaN(n)&&isFinite(n))return`${n}px`}return t}const Gf=["script","iframe","object","embed","form","base","meta","link","style","template"];function So(i){if(!i||!i.includes("<"))return i;const t=new DOMParser().parseFromString(i,"text/html");return Gf.forEach(e=>{t.body.querySelectorAll(e).forEach(s=>s.remove())}),t.body.querySelectorAll("*").forEach(e=>{Array.from(e.attributes).forEach(s=>{const n=s.name.toLowerCase(),r=s.value.trim().toLowerCase();if(n.startsWith("on")){e.removeAttribute(s.name);return}(n==="href"||n==="src"||n==="action"||n==="xlink:href")&&r.startsWith("javascript:")&&e.removeAttribute(s.name)})}),t.body.innerHTML}class Ff{constructor(t,e,s){M(this,"element"),M(this,"isDragging",!1),M(this,"dragStartY",0),M(this,"dragStartIndex",-1),M(this,"currentIndex",-1),M(this,"dragType","inside"),M(this,"canDrop",!1),M(this,"ghostElement",null),M(this,"placeholderElement",null),M(this,"animationFrameId",null),M(this,"rowElement",null),M(this,"handleSelectStart",r=>{r.preventDefault()}),M(this,"handleMouseDown",r=>{if(!this.task||!this.container){Q.warn("DragHandler: task or container is not defined");return}if(this.rowElement=this.container.closest(".x-gantt-table-row"),!this.rowElement){Q.warn("Row element not found",this.container);return}r.preventDefault(),r.stopPropagation(),this.isDragging=!0,this.dragStartY=r.clientY+this.context.getScrollbar().getScrollPosition().y,this.dragStartIndex=this.task.flatIndex,this.currentIndex=this.dragStartIndex,this.createGhostElement(r),this.createPlaceholderElement(r),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),Q.debug(`Drag started for task ${this.task.id} at index ${this.dragStartIndex}`)}),M(this,"handleMouseMove",r=>{!this.isDragging||!this.task||!this.container||(this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=requestAnimationFrame(()=>{var a,o,h,l;const d=this.context.getRootElement();if(!d)return;const p=d.getBoundingClientRect(),u=this.context.getOptions().header.height,g=this.context.getOptions().row.height,f=this.context.getScrollbar().getScrollPosition(),m=r.clientY-p.top-u+f.y,b=Math.max(0,Math.min(Math.floor(m/g),this.context.store.getDataManager().getVisibleSize()-1)),S=m%g;let y;S<g*.25?y="before":S>g*.75?y="after":y="inside",this.dragType=y,this.updateGhostPosition(r.clientY-p.top),this.canDrop=!1;const c=this.context.store.getDataManager().getVisibleTasks()[b];((a=this.context.getOptions().drag.drop)==null?void 0:a.crossLevel)===!0?y=="inside"?this.canDrop=!this.task.isSomeoneChildren(c):this.canDrop=this.task.id!==c.id&&!this.task.isSomeoneChildren(c.parent):y!=="inside"&&(this.canDrop=((o=this.task.parent)==null?void 0:o.id)===((h=c.parent)==null?void 0:h.id)&&this.task.id!==c.id),this.canDrop===!0&&(l=this.context.getOptions().drag.drop)!=null&&l.allowed&&(this.canDrop=this.context.getOptions().drag.drop.allowed(c.getEmitData(),this.task.getEmitData())),this.updatePlaceholderPosition(b,y,p,f,this.canDrop),this.currentIndex!==b&&(this.currentIndex=b)}))}),M(this,"handleMouseUp",r=>{!this.isDragging||!this.task||(this.canDrop&&this.context.store.getDataManager().moveTask(this.dragType,this.task,this.currentIndex),this.cleanup())}),M(this,"handleKeyDown",r=>{r.key==="Escape"&&this.isDragging&&this.cleanup()});var n;this.context=t,this.container=e,this.task=s,this.element=document.createElement("div"),this.createElement(),this.bindEvents(),(n=this.container)==null||n.appendChild(this.element)}createElement(){this.element.className="x-gantt-drag-handle",this.element.style.color=this.context.getOptions().drag.color||"#999",this.element.innerHTML='<svg t="1746781386866" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3253" width="14" height="14"><path d="M384 128m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" fill="currentColor" p-id="3254"></path><path d="M384 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" fill="currentColor" p-id="3255"></path><path d="M384 896m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" fill="currentColor" p-id="3256"></path><path d="M704 128m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" fill="currentColor" p-id="3257"></path><path d="M704 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" fill="currentColor" p-id="3258"></path><path d="M704 896m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 -0Z" fill="currentColor" p-id="3259"></path></svg>'}bindEvents(){this.element.addEventListener("mousedown",this.handleMouseDown),this.element.addEventListener("selectstart",this.handleSelectStart)}createGhostElement(t){if(!this.container||!this.task||!this.rowElement)return;this.ghostElement=document.createElement("div"),this.ghostElement.className="x-gantt-drag-ghost",this.ghostElement.innerHTML=this.rowElement.innerHTML;const e=this.context.getRootElement();if(!e)return;const s=e.getBoundingClientRect(),n=this.rowElement.getBoundingClientRect();this.context.store.getTimeAxis().getTotalWidth(),this.ghostElement.style.position="absolute",this.ghostElement.style.left="0px",this.ghostElement.style.top=`${t.clientY-s.top-n.height/2}px`,this.ghostElement.style.width=`${s.width}px`,this.ghostElement.style.height=`${n.height}px`,this.ghostElement.style.pointerEvents="none",this.ghostElement.style.zIndex="10000",this.ghostElement.style.opacity="0.8",this.ghostElement.style.borderRadius="4px",this.ghostElement.style.overflow="hidden",this.ghostElement.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)";const r=document.createElement("div");r.style.cssText=`
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0; left: 0; right: 0; bottom: 0;
|
|
22
|
+
background: linear-gradient(to right,
|
|
23
|
+
rgba(255,255,255,0) 0%,
|
|
24
|
+
rgba(255,255,255,0.3) 50%,
|
|
25
|
+
rgba(255,255,255,0.9) 100%);
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
`,(this.context.getRootElement()||document.body).appendChild(this.ghostElement),Q.debug("Ghost element created")}updateGhostPosition(t){if(!this.ghostElement||!this.rowElement)return;const e=this.context.getRootElement();if(!e)return;const s=e.getBoundingClientRect(),n=this.context.getOptions().row.height,r=0,a=s.height-n,o=Math.max(r,Math.min(t-n/2,a));this.ghostElement.style.top=`${o}px`}createPlaceholderElement(t){this.rowElement&&(this.placeholderElement=document.createElement("div"),this.placeholderElement.className="x-gantt-drag-placeholder",this.placeholderElement.style.cssText=`
|
|
28
|
+
position: absolute;
|
|
29
|
+
left: 0;
|
|
30
|
+
top: ${t.clientY}px;
|
|
31
|
+
opacity: 0;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: ${this.context.getOptions().row.height}px;
|
|
34
|
+
background-color: ${lt(this.context.getOptions().drag.targetBackgroundColor||this.context.getOptions().primaryColor).toString()};
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
z-index: 9999;
|
|
37
|
+
transition: all 0.1s ease;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
`,this.context.getRootElement().appendChild(this.placeholderElement))}updatePlaceholderPosition(t,e,s,n,r){var a;if(!this.placeholderElement)return;if(!r){this.placeholderElement.style.opacity="0",this.context.getRootElement().style.setProperty("cursor","not-allowed","important");return}this.context.getRootElement().style.setProperty("cursor","grabbing","important");const o=this.context.getOptions().header.height,h=this.context.getOptions().row.height;let l=o+t*h;e==="after"&&(l+=h);const d=l-n.y,p=e==="inside"?h:2;this.placeholderElement.style.top=`${d}px`,this.placeholderElement.style.height=`${p}px`,this.placeholderElement.style.opacity==="0"&&(this.placeholderElement.style.opacity=((a=this.context.getOptions().drag.targetOpacity)==null?void 0:a.toString())||"0.2"),e==="inside"?(this.placeholderElement.style.backgroundColor=lt(this.context.getOptions().drag.targetBackgroundColor||this.context.getOptions().primaryColor).alpha(.1).toString(),this.placeholderElement.style.border=`2px dashed ${lt(this.context.getOptions().drag.targetBackgroundColor||this.context.getOptions().primaryColor).toString()}`):(this.placeholderElement.style.backgroundColor=lt(this.context.getOptions().drag.targetBackgroundColor||this.context.getOptions().primaryColor).toString(),this.placeholderElement.style.border="none")}cleanup(){this.isDragging=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.ghostElement&&this.ghostElement.parentNode&&(this.ghostElement.parentNode.removeChild(this.ghostElement),this.ghostElement=null),this.placeholderElement&&this.placeholderElement.parentNode&&(this.placeholderElement.parentNode.removeChild(this.placeholderElement),this.placeholderElement=null),this.rowElement=null,document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown)}getElement(){return this.element}destroy(){this.cleanup(),this.element.removeEventListener("mousedown",this.handleMouseDown),this.element.removeEventListener("selectstart",this.handleSelectStart),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),Q.debug("DragHandler destroyed")}}class fi{constructor(t,e,s,n,r,a,o=1,h=1,l){M(this,"element"),M(this,"isEmpty",!1),M(this,"isHandler",!1),this.context=t,this.container=e,this.column=s,this.task=n,this.rowIndex=r,this.colIndex=a,this.colspan=o,this.rowspan=h,this.isEmpty=l==="empty",this.isHandler=l==="handler",this.element=document.createElement("div"),this.element.className="x-gantt-table-cell",this.element.style.boxSizing="border-box",this.element.style.display="inline-flex",this.element.style.flexShrink="0",this.element.style.flexGrow="0",this.element.style.flexBasis="auto",this.element.style.pointerEvents="all",this.element.style.setProperty("border-color",this.context.getOptions().border.color,"important"),this.element.style.textAlign=this.column.column.align||this.context.getOptions().table.align,!this.context.store.getColumnManager().isLastColumn(this.column.key)&&this.context.getOptions().border.show&&!this.isEmpty&&this.element.classList.add("border"),this.updateWidth(),this.updateHeight(),this.isEmpty?(this.element.style.borderBottom="none",this.element.style.pointerEvents="none",this.element.style.backgroundColor="transparent",this.element.style.setProperty("border-color","transparent","important")):this.isHandler?this.setHandler():this.setContent(),this.container.appendChild(this.element)}setContent(){const t=document.createElement("div");if(t.className="x-gantt-table-cell__content",t.style.overflow="hidden",(this.column.column.ellipsis??this.context.getOptions().table.ellipsis??!0)&&(t.style.textOverflow="ellipsis"),t.style.whiteSpace="nowrap",t.style.flex="1",t.style.height="100%",t.style.alignContent="center",this.colIndex===0&&(t.style.paddingLeft=oe(this.task.level*this.context.getOptions().row.indent,"16px")),typeof this.column.column.render=="function")try{const e=this.column.column.render(this.task.getEmitData());typeof e=="string"?t.innerHTML=So(e):e instanceof HTMLElement?t.appendChild(e):Q.warn("Table cell render function does not return a valid value.",e)}catch(e){Q.error("Table cell render error:",e),t.textContent=this.task.getField(this.column.column.field)??this.context.getOptions().table.emptyText}else t.textContent=this.task.getField(this.column.column.field)??this.context.getOptions().table.emptyText;this.column.column.customStyle&&Object.assign(t.style,this.column.column.customStyle),this.element.appendChild(t)}setHandler(){const t=document.createElement("div");t.className="x-gantt-table-cell__content",t.style.overflow="hidden",t.style.whiteSpace="nowrap",t.style.display="inline-flex",t.style.flex="1",t.style.height="100%";const e=this.context.getOptions().drag.enabled!==!1,s=this.context.store.getOptionManager().unpackFunc(this.context.getOptions().drag.enabled,this.task),n=["0.3","0.3","0.4"];if(e||(n[0]="0",n[1]="0.5",n[2]="0.5"),e){const r=document.createElement("div");r.style.flex=n[0],r.style.display="flex",r.style.justifyContent="center",r.style.alignItems="center",s&&new Ff(this.context,r,this.task),t.appendChild(r)}if(this.context.getOptions().selection.enabled){const r=document.createElement("div");r.style.flex=n[1],r.style.display="flex",r.style.justifyContent="center",r.style.alignItems="center",new no(this.context,r,this.task),t.appendChild(r)}if(this.context.getOptions().expand.show&&this.task.children&&this.task.children.length>0){const r=document.createElement("div");r.className="x-gantt-table-cell__expand",r.style.flex=n[2],r.style.color=this.context.getOptions().primaryColor,r.style.display="flex",r.style.alignItems="center",r.style.justifyContent="center",r.style.height="100%",r.style.width="14px",r.style.height="100%",r.style.cursor="pointer",r.innerHTML='<svg t="1746693752280" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2612" width="14" height="14"><path d="M724.48 521.728c-1.8432 7.7824-5.7344 14.848-11.3664 20.48l-341.9136 342.016c-16.6912 16.6912-43.7248 16.6912-60.3136 0s-16.6912-43.7248 0-60.3136L622.6944 512 310.8864 200.0896c-16.6912-16.6912-16.6912-43.7248 0-60.3136 16.6912-16.6912 43.7248-16.6912 60.3136 0l341.9136 341.9136c10.8544 10.8544 14.6432 26.112 11.3664 40.0384z" fill="currentColor" p-id="2613"></path></svg>',r.style.transform=this.task.expanded?"rotate(90deg)":"",r.addEventListener("click",a=>{a.stopPropagation(),this.context.store.getDataManager().expandTask(this.task.id,!1)}),r.addEventListener("dblclick",a=>{a.stopPropagation()}),t.appendChild(r)}this.element.appendChild(t)}remove(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}updateWidth(){if(this.isHandler){this.element.style.width=oe(this.context.store.getColumnManager().getHandlerColumn().width);return}const t=this.context.store.getColumnManager().getLeafColumns().slice(this.colIndex,this.colIndex+Math.max(1,this.colspan)).reduce((e,s)=>e+s.width,0);this.element.style.width=oe(t)}updateHeight(){const t=this.context.getOptions().row.height;this.element.style.height=oe(t*Math.max(1,this.rowspan))}}class mr{constructor(t,e,s,n,r=!1){M(this,"element"),M(this,"cells",[]),M(this,"handleMouseEnter"),M(this,"handleMouseLeave"),M(this,"handleClick"),M(this,"handleDblClick"),M(this,"handleContextMenu"),M(this,"onRowHighlight"),M(this,"onRowUnhighlight"),M(this,"onTaskSelected"),M(this,"onTaskUnselected"),this.context=t,this.container=e,this.task=s,this.top=n,this.element=document.createElement("div"),this.element.className="x-gantt-table-row",this.element.style.display="flex",this.element.style.flexDirection="row",this.element.style.flexWrap="nowrap",this.element.style.position="absolute",this.element.style.pointerEvents="none",this.element.style.width=`${this.context.store.getColumnManager().getTotalWidth()}px`,r&&this.raise(),this.updateStyles(),this.container.appendChild(this.element),this.bindEvents(),this.registerEvents()}bindEvents(){this.handleMouseEnter=()=>{this.context.event.emit(V.ROW_HIGHLIGHT,this.task.id)},this.handleMouseLeave=()=>{this.context.event.emit(V.ROW_UNHIGHLIGHT,this.task.id)},this.handleClick=t=>{this.context.store.getDataManager().isTaskSelected(this.task.id)||this.context.store.getDataManager().selectTask(this.task.id),this.context.event.emit(V.ROW_CLICK,t,this.task)},this.handleDblClick=t=>{this.context.event.emit(V.ROW_DBL_CLICK,t,this.task)},this.handleContextMenu=t=>{t.preventDefault(),this.context.store.getDataManager().selectTask(this.task.id),this.context.event.emit(V.ROW_CONTEXTMENU,t,this.task)},this.element.addEventListener("mouseenter",this.handleMouseEnter),this.element.addEventListener("mouseleave",this.handleMouseLeave),this.element.addEventListener("click",this.handleClick),this.element.addEventListener("dblclick",this.handleDblClick),this.element.addEventListener("contextmenu",this.handleContextMenu)}registerEvents(){this.onRowHighlight=t=>{this.task.id===t?this.element.classList.add("hover"):this.element.classList.remove("hover")},this.onRowUnhighlight=t=>{this.task.id===t&&this.element.classList.remove("hover")},this.onTaskSelected=t=>{this.task.id===t.id&&this.element.classList.add("selected")},this.onTaskUnselected=t=>{this.task.id===t&&this.element.classList.remove("selected")},this.context.event.on(V.ROW_HIGHLIGHT,this.onRowHighlight),this.context.event.on(V.ROW_UNHIGHLIGHT,this.onRowUnhighlight),this.context.event.on(V.TASK_SELECTED,this.onTaskSelected),this.context.event.on(V.TASK_UNSELECTED,this.onTaskUnselected)}updateStyles(){this.updateTop(this.top),this.context.store.getDataManager().isTaskSelected(this.task.id),this.element.style.backgroundColor=this.context.store.getOptionManager().getRowBackgroundColor(this.task)}raise(){this.element.style.zIndex="2"}updateTop(t){this.top=t;const e=this.context.store.getOptionManager().getOptions().row.height,s=`${-this.top+this.task.flatIndex*e}px`;this.element.style.transform=`translateY(${s})`}create(){var t,e;this.clearCells();const s=this.context.store.getColumnManager().getHandlerColumn();if(s.width!==0){const r=new fi(this.context,this.element,s,this.task,this.task.flatIndex,-1,1,1,"handler");this.cells.push(r)}const n=this.context.store.getColumnManager().getLeafColumns();for(let r=0;r<n.length;r++){const a=n[r],o=this.context.store.getColumnManager().getMergeInfo(this.task.id,r);if(o){if(o.task.id!==this.task.id){const h=new fi(this.context,this.element,a,this.task,this.task.flatIndex,r,1,1,"empty");this.element.style.backgroundColor="transparent",this.raise(),this.cells.push(h)}else if(o.originColumnIndex===r){const h=new fi(this.context,this.element,a,o.task,o.task.flatIndex,r,o.colspan,o.rowspan);this.cells.push(h)}}else{let h=1,l=1;const d=(e=(t=a.column).merge)==null?void 0:e.call(t,this.task.getField(a.column.field),this.task.data,r,this.task.level+1);if(d&&(typeof d.col!="number"?Q.error("colspan function must returned a number"):h=d.col,typeof d.row!="number"?Q.error("rowspan function must returned a number"):l=d.row),h>1||l>1){if(l>1)for(let f=1;f<l;f++){const m=this.context.store.getDataManager().getVisibleTasks()[this.task.flatIndex+f];if(m&&this.task.level!==m.level){l=f;break}}const u={task:this.task,originColumnIndex:r,colspan:h,rowspan:l};let g=this.task;for(let f=l;f>0;f--)if(g){for(let m=0;m<h;m++)this.context.store.getColumnManager().addMergeInfo(g.id,m+r,u);g=this.context.store.getDataManager().getVisibleTasks().at(g.flatIndex+1)}for(let f=0;f<h;f++)this.context.store.getColumnManager().addMergeInfo(this.task.id,f+r,u)}const p=new fi(this.context,this.element,a,this.task,this.task.flatIndex,r,h,l);this.cells.push(p)}}this.context.store.getDataManager().isTaskSelected(this.task.id)&&this.element.classList.add("selected")}update(t){this.task=t,this.create()}updateWidth(){this.element.style.width=`${this.context.store.getColumnManager().getTotalWidth()}px`,this.cells.forEach(t=>t.updateWidth())}clearCells(){for(this.cells.forEach(t=>t.remove()),this.cells=[];this.element.firstChild;)this.element.removeChild(this.element.firstChild)}remove(){this.element.removeEventListener("mouseenter",this.handleMouseEnter),this.element.removeEventListener("mouseleave",this.handleMouseLeave),this.element.removeEventListener("click",this.handleClick),this.element.removeEventListener("dblclick",this.handleDblClick),this.element.removeEventListener("contextmenu",this.handleContextMenu),this.context.event.off(V.ROW_HIGHLIGHT,this.onRowHighlight),this.context.event.off(V.ROW_UNHIGHLIGHT,this.onRowUnhighlight),this.context.event.off(V.TASK_SELECTED,this.onTaskSelected),this.context.event.off(V.TASK_UNSELECTED,this.onTaskUnselected),this.clearCells(),this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class Nf{constructor(t,e){M(this,"element"),M(this,"rows",new Map),M(this,"mergeRows",new Map),this.context=t,this.container=e,this.element=document.createElement("div"),this.element.className="x-gantt-table-body",this.element.style.width="100%",this.element.style.position="relative",this.container.appendChild(this.element)}render(t,e){this.mergeRows.forEach(r=>r.remove()),this.mergeRows.clear();const s=new Set;e.forEach(r=>{s.add(r.id)});const n=[];this.rows.forEach((r,a)=>{s.has(a)||n.push(a)}),n.forEach(r=>{const a=this.rows.get(r);a&&a.remove(),this.rows.delete(r)}),e.forEach((r,a)=>{const o=r.id;if(this.rows.has(o)){const h=this.rows.get(o);h.update(r),h.updateTop(t)}else{const h=new mr(this.context,this.element,r,t);h.create(),this.rows.set(o,h)}this.context.store.getColumnManager().getLeafColumns().forEach((h,l)=>{const d=this.context.store.getColumnManager().getMergeInfo(r.id,l);if(d&&d.rowspan>1){const p=d.task.id;if(!this.rows.has(p)&&!this.mergeRows.has(p)){const u=new mr(this.context,this.element,d.task,t,!0);u.create(),this.mergeRows.set(p,u)}}})})}refresh(t,e){this.rows.forEach(s=>{s.remove()}),this.rows.clear(),this.render(t,e)}updateTask(t){this.rows.has(t.id)&&this.rows.get(t.id).update(t)}update(){this.rows.forEach(t=>{t.create()})}updateWidth(){this.rows.forEach(t=>{t.updateWidth()}),this.mergeRows.forEach(t=>{t.updateWidth()})}}class os{constructor(t,e,s,n){M(this,"columnElement"),this.context=t,this.root=e,this.container=s,this.column=n,this.columnElement=document.createElement("div"),this.initElement(),this.container.appendChild(this.columnElement)}initElement(){const t=this.context.store.getColumnManager(),e=t.getColumnWidth(this.column.key),s=this.column.column.headerAlign||this.context.getOptions().table.headerAlign,n=this.column.column.ellipsis??this.context.getOptions().table.ellipsis??!0;this.columnElement.className="x-gantt-table-header-cell",(t.isMultiHeader()||this.context.getOptions().border.show)&&this.columnElement.classList.add("border"),this.columnElement.style.height="100%",this.columnElement.style.width=`${e}px`,this.columnElement.style.display="flex",this.columnElement.style.flexShrink="0",this.columnElement.style.alignItems="center",this.columnElement.style.padding="0 8px",this.columnElement.style.boxSizing="border-box",this.columnElement.style.setProperty("border-color",this.context.getOptions().border.color,"important");const r=document.createElement("div");if(r.className="x-gantt-table-header-cell__content",r.style.flex="1",r.style.textAlign=s,r.style.overflow="hidden",r.style.whiteSpace="nowrap",n&&(r.style.textOverflow="ellipsis"),r.style.position="relative",r.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,r.style.fontSize=oe(this.context.getOptions().header.fontSize),r.style.setProperty("color",Ai(this.context.getOptions().header.color,this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor),"important"),r.style.fontFamily=this.context.getOptions().header.fontFamily,this.column.column.headerRender){const a=this.column.column.headerRender();typeof a=="string"?r.innerHTML=So(a):a instanceof HTMLElement&&(r.innerHTML="",r.appendChild(a))}else r.textContent=this.column.label||this.column.column.label||"";this.column.column.customStyle&&Object.assign(r.style,this.column.column.customStyle),this.columnElement.appendChild(r),this.addResizeHandle()}setWidth(t){this.columnElement.style.width=`${t}px`,this.context.store.getColumnManager().setColumnWidth(this.column.key,t)}addResizeHandle(){if(this.column.column.resizable===!1||this.context.store.getColumnManager().isLastColumn(this.column.key))return;const t=document.createElement("div");t.className="x-gantt-column-resize-handle",t.style.position="absolute",t.style.top="0",t.style.right="0",t.style.width="5px",t.style.height="100%",t.style.cursor="col-resize",t.style.zIndex="2",this.columnElement.appendChild(t);let e=0,s=0,n=null,r=0;const a=l=>{l.preventDefault(),l.stopPropagation(),e=l.clientX,s=this.columnElement.offsetWidth,n=this.root.getBoundingClientRect();const d=u=>o(u),p=u=>h(u,d,p);document.addEventListener("mousemove",d),document.addEventListener("mouseup",p),r=e-n.left,this.context.event.emit(V.SHOW_GUIDELINE,r)},o=l=>{if(l.preventDefault(),!n)return;const d=l.clientX-e,p=s+d,u=Math.max(50,p),g=e-n.left-s,f=this.root.clientWidth-20;let m=g+u;m=Math.min(f,m),this.context.event.emit(V.MOVE_GUIDELINE,m)},h=(l,d,p)=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p),this.context.event.emit(V.HIDE_GUIDELINE);const u=l.clientX-e,g=Math.max(50,s+u);this.setWidth(g)};t.addEventListener("mousedown",a)}}class ks{constructor(t,e,s,n){M(this,"groupElement"),M(this,"titleContainer"),M(this,"childContainer"),M(this,"children",[]),this.context=t,this.root=e,this.container=s,this.column=n,this.groupElement=document.createElement("div"),this.titleContainer=document.createElement("div"),this.childContainer=document.createElement("div"),this.initElement(),this.initChildren(),this.container.appendChild(this.groupElement)}initElement(){const t=this.context.getOptions().header.height/this.column.maxLevel;this.groupElement.className="x-gantt-table-header-group",(this.context.store.getColumnManager().isMultiHeader()||this.context.getOptions().border.show)&&this.groupElement.classList.add("border"),this.groupElement.style.display="flex",this.groupElement.style.flexShrink="0",this.groupElement.style.flexGrow="0",this.groupElement.style.flexDirection="column",this.groupElement.style.height="100%",this.groupElement.style.overflow="hidden",this.groupElement.style.boxSizing="border-box",this.titleContainer.className="x-gantt-table-header-cell",(this.context.store.getColumnManager().isMultiHeader()||this.context.getOptions().border.show)&&this.titleContainer.classList.add("border"),this.titleContainer.style.height=`${t}px`,this.titleContainer.style.flex="0 0 auto",this.titleContainer.style.display="flex",this.titleContainer.style.alignItems=this.context.getOptions().table.headerAlign,this.titleContainer.style.justifyContent="center",this.titleContainer.style.padding="0 8px",this.titleContainer.style.boxSizing="border-box",this.titleContainer.style.overflow="hidden",this.titleContainer.style.whiteSpace="nowrap",this.context.getOptions().table.ellipsis&&(this.titleContainer.style.textOverflow="ellipsis"),this.titleContainer.style.borderBottom=`1px solid ${this.context.getOptions().border.color}`,this.titleContainer.style.setProperty("border-color",this.context.getOptions().border.color,"important"),this.titleContainer.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,this.titleContainer.style.fontSize=oe(this.context.getOptions().header.fontSize),this.titleContainer.style.fontFamily=this.context.getOptions().header.fontFamily,this.titleContainer.style.setProperty("color",Ai(this.context.getOptions().header.color,this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor),"important"),this.titleContainer.textContent=this.column.label||"",this.childContainer.className="x-gantt-table-header-children",this.childContainer.style.flex="1 0 auto",this.childContainer.style.display="flex",this.childContainer.style.width="100%",this.groupElement.appendChild(this.titleContainer),this.groupElement.appendChild(this.childContainer)}initChildren(){this.column.children.forEach(t=>{if(t.isLeaf){const e=new os(this.context,this.root,this.childContainer,t);this.children.push(e)}else if(t.children.length>0){const e=new ks(this.context,this.root,this.childContainer,t);this.children.push(e)}})}}class Hf{constructor(t,e){M(this,"headerElement"),M(this,"headerColumns",[]),this.context=t,this.container=e,this.headerElement=document.createElement("div"),this.initElement(),this.container.appendChild(this.headerElement)}initElement(){this.headerElement.className="x-gantt-table-header",this.headerElement.style.display="flex",this.headerElement.style.height=`${this.context.getOptions().header.height}px`,this.headerElement.style.minHeight=`${Math.max(this.context.getOptions().header.height,30)}px`,this.headerElement.style.setProperty("background-color",this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,"important"),this.headerElement.style.setProperty("color",Ai(this.context.getOptions().header.color,this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor),"important"),this.headerElement.style.fontSize=`${this.context.getOptions().header.fontSize}px`,this.headerElement.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,this.headerElement.style.zIndex="10",this.headerElement.style.width="100%",this.headerElement.style.flexShrink="0",this.headerElement.style.borderBottom=`1px solid ${this.context.getOptions().border.color}`,this.headerElement.style.setProperty("border-color",this.context.getOptions().border.color,"important")}render(){this.headerColumns=[],this.headerElement.innerHTML="",this.initElement();const t=this.context.store.getColumnManager(),e=t.getColumns();if(t.getHandlerColumn().width!==0){const s=new os(this.context,this.headerElement,this.headerElement,t.getHandlerColumn());this.headerColumns.push(s)}e.forEach(s=>{if(s.isLeaf){const n=new os(this.context,this.headerElement,this.headerElement,s);this.headerColumns.push(n)}else if(s.children.length>0){const n=new ks(this.context,this.headerElement,this.headerElement,s);this.headerColumns.push(n)}})}}class $f{constructor(t,e){M(this,"tableContainer"),M(this,"tableHeader"),M(this,"tableBody"),M(this,"onUpdateTableHeader",()=>{this.tableHeader.render()}),M(this,"onUpdateTableBody",()=>{this.tableBody.update()}),this.context=t,this.container=e,this.tableContainer=document.createElement("div"),this.tableContainer.className="x-gantt-table-container",this.tableContainer.style.position="relative",this.tableContainer.style.width="100%",this.tableContainer.style.height="100%",this.tableContainer.style.overflow="hidden",this.tableContainer.style.display="flex",this.tableContainer.style.flexDirection="column",this.container.appendChild(this.tableContainer),this.tableHeader=new Hf(t,this.tableContainer),this.tableBody=new Nf(t,this.tableContainer),this.listenEvents()}render(t,e){this.tableHeader.render(),this.refresh(t,e)}refresh(t,e){this.tableBody.render(t,e)}updateWidth(){this.tableBody.updateWidth()}updateTask(t){this.tableBody.updateTask(t)}listenEvents(){this.context.event.on(V.UPDATE_TABLE_HEADER,this.onUpdateTableHeader),this.context.event.on(V.UPDATE_TABLE_BODY,this.onUpdateTableBody)}destroy(){this.context.event.off(V.UPDATE_TABLE_HEADER,this.onUpdateTableHeader),this.context.event.off(V.UPDATE_TABLE_BODY,this.onUpdateTableBody)}}const To=class Co{constructor(t,e){M(this,"background"),M(this,"headerGroups",[]),M(this,"separatorLines",[]),M(this,"cellCache",new Map),M(this,"renderedStartX",0),M(this,"renderedEndX",0),M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),this.context=t,this.layer=e,this.background=new Y.Rect({fill:this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,name:"header-background"}),this.layer.add(this.background),this.registerEvents()}resize(t){this.width=t;const e=this.context.store.getTimeAxis();this.height=e.getResolvedHeaderHeight(),this.background.width(t),this.background.height(this.height),this.render()}setOffset(t,e){if(this.offsetX===t)return;this.offsetX=t;for(const r of this.headerGroups)r.x(t);const s=-t,n=s+this.width;(s<this.renderedStartX||n>this.renderedEndX)&&this.renderCells(),this.layer.batchDraw()}registerEvents(){this.context.event.on(V.ROW_HIGHLIGHT,t=>{this.highlightDate(t)}),this.context.event.on(V.ROW_UNHIGHLIGHT,t=>{this.unhighlightDate(t)}),this.context.event.on(V.UPDATE_TASK,t=>{this.highlightDate(t.id)})}render(){this.buildStructure(),this.renderCells(),this.layer.moveToTop(),this.layer.batchDraw()}buildStructure(){this.clearHeader();const t=this.context.store.getTimeAxis(),e=t.getTimeline().length;if(e===0)return;const s=t.getLayerHeights(),n=this.context.getOptions().border.color,r=[];let a=0;for(let h=0;h<e;h++)r.push(a),a+=s[h]??0;for(let h=0;h<e;h++){const l=new Y.Group({name:`header-level-${h}`});this.headerGroups.push(l),this.layer.add(l),l.x(this.offsetX)}for(let h=1;h<e;h++){const l=new Y.Line({points:[0,r[h],this.width,r[h]],stroke:n,strokeWidth:1});this.layer.add(l),this.separatorLines.push(l)}const o=new Y.Line({points:[0,this.height,this.width,this.height],stroke:n,strokeWidth:1});this.layer.add(o),this.separatorLines.push(o)}renderCells(){const t=this.context.store.getTimeAxis(),e=t.getCellWidth(),s=t.getTimeline(),n=s.length;if(n===0)return;const r=t.getLayerHeights(),a=[];let o=0;for(let u=0;u<n;u++)a.push(o),o+=r[u]??0;const h=this.width*Co.BUFFER_FACTOR,l=Math.max(0,-this.offsetX-h),d=-this.offsetX+this.width+h,p=this.context.getOptions().border.color;for(const u of this.headerGroups)u.destroyChildren();this.cellCache.clear();for(let u=0;u<n;u++){const g=s[u],f=this.headerGroups[u],m=a[u],b=r[u]??0,S=u===n-1;let y=0;for(let c=0;c<g.items.length;c++){const v=g.items[c],x=v.span*e;if(y+x<l){y+=x;continue}if(y>d)break;const T=S?`cell-${v.date.format("YYYY-MM-DD-HH")}`:`group-${u}-${v.date.format("YYYY-MM-DD-HH")}`,O=this.createCell(T,y,m,x,b,v.hide?"transparent":p,v.hide?"":v.label);f.add(O),v.hide&&O.visible(!1),y+=x}}this.renderedStartX=l,this.renderedEndX=d}createCell(t,e,s,n,r,a,o){const h=new Y.Group;h.x(e),h.y(s);const l=new Y.Rect({id:t,x:0,y:0,width:n,height:r,fill:this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,name:"header-cell-bg"});h.add(l);let d=this.context.getOptions().header.fontSize;t.startsWith("cell-")&&(this.cellCache.set(t,l),d-=2);const p=new Y.Line({points:[n,0,n,r],stroke:a,strokeWidth:1,name:"header-cell-right-border"});h.add(p);const u=new Y.Text({x:0,y:0,width:n,height:r,text:o,fontSize:d,fontFamily:this.context.getOptions().header.fontFamily,fontStyle:`${this.context.getOptions().header.fontWeight}`,fill:Ai(this.context.getOptions().header.color,this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor),align:"center",verticalAlign:"middle",wrap:"none",ellipsis:!0,name:"header-cell-text"});return h.add(u),h}clearHeader(){for(const t of this.headerGroups)t.destroy();this.headerGroups=[],this.cellCache.clear();for(const t of this.separatorLines)t.destroy();this.separatorLines=[],this.renderedStartX=0,this.renderedEndX=0}destroy(){this.layer.destroy(),this.cellCache.clear()}highlightDate(t){const e=this.context.store.getDataManager().getTaskById(t);e&&e.startTime&&e.endTime&&this.handleHighlight("in",e)}unhighlightDate(t){const e=this.context.store.getDataManager().getTaskById(t);e&&e.startTime&&e.endTime&&this.handleHighlight("out",e)}handleHighlight(t,e){var s,n;if(!this.context.getOptions().highlight)return;const r=this.context.store.getTimeAxis().getBottomScale();if(r.unit!=="day"||r.step!==1)return;const a=this.cellCache.get(`cell-${(s=e==null?void 0:e.startTime)==null?void 0:s.format("YYYY-MM-DD-HH")}`),o=this.cellCache.get(`cell-${(n=e==null?void 0:e.endTime)==null?void 0:n.format("YYYY-MM-DD-HH")}`),h=this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor;h&&(this.cellCache.forEach(l=>{new Y.Tween({node:l,fill:h,duration:.02}).play()}),t==="in"&&(a&&new Y.Tween({node:a,fill:lt(h).brighten(30).toHex(),duration:.02}).play(),o&&new Y.Tween({node:o,fill:lt(h).brighten(30).toHex(),duration:0}).play()))}};M(To,"BUFFER_FACTOR",.3);let Bf=To;class Uf{constructor(t,e){M(this,"verticalLines"),M(this,"horizontalLines"),M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),M(this,"renderedColStart",-1),M(this,"renderedColEnd",-1),M(this,"renderedRowStart",-1),M(this,"renderedRowEnd",-1),this.context=t,this.layer=e,this.verticalLines=new Y.Group({name:"vertical-grid-lines"}),this.horizontalLines=new Y.Group({name:"horizontal-grid-lines"}),this.layer.add(this.verticalLines),this.layer.add(this.horizontalLines)}resize(t,e){this.width=t,this.height=e,this.clearGrid(),this.renderedColStart=-1,this.renderedColEnd=-1,this.renderedRowStart=-1,this.renderedRowEnd=-1,this.calculateGrid()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.verticalLines.x(t),this.horizontalLines.y(e);const s=this.context.store.getTimeAxis().getCellWidth(),n=this.context.getOptions().row.height,r=this.context.getOptions().header.height,a=Math.floor(-t/s),o=Math.ceil((-t+this.width)/s),h=Math.floor((-e+r)/n),l=Math.ceil((-e+this.height)/n);(a<this.renderedColStart||o>this.renderedColEnd||h<this.renderedRowStart||l>this.renderedRowEnd)&&this.calculateGrid(),this.layer.batchDraw()}render(){this.layer.batchDraw()}destroy(){this.layer.destroy()}calculateGrid(){this.clearGrid();const t=this.context.getOptions().header.height,e=this.width,s=this.context.store.getTimeAxis().getCellWidth(),n=this.context.getOptions().row.height,r=this.context.store.getDataManager().getVisibleSize(),a=r*n,o=Math.max(0,Math.floor(-this.offsetX/s)-2),h=Math.min(this.context.store.getTimeAxis().getCellCount(),Math.ceil((-this.offsetX+this.width)/s)+2),l=Math.max(0,Math.floor((-this.offsetY+t)/n)-2),d=Math.min(r,Math.ceil((-this.offsetY+this.height)/n)+2);if(this.renderedColStart=o,this.renderedColEnd=h,this.renderedRowStart=l,this.renderedRowEnd=d,this.context.getOptions().border.show&&this.context.getOptions().chart.showVerticalLine){const p=this.context.store.getTimeAxis().getTimeline();if(p.length>0){const u=p[p.length-1];let g=0;for(const f of u.items){const m=f.span*s;if(g+=m,g<-this.offsetX-s*2)continue;if(g>-this.offsetX+this.width+s*2)break;const b=new Y.Line({points:[g,t,g,a+t],stroke:this.context.getOptions().border.color,strokeWidth:.5,name:"vertical-grid-line"});this.verticalLines.add(b)}}}for(let p=l;p<=d;p++){const u=p*n+t,g=new Y.Line({points:[0,u,Math.max(this.width,e),u],stroke:this.context.getOptions().border.color,strokeWidth:.5,name:"horizontal-grid-line"});this.horizontalLines.add(g)}}clearGrid(){this.verticalLines.destroyChildren(),this.horizontalLines.destroyChildren()}}const yr='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15"><path fill="currentColor" fill-rule="evenodd" d="M5.5 4.625a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25m4 0a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25M10.625 7.5a1.125 1.125 0 1 1-2.25 0a1.125 1.125 0 0 1 2.25 0M5.5 8.625a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25m5.125 2.875a1.125 1.125 0 1 1-2.25 0a1.125 1.125 0 0 1 2.25 0M5.5 12.625a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25" clip-rule="evenodd"/></svg>';class Wf{constructor(t,e,s,n,r){M(this,"offsetX",0),M(this,"offsetY",0),M(this,"sliderGroup"),M(this,"slider"),M(this,"sliderBar",null),M(this,"sliderType",""),M(this,"leftHandleGroup",null),M(this,"rightHandleGroup",null),M(this,"progressGroup",null),M(this,"handlerWidth",10),M(this,"autoMoveTimer",null),M(this,"autoScrollTimer",null),M(this,"autoExpandTimer",null),M(this,"EDGE_THRESHOLD",20),M(this,"SCROLL_STEP",5),M(this,"MOVE_INTERVAL",1e3/60),M(this,"AUTO_EXPAND_INTERVAL",500),M(this,"isDragging",!1),M(this,"draggingDirection","none"),M(this,"dragDiffX",0),M(this,"oldTasks",[]),this.context=t,this.x=e,this.y=s,this.task=n,this.rowWidth=r,this.sliderGroup=new Y.Group({x:e,y:s,id:`chart-slider-bar-${n.id}`}),this.render(),this.bindEvents(),this.registerEvents()}update(t,e,s){this.task=s,this.x=t,this.y=e,this.sliderGroup.position({x:t,y:e}),this.render()}setOffset(t,e){this.offsetX=t,this.offsetY=e}unpackFunc(t){return this.context.store.getOptionManager().unpackFunc(t,this.task)}registerEvents(){this.context.event.on(V.SLIDER_BLINK,t=>{t===this.task.id&&this.handleBarBlink()})}render(){var t,e,s,n,r,a,o,h,l,d,p,u,g;if(!this.task.startTime||!this.task.endTime)return;if(this.task.endTime.isBefore(this.task.startTime)){Q.error("The endTime of the current task is earlier than the startTime.",this.task);return}const f=this.context.getOptions().row.height,m=mi(this.unpackFunc(this.context.getOptions().bar.height),f),b=(f-m)/2,S=this.context.store.getTimeAxis().getTimeLeft(this.task.startTime),y=this.context.store.getTimeAxis().getTimeLeft(this.task.endTime)-S,c=this.unpackFunc(this.context.getOptions().bar.backgroundColor)||this.context.getOptions().primaryColor,v=yi(this.unpackFunc(this.context.getOptions().bar.radius)),x=this.unpackFunc(this.context.getOptions().bar.shadowColor)||"rgba(0, 0, 0, 0.2)",T=this.unpackFunc(this.context.getOptions().bar.shadowBlur)||0,O=this.unpackFunc(this.context.getOptions().bar.shadowOffsetX)||0,_=this.unpackFunc(this.context.getOptions().bar.shadowOffsetY)||0;this.slider||(this.slider=new Y.Group({dragBoundFunc:k=>{let L=Math.min(0,-(-this.offsetX-this.slider.x())),F=this.context.store.getTimeAxis().getTimeLeft(this.context.store.getTimeAxis().getEndTime())+this.offsetX-this.slider.width();if(this.context.getOptions().bar.move.link.parent==="strict"&&this.task.parent){if(this.task.parent.startTime){const N=this.task.parent.startTime;L=this.context.store.getTimeAxis().getTimeLeft(N)}if(this.task.parent.endTime){const N=this.task.parent.endTime,P=this.context.store.getTimeAxis().getTimeLeft(N);F=Math.abs(P-this.slider.width())}}return{x:at(k.x,L,F),y:this.y+b+this.offsetY}}})),this.slider.position({x:S,y:b}),this.slider.size({width:y,height:m});const C=!!this.unpackFunc(this.context.getOptions().bar.move.enabled)&&(this.task.isSummary()?this.context.getOptions().summary.move.enabled:!0);if(this.slider.draggable(C),this.slider.on("mouseover",k=>{C&&!this.isDragging&&(k.target.getStage().container().style.cursor="grab"),this.handleBarHighlight({shadowColor:lt(x).alpha(lt(x).alpha()+.1).toHex(),shadowBlur:Math.max((T||1)*2,4),shadowOffsetX:Math.max(O||1,2),shadowOffsetY:Math.max((_||1)*1.5,4)}),this.context.event.emit(V.SLIDER_ENTER,k.evt,this.task)}),this.slider.on("mousemove",k=>{this.context.event.emit(V.SLIDER_HOVER,k.evt,this.task)}),this.slider.on("mouseout",k=>{C&&!this.isDragging&&(k.target.getStage().container().style.cursor="default"),this.isDragging||this.handleBarHighlight({shadowColor:x,shadowBlur:T,shadowOffsetX:O,shadowOffsetY:_}),this.context.event.emit(V.SLIDER_LEAVE,k.evt,this.task)}),this.task.isMilestone()){this.sliderBar&&!this.sliderType.startsWith("milestone")&&(this.slider.destroyChildren(),this.sliderBar=null,this.progressGroup=null,this.leftHandleGroup=null,this.rightHandleGroup=null);const k=this.unpackFunc(this.context.getOptions().milestone.size),L=Math.min(k||m,f/2),F=this.unpackFunc(this.context.getOptions().milestone.color)||c,N=this.unpackFunc(this.context.getOptions().milestone.border.color),P=this.unpackFunc(this.context.getOptions().milestone.border.width),A=this.unpackFunc(this.context.getOptions().milestone.shape);if(!this.sliderBar){switch(A){case"triangle":this.sliderBar=new Y.RegularPolygon({sides:3,radius:L,rotation:0,fill:F,stroke:N,strokeWidth:P,y:m/2});break;case"circle":this.sliderBar=new Y.Circle({radius:L,fill:F,stroke:N,strokeWidth:P,y:m/2});break;case"star":this.sliderBar=new Y.Star({numPoints:5,innerRadius:L/2,outerRadius:L,fill:F,stroke:N,strokeWidth:P,y:m/2});break;case"diamond":default:this.sliderBar=new Y.RegularPolygon({sides:4,radius:L,rotation:0,fill:F,stroke:N,strokeWidth:P,y:m/2})}if(this.slider.add(this.sliderBar),this.unpackFunc(this.context.getOptions().milestone.label.show)){const $=this.unpackFunc(this.context.getOptions().milestone.label.text),w=this.unpackFunc(this.context.getOptions().milestone.label.position),E=this.unpackFunc(this.context.getOptions().milestone.label.fontSize),R=this.unpackFunc(this.context.getOptions().milestone.label.fontFamily),D=this.unpackFunc(this.context.getOptions().milestone.label.color),G=new Y.Text({height:m,text:$,fill:D||F,fontSize:E,fontFamily:R}),B=G.measureSize($);G.width(B.width);const H={x:0,y:0};switch(w){case"top-left":H.x=-(12+B.width),H.y=-8;break;case"bottom-left":H.x=-(12+B.width),H.y=10;break;case"bottom-right":H.x=12,H.y=10;break;case"top-right":default:H.x=12,H.y=-8;break}G.setAttrs(H),this.slider.add(G)}}this.sliderType="milestone"}else if(this.task.isSummary()&&(this.context.getOptions().summary.mode==="always"||this.task.expanded)){this.sliderBar&&this.sliderType!=="summary"&&(this.slider.destroyChildren(),this.sliderBar=null,this.progressGroup=null,this.leftHandleGroup=null,this.rightHandleGroup=null);const k=this.unpackFunc(this.context.getOptions().summary.color)||c,L=f*.2,F=f*.3,N=P=>new Y.Shape({sceneFunc:(A,$)=>{const w=F*.5;A.beginPath(),A.moveTo(0,(f-L)/2),A.lineTo(w,(f-L)/2),A.lineTo(w,(f-L)/2+L),A.lineTo(0,(f-L)/2+L+F),A.lineTo(0,(f-L)/2),A.rect(w,(f-L)/2,P-2*w,L),A.moveTo(P-w,(f-L)/2),A.lineTo(P,(f-L)/2),A.lineTo(P,(f-L)/2+L+F),A.lineTo(P-w,(f-L)/2+L),A.lineTo(P-w,(f-L)/2),A.fillStrokeShape($)},width:P,fill:k,shadowColor:x,shadowBlur:T,shadowOffsetX:O,shadowOffsetY:_,y:-(F+L)/2-b/2});!this.sliderBar||this.sliderBar.width()!==y?(this.sliderBar&&this.sliderBar.destroy(),this.sliderBar=N(y),this.slider.add(this.sliderBar)):this.sliderBar.setAttrs({fill:k,shadowColor:x,shadowBlur:T,shadowOffsetX:O,shadowOffsetY:_}),this.sliderType="summary"}else{this.sliderBar&&this.sliderType!=="bar"&&(this.slider.destroyChildren(),this.sliderBar=null),this.sliderBar||(this.sliderBar=new Y.Rect({x:0,y:0}),this.slider.add(this.sliderBar),this.sliderType="bar"),this.sliderBar.setAttrs({width:y,height:m,fill:c,cornerRadius:v}),this.renderProgress(y,m);const k=(t=this.context.getOptions().bar.move.single)==null?void 0:t.icon,L=(e=this.context.getOptions().bar.move.single)==null?void 0:e.backgroundColor,F=L?lt(L).alpha(((s=this.context.getOptions().bar.move.single)==null?void 0:s.opacity)??1).toHex():lt(c).brighten(30*(this.unpackFunc((n=this.context.getOptions().bar.progress)==null?void 0:n.show)?-1:1)).alpha(((r=this.context.getOptions().bar.move.single)==null?void 0:r.opacity)??1).toHex();if(this.unpackFunc((a=this.context.getOptions().bar.move.single)==null?void 0:a.left)){if(!this.leftHandleGroup){this.leftHandleGroup=new Y.Group({x:0,y:0,opacity:0}),this.slider.add(this.leftHandleGroup),this.leftHandleGroup.on("mousedown",P=>{this.resizeMove(P,"left")}),this.leftHandleGroup.on("mouseover",P=>{setTimeout(()=>{P.target.getStage().container().style.cursor="ew-resize"},0)}),this.leftHandleGroup.on("mouseout",P=>{this.isDragging||(P.target.getStage().container().style.cursor="default")});const N=new Y.Rect({x:0,y:0});this.leftHandleGroup.add(N),k!==null&&fr(k||yr,this.handlerWidth,m).then(P=>{var A;const $=new Y.Image({image:P,x:0,y:(m-this.handlerWidth)/2,width:this.handlerWidth,height:this.handlerWidth});(A=this.leftHandleGroup)==null||A.add($)})}(o=this.leftHandleGroup.findOne("Rect"))==null||o.setAttrs({width:this.handlerWidth,height:m,fill:F,cornerRadius:[v[0],0,0,v[3]]}),(h=this.leftHandleGroup.findOne("Image"))==null||h.setAttrs({x:0,y:(m-this.handlerWidth)/2,width:this.handlerWidth,height:this.handlerWidth})}else this.leftHandleGroup&&(this.leftHandleGroup.remove(),this.leftHandleGroup=null);if(this.unpackFunc((l=this.context.getOptions().bar.move.single)==null?void 0:l.right)){if(!this.rightHandleGroup){this.rightHandleGroup=new Y.Group({x:0,y:0,opacity:0}),this.slider.add(this.rightHandleGroup),this.rightHandleGroup.on("mousedown",P=>{this.resizeMove(P,"right")}),this.rightHandleGroup.on("mouseover",P=>{setTimeout(()=>{P.target.getStage().container().style.cursor="ew-resize"},0)}),this.rightHandleGroup.on("mouseout",P=>{this.isDragging||(P.target.getStage().container().style.cursor="default")});const N=new Y.Rect({x:0,y:0});this.rightHandleGroup.add(N),k!==null&&fr(k||yr,this.handlerWidth,m).then(P=>{var A;const $=new Y.Image({image:P,x:y-this.handlerWidth,y:(m-this.handlerWidth)/2,width:this.handlerWidth,height:this.handlerWidth});(A=this.rightHandleGroup)==null||A.add($)})}(d=this.rightHandleGroup.findOne("Rect"))==null||d.setAttrs({x:y-this.handlerWidth,width:this.handlerWidth,height:m,fill:F,cornerRadius:[0,v[1],v[2],0]}),(p=this.rightHandleGroup.findOne("Image"))==null||p.setAttrs({x:y-this.handlerWidth,y:(m-this.handlerWidth)/2,width:this.handlerWidth,height:this.handlerWidth})}else this.rightHandleGroup&&(this.rightHandleGroup.remove(),this.rightHandleGroup=null);this.renderText(y,m),(u=this.leftHandleGroup)==null||u.moveToTop(),(g=this.rightHandleGroup)==null||g.moveToTop()}this.isDragging||this.sliderBar.setAttrs({shadowColor:x,shadowBlur:T,shadowOffsetX:O,shadowOffsetY:_}),this.sliderGroup.add(this.slider),this.unpackFunc(this.context.getOptions().bar.show)===!1?this.sliderGroup.hide():this.sliderGroup.show()}renderText(t,e){const s=`chart-slider-text-${this.task.id}`,n=()=>{this.slider.find(`#${s}`)&&this.slider.find(`#${s}`).forEach(h=>h.remove())};if(!this.context.getOptions().bar.field&&!this.context.getOptions().bar.label){n();return}const r=this.context.getOptions().bar.label;let a="";r?a=this.unpackFunc(r):this.context.getOptions().bar.field&&(a=this.task.getField(this.context.getOptions().bar.field)),n();const o=t-(this.leftHandleGroup?this.handlerWidth:0)-(this.rightHandleGroup?this.handlerWidth:0);if(o>20){const h=new Y.Text({id:s,x:this.leftHandleGroup?10:0,y:0,width:o,height:e,padding:10,text:a,fill:this.unpackFunc(this.context.getOptions().bar.color)||"#000",fontSize:this.unpackFunc(this.context.getOptions().bar.fontSize)||12,fontFamily:this.unpackFunc(this.context.getOptions().bar.fontFamily)||"Arial",align:this.unpackFunc(this.context.getOptions().bar.align),verticalAlign:this.unpackFunc(this.context.getOptions().bar.verticalAlign)||"middle",ellipsis:!0});this.slider.add(h)}}renderProgress(t,e){var s,n,r,a,o,h,l,d,p,u,g,f;if(!this.unpackFunc((s=this.context.getOptions().bar.progress)==null?void 0:s.show)){this.progressGroup&&(this.progressGroup.destroy(),this.progressGroup=null);return}if(this.task.progress){const m=Ku(this.task.progress,((n=this.context.getOptions().bar.progress)==null?void 0:n.targetVal)??100);if(m===0)return;const b=this.unpackFunc(this.context.getOptions().bar.backgroundColor)||this.context.getOptions().primaryColor,S=this.unpackFunc((r=this.context.getOptions().bar.progress)==null?void 0:r.backgroundColor)||lt(b).brighten(((a=this.context.getOptions().bar.progress)==null?void 0:a.amount)||30).toHex(),y=yi(this.unpackFunc(this.context.getOptions().bar.radius)),c=yi(this.unpackFunc((o=this.context.getOptions().bar.progress)==null?void 0:o.radius),2);c[0]=y[0],c[3]=y[3],m===1&&(c[1]=y[1],c[2]=y[2]);const v=t*m;this.progressGroup?(this.progressGroup.width(v),this.progressGroup.destroyChildren()):(this.progressGroup=new Y.Group({x:0,y:0,width:v,height:e,listening:!1}),this.slider.add(this.progressGroup));const x=new Y.Rect({x:0,y:0,width:v,height:e,fill:S,cornerRadius:c,opacity:this.unpackFunc((h=this.context.getOptions().bar.progress)==null?void 0:h.opacity)});this.progressGroup.add(x);const T=`${ns(m*100,(l=this.context.getOptions().bar.progress)==null?void 0:l.decimal)}%`,O=new Y.Text().measureSize(T).width,_=this.unpackFunc((d=this.context.getOptions().bar.progress)==null?void 0:d.textAlign),C=new Y.Text({x:0,y:_==="top"?-e:0,width:_==="right"?v+O:Math.max(v,O),height:e,fill:this.unpackFunc((p=this.context.getOptions().bar.progress)==null?void 0:p.color)||lt("#000000").mix(S,50).alpha(.7).toHex(),text:T,fontSize:this.unpackFunc((u=this.context.getOptions().bar.progress)==null?void 0:u.fontSize)||10,fontStyle:this.unpackFunc((g=this.context.getOptions().bar.progress)==null?void 0:g.fontStyle)||"italic",fontFamily:"Arial",verticalAlign:_==="top"?"bottom":"middle",align:"right"});(f=this.progressGroup)==null||f.add(C)}}bindEvents(){this.slider&&(this.slider.on("dragstart",t=>this.handleDragStart(t)),this.slider.on("dragend",t=>this.handleDragEnd(t)),this.slider.on("dragmove",t=>this.handleDragMove(t)),this.slider.on("mouseover",()=>this.handleMouseEnter()),this.slider.on("mouseout",()=>this.handleMouseLeave()),this.slider.on("mousedown",t=>{if(t.evt.button!==0)return;const e=t.target.getStage();e&&this.slider.draggable()&&(e.container().style.cursor="grabbing")}),this.slider.on("mouseup",t=>{if(t.evt.button!==0)return;const e=t.target.getStage();e&&this.slider.draggable()&&(e.container().style.cursor="grab")}),this.slider.on("click",t=>{t.evt.button===0&&(t.cancelBubble=!0,this.isDragging=!1,this.context.event.emit(V.SLIDER_CLICK,t.evt,this.task))}),this.slider.on("contextmenu",t=>{t.cancelBubble=!0,t.evt.stopPropagation(),t.evt.preventDefault(),this.context.event.emit(V.SLIDER_CONTEXTMENU,t.evt,this.task)}),this.slider.on("dblclick",t=>{t.evt.button===0&&(t.cancelBubble=!0,this.context.event.emit(V.SLIDER_DBL_CLICK,t.evt,this.task))}))}emitUpdate(t){let e=this.task.startTime.clone(),s=this.task.endTime.clone();t!=="right"&&(e=this.context.store.getTimeAxis().getTimeByLeft(this.slider.x())),t!=="left"&&(s=this.context.store.getTimeAxis().getTimeByLeft(this.slider.x()+this.slider.width())),(!(e!=null&&e.isSame(this.task.startTime))||!(s!=null&&s.isSame(this.task.endTime)))&&this.context.store.getDataManager().updateTaskTime(this.task,e,s,t,this.oldTasks)}handleDragStart(t){const e=t.target.getStage();if(!e)return;this.isDragging=!0,this.oldTasks=[],this.context.event.emit(V.SLIDER_DRAGGING,!0),e.container().style.cursor="grabbing";const s=t.target.x(),n=this.context.store.getTimeAxis().getCellWidth(),r=ji(s,n);this.dragDiffX=r-s,this.handleMove(t,e)}handleDragMove(t){if(this.isDragging&&(t.evt.movementX>0?this.draggingDirection!=="right"&&(this.draggingDirection="right",this.stopAutoScroll(),this.stopAutoExpand()):t.evt.movementX<0&&this.draggingDirection!=="left"&&(this.draggingDirection="left",this.stopAutoScroll(),this.stopAutoExpand()),!!this.context.getOptions().bar.move.byUnit)){const e=t.target.x(),s=this.context.store.getTimeAxis().getCellWidth(),n=ji(e,s);t.target.x(n-this.dragDiffX)}}handleDragEnd(t){this.stopAutoMove(),this.stopAutoScroll(),this.stopAutoExpand(),this.isDragging=!1,this.dragDiffX=0,this.draggingDirection="none",this.oldTasks.length>0&&(this.context.event.emit(V.TASK_DRAG_END,this.task,this.oldTasks),this.oldTasks=[]);const e=t.target.getStage();if(e){const s=e.getPointerPosition();if(s){const n=this.context.getOptions().row.height,r=this.y+this.offsetY,a=r+n;if(s.y<r||s.y>a){const o=this.unpackFunc(this.context.getOptions().bar.shadowColor)||"rgba(0, 0, 0, 0.2)",h=this.unpackFunc(this.context.getOptions().bar.shadowBlur)||0,l=this.unpackFunc(this.context.getOptions().bar.shadowOffsetX)||0,d=this.unpackFunc(this.context.getOptions().bar.shadowOffsetY)||0;this.handleBarHighlight({shadowColor:o,shadowBlur:h,shadowOffsetX:l,shadowOffsetY:d}),this.handleResizeHighlight(0),e.container().style.cursor="default"}}}this.context.event.emit(V.SLIDER_DRAGGING,!1)}handleMove(t,e){const s=e.width(),n=!!this.context.getOptions().bar.move.lock,r=!!this.context.getOptions().bar.move.byUnit,a=this.context.store.getTimeAxis().getCellWidth(),o=t.target.width(),h=t.target.x(),l=h+o,d=Math.max(0,-this.offsetX-h),p=Math.max(0,l-(-this.offsetX+s));this.autoMoveTimer=window.setInterval(()=>{const u=t.target.width(),g=t.target.x(),f=g+u,m=-this.offsetX,b=m+s,S=this.context.store.getTimeAxis().getTotalWidth(),y=g<=m+this.EDGE_THRESHOLD,c=f>=b-this.EDGE_THRESHOLD;if(this.draggingDirection==="left"&&y)if(m<=0)t.target.x(-d),this.stopAutoScroll(),n||this.startAutoExpand("left",-d);else{const v=r?-a:-this.SCROLL_STEP;this.startAutoScroll(v,r,()=>{t.target.x(t.target.x()+v)},()=>t.target.x(t.target.x()-d))}else if(this.draggingDirection==="right"&&c)if(b>=S)t.target.x(S-u+p),this.stopAutoScroll(),n||this.startAutoExpand("right",0,p);else{const v=r?a:this.SCROLL_STEP;this.startAutoScroll(v,r,()=>{t.target.x(t.target.x()+v)})}else this.stopAutoExpand(),this.stopAutoScroll();this.emitUpdate("both")},this.MOVE_INTERVAL)}resizeMove(t,e){var s;t.cancelBubble=!0;const n=t.target.getStage();if(!n)return;this.isDragging=!0,this.context.event.emit(V.SLIDER_DRAGGING,!0);let r=((s=n.getPointerPosition())==null?void 0:s.x)||0;const a=!!this.context.getOptions().bar.move.byUnit,o=this.context.store.getTimeAxis().getCellWidth(),h=!!this.context.getOptions().bar.move.lock,l=n.width();let d=0,p=0;this.autoMoveTimer=window.setInterval(()=>{const S=this.slider.width(),y=this.slider.x(),c=y+S,v=-this.offsetX,x=v+l,T=y<=v+this.EDGE_THRESHOLD,O=c>=x-this.EDGE_THRESHOLD;if(T&&e==="left"){if(v<=0)this.slider.x(0),this.stopAutoScroll(),h||(this.draggingDirection==="left"?this.startAutoExpand("left"):this.stopAutoExpand());else if(this.draggingDirection==="left"){const _=a?-o:-this.SCROLL_STEP;this.startAutoScroll(_,a,()=>{d+=_,this.slider.x(this.slider.x()+_)})}else this.stopAutoScroll();this.emitUpdate("left")}else if(O&&e==="right"){if(x>=this.context.store.getTimeAxis().getTotalWidth())this.slider.width(this.context.store.getTimeAxis().getTotalWidth()-this.slider.x()),this.stopAutoScroll(),h||(this.draggingDirection==="right"?this.startAutoExpand("right"):this.stopAutoExpand());else if(this.draggingDirection==="right"){const _=a?o:this.SCROLL_STEP;this.startAutoScroll(_,a,()=>{p+=_,this.slider.x(this.slider.x()+_)})}else this.stopAutoScroll();this.emitUpdate("right")}else if(e==="right"&&y<=v&&c<=v+this.EDGE_THRESHOLD+o){const _=a?-o:-this.SCROLL_STEP;this.startAutoScroll(_,a,()=>{p+=_,this.slider.width(Math.max(this.slider.width(),o)),this.slider.width()>o&&this.slider.x(this.slider.x()+_),this.emitUpdate("right")})}else if(e==="left"&&c>=x&&y>=x-this.EDGE_THRESHOLD-o){const _=a?o:this.SCROLL_STEP;this.startAutoScroll(_,a,()=>{d+=_,this.slider.width(Math.max(this.slider.width(),o)),this.slider.width()>o&&this.slider.x(this.slider.x()+_),this.emitUpdate("left")})}else this.stopAutoExpand(),this.stopAutoScroll()},this.MOVE_INTERVAL);let u;const g=this.slider.x(),f=this.slider.width(),m=S=>{var y;S.movementX>0?this.draggingDirection="right":S.movementX<0&&(this.draggingDirection="left");const c=Math.max(((y=n.getPointerPosition())==null?void 0:y.x)||0,0);let v=c-r;a&&(v=ji(v,o)),(u===void 0||u!==v)&&(e==="left"?f-v-d>=o&&c<l-this.EDGE_THRESHOLD&&(this.slider.width(f-v-d),this.slider.x(g+v+d),this.emitUpdate("left")):f+v+p>=o&&c>this.EDGE_THRESHOLD&&(this.slider.width(f+v+p),this.emitUpdate("right")),u=v)},b=()=>{this.handleDragEnd(t),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",b)}startAutoExpand(t,e=0,s=0){if(this.autoExpandTimer)return;const n=this.context.store.getTimeAxis();this.autoExpandTimer=window.setInterval(()=>{n.expand(t,1),this.context.event.emit(V.CHART_OFFSET_CHANGE),t==="left"&&this.slider.x(e)},this.AUTO_EXPAND_INTERVAL)}startAutoScroll(t,e,s,n){if(this.autoScrollTimer)return;const r=this.context.getScrollbar();r&&(n&&(n==null||n()),this.autoScrollTimer=window.setInterval(()=>{const a=r.getScrollPosition();r.scrollTo({x:a.x+t,y:a.y},"drag"),s==null||s()},e?300:this.MOVE_INTERVAL))}stopAutoMove(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=null)}stopAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}stopAutoExpand(){this.autoExpandTimer&&(clearInterval(this.autoExpandTimer),this.autoExpandTimer=null)}handleMouseEnter(){this.handleResizeHighlight(1)}handleMouseLeave(){this.isDragging||this.handleResizeHighlight(0)}handleResizeHighlight(t){this.leftHandleGroup&&new Y.Tween({node:this.leftHandleGroup,opacity:t,duration:.2}).play(),this.rightHandleGroup&&new Y.Tween({node:this.rightHandleGroup,opacity:t,duration:.2}).play()}handleBarHighlight(t){this.sliderBar&&new Y.Tween({...t,node:this.sliderBar,duration:.2}).play()}handleBarBlink(){if(!this.sliderGroup)return;const t=this.sliderGroup.opacity(),e=500,s=e*2,n=new Y.Animation(r=>{if(!this.sliderGroup||!r)return;const a=r.time;if(a>=s){this.sliderGroup.opacity(t),n.stop();return}const o=a%e/e;let h;o<.5?h=t*(1-o*2):h=t*((o-.5)*2),this.sliderGroup.opacity(Math.max(0,Math.min(t,h)))},this.sliderGroup.getLayer());n.start()}destroy(){this.stopAutoMove(),this.stopAutoScroll(),this.stopAutoExpand(),this.slider&&(this.slider.destroyChildren(),this.slider.destroy())}}class zf{constructor(t,e,s,n,r,a,o){M(this,"row"),M(this,"slider"),M(this,"cacheKey",""),this.context=t,this.task=e,this.width=a,this.height=o,this.row=new Y.Group;const h=new Y.Rect({x:n,y:r,width:a,height:o,id:s,listening:!1});this.row.add(h),this.slider=new Wf(this.context,0,r,this.task,this.width),this.row.add(this.slider.sliderGroup)}update(t,e,s){this.slider.update(t,e,s)}setOffset(t,e){this.slider.setOffset(t,e)}destroy(){this.slider.destroy(),this.row.destroy()}}class Vf{constructor(t,e,s,n){M(this,"tasks",[]),M(this,"rowsGroup"),M(this,"rowsCache",new Map),M(this,"rowBgGroup"),M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),M(this,"highlightedRowId",null),M(this,"highlightRect",null),M(this,"selectedRowId",null),M(this,"selectedRect",null),M(this,"boundHandleMouseMove"),M(this,"boundHandleMouseLeave"),M(this,"boundHandleClick"),M(this,"boundHandleDblClick"),M(this,"boundHandleContextMenu"),M(this,"onRowHighlight"),M(this,"onRowUnhighlight"),M(this,"onTaskSelected"),M(this,"onTaskUnselected"),this.context=t,this.stage=e,this.layer=s,this.bgLayer=n,this.rowsGroup=new Y.Group({name:"chart-body-rows"}),this.layer.add(this.rowsGroup),this.rowBgGroup=new Y.Group({name:"chart-body-row-bgs"}),this.bgLayer.add(this.rowBgGroup),this.boundHandleMouseMove=this.handleMouseMove.bind(this),this.boundHandleMouseLeave=this.handleMouseLeave.bind(this),this.boundHandleClick=this.handleClick.bind(this),this.boundHandleDblClick=this.handleDblClick.bind(this),this.boundHandleContextMenu=this.handleContextMenu.bind(this),this.onRowHighlight=r=>this.highlightRow(r),this.onRowUnhighlight=r=>this.unhighlightRow(r),this.onTaskSelected=r=>this.selectRow(r.id),this.onTaskUnselected=r=>this.unselectRow(r),this.registerEvents(),this.bindEvents()}resize(t,e){this.width=t,this.height=e}setOffset(t,e){const s=e-this.offsetY;this.offsetX=t,this.offsetY=e,this.rowsGroup.x(t),this.rowsGroup.y(e),this.updateHighlightPosition(s),this.updateSelectedPosition(s)}render(t){this.tasks=t;const e=this.context.getOptions().row.height,s=te();this.rowBgGroup.destroyChildren(),this.tasks.forEach((n,r)=>{const a=`chart-row-${n.id}`;let o=this.rowsCache.get(a);const h=n.flatIndex*e+this.context.getOptions().header.height;o?(o.update(0,h,n),o.setOffset(this.offsetX,this.offsetY)):(o=new zf(this.context,n,a,0,h,this.width,e),o.setOffset(this.offsetX,this.offsetY),this.rowsGroup.add(o.row),this.rowsCache.set(a,o)),o.cacheKey=s,this.context.store.getDataManager().isTaskSelected(n.id)&&this.selectRow(n.id);const l=new Y.Rect({x:0,y:h+this.offsetY,width:this.width,height:e,fill:this.context.store.getOptionManager().getRowBackgroundColor(n),id:`chart-row-bg-${n.id}`,listening:!1});this.rowBgGroup.add(l),this.rowBgGroup.moveToBottom()}),this.rowsCache.forEach((n,r)=>{n.cacheKey!==s&&(n.destroy(),this.rowsCache.delete(r))}),this.layer.batchDraw()}updateTask(t){const e=this.rowsCache.get(`chart-row-${t.id}`);e&&e.update(0,t.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height,t)}bindEvents(){this.stage.on("mousemove",this.boundHandleMouseMove),this.stage.on("mouseleave",this.boundHandleMouseLeave),this.stage.on("click",this.boundHandleClick),this.stage.on("dblclick",this.boundHandleDblClick),this.stage.on("contextmenu",this.boundHandleContextMenu)}registerEvents(){this.context.event.on(V.ROW_HIGHLIGHT,this.onRowHighlight),this.context.event.on(V.ROW_UNHIGHLIGHT,this.onRowUnhighlight),this.context.event.on(V.TASK_SELECTED,this.onTaskSelected),this.context.event.on(V.TASK_UNSELECTED,this.onTaskUnselected)}handleMouseMove(t){const e=this.stage.getPointerPosition();if(!e)return;const s=this.getTaskByPosition(e);this.highlightedRowId&&s&&s.id!==this.highlightedRowId&&this.context.event.emit(V.ROW_UNHIGHLIGHT,this.highlightedRowId),s&&this.context.event.emit(V.ROW_HIGHLIGHT,s.id)}handleMouseLeave(t){this.unhighlightRow()}handleClick(t){if(t.evt.button!==0)return;const e=this.stage.getPointerPosition();if(!e)return;const s=this.getTaskByPosition(e);if(s){this.context.store.getDataManager().isTaskSelected(s.id)||this.context.store.getDataManager().selectTask(s.id);const n=this.getTimeByPosition(e);this.context.event.emit(V.ROW_CLICK,t.evt,s,n)}}handleDblClick(t){if(t.evt.button!==0)return;const e=this.stage.getPointerPosition();if(!e)return;const s=this.getTaskByPosition(e);if(s){const n=this.getTimeByPosition(e);this.context.event.emit(V.ROW_DBL_CLICK,t.evt,s,n)}}handleContextMenu(t){if(t.evt.button!==2)return;t.evt.preventDefault(),t.cancelBubble=!0;const e=this.stage.getPointerPosition();if(!e)return;const s=this.getTaskByPosition(e);if(s){const n=this.getTimeByPosition(e);this.context.event.emit(V.ROW_CONTEXTMENU,t.evt,s,n)}}getTaskByPosition(t){const e=this.context.getOptions().header.height;if(t.y<=e)return null;const s=t.y-this.offsetY,n=Math.floor((s-e)/this.context.getOptions().row.height);return this.context.store.getDataManager().getVisibleTasks()[n]||null}getTimeByPosition(t){return this.context.store.getTimeAxis().getTimeByLeft(t.x-this.offsetX)}highlightRow(t){if(this.highlightedRowId===t||(this.highlightedRowId=t,!this.rowsCache.get(`chart-row-${t}`))||(this.highlightRect&&this.highlightRect.destroy(),this.selectedRowId===t))return;const e=this.context.store.getDataManager().getTaskById(t);if(e){const s=e.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.highlightRect=new Y.Rect({x:0,y:s+this.offsetY,width:this.width,height:this.context.getOptions().row.height,fill:lt(this.context.getOptions().row.hover.backgroundColor).alpha(this.context.getOptions().row.hover.opacity).toHex(),name:"highlight-rect"}),this.layer.add(this.highlightRect),this.highlightRect.moveToBottom(),this.layer.batchDraw()}}unhighlightRow(t){this.highlightedRowId===t&&(this.highlightedRowId=null,this.highlightRect&&(this.highlightRect.destroy(),this.highlightRect=null,this.layer.batchDraw()))}updateHighlightPosition(t){if(!this.highlightRect||this.highlightedRowId===null)return;const e=this.rowsCache.get(`chart-row-${this.highlightedRowId}`);if(!e){this.clearHighlight();return}if(t)this.highlightRect.y(this.highlightRect.y()+t);else{const s=this.context.store.getDataManager().getTaskById(e.task.id);if(!s){this.clearHighlight();return}const n=s.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.highlightRect.y(n+this.offsetY)}this.layer.batchDraw()}clearHighlight(){this.highlightRect&&(this.highlightRect.destroy(),this.highlightRect=null),this.highlightedRowId=null}selectRow(t){var e;if(this.selectedRowId=t,!this.rowsCache.get(`chart-row-${t}`))return;this.selectedRect&&this.selectedRect.destroy(),this.selectedRowId===this.highlightedRowId&&((e=this.highlightRect)==null||e.fill("transparent"));const s=this.context.store.getDataManager().getTaskById(t);if(!s)return;const n=s.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRect=new Y.Rect({x:0,y:n+this.offsetY,width:this.width,height:this.context.getOptions().row.height,fill:lt(this.context.getOptions().row.select.backgroundColor).alpha(this.context.getOptions().row.select.opacity).toHex(),name:"selected-rect"}),this.layer.add(this.selectedRect),this.selectedRect.moveToBottom(),this.layer.batchDraw()}unselectRow(t){this.selectedRowId===t&&(this.selectedRowId=null,this.selectedRect&&(this.selectedRect.destroy(),this.selectedRect=null,this.layer.batchDraw()))}updateSelectedPosition(t){if(!this.selectedRect||this.selectedRowId===null)return;const e=this.rowsCache.get(`chart-row-${this.selectedRowId}`);if(e)if(this.context.store.getDataManager().isTaskVisible(e.task)){const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRect.y(s+this.offsetY),this.layer.batchDraw()}else this.selectedRect.destroy(),this.selectedRect=null,this.selectedRowId=null}destroy(){this.stage.off("mousemove",this.boundHandleMouseMove),this.stage.off("mouseleave",this.boundHandleMouseLeave),this.stage.off("click",this.boundHandleClick),this.stage.off("dblclick",this.boundHandleDblClick),this.stage.off("contextmenu",this.boundHandleContextMenu),this.context.event.off(V.ROW_HIGHLIGHT,this.onRowHighlight),this.context.event.off(V.ROW_UNHIGHLIGHT,this.onRowUnhighlight),this.context.event.off(V.TASK_SELECTED,this.onTaskSelected),this.context.event.off(V.TASK_UNSELECTED,this.onTaskUnselected),this.clearHighlight(),this.unselectRow(this.selectedRowId??void 0),this.rowsCache.forEach(t=>t.destroy()),this.rowsCache.clear(),this.rowsGroup.destroy(),this.rowBgGroup.destroy()}}class ko{constructor(){}static async createPattern(t){if(!(t!=null&&t.pattern))return null;const e=t.patternOptions||{};switch(e.color=e.color||t.backgroundColor,t.pattern){case"stripe":return this.createStripePattern(e);case"dot":return this.createDotPattern(e);case"grid":return this.createGridPattern(e);case"custom":if(e.image){const s=new Image;return s.src=e.image,new Promise(n=>{s.onload=()=>n(s)})}return null;default:return null}}static createStripePattern(t){const{color:e=(t==null?void 0:t.color)||"#c9c9c9",width:s=(t==null?void 0:t.width)||1,angle:n=(t==null?void 0:t.angle)??30,spacing:r=(t==null?void 0:t.spacing)||10}=t||{},a=n%180,o=a*Math.PI/180;let h,l;a===0?(h=r,l=s+r):a===90?(h=s+r,l=r):(h=Math.abs(Math.ceil((s+r)/Math.sin(o))),l=Math.abs(Math.ceil((s+r)/Math.cos(o))));const d=new Y.Stage({container:document.createElement("div"),width:h,height:l}),p=new Y.Layer;d.add(p);const u=new Y.Group;if(a===0||a===90){const f=new Y.Line({points:[0,0,a===0?h:0,a===0?0:l],stroke:e,strokeWidth:s,perfectDrawEnabled:!0});u.add(f)}else for(let f=-h;f<h*2;f+=h){const m=f+s/2,b=0,S=f+s/2+(Math.cos(o)<0?-h:h),y=l,c=new Y.Line({points:[Math.ceil(m),Math.ceil(b),Math.ceil(S),Math.ceil(y)],stroke:e,strokeWidth:s,perfectDrawEnabled:!0,lineCap:"square",lineJoin:"miter"});u.add(c)}p.add(u),p.draw();const g=new Image;return g.src=d.toDataURL(),d.destroy(),g}static createDotPattern(t){const{color:e=(t==null?void 0:t.color)||"#f9f9f9",width:s=(t==null?void 0:t.width)||2,spacing:n=(t==null?void 0:t.spacing)||4}=t||{},r=s*2+n*2,a=r,o=lt(e),h=new Y.Stage({container:document.createElement("div"),width:r,height:a}),l=new Y.Layer;h.add(l),[{x:n/2+s/2,y:n/2+s/2},{x:r-n/2-s/2,y:n/2+s/2},{x:n/2+s/2,y:a-n/2-s/2},{x:r-n/2-s/2,y:a-n/2-s/2}].forEach(p=>{const u=new Y.Circle({x:p.x,y:p.y,radius:s/2,fill:o.toString()});l.add(u)}),l.draw();const d=new Image;return d.src=h.toDataURL(),h.destroy(),d}static createGridPattern(t){const{color:e=(t==null?void 0:t.color)||"#f9f9f9",width:s=(t==null?void 0:t.width)||1,spacing:n=(t==null?void 0:t.spacing)||20}=t||{},r=s+n,a=r,o=r,h=new Y.Stage({container:document.createElement("div"),width:a,height:o}),l=new Y.Layer;h.add(l);const d=new Y.Group;d.add(new Y.Line({points:[0,0,a,o],stroke:e,strokeWidth:s,perfectDrawEnabled:!0})),d.add(new Y.Line({points:[0,o,a,0],stroke:e,strokeWidth:s,perfectDrawEnabled:!0})),l.add(d),l.draw();const p=new Image;return p.src=h.toDataURL(),h.destroy(),p}}class Yf{constructor(t,e){M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),M(this,"weekendGroup"),M(this,"patternImage",null),M(this,"renderVersion",0),this.context=t,this.layer=e,this.weekendGroup=new Y.Group,this.layer.add(this.weekendGroup)}isWeekend(t){return t.day()===6||t.day()===0}resize(t,e){this.width=t,this.height=e,this.calculateWeekend()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.weekendGroup.x(t),this.weekendGroup.y(e),this.calculateWeekend()}render(){this.layer.batchDraw()}destroy(){this.weekendGroup.destroy(),this.patternImage=null}clearWeekend(){this.weekendGroup.destroyChildren()}async calculateWeekend(){const t=++this.renderVersion;if(this.clearWeekend(),!this.context.getOptions().weekend.show)return;const e=this.context.store.getTimeAxis().getStartTime(),s=this.context.store.getTimeAxis().getEndTime(),n=this.context.store.getTimeAxis().getCellUnit(),r=this.context.store.getTimeAxis().getCellWidth(),a=this.context.getOptions().header.height,o=this.context.getOptions().row.height,h=this.context.store.getDataManager().getVisibleSize()*o,l=Math.max(0,-this.offsetX),d=l+this.width;for(let p=e;p<=s;){let u=r;if(u=r*2*(n==="day"?1:24),this.isWeekend(p)){const g=this.context.store.getTimeAxis().getTimeLeft(p),f=a,m=h;if(g+u<l){p=p.add(2,"day");continue}if(g>d)break;if(!this.patternImage&&this.context.getOptions().weekend.pattern&&(this.patternImage=await ko.createPattern(this.context.getOptions().weekend),t!==this.renderVersion))return;const b=new Y.Rect({name:"weekend-rect",x:g,y:f,width:u,height:m,...this.patternImage?{fillPatternImage:this.patternImage,fillPatternRepeat:"repeat",fillPatternOffset:{x:0,y:0},fillPatternScale:{x:1,y:1}}:{fill:this.context.getOptions().weekend.backgroundColor||"#c9c9c9"},opacity:this.context.getOptions().weekend.opacity});this.weekendGroup.add(b),p=p.add(2,"day")}else p=p.add(1,"day")}this.layer.batchDraw()}}class jf{constructor(t,e,s){M(this,"arrowAnimation"),M(this,"todayLine"),M(this,"todayTextGroup"),M(this,"triangle"),M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),this.context=t,this.bgLayer=e,this.headerLayer=s}resize(t,e){this.width=t,this.height=e,this.render()}setOffset(t,e){t!==this.offsetX&&(this.offsetX=t,this.render())}render(){var t,e,s,n,r,a,o;const h=Object.assign({show:!0,type:"line",backgroundColor:lt("lightblue").toHex(),opacity:1,width:1},this.context.getOptions().today||{});if(!h.show)return;let l=et();const d=this.context.store.getTimeAxis().getCellUnit();h.type==="block"&&(l=l.startOf(d));const p=this.context.store.getTimeAxis().getTimeLeft(l),u=this.context.store.getTimeAxis().getCellWidth(),g=this.context.getOptions().header.height,f=lt(h.backgroundColor).alpha(h.opacity).toHex(),m=(h.type==="block"?p+u/2:p)+this.offsetX,b=[m,g,m,this.height],S=h.type==="line"?h.width:u;if(this.todayLine?(this.todayLine.points(b),this.todayLine.stroke(f),this.todayLine.strokeWidth(S)):(this.todayLine=new Y.Line({points:b,stroke:f,strokeWidth:S}),this.bgLayer.add(this.todayLine)),(t=this.context.getOptions().today.text)!=null&&t.show){const y=((e=this.context.getOptions().today.text)==null?void 0:e.fontSize)||10,c=((s=this.context.getOptions().today.text)==null?void 0:s.fontFamily)||"Arial",v=((n=this.context.getOptions().today.text)==null?void 0:n.content)||"今天",x=new Y.Text({fontSize:y,fontFamily:c}).measureSize(v),T=((r=this.context.getOptions().today.text)==null?void 0:r.color)||"white",O=((a=this.context.getOptions().today.text)==null?void 0:a.backgroundColor)||f;if(!this.todayTextGroup)this.todayTextGroup=new Y.Group({x:p+this.offsetX+S,y:g,opacity:(o=this.context.getOptions().today.text)==null?void 0:o.opacity}),this.todayTextGroup.add(new Y.Rect({x:0,y:0,width:x.width+12,height:x.height+8,fill:O,cornerRadius:0,name:"today-text-bg"})),this.todayTextGroup.add(new Y.Text({x:0,y:0,text:v,fontSize:y,fontFamily:c,padding:5,fill:T,align:"center",verticalAlign:"middle",name:"today-text"})),this.bgLayer.add(this.todayTextGroup);else{this.todayTextGroup.x(p+this.offsetX+S);const _=this.todayTextGroup.findOne(".today-text");_==null||_.setAttrs({text:v,fill:T,fontSize:y,fontFamily:c,padding:5});const C=this.todayTextGroup.findOne(".today-text-bg");C==null||C.setAttrs({width:x.width+12,height:x.height+8,fill:O})}}else this.todayTextGroup&&(this.todayTextGroup.destroy(),this.todayTextGroup=void 0);h.type==="line"&&(this.triangle?(this.triangle.x(m),this.triangle.fill(f)):(this.triangle=new Y.RegularPolygon({x:m,y:g-8,sides:3,radius:8,fill:f,rotation:180,name:"today-triangle"}),this.arrowAnimation=new Y.Animation(y=>{var c;const v=Math.sin(y.time*4*Math.PI/2e3)+g-8;(c=this.triangle)==null||c.y(v)},this.headerLayer),this.headerLayer.add(this.triangle),this.triangle.moveToTop(),this.arrowAnimation.start())),this.bgLayer.batchDraw()}destroy(){var t,e,s,n;(t=this.todayLine)==null||t.destroy(),(e=this.triangle)==null||e.destroy(),(s=this.todayTextGroup)==null||s.destroy(),(n=this.arrowAnimation)==null||n.stop(),this.arrowAnimation=void 0}}class Kf{constructor(t,e){M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),M(this,"holidayGroup"),M(this,"patternImage",new WeakMap),M(this,"renderVersion",0),this.context=t,this.layer=e,this.holidayGroup=new Y.Group,this.layer.add(this.holidayGroup)}resize(t,e){this.width=t,this.height=e,this.calculateHoliday()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.holidayGroup.x(t),this.calculateHoliday()}render(){this.layer.batchDraw()}destroy(){this.holidayGroup.destroy()}clearHoliday(){this.holidayGroup.destroyChildren()}async calculateHoliday(){var t,e,s,n,r,a,o,h;const l=++this.renderVersion;if(this.clearHoliday(),!this.context.getOptions().holiday.show)return;const d=this.context.getOptions().holiday.holidays;if(!d||d.length===0)return;const p=Math.max(0,-this.offsetX),u=p+this.width,g=this.context.store.getTimeAxis().getStartTime(),f=this.context.store.getTimeAxis().getEndTime();this.context.store.getTimeAxis().getCellUnit();const m=this.context.store.getTimeAxis().getCellWidth(),b=this.context.getOptions().header.height,S=this.context.getOptions().row.height,y=this.context.store.getDataManager().getVisibleSize()*S;for(let c=g;c<=f;c=c.add(1,"day")){const v=d.find(x=>{if(ft(x.date)){if(x.date.some(T=>et(T).isSame(c,"day")))return x}else if(et(x.date).isSame(c,"day"))return x});if(v){const x=this.context.store.getTimeAxis().getTimeLeft(c),T=b,O=y;if(x+m<p)continue;if(x>u)break;if(!this.patternImage.has(v)&&(v.pattern||this.context.getOptions().holiday.pattern)&&(this.patternImage.set(v,await ko.createPattern({backgroundColor:this.context.getOptions().primaryColor,...v,...this.context.getOptions().holiday})),l!==this.renderVersion))return;const _=new Y.Rect({name:"holiday-rect",x,y:T,width:m,height:O,...this.patternImage.get(v)?{fillPatternImage:this.patternImage.get(v)??void 0,fillPatternRepeat:"repeat",fillPatternOffset:{x:0,y:0},fillPatternScale:{x:1,y:1},opacity:v.opacity||this.context.getOptions().holiday.opacity}:{fill:v.backgroundColor||this.context.getOptions().holiday.backgroundColor||this.context.getOptions().primaryColor,opacity:v.opacity||this.context.getOptions().holiday.opacity}});if(this.holidayGroup.add(_),(t=v.text)!=null&&t.show){if(ft(v.date)&&!et(v.date[0]).isSame(c,"day"))continue;const C=((e=v.text)==null?void 0:e.fontSize)||10,k=((s=v.text)==null?void 0:s.fontFamily)||"Arial",L=((n=v.text)==null?void 0:n.content)||"",F=new Y.Text({fontSize:C,fontFamily:k}).measureSize(L),N=((r=v.text)==null?void 0:r.color)||"white",P=((a=v.text)==null?void 0:a.backgroundColor)||v.backgroundColor||((o=this.context.getOptions().holiday)==null?void 0:o.backgroundColor)||this.context.getOptions().primaryColor,A=new Y.Group({name:"holiday-text-group",x,y:T,opacity:(h=v.text)==null?void 0:h.opacity}),$=new Y.Text({text:L,fill:N,fontSize:C,fontFamily:k,padding:5}),w=new Y.Rect({x:0,y:0,width:F.width+12,height:F.height+8,fill:P});A.add(w),A.add($),this.holidayGroup.add(A)}}}this.layer.batchDraw()}}class Xf{constructor(t,e){M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),M(this,"flagGroup"),this.context=t,this.layer=e,this.flagGroup=new Y.Group,this.layer.add(this.flagGroup)}resize(t,e){this.width=t,this.height=e,this.calculateFlag()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.flagGroup.x(t),this.calculateFlag()}render(){this.layer.batchDraw()}destroy(){this.flagGroup.destroy()}clearFlag(){this.flagGroup.destroyChildren()}async calculateFlag(){var t,e,s,n,r,a,o;if(this.clearFlag(),!((t=this.context.getOptions().flag)!=null&&t.show))return;const h=(e=this.context.getOptions().flag)==null?void 0:e.data;if(!h||h.length===0)return;const l=((s=this.context.getOptions().flag)==null?void 0:s.backgroundColor)||this.context.getOptions().primaryColor,d=((n=this.context.getOptions().flag)==null?void 0:n.opacity)||1,p=((r=this.context.getOptions().flag)==null?void 0:r.color)||(lt(l).isDark()?"white":"black"),u=((a=this.context.getOptions().flag)==null?void 0:a.fontFamily)||"Arial",g=((o=this.context.getOptions().flag)==null?void 0:o.fontSize)||10,f=Math.max(0,-this.offsetX),m=f+this.width,b=this.context.store.getTimeAxis().getCellWidth(),S=this.context.getOptions().header.height;this.context.getOptions().row.height,this.context.store.getDataManager().getVisibleSize(),h.forEach(y=>{const c=et(y.date),v=this.context.store.getTimeAxis().getTimeLeft(c),x=S;if(v+b<f||v>m)return;const T=[v,S,v,this.height],O=new Y.Line({points:T,stroke:y.backgroundColor||l,opacity:y.opacity||d,strokeWidth:1});this.flagGroup.add(O);const _=y.content||"";if(_){const C=new Y.Text({text:_,x:v+5,y:x+5,fontSize:g,fontFamily:u,fill:y.color||p,verticalAlign:"middle",align:"left"}),k=new Y.Rect({x:v,y:x,width:C.measureSize(_).width+12,height:C.measureSize(_).height+8,fill:y.backgroundColor||l});this.flagGroup.add(k),this.flagGroup.add(C)}else if(y.flag)switch(y.flag){case"banner":this.flagGroup.add(new Y.Rect({x:v,y:x,width:20,height:10,fill:y.backgroundColor||l,opacity:y.opacity||d}));break;case"pennant":this.flagGroup.add(new Y.Line({points:[v,x,v+20,x+5,v,x+10],fill:y.backgroundColor||l,opacity:y.opacity||d,closed:!0}));break;case"tag":this.flagGroup.add(new Y.Line({points:[v,x,v+20,x,v+15,x+5,v+20,x+10,v,x+10],fill:y.backgroundColor||l,opacity:y.opacity||d,closed:!0}));break;case"wedge":this.flagGroup.add(new Y.Line({points:[v,x,v+20,x,v+25,x+5,v+20,x+10,v,x+10],fill:y.backgroundColor||l,opacity:y.opacity||d,closed:!0}));break;case"ribbon":this.flagGroup.add(new Y.Line({points:[v,x,v+15,x+2,v+20,x,v+20,x+10,v+15,x+12,v,x+10],fill:y.backgroundColor||l,opacity:y.opacity||d,closed:!0,tension:.1}));break}}),this.layer.batchDraw()}}class qf{constructor(t,e,s){M(this,"tasks",[]),M(this,"pointGroup"),M(this,"linksGroup"),M(this,"templateArrow"),M(this,"linkCache",new Map),M(this,"isDragging",!1),M(this,"isSliderMoving",!1),M(this,"selectedMap",new Map),M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),this.context=t,this.stage=e,this.layer=s,this.linksGroup=new Y.Group({name:"links-group"}),this.pointGroup=new Y.Group({name:"point-group"}),this.templateArrow=new Y.Arrow({points:[],stroke:this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:this.context.getOptions().links.width,pointerLength:this.context.getOptions().links.arrow.height,pointerWidth:this.context.getOptions().links.arrow.width,fill:this.context.getOptions().links.arrow.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:this.context.getOptions().links.dash,opacity:.4}),this.templateArrow.visible(!1),this.layer.add(this.linksGroup),this.layer.add(this.pointGroup),this.layer.add(this.templateArrow),this.registerEvents()}registerEvents(){this.context.event.on(V.ROW_HIGHLIGHT,t=>{this.highlightPoint(t)}),this.context.event.on(V.ROW_UNHIGHLIGHT,t=>{this.unhighlightPoint(t)}),this.context.event.on(V.SLIDER_DRAGGING,t=>{this.isSliderMoving=t})}resize(t,e){this.width=t,this.height=e}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.linksGroup.x(t),this.linksGroup.y(e),this.pointGroup.x(t),this.pointGroup.y(e),this.templateArrow.x(t),this.templateArrow.y(e)}updateTask(t){this.calculateLinks([t]),this.calculatePoints(t)}render(t){this.tasks=t,this.calculateLinks(),this.calculatePoints()}destroy(){this.linksGroup.destroy(),this.pointGroup.destroy(),this.templateArrow.destroy(),this.selectedMap.clear(),this.linkCache.clear()}calculatePoints(t){var e,s;if(!this.context.getOptions().links.show||!this.context.getOptions().links.create.enabled){this.pointGroup.destroyChildren();return}t?((e=this.pointGroup.findOne(`#point-${t.id}-left`))==null||e.destroy(),(s=this.pointGroup.findOne(`#point-${t.id}-right`))==null||s.destroy()):this.pointGroup.destroyChildren();const n=this.context.getOptions().header.height,r=this.context.getOptions().row.height,a=r/2+n,o=this.context.getOptions().links.create.radius,h=this.context.getOptions().links.create.mode==="always"?.5:0,l=this.context.getOptions().links.create.color||this.context.getOptions().primaryColor,d=lt(l).alpha(this.context.getOptions().links.create.opacity??1).toHex(),p=this.context.getOptions().links.create.width;this.tasks.forEach(u=>{if(!(t&&u.id!==t.id)&&this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.show,u)&&u.startTime&&u.endTime){const g=this.context.store.getTimeAxis().getTimeLeft(u.startTime),f=this.context.store.getTimeAxis().getTimeLeft(u.endTime);let m=this.context.getOptions().links.gap;u.isMilestone()&&(m+=r/2);const b=a+r*u.flatIndex;let S=!0,y=!0,c=this.context.store.getOptionManager().unpackFunc(this.context.getOptions().links.create.from,u);if(Gi(c)?S=y=c:Ft(c)&&(S=c==="S",y=c==="F"),S){const v=new Y.Circle({id:`point-${u.id}-left`,x:g-m,y:b,radius:o,opacity:h,stroke:d,strokeWidth:p});this.pointGroup.add(v),v.on("mousedown",x=>{this.isDragging=!0,this.createLink(x,"S",l,[g-m,b],u.id)}),v.on("mouseover",x=>{this.isSliderMoving||(this.stage.container().style.cursor="pointer")}),v.on("mouseout",x=>{this.isDragging||this.isSliderMoving||(this.stage.container().style.cursor="default")})}if(y){const v=new Y.Circle({id:`point-${u.id}-right`,x:f+m,y:b,radius:o,opacity:h,stroke:d,strokeWidth:p});this.pointGroup.add(v),v.on("mousedown",x=>{this.isDragging=!0,this.createLink(x,"F",l,[f+m,b],u.id)}),v.on("mouseover",x=>{this.isSliderMoving||(this.stage.container().style.cursor="pointer")}),v.on("mouseout",x=>{this.isDragging||this.isSliderMoving||(this.stage.container().style.cursor="default")})}}})}calculateLinks(t){if(!this.context.getOptions().links.show){this.linksGroup.destroyChildren(),this.linkCache.clear();return}if(this.tasks.length===0){this.linksGroup.destroyChildren(),this.linkCache.clear();return}const e=t!=null&&t.length?t.reduce((n,r)=>(n.push(...this.context.store.getLinkManager().getLinksByTaskId(r.id)),n),[]):this.context.store.getLinkManager().getLinks();t!=null&&t.length&&e.forEach(n=>{const r=this.createId(n),a=this.linkCache.get(r);a==null||a.destroy(),this.linkCache.delete(r)});const s=te();e.forEach(n=>{var r,a,o,h,l,d,p,u;if(n.valid===!1)return;const g=this.createId(n),f=this.context.store.getDataManager().getTaskById(n.from),m=this.context.store.getDataManager().getTaskById(n.to);if(!f){Q.warn(`No corresponding FROM task [${n.from}] was found for the link. Info:`,n),n.valid=!1;return}if(!m){Q.warn(`No corresponding TO task [${n.to}] was found for the link. Info:`,n),n.valid=!1;return}if(!this.context.store.getDataManager().isTaskVisible(f)||!this.context.store.getDataManager().isTaskVisible(m)||f.flatIndex<this.tasks[0].flatIndex&&m.flatIndex<this.tasks[0].flatIndex||f.flatIndex>this.tasks[this.tasks.length-1].flatIndex&&m.flatIndex>this.tasks[this.tasks.length-1].flatIndex)return;const b=Math.max(0,-this.offsetX),S=b+this.width;if(!(this.context.store.getTimeAxis().getTimeLeft(((r=n.type)==null?void 0:r[0])==="S"?f.startTime:f.endTime)<b&&this.context.store.getTimeAxis().getTimeLeft(((a=n.type)==null?void 0:a[1])==="F"?m.endTime:m.startTime)<b)&&!(this.context.store.getTimeAxis().getTimeLeft(((o=n.type)==null?void 0:o[0])==="S"?f.startTime:f.endTime)>S&&this.context.store.getTimeAxis().getTimeLeft(((h=n.type)==null?void 0:h[1])==="F"?m.endTime:m.startTime)>S)&&this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.show,f)&&this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.show,m)){const y=this.getPoints(f,m,n);if(y.length<=2)Q.warn("The link position has some error.",n);else{const c=n.radius??this.context.getOptions().links.radius,v=((l=n.arrow)==null?void 0:l.width)??this.context.getOptions().links.arrow.width,x=((d=n.arrow)==null?void 0:d.height)??this.context.getOptions().links.arrow.height,T=n.width??this.context.getOptions().links.width;let O=this.linkCache.get(g);O===void 0&&(O=new Y.Group({id:g})),t!=null&&t.length||(O._=s);const _=O.findOne("Circle");if(_)_.radius(c),_.fill(n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor),_.x(y[0]),_.y(y[1]);else{const A=new Y.Circle({radius:c,fill:n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,x:y[0],y:y[1]});O.add(A)}const C=Math.floor(y.length/2),k=C%2===0?C:C-1,L=y.slice(0,k+2),F=y.slice(k),N=O.findOne("Line");if(N)N.points(L),N.stroke(n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor),N.strokeWidth(T+(this.selectedMap.has(g)?2:0)),N.dash(n.dash||this.context.getOptions().links.dash);else{const A=new Y.Line({points:L,stroke:n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:T,lineCap:"round",lineJoin:"round",dash:n.dash||this.context.getOptions().links.dash,hitStrokeWidth:10,draggable:!0,dragBoundFunc:$=>({x:0,y:0})});O.add(A),A.on("dragstart",$=>{this.handleDrag($,n,"S",[y[y.length-2],y[y.length-1]],g)})}const P=O.findOne("Arrow");if(P)P.points(F),P.stroke(n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor),P.strokeWidth(T+(this.selectedMap.has(g)?2:0)),P.pointerLength(x),P.pointerWidth(v),P.fill(((p=n.arrow)==null?void 0:p.color)||this.context.getOptions().links.arrow.color||n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor),P.lineJoin("round"),P.dash(n.dash||this.context.getOptions().links.dash);else{const A=new Y.Arrow({points:F,stroke:n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:T,pointerLength:x,pointerWidth:v,fill:((u=n.arrow)==null?void 0:u.color)||this.context.getOptions().links.arrow.color||n.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:n.dash||this.context.getOptions().links.dash,hitStrokeWidth:10,draggable:!0,dragBoundFunc:$=>({x:0,y:0})});O.add(A),A.on("dragstart",$=>{this.handleDrag($,n,"F",[y[0],y[1]],g)})}this.linkCache.has(g)||(this.linksGroup.add(O),O.on("mouseover",A=>{A.target.moveToTop(),this.context.getOptions().links.move.enabled===!0&&(this.stage.container().style.cursor="pointer"),this.selectedMap.has(g)||this.handleHighlight(O,c,v,x,T,2)}),O.on("mouseout",A=>{this.selectedMap.has(g)||this.handleHighlight(O,c,v,x,T,0),!this.isDragging&&(this.stage.container().style.cursor="default")}),O.on("mousedown",A=>{this.isDragging=!0}),O.on("click",A=>{A.cancelBubble=!0,this.isDragging=!1,O.moveToTop(),A.evt.button===0&&(this.selectedMap.has(g)?(this.selectedMap.delete(g),this.context.event.emit(V.SELECT_LINK,null,n,this.selectedMap.values().toArray())):(this.selectedMap.set(g,n),this.context.event.emit(V.SELECT_LINK,n,null,this.selectedMap.values().toArray())))}),O.on("contextmenu",A=>{A.evt.preventDefault(),A.cancelBubble=!0,this.context.event.emit(V.CONTEXT_LINK,A.evt,n)}),this.linkCache.set(g,O)),this.selectedMap.has(g)&&this.handleHighlight(O,c,v,x,T,2,!0)}}}),t!=null&&t.length||this.linkCache.forEach((n,r)=>{n._!==s&&(n.destroy(),this.linkCache.delete(r))}),this.layer.batchDraw()}createId(t){return`link-group-${t[this.context.getOptions().links.key]}-${t.from}-${t.to}-${t.type||"FS"}`}getPoints(t,e,s){if(t.startTime&&t.endTime&&e.startTime&&e.endTime){const n=this.context.getOptions().row.height,r=t.isMilestone()?n/2:0,a=this.context.store.getTimeAxis().getTimeLeft(t.startTime)-r,o=this.context.store.getTimeAxis().getTimeLeft(t.endTime)+r,h=e.isMilestone()?n/2:0,l=this.context.store.getTimeAxis().getTimeLeft(e.startTime)-h,d=this.context.store.getTimeAxis().getTimeLeft(e.endTime)+h;let p=[];switch(s.type||"FS"){case"FF":p=this.createFF(s,t,e,a,o,l,d);break;case"SS":p=this.createSS(s,t,e,a,o,l,d);break;case"SF":p=this.createSF(s,t,e,a,o,l,d);break;case"FS":default:p=this.createFS(s,t,e,a,o,l,d)}return p}return[]}createFS(t,e,s,n,r,a,o){const h=this.context.getOptions().header.height,l=this.context.getOptions().row.height,d=l/2+h,p=t.gap||this.context.getOptions().links.gap,u=[r+p,.05+d+l*e.flatIndex];{const g=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(g))Q.error("Link's distance must be a Numeric");else{const f=r+p+g,m=a-p-g,b=[Math.max(f,m),d+l*e.flatIndex];u.push(...b);const S=l*e.flatIndex+h+(e.flatIndex<=s.flatIndex?l:0);u.push(b[0],S),u.push(m,S),u.push(m,d+l*s.flatIndex)}}return u.push(a-p,d+l*s.flatIndex),u}createFF(t,e,s,n,r,a,o){const h=this.context.getOptions().header.height,l=this.context.getOptions().row.height,d=l/2+h,p=t.gap||this.context.getOptions().links.gap,u=[r+p,.05+d+l*e.flatIndex];{const g=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(g))Q.error("Link's distance must be a Numeric");else{const f=r+p+g,m=o+p+g,b=[f<=m?m:f,d+l*e.flatIndex];u.push(...b),u.push(Math.max(m,f),d+l*s.flatIndex)}}return u.push(o+p,d+l*s.flatIndex),u}createSS(t,e,s,n,r,a,o){const h=this.context.getOptions().header.height,l=this.context.getOptions().row.height,d=l/2+h,p=t.gap||this.context.getOptions().links.gap,u=[n-p,.05+d+l*e.flatIndex];{const g=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(g))Q.error("Link's distance must be a Numeric");else{const f=n-p-g,m=a-p-g;u.push(Math.min(m,f),d+l*e.flatIndex),u.push(Math.min(m,f),d+l*s.flatIndex)}}return u.push(a-p,d+l*s.flatIndex),u}createSF(t,e,s,n,r,a,o){const h=this.context.getOptions().header.height,l=this.context.getOptions().row.height,d=l/2+h,p=t.gap||this.context.getOptions().links.gap,u=[n-p,.05+d+l*e.flatIndex];{const g=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(g))Q.error("Link's distance must be a Numeric");else{const f=n-p-g,m=o+p+g,b=[Math.min(f,m),d+l*e.flatIndex];u.push(...b);const S=l*e.flatIndex+h+(e.flatIndex<=s.flatIndex?l:0);u.push(b[0],S),u.push(m,S),u.push(m,d+l*s.flatIndex)}}return u.push(o+p,d+l*s.flatIndex),u}handleDrag(t,e,s,n,r){var a,o,h;if(!this.isDragging||this.context.getOptions().links.move.enabled!==!0)return;this.stage.container().style.cursor="pointer";const l=this.linksGroup.findOne(`#${r}`);this.templateArrow.setAttrs({stroke:e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:e.width??this.context.getOptions().links.width,pointerLength:((a=e.arrow)==null?void 0:a.height)??this.context.getOptions().links.arrow.height,pointerWidth:((o=e.arrow)==null?void 0:o.width)??this.context.getOptions().links.arrow.width,fill:((h=e.arrow)==null?void 0:h.color)||this.context.getOptions().links.arrow.color||e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:e.data||this.context.getOptions().links.dash}),this.templateArrow.visible(!1);let d=null;const p=this.context.getOptions().header.height,u=this.context.getOptions().row.height,g=u/2+p,f=e.gap||this.context.getOptions().links.gap;let m=null;const b=()=>{const c=this.stage.getPointerPosition();if(c&&(m=this.getTaskByPosition(c),!!m&&(this.templateArrow.visible(!0),l==null||l.visible(!1),m!=null&&m.startTime&&m!=null&&m.endTime))){const v=this.context.store.getTimeAxis().getTimeLeft(m.startTime),x=this.context.store.getTimeAxis().getTimeLeft(m.endTime),T=(x+v)/2+this.offsetX;let O=v-f;c.x<=T?d="S":(d="F",O=x+f);let _;if(s==="S"?_=`${d}${(e.type||"FS")[1]}`:_=`${(e.type||"FS")[0]}${d}`,s==="S"){const{allowLeft:C,allowRight:k}=this.isAllowStartDrop(m,e.to,_);this.templateArrow.points([O,g+u*m.flatIndex,...n]),k?this.stage.container().style.cursor="pointer":this.stage.container().style.cursor="not-allowed"}else if(s==="F"){const{allowLeft:C,allowRight:k}=this.isAllowEndDrop(m,e.from,_);this.templateArrow.points([...n,O,g+u*m.flatIndex]),C?this.stage.container().style.cursor="pointer":this.stage.container().style.cursor="not-allowed"}}},S=()=>{var c,v;let x;const T=le(e);if(d&&m&&(s==="S"?(x=`${d}${(e.type||"FS")[1]}`,T.from=m.id):s==="F"&&(x=`${(e.type||"FS")[0]}${d}`,T.to=m.id)),x&&m){T.type=x;let O=!1,_=!1,C;s==="S"?{allowLeft:O,allowRight:_,reason:C}=this.isAllowStartDrop(m,T.to,T.type,!0):s==="F"&&({allowLeft:O,allowRight:_,reason:C}=this.isAllowEndDrop(m,T.from,T.type,!0)),((c=T.type)==null?void 0:c.slice(1))==="S"&&O||((v=T.type)==null?void 0:v.slice(1))==="F"&&_?(this.context.event.emit(V.UPDATE_LINK,T),this.context.store.getLinkManager().update(),this.calculateLinks()):this.context.event.emit(V.ERROR,C||xt.LINK_NOT_ALLOWED)}else this.context.event.emit(V.ERROR,xt.TASK_NOT_FOUND);this.cleanupTempLink(),this.calculateLinks([m,this.context.store.getDataManager().getTaskById(e.from),this.context.store.getDataManager().getTaskById(e.to)].filter(O=>!!O)),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",S)},y=c=>{c.key==="Escape"&&(this.cleanupTempLink(),l==null||l.visible(!0),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",S),document.removeEventListener("keydown",y))};document.addEventListener("mousemove",b),document.addEventListener("mouseup",S),document.addEventListener("keydown",y)}createLink(t,e,s,n,r){this.stage.container().style.cursor="pointer",this.templateArrow.setAttrs({points:[],stroke:s,strokeWidth:this.context.getOptions().links.width,pointerLength:this.context.getOptions().links.arrow.height,pointerWidth:this.context.getOptions().links.arrow.width,fill:s,dash:this.context.getOptions().links.dash}),this.templateArrow.visible(!1);const a=this.context.store.getLinkManager();let o=null;const h=this.context.getOptions().header.height,l=this.context.getOptions().row.height,d=l/2+h,p=this.context.getOptions().links.gap;let u=null;const g=()=>{const b=this.stage.getPointerPosition();if(b&&(u=this.getTaskByPosition(b),!!u&&(this.templateArrow.visible(!0),u.startTime&&u.endTime))){const S=this.context.store.getTimeAxis().getTimeLeft(u.startTime),y=this.context.store.getTimeAxis().getTimeLeft(u.endTime),c=(y+S)/2+this.offsetX;let v=S-p;b.x<=c?o="S":(o="F",v=y+p),this.templateArrow.points([...n,v,d+l*u.flatIndex]);const{allowLeft:x,allowRight:T}=this.isAllowEndDrop(u,r,a.convertPointsToLinkType(e,o));o==="S"&&!x?this.stage.container().style.cursor="not-allowed":o==="F"&&!T?this.stage.container().style.cursor="not-allowed":this.stage.container().style.cursor="pointer"}},f=()=>{let b;if(o&&(b=a.convertPointsToLinkType(e,o)),b&&u)if(a.isLinkExist(r,u.id,b))this.context.event.emit(V.ERROR,xt.LINK_EXIST);else if(r===u.id&&e===o)this.context.event.emit(V.ERROR,xt.LINK_SAME);else{const{allowLeft:S,allowRight:y,reason:c}=this.isAllowEndDrop(u,r,b,!0);o==="S"&&S||o==="F"&&y?(this.context.event.emit(V.CREATE_LINK,{from:r,to:u.id,type:b,color:s}),this.context.store.getLinkManager().update()):this.context.event.emit(V.ERROR,c||xt.LINK_NOT_ALLOWED)}this.cleanupTempLink(),this.calculateLinks([u].filter(S=>!!S)),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)},m=b=>{b.key==="Escape"&&(this.cleanupTempLink(),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f),document.removeEventListener("keydown",m))};document.addEventListener("mousemove",g),document.addEventListener("mouseup",f),document.addEventListener("keydown",m)}cleanupTempLink(){this.templateArrow.visible(!1),this.stage.container().style.cursor="default",this.isDragging=!1}getTaskByPosition(t){const e=this.context.getOptions().header.height;if(t.y<=e)return null;const s=t.y-this.offsetY,n=Math.floor((s-e)/this.context.getOptions().row.height);return this.context.store.getDataManager().getVisibleTasks()[n]||null}isAllowStartDrop(t,e,s,n=!1){let r=!0,a=!0,o=this.context.getOptions().links.create.from;Bt(o)&&(o=o(t.getEmitData(),this.context.store.getDataManager().getTaskById(e).getEmitData())),Gi(o)?r=a=o:Ft(o)&&(r=o==="S",a=o==="F");const h=this.validateChain(t.id,e,s,n);return{allowLeft:r&&h.ok,allowRight:a&&h.ok,reason:h.reason}}isAllowEndDrop(t,e,s,n=!1){let r=!0,a=!0,o=this.context.getOptions().links.create.to;Bt(o)&&(o=o(t.getEmitData(),this.context.store.getDataManager().getTaskById(e).getEmitData())),Gi(o)?r=a=o:Ft(o)&&(r=o==="S",a=o==="F");const h=this.validateChain(e,t.id,s,n);return{allowLeft:r&&h.ok,allowRight:a&&h.ok,reason:h.reason}}validateChain(t,e,s,n=!1){const r=this.context.store.getLinkManager().validateChain(t,e,s);return r.ok?{ok:!0}:(n&&r.reason===xt.LINK_CYCLE&&r.cycleInfo&&this.highlightCycleNodes(r.cycleInfo.nodes),{ok:!1,reason:r.reason})}handleHighlight(t,e,s,n,r,a,o=!1){const h=t.findOne("Circle"),l=t.findOne("Arrow"),d=t.findOne("Line");h&&new Y.Tween({node:h,radius:e+a,duration:o?0:.1}).play(),l&&new Y.Tween({node:l,pointerWidth:s+a,pointerLength:n+a,strokeWidth:r+a,duration:o?0:.1}).play(),d&&new Y.Tween({node:d,strokeWidth:r+a,duration:o?0:.1}).play()}highlightPoint(t){this.handlePointHighlight(t,1)}unhighlightPoint(t){const e=this.context.getOptions().links.create.mode==="always"?.5:0;this.handlePointHighlight(t,e)}handlePointHighlight(t,e){const s=this.pointGroup.findOne(`#point-${t}-left`),n=this.pointGroup.findOne(`#point-${t}-right`);s&&new Y.Tween({node:s,opacity:e,duration:.1}).play(),n&&new Y.Tween({node:n,opacity:e,duration:.1}).play()}highlightCycleNodes(t){t.forEach(e=>{this.context.event.emit(V.SLIDER_BLINK,e)})}}class Qf{constructor(t,e,s){M(this,"tasks",[]),M(this,"chartBaselineGroup"),M(this,"indicatorGroup"),M(this,"baselineGroup"),M(this,"width",0),M(this,"height",0),M(this,"offsetX",0),M(this,"offsetY",0),this.context=t,this.stage=e,this.layer=s,this.chartBaselineGroup=new Y.Group({name:"chart-baseline-group"}),this.baselineGroup=new Y.Group({name:"baseline-group"}),this.chartBaselineGroup.add(this.baselineGroup),this.indicatorGroup=new Y.Group({name:"baseline-indicator-group"}),this.chartBaselineGroup.add(this.indicatorGroup),this.layer.add(this.chartBaselineGroup),this.registerEvents()}registerEvents(){}resize(t,e){this.width=t,this.height=e,this.calculateBaselines()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.chartBaselineGroup.x(t),this.chartBaselineGroup.y(e),this.calculateBaselines()}update(){this.calculateBaselines()}render(t){this.tasks=t,this.update()}destroy(){this.baselineGroup.destroy(),this.indicatorGroup.destroy(),this.chartBaselineGroup.destroy()}calculateBaselines(){if(this.baselineGroup.destroyChildren(),this.indicatorGroup.destroyChildren(),!this.context.getOptions().baselines.show)return;const t=this.context.getOptions().header.height,e=this.context.getOptions().row.height,s=e/2+t,n=yi(this.context.getOptions().baselines.radius),r=this.context.getOptions().baselines.opacity,a=this.context.getOptions().baselines.backgroundColor;this.tasks.forEach(o=>{if(this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.show,o)){const h=this.context.store.getDataManager().getBaselinesByTaskId(o.id),l=mi(this.context.getOptions().baselines.height||this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.height,o),e),d=this.context.getOptions().baselines.offset??0;h.forEach((p,u)=>{if(!p.validate())return;const g=this.context.store.getTimeAxis().getTimeLeft(p.startTime),f=this.context.store.getTimeAxis().getTimeLeft(p.endTime),m=new Y.Group({id:`baseline-group-${p.id}`});this.renderBaselineBar(m,o,p,g,f,s,e,l,t,a,r,n,d),this.baselineGroup.add(m);const b=this.context.getOptions().baselines.compare,S=p.getTimeDiff();if(!b.enabled||!S)return;const y=b.mode;p.highlight&&(y==="highlight"||y==="both")&&this.renderCompareHighlight(m,o,p,S),u===0&&(y==="indicator"||y==="both")&&this.renderCompareIndicator(o,p,S),this.bindEvents(m,o,p)})}})}renderBaselineBar(t,e,s,n,r,a,o,h,l,d,p,u,g){if(this.context.getOptions().baselines.mode==="shadow"){const f=a+o*e.flatIndex-h/2+g,m=new Y.Rect({id:`baseline-item-${s.id}`,x:n,y:f,width:r-n,height:h,cornerRadius:u,fill:d,opacity:p});t.add(m),this.renderText(t,e,s,n,r,f,h)}else if(this.context.getOptions().baselines.mode==="line"){const f=mi(this.context.getOptions().baselines.height??5,o);let m=l+o*e.flatIndex+g;const b=this.context.getOptions().baselines.position;let S="";b==="top"?(m+=+f/2,S="line_top"):b==="center"?(m+=o/2,S="line_center"):(m+=o-f/2,S="line_bottom");const y=new Y.Line({id:`baseline-item-${s.id}`,points:[n,m,r,m],stroke:d,opacity:p,strokeWidth:f,lineCap:"butt",lineJoin:"round"});t.add(y),this.renderText(t,e,s,n,r,m,f,S)}}renderText(t,e,s,n,r,a,o,h){const l=`chart-baseline-text-${s.id}`;if(this.baselineGroup.find(`#${l}`)&&this.baselineGroup.find(`#${l}`).forEach(b=>b.remove()),!this.context.getOptions().baselines.label.show)return;const d=this.context.getOptions().baselines.label.field,p=d?s.getField(d):s.name;if(!p||p==="")return;const u=r-n-10,g=Math.max(this.context.getOptions().baselines.label.fontSize,o),f=new Y.Text({text:p,id:l,x:n+5,y:a,width:u,height:g,fill:this.context.getOptions().baselines.label.color,fontSize:this.context.getOptions().baselines.label.fontSize,fontFamily:this.context.getOptions().baselines.label.fontFamily||"Arial",align:this.context.getOptions().baselines.label.position,verticalAlign:"bottom"});h==="line_bottom"?f.setAttrs({y:a-g/2,verticalAlign:"top"}):h==="line_center"?f.setAttrs({y:a-g/2,verticalAlign:"middle"}):h==="line_top"&&f.setAttrs({y:a-o/2,verticalAlign:"bottom"}),o>=g&&f.setAttrs({verticalAlign:"middle"});const m=f.measureSize(p);(this.context.getOptions().baselines.label.forceDisplay||u>m.width)&&t.add(f)}renderCompareHighlight(t,e,s,n){const r=n[`${this.context.getOptions().baselines.compare.target}Status`];if(!r||r==="ontime")return;const a=t.findOne(`#baseline-item-${s.id}`);if(!a)return;const o=this.context.getOptions().baselines.compare,h=this.context.getOptions().baselines.mode,l={fill:"",stroke:"",opacity:o[r].opacity};if(h==="shadow")l.fill=o[r].backgroundColor;else if(h==="line")l.stroke=o[r].backgroundColor;else return;a.setAttrs(l)}renderCompareIndicator(t,e,s){const n=this.context.getOptions().baselines,r=n.compare.indicator;if(!r||!r.show)return;const a=this.context.getOptions().header.height,o=this.context.getOptions().row.height,h=mi(this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.height,t),o);let l=n.backgroundColor;const d=this.context.store.getTimeAxis().getTimeLeft(t.startTime),p=this.context.store.getTimeAxis().getTimeLeft(t.endTime);let u=(o-h)/2+o*t.flatIndex+a;if(r.position==="bottom"&&(u+=h),r.show==="start"||r.show==="both"||r.show===!0){const g=s.startStatus;if(g&&n.compare.indicator[g].show){l=lt(n.compare.indicator[g].color).alpha(n.compare.indicator[g].opacity).toHex();const f=new Y.Circle({x:d-r.size,y:u,fill:l,radius:r.size/2});this.indicatorGroup.add(f);let m=`${ns(s.startDiff)}${s.unit} ${g}`;const b=n.compare.indicator[g].text;Bt(b)?m=b(s.startDiff,{...t.getEmitData(),baseline:e}):Ft(b)&&(m=b);const S=new Y.Text({y:u-r.fontSize/2,text:m,fill:l,fontSize:r.fontSize,fontFamily:r.fontFamily||"Arial"}),y=S.measureSize(m);S.x(d-r.size-y.width-5),this.indicatorGroup.add(S)}}if(r.show==="end"||r.show==="both"||r.show===!0){const g=s.endStatus;if(g&&n.compare.indicator[g].show){l=lt(n.compare.indicator[g].color).alpha(n.compare.indicator[g].opacity).toHex();const f=new Y.Circle({x:p+r.size,y:u,fill:l,radius:r.size/2});this.indicatorGroup.add(f);let m=`${ns(s.endDiff)}${s.unit} ${g}`;const b=n.compare.indicator[g].text;Bt(b)?m=b(s.endDiff,{...t.getEmitData(),baseline:e}):Ft(b)&&(m=b);const S=new Y.Text({x:p+r.size+5,y:u-r.fontSize/2,text:m,fill:l,fontSize:r.fontSize,fontFamily:r.fontFamily||"Arial"});this.indicatorGroup.add(S)}}}bindEvents(t,e,s){t.on("mouseenter",n=>{this.context.event.emit(V.BASELINE_MOUSEENTER,n.evt,e,s)}),t.on("mousemove",n=>{this.context.event.emit(V.BASELINE_MOUSEMOVE,n.evt,e,s)}),t.on("mouseout",n=>{this.context.event.emit(V.BASELINE_MOUSEOUT,n.evt,e,s)}),t.on("click",n=>{n.cancelBubble=!0,n.evt.button===0?this.context.event.emit(V.BASELINE_CLICK,n.evt,e,s):n.evt.button===2&&this.context.event.emit(V.BASELINE_CONTEXTMENU,n.evt,e,s)})}}class Jf{constructor(t,e){M(this,"stage"),M(this,"headerLayer"),M(this,"bodyGroup"),M(this,"gridGroup"),M(this,"weekendGroup"),M(this,"holidayGroup"),M(this,"flagGroup"),M(this,"todayLayer"),M(this,"linkGroup"),M(this,"baselineGroup"),M(this,"axisLayer"),M(this,"bgLayer"),M(this,"bodyLayer"),M(this,"width",0),M(this,"height",0),this.context=t,this.container=e,this.stage=new Y.Stage({container:this.container,width:this.container.clientWidth,height:this.container.clientHeight}),this.bgLayer=new Y.Layer,this.weekendGroup=new Yf(this.context,this.bgLayer),this.holidayGroup=new Kf(this.context,this.bgLayer),this.flagGroup=new Xf(this.context,this.bgLayer),this.gridGroup=new Uf(this.context,this.bgLayer),this.stage.add(this.bgLayer),this.axisLayer=new Y.Layer,this.headerLayer=new Bf(this.context,this.axisLayer),this.todayLayer=new jf(this.context,this.bgLayer,this.axisLayer),this.stage.add(this.axisLayer),this.bodyLayer=new Y.Layer,this.linkGroup=new qf(this.context,this.stage,this.bodyLayer),this.baselineGroup=new Qf(this.context,this.stage,this.bodyLayer),this.bodyGroup=new Vf(this.context,this.stage,this.bodyLayer,this.bgLayer),this.stage.add(this.bodyLayer)}resize(t,e){this.width=t,this.height=e,this.context.store.getTimeAxis().setAllWidth(t),this.stage.width(t),this.stage.height(e),this.headerLayer.resize(t),this.gridGroup.resize(t,e),this.linkGroup.resize(t,e),this.baselineGroup.resize(t,e),this.holidayGroup.resize(t,e),this.flagGroup.resize(t,e),this.weekendGroup.resize(t,e),this.bodyGroup.resize(t,e),this.todayLayer.resize(t,e)}render(t,e,s,n=!1,r=!1){this.headerLayer.setOffset(-t,0),this.gridGroup.setOffset(-t,-e),this.linkGroup.setOffset(-t,-e),this.baselineGroup.setOffset(-t,-e),this.weekendGroup.setOffset(-t,-e),this.holidayGroup.setOffset(-t,-e),this.flagGroup.setOffset(-t,-e),this.bodyGroup.setOffset(-t,-e),this.todayLayer.setOffset(-t,-e),this.gridGroup.render(),this.holidayGroup.render(),this.flagGroup.render(),this.weekendGroup.render(),this.linkGroup.render(s),this.baselineGroup.render(s),this.bodyGroup.render(s),this.headerLayer.render(),this.todayLayer.render()}refresh(t,e,s,n=!1){this.render(t,e,s,!0,n)}updateTask(t){this.bodyGroup.updateTask(t),this.linkGroup.updateTask(t),this.baselineGroup.update()}destroy(){this.headerLayer.destroy(),this.gridGroup.destroy(),this.bodyLayer.destroy(),this.todayLayer.destroy(),this.holidayGroup.destroy(),this.flagGroup.destroy(),this.weekendGroup.destroy(),this.linkGroup.destroy(),this.baselineGroup.destroy(),this.axisLayer.destroy(),this.bgLayer.destroy(),this.stage.destroy()}}const Zf='<svg style="transition: all 0.3s" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"/><path fill="currentColor" d="M8.293 12.707a1 1 0 0 1 0-1.414l5.657-5.657a1 1 0 1 1 1.414 1.414L10.414 12l4.95 4.95a1 1 0 0 1-1.414 1.414z"/></g></svg>';class tg{constructor(t,e){M(this,"line"),M(this,"initialX",0),M(this,"initialWidth",0),M(this,"collapseButton",null),this.root=t,this.container=e,this.line=document.createElement("div"),this.line.className="x-gantt-middle-resize-line",this.line.style.position="absolute",this.line.style.zIndex="99",this.line.style.width="5px",this.line.style.height="100%",this.line.style.borderLeft="2px solid",this.line.style.setProperty("border-left-color",this.root.store.getOptionManager().getOptions().border.color,"important"),this.line.style.cursor="col-resize",this.root.store.getOptionManager().getOptions().collapse.show&&(this.collapseButton=document.createElement("div"),this.collapseButton.className="x-gantt-collapse-button",this.collapseButton.style.position="absolute",this.collapseButton.style.top="50%",this.collapseButton.style.left="0",this.collapseButton.style.transform="translateY(-50%)",this.collapseButton.style.cursor="pointer",this.collapseButton.style.width="16px",this.collapseButton.style.height="30px",this.collapseButton.style.backgroundColor=this.root.store.getOptionManager().getOptions().collapse.backgroundColor||"#fff",this.collapseButton.style.borderRadius=`0 ${this.root.store.getOptionManager().getOptions().collapse.radius}px ${this.root.store.getOptionManager().getOptions().collapse.radius}px 0`,this.collapseButton.style.boxShadow="0 0 2px rgba(0, 0, 0, 0.2)",this.collapseButton.style.display="flex",this.collapseButton.style.alignItems="center",this.collapseButton.style.justifyContent="center",this.collapseButton.innerHTML=Zf,this.collapseButton.addEventListener("click",s=>{s.stopPropagation(),this.root.store.getColumnManager().collapse()}),this.line.appendChild(this.collapseButton)),this.container.appendChild(this.line),this.addDragEvents(),this.initEvents()}initEvents(){this.root.event.on(V.OPTIONS_UPDATE,()=>{this.updateOptions()})}setOffset(t){this.line.style.transform=`translateX(${t-2}px)`,this.initialX=t,this.collapseButton&&(this.root.store.getColumnManager().isCollapsed()?this.collapseButton.querySelector("svg").style.transform="rotate(180deg)":this.collapseButton.querySelector("svg").style.transform="rotate(0deg)")}addDragEvents(){let t=0,e=null;const s=this.root.store.getColumnManager(),n=s.getLeafColumns(),r=h=>{h.preventDefault(),h.stopPropagation(),t=h.clientX,e=this.container.getBoundingClientRect();const l=n[n.length-1].key;this.initialWidth=s.getColumnWidth(l);const d=this.initialX;this.root.event.emit(V.SHOW_GUIDELINE,d);const p=g=>a(g),u=g=>o(g,p,u);document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)},a=h=>{if(h.preventDefault(),!e)return;const l=h.clientX-t;n[n.length-1].key;const d=50-this.initialWidth,p=e.width-20-this.initialX,u=Math.max(d,Math.min(p,l)),g=this.initialX+u;this.root.event.emit(V.MOVE_GUIDELINE,g)},o=(h,l,d)=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",d),this.root.event.emit(V.HIDE_GUIDELINE);const p=h.clientX-t,u=n[n.length-1].key,g=Math.max(50,this.initialWidth+p);s.setColumnWidth(u,g),this.root.event.emit(V.UPDATE_TABLE_HEADER)};this.line.addEventListener("mousedown",r)}updateOptions(){this.line.style.setProperty("border-left-color",this.root.store.getOptionManager().getOptions().border.color,"important"),this.collapseButton&&(this.collapseButton.style.backgroundColor=this.root.store.getOptionManager().getOptions().collapse.backgroundColor||"#fff",this.collapseButton.style.borderRadius=`0 ${this.root.store.getOptionManager().getOptions().collapse.radius}px ${this.root.store.getOptionManager().getOptions().collapse.radius}px 0`)}}class eg{constructor(t,e){if(M(this,"element"),M(this,"container"),M(this,"visible",!1),M(this,"onShowGuideline"),M(this,"onHideGuideline"),M(this,"onMoveGuideline"),M(this,"onOptionsUpdate"),this.context=t,!e)throw new Error("Container is required for GuideLine instance");this.container=e,this.element=document.createElement("div"),this.initElement(),this.initEvents()}initElement(){this.element.className="x-gantt-guide-line",this.element.style.position="absolute",this.element.style.top="0",this.element.style.left="0",this.element.style.width="0",this.element.style.height="100%",this.element.style.setProperty("border-left",`1px dashed ${this.context.getOptions().border.color}`,"important"),this.element.style.zIndex="9999",this.element.style.pointerEvents="none",this.element.style.display="none",this.element.style.transform="translateX(-0.5px)",getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.appendChild(this.element)}initEvents(){this.onShowGuideline=t=>{this.show(t)},this.onHideGuideline=()=>{this.hide()},this.onMoveGuideline=t=>{this.setLeft(t)},this.onOptionsUpdate=()=>{this.updateOptions()},this.context.event.on(V.SHOW_GUIDELINE,this.onShowGuideline),this.context.event.on(V.HIDE_GUIDELINE,this.onHideGuideline),this.context.event.on(V.MOVE_GUIDELINE,this.onMoveGuideline),this.context.event.on(V.OPTIONS_UPDATE,this.onOptionsUpdate)}setContainer(t){this.element.parentElement&&this.element.parentElement.removeChild(this.element),this.container=t,getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.appendChild(this.element)}setLeft(t){const e=this.container.clientWidth,s=Math.max(0,Math.min(e-20,t));this.element.style.transform=`translateX(${s-.5}px)`}show(t){t!==void 0&&this.setLeft(t),this.element.style.display="block",this.visible=!0}hide(){this.element.style.display="none",this.visible=!1}isVisible(){return this.visible}getLeft(){return this.element.offsetLeft}updateOptions(){this.element.style.setProperty("border-left",`1px dashed ${this.context.getOptions().border.color}`,"important")}destroy(){this.context.event.off(V.SHOW_GUIDELINE,this.onShowGuideline),this.context.event.off(V.HIDE_GUIDELINE,this.onHideGuideline),this.context.event.off(V.MOVE_GUIDELINE,this.onMoveGuideline),this.context.event.off(V.OPTIONS_UPDATE,this.onOptionsUpdate),this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class ig{constructor(t=16){M(this,"taskQueue",new Map),M(this,"taskHandlers",new Map),M(this,"isScheduled",!1),M(this,"delay"),M(this,"debouncedFlush"),this.delay=t,this.debouncedFlush=Xr(()=>{this.flushTaskQueue()},t)}registerHandler(t,e){this.taskHandlers.set(t,e),Q.debug(`RenderScheduler: 注册任务处理器 ${t}`)}registerSimpleHandler(t,e,s=!1){this.registerHandler(t,{callback:e,immediate:s})}scheduleTask(t,e=[],s={}){const n=this.taskHandlers.get(t);if(!n){Q.warn(`RenderScheduler: 未找到任务类型 ${t} 的处理器`);return}const r={type:t,refresh:s.refresh,callback:n.callback,args:e,immediate:s.immediate??n.immediate??!1};if(r.immediate){Q.debug(`RenderScheduler: 立即执行任务 ${t}`),this.executeTask(r);return}this.taskQueue.set(t,r),Q.debug(`RenderScheduler: 添加任务到队列 ${t}`),this.debouncedFlush()}immediateExecuteTask(t,e=[],s=!1){const n=this.taskHandlers.get(t);if(!n){Q.warn(`RenderScheduler: 未找到任务类型 ${t} 的处理器`);return}Q.debug(`RenderScheduler: 立即执行任务 ${t}`);const r={type:t,refresh:s,callback:n.callback,args:e,immediate:!0};this.executeTask(r)}immediateFlushAll(){Q.debug("RenderScheduler: 立即执行所有队列任务"),this.cancelScheduled(),this.flushTaskQueue()}executeTask(t){try{t.callback(...t.args||[])}catch(e){Q.error(`RenderScheduler: 执行任务 ${t.type} 时出错:`,e)}}flushTaskQueue(){if(this.taskQueue.size===0)return;Q.debug(`RenderScheduler: 执行任务队列,任务数量: ${this.taskQueue.size}`);const t=Array.from(this.taskQueue.values()).sort((e,s)=>e.immediate!==s.immediate?e.immediate?-1:1:e.refresh!==s.refresh?e.refresh?-1:1:0);this.taskQueue.clear(),this.isScheduled=!1;for(const e of t)this.executeTask(e)}cancelScheduled(){this.debouncedFlush.cancel(),this.taskQueue.clear(),this.isScheduled=!1}unregisterHandler(t){this.taskHandlers.delete(t),this.taskQueue.delete(t),Q.debug(`RenderScheduler: 移除任务处理器 ${t}`)}getQueueSize(){return this.taskQueue.size}getRegisteredHandlers(){return Array.from(this.taskHandlers.keys())}destroy(){this.cancelScheduled(),this.taskHandlers.clear(),Q.debug("RenderScheduler: 已销毁")}}class sg{constructor(t,e){M(this,"scrollbar"),M(this,"rootElement"),M(this,"tableContainer"),M(this,"chartContainer"),M(this,"table"),M(this,"chart"),M(this,"middleLine"),M(this,"guideLine"),M(this,"renderScheduler"),M(this,"_id",te()),M(this,"width",0),M(this,"height",0),M(this,"isInitialized",!0),M(this,"resizeObserver"),M(this,"updateSize",()=>{this.width=this.context.store.getOptionManager().getOptions().width||this.container.clientWidth,this.height=this.context.store.getOptionManager().getOptions().height||this.container.clientHeight,this.rootElement.style.width=this.width?`${this.width}px`:"100%",this.rootElement.style.height=this.height?`${this.height}px`:"100%";const n=this.context.store.getColumnManager().getTotalWidth();this.tableContainer.style.width=`${n}px`,this.tableContainer.style.height=this.height?`${this.height}px`:"100%";const r=this.width-n;this.chartContainer.style.width=`${r}px`,this.chartContainer.style.height=this.height?`${this.height}px`:"100%",this.chart.resize(r,this.height),this.middleLine.setOffset(n);const a=this.context.store.getTimeAxis().getTotalWidth();this.scrollbar.updateSize(r,this.height,a,this.context.store.getDataManager().getVisibleSize()*this.context.store.getOptionManager().getOptions().row.height+this.context.store.getOptionManager().getOptions().header.height,n)}),M(this,"setStyleValue",()=>{const n=this.context.store.getOptionManager().getOptions();this.rootElement.style.setProperty("--x-gantt-primary-color",`${n.primaryColor}`),this.rootElement.style.setProperty("--x-gantt-border-color",`${n.border.color}`),this.rootElement.style.setProperty("--x-gantt-row-hover-color",`${lt(n.row.hover.backgroundColor).alpha(n.row.hover.opacity)}`),this.rootElement.style.setProperty("--x-gantt-row-selected-color",`${lt(n.row.select.backgroundColor).alpha(n.row.select.opacity)}`),this.rootElement.style.setProperty("--x-gantt-header-font-weight",`${n.header.fontWeight}`)}),M(this,"handleUpdateTask",n=>{this.table.updateTask(n),this.chart.updateTask(n)}),M(this,"handleColumnWidthChange",()=>{this.table.updateWidth(),this.updateSize()});var s;this.context=t,this.container=e,this.rootElement=document.createElement("div"),this.rootElement.id=`x-gantt-${this._id}`,this.rootElement.className="x-gantt",this.rootElement.style.overflow="hidden",this.rootElement.style.display="flex",this.rootElement.style.position="relative",this.container.appendChild(this.rootElement),this.tableContainer=document.createElement("div"),this.tableContainer.className="x-gantt-table",this.rootElement.appendChild(this.tableContainer),this.guideLine=new eg(this.context,this.container),this.middleLine=new tg(this.context,this.rootElement),this.chartContainer=document.createElement("div"),this.chartContainer.className="x-gantt-chart",this.rootElement.appendChild(this.chartContainer),this.table=new $f(this.context,this.tableContainer),this.chart=new Jf(this.context,this.chartContainer),this.scrollbar=new If(this.context,this.rootElement,this.context.store.getOptionManager().getOptions().scrollbar||{}),this.renderScheduler=new ig(16),this.setupTaskHandlers(),this.updateSize(),this.setupEventListeners(),(s=this.context.store.getOptionManager().getOptions().resize)!=null&&s.enabled&&(typeof window.ResizeObserver>"u"?Q.warn("Current environment does not support ResizeObserver, please include a polyfill to enable auto-resize feature."):(this.resizeObserver=new ResizeObserver(()=>{this.updateSize(),this.renderScheduler.scheduleTask("VIEW_UPDATE",[!1])}),this.resizeObserver.observe(this.container)))}getScrollbar(){return this.scrollbar}getRootElement(){return this.rootElement}setupTaskHandlers(){this.renderScheduler.registerSimpleHandler("DATA_UPDATE",(t=!0)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("VIEW_UPDATE",(t=!0)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("MANUAL_RENDER",(t=!1)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("SCROLL",()=>this.performRender(!0,!0),!0),this.renderScheduler.registerSimpleHandler("UPDATE_TASK",t=>this.handleUpdateTask(t)),this.renderScheduler.registerSimpleHandler("COLUMN_WIDTH_CHANGE",()=>this.handleColumnWidthChange()),this.renderScheduler.registerSimpleHandler("CHART_OFFSET_CHANGE",(t=!1)=>this.performRender(t))}setupEventListeners(){this.context.event.on(V.DATA_UPDATE,()=>{this.renderScheduler.scheduleTask("DATA_UPDATE",[!0])}),this.context.event.on(V.SCROLL,()=>{this.renderScheduler.scheduleTask("SCROLL",[!0],{immediate:!0})}),this.context.event.on(V.COLUMN_WIDTH_CHANGE,()=>{this.renderScheduler.scheduleTask("COLUMN_WIDTH_CHANGE")}),this.context.event.on(V.VIEW_UPDATE,()=>{this.renderScheduler.scheduleTask("VIEW_UPDATE",[!0])}),this.context.event.on(V.UPDATE_TASK,t=>{this.renderScheduler.scheduleTask("UPDATE_TASK",[t],{immediate:!0})}),this.context.event.on(V.CHART_OFFSET_CHANGE,()=>{this.renderScheduler.scheduleTask("CHART_OFFSET_CHANGE",[!1])}),this.context.event.on(V.TOGGLE_COLLAPSE,()=>{this.renderScheduler.scheduleTask("CHART_OFFSET_CHANGE",[!1],{immediate:!0})})}performRender(t=!1,e=!1){this.setStyleValue();const{x:s,y:n}=this.scrollbar.getScrollPosition(),r=this.context.store.getOptionManager().getOptions().row.height,a=this.context.store.getOptionManager().getOptions().header.height,o=Math.floor(n/r),h=Math.ceil((this.height-a)/r),l=2,d=Math.max(0,o),p=h+l,u=this.context.store.getDataManager().getVisibleTasks().slice(d,d+p);this.updateSize(),e?(this.table.refresh(n,u),this.chart.refresh(s,n,u,!0)):t?(this.table.refresh(n,u),this.chart.refresh(s,n,u)):(this.table.render(n,u),this.chart.render(s,n,u)),this.isInitialized&&(this.context.event.emit(V.LOADED),this.isInitialized=!1),Q.debug("execute render")}render(t=!1){this.renderScheduler.scheduleTask("MANUAL_RENDER",[t])}immediateRender(t=!1){this.renderScheduler.immediateExecuteTask("MANUAL_RENDER",[t],t)}destroy(){Q.debug("Renderer destroy"),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.renderScheduler.destroy(),this.scrollbar.destroy(),this.guideLine.destroy(),this.chart.destroy(),this.table.destroy(),this.context.event.offAll()}}class ng{constructor(t,e,s){M(this,"_id",te()),M(this,"store"),M(this,"event",new ju),M(this,"renderer"),this.container=t,this.events=e,this.container.innerHTML="",this.store=new Pf(this,s),this.renderer=new sg(this,this.container),this.render(),this.registerEvents(),Q.debug("----Gantt initialized for element:",this._id,this.container)}getScrollbar(){var t;return(t=this.renderer)==null?void 0:t.getScrollbar()}getRootElement(){var t;return(t=this.renderer)==null?void 0:t.getRootElement()}getOptions(){return this.store.getOptionManager().getOptions()}setOptions(t,e){this.store.setOption(t,e)}render(){this.renderer.render()}updateOptions(t,e){this.setOptions(t,e),Q.debug("GanttChart options updated"),this.render()}destroy(){Q.debug("Gantt destroying..."),this.event.offAll(),this.renderer.destroy(),this.container.innerHTML=""}jumpTo(t){const e=et(t);if(!this.store.getTimeAxis().isInTimeAxis(e))return!1;const s=this.store.getTimeAxis().getTimeLeft(e)-100;return this.renderer.getScrollbar().scrollTo({x:Math.max(s,0)}),!0}scrollTo(t,e){var s;let n=0,r;const a=Math.max(100,((s=this.getOptions().scrollbar)==null?void 0:s.animationDuration)||100);if(t){if(r=this.store.getDataManager().getTaskById(t),!r)return!1;n=r.flatIndex*this.store.getOptionManager().getOptions().row.height-100,setTimeout(()=>{this.jumpTo(r==null?void 0:r.startTime)},a)}return this.renderer.getScrollbar().scrollTo({y:n}),e&&r&&setTimeout(()=>{this.event.emit(V.SLIDER_BLINK,r.id)},a*2),!0}getDataChain(t){return this.store.getLinkManager().getDataChain(t)}_emit(t,...e){var s;this.events.has(t)&&((s=this.events.get(t))==null||s.forEach(n=>n(...e)))}registerEvents(){this.event.on(V.ERROR,(t,e)=>{this._emit("error",t,e)}),this.event.on(V.LOADED,()=>{this._emit("loaded")}),this.event.on(V.TASK_DRAG_END,(t,e)=>{this._emit("move",e.map(s=>{var n;return{row:(n=this.store.getDataManager().getTaskById(s.id))==null?void 0:n.data,old:s.data}}))}),this.event.on(V.ROW_DRAG_END,(t,e)=>{this._emit("drag:row",t.data,e.data)}),this.event.on(V.CHECK_TASK,(t,e)=>{this._emit("select",t.map(s=>s.data),e,this.store.getDataManager().getCheckedList().map(s=>s.data))}),this.event.on(V.UPDATE_LINK,t=>{this._emit("update:link",t)}),this.event.on(V.CREATE_LINK,t=>{this._emit("create:link",t)}),this.event.on(V.SELECT_LINK,(t,e,s)=>{this._emit("select:link",t,e,s)}),this.event.on(V.CONTEXT_LINK,(t,e)=>{this._emit("contextmenu:link",t,e)}),this.event.on(V.ROW_CLICK,(t,e,s)=>{this._emit("click:row",t,e.data,s)}),this.event.on(V.ROW_DBL_CLICK,(t,e,s)=>{this._emit("dblclick:row",t,e.data,s)}),this.event.on(V.ROW_CONTEXTMENU,(t,e,s)=>{this._emit("contextmenu:row",t,e.data,s)}),this.event.on(V.SLIDER_CLICK,(t,e)=>{this._emit("click:slider",t,e.data)}),this.event.on(V.SLIDER_DBL_CLICK,(t,e)=>{this._emit("dblclick:slider",t,e.data)}),this.event.on(V.SLIDER_CONTEXTMENU,(t,e)=>{this._emit("contextmenu:slider",t,e.data)}),this.event.on(V.SLIDER_ENTER,(t,e)=>{this._emit("enter:slider",t,e.data)}),this.event.on(V.SLIDER_HOVER,(t,e)=>{this._emit("hover:slider",t,e.data)}),this.event.on(V.SLIDER_LEAVE,(t,e)=>{this._emit("leave:slider",t,e.data)}),this.event.on(V.BASELINE_CLICK,(t,e,s)=>{this._emit("click:baseline",t,e.data,s.data)}),this.event.on(V.BASELINE_CONTEXTMENU,(t,e,s)=>{this._emit("contextmenu:baseline",t,e.data,s.data)}),this.event.on(V.BASELINE_MOUSEENTER,(t,e,s)=>{this._emit("enter:baseline",t,e.data,s.data)}),this.event.on(V.BASELINE_MOUSEMOVE,(t,e,s)=>{this._emit("hover:baseline",t,e.data,s.data)}),this.event.on(V.BASELINE_MOUSEOUT,(t,e,s)=>{this._emit("leave:baseline",t,e.data,s.data)})}}class rg{constructor(t,e){M(this,"context"),M(this,"events",new Map),e!=null&&e.logLevel&&Q.setOptions({showTimestamp:e.logLevel==="debug",level:{debug:1,info:2,warn:3,error:4,none:5}[e.logLevel]||3});const s=typeof t=="string"?document.querySelector(t):t;if(!s)throw Q.exception(`Container ${t} not found or invalid.`);s.innerHTML="",s.classList.add("x-gantt-container"),this.context=new ng(s,this.events,e)}update(t,e={merge:!0}){this.context.updateOptions(t,e)}render(){this.context.render(),Q.info("Gantt rendered successfully.")}destroy(){Q.info("Gantt destroying..."),this.events.clear(),this.context.destroy(),Q.info("Gantt destroyed successfully.")}jumpTo(t){return this.context.jumpTo(t)}scrollTo(t,e){return this.context.scrollTo(t,e)}getDataChain(t){return this.context.getDataChain(t)}on(t,e){var s;this.events.has(t)||this.events.set(t,[]),(s=this.events.get(t))==null||s.push(e)}off(t,e){if(this.events.has(t))if(e){const s=this.events.get(t);s&&this.events.set(t,s.filter(n=>n!==e))}else this.events.delete(t)}getDataById(t){var e;return(e=this.context.store.getDataManager().getTaskById(t))==null?void 0:e.data}getDataSize(){return this.context.store.getDataManager().getDataSize()}removeDataById(t){return this.context.store.getDataManager().deleteTaskById(t)}}Vu();const Eo=rt.forwardRef((i,t)=>{const{options:e,className:s,style:n,onLoaded:r,onError:a,onUpdateLink:o,onCreateLink:h,onSelectLink:l,onContextMenuLink:d,onSelect:p,onClickRow:u,onDoubleClickRow:g,onContextMenuRow:f,onClickSlider:m,onDoubleClickSlider:b,onContextMenuSlider:S,onMove:y,onEnterSlider:c,onHoverSlider:v,onLeaveSlider:x,onClickBaseline:T,onContextMenuBaseline:O,onEnterBaseline:_,onHoverBaseline:C,onLeaveBaseline:k,onDragRow:L,...F}=i,N=rt.useRef(null),P=rt.useRef(null),A=rt.useCallback(()=>{const U=P.current;U&&(r&&U.on("loaded",r),a&&U.on("error",a),o&&U.on("update:link",o),h&&U.on("create:link",h),l&&U.on("select:link",l),d&&U.on("contextmenu:link",d),p&&U.on("select",p),u&&U.on("click:row",u),g&&U.on("dblclick:row",g),f&&U.on("contextmenu:row",f),L&&U.on("drag:row",L),m&&U.on("click:slider",m),b&&U.on("dblclick:slider",b),S&&U.on("contextmenu:slider",S),y&&U.on("move",y),c&&U.on("enter:slider",c),v&&U.on("hover:slider",v),x&&U.on("leave:slider",x),T&&U.on("click:baseline",T),O&&U.on("contextmenu:baseline",O),_&&U.on("enter:baseline",_),C&&U.on("hover:baseline",C),k&&U.on("leave:baseline",k))},[r,a,o,h,l,d,p,u,g,f,L,m,b,S,y,c,v,x,T,O,_,C,k]),$=rt.useCallback(()=>{N.current&&(P.current=new rg(N.current,e),A())},[e,A]),w=rt.useCallback(U=>P.current?P.current.jumpTo(U):!1,[]),E=rt.useCallback(U=>P.current?P.current.getDataChain(U):{prev:{chain:[],nodes:[],links:[]},next:{chain:[],nodes:[],links:[]},allNodes:[],allLinks:[],current:void 0},[]),R=rt.useCallback((U,j)=>P.current?P.current.scrollTo(U,j):!1,[]),D=rt.useCallback(U=>P.current?P.current.getDataById(U):null,[]),G=rt.useCallback(()=>P.current?P.current.getDataSize():0,[]),B=rt.useCallback(()=>{P.current&&(P.current.destroy(),P.current=null)},[]),H=rt.useCallback(U=>P.current?P.current.removeDataById(U):!1,[]);return rt.useImperativeHandle(t,()=>({getInstance:()=>P.current,jumpTo:w,getDataChain:E,scrollTo:R,getDataById:D,getDataSize:G,removeDataById:H}),[w]),rt.useEffect(()=>($(),()=>{B()}),[]),rt.useEffect(()=>{P.current&&P.current.update(e)},[e]),Ot.jsx("div",{ref:N,"data-testid":"x-gantt-container",className:`x-gantt-container ${s||""}`,style:{position:"relative",width:"100%",height:"100%",...n},...F})});Eo.displayName="XGanttReact";function og(){const i=rt.useRef(null),t=rt.useCallback(()=>{var h;return((h=i.current)==null?void 0:h.getInstance())||null},[]),e=rt.useCallback(h=>{var l;return((l=i.current)==null?void 0:l.jumpTo(h))||!1},[]),s=rt.useCallback(h=>{var l;return((l=i.current)==null?void 0:l.getDataChain(h))||[]},[]),n=rt.useCallback((h,l)=>{var d;return((d=i.current)==null?void 0:d.scrollTo(h,l))||!1},[]),r=rt.useCallback(h=>{var l;return((l=i.current)==null?void 0:l.getDataById(h))||null},[]),a=rt.useCallback(()=>{var h;return((h=i.current)==null?void 0:h.getDataSize())||0},[]),o=rt.useCallback(h=>{var l;return((l=i.current)==null?void 0:l.removeDataById(h))||!1},[]);return{ganttRef:i,getInstance:t,jumpTo:e,getDataChain:s,scrollTo:n,getDataById:r,getDataSize:a,removeDataById:o}}function ag(i){const t=[],e=[];for(const s of i){let n=function(h){const l=a[h];return!l||l.length===0?[]:l.filter(d=>d.start_date&&d.end_date).map(d=>({id:d.id,name:d.title,startTime:new Date(d.start_date).toISOString().slice(0,10),endTime:new Date(d.end_date).toISOString().slice(0,10),progress:vr(d),_status:d.status,children:n(d.id)}))};const r=[],a={};for(const h of s.tasks)h.parent_task_id?(a[h.parent_task_id]||(a[h.parent_task_id]=[]),a[h.parent_task_id].push(h)):r.push(h);const o=r.filter(h=>h.start_date&&h.end_date).map(h=>({id:h.id,name:h.title,startTime:new Date(h.start_date).toISOString().slice(0,10),endTime:new Date(h.end_date).toISOString().slice(0,10),progress:vr(h),_status:h.status,children:n(h.id)}));if(o.length>0){const h=o.map(p=>[new Date(p.startTime).getTime(),new Date(p.endTime).getTime()]).flat(),l=new Date(Math.min(...h)).toISOString().slice(0,10),d=new Date(Math.max(...h)).toISOString().slice(0,10);t.push({id:s.id,name:`[${s.name}]`,startTime:l,endTime:d,progress:0,type:"summary",children:o})}for(const h of s.tasks)for(const l of h.dependencies)e.push({id:`${l}-${h.id}`,from:l,to:h.id,type:"FS"})}return{data:t,links:e}}function vr(i){return i.progress>0?i.progress:i.status==="done"?100:i.status==="abandoned"?0:i.status==="claimed"?50:0}function Ag({workspaceId:i,projectFilter:t}){const{ganttRef:e,jumpTo:s}=og(),[n,r]=rt.useState([]),[a,o]=rt.useState(!0),[h,l]=rt.useState(""),[d,p]=rt.useState("day"),{lastEvent:u}=Do("task.*"),g=rt.useRef(null),f=()=>{let c=`/workspaces/${i}/gantt`;t&&(c+=`?project_id=${t}`),Lo(c).then(v=>{r(v.projects),o(!1)}).catch(v=>{l(v.message),o(!1)})};rt.useEffect(()=>{o(!0),l(""),r([]),f()},[i,t]),rt.useEffect(()=>{u&&(g.current&&clearTimeout(g.current),g.current=setTimeout(f,500))},[u]);const{data:m,links:b}=rt.useMemo(()=>ag(n),[n]),S=rt.useMemo(()=>({data:m,unit:d,primaryColor:"#4fc3f7",table:{columns:[{field:"name",label:"任务",width:200},{field:"progress",label:"进度%",width:70,align:"center"}]},links:{data:b,show:!0,create:{enabled:!0,mode:"hover",from:!0,to:!0}},expand:{show:!0,enabled:!0}}),[m,b,d]),y=c=>{for(const{row:v}of c){if(!v.id||v.type==="summary")continue;const x=v.startTime?new Date(v.startTime).getTime():null,T=v.endTime?new Date(v.endTime).getTime():null;Ao(`/tasks/${v.id}`,{start_date:x,end_date:T}).catch(()=>{})}};return a?Ot.jsx("div",{className:"flex items-center justify-center h-64 text-gray-500 text-sm",children:"加载甘特图..."}):h?Ot.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded text-sm",children:h}):m.length===0?Ot.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-400 text-sm",children:[Ot.jsx("p",{children:"暂无可展示的甘特图数据"}),Ot.jsx("p",{className:"mt-1 text-xs",children:"请先为任务设置开始/结束时间"})]}):Ot.jsxs("div",{className:"flex flex-col h-full",children:[Ot.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[Ot.jsx("div",{className:"flex rounded border border-gray-200 overflow-hidden text-xs",children:["day","week","month"].map(c=>Ot.jsx("button",{onClick:()=>p(c),className:`px-3 py-1.5 ${d===c?"bg-blue-600 text-white":"bg-white text-gray-600 hover:bg-gray-50"}`,children:c==="day"?"日":c==="week"?"周":"月"},c))}),Ot.jsx("button",{onClick:()=>s(),className:"px-3 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50 text-gray-600",children:"今天"})]}),Ot.jsx("div",{className:"flex-1 min-h-0 border border-gray-200 rounded overflow-hidden",children:Ot.jsx(Eo,{ref:e,style:{height:"100%",width:"100%"},options:S,onMove:y,onClickSlider:(c,v)=>{console.log("点击任务:",v)}})})]})}export{Ag as G};
|