@svar-ui/gantt-store 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/DataStore.d.ts +25 -1
- package/dist/types/GanttDataTree.d.ts +2 -1
- package/dist/types/helpers/actionHandlers.d.ts +4 -1
- package/dist/types/helpers/editorItems.d.ts +3 -0
- package/dist/types/helpers/getCircularLinks.d.ts +3 -0
- package/dist/types/helpers/menuOptions.d.ts +4 -2
- package/dist/types/helpers/toolbarButtons.d.ts +5 -1
- package/dist/types/index.d.ts +9 -6
- package/dist/types/links.d.ts +8 -1
- package/dist/types/modules/AutoScheduler.pro.d.ts +15 -0
- package/dist/types/modules/ChangeTracker.pro.d.ts +10 -0
- package/dist/types/modules/CriticalPath.pro.d.ts +11 -0
- package/dist/types/modules/EventTracker.pro.d.ts +20 -0
- package/dist/types/modules/HistoryManager.pro.d.ts +48 -0
- package/dist/types/normalizeDates.d.ts +5 -3
- package/dist/types/scales.d.ts +5 -4
- package/dist/types/splitTasks.pro.d.ts +11 -0
- package/dist/types/tasks.d.ts +6 -4
- package/dist/types/time.d.ts +9 -7
- package/dist/types/types.d.ts +72 -8
- package/license.txt +4 -16
- package/package.json +5 -2
- package/readme.md +5 -0
- package/dist/types/editorItems.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var kt=new Date().valueOf(),oe=()=>kt++;function wt(){return"temp://"+kt++}var bt=class{constructor(t){this._data=t,this._pool=new Map;for(let e=0;e<t.length;e++){const n=t[e];this._pool.set(n.id,n)}}add(t){t={id:oe(),...t},this._data.push(t),this._pool.set(t.id,t)}update(t,e){const n=this._data.findIndex(s=>s.id==t),a={...this._data[n],...e};this._data[n]=a,this._pool.set(a.id,a)}remove(t){this._data=this._data.filter(e=>e.id!=t),this._pool.delete(t)}filter(t){this._data=this._data.filter(e=>{const n=t(e);return n||this._pool.delete(e.id),n})}byId(t){return this._pool.get(t)}map(t){return this._data.map(t)}forEach(t){this._data.forEach(t)}},ce=class{constructor(t){const e={id:0,$level:0,data:[],parent:null},n=new Map;n.set(0,e),this._pool=n,t&&t.length&&this.parse(t,0)}parse(t,e){const n=this._pool;for(let s=0;s<t.length;s++){const r=t[s];r.parent=r.parent||e,r.data=null,n.set(r.id,r)}for(let s=0;s<t.length;s++){const r=t[s],i=n.get(r.parent);i&&(i.data||(i.data=[]),i.data.push(r))}const a=n.get(e);this.setLevel(a,a.$level+1,!1)}add(t,e){const n=this._pool.get(t.parent||0);t.$level=n.$level+1,this._pool.set(t.id,t),n.data?e===-1?n.data=[...n.data,t]:_t(n,e,t):n.data=[t]}addAfter(t,e){if(!e)return this.add(t,-1);const n=this.byId(e),a=this.byId(n.parent),s=L(a,n.id)+1;t.parent=a.id,t.$level=a.$level+1,this.add(t,s)}remove(t){const e=this._pool.get(t);this._remove(e);const n=this._pool.get(e.parent);n.data=n.data.filter(a=>a.id!=t),this._clearBranch(n)}_remove(t){t.data&&t.data.forEach(e=>this._remove(e)),this._pool.delete(t.id)}update(t,e){let n=this._pool.get(t);const a=this._pool.get(n.parent),s=L(a,n.id);n={...n,...e},a&&s>=0&&(a.data[s]=n,a.data=[...a.data]),this._pool.set(n.id,n)}move(t,e,n){const a=this._pool.get(t),s=e==="child",r=this._pool.get(n),i=r.$level+(s?1:0);if(!a||!r)return;const o=this._pool.get(a.parent),c=s?r:this._pool.get(r.parent);c.data||(c.data=[]);const u=L(o,a.id);ue(o,u);const l=s?c.data.length:L(c,r.id)+(e==="after"?1:0);if(_t(c,l,a),o.id===c.id&&u===l)return null;a.parent=c.id,a.$level!==i&&(a.$level=i,this.setLevel(a,i+1,!0)),this.update(a.id,a),this._clearBranch(o)}_clearBranch(t){t.data&&!t.data.length&&(t.open&&delete t.open,this.update(t.id,{data:null}))}toArray(){const t=[],e=this._pool.get(0).data;return e&&xt(e,t),t}byId(t){return this._pool.get(t)}getBranch(t){return this._pool.get(t).data}forEach(t){this._pool.forEach((e,n)=>{n!==0&&t(e)})}eachChild(t,e){const n=this.byId(e);!n||!n.data||n.data.forEach((a,s)=>{t(this.byId(a.id),s),this.eachChild(t,a.id)})}setLevel(t,e,n){t.data&&(t.data=t.data.map(a=>(n&&(a={...a},this._pool.set(a.id,a)),a.$level=e,a.data&&this.setLevel(a,e+1,n),a)))}};function xt(t,e){t.forEach(n=>{e.push(n),n.open===!0&&xt(n.data,e)})}function ue(t,e){const n=[...t.data];n.splice(e,1),t.data=n}function _t(t,e,n){const a=[...t.data];a.splice(e,0,n),t.data=a}function L(t,e){return t?.data.findIndex(n=>n.id===e)}var vt=2,de=class{constructor(t){t&&(this._writable=t.writable,this._async=t.async),this._values={},this._state={}}setState(t,e=0){const n={};return this._wrapProperties(t,this._state,this._values,"",n,e),n}getState(){return this._values}getReactive(){return this._state}_wrapProperties(t,e,n,a,s,r){for(const i in t){const o=e[i],c=n[i],u=t[i];if(o&&(c===u&&typeof u!="object"||u instanceof Date&&c instanceof Date&&c.getTime()===u.getTime()))continue;const l=a+(a?".":"")+i;o?(o.__parse(u,l,s,r)&&(n[i]=u),r&vt?s[l]=o.__trigger:o.__trigger()):(u&&u.__reactive?e[i]=this._wrapNested(u,u,l,s):e[i]=this._wrapWritable(u),n[i]=u),s[l]=s[l]||null}}_wrapNested(t,e,n,a){const s=this._wrapWritable(t);return this._wrapProperties(t,s,e,n,a,0),s.__parse=(r,i,o,c)=>(this._wrapProperties(r,s,e,i,o,c),!1),s}_wrapWritable(t){const e=[],n=function(){for(let a=0;a<e.length;a++)e[a](t)};return{subscribe:a=>(e.push(a),this._async?setTimeout(a,1,t):a(t),()=>{const s=e.indexOf(a);s>=0&&e.splice(s,1)}),__trigger:()=>{e.length&&(this._async?setTimeout(n,1):n())},__parse:function(a){return t=a,!0}}}},le=class{constructor(t,e,n,a){typeof t=="function"?this._setter=t:this._setter=t.setState.bind(t),this._routes=e,this._parsers=n,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(s=>{s.in.forEach(r=>{const i=this._triggers.get(r)||[];i.push(s),this._triggers.set(r,i)}),s.out.forEach(r=>{const i=this._sources.get(r)||{};s.in.forEach(o=>i[o]=!0),this._sources.set(r,i)})}),this._routes.forEach(s=>{s.length=Math.max(...s.in.map(r=>St(r,this._sources,1)))}),this._bus=a}init(t){const e={};for(const n in t)if(this._prev[n]!==t[n]){const a=this._parsers[n];e[n]=a?a(t[n]):t[n]}this._prev=this._prev?{...this._prev,...t}:{...t},this.setState(e),this._bus&&this._bus.exec("init-state",e)}setStateAsync(t){const e=this._setter(t,vt);return this._async?Object.assign(this._async.signals,e):this._async={signals:e,timer:setTimeout(this._applyState.bind(this),1)},e}_applyState(){const t=this._async;if(t){this._async=null,this._triggerUpdates(t.signals,[]);for(const e in t.signals){const n=t.signals[e];n&&n()}}}setState(t,e=[]){const n=this._setter(t);return this._triggerUpdates(n,e),n}_triggerUpdates(t,e){const n=Object.keys(t),a=!e.length;e=e||[];for(let s=0;s<n.length;s++){const r=n[s],i=this._triggers.get(r);i&&i.forEach(o=>{e.indexOf(o)==-1&&e.push(o)})}a&&this._execNext(e)}_execNext(t){for(;t.length;){t.sort((n,a)=>n.length<a.length?1:-1);const e=t[t.length-1];t.splice(t.length-1),e.exec(t)}}};function St(t,e,n){const a=e.get(t);if(!a)return n;const s=Object.keys(a).map(r=>St(r,e,n+1));return Math.max(...s)}var he=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(t,e,n){let a=this._handlers[t];a?n&&n.intercept?a.unshift(e):a.push(e):a=this._handlers[t]=[e],n&&n.tag&&this._tag.set(e,n.tag)}intercept(t,e,n){this.on(t,e,{...n,intercept:!0})}detach(t){for(const e in this._handlers){const n=this._handlers[e];for(let a=n.length-1;a>=0;a--)this._tag.get(n[a])===t&&n.splice(a,1)}}async exec(t,e){const n=this._handlers[t];if(n)for(let a=0;a<n.length;a++){const s=n[a](e);if(s===!1||s&&s.then&&await s===!1)return}return this._nextHandler&&await this._nextHandler.exec(t,e),e}setNext(t){return this._nextHandler=t}};function fe(t,e){return typeof t=="string"?t.localeCompare(e,void 0,{numeric:!0}):typeof t=="object"?t.getTime()-e.getTime():(t??0)-(e??0)}function me(t,e){return typeof t=="string"?-t.localeCompare(e,void 0,{numeric:!0}):typeof e=="object"?e.getTime()-t.getTime():(e??0)-(t??0)}function ge({key:t,order:e}){const n=e==="asc"?fe:me;return(a,s)=>n(a[t],s[t])}function pe(t){if(!t||!t.length)return;const e=t.map(n=>ge(n));return t.length===1?e[0]:function(n,a){for(let s=0;s<e.length;s++){const r=e[s](n,a);if(r!==0)return r}return 0}}function ye(t,e){return t.sort(pe(e))}function y(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function S(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function U(t,e){const n=y(t);return isNaN(e)?S(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function et(t,e){const n=y(t);if(isNaN(e))return S(t,NaN);if(!e)return n;const a=n.getDate(),s=S(t,n.getTime());s.setMonth(n.getMonth()+e+1,0);const r=s.getDate();return a>=r?s:(n.setFullYear(s.getFullYear(),s.getMonth(),a),n)}function Mt(t,e){const n=+y(t);return S(t,n+e)}const j=6048e5,ke=864e5,Wt=6e4,Dt=36e5;function we(t,e){return Mt(t,e*Dt)}let be={};function X(){return be}function $(t,e){const n=X(),a=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=y(t),r=s.getDay(),i=(r<a?7:0)+r-a;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function E(t){return $(t,{weekStartsOn:1})}function $t(t){const e=y(t),n=e.getFullYear(),a=S(t,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const s=E(a),r=S(t,0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);const i=E(r);return e.getTime()>=s.getTime()?n+1:e.getTime()>=i.getTime()?n:n-1}function I(t){const e=y(t);return e.setHours(0,0,0,0),e}function Q(t){const e=y(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function nt(t,e){const n=I(t),a=I(e),s=+n-Q(n),r=+a-Q(a);return Math.round((s-r)/ke)}function at(t){const e=$t(t),n=S(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),E(n)}function xe(t,e){return Mt(t,e*Wt)}function _e(t,e){const n=e*3;return et(t,n)}function Tt(t,e){const n=e*7;return U(t,n)}function ve(t,e){return et(t,e*12)}function z(t,e){const n=y(t),a=y(e),s=n.getTime()-a.getTime();return s<0?-1:s>0?1:s}function Se(t,e){const n=I(t),a=I(e);return+n==+a}function Me(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function We(t){if(!Me(t)&&typeof t!="number")return!1;const e=y(t);return!isNaN(Number(e))}function st(t,e){const n=E(t),a=E(e),s=+n-Q(n),r=+a-Q(a);return Math.round((s-r)/j)}function De(t,e){const n=y(t),a=y(e),s=n.getFullYear()-a.getFullYear(),r=n.getMonth()-a.getMonth();return s*12+r}function $e(t,e){const n=y(t),a=y(e);return n.getFullYear()-a.getFullYear()}function rt(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function Ct(t,e){return+y(t)-+y(e)}function Te(t,e,n){const a=Ct(t,e)/Dt;return rt(n?.roundingMethod)(a)}function Ce(t,e,n){const a=Ct(t,e)/Wt;return rt(n?.roundingMethod)(a)}function It(t){const e=y(t);return e.setHours(23,59,59,999),e}function it(t){const e=y(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function Ie(t){const e=y(t);return+It(e)==+it(e)}function Pt(t,e){const n=y(t),a=y(e),s=z(n,a),r=Math.abs(De(n,a));let i;if(r<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-s*r);let o=z(n,a)===-s;Ie(y(t))&&r===1&&z(t,a)===1&&(o=!1),i=s*(r-Number(o))}return i===0?0:i}function Pe(t,e,n){const a=Pt(t,e)/3;return rt(n?.roundingMethod)(a)}function Ee(t,e){const n=y(t),a=y(e),s=z(n,a),r=Math.abs($e(n,a));n.setFullYear(1584),a.setFullYear(1584);const i=z(n,a)===-s,o=s*(r-+i);return o===0?0:o}function H(t){const e=y(t),n=e.getMonth(),a=n-n%3;return e.setMonth(a,1),e.setHours(0,0,0,0),e}function Et(t){const e=y(t);return e.setDate(1),e.setHours(0,0,0,0),e}function Oe(t){const e=y(t),n=e.getFullYear();return e.setFullYear(n+1,0,0),e.setHours(23,59,59,999),e}function Ot(t){const e=y(t),n=S(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ye(t){const e=y(t);return e.setMinutes(59,59,999),e}function Ne(t,e){const n=e?.weekStartsOn,a=y(t),s=a.getDay(),r=(s<n?-7:0)+6-(s-n);return a.setDate(a.getDate()+r),a.setHours(23,59,59,999),a}function ot(t){const e=y(t),n=e.getMonth(),a=n-n%3+3;return e.setMonth(a,0),e.setHours(23,59,59,999),e}const ze={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},He=(t,e,n)=>{let a;const s=ze[t];return typeof s=="string"?a=s:e===1?a=s.one:a=s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function ct(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Ae={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Fe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Be={date:ct({formats:Ae,defaultWidth:"full"}),time:ct({formats:Fe,defaultWidth:"full"}),dateTime:ct({formats:qe,defaultWidth:"full"})},Le={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ue=(t,e,n,a)=>Le[t];function A(t){return(e,n)=>{const a=n?.context?String(n.context):"standalone";let s;if(a==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,o=n?.width?String(n.width):i;s=t.formattingValues[o]||t.formattingValues[i]}else{const i=t.defaultWidth,o=n?.width?String(n.width):t.defaultWidth;s=t.values[o]||t.values[i]}const r=t.argumentCallback?t.argumentCallback(e):e;return s[r]}}const je={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Xe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Qe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Ge={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Re={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Je={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Ve=(t,e)=>{const n=Number(t),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Ke={ordinalNumber:Ve,era:A({values:je,defaultWidth:"wide"}),quarter:A({values:Xe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:A({values:Qe,defaultWidth:"wide"}),day:A({values:Ge,defaultWidth:"wide"}),dayPeriod:A({values:Re,defaultWidth:"wide",formattingValues:Je,defaultFormattingWidth:"wide"})};function F(t){return(e,n={})=>{const a=n.width,s=a&&t.matchPatterns[a]||t.matchPatterns[t.defaultMatchWidth],r=e.match(s);if(!r)return null;const i=r[0],o=a&&t.parsePatterns[a]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?tn(o,h=>h.test(i)):Ze(o,h=>h.test(i));let u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const l=e.slice(i.length);return{value:u,rest:l}}}function Ze(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function tn(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function en(t){return(e,n={})=>{const a=e.match(t.matchPattern);if(!a)return null;const s=a[0],r=e.match(t.parsePattern);if(!r)return null;let i=t.valueCallback?t.valueCallback(r[0]):r[0];i=n.valueCallback?n.valueCallback(i):i;const o=e.slice(s.length);return{value:i,rest:o}}}const nn=/^(\d+)(th|st|nd|rd)?/i,an=/\d+/i,sn={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},rn={any:[/^b/i,/^(a|c)/i]},on={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},cn={any:[/1/i,/2/i,/3/i,/4/i]},un={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},dn={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ln={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},hn={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},fn={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},mn={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},gn={ordinalNumber:en({matchPattern:nn,parsePattern:an,valueCallback:t=>parseInt(t,10)}),era:F({matchPatterns:sn,defaultMatchWidth:"wide",parsePatterns:rn,defaultParseWidth:"any"}),quarter:F({matchPatterns:on,defaultMatchWidth:"wide",parsePatterns:cn,defaultParseWidth:"any",valueCallback:t=>t+1}),month:F({matchPatterns:un,defaultMatchWidth:"wide",parsePatterns:dn,defaultParseWidth:"any"}),day:F({matchPatterns:ln,defaultMatchWidth:"wide",parsePatterns:hn,defaultParseWidth:"any"}),dayPeriod:F({matchPatterns:fn,defaultMatchWidth:"any",parsePatterns:mn,defaultParseWidth:"any"})},pn={code:"en-US",formatDistance:He,formatLong:Be,formatRelative:Ue,localize:Ke,match:gn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function yn(t){const e=y(t);return nt(e,Ot(e))+1}function kn(t){const e=y(t),n=+E(e)-+at(e);return Math.round(n/j)+1}function Yt(t,e){const n=y(t),a=n.getFullYear(),s=X(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=S(t,0);i.setFullYear(a+1,0,r),i.setHours(0,0,0,0);const o=$(i,e),c=S(t,0);c.setFullYear(a,0,r),c.setHours(0,0,0,0);const u=$(c,e);return n.getTime()>=o.getTime()?a+1:n.getTime()>=u.getTime()?a:a-1}function wn(t,e){const n=X(),a=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Yt(t,e),r=S(t,0);return r.setFullYear(s,0,a),r.setHours(0,0,0,0),$(r,e)}function bn(t,e){const n=y(t),a=+$(n,e)-+wn(n,e);return Math.round(a/j)+1}function b(t,e){const n=t<0?"-":"",a=Math.abs(t).toString().padStart(e,"0");return n+a}const T={y(t,e){const n=t.getFullYear(),a=n>0?n:1-n;return b(e==="yy"?a%100:a,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):b(n+1,2)},d(t,e){return b(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return b(t.getHours()%12||12,e.length)},H(t,e){return b(t.getHours(),e.length)},m(t,e){return b(t.getMinutes(),e.length)},s(t,e){return b(t.getSeconds(),e.length)},S(t,e){const n=e.length,a=t.getMilliseconds(),s=Math.trunc(a*Math.pow(10,n-3));return b(s,e.length)}},O={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Nt={G:function(t,e,n){const a=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});case"GGGG":default:return n.era(a,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const a=t.getFullYear(),s=a>0?a:1-a;return n.ordinalNumber(s,{unit:"year"})}return T.y(t,e)},Y:function(t,e,n,a){const s=Yt(t,a),r=s>0?s:1-s;if(e==="YY"){const i=r%100;return b(i,2)}return e==="Yo"?n.ordinalNumber(r,{unit:"year"}):b(r,e.length)},R:function(t,e){const n=$t(t);return b(n,e.length)},u:function(t,e){const n=t.getFullYear();return b(n,e.length)},Q:function(t,e,n){const a=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(a);case"QQ":return b(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(t,e,n){const a=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(a);case"qq":return b(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(t,e,n){const a=t.getMonth();switch(e){case"M":case"MM":return T.M(t,e);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(t,e,n){const a=t.getMonth();switch(e){case"L":return String(a+1);case"LL":return b(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(t,e,n,a){const s=bn(t,a);return e==="wo"?n.ordinalNumber(s,{unit:"week"}):b(s,e.length)},I:function(t,e,n){const a=kn(t);return e==="Io"?n.ordinalNumber(a,{unit:"week"}):b(a,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):T.d(t,e)},D:function(t,e,n){const a=yn(t);return e==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):b(a,e.length)},E:function(t,e,n){const a=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});case"EEEE":default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(t,e,n,a){const s=t.getDay(),r=(s-a.weekStartsOn+8)%7||7;switch(e){case"e":return String(r);case"ee":return b(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,a){const s=t.getDay(),r=(s-a.weekStartsOn+8)%7||7;switch(e){case"c":return String(r);case"cc":return b(r,e.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const a=t.getDay(),s=a===0?7:a;switch(e){case"i":return String(s);case"ii":return b(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});case"iiii":default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const a=t.getHours();let s;switch(a===12?s=O.noon:a===0?s=O.midnight:s=a/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const a=t.getHours();let s;switch(a>=17?s=O.evening:a>=12?s=O.afternoon:a>=4?s=O.morning:s=O.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let a=t.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return T.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):T.H(t,e)},K:function(t,e,n){const a=t.getHours()%12;return e==="Ko"?n.ordinalNumber(a,{unit:"hour"}):b(a,e.length)},k:function(t,e,n){let a=t.getHours();return a===0&&(a=24),e==="ko"?n.ordinalNumber(a,{unit:"hour"}):b(a,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):T.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):T.s(t,e)},S:function(t,e){return T.S(t,e)},X:function(t,e,n){const a=t.getTimezoneOffset();if(a===0)return"Z";switch(e){case"X":return Ht(a);case"XXXX":case"XX":return P(a);case"XXXXX":case"XXX":default:return P(a,":")}},x:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"x":return Ht(a);case"xxxx":case"xx":return P(a);case"xxxxx":case"xxx":default:return P(a,":")}},O:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+zt(a,":");case"OOOO":default:return"GMT"+P(a,":")}},z:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+zt(a,":");case"zzzz":default:return"GMT"+P(a,":")}},t:function(t,e,n){const a=Math.trunc(t.getTime()/1e3);return b(a,e.length)},T:function(t,e,n){const a=t.getTime();return b(a,e.length)}};function zt(t,e=""){const n=t>0?"-":"+",a=Math.abs(t),s=Math.trunc(a/60),r=a%60;return r===0?n+String(s):n+String(s)+e+b(r,2)}function Ht(t,e){return t%60===0?(t>0?"-":"+")+b(Math.abs(t)/60,2):P(t,e)}function P(t,e=""){const n=t>0?"-":"+",a=Math.abs(t),s=b(Math.trunc(a/60),2),r=b(a%60,2);return n+s+e+r}const At=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},Ft=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},xn=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],a=n[1],s=n[2];if(!s)return At(t,e);let r;switch(a){case"P":r=e.dateTime({width:"short"});break;case"PP":r=e.dateTime({width:"medium"});break;case"PPP":r=e.dateTime({width:"long"});break;case"PPPP":default:r=e.dateTime({width:"full"});break}return r.replace("{{date}}",At(a,e)).replace("{{time}}",Ft(s,e))},_n={p:Ft,P:xn},vn=/^D+$/,Sn=/^Y+$/,Mn=["D","DD","YY","YYYY"];function Wn(t){return vn.test(t)}function Dn(t){return Sn.test(t)}function $n(t,e,n){const a=Tn(t,e,n);if(console.warn(a),Mn.includes(t))throw new RangeError(a)}function Tn(t,e,n){const a=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Cn=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,In=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Pn=/^'([^]*?)'?$/,En=/''/g,On=/[a-zA-Z]/;function G(t,e,n){const a=X(),s=n?.locale??a.locale??pn,r=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,o=y(t);if(!We(o))throw new RangeError("Invalid time value");let c=e.match(In).map(l=>{const h=l[0];if(h==="p"||h==="P"){const d=_n[h];return d(l,s.formatLong)}return l}).join("").match(Cn).map(l=>{if(l==="''")return{isToken:!1,value:"'"};const h=l[0];if(h==="'")return{isToken:!1,value:Yn(l)};if(Nt[h])return{isToken:!0,value:l};if(h.match(On))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:l}});s.localize.preprocessor&&(c=s.localize.preprocessor(o,c));const u={firstWeekContainsDate:r,weekStartsOn:i,locale:s};return c.map(l=>{if(!l.isToken)return l.value;const h=l.value;(!n?.useAdditionalWeekYearTokens&&Dn(h)||!n?.useAdditionalDayOfYearTokens&&Wn(h))&&$n(h,e,String(t));const d=Nt[h[0]];return d(o,h,s.localize,u)}).join("")}function Yn(t){const e=t.match(Pn);return e?e[1].replace(En,"'"):t}function qt(t){const e=y(t),n=e.getFullYear(),a=e.getMonth(),s=S(t,0);return s.setFullYear(n,a+1,0),s.setHours(0,0,0,0),s.getDate()}function Nn(t){const e=y(t).getFullYear();return e%400===0||e%4===0&&e%100!==0}function Bt(t){const e=y(t);return String(new Date(e))==="Invalid Date"?NaN:Nn(e)?366:365}function zn(t){const e=at(t),n=+at(Tt(e,60))-+e;return Math.round(n/j)}function Y(t,e){const n=y(t),a=y(e);return+n==+a}function Hn(t){const e=y(t);return e.setMinutes(0,0,0),e}function An(t,e,n){const a=$(t,n),s=$(e,n);return+a==+s}function Fn(t,e){const n=y(t),a=y(e);return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()}function qn(t,e){const n=H(t),a=H(e);return+n==+a}function Bn(t,e){const n=y(t),a=y(e);return n.getFullYear()===a.getFullYear()}const ut=8,Lt=4,Ln=3,Ut=7,Un=ut+Lt;function jt(t,e){(t.open||t.type!="summary")&&t.data?.forEach(n=>{n.$x+=e,jt(n,e)})}function dt(t,e,n,a){const s=t.getSummaryId(e.id);if(s){const r=t.byId(s),i={xMin:1/0,xMax:0};Xt(r,i,n,a),r.$x=i.xMin,r.$w=i.xMax-i.xMin,dt(t,r,n,a)}}function Xt(t,e,n,a){const{lengthUnit:s,start:r}=n;t.data?.forEach(i=>{if(!i.unscheduled){typeof i.$x>"u"&&(i.$x=Math.round(n.diff(i.start,r,s)*a),i.$w=Math.round(n.diff(i.end,i.start,s,!0)*a));const o=i.type==="milestone"&&i.$h?i.$h/2:0;e.xMin>i.$x&&(e.xMin=i.$x+o);const c=i.$x+i.$w-o;e.xMax<c&&(e.xMax=c)}i.type!=="summary"&&Xt(i,e,n,a)})}function lt(t,e){let n;e&&(n=e.filter(s=>s.parent==t.id));const a={data:n,...t};if(a.data?.length)a.data.forEach(s=>{if(s.unscheduled&&!s.data)return;(e||s.type!="summary"&&s.data)&&(s.unscheduled&&(s={...s,start:void 0,end:void 0}),s=lt(s,e)),s.start&&(!a.start||a.start>s.start)&&(a.start=new Date(s.start));const r=s.type==="milestone"?s.start:s.end;r&&(!a.end||a.end<r)&&(a.end=new Date(r))});else if(t.type==="summary")throw Error("Summary tasks must have start and end dates if they have no subtasks");return a}function jn(t,e,n,a,s,r){return Qt(t,e,n,a,s,r,!1),r&&Qt(t,e,n,a,s,r,!0),t}function Qt(t,e,n,a,s,r,i){const{start:o,end:c,lengthUnit:u,diff:l}=s,h=(i?"base_":"")+"start",d=(i?"base_":"")+"end",p="$x"+(i?"_base":""),m="$y"+(i?"_base":""),f="$w"+(i?"_base":""),k="$h"+(i?"_base":""),g="$skip"+(i?"_baseline":"");let w=t[h],x=t[d];if(i&&!w){t[g]=!0;return}t[h]<o&&(t[d]<o||Y(t[d],o))?w=x=o:t[h]>c&&(w=x=c),t[p]=Math.round(l(w,o,u)*n),t[m]=i?t.$y+t.$h+Lt:a*e+Ln,t[f]=Math.round(l(x,w,u,!0)*n),t[k]=i?ut:r?a-Ut-Un:a-Ut,t.type==="milestone"&&(t[p]=t[p]-t.$h/2,t[f]=t.$h,i&&(t[m]=t.$y+ut,t[f]=t[k]=t.$h)),t.unscheduled&&!i?t.$skip=!0:t[g]=Y(w,x)}class Xn extends ce{_sort;constructor(e){super(),this.parse(e,0)}parse(e,n){if(!e||!e.length)return;const a=e.map(s=>this.normalizeTask(s,e));super.parse(a,n),this._sort&&this.sortBranch(this._sort,n)}getBranch(e){const n=this._pool.get(e);return this._pool.get(n.parent||0).data}contains(e,n){const a=this._pool.get(e).data;let s=!1;if(a)for(let r=0;r<a.length;r++){if(a[r].id===n){s=!0;break}if(a[r].data&&(s=this.contains(a[r].id,n),s))break}return s}getIndexById(e){return this.getBranch(e).findIndex(n=>n.id===e)}add(e,n){const a=this.normalizeTask(e);return super.add(a,n),a}copy(e,n,a){const s=this.add({...e,id:null,data:null,parent:n},a);let r=[[e.id,s.id]];return e.data?.forEach((i,o)=>{const c=this.copy(i,s.id,o);r=r.concat(c)}),r}normalizeTask(e,n){const a=e.id||wt(),s=e.parent||0,r=e.text||"",i=e.type||"task",o=e.progress||0,c=e.details||"",u={...e,id:a,text:r,parent:s,progress:o,type:i,details:c};if(u.type==="summary"&&!(u.start&&u.end)){const{start:l,end:h}=lt({...u},n);u.start=l,u.end=h}return u}getSummaryId(e){const n=this._pool.get(e);if(!n.parent)return null;const a=this._pool.get(n.parent);return a.type==="summary"?a.id:this.getSummaryId(a.id)}sort(e){this._sort=e,e&&this.sortBranch(e,0)}sortBranch(e,n){const a=this._pool.get(n||0).data;a&&(ye(a,e),a.forEach(s=>{this.sortBranch(e,s.id)}))}serialize(){const e=[],n=this._pool.get(0).data;return n&&Gt(n,e),e}}function Gt(t,e){t.forEach(n=>{e.push(n),n.data&&Gt(n.data,e)})}const ht={year:Ee,quarter:Pe,month:Pt,week:st,day:nt,hour:Te,minute:Ce},C={year:{quarter:4,month:12,week:zn,day:Qn,hour:Gn},quarter:{month:3,week:Rn,day:Rt,hour:Jn},month:{week:Vn,day:Kn,hour:Zn},week:{day:7,hour:24*7},day:{hour:24},hour:{minute:60}};function Qn(t){return t?Bt(t):365}function Gn(t){return Bt(t)*24}function Rn(t){const e=H(t),n=U(I(ot(t)),1);return st(n,e)}function Rt(t){if(t){const e=H(t),n=ot(t);return nt(n,e)+1}return 91}function Jn(t){return Rt(t)*24}function Vn(t){if(t){const e=Et(t),n=U(I(it(t)),1);return st(n,e)}return 5}function Kn(t){return t?qt(t):30}function Zn(t){return qt(t)*24}function R(t,e,n){const a=C[t][e];return a?typeof a=="number"?a:a(n):1}function ta(t,e){return t===e||!!(C[t]&&C[t][e])}const J={year:ve,quarter:_e,month:et,week:Tt,day:U,hour:we,minute:xe};function V(t){return(e,n,a,s)=>!C[t][a]||typeof C[t][a]=="number"||Kt(t,e,n)?q(t,e,n,a,s):ea(e,n,t,a,s)}function q(t,e,n,a,s){const r=a||t;let i=n,o=e;if(s&&(i=D(r,n),o=D(r,e),o<e&&(o=M(r)(o,1))),t!==r){const c=ht[r](o,i),u=R(t,r,n);return c/u}else return ht[r](o,i)}function ea(t,e,n,a,s){let r=0;const i=D(n,e);if(e>i){const c=J[n](i,1);r=q(n,c,e,a),e=c}let o=0;return Kt(n,e,t)||(o=q(n,D(n,t),e),e=J[n](e,o)),o+=r+q(n,t,e,a),!o&&s&&(o=q(n,t,e,a,s)),o}function M(t){return J[t]}const Jt={year:Ot,quarter:H,month:Et,week:t=>$(t,{weekStartsOn:1}),day:I,hour:Hn};function D(t,e){const n=Jt[t];return n?n(e):new Date(e)}const na={year:Oe,quarter:ot,month:it,week:t=>Ne(t,{weekStartsOn:1}),day:It,hour:Ye},Vt={year:Bn,quarter:qn,month:Fn,week:(t,e)=>An(t,e,{weekStartsOn:1}),day:Se};function Kt(t,e,n){const a=Vt[t];return a?a(e,n):!1}const aa={start:Jt,end:na,add:J,isSame:Vt,diff:ht,smallerCount:C},Zt=t=>typeof t=="function"?t(new Date):t;function sa(t,e){for(const n in e){if(n==="smallerCount"){const a=Object.keys(e[n]).sort((o,c)=>W.indexOf(o)-W.indexOf(c)).shift();let s=W.indexOf(a);const r=e[n][a],i=Zt(r);for(let o=s-1;o>=0;o--){const c=W[o],u=Zt(C[c][a]);if(i<=u)break;s=o}W.splice(s,0,t)}if(n==="biggerCount")for(const a in e[n])C[a][t]=e[n][a];else aa[n][t]=e[n]}}function N(t){const e=new Date;return t.map(n=>({item:n,len:M(n.unit)(e,1)})).sort((n,a)=>n.len<a.len?-1:1)[0].item}const W=["year","quarter","month","week","day","hour"],K={year:"yyyy",quarter:"QQQ",month:"MMM",week:"w",day:"MMM d",hour:"HH:mm"},ft=50,mt=300;function ra(t,e,n,a,s){let r=t,i=e,o=!1,c=!1;s&&s.forEach(l=>{(!t||n)&&(!r||l.start<=r)&&(r=l.start,o=!0);const h=l.type==="milestone"?l.start:l.end;(!e||n)&&(!i||h>=i)&&(i=h,c=!0)});const u=M(a||"day");return r?o&&(r=u(r,-1)):i?r=u(i,-30):r=new Date,i?c&&(i=u(i,1)):i=u(r,30),{_start:r,_end:i}}function ia(t,e,n,a,s,r){const i=N(r).unit,o=V(i),c=o(e,t,"",!0),u=D(i,e);t=D(i,t),e=u<e?M(i)(u,1):u;const l=c*a,h=s*r.length,d=r.map(m=>{const f=[],k=M(m.unit);let g=D(m.unit,t);for(;g<e;){let w=k(g,m.step);g<t&&(g=t),w>e&&(w=e);const x=o(w,g,"",!0)*a,v=typeof m.format=="function"?m.format(g,w):G(g,m.format,{firstWeekContainsDate:4,weekStartsOn:1});let _="";m.css&&(_+=typeof m.css=="function"?m.css(g):m.css),f.push({width:x,value:v,date:g,css:_,unit:m.unit}),g=w}return{cells:f,add:k,height:s}});let p=a;return i!==n&&(p=Math.round(p/R(i,n))||1),{rows:d,width:l,height:h,diff:o,start:t,end:e,lengthUnit:n,minUnit:i,lengthUnitWidth:p}}function oa(t,e,n){const a=typeof t=="boolean"?{}:t,s=W.indexOf(N(e).unit);if(typeof a.level>"u"&&(a.level=s),a.levels)a.levels.forEach(o=>{o.minCellWidth||(o.minCellWidth=Z(a.minCellWidth,ft)),o.maxCellWidth||(o.maxCellWidth=Z(a.maxCellWidth,mt))});else{const o=[],c=e.length||1,u=Z(a.minCellWidth,ft),l=Z(a.maxCellWidth,mt);e.forEach(h=>{h.format&&!K[h.unit]&&(K[h.unit]=h.format)}),W.forEach((h,d)=>{if(d===s)o.push({minCellWidth:u,maxCellWidth:l,scales:e});else{const p=[];if(d)for(let m=c-1;m>0;m--){const f=W[d-m];f&&p.push({unit:f,step:1,format:K[f]})}p.push({unit:h,step:1,format:K[h]}),o.push({minCellWidth:u,maxCellWidth:l,scales:p})}}),a.levels=o}a.levels[a.level]||(a.level=0);const r=a.levels[a.level],i=Math.min(Math.max(n,r.minCellWidth),r.maxCellWidth);return{_zoom:a,scales:r.scales,cellWidth:i}}function ca(t,e,n,a,s,r,i){t.level=n;let o;const c=a.scales||a,u=N(c).unit,l=ua(u,s);if(e===-1){const p=R(u,s);o=i*p}else{const p=R(N(r).unit,u);o=Math.round(i/p)}const h=a.minCellWidth??ft,d=a.maxCellWidth??mt;return{scales:c,cellWidth:Math.min(d,Math.max(h,o)),lengthUnit:l,zoom:t}}function ua(t,e){const n=W.indexOf(t),a=W.indexOf(e);return a>=n?t==="hour"?"hour":"day":W[a]}function Z(t,e){return t??e}const gt=20,da=function(t,e,n,a,s){const r=Math.round(a/2)-3;if(!e||!n||!e.$y||!n.$y||e.$skip||n.$skip)return t.$p="",t;let i=!1,o=!1;switch(t.type){case"e2s":o=!0;break;case"s2s":i=!0,o=!0;break;case"s2e":i=!0;break}const c=i?e.$x:e.$x+e.$w,u=s?e.$y-7:e.$y,l=o?n.$x:n.$x+n.$w,h=s?n.$y-7:n.$y;if(c!==l||u!==h){const d=la(c,u+r,l,h+r,i,o,a/2,s),p=ha(l,h+r,o);t.$p=`${d},${p}`}return t};function la(t,e,n,a,s,r,i,o){const c=gt*(s?-1:1),u=gt*(r?-1:1),l=t+c,h=n+u,d=[t,e,l,e,0,0,0,0,h,a,n,a],p=h-l;let m=a-e;const f=r===s;return f||(h<=t+gt-2&&r||h>t&&!r)&&(m=o?m-i+6:m-i),f&&r&&l>h||f&&!r&&l<h?(d[4]=d[2]+p,d[5]=d[3],d[6]=d[4],d[7]=d[5]+m):(d[4]=d[2],d[5]=d[3]+m,d[6]=d[4]+p,d[7]=d[5]),d.join(",")}function ha(t,e,n){return n?`${t-5},${e-3},${t-5},${e+3},${t},${e}`:`${t+5},${e+3},${t+5},${e-3},${t},${e}`}function fa(t,e,n){if(e&&n){const a=n.x-e.x,s=n.y-e.y,r=(a>0?e.x:n.x)-t.left,i=(s>0?e.y:n.y)-t.top,o=`${a>0?0:-a},${s>0?0:-s},${a>0?a:0},${s>0?s:0}`;return{width:Math.abs(a),height:Math.abs(s),left:r,top:i,p:o}}else return null}const te=["start","end","duration"];function ma(t,e){const{type:n,unscheduled:a}=t;return a||n==="summary"?!te.includes(e):n==="milestone"?!["end","duration"].includes(e):!0}function ga(t,e){return typeof e=="function"?e:te.includes(t)?(typeof e=="string"&&(e={type:e,config:{}}),e.config||(e.config={}),e.type==="datepicker"&&(e.config.buttons=["today"]),(n,a)=>ma(n,a.id)?e:null):e}function pa(t){return!t||!t.length?[]:t.map(e=>{const n=e.align||"left",a=e.id==="add-task",s=!a&&e.flexgrow?e.flexgrow:null,r=s?1:e.width||(a?50:120);let i=e.template;if(!i)switch(e.id){case"start":i=c=>G(c,"dd-MM-yyyy");break;case"end":i=c=>c?G(c,"dd-MM-yyyy"):"-";break}const o=e.editor&&ga(e.id,e.editor);return{width:r,align:n,header:e.header,id:e.id,template:i,...s&&{flexgrow:s},cell:e.cell,resize:e.resize??!0,sort:e.sort??!a,...o&&{editor:o},...e.options&&{options:e.options}}})}const ya=[{id:"text",header:"Task name",flexgrow:1,sort:!0},{id:"start",header:"Start date",align:"center",sort:!0},{id:"duration",header:"Duration",width:100,align:"center",sort:!0},{id:"add-task",header:"Add task",width:50,align:"center",sort:!1,resize:!1}];function ka(){let t=!0;return t=!1,t}function B(t,e,n,a){const{selected:s,tasks:r}=t.getState(),i=s.length,o=!i&&e==="add-task",c=["edit-task","paste-task"],u=["copy-task","cut-task"],l=["copy-task","cut-task","delete-task","indent-task:remove","move-task:down"],h=["indent-task:add","move-task:down","move-task:up"],d={"indent-task:remove":2},p={parent:h.includes(e),level:d[e]};if(n=n||(i?s[s.length-1]:null),!(!n&&!o)){if(e!=="paste-task"&&(t._temp=null),c.includes(e)||o||s.length===1)ee(t,e,n,a);else if(i){const m=u.includes(e)?s:wa(s,r,p);l.includes(e)&&m.reverse(),m.forEach(f=>ee(t,e,f,a))}}}function wa(t,e,n){let a=t.map(s=>{const r=e.byId(s);return{id:s,level:r.$level,parent:r.parent,index:e.getIndexById(s)}});return(n.parent||n.level)&&(a=a.filter(s=>n.level&&s.level<=n.level||!t.includes(s.parent))),a.sort((s,r)=>s.level-r.level||s.index-r.index),a.map(s=>s.id)}function ee(t,e,n,a){const s=t.exec?t.exec:t.in.exec;let r=e.split(":")[0],i=e.split(":")[1],o={id:n},c={};if(r=="copy-task"||r=="cut-task"){t._temp||(t._temp=[]),t._temp.push({id:n,cut:r=="cut-task"});return}else if(r=="paste-task"){t._temp&&t._temp.length&&(t._temp.forEach(u=>{s(u.cut?"move-task":"copy-task",{id:u.id,target:n,mode:"after"})}),t._temp=null);return}else r==="add-task"?(c={task:{type:"task",text:a("New Task")},target:n},o={}):r==="edit-task"?r="show-editor":r==="convert-task"?(r="update-task",c={task:{type:i}},i=void 0):r==="indent-task"&&(i=i==="add");typeof i<"u"&&(c={mode:i,...c}),o={...o,...c},s(r,o)}function ne(t,e){return t.some(n=>n.data?ne(n.data,e):n.id===e)}const ba=t=>M(t),xa=t=>V(t);function ae(t,e,n){se(t,e),t.base_start&&se(t,e,!0),tt(e,n)}function tt(t,e,n,a){t.unscheduled||(n&&_a(t,a),re(t,e)),t.base_start&&re(t,e,!0)}function se(t,e,n=!1){e.type=e.type||t.type;const[a,s,r]=ie(n);e.type!=="milestone"?(t[s]&&e[a]||(e[a]=t[a]),e[a]&&!(e[r]||e[s])?(e[s]=t[s]>e[a]?t[s]:null,e[s]||(e[r]=1)):e[s]&&!(e[r]||e[a])?(e[a]=t[a]<e[s]?t[a]:e[s],e[a]===e[s]&&(e[r]=1,delete e[s])):e[r]&&!(e[a]||e[s])&&(e[a]=t[a])):(e[s]&&delete e[s],t[s]&&delete t[s])}function re(t,e="day",n){const[a,s,r]=ie(n);t.type==="milestone"?t[r]=0:t[a]&&(t[r]?t[s]||(t[s]=ba(e)(t[a],t[r])):t[s]?t[r]=xa(e)(t[s],t[a]):(t[s]=t[a],t[r]=0))}function ie(t){return t?["base_start","base_end","base_duration"]:["start","end","duration"]}function _a(t,e){e==="duration"&&(t.end=null),t.start&&t.end&&(t.start>=t.end?t.end=null:t.duration=null),t.base_start&&t.base_end&&(t.base_start>=t.base_end?t.base_end=null:t.base_duration=null)}class va extends de{in;_router;constructor(e){super({writable:e,async:!1}),this._router=new le(super.setState.bind(this),[{in:["tasks","start","end","scales","autoScale"],out:["_start","_end"],exec:s=>{const{_end:r,_start:i,start:o,end:c,tasks:u,scales:l,autoScale:h}=this.getState();if(!o||!c||h){const d=N(l).unit,p=ra(o,c,h,d,u);(p._end!=r||p._start!=i)&&this.setState(p,s)}else this.setState({_start:o,_end:c},s)}},{in:["_start","_end","cellWidth","scaleHeight","scales","lengthUnit"],out:["_scales"],exec:s=>{const r=this.getState();let{lengthUnit:i}=r;const{_start:o,_end:c,cellWidth:u,scaleHeight:l,scales:h}=r,d=N(h).unit;ta(d,i)||(i=d);const p=ia(o,c,i,u,l,h);this.setState({_scales:p},s)}},{in:["_scales","tasks","cellHeight","baselines"],out:["_tasks"],exec:s=>{const{cellWidth:r,cellHeight:i,tasks:o,_scales:c,baselines:u}=this.getState(),l=o.toArray().map((h,d)=>jn(h,d,r,i,c,u));this.setState({_tasks:l},s)}},{in:["_tasks","links","cellHeight"],out:["_links"],exec:s=>{const{tasks:r,links:i,cellHeight:o,baselines:c}=this.getState(),u=i.map(l=>{const h=r.byId(l.source),d=r.byId(l.target);return da(l,h,d,o,c)}).filter(l=>l!==null);this.setState({_links:u},s)}},{in:["tasks","activeTask"],out:["_activeTask"],exec:s=>{const{tasks:r,activeTask:i}=this.getState();this.setState({_activeTask:r.byId(i)||null},s)}},{in:["tasks","selected"],out:["_selected"],exec:s=>{const{tasks:r,selected:i}=this.getState(),o=i.map(c=>r.byId(c)).filter(c=>!!c);this.setState({_selected:o},s)}},{in:["start","end"],out:["cellWidth"],exec:s=>{const{_cellWidth:r,cellWidth:i}=this.getState();r!=i&&this.setState({cellWidth:r},s)}},{in:["markers","_scales","cellWidth"],out:["_markers"],exec:s=>{const{markers:r,_scales:i,cellWidth:o}=this.getState(),{start:c,diff:u}=i,l=r.map(h=>(h.left=u(h.start,c)*o,h));this.setState({_markers:l},s)}}],{tasks:s=>new Xn(s),links:s=>new bt(s),columns:s=>pa(s)});const n=this.in=new he;n.on("show-editor",({id:s})=>{this.setStateAsync({activeTask:s})}),n.on("select-task",({id:s,toggle:r,range:i,show:o})=>{const{selected:c,_tasks:u,activeTask:l}=this.getState();let h=!1,d;if(c.length&&(r||i)){const m=[...c];if(i){const f=m[m.length-1],k=u.findIndex(_=>_.id==f),g=u.findIndex(_=>_.id==s),w=Math.min(k,g),x=Math.max(k,g)+1,v=u.slice(w,x).map(_=>_.id);k>g&&v.reverse(),v.forEach(_=>{m.includes(_)||m.push(_)})}else if(r){const f=m.findIndex(k=>k==s);f===-1?m.push(s):(h=!0,m.splice(f,1))}d=m}else d=[s];const p={selected:d};o&&d.length&&(p._scrollTask={id:d[0],mode:o}),this.setStateAsync(p),!h&&l&&l!=s&&n.exec("show-editor",{id:s})}),n.on("delete-link",({id:s})=>{const{links:r}=this.getState();r.remove(s),this.setStateAsync({links:r})}),n.on("update-link",s=>{const{links:r}=this.getState(),{id:i,link:o}=s;r.update(i,o),this.setStateAsync({links:r}),s.link=r.byId(i)}),n.on("add-link",s=>{const{link:r}=s,{links:i}=this.getState();!r.source||!r.target||(r.type||(r.type="e2s"),r.id=r.id||wt(),i.add(r),this.setStateAsync({links:i}),s.id=r.id,s.link=i.byId(r.id))});let a=null;n.on("move-task",s=>{const{tasks:r}=this.getState();let{mode:i,target:o}=s;const{id:c,inProgress:u}=s,l=r.byId(c);if(typeof u>"u"?s.source=l.parent:s.source=a=a??l.parent,u===!1){r.update(l.id,{$reorder:!1}),this.setState({tasks:r}),a=null;return}if(o===c||r.contains(c,o)){s.skipProvider=!0;return}if(i==="up"||i==="down"){const h=r.getBranch(c);let d=r.getIndexById(c);if(i==="up"){const p=l.parent===0;if(d===0&&p){s.skipProvider=!0;return}d-=1,i="before"}else if(i==="down"){const p=d===h.length-1,m=l.parent===0;if(p&&m){s.skipProvider=!0;return}d+=1,i="after"}if(o=h[d]&&h[d].id||l.parent,o){const p=r.getBranch(o);let m=r.getIndexById(o),f=p[m];if(f.data){if(i==="before"){if(f.parent===l.parent){for(;f.data;)f.open||n.exec("open-task",{id:f.id,mode:!0}),f=f.data[f.data.length-1];o=f.id}}else if(i==="after"){let w;f.parent===l.parent?(w=f,f=f.data[0],o=f.id,i="before"):p.length-1!==m&&(w=f,m+=1,f=p[m],l.$level>f.$level&&f.data?(w=f,f=f.data[0],o=f.id,i="before"):o=f.id),w&&!w.open&&n.exec("open-task",{id:w.id,mode:!0})}}const k=r.getSummaryId(l.id);r.move(c,i,o);const g=r.getSummaryId(c);k!=g&&(k&&this.resetSummaryDates(k,"move-task"),g&&this.resetSummaryDates(g,"move-task"))}}else{const h=r.byId(o);let d=h,p=!1;for(;d.$level>l.$level;)d=r.byId(d.parent),d.id===c&&(p=!0);if(p)return;const m=r.getSummaryId(l.id);if(r.move(c,i,o),i=="child"){let k=h;for(;k.id!==0&&!k.open;)n.exec("open-task",{id:k.id,mode:!0}),k=r.byId(k.parent)}const f=r.getSummaryId(c);m!=f&&(m&&this.resetSummaryDates(m,"move-task"),f&&this.resetSummaryDates(f,"move-task"))}u?this.setState({tasks:r}):this.setStateAsync({tasks:r}),s.target=o,s.mode=i}),n.on("drag-task",s=>{const{id:r,width:i,left:o,top:c,inProgress:u}=s,l=this.getState(),{tasks:h,_tasks:d,_selected:p,_scales:m,cellWidth:f}=l,k={_tasks:d,_selected:p},g=h.byId(r);typeof i<"u"&&(g.$w=i,dt(h,g,m,f)),typeof o<"u"&&(g.type==="summary"&&jt(g,o-g.$x),g.$x=o,dt(h,g,m,f)),typeof c<"u"&&(g.$y=c+4,g.$reorder=u),typeof i<"u"&&(g.$w=i),typeof o<"u"&&(g.$x=o),typeof c<"u"&&(g.$y=c+4,g.$reorder=u),this.setState(k)}),n.on("update-task",s=>{const{id:r,task:i,eventSource:o}=s;let c=s.diff;const{tasks:u,_scales:l,durationUnit:h}=this.getState(),d=u.byId(r);if(o==="add-task"||o==="copy-task"||o==="move-task"||o==="update-task"||o==="delete-task"){ae(d,i,h),u.update(r,i);return}const p=l.lengthUnit,m=M(p),f=V(p);if(c&&(i.start&&(i.start=m(i.start,c)),i.end&&(i.end=m(i.end,c))),i.start&&i.end){if((!Y(i.start,d.start)||!Y(i.end,d.end))&&d.type==="summary"&&(!i.type||i.type==="summary")&&d.data?.length){if(!c&&(c=f(i.start,d.start),f(i.end,d.end)!==c))return;this.moveSummaryKids(d,g=>m(g,c),"update-task")}}else if(d.type=="summary"&&(i.start&&!i.end||i.end&&!i.start||i.duration))return;ae(d,i,h),u.update(r,i),i.type==="summary"&&d.type!=="summary"&&this.resetSummaryDates(r,"update-task");const k=u.getSummaryId(r);k&&this.resetSummaryDates(k,"update-task"),this.setStateAsync({tasks:u}),s.task=u.byId(r)}),n.on("add-task",s=>{const{tasks:r,_scales:i,baselines:o,unscheduledTasks:c,durationUnit:u}=this.getState(),{target:l,mode:h,task:d,show:p}=s;d.unscheduled=c;let m=-1,f,k;if(l?(k=r.byId(l),h=="child"?(f=k,d.parent=f.id):(k.parent!==null&&(f=r.byId(k.parent),d.parent=f.id),m=r.getIndexById(l),h=="after"&&(m+=1))):d.parent&&(f=r.byId(d.parent)),!d.start){if(f?.start)d.start=new Date(f.start.valueOf());else if(k)d.start=new Date(k.start.valueOf());else{const x=r.getBranch(0);let v;if(x?.length){const _=x[x.length-1];if(!_.$skip){const yt=new Date(_.start.valueOf());i.start<=yt&&(v=yt)}}d.start=v||M(u)(i.start,1)}d.duration=1,o&&(d.base_start=d.start,d.base_duration=d.duration)}tt(d,u);const g=r.add(d,m);if(f)for(;f&&f.id;)n.exec("open-task",{id:f.id,mode:!0}),f=r.byId(f.parent);s.id=g.id;const w=r.getSummaryId(g.id);w&&this.resetSummaryDates(w,"add-task"),this.setStateAsync({tasks:r}),n.exec("select-task",{id:g.id,show:p||!1}),s.id=g.id,s.task=g}),n.on("delete-task",s=>{const{id:r}=s,{tasks:i,links:o,selected:c}=this.getState();s.source=i.byId(r).parent;const u=i.getSummaryId(r),l=[r];i.eachChild(d=>l.push(d.id),r),o.filter(d=>!(l.includes(d.source)||l.includes(d.target)));const h={tasks:i,links:o};c.includes(r)&&(h.selected=c.filter(d=>d!==r)),i.remove(r),u&&this.resetSummaryDates(u,"delete-task"),this.setStateAsync(h)}),n.on("indent-task",({id:s,mode:r})=>{const{tasks:i}=this.getState();if(r){const o=i.getBranch(s)[i.getIndexById(s)-1];o&&n.exec("move-task",{id:s,mode:"child",target:o.id})}else{const o=i.byId(s),c=i.byId(o.parent);c&&c.parent!==null&&n.exec("move-task",{id:s,mode:"after",target:o.parent})}}),n.on("copy-task",s=>{const{id:r,target:i,mode:o,eventSource:c}=s;if(c==="copy-task")return;const{tasks:u,links:l}=this.getState();if(u.contains(r,i)){s.skipProvider=!0;return}const h=u.getSummaryId(r),d=u.getSummaryId(i);let p=u.getIndexById(i);o=="before"&&(p-=1);const m=u.byId(r),f=u.copy(m,u.byId(i).parent,p+1);s.source=s.id,s.id=f[0][1],m.lazy&&(s.lazy=!0),h!=d&&d&&this.resetSummaryDates(d,"copy-task");let k=[];for(let g=1;g<f.length;g++){const[w,x]=f[g];l.forEach(v=>{if(v.source===w){const _={...v};delete _.target,k.push({..._,source:x})}else if(v.target===w){const _={...v};delete _.source,k.push({..._,target:x})}})}k=k.reduce((g,w)=>{const x=g.findIndex(v=>v.id===w.id);return x>-1?g[x]={...g[x],...w}:g.push(w),g},[]);for(let g=1;g<f.length;g++){const[w,x]=f[g],v=u.byId(x);n.exec("copy-task",{source:w,id:x,lazy:!!v.lazy,eventSource:"copy-task",target:v.parent,mode:"child"})}k.forEach(g=>{n.exec("add-link",{link:{source:g.source,target:g.target,type:g.type}})}),this.setStateAsync({tasks:u})}),n.on("open-task",({id:s,mode:r})=>{const{tasks:i}=this.getState(),o=i.byId(s);o.lazy?n.exec("request-data",{id:o.id}):(i.toArray().forEach(c=>c.$y=0),i.update(s,{open:r}),this.setState({tasks:i}))}),n.on("scroll-chart",({left:s,top:r})=>{if(!isNaN(s)){const i=this.calcScaleDate(s);this.setState({scrollLeft:s,_scaleDate:i})}isNaN(r)||this.setState({scrollTop:r})}),n.on("render-data",s=>{this.setState({area:s})}),n.on("provide-data",s=>{const{tasks:r,links:i}=this.getState(),o=r.byId(s.id);o.lazy?(o.lazy=!1,o.open=!0):o.data=[],r.parse(s.data.tasks,s.id),this.setStateAsync({tasks:r,links:new bt(i.map(c=>c).concat(s.data.links))})}),n.on("zoom-scale",({dir:s,offset:r})=>{const{zoom:i,cellWidth:o,_cellWidth:c,scrollLeft:u}=this.getState(),l=r+u,h=this.calcScaleDate(l);let d=o;s<0&&(d=c||o);const p=d+s*50,m=i.levels[i.level],f=s<0&&o>m.maxCellWidth;if(p<m.minCellWidth||p>m.maxCellWidth||f){if(!this.changeScale(i,s))return}else this.setState({cellWidth:p,_cellWidth:p});const{_scales:k,_start:g,cellWidth:w}=this.getState(),x=D(k.minUnit,g),v=k.diff(h,x,"hour");typeof r>"u"&&(r=w);let _=Math.round(v*w)-r;_<0&&(_=0),this.setState({scrollLeft:_,_scaleDate:h,_zoomOffset:r})}),n.on("expand-scale",({minWidth:s})=>{const{_start:r,_scales:i,start:o,end:c,_end:u,cellWidth:l,_scaleDate:h,_zoomOffset:d}=this.getState(),p=M(i.minUnit);let m=i.width;if(o&&c){if(m<s&&m){const x=s/m;this.setState({cellWidth:l*x})}return!0}let f=0;for(;m<s;)m+=l,f++;const k=f?c?-f:-1:0,g=o||p(r,k);let w=0;if(h){const x=i.diff(h,g,"hour");w=Math.max(0,Math.round(x*l)-(d||0))}this.setState({_start:g,_end:c||p(u,f),scrollLeft:w})}),n.on("sort-tasks",({key:s,order:r,add:i})=>{const o=this.getState(),{tasks:c}=o;let u=o._sort;const l={key:s,order:r};let h=u?.length||0;h&&i?(u.forEach((d,p)=>{d.key===s&&(h=p)}),u[h]=l):u=[l],c.sort(u),this.setState({_sort:u,tasks:c})}),n.on("hotkey",({key:s,event:r,eventSource:i})=>{switch(s){case"arrowup":case"arrowdown":{const{selected:o,_tasks:c}=this.getState();r.preventDefault();const u=o.length;let l;if(s==="arrowup"?l=u?this.getPrevRow(o[u-1])?.id:c[c.length-1]?.id:l=u?this.getNextRow(o[u-1])?.id:c[0]?.id,l){const h=i==="chart"?"xy":!0;this.in.exec("select-task",{id:l,show:h})}break}case"ctrl+c":{B(this,"copy-task",null,null);break}case"ctrl+x":{B(this,"cut-task",null,null);break}case"ctrl+v":{B(this,"paste-task",null,null);break}case"ctrl+d":case"backspace":{r.preventDefault(),B(this,"delete-task",null,null);break}}})}init(e){const n=this.getState().area?{}:{scrollLeft:0,scrollTop:0,area:{from:0,start:0,end:0}};if(e.cellWidth&&(e._cellWidth=e.cellWidth),e._sort=null,ka()&&(e.unscheduledTasks=!1,e.baselines=!1,e.markers=[]),Array.isArray(e.tasks)&&e.tasks.forEach(a=>tt(a,e.durationUnit)),this._router.init({_scrollTask:null,selected:[],markers:[],autoScale:!0,durationUnit:"day",...n,...e}),e.zoom){const a=oa(e.zoom,e.scales,e.cellWidth);this.setState({zoom:a._zoom,cellWidth:a.cellWidth,_cellWidth:a.cellWidth,scales:a.scales})}}setState(e,n){return this._router.setState(e,n)}setStateAsync(e){this._router.setStateAsync(e)}getTask(e){const{tasks:n}=this.getState();return n.byId(e)}serialize(){const{tasks:e}=this.getState();return e.serialize()}changeScale(e,n){const a=e.level+n,s=e.levels[a];if(s){const{cellWidth:r,scales:i,_scales:o}=this.getState(),c=ca(e,n,a,s,o.lengthUnit,i,r);return c._cellWidth=c.cellWidth,this.setState(c),!0}return!1}isScheduled(e){return this.getState().unscheduledTasks?e.some(n=>!n.unscheduled||n.data&&this.isScheduled(n.data)):!0}resetSummaryDates(e,n){const{tasks:a}=this.getState(),s=a.byId(e),r=s.data;if(r?.length&&this.isScheduled(r)){const i=lt({...s,start:void 0,end:void 0,duration:void 0});if(!Y(s.start,i.start)||!Y(s.end,i.end)){this.in.exec("update-task",{id:e,task:i,eventSource:n});const o=a.getSummaryId(e);o&&this.resetSummaryDates(o,n)}}}moveSummaryKids(e,n,a){const{tasks:s}=this.getState();e.data.forEach(r=>{const i={...s.byId(r.id),start:n(r.start)};i.type!=="milestone"&&(i.end=n(r.end)),delete i.id,this.in.exec("update-task",{id:r.id,task:i,eventSource:a}),r.data?.length&&this.moveSummaryKids(r,n,a)})}calcScaleDate(e){const{_scales:n,_start:a}=this.getState(),s=n.lengthUnit==="day"?n.lengthUnitWidth/24:n.lengthUnitWidth;return M("hour")(D(n.minUnit,a),Math.floor(e/s))}getNextRow(e){const n=this.getState()._tasks,a=n.findIndex(s=>s.id==e);return n[a+1]}getPrevRow(e){const n=this.getState()._tasks,a=n.findIndex(s=>s.id==e);return n[a-1]}}function Sa(t,e,n,a){if(typeof document>"u")return"";const s=document.createElement("canvas");{const r=Ma(s,t,e,1,n);Wa(r,a,0,t,0,e)}return s.toDataURL()}function Ma(t,e,n,a,s){t.setAttribute("width",(e*a).toString()),t.setAttribute("height",(n*a).toString());const r=t.getContext("2d");return r.translate(-.5,-.5),r.strokeStyle=s,r}function Wa(t,e,n,a,s,r){t.beginPath(),t.moveTo(a,s),t.lineTo(a,r),e==="full"&&t.lineTo(n,r),t.stroke()}function pt(t){return t.map(e=>{switch(e.data&&pt(e.data),e.id){case"add-task:before":case"move-task:up":e.check=(n,a)=>!$a(n,a);break;case"move-task:down":e.check=(n,a)=>!Ta(n,a);break;case"indent-task:add":e.check=(n,a)=>Ca(n,a)!==n.parent;break;case"indent-task:remove":e.check=n=>!Da(n);break}return e})}function Da(t){return t.parent===0}function $a(t,e){return e[0]?.id===t.id}function Ta(t,e){return e[e.length-1]?.id===t.id}function Ca(t,e){const n=e.findIndex(a=>a.id===t.id);return e[n-1]?.id??t.parent}const Ia=t=>e=>e.type!==t,Pa=pt([{id:"add-task",text:"Add",icon:"wxi-plus",data:[{id:"add-task:child",text:"Child task"},{id:"add-task:before",text:"Task above"},{id:"add-task:after",text:"Task below"}]},{type:"separator"},{id:"convert-task",text:"Convert to",icon:"wxi-swap-horizontal",dataFactory:t=>({id:`convert-task:${t.id}`,text:`${t.label}`,check:Ia(t.id)})},{id:"edit-task",text:"Edit",icon:"wxi-edit",subtext:"Ctrl+E"},{id:"cut-task",text:"Cut",icon:"wxi-content-cut",subtext:"Ctrl+X"},{id:"copy-task",text:"Copy",icon:"wxi-content-copy",subtext:"Ctrl+C"},{id:"paste-task",text:"Paste",icon:"wxi-content-paste",subtext:"Ctrl+V"},{id:"move-task",text:"Move",icon:"wxi-swap-vertical",data:[{id:"move-task:up",text:"Up"},{id:"move-task:down",text:"Down"}]},{type:"separator"},{id:"indent-task:add",text:"Indent",icon:"wxi-indent"},{id:"indent-task:remove",text:"Outdent",icon:"wxi-unindent"},{type:"separator"},{id:"delete-task",icon:"wxi-delete",text:"Delete",subtext:"Ctrl+D / BS"}]),Ea=pt([{id:"add-task",comp:"button",icon:"wxi-plus",text:"New task",type:"primary"},{id:"edit-task",comp:"icon",icon:"wxi-edit",menuText:"Edit",text:"Ctrl+E"},{id:"delete-task",comp:"icon",icon:"wxi-delete",menuText:"Delete",text:"Ctrl+D, Backspace"},{comp:"separator"},{id:"move-task:up",comp:"icon",icon:"wxi-angle-up",menuText:"Move up"},{id:"move-task:down",comp:"icon",icon:"wxi-angle-down",menuText:"Move down"},{comp:"separator"},{id:"copy-task",comp:"icon",icon:"wxi-content-copy",menuText:"Copy",text:"Ctrl+V"},{id:"cut-task",comp:"icon",icon:"wxi-content-cut",menuText:"Cut",text:"Ctrl+X"},{id:"paste-task",comp:"icon",icon:"wxi-content-paste",menuText:"Paste",text:"Ctrl+V"},{comp:"separator"},{id:"indent-task:add",comp:"icon",icon:"wxi-indent",menuText:"Indent"},{id:"indent-task:remove",comp:"icon",icon:"wxi-unindent",menuText:"Outdent"}]),Oa=[{key:"text",comp:"text",label:"Name",config:{placeholder:"Add task name"}},{key:"details",comp:"textarea",label:"Description",config:{placeholder:"Add description"}},{key:"type",comp:"select",label:"Type"},{key:"start",comp:"date",label:"Start date"},{key:"end",comp:"date",label:"End date"},{key:"duration",comp:"counter",label:"Duration",config:{min:1}},{key:"unscheduled",comp:"twostate",label:"",config:{value:!0,text:"Unschedule",textActive:"Schedule"}},{key:"progress",comp:"slider",label:"Progress",config:{min:1,max:100}},{key:"links",comp:"links",label:""}],Ya=[{id:"task",label:"Task"},{id:"summary",label:"Summary task"},{id:"milestone",label:"Milestone"}];export{va as DataStore,ya as defaultColumns,Oa as defaultEditorItems,Pa as defaultMenuOptions,Ya as defaultTaskTypes,Ea as defaultToolbarButtons,G as format,M as getAdder,V as getDiffer,D as getUnitStart,Sa as grid,B as handleAction,ne as isHandledAction,tt as normalizeDates,fa as placeLink,sa as registerScaleUnit};
|
|
1
|
+
var Kt=new Date().valueOf(),cn=()=>Kt++;function bt(){return"temp://"+Kt++}function un(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in t){const s=e[n],a=t[n];if(!wt(s,a))return!1}return!0}function wt(e,t){if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e===null)return e===t;if(typeof e!=typeof t||(e===null||t===null)&&e!==t||e instanceof Date&&t instanceof Date&&e.getTime()!==t.getTime())return!1;if(typeof e=="object")if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=e.length-1;n>=0;n--)if(!wt(e[n],t[n]))return!1;return!0}else return un(e,t);return e===t}function P(e){if(typeof e!="object"||e===null)return e;if(e instanceof Date)return new Date(e);if(e instanceof Array)return e.map(P);const t={};for(const n in e)t[n]=P(e[n]);return t}var Zt=class{constructor(e){this._data=e,this._pool=new Map;for(let t=0;t<e.length;t++){const n=e[t];this._pool.set(n.id,n)}}add(e){e={id:cn(),...e},this._data.push(e),this._pool.set(e.id,e)}update(e,t){const n=this._data.findIndex(a=>a.id==e),s={...this._data[n],...t};this._data[n]=s,this._pool.set(s.id,s)}remove(e){this._data=this._data.filter(t=>t.id!=e),this._pool.delete(e)}filter(e){this._data=this._data.filter(t=>{const n=e(t);return n||this._pool.delete(t.id),n})}byId(e){return this._pool.get(e)}map(e){return this._data.map(e)}forEach(e){this._data.forEach(e)}},ln=class{constructor(e){const t={id:0,$level:0,data:[],parent:null},n=new Map;n.set(0,t),this._pool=n,e&&e.length&&this.parse(e,0)}parse(e,t){const n=this._pool;for(let a=0;a<e.length;a++){const r=e[a];r.parent=r.parent||t,r.data=null,n.set(r.id,r)}for(let a=0;a<e.length;a++){const r=e[a],i=n.get(r.parent);i&&(i.data||(i.data=[]),i.data.push(r))}const s=n.get(t);this.setLevel(s,s.$level+1,!1)}add(e,t){const n=this._pool.get(e.parent||0);e.$level=n.$level+1,this._pool.set(e.id,e),n.data?t===-1?n.data=[...n.data,e]:ee(n,t,e):n.data=[e]}addAfter(e,t){if(!t)return this.add(e,-1);const n=this.byId(t),s=this.byId(n.parent),a=rt(s,n.id)+1;e.parent=s.id,e.$level=s.$level+1,this.add(e,a)}remove(e){const t=this._pool.get(e);this._remove(t);const n=this._pool.get(t.parent);n.data=n.data.filter(s=>s.id!=e),this._clearBranch(n)}_remove(e){e.data&&e.data.forEach(t=>this._remove(t)),this._pool.delete(e.id)}update(e,t){let n=this._pool.get(e);const s=this._pool.get(n.parent),a=rt(s,n.id);n={...n,...t},s&&a>=0&&(s.data[a]=n,s.data=[...s.data]),this._pool.set(n.id,n)}move(e,t,n){const s=this._pool.get(e),a=t==="child",r=this._pool.get(n),i=r.$level+(a?1:0);if(!s||!r)return;const o=this._pool.get(s.parent),d=a?r:this._pool.get(r.parent);d.data||(d.data=[]);const c=rt(o,s.id);hn(o,c);const u=a?d.data.length:rt(d,r.id)+(t==="after"?1:0);if(ee(d,u,s),o.id===d.id&&c===u)return null;s.parent=d.id,s.$level!==i&&(s.$level=i,this.setLevel(s,i+1,!0)),this.update(s.id,s),this._clearBranch(o)}_clearBranch(e){e.data&&!e.data.length&&(e.open&&delete e.open,this.update(e.id,{data:null}))}toArray(){const e=[],t=this._pool.get(0).data;return t&&te(t,e),e}byId(e){return this._pool.get(e)}getBranch(e){return this._pool.get(e).data}forEach(e){this._pool.forEach((t,n)=>{n!==0&&e(t)})}eachChild(e,t){const n=this.byId(t);!n||!n.data||n.data.forEach((s,a)=>{e(this.byId(s.id),a),this.eachChild(e,s.id)})}setLevel(e,t,n){e.data&&(e.data=e.data.map(s=>(n&&(s={...s},this._pool.set(s.id,s)),s.$level=t,s.data&&this.setLevel(s,t+1,n),s)))}};function te(e,t){e.forEach(n=>{t.push(n),n.open===!0&&te(n.data,t)})}function hn(e,t){const n=[...e.data];n.splice(t,1),e.data=n}function ee(e,t,n){const s=[...e.data];s.splice(t,0,n),e.data=s}function rt(e,t){return e?.data.findIndex(n=>n.id===t)}var ne=2,fn=class{constructor(e){e&&(this._writable=e.writable,this._async=e.async),this._values={},this._state={}}setState(e,t=0){const n={};return this._wrapProperties(e,this._state,this._values,"",n,t),n}getState(){return this._values}getReactive(){return this._state}_wrapProperties(e,t,n,s,a,r){for(const i in e){const o=t[i],d=n[i],c=e[i];if(o&&(d===c&&typeof c!="object"||c instanceof Date&&d instanceof Date&&d.getTime()===c.getTime()))continue;const u=s+(s?".":"")+i;o?(o.__parse(c,u,a,r)&&(n[i]=c),r&ne?a[u]=o.__trigger:o.__trigger()):(c&&c.__reactive?t[i]=this._wrapNested(c,c,u,a):t[i]=this._wrapWritable(c),n[i]=c),a[u]=a[u]||null}}_wrapNested(e,t,n,s){const a=this._wrapWritable(e);return this._wrapProperties(e,a,t,n,s,0),a.__parse=(r,i,o,d)=>(this._wrapProperties(r,a,t,i,o,d),!1),a}_wrapWritable(e){const t=[],n=function(){for(let s=0;s<t.length;s++)t[s](e)};return{subscribe:s=>(t.push(s),this._async?setTimeout(s,1,e):s(e),()=>{const a=t.indexOf(s);a>=0&&t.splice(a,1)}),__trigger:()=>{t.length&&(this._async?setTimeout(n,1):n())},__parse:function(s){return e=s,!0}}}},gn=class{constructor(e,t,n,s){typeof e=="function"?this._setter=e:this._setter=e.setState.bind(e),this._routes=t,this._parsers=n,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(a=>{a.in.forEach(r=>{const i=this._triggers.get(r)||[];i.push(a),this._triggers.set(r,i)}),a.out.forEach(r=>{const i=this._sources.get(r)||{};a.in.forEach(o=>i[o]=!0),this._sources.set(r,i)})}),this._routes.forEach(a=>{a.length=Math.max(...a.in.map(r=>se(r,this._sources,1)))}),this._bus=s}init(e){const t={};for(const n in e)if(this._prev[n]!==e[n]){const s=this._parsers[n];t[n]=s?s(e[n]):e[n]}this._prev=this._prev?{...this._prev,...e}:{...e},this.setState(t),this._bus&&this._bus.exec("init-state",t)}setStateAsync(e){const t=this._setter(e,ne);return this._async?Object.assign(this._async.signals,t):this._async={signals:t,timer:setTimeout(this._applyState.bind(this),1)},t}_applyState(){const e=this._async;if(e){this._async=null,this._triggerUpdates(e.signals,[]);for(const t in e.signals){const n=e.signals[t];n&&n()}}}setState(e,t=[]){const n=this._setter(e);return this._triggerUpdates(n,t),n}_triggerUpdates(e,t){const n=Object.keys(e),s=!t.length;t=t||[];for(let a=0;a<n.length;a++){const r=n[a],i=this._triggers.get(r);i&&i.forEach(o=>{t.indexOf(o)==-1&&t.push(o)})}s&&this._execNext(t)}_execNext(e){for(;e.length;){e.sort((n,s)=>n.length<s.length?1:-1);const t=e[e.length-1];e.splice(e.length-1),t.exec(e)}}};function se(e,t,n){const s=t.get(e);if(!s)return n;const a=Object.keys(s).map(r=>se(r,t,n+1));return Math.max(...a)}var pn=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(e,t,n){let s=this._handlers[e];s?n&&n.intercept?s.unshift(t):s.push(t):s=this._handlers[e]=[t],n&&n.tag&&this._tag.set(t,n.tag)}intercept(e,t,n){this.on(e,t,{...n,intercept:!0})}detach(e){for(const t in this._handlers){const n=this._handlers[t];for(let s=n.length-1;s>=0;s--)this._tag.get(n[s])===e&&n.splice(s,1)}}async exec(e,t){const n=this._handlers[e];if(n)for(let s=0;s<n.length;s++){const a=n[s](t);if(a===!1||a&&a.then&&await a===!1)return}return this._nextHandler&&await this._nextHandler.exec(e,t),t}setNext(e){return this._nextHandler=e}};function mn(e,t){return typeof e=="string"?e.localeCompare(t,void 0,{numeric:!0}):typeof e=="object"?e.getTime()-t.getTime():(e??0)-(t??0)}function kn(e,t){return typeof e=="string"?-e.localeCompare(t,void 0,{numeric:!0}):typeof t=="object"?t.getTime()-e.getTime():(t??0)-(e??0)}function yn({key:e,order:t}){const n=t==="asc"?mn:kn;return(s,a)=>n(s[e],a[e])}function bn(e){if(!e||!e.length)return;const t=e.map(n=>yn(n));return e.length===1?t[0]:function(n,s){for(let a=0;a<t.length;a++){const r=t[a](n,s);if(r!==0)return r}return 0}}function wn(e,t){return e.sort(bn(t))}class xn extends ln{_sort;constructor(t){super(),this.parse(t,0)}parse(t,n){if(!t||!t.length)return;const s=t.map(a=>this.normalizeTask(a,t));super.parse(s,n),this._sort&&this.sortBranch(this._sort,n)}getBranch(t){const n=this._pool.get(t);return this._pool.get(n.parent||0).data}contains(t,n){const s=this._pool.get(t).data;let a=!1;if(s)for(let r=0;r<s.length;r++){if(s[r].id===n){a=!0;break}if(s[r].data&&(a=this.contains(s[r].id,n),a))break}return a}getIndexById(t){return this.getBranch(t).findIndex(n=>n.id===t)}add(t,n){const s=this.normalizeTask(t);return super.add(s,n),s}copy(t,n,s){const a=this.add({...t,id:null,data:null,parent:n},s);let r=[[t.id,a.id]];return t.data?.forEach((i,o)=>{const d=this.copy(i,a.id,o);r=r.concat(d)}),r}normalizeTask(t){const n=t.id||bt(),s=t.parent||0,a=t.text||"",r=t.type||"task",i=t.progress||0,o=t.details||"",d={...t,id:n,text:a,parent:s,progress:i,type:r,details:o};return t.segments&&(d.segments=t.segments.map(c=>({...c}))),t.segments&&(d.segments=t.segments.map(c=>({...c}))),d}getSummaryId(t,n=!1){const s=this._pool.get(t);if(!s.parent)return null;const a=this._pool.get(s.parent);if(n){let r=t,i=this.getSummaryId(r);const o=[];for(;i;)r=i,o.push(i),i=this.getSummaryId(r);return o}return a.type==="summary"?a.id:this.getSummaryId(a.id)}sort(t){this._sort=t,t&&this.sortBranch(t,0)}sortBranch(t,n){const s=this._pool.get(n||0).data;s&&(wn(s,t),s.forEach(a=>{this.sortBranch(t,a.id)}))}serialize(){const t=[],n=this._pool.get(0).data;return n&&ae(n,t),t}}function ae(e,t){e.forEach(n=>{t.push(n),n.data&&ae(n.data,t)})}function w(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function $(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function it(e,t){const n=w(e);return isNaN(t)?$(e,NaN):(t&&n.setDate(n.getDate()+t),n)}function xt(e,t){const n=w(e);if(isNaN(t))return $(e,NaN);if(!t)return n;const s=n.getDate(),a=$(e,n.getTime());a.setMonth(n.getMonth()+t+1,0);const r=a.getDate();return s>=r?a:(n.setFullYear(a.getFullYear(),a.getMonth(),s),n)}function re(e,t){const n=+w(e);return $(e,n+t)}const ot=6048e5,Sn=864e5,ie=6e4,oe=36e5;function vn(e,t){return re(e,t*oe)}let _n={};function G(){return _n}function C(e,t){const n=G(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=w(e),r=a.getDay(),i=(r<s?7:0)+r-s;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function j(e){return C(e,{weekStartsOn:1})}function de(e){const t=w(e),n=t.getFullYear(),s=$(e,0);s.setFullYear(n+1,0,4),s.setHours(0,0,0,0);const a=j(s),r=$(e,0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);const i=j(r);return t.getTime()>=a.getTime()?n+1:t.getTime()>=i.getTime()?n:n-1}function U(e){const t=w(e);return t.setHours(0,0,0,0),t}function dt(e){const t=w(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function St(e,t){const n=U(e),s=U(t),a=+n-dt(n),r=+s-dt(s);return Math.round((a-r)/Sn)}function vt(e){const t=de(e),n=$(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),j(n)}function Dn(e,t){return re(e,t*ie)}function Tn(e,t){const n=t*3;return xt(e,n)}function ce(e,t){const n=t*7;return it(e,n)}function Mn(e,t){return xt(e,t*12)}function R(e,t){const n=w(e),s=w(t),a=n.getTime()-s.getTime();return a<0?-1:a>0?1:a}function $n(e,t){const n=U(e),s=U(t);return+n==+s}function Hn(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Wn(e){if(!Hn(e)&&typeof e!="number")return!1;const t=w(e);return!isNaN(Number(t))}function _t(e,t){const n=j(e),s=j(t),a=+n-dt(n),r=+s-dt(s);return Math.round((a-r)/ot)}function In(e,t){const n=w(e),s=w(t),a=n.getFullYear()-s.getFullYear(),r=n.getMonth()-s.getMonth();return a*12+r}function En(e,t){const n=w(e),s=w(t);return n.getFullYear()-s.getFullYear()}function Dt(e){return t=>{const n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function ue(e,t){return+w(e)-+w(t)}function Pn(e,t,n){const s=ue(e,t)/oe;return Dt(n?.roundingMethod)(s)}function Cn(e,t,n){const s=ue(e,t)/ie;return Dt(n?.roundingMethod)(s)}function le(e){const t=w(e);return t.setHours(23,59,59,999),t}function Tt(e){const t=w(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function On(e){const t=w(e);return+le(t)==+Tt(t)}function he(e,t){const n=w(e),s=w(t),a=R(n,s),r=Math.abs(In(n,s));let i;if(r<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*r);let o=R(n,s)===-a;On(w(e))&&r===1&&R(e,s)===1&&(o=!1),i=a*(r-Number(o))}return i===0?0:i}function Nn(e,t,n){const s=he(e,t)/3;return Dt(n?.roundingMethod)(s)}function zn(e,t){const n=w(e),s=w(t),a=R(n,s),r=Math.abs(En(n,s));n.setFullYear(1584),s.setFullYear(1584);const i=R(n,s)===-a,o=a*(r-+i);return o===0?0:o}function J(e){const t=w(e),n=t.getMonth(),s=n-n%3;return t.setMonth(s,1),t.setHours(0,0,0,0),t}function fe(e){const t=w(e);return t.setDate(1),t.setHours(0,0,0,0),t}function An(e){const t=w(e),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(23,59,59,999),t}function ge(e){const t=w(e),n=$(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Un(e){const t=w(e);return t.setMinutes(59,59,999),t}function Yn(e,t){const n=G(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=w(e),r=a.getDay(),i=(r<s?-7:0)+6-(r-s);return a.setDate(a.getDate()+i),a.setHours(23,59,59,999),a}function Mt(e){const t=w(e),n=t.getMonth(),s=n-n%3+3;return t.setMonth(s,0),t.setHours(23,59,59,999),t}const Bn={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Fn=(e,t,n)=>{let s;const a=Bn[e];return typeof a=="string"?s=a:t===1?s=a.one:s=a.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function $t(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const jn={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},qn={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Ln={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Xn={date:$t({formats:jn,defaultWidth:"full"}),time:$t({formats:qn,defaultWidth:"full"}),dateTime:$t({formats:Ln,defaultWidth:"full"})},Qn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Gn=(e,t,n,s)=>Qn[e];function V(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let a;if(s==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):i;a=e.formattingValues[o]||e.formattingValues[i]}else{const i=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[i]}const r=e.argumentCallback?e.argumentCallback(t):t;return a[r]}}const Rn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Jn={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Vn={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Kn={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Zn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},ts={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},es=(e,t)=>{const n=Number(e),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},ns={ordinalNumber:es,era:V({values:Rn,defaultWidth:"wide"}),quarter:V({values:Jn,defaultWidth:"wide",argumentCallback:e=>e-1}),month:V({values:Vn,defaultWidth:"wide"}),day:V({values:Kn,defaultWidth:"wide"}),dayPeriod:V({values:Zn,defaultWidth:"wide",formattingValues:ts,defaultFormattingWidth:"wide"})};function K(e){return(t,n={})=>{const s=n.width,a=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],r=t.match(a);if(!r)return null;const i=r[0],o=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(o)?as(o,l=>l.test(i)):ss(o,l=>l.test(i));let c;c=e.valueCallback?e.valueCallback(d):d,c=n.valueCallback?n.valueCallback(c):c;const u=t.slice(i.length);return{value:c,rest:u}}}function ss(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function as(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function rs(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const a=s[0],r=t.match(e.parsePattern);if(!r)return null;let i=e.valueCallback?e.valueCallback(r[0]):r[0];i=n.valueCallback?n.valueCallback(i):i;const o=t.slice(a.length);return{value:i,rest:o}}}const is=/^(\d+)(th|st|nd|rd)?/i,os=/\d+/i,ds={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},cs={any:[/^b/i,/^(a|c)/i]},us={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ls={any:[/1/i,/2/i,/3/i,/4/i]},hs={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},fs={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},gs={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ps={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},ms={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ks={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ys={ordinalNumber:rs({matchPattern:is,parsePattern:os,valueCallback:e=>parseInt(e,10)}),era:K({matchPatterns:ds,defaultMatchWidth:"wide",parsePatterns:cs,defaultParseWidth:"any"}),quarter:K({matchPatterns:us,defaultMatchWidth:"wide",parsePatterns:ls,defaultParseWidth:"any",valueCallback:e=>e+1}),month:K({matchPatterns:hs,defaultMatchWidth:"wide",parsePatterns:fs,defaultParseWidth:"any"}),day:K({matchPatterns:gs,defaultMatchWidth:"wide",parsePatterns:ps,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:ms,defaultMatchWidth:"any",parsePatterns:ks,defaultParseWidth:"any"})},bs={code:"en-US",formatDistance:Fn,formatLong:Xn,formatRelative:Gn,localize:ns,match:ys,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ws(e){const t=w(e);return St(t,ge(t))+1}function xs(e){const t=w(e),n=+j(t)-+vt(t);return Math.round(n/ot)+1}function pe(e,t){const n=w(e),s=n.getFullYear(),a=G(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=$(e,0);i.setFullYear(s+1,0,r),i.setHours(0,0,0,0);const o=C(i,t),d=$(e,0);d.setFullYear(s,0,r),d.setHours(0,0,0,0);const c=C(d,t);return n.getTime()>=o.getTime()?s+1:n.getTime()>=c.getTime()?s:s-1}function Ss(e,t){const n=G(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=pe(e,t),r=$(e,0);return r.setFullYear(a,0,s),r.setHours(0,0,0,0),C(r,t)}function vs(e,t){const n=w(e),s=+C(n,t)-+Ss(n,t);return Math.round(s/ot)+1}function D(e,t){const n=e<0?"-":"",s=Math.abs(e).toString().padStart(t,"0");return n+s}const O={y(e,t){const n=e.getFullYear(),s=n>0?n:1-n;return D(t==="yy"?s%100:s,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):D(n+1,2)},d(e,t){return D(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return D(e.getHours()%12||12,t.length)},H(e,t){return D(e.getHours(),t.length)},m(e,t){return D(e.getMinutes(),t.length)},s(e,t){return D(e.getSeconds(),t.length)},S(e,t){const n=t.length,s=e.getMilliseconds(),a=Math.trunc(s*Math.pow(10,n-3));return D(a,t.length)}},q={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},me={G:function(e,t,n){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});case"GGGG":default:return n.era(s,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const s=e.getFullYear(),a=s>0?s:1-s;return n.ordinalNumber(a,{unit:"year"})}return O.y(e,t)},Y:function(e,t,n,s){const a=pe(e,s),r=a>0?a:1-a;if(t==="YY"){const i=r%100;return D(i,2)}return t==="Yo"?n.ordinalNumber(r,{unit:"year"}):D(r,t.length)},R:function(e,t){const n=de(e);return D(n,t.length)},u:function(e,t){const n=e.getFullYear();return D(n,t.length)},Q:function(e,t,n){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return D(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,n){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return D(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,n){const s=e.getMonth();switch(t){case"M":case"MM":return O.M(e,t);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,n){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return D(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,n,s){const a=vs(e,s);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):D(a,t.length)},I:function(e,t,n){const s=xs(e);return t==="Io"?n.ordinalNumber(s,{unit:"week"}):D(s,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):O.d(e,t)},D:function(e,t,n){const s=ws(e);return t==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):D(s,t.length)},E:function(e,t,n){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(s,{width:"short",context:"formatting"});case"EEEE":default:return n.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,n,s){const a=e.getDay(),r=(a-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(r);case"ee":return D(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,s){const a=e.getDay(),r=(a-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(r);case"cc":return D(r,t.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const s=e.getDay(),a=s===0?7:s;switch(t){case"i":return String(a);case"ii":return D(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});case"iiii":default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const s=e.getHours();let a;switch(s===12?a=q.noon:s===0?a=q.midnight:a=s/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const s=e.getHours();let a;switch(s>=17?a=q.evening:s>=12?a=q.afternoon:s>=4?a=q.morning:a=q.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let s=e.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return O.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):O.H(e,t)},K:function(e,t,n){const s=e.getHours()%12;return t==="Ko"?n.ordinalNumber(s,{unit:"hour"}):D(s,t.length)},k:function(e,t,n){let s=e.getHours();return s===0&&(s=24),t==="ko"?n.ordinalNumber(s,{unit:"hour"}):D(s,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):O.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):O.s(e,t)},S:function(e,t){return O.S(e,t)},X:function(e,t,n){const s=e.getTimezoneOffset();if(s===0)return"Z";switch(t){case"X":return ye(s);case"XXXX":case"XX":return Y(s);case"XXXXX":case"XXX":default:return Y(s,":")}},x:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"x":return ye(s);case"xxxx":case"xx":return Y(s);case"xxxxx":case"xxx":default:return Y(s,":")}},O:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+ke(s,":");case"OOOO":default:return"GMT"+Y(s,":")}},z:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+ke(s,":");case"zzzz":default:return"GMT"+Y(s,":")}},t:function(e,t,n){const s=Math.trunc(e.getTime()/1e3);return D(s,t.length)},T:function(e,t,n){const s=e.getTime();return D(s,t.length)}};function ke(e,t=""){const n=e>0?"-":"+",s=Math.abs(e),a=Math.trunc(s/60),r=s%60;return r===0?n+String(a):n+String(a)+t+D(r,2)}function ye(e,t){return e%60===0?(e>0?"-":"+")+D(Math.abs(e)/60,2):Y(e,t)}function Y(e,t=""){const n=e>0?"-":"+",s=Math.abs(e),a=D(Math.trunc(s/60),2),r=D(s%60,2);return n+a+t+r}const be=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},we=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},_s=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],s=n[1],a=n[2];if(!a)return be(e,t);let r;switch(s){case"P":r=t.dateTime({width:"short"});break;case"PP":r=t.dateTime({width:"medium"});break;case"PPP":r=t.dateTime({width:"long"});break;case"PPPP":default:r=t.dateTime({width:"full"});break}return r.replace("{{date}}",be(s,t)).replace("{{time}}",we(a,t))},Ds={p:we,P:_s},Ts=/^D+$/,Ms=/^Y+$/,$s=["D","DD","YY","YYYY"];function Hs(e){return Ts.test(e)}function Ws(e){return Ms.test(e)}function Is(e,t,n){const s=Es(e,t,n);if(console.warn(s),$s.includes(e))throw new RangeError(s)}function Es(e,t,n){const s=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Ps=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Cs=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Os=/^'([^]*?)'?$/,Ns=/''/g,zs=/[a-zA-Z]/;function As(e,t,n){const s=G(),a=n?.locale??s.locale??bs,r=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,o=w(e);if(!Wn(o))throw new RangeError("Invalid time value");let d=t.match(Cs).map(u=>{const l=u[0];if(l==="p"||l==="P"){const h=Ds[l];return h(u,a.formatLong)}return u}).join("").match(Ps).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const l=u[0];if(l==="'")return{isToken:!1,value:Us(u)};if(me[l])return{isToken:!0,value:u};if(l.match(zs))throw new RangeError("Format string contains an unescaped latin alphabet character `"+l+"`");return{isToken:!1,value:u}});a.localize.preprocessor&&(d=a.localize.preprocessor(o,d));const c={firstWeekContainsDate:r,weekStartsOn:i,locale:a};return d.map(u=>{if(!u.isToken)return u.value;const l=u.value;(!n?.useAdditionalWeekYearTokens&&Ws(l)||!n?.useAdditionalDayOfYearTokens&&Hs(l))&&Is(l,t,String(e));const h=me[l[0]];return h(o,l,a.localize,c)}).join("")}function Us(e){const t=e.match(Os);return t?t[1].replace(Ns,"'"):e}function xe(e){const t=w(e),n=t.getFullYear(),s=t.getMonth(),a=$(e,0);return a.setFullYear(n,s+1,0),a.setHours(0,0,0,0),a.getDate()}function Ys(e){const t=w(e).getFullYear();return t%400===0||t%4===0&&t%100!==0}function Se(e){const t=w(e);return String(new Date(t))==="Invalid Date"?NaN:Ys(t)?366:365}function Bs(e){const t=vt(e),n=+vt(ce(t,60))-+t;return Math.round(n/ot)}function H(e,t){const n=w(e),s=w(t);return+n==+s}function Fs(e){const t=w(e);return t.setMinutes(0,0,0),t}function js(e,t,n){const s=C(e,n),a=C(t,n);return+s==+a}function qs(e,t){const n=w(e),s=w(t);return n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()}function Ls(e,t){const n=J(e),s=J(t);return+n==+s}function Xs(e,t){const n=w(e),s=w(t);return n.getFullYear()===s.getFullYear()}const Ht={year:zn,quarter:Nn,month:he,week:_t,day:St,hour:Pn,minute:Cn},N={year:{quarter:4,month:12,week:Bs,day:Qs,hour:Gs},quarter:{month:3,week:Rs,day:ve,hour:Js},month:{week:Vs,day:Ks,hour:Zs},week:{day:7,hour:24*7},day:{hour:24},hour:{minute:60}};function Qs(e){return e?Se(e):365}function Gs(e){return Se(e)*24}function Rs(e){const t=J(e),n=it(U(Mt(e)),1);return _t(n,t)}function ve(e){if(e){const t=J(e),n=Mt(e);return St(n,t)+1}return 91}function Js(e){return ve(e)*24}function Vs(e){if(e){const t=fe(e),n=it(U(Tt(e)),1);return _t(n,t)}return 5}function Ks(e){return e?xe(e):30}function Zs(e){return xe(e)*24}function ct(e,t,n){const s=N[e][t];return s?typeof s=="number"?s:s(n):1}function ta(e,t){return e===t||!!(N[e]&&N[e][t])}const ut={year:Mn,quarter:Tn,month:xt,week:ce,day:it,hour:vn,minute:Dn};function E(e,t,n){if(t){if(e==="day")return(s,a)=>t.getWorkingDays(a,s,!0);if(e==="hour")return(s,a)=>t.getWorkingHours(a,s,!0)}return(s,a,r,i)=>!N[e][r]||typeof N[e][r]=="number"||Te(e,s,a,n)?Z(e,s,a,r,i,n):ea(s,a,e,r,i,n)}function Z(e,t,n,s,a,r){const i=s||e;let o=n,d=t;if(a&&(o=I(i,n,r),d=I(i,t,r),d<t&&(d=T(i)(d,1))),e!==i){const c=Ht[i](d,o),u=ct(e,i,n);return c/u}else return Ht[i](d,o)}function ea(e,t,n,s,a,r){let i=0;const o=I(n,t,r);if(t>o){const c=ut[n](o,1);i=Z(n,c,t,s,void 0,r),t=c}let d=0;return Te(n,t,e,r)||(d=Z(n,I(n,e,r),t,void 0,void 0,r),t=ut[n](t,d)),d+=i+Z(n,e,t,s,void 0,r),!d&&a&&(d=Z(n,e,t,s,a,r)),d}function T(e,t){if(t){if(e==="day")return(n,s)=>t.addWorkingDays(n,s,!0);if(e==="hour")return(n,s)=>t.addWorkingHours(n,s)}return ut[e]}const _e={year:ge,quarter:J,month:fe,week:(e,t)=>C(e,{weekStartsOn:t}),day:U,hour:Fs};function I(e,t,n){const s=_e[e];return s?s(t,n):new Date(t)}const na={year:An,quarter:Mt,month:Tt,week:(e,t)=>Yn(e,{weekStartsOn:t}),day:le,hour:Un},De={year:Xs,quarter:Ls,month:qs,week:(e,t,n)=>js(e,t,{weekStartsOn:n}),day:$n};function Te(e,t,n,s){const a=De[e];return a?a(t,n,s):!1}const sa={start:_e,end:na,add:ut,isSame:De,diff:Ht,smallerCount:N},Me=e=>typeof e=="function"?e(new Date):e;function aa(e,t){for(const n in t){if(n==="smallerCount"){const s=Object.keys(t[n]).sort((o,d)=>W.indexOf(o)-W.indexOf(d)).shift();let a=W.indexOf(s);const r=t[n][s],i=Me(r);for(let o=a-1;o>=0;o--){const d=W[o],c=Me(N[d][s]);if(i<=c)break;a=o}W.splice(a,0,e)}if(n==="biggerCount")for(const s in t[n])N[s][e]=t[n][s];else sa[n][e]=t[n]}}function Wt(e,t=1,n){return n.isWorkingDay(e)||(e=t>0?n.getNextWorkingDay(e):n.getPreviousWorkingDay(e)),e}function lt(e){return(t,n)=>{if(n>0)for(let s=0;s<n;s++)t=e.getNextWorkingDay(t);if(n<0)for(let s=0;s>n;s--)t=e.getPreviousWorkingDay(t);return t}}function L(e){const t=new Date;return e.map(n=>({item:n,len:T(n.unit)(t,1)})).sort((n,s)=>n.len<s.len?-1:1)[0].item}const W=["year","quarter","month","week","day","hour"],It=50,Et=300;function ra(e,t,n,s,a){let r=e,i=t,o=!1,d=!1;a&&a.forEach(u=>{(!e||n)&&(!r||u.start<=r)&&(r=u.start,o=!0);const l=u.type==="milestone"?u.start:u.end;(!t||n)&&(!i||l>=i)&&(i=l,d=!0)});const c=T(s||"day");return r?o&&(r=c(r,-1)):i?r=c(i,-30):r=new Date,i?d&&(i=c(i,1)):i=c(r,30),{_start:r,_end:i}}function ia(e,t,n,s,a,r,i){const o=L(i).unit,d=E(o,void 0,r),c=d(t,e,"",!0),u=I(o,t,r);e=I(o,e,r),t=u<t?T(o)(u,1):u;const l=c*s,h=a*i.length,f=i.map(g=>{const m=[],k=T(g.unit);let y=I(g.unit,e,r);for(;y<t;){const b=k(y,g.step),_=y<e?e:y,x=b>t?t:b,S=d(x,_,"",!0)*s,v=typeof g.format=="function"?g.format(y,b):g.format;let M="";g.css&&(M+=typeof g.css=="function"?g.css(y):g.css),m.push({width:S,value:v,date:_,css:M,unit:g.unit}),y=b}return{cells:m,add:k,height:a}});let p=s;return o!==n&&(p=Math.round(p/ct(o,n))||1),{rows:f,width:l,height:h,diff:d,start:e,end:t,lengthUnit:n,minUnit:o,lengthUnitWidth:p}}function oa(e,t,n,s){const a=typeof e=="boolean"?{}:e,r=W.indexOf(L(n).unit);if(typeof a.level>"u"&&(a.level=r),a.levels)a.levels.forEach(d=>{d.minCellWidth||(d.minCellWidth=ht(a.minCellWidth,It)),d.maxCellWidth||(d.maxCellWidth=ht(a.maxCellWidth,Et))});else{const d=[],c=n.length||1,u=ht(a.minCellWidth,It),l=ht(a.maxCellWidth,Et);n.forEach(h=>{h.format&&!t[h.unit]&&(t[h.unit]=h.format)}),W.forEach((h,f)=>{if(f===r)d.push({minCellWidth:u,maxCellWidth:l,scales:n});else{const p=[];if(f)for(let g=c-1;g>0;g--){const m=W[f-g];m&&p.push({unit:m,step:1,format:t[m]})}p.push({unit:h,step:1,format:t[h]}),d.push({minCellWidth:u,maxCellWidth:l,scales:p})}}),a.levels=d}a.levels[a.level]||(a.level=0);const i=a.levels[a.level],o=Math.min(Math.max(s,i.minCellWidth),i.maxCellWidth);return{zoom:a,scales:i.scales,cellWidth:o}}function da(e,t,n,s,a,r,i){e.level=n;let o;const d=s.scales||s,c=L(d).unit,u=ca(c,a);if(t===-1){const f=ct(c,a);o=i*f}else{const f=ct(L(r).unit,c);o=Math.round(i/f)}const l=s.minCellWidth??It,h=s.maxCellWidth??Et;return{scales:d,cellWidth:Math.min(h,Math.max(l,o)),lengthUnit:u,zoom:e}}function ca(e,t){const n=W.indexOf(e),s=W.indexOf(t);return s>=n?e==="hour"?"hour":"day":W[s]}function ht(e,t){return e??t}function Pt(){let e=!0;return e=!1,e}const Ct=8,$e=4,ua=3,He=7,la=Ct+$e;function We(e,t,n,s){(e.open||e.type!="summary")&&e.data?.forEach(a=>{typeof a.$x>"u"&&Ee(a,n,s),a.$x+=t,We(a,t,n,s)})}function Ot(e,t,n,s){const a=e.getSummaryId(t.id);if(a){const r=e.byId(a),i={xMin:1/0,xMax:0};Ie(r,i,n,s),r.$x=i.xMin,r.$w=i.xMax-i.xMin,Ot(e,r,n,s)}}function Ie(e,t,n,s){e.data?.forEach(a=>{if(!a.unscheduled){typeof a.$x>"u"&&Ee(a,n,s);const r=a.type==="milestone"&&a.$h?a.$h/2:0;t.xMin>a.$x&&(t.xMin=a.$x+r);const i=a.$x+a.$w-r;t.xMax<i&&(t.xMax=i)}a.type!=="summary"&&Ie(a,t,n,s)})}function Ee(e,t,n){e.$x=Math.round(t.diff(e.start,t.start,t.lengthUnit)*n),e.$w=Math.round(t.diff(e.end,e.start,t.lengthUnit,!0)*n)}function Nt(e,t){let n;t&&(n=t.filter(a=>a.parent==e.id));const s={data:n,...e};if(s.data?.length)s.data.forEach(a=>{if(a.unscheduled&&!a.data)return;(t||a.type!="summary"&&a.data)&&(a.unscheduled&&(a={...a,start:void 0,end:void 0}),a=Nt(a,t)),a.start&&(!s.start||s.start>a.start)&&(s.start=new Date(a.start));const r=a.end||a.start;r&&(!s.end||s.end<r)&&(s.end=new Date(r))});else if(e.type==="summary")throw Error("Summary tasks must have start and end dates if they have no subtasks");return s}function Pe(e,t,n){return Ce(e,t,n,!1),n.splitTasks&&e.segments?.forEach(s=>{Pe(s,t,{...n,baselines:!1}),s.$x-=e.$x}),n.baselines&&Ce(e,t,n,!0),e}function Ce(e,t,n,s){const{cellWidth:a,cellHeight:r,_scales:i,baselines:o}=n,{start:d,end:c,lengthUnit:u,diff:l}=i,h=(s?"base_":"")+"start",f=(s?"base_":"")+"end",p="$x"+(s?"_base":""),g="$y"+(s?"_base":""),m="$w"+(s?"_base":""),k="$h"+(s?"_base":""),y="$skip"+(s?"_baseline":"");let b=e[h],_=e[f];if(s&&!b){e[y]=!0;return}e[h]<d&&(e[f]<d||H(e[f],d))?b=_=d:e[h]>c&&(b=_=c),e[p]=Math.round(l(b,d,u)*a),e[g]=s?e.$y+e.$h+$e:r*t+ua,e[m]=Math.round(l(_,b,u,!0)*a),e[k]=s?Ct:o?r-He-la:r-He,e.type==="milestone"&&(e[p]=e[p]-e.$h/2,e[m]=e.$h,s&&(e[g]=e.$y+Ct,e[m]=e[k]=e.$h)),n.unscheduledTasks&&e.unscheduled&&!s?e.$skip=!0:e[y]=H(b,_)}function ha(e,t){if(Pt())return!1;const{mode:n,l:s,w:a,dx:r,index:i}=t,{segments:o}=e;if(i||n==="end"){if(r>0&&i<o.length-1){if(s+a+r>o[i+1].$x+e.$x)return!1}else if(r<0&&i){const d=n==="end"?a:0;if(s+r+d<o[i-1].$x+e.$x+o[i-1].$w)return!1}}return!0}function fa(e,t){if(Pt())return;const{segments:n}=e,{segmentIndex:s,mode:a}=t,r=n[s];(s||a!=="move")&&(t.index=s,t.l=r.$x+e.$x,t.w=r.$w,t.segment=!0)}const zt=20,ga=function(e,t,n,s,a){const r=Math.round(s/2)-3;if(!t||!n||!t.$y||!n.$y||t.$skip||n.$skip)return e.$p="",e.$pl=0,e;let i=!1,o=!1;switch(e.type){case"e2s":o=!0;break;case"s2s":i=!0,o=!0;break;case"s2e":i=!0;break}const d=i?t.$x:t.$x+t.$w,c=a?t.$y-7:t.$y,u=o?n.$x:n.$x+n.$w,l=a?n.$y-7:n.$y;if(d!==u||c!==l){const h=ma(d,c+r,u,l+r,i,o,s/2,a),f=ka(u,l+r,o);e.$p=`${h},${f}`,e.$pl=pa(e.$p)}return e};function pa(e){const t=e.split(",").map(Number),n=[];for(let a=0;a<t.length;a+=2)a+1<t.length&&n.push([t[a],t[a+1]]);let s=0;for(let a=0;a<n.length-1;a++){const[r,i]=n[a],[o,d]=n[a+1];s+=Math.hypot(o-r,d-i)}return s}function ma(e,t,n,s,a,r,i,o){const d=zt*(a?-1:1),c=zt*(r?-1:1),u=e+d,l=n+c,h=[e,t,u,t,0,0,0,0,l,s,n,s],f=l-u;let p=s-t;const g=r===a;return g||(l<=e+zt-2&&r||l>e&&!r)&&(p=o?p-i+6:p-i),g&&r&&u>l||g&&!r&&u<l?(h[4]=h[2]+f,h[5]=h[3],h[6]=h[4],h[7]=h[5]+p):(h[4]=h[2],h[5]=h[3]+p,h[6]=h[4]+f,h[7]=h[5]),h.join(",")}function ka(e,t,n){return n?`${e-5},${t-3},${e-5},${t+3},${e},${t}`:`${e+5},${t+3},${e+5},${t-3},${e},${t}`}function ya(e,t,n){if(t&&n){const s=n.x-t.x,a=n.y-t.y,r=(s>0?t.x:n.x)-e.left,i=(a>0?t.y:n.y)-e.top,o=`${s>0?0:-s},${a>0?0:-a},${s>0?s:0},${a>0?a:0}`;return{width:Math.abs(s),height:Math.abs(a),left:r,top:i,p:o}}else return null}function Oe(e){return e.map(t=>{const n=t.id||bt();return{...t,id:n}})}const Ne=["start","end","duration"];function ba(e,t){const{type:n,unscheduled:s}=e;return s||n==="summary"?!Ne.includes(t):n==="milestone"?!["end","duration"].includes(t):!0}function wa(e,t){return typeof t=="function"?t:Ne.includes(e)?(typeof t=="string"&&(t={type:t,config:{}}),t.config||(t.config={}),t.type==="datepicker"&&(t.config.buttons=["today"]),(n,s)=>ba(n,s.id)?t:null):t}function xa(e){return!e||!e.length?[]:e.map(t=>{const n=t.align||"left",s=t.id==="add-task",a=!s&&t.flexgrow?t.flexgrow:null,r=a?1:t.width||(s?50:120),i=t.editor&&wa(t.id,t.editor);return{width:r,align:n,header:t.header,id:t.id,template:t.template,_template:t._template,...a&&{flexgrow:a},cell:t.cell,resize:t.resize??!0,sort:t.sort??!s,...i&&{editor:i},...t.options&&{options:t.options}}})}const Sa=[{id:"text",header:"Task name",flexgrow:1,sort:!0},{id:"start",header:"Start date",align:"center",sort:!0},{id:"duration",header:"Duration",width:100,align:"center",sort:!0},{id:"add-task",header:"Add task",width:50,align:"center",sort:!1,resize:!1}];function tt(e,t,n,s){const{selected:a,tasks:r}=e.getState(),i=a.length,o=["edit-task","paste-task","edit-task:task","edit-task:segment"],d=["copy-task","cut-task"],c=["copy-task","cut-task","delete-task","indent-task:remove","move-task:down"],u=["add-task","undo","redo"],l=["indent-task:add","move-task:down","move-task:up"],h={"indent-task:remove":2},f=!i&&u.includes(t),p={parent:l.includes(t),level:h[t]};if(n=n||(i?a[a.length-1]:null),!(!n&&!f)){if(t!=="paste-task"&&(e._temp=null),o.includes(t)||f||a.length===1)ze(e,t,n,s);else if(i){const g=d.includes(t)?a:va(a,r,p);c.includes(t)&&g.reverse();const m=e.getHistory();m&&m.startBatch(),g.forEach((k,y)=>ze(e,t,k,s,y)),m&&m.endBatch()}}}function va(e,t,n){let s=e.map(a=>{const r=t.byId(a);return{id:a,level:r.$level,parent:r.parent,index:t.getIndexById(a)}});return(n.parent||n.level)&&(s=s.filter(a=>n.level&&a.level<=n.level||!e.includes(a.parent))),s.sort((a,r)=>a.level-r.level||a.index-r.index),s.map(a=>a.id)}function ze(e,t,n,s,a){const r=e.exec?e.exec:e.in.exec;let i=t.split(":")[0],o=t.split(":")[1];const d=n?.id||n;let c={id:d},u={},l=!1;if(i=="copy-task"||i=="cut-task"){e._temp||(e._temp=[]),e._temp.push({id:d,cut:i=="cut-task"});return}else if(i=="paste-task"){if(e._temp&&e._temp.length){const h=e.getHistory();h&&h.startBatch();const f=new Map;if(e._temp.forEach(p=>{const g={id:p.id,target:d,mode:"after"};r(p.cut?"move-task":"copy-task",g),f.set(p.id,g.id)}),!e._temp[0].cut){const{links:p}=e.getState(),g=e._temp.map(k=>k.id),m=[];p.forEach(k=>{g.includes(k.source)&&g.includes(k.target)&&m.push(k)}),m.forEach(k=>{r("add-link",{link:{source:f.get(k.source),target:f.get(k.target),type:k.type}})}),e._temp.forEach((k,y)=>{r("select-task",{id:f.get(k.id),toggle:!!y})})}h&&h.endBatch(),e._temp=null}return}else i==="add-task"?(u={task:{type:"task",text:s("New Task")},target:d,show:!0,select:!1},c={},l=!0):i==="edit-task"?(i="show-editor",o==="segment"&&typeof n=="object"&&(u=n)):i==="convert-task"?(i="update-task",u={task:{type:o}},o=void 0):i==="indent-task"&&(o=o==="add");if(i==="split-task"&&typeof n=="object")u=n;else if(i==="delete-task"&&o==="segment"&&typeof n=="object"){const h=e.getTask(d),{segmentIndex:f}=n,p=h.segments.filter((g,m)=>m!==f);r("update-task",{id:d,task:{segments:p}});return}typeof o<"u"&&(u={mode:o,...u}),c={...c,...u},r(i,c),l&&r("select-task",{id:c.id,toggle:!!a})}function Ae(e,t){return e.some(n=>n.data?Ae(n.data,t):n.id===t)}const Ue=(e,t)=>T(e,t),_a=(e,t)=>E(e,t);function Ye(e,t){Array.isArray(e)&&(e.forEach(n=>z(n,t)),e.forEach(n=>{if(n.type==="summary"&&!(n.start&&n.end)){const{start:s,end:a}=Nt(n,e);n.start=s,n.end=a,z(n,t)}}))}function z(e,t){e.unscheduled||At(e,t,!1),e.base_start&&At(e,t,!0)}function At(e,t,n){const{calendar:s,durationUnit:a}=t,r=a||"day",[i,o,d]=Be(n);if(e.type==="milestone")e[d]=0,e[o]=void 0;else if(e[i]){if(!n&&t.splitTasks&&e.segments)return Ta(e,t);e[d]?e[o]=Ue(r,s)(e[i],e[d]):e[o]?e[d]=_a(r,s)(e[o],e[i]):(e[o]=Ue(r,s)(e[i],1),e[d]=1)}}function Be(e){return e?["base_start","base_end","base_duration"]:["start","end","duration"]}function Fe(e,t,n){const[s,a,r]=Be(n);(t===r||t===s)&&(e[a]=null),t===a&&(e[r]=0,e[s]&&e[s]>=e[a]&&(e[a]=null,e[r]=1))}function Da(e,t,n){Fe(e,n,!1),e.base_start&&Fe(e,n,!0),z(e,t)}function Ta(e,t){if(!e.segments.length||e.type==="summary"||e.duration===0)return;const{segments:n}=e,s=e.start&&e.end===null&&e.duration,{_scales:a,calendar:r}=t,i=s&&T(a.lengthUnit,r);let o=0;for(let d=0;d<n.length&&(!s||o!==s);d++){const c=n[d];At(c,t),s&&(s<=o+c.duration||d===n.length-1)?(e.end=i(c.start,s-o),o=s):o+=c.duration}e.duration=o,s||(e.end=n[n.length-1].end)}function Ma(e,t){const{left:n,width:s,segmentIndex:a}=t,r=typeof n<"u",i=typeof s<"u",{segments:o}=e;if(!o?.length||!r&&!i)return;const d=o[a];if(r){const l=n-e.$x;if(a)d.$x=l;else for(let h=1;h<o.length;h++)o[h].$x+=-l}i&&(d.$w=s);const c=o.length;let u=!1;if(!a&&i||a===o.length-1){const l=o[c-1];t.width=l.$x-o[0].$x+l.$w,u=!0}else delete t.width;return!a&&r?u=!0:delete t.left,u}function je(e,t){return e.map(n=>(delete n.duration,z(n,t),n))}function qe(e,t,n,s,a){let r=t.segments||e.segments;const i=r?.length;if(!i||Ut(t)||t.segments===null)return{...t,segments:null};let o=e;const d=s||s===0;d&&(o=e.segments[s]);const{_scales:c,calendar:u}=n,{lengthUnit:l}=c,h=t.start&&!H(o.start,t.start),f=t.end&&!H(o.end,t.end),p=E(l,u),g=E(l),m=T(l,u),k=T(l),y=u?lt(u):m;r=r.map(S=>({...S}));const b=h?g(t.start,o.start):0,_=f?g(t.end,o.end):0;if(u){if(b&&!u.isWorkingDay(t.start)&&(t.start=y(t.start,b>0||!a?1:-1)),_)if(h)t.end=y(t.start,t.duration||o.duration);else{const S=k(t.end,-1);u.isWorkingDay(S)||(t.end=y(t.end,_>0||!a?1:-1),_<0&&a&&(t.end=k(t.end,1)))}b&&H(t.end,t.start)&&(t.end=m(t.end,1))}let x;if(d&&(x={...t},t={}),h||f){if(d){let S,v;i>1&&(S=s>0?r[s-1]:null,v=s<i-1?r[s+1]:null,h&&(S&&(x.start<S.end||H(x.start,S.start))?x.start=S.end:v&&x.start.valueOf()>=v.start.valueOf()&&(x.start=m(v.start,-1))),f&&(v&&x.end>v.start?x.end=v.start:S&&x.end<S.end&&(x.end=m(S.end,1))));const M=r[s];if(h&&S&&!p(x.start,S.end)){if(x.start=S.start,u){const F=p(x.end||M.end,S.end)||1;x.duration=S.duration+F,x.end=m(x.start,x.duration)}r.splice(s-1,1),s--}else if(f&&v&&!p(v.start,x.end)){if(x.end=v.end,u){const F=p(v.start,x.start||M.start)||1;x.duration=v.duration+F,x.start=y(x.end,-x.duration)}r.splice(s+1,1)}r[s]={...M,...x}}else if(h){const S=Le(l,u);let v=0;b>0?v=p(t.start,r[0].start):v=-p(e.start,t.start),v&&(r=r.map(M=>(M.start=y(M.start,v),M.end=S(M.start,M.duration),M))),u&&Xe(r,c.lengthUnit,0,u,v),t.end=r[r.length-1].end}else if(f)if(_>0)r[i-1].end=t.end;else for(let S=i-1;S>=0;S--){const v=r[S];v.start.valueOf()>=t.end.valueOf()?r.splice(S,1):S===r.length-1&&(v.end=t.end)}t.segments=je(r,n)}else d&&(r[s]={...r[s],...x},t.segments=r);return(d||t.segments)&&(r=t.segments||r,t.start=r[0].start,t.end=r[r.length-1].end),r.length<2&&(t.segments=null),t}function $a(e,t,n){const{_scales:s,calendar:a}=n;let r,{segments:i}=e;const o=i?.length;o&&(typeof t>"u"&&(t=o-1),r=i[t]);const d=r||e;i=i?.map(_=>({..._}));const{lengthUnit:c}=s,u=d.duration;if(u<=1)return null;const l={},h=T(c,a),f=Le(c,a),p=E(c,a),g=a?lt(a):h,m=u-Math.round(u/2),k=u-m,y=f(d.start,k);r||(i=l.segments=[],i.push({start:d.start,end:y})),t=t||0,i[t].end=y;let b=g(y,1);return a&&!p(b,y)&&(b=g(b,1)),i.splice(t+1,0,{start:b,end:g(b,m)}),Xe(i,c,t+1,a),l.end=i[i.length-1].end,l.segments=je(i,n),l}function Ut(e){return e.type==="summary"||e.type==="milestone"}function Ha(e,t,n){if(Ut(e))return!0;const{_scales:s,calendar:a}=t,{lengthUnit:r}=s;let i=e;const{segments:o}=e;return o?.length&&(typeof n>"u"&&(n=o.length-1),i=e.segments[n]),E(r,a)(i.end,i.start)<2}function Le(e,t){const n=T(e);if(!t)return n;const s=T(e,t);return(a,r)=>{const i=s(a,r-1);return t.isWorkingDay(i)?n(i,1):s(i,1)}}function Xe(e,t,n,s,a){const r=T(t,s),i=E(t),o=s?lt(s):null;for(let d=n+1;d<e.length;d++){const c=e[d],u=e[d-1].end,l=i(c.start,u);l<1?(c.start=r(u,1),c.end=r(c.start,c.duration)):s&&!s.isWorkingDay(c.start)&&(c.start=o(c.start,a<0&&l>1?-1:1),c.end=r(c.start,c.duration))}}class Yt{in;getState;setState;getHistory;_timer;_tags=new Set;constructor(t,n,s,a){this.in=t,this.getState=n,this.setState=s,this.getHistory=a}debounce(t,n=10){clearTimeout(this._timer),this._timer=setTimeout(t,n)}shouldTrack(t,n={}){return!(t.inProgress||n[t.eventSource])}registerHandler(t,n,s,a){const r=a||`${this.getDefaultTag()}-${t}`;this.in[t](n,s,{tag:r}),this._tags.add(r)}on(t,n,s){this.registerHandler("on",t,n,s)}intercept(t,n,s){this.registerHandler("intercept",t,n,s)}detachHandlers(){this._tags.forEach(t=>this.in.detach(t))}}class Wa extends Yt{undo=[];redo=[];progress={};_dataSnapshot={};_batch=[];_isBatching=!1;init(){this.setHandlers(),this.resetStateHistory()}destroy(){this.setState({history:null})}getDefaultTag(){return"historyManager"}getHandlers(){return{"add-task":{handler:t=>{let{task:n}=t;return n=P(n),n.data&&delete n.data,n.open&&delete n.open,{action:"delete-task",data:{id:t.id},source:{action:"add-task",data:{...t,task:n,select:!1}}}}},"delete-task":{getSnapshot:t=>this.getOrder(t.id,!0),handler:t=>{const{id:n}=t,{task:s,mode:a,target:r,kids:i,links:o}=this.getPrevData(),d=[{id:n,task:s,mode:a,target:r,select:!1}];return i.forEach(c=>{d.push({id:c.id,task:c,mode:"child",select:!1})}),o.forEach(c=>{d.push({action:"add-link",link:c})}),{action:"add-task",data:d,source:{action:"delete-task",data:t}}}},"update-task":{getSnapshot:t=>{const{id:n}=t,{tasks:s}=this.getState(),a=s.byId(n);return{task:P(a)}},handler:t=>{const{id:n}=t,{task:s}=this.getPrevData(),a=P(t.task);if(a.segments&&!s.segments&&(s.segments=null),!wt(s,a))return{action:"update-task",data:{id:n,task:s},source:{action:"update-task",data:{...t,task:a,diff:void 0,segmentIndex:void 0}}}},progress:!0},"copy-task":{handler:t=>{const{id:n}=t,{task:s,mode:a,target:r,kids:i,links:o}=this.getOrder(t.id,!0),d=[{id:n,task:s,mode:a,target:r,select:!1}];return i.forEach(c=>{d.push({id:c.id,task:c,select:!1})}),o.forEach(c=>{d.push({action:"add-link",link:c})}),{action:"delete-task",data:{id:t.id},source:{action:"add-task",data:d}}}},"move-task":{getSnapshot:t=>this.getOrder(t.id),handler:t=>{const{id:n}=t,{target:s,mode:a}=this.getPrevData();return{action:"move-task",data:{id:n,target:s,mode:a},source:{action:"move-task",data:{id:n,target:t.target,mode:t.mode}}}},progress:!0},"add-link":{handler:t=>({action:"delete-link",data:{id:t.id},source:{action:"add-link",data:t}})},"delete-link":{getSnapshot:t=>{const{id:n}=t,{links:s}=this.getState(),a=s.byId(n);return{link:P(a)}},handler:t=>{const{link:n}=this.getPrevData();return{action:"add-link",data:{id:t.id,link:n},source:{action:"delete-link",data:t}}}},"update-link":{getSnapshot:t=>{const{id:n}=t,{links:s}=this.getState(),a=s.byId(n);return{link:P(a)}},handler:t=>{const{link:n}=this.getPrevData();return{action:"update-link",data:{id:t.id,link:n},source:{action:"update-link",data:t}}}}}}resetHistory(){this.undo=[],this.redo=[],this.progress={},this.resetStateHistory()}setHandlers(){const t=this.getHandlers();for(const n in t){const{getSnapshot:s,handler:a,progress:r}=t[n];this.in.intercept(n,i=>{if(!(i.eventSource==="undo"||i.eventSource==="redo"||i.skipUndo||!s)){if(r){(i.inProgress&&!this.progress[n]||typeof i.inProgress!="boolean")&&this.setPrevData(s(i)),this.progress[n]=i.inProgress;return}this.setPrevData(s(i))}}),this.in.on(n,i=>{if(i.eventSource==="undo"||i.eventSource==="redo"||i.skipUndo||i.inProgress)return;const o=a(i);o&&this.addToHistory(o)})}}setPrevData(t){this._dataSnapshot=t}getPrevData(){return this._dataSnapshot}addToHistory(t){this._isBatching?this._batch.push(t):(this.undo.push(t),this.redo=[],this.setStateHistory())}startBatch(){this._isBatching=!0,this._batch=[]}endBatch(){if(this._isBatching=!1,this._batch.length===0)return;const t={action:"batch",data:this._batch,source:{action:"batch",data:this._batch.map(n=>n.source)}};this.undo.push(t),this._batch=[],this.redo=[],this.setStateHistory()}handleUndo(){if(!this.undo.length)return;const t=this.undo.pop();this.redo.push({...t.source,source:t}),t.action==="batch"?[...t.data].reverse().forEach(n=>{this.executeHistoryEntry(n,"undo")}):this.executeHistoryEntry(t,"undo"),this.setStateHistory()}handleRedo(){if(!this.redo.length)return;const t=this.redo.pop();this.undo.push({...t.source,source:t}),t.action==="batch"?t.data.forEach(n=>{this.executeHistoryEntry(n,"redo")}):this.executeHistoryEntry(t,"redo"),this.setStateHistory()}executeHistoryEntry(t,n){Array.isArray(t.data)?t.data.forEach(({action:s,...a})=>{const r=s||t.action,i={...a,eventSource:n};i.task&&delete i.task.data,this.in.exec(r,i)}):(t.data.task&&delete t.data.task.data,this.in.exec(t.action,{...t.data,eventSource:n}))}resetStateHistory(){this.setState({history:{undo:0,redo:0}})}setStateHistory(){this.setState({history:{undo:this.undo.length,redo:this.redo.length}})}getOrder(t,n){const{tasks:s,links:a}=this.getState();let r={};const i=[],o=s.byId(t),d=o.parent||0,c=s.byId(d).data,u=c.findIndex(h=>h.id===t),l=c[u+1];if(l?r={mode:"before",target:l.id}:c.length?r={mode:"after",target:c[u-1]?.id}:r={mode:"child",target:d},a.forEach(h=>{(h.source===t||h.target===t)&&i.push(h)}),r.task=P(o),n){const h=[];s.eachChild(f=>{h.push(f)},t),r.kids=h.map(f=>({...f})),h.forEach(f=>{a.forEach(p=>{(p.source===f.id||p.target===f.id)&&!i.some(({id:g})=>p.id==g)&&i.push(p)})})}return r.links=i,r}}const Qe=Symbol.for("constructDateFrom");function ft(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Qe in e?e[Qe](t):e instanceof Date?new e.constructor(t):new Date(t)}function Bt(e,t){return ft(e,e)}function et(e,t,n){const s=Bt(e);return isNaN(t)?ft(e,NaN):(t&&s.setDate(s.getDate()+t),s)}function Ia(e,...t){const n=ft.bind(null,t.find(s=>typeof s=="object"));return t.map(n)}function Ea(e,t){const n=Bt(e);return n.setHours(0,0,0,0),n}function Pa(e,t){const[n,s]=Ia(e,t.start,t.end);return{start:n,end:s}}function Ft(e,t){const{start:n,end:s}=Pa(t?.in,e);let a=+n>+s;const r=a?+n:+s,i=a?s:n;i.setHours(0,0,0,0);let o=1;const d=[];for(;+i<=r;)d.push(ft(n,i)),i.setDate(i.getDate()+o),i.setHours(0,0,0,0);return a?d.reverse():d}function Ca(e,t){return Bt(e).getDay()}function jt(e){return Math.round(e.getTime()/864e5)-19e3}function Ge(e,t){return jt(e)}function Re(e,t){return t.inclusiveEnd?jt(e)+1:jt(e)}function Je(e){const t=new Date((e+19e3)*864e5);return new Date(t.getFullYear(),t.getMonth(),t.getDate())}var Ve=class{constructor(e,t,n){e&&this.parse(e,t,n)}parse(e,t=[],n={}){this._originalData=[...e],this._originalLinks=[...t],this._originalConfig={...n},this._nodes=new Map;const{start:s,end:a}=Oa(e,n),r=this._data=new Array(e.length+2);if(r[0]={id:0,in:[],out:[],counter:0,start:Ge(s)},r[1]={id:1,in:[],out:[],counter:0,start:Re(a,n)},!e.length){const h={left:r[0],right:r[1],lag:void 0};r[0].out.push(h),r[1].in.push(h);return}for(let h=0;h<e.length;h++){const f=e[h],p=2*h+2,g={};r[p]={id:p,in:[],out:[g],counter:0,start:Ge(f.start)},r[p+1]={id:p+1,in:[g],out:[],counter:0,start:Re(f.end||f.start,n)},g.left=r[p],g.right=r[p+1],g.lag=f.duration||g.right.start-g.left.start,this._nodes.set(f.id,p)}for(const h of t){const f=r[this._nodes.get(h.source)+1],p=r[this._nodes.get(h.target)];if(!f||!p){console.warn(`Link ${h.source} -> ${h.target} not found`);continue}const g={left:f,right:p,lag:h.lag!==void 0?h.lag:void 0};f.out.push(g),p.in.push(g)}const i=[],o=[];let d=r[2],c=r[2];for(let h=2;h<r.length;h++){const f=r[h];f.in.length===0&&i.push(f),f.out.length===0&&o.push(f),f.start<d.start&&(d=f),f.start>c.start&&(c=f)}i.length||i.push(d),o.length||o.push(c);const u=r[0],l=r[1];for(const h of i){const f={left:u,right:h,lag:void 0};u.out.push(f),h.in.push(f)}for(const h of o){const f={left:h,right:l,lag:void 0};h.out.push(f),l.in.push(f)}}byOrder(e){return this._data[e]}byId(e){return this._data[this._nodes.get(e)]}toTaskIds(e,t=!1){if(!t)return e.map(a=>this.getTaskId(a));const n=[];let s=null;for(const a of e){const r=this.getTaskId(a);r===0||s===r||(s=r,n.push(r))}return n}toTasks(e){return e.map(t=>this.getCurrentTask(t))}forward(e){this._resetCounters();const t=[this._data[0]];let n=0;for(;n<t.length;){const s=t[n];e(s);for(const a of s.out){const r=a.right;r&&(r.counter++,r.counter===r.in.length&&t.push(a.right))}n++}return t}backward(e){this._resetCounters();const t=[this._data[1]];let n=0;for(;n<t.length;){const s=t[n];e(s);for(const a of s.in){const r=a.left;r&&(r.counter++,r.counter===r.out.length&&t.push(a.left))}n++}return t}_resetCounters(){for(const e of this._data)e.counter=0}resetToOriginal(){this.parse(this._originalData,this._originalLinks,this._originalConfig)}getCurrentTask(e){const t=this.getTaskId(e),n=this.getOriginalTask(t)||{id:"__new"},s=e-e%2,a=this._data[s].start,r=this._data[s+1].start,i=this._data[s].out[0].lag;return{...n,start:Je(a),end:Je(r),duration:i}}getOriginalTask(e){return this._originalData.find(t=>t.id===e)}getTaskId(e){if(e<=1)return 0;const t=Math.floor((e-2)/2);return this._originalData[t].id}getStartNodeId(e){return this._nodes.get(e)||0}getEndNodeId(e){const t=this._nodes.get(e);return t!==void 0?t+1:0}};function Oa(e,t){if(t.start&&t.end)return{start:t.start,end:t.end};let n=t.start||new Date(2970,1,1),s=t.end||new Date(1970,1,1);for(const a of e)a.start<n&&(n=a.start),a.end>s&&(s=a.end);return{start:n,end:s}}var Ke=1,Ze=2;function Na(e,t,n){const s=za(e,t,n);return e.toTaskIds(s,!0)}function za(e,t,n){const s=Ua(e,n),a=[],r=e.byOrder(0),i=e.byOrder(1);if(t===Ke){let o=i;const d=0;for(;o!==r;){o!==i&&a.push(o.id);let c=null,u=1/0,l=-1;for(const h of o.in){const f=s.get(h.left.id);(f.totalSlack<u||f.totalSlack===u&&f.count>l)&&(l=f.count,c=h.left,u=f.totalSlack)}if(u>d||!c)break;o=c}return a.reverse()}else if(t===Ze){let o=r;for(;o!==i;){o!==r&&a.push(o.id);let d=0,c=1/0;for(let u=0;u<o.out.length;u++){const l=o.out[u].right,h=s.get(l.id),f=o.out[u].lag??0,p=h.earliest-(o.start+f),g=h.pathSlack+p;g<c&&(c=g,d=u)}o=o.out[d].right}}return a}function Aa(e){return Math.round(e.getTime()/864e5)-19e3}function gt(e){const t=new Date((e+19e3)*864e5);return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function qt(e,t,n){if(!n)return e+t;const s=gt(e),a=n.addWorkingDays(s,t);return a?Aa(a):e+t}function Ua(e,t){const n=new Map,s=t?.calendar,a=e.byOrder(0).start;e.forward(i=>{let o=a;for(const d of i.in){const c=n.get(d.left.id);if(c){const u=qt(c.earliest,d.lag??0,s);u>o&&(o=u)}}n.set(i.id,{earliest:o,latest:0,freeSlack:0,totalSlack:0,pathSlack:0,count:0})});const r=e.byOrder(1).start;return e.backward(i=>{const o=n.get(i.id);let d=r,c=r,u=0,l=r;for(const h of i.out){const f=n.get(h.right.id),p=h.lag??0,g=qt(f.latest,-p,s);g<d&&(d=g),(f.pathSlack<c||f.pathSlack===c&&f.count>u)&&(u=f.count,c=f.pathSlack);const m=qt(f.earliest,-p,s);m<l&&(l=m)}if(o.latest=d,s){const h=gt(o.earliest),f=gt(o.latest),p=gt(l);o.totalSlack=s.getWorkingDays(h,f,!0),o.freeSlack=s.getWorkingDays(h,p,!0)}else o.totalSlack=o.latest-o.earliest,o.freeSlack=l-o.earliest;o.pathSlack=c+o.totalSlack,o.count=u+1}),n}var Ya=class A{static{this.globalConfig={defaultHoursPerDay:8,maxIterations:365}}constructor(t){this.name=t?.name,this.weekHours=[0,8,8,8,8,8,0];const n=t?.weekHours;n&&(this.weekHours=[n.sunday??0,n.monday??8,n.tuesday??8,n.wednesday??8,n.thursday??8,n.friday??8,n.saturday??0]),this.exceptions=new Map,this.rules=[]}static setGlobalConfig(t){A.globalConfig={...A.globalConfig,...t}}setDayHours(t,n){const s=this.normalizeDate(t);this.exceptions.set(s.getTime(),n)}setRangeHours(t,n,s){const a=this.normalizeDate(t),r=this.normalizeDate(n),i=Ft({start:a,end:r});for(const o of i)this.exceptions.set(o.getTime(),s)}isWorkingDay(t){return this.getWorkingHours(t)>0}getWorkingHours(t,n,s){if(n===void 0)return this.getDayHours(t);const a=this.normalizeDate(t),r=this.normalizeDate(n,s);if(a>r)return 0;let i=0;const o=Ft({start:a,end:r});for(const d of o)i+=this.getDayHours(d);return i}getWorkingDays(t,n,s){const a=this.normalizeDate(t),r=this.normalizeDate(n,s);if(a>r)return 0;let i=0;const o=Ft({start:a,end:r});for(const d of o)this.getDayHours(d)>0&&i++;return i}getNextWorkingDay(t){const n=A.globalConfig.maxIterations||365;let s=this.normalizeDate(t),a=0;for(;a<n;){if(s=et(s,1),this.getDayHours(s)>0)return s;a++}return null}getPreviousWorkingDay(t){const n=A.globalConfig.maxIterations||365;let s=this.normalizeDate(t),a=0;for(;a<n;){if(s=et(s,-1),this.getDayHours(s)>0)return s;a++}return null}addWorkingDays(t,n,s){if(n===0)return this.normalizeDate(t);const a=A.globalConfig.maxIterations||365;let r=this.normalizeDate(t);const i=n>0?1:-1;if(this.getDayHours(r)===0){const c=i>0?this.getNextWorkingDay(r):this.getPreviousWorkingDay(r);if(!c)return null;r=c}let o=s?Math.abs(n)-1:Math.abs(n),d=0;for(;o>0&&d<a;)r=et(r,i),this.getDayHours(r)>0&&o--,d++;return o>0?null:(s&&(r=et(r,i)),r)}addWorkingHours(t,n){if(n===0)return this.normalizeDate(t);const s=A.globalConfig.maxIterations||365;let a=this.normalizeDate(t),r=Math.abs(n);const i=n>0?1:-1;let o=0;for(;r>0&&o<s;){o>0&&(a=et(a,i));const d=this.getDayHours(a);d>0&&(r-=d),o++}return r>0?null:a}addRule(t){this.rules.push(t)}clone(t){const n={sunday:this.weekHours[0],monday:this.weekHours[1],tuesday:this.weekHours[2],wednesday:this.weekHours[3],thursday:this.weekHours[4],friday:this.weekHours[5],saturday:this.weekHours[6]},s=new A({name:t?.name||this.name,weekHours:t?.weekHours||n});for(const r of this.rules)s.rules.push(r);const a=r=>{const i=this.normalizeDate(r).getTime();return this.exceptions.get(i)};return s.rules.push(a),s}getDayHours(t){const n=this.normalizeDate(t),s=n.getTime(),a=this.exceptions.get(s);if(a!==void 0)return a;for(let i=this.rules.length-1;i>=0;i--){const o=this.rules[i](n);if(o!==void 0)return o}const r=Ca(n);return this.weekHours[r]??0}normalizeDate(t,n=!1){const s=Ea(t);return new Date(s.getFullYear(),s.getMonth(),s.getDate()-(n?1:0))}};function Ba(e){return e.setDate(e.getDate()-1),e}var Lt=0,tn=1,en=2,Fa=1,nn=864e5;function B(e){return Math.round(e.getTime()/nn)-19e3}function X(e){return new Date((e+19e3)*nn)}function sn(e,t,n){return t.isWorkingDay(e)?e:n===tn?t.getPreviousWorkingDay(e)??e:t.getNextWorkingDay(e)??e}function pt(e,t,n){const s=X(e),a=n.addWorkingDays(s,t);return a?B(a):e+t}var ja=-1e12,Xt=1e12;function an(e,t,n,s,a,r,i){const o=t.start>=n&&t.start<=s&&r!==Lt;if(o&&!i)return;const d=t.id%2===0,c=e.byOrder(t.id+(d?1:-1));if(o)a.debug.push(`[${t.id}] cascade: already valid, checking links only`);else{const u=d?t.out[0].lag:t.in[0].lag;let l=r!==en?s:n;if(a.calendar){const h=X(l),f=sn(h,a.calendar,r);l=B(f)}if(a.debug.push(`[${t.id}] update ${t.start} => ${l}`),t.start=l,a.modified.add(t.id),a.calendar&&d){const h=X(t.start),f=a.calendar.addWorkingDays(h,u,!0);f?l=B(f):l=t.start+u}else if(a.calendar&&!d){const h=Ba(X(t.start)),f=a.calendar.addWorkingDays(h,-u,!1);l=f?B(f):t.start-u}else l=t.start+(d?1:-1)*u;a.debug.push(`[${c.id}] update ${c.start} => ${l}`),c.start=l,a.modified.add(c.id)}nt(e,d?t.in:t.out,t,d,a,i),nt(e,d?c.out:c.in,c,d,a,i)}function nt(e,t,n,s,a,r){for(let i=0;i<t.length;i++){const o=t[i],d=o.left.id===n.id?o.right:o.left;if(d.id<2)continue;const c=o.left===d;if(c&&!a.backward||!c&&!a.forward)continue;const u=o.lag!==void 0;let l;if(u)if(a.calendar){const m=X(n.start),k=c?-o.lag:o.lag,y=a.calendar.addWorkingDays(m,k);l=y?B(y):n.start+k}else l=c?n.start-o.lag:n.start+o.lag;else if(a.calendar&&!c){const m=X(n.start),k=a.calendar.addWorkingDays(m,0);l=k?B(k):n.start}else l=n.start;let h=u?l:c?ja:l,f=u||c?l:Xt,p=d;if(d.id%2===(s?1:0)){p=e.byOrder(d.id+(s?-1:1));const m=s?d.in[0].lag:d.out[0].lag;if(a.calendar)s?(h=pt(h,-m,a.calendar),f!==Xt&&(f=pt(f,-m,a.calendar))):(h=pt(h,m,a.calendar),f!==Xt&&(f=pt(f,m,a.calendar)));else{const k=s?-m:m;h+=k,f+=k}}const g=p.start>=h&&p.start<=f;g&&!r||(g||a.debug.push(`[${n.id}] link to ${d.id} violation: [${p.id}] ${p.start} not in [${h}, ${f}]`),qa(n,p,h,f,c?tn:en,a))}}function rn(e,t,n){n.debug.push(`[${e.id}] link to ${t.id} violation: target node can't be rescheduled`),n.conflicts.push({type:Fa,source:e.id,target:t.id})}function qa(e,t,n,s,a,r){if(r.modified.has(t.id))return t.start<n||t.start>s?(rn(e,t,r),!1):!0;const i=r.signals.get(t.id);if(!i)return r.signals.set(t.id,{sourceNode:e,targetNode:t,min:n,max:s,mode:a}),r.queue.push(t.id),!0;const o=Math.max(i.min,n),d=Math.min(i.max,s);return o>d?(rn(e,t,r),!1):(i.min=o,i.max=d,!0)}function La(e,t,n,s,a){const r=Xa(e,t,n,s,a),i=new Set;for(const c of r.updates){if(c<=1)continue;const u=c-c%2;i.add(u)}const o=e.toTasks(Array.from(i)),d=r.conflicts.map(c=>({type:c.type,source:e.getTaskId(c.source),target:e.getTaskId(c.target)}));return{updates:o,conflicts:d,debug:r.debug}}function Xa(e,t,n,s,a){const r=a?.cascade??!1,i=a?.calendar,o=a?.forward??!0,d=a?.backward??!0,c=e.getStartNodeId(t),u=c<=1,l={queue:[],modified:new Set,signals:new Map,conflicts:[],debug:[],calendar:i,forward:o,backward:d};if(u){const f=e.byOrder(c);l.debug.push(`[${c}] virtual node, force=true, checking links`),nt(e,f.out,f,!0,l,r)}else{const f=e.getOriginalTask(t),p=s!==void 0&&s!==f.duration,g=p||n!==void 0&&n.getTime()!==f.start.getTime();n=n||f.start,i&&n&&(n=sn(n,i,Lt));const m=e.byOrder(c);p&&(f.duration=s,m.out[0].lag=s,e.byOrder(c+1).in[0].lag=s);const k=B(n);if(g)an(e,m,k,k,l,Lt,r);else{const y=e.byOrder(m.id+1);l.debug.push(`[${m.id}] force=true, checking links without modifying`),nt(e,m.in,m,!0,l,r),nt(e,y.out,y,!0,l,r)}}let h=0;for(;h<l.queue.length;){const f=l.signals.get(l.queue[h]);an(e,f.targetNode,f.min,f.max,l,f.mode,r),h++}return{updates:l.modified,conflicts:l.conflicts,debug:l.debug}}class mt{prevState=new Map;track(t,n,s){const a={};s.forEach(r=>{n[r]!==void 0&&(a[r]=n[r])}),this.prevState.set(t,a)}hasChanged(t,n,s){const a=this.prevState.get(t);if(!a)return!1;const r=s.some(i=>{const o=a[i],d=n[i];return o instanceof Date&&d instanceof Date?!H(o,d):o!==d});return this.prevState.delete(t),r}clear(t){t!==void 0?this.prevState.delete(t):this.prevState.clear()}getSnapshot(t){return this.prevState.get(t)}}function Qa(e){const t={},n=new Map;for(const d of e){const{source:c,target:u}=d;(t[c]??=[]).push(u),n.set(`${c}->${u}`,d)}const s=new Set,a=[],r=new Set,i=new Set,o=d=>{s.add(d),r.add(d),a.push(d);for(const c of t[d]||[])if(!s.has(c))o(c);else if(r.has(c)){const u=a.indexOf(c),l=a.slice(u).concat(c);for(let h=0;h<l.length-1;h++){const f=`${l[h]}->${l[h+1]}`;n.has(f)&&i.add(n.get(f).id)}}a.pop(),r.delete(d)};for(const d of Object.keys(t).map(Number))s.has(d)||o(d);return i}const st={"schedule-tasks":1,"move-task":1,"copy-task":1,"add-task":1};class Ga extends Yt{taskTracker=new mt;linkTracker=new mt;init(){this.setupScheduleHandler(),this.setupTaskHandlers(),this.setupLinkHandlers()}destroy(){this.taskTracker.clear(),this.linkTracker.clear(),this.detachHandlers()}schedule(t=0,n){n&&this.deleteInvalidLinks(),this.in.exec("schedule-tasks",{id:t})}getDefaultTag(){return"scheduler"}setupScheduleHandler(){this.on("schedule-tasks",({id:t,task:n})=>{const{links:s,tasks:a,projectStart:r,projectEnd:i,calendar:o,unscheduledTasks:d}=this.getState(),c={calendar:o};t===0?(n={},c.cascade=!0):n||(n=a.byId(t));const u=new Ve,l=[],h=[];s.forEach(g=>{if(g.type==="e2s"){let m=!0;if(d){const k=a.byId(g.source),y=a.byId(g.target);m=!k.unscheduled&&!y.unscheduled}m&&l.push(g)}}),a.serialize().forEach(g=>{(!d||!g.unscheduled)&&h.push({...g})}),u.parse(h,l,{start:r,end:i});const f=La(u,t,n.start,n.duration,c),p=this.getHistory();p&&p.startBatch(),f.updates.forEach(g=>{if(g.id===t)return;const m={start:g.start,duration:g.duration};g.type!=="milestone"&&(m.end=g.end),this.in.exec("update-task",{id:g.id,task:m,eventSource:"schedule-tasks"})}),p&&p.endBatch()})}setupTaskHandlers(){this.intercept("update-task",t=>{if(t.eventSource=="undo"||t.eventSource=="redo"||t.skipUndo||!this.shouldTrack(t,st))return;const n=this.getState().tasks.byId(t.id);n&&this.taskTracker.track(t.id,n,["start","end","duration","type"])}),this.on("update-task",t=>{if(t.eventSource=="undo"||t.eventSource=="redo"||t.skipUndo||!this.shouldTrack(t,st))return;const{id:n,task:s}=t;this.taskTracker.hasChanged(n,s,["start","end","duration"])&&this.debounce(()=>this.schedule())}),this.in.on("move-task",({inProgress:t})=>{t!==!0&&this.schedule(0,!0)}),this.on("copy-task",t=>{this.shouldTrack(t,st)&&this.schedule()}),this.on("add-task",t=>{this.shouldTrack(t,st)&&this.getState().tasks.getSummaryId(t.id)&&this.schedule()}),this.on("provide-data",()=>{this.schedule(0,!0)})}setupLinkHandlers(){this.intercept("update-link",t=>{const{links:n}=this.getState(),s=n.byId(t.id);s&&this.linkTracker.track(t.id,s,["type","source","target","lag"])}),this.on("update-link",t=>{if(this.linkTracker.hasChanged(t.id,t.link,["type","source","target","lag"])){const n=this.linkTracker.getSnapshot(t.id);(t.link.type==="e2s"||n?.type==="e2s")&&this.schedule()}}),this.intercept("delete-link",t=>{const{links:n}=this.getState(),s=n.byId(t.id);s&&this.linkTracker.track(t.id,s,["type"])}),this.on("delete-link",t=>{this.linkTracker.getSnapshot(t.id)?.type==="e2s"&&t.eventSource!=="schedule-tasks"&&this.schedule(),this.linkTracker.clear(t.id)}),this.in.intercept("add-link",t=>{const{links:n}=this.getState();if(this.getInvalidLinks([...n.map(s=>s),t.link]).size)return!1}),this.on("add-link",t=>{this.shouldTrack(t,st)&&t.link.type==="e2s"&&this.schedule()})}deleteInvalidLinks(){const{links:t}=this.getState(),n=this.getInvalidLinks(t.map(s=>s));for(const s of n)this.in.exec("delete-link",{id:s,eventSource:"schedule-tasks"})}getInvalidLinks(t){const{tasks:n}=this.getState(),s=new Set;return t.forEach(a=>{const r=n.getSummaryId(a.source,!0),i=n.getSummaryId(a.target,!0);(r?.includes(a.target)||i?.includes(a.source))&&s.add(a.id)}),new Set([...s,...Qa(t)])}}const Ra={strict:Ke,flexible:Ze},on={"schedule-tasks":1,"update-task":1,"move-task":1};class Ja extends Yt{taskTracker=new mt;linkTracker=new mt;init(){this.setupTaskHandlers(),this.setupLinkHandlers()}destroy(){this.taskTracker.clear(),this.linkTracker.clear(),this.detachHandlers();const{links:t,tasks:n}=this.getState();t.forEach(s=>{delete s.$critical}),n.forEach(s=>{delete s.$critical}),this.setState({tasks:n,links:t})}calculate(){const{tasks:t,links:n,criticalPath:s,projectStart:a,projectEnd:r,calendar:i,unscheduledTasks:o}=this.getState(),d=[],c=[],u=[];n.forEach(g=>{if(g.type==="e2s"){let m=!0;[g.source,g.target].forEach(k=>{if(m){const{type:y,unscheduled:b}=t.byId(k);m=y!=="summary"&&(!o||!b)}}),m&&d.push({...g})}}),t.serialize().forEach(g=>{g.type!=="summary"&&(!o||!g.unscheduled)?c.push({...g}):u.push(g.id)});const l=new Ve(c,d,{start:a,end:r}),h={calendar:i},f=Na(l,Ra[s.type],h),p={};f.forEach(g=>p[g]=!0),u.reverse().forEach(g=>{const m=t.byId(g)?.data||[];m.length&&m.some(k=>p[k.id])&&(p[g]=!0)}),n.forEach(g=>{const m=p[g.source],k=p[g.target];m&&k?g.$critical=!0:delete g.$critical}),t.forEach(g=>{p[g.id]?g.$critical=!0:delete g.$critical}),this.setState({tasks:t,links:n})}getDefaultTag(){return"path"}setupTaskHandlers(){this.intercept("update-task",t=>{if(!this.shouldTrack(t,on))return;const n=this.getState().tasks.byId(t.id);n&&this.taskTracker.track(t.id,n,["start","end","duration","type","unscheduled"])}),this.on("update-task",t=>{this.shouldTrack(t,on)&&this.taskTracker.hasChanged(t.id,t.task,["start","end","duration","type","unscheduled"])&&this.debounce(()=>this.calculate())}),this.on("add-task",t=>{t.task.unscheduled||this.debounce(()=>this.calculate())}),this.on("delete-task",()=>{this.debounce(()=>this.calculate())}),this.on("move-task",t=>{t.inProgress!==!0&&this.debounce(()=>this.calculate())})}setupLinkHandlers(){this.on("add-link",t=>{t.link.type==="e2s"&&this.calculate()}),this.intercept("update-link",t=>{const{links:n}=this.getState(),s=n.byId(t.id);s&&this.linkTracker.track(t.id,s,["type","source","target","lag"])}),this.on("update-link",t=>{if(this.linkTracker.hasChanged(t.id,t.link,["type","source","target","lag"])){const n=this.linkTracker.getSnapshot(t.id);(t.link.type==="e2s"||n?.type==="e2s")&&this.calculate()}}),this.intercept("delete-link",t=>{const{links:n}=this.getState(),s=n.byId(t.id);s&&this.linkTracker.track(t.id,s,["type"])}),this.on("delete-link",t=>{this.linkTracker.getSnapshot(t.id)?.type==="e2s"&&this.calculate(),this.linkTracker.clear(t.id)})}}class Va extends fn{in;_router;_modules=new Map;constructor(t){super({writable:t,async:!1}),this._router=new gn(super.setState.bind(this),[{in:["tasks","start","end","scales","autoScale"],out:["_start","_end"],exec:a=>{const{_end:r,_start:i,start:o,end:d,tasks:c,scales:u,autoScale:l}=this.getState();if(!o||!d||l){const h=L(u).unit,f=ra(o,d,l,h,c);(f._end!=r||f._start!=i)&&this.setState(f,a)}else this.setState({_start:o,_end:d},a)}},{in:["_start","_end","cellWidth","scaleHeight","scales","lengthUnit","_weekStart"],out:["_scales"],exec:a=>{const r=this.getState();let{lengthUnit:i}=r;const{_start:o,_end:d,cellWidth:c,scaleHeight:u,scales:l,_weekStart:h}=r,f=L(l).unit;ta(f,i)||(i=f);const p=ia(o,d,i,c,u,h,l);this.setState({_scales:p},a)}},{in:["_scales","tasks","cellHeight","baselines","unscheduledTasks"],out:["_tasks"],exec:a=>{const{cellWidth:r,cellHeight:i,tasks:o,_scales:d,baselines:c,splitTasks:u,unscheduledTasks:l}=this.getState(),h=o.toArray().map((f,p)=>Pe(f,p,{cellWidth:r,cellHeight:i,_scales:d,baselines:c,splitTasks:u,unscheduledTasks:l}));this.setState({_tasks:h},a)}},{in:["_tasks","links","cellHeight"],out:["_links"],exec:a=>{const{tasks:r,links:i,cellHeight:o,baselines:d,criticalPath:c}=this.getState(),u=i.map(l=>{const h=r.byId(l.source),f=r.byId(l.target);return ga(l,h,f,o,d)}).toSorted((l,h)=>c?!!l.$critical==!!h.$critical?h.$pl-l.$pl:l.$critical?1:-1:h.$pl-l.$pl).filter(l=>l!==null);this.setState({_links:u},a)}},{in:["tasks","activeTask"],out:["_activeTask"],exec:a=>{const r=this.getState();let{activeTask:i}=r;i&&typeof i=="object"&&(i=i.id);const o=r.tasks.byId(i);this.setState({_activeTask:o||null},a)}},{in:["tasks","selected"],out:["_selected"],exec:a=>{const{tasks:r,selected:i}=this.getState(),o=i.map(d=>r.byId(d)).filter(d=>!!d);this.setState({_selected:o},a)}},{in:["start","end"],out:["cellWidth"],exec:a=>{const{_cellWidth:r,cellWidth:i}=this.getState();r!=i&&this.setState({cellWidth:r},a)}},{in:["markers","_scales","cellWidth"],out:["_markers"],exec:a=>{const{markers:r,_scales:i,cellWidth:o}=this.getState(),{start:d,diff:c}=i,u=r.map(l=>(l.left=c(l.start,d)*o,l));this.setState({_markers:u},a)}},{in:["unscheduledTasks"],out:["columns"],exec:a=>{const{columns:r,unscheduledTasks:i}=this.getState(),o=r.map(d=>(d._template&&(d.id=="start"||d.id=="end"||d.id=="duration")&&(d={...d,template:(c,u,l)=>u.unscheduled&&i?"-":l._template(c,u,l)}),d));this.setState({columns:o},a)}}],{tasks:a=>new xn(a),links:a=>new Zt(a),columns:a=>xa(a)});const n=this.in=new pn;n.on("show-editor",a=>{const{splitTasks:r}=this.getState();if(r){const{id:i,segmentIndex:o}=a;if(i&&(o||o===0)){this.setStateAsync({activeTask:{id:i,segmentIndex:o}});return}}this.setStateAsync({activeTask:a.id})}),n.on("select-task",({id:a,toggle:r,range:i,show:o,segmentIndex:d})=>{const{selected:c,_tasks:u,activeTask:l,splitTasks:h}=this.getState();let f=!1,p;if(c.length&&(r||i)){const m=[...c];if(i){const k=m[m.length-1],y=u.findIndex(v=>v.id==k),b=u.findIndex(v=>v.id==a),_=Math.min(y,b),x=Math.max(y,b)+1,S=u.slice(_,x).map(v=>v.id);y>b&&S.reverse(),S.forEach(v=>{m.includes(v)||m.push(v)})}else if(r){const k=m.findIndex(y=>y==a);k===-1?m.push(a):(f=!0,m.splice(k,1))}p=m}else p=[a];const g={selected:p};o&&p.length&&(g._scrollTask={id:p[0],mode:o}),this.setStateAsync(g),!f&&l&&(l!==a||h)&&n.exec("show-editor",{id:a,...h&&{segmentIndex:d}})}),n.on("delete-link",({id:a})=>{const{links:r}=this.getState();r.remove(a),this.setStateAsync({links:r})}),n.on("update-link",a=>{const{links:r}=this.getState(),i=a.id;let o=a.link;r.update(i,o),o=r.byId(i),!o.lag&&o.lag!==0&&delete o.lag,this.setStateAsync({links:r}),a.link=o}),n.on("add-link",a=>{const{link:r}=a,{links:i}=this.getState();!r.source||!r.target||(r.type||(r.type="e2s"),r.id=r.id||bt(),i.add(r),this.setStateAsync({links:i}),a.id=r.id,a.link=i.byId(r.id))});let s=null;n.on("move-task",a=>{const{tasks:r}=this.getState();let{mode:i,target:o}=a;const{id:d,inProgress:c}=a,u=r.byId(d);if(typeof c>"u"?a.source=u.parent:a.source=s=s??u.parent,c===!1){r.update(u.id,{$reorder:!1}),this.setState({tasks:r}),s=null;return}if(o===d||r.contains(d,o)){a.skipProvider=!0;return}if(i==="up"||i==="down"){const l=r.getBranch(d);let h=r.getIndexById(d);if(i==="up"){const f=u.parent===0;if(h===0&&f){a.skipProvider=!0;return}h-=1,i="before"}else if(i==="down"){const f=h===l.length-1,p=u.parent===0;if(f&&p){a.skipProvider=!0;return}h+=1,i="after"}if(o=l[h]&&l[h].id||u.parent,o){const f=r.getBranch(o);let p=r.getIndexById(o),g=f[p];if(g.data){if(i==="before"){if(g.parent===u.parent){for(;g.data;)g.open||n.exec("open-task",{id:g.id,mode:!0}),g=g.data[g.data.length-1];o=g.id}}else if(i==="after"){let y;g.parent===u.parent?(y=g,g=g.data[0],o=g.id,i="before"):f.length-1!==p&&(y=g,p+=1,g=f[p],u.$level>g.$level&&g.data?(y=g,g=g.data[0],o=g.id,i="before"):o=g.id),y&&!y.open&&n.exec("open-task",{id:y.id,mode:!0})}}const m=r.getSummaryId(u.id);r.move(d,i,o);const k=r.getSummaryId(d);m!=k&&(m&&this.resetSummaryDates(m,"move-task"),k&&this.resetSummaryDates(k,"move-task"))}}else{const l=r.byId(o);let h=l,f=!1;for(;h.$level>u.$level;)h=r.byId(h.parent),h.id===d&&(f=!0);if(f)return;const p=r.getSummaryId(u.id);if(r.move(d,i,o),i=="child"){let m=l;for(;m.id!==0&&!m.open;)n.exec("open-task",{id:m.id,mode:!0}),m=r.byId(m.parent)}const g=r.getSummaryId(d);p!=g&&(p&&this.resetSummaryDates(p,"move-task"),g&&this.resetSummaryDates(g,"move-task"))}c?this.setState({tasks:r}):this.setStateAsync({tasks:r}),a.target=o,a.mode=i}),n.on("drag-task",a=>{const r=this.getState(),{tasks:i,_tasks:o,_selected:d,_scales:c,cellWidth:u}=r,l=i.byId(a.id);if(a.segmentIndex>=0&&r.splitTasks&&Ma(l,a)===!1){this.setState({_tasks:o});return}const{left:h,top:f,width:p,inProgress:g}=a,m={_tasks:o,_selected:d};if(typeof p<"u"&&(l.$w=p,Ot(i,l,c,u)),typeof h<"u"){if(l.type==="summary"){const k=h-l.$x;We(l,k,c,u)}l.$x=h,Ot(i,l,c,u)}typeof f<"u"&&(l.$y=f+4,l.$reorder=g),typeof p<"u"&&(l.$w=p),typeof h<"u"&&(l.$x=h),typeof f<"u"&&(l.$y=f+4,l.$reorder=g),this.setState(m)}),n.on("update-task",a=>{const{id:r,segmentIndex:i,diff:o,eventSource:d}=a;let{task:c}=a;const{tasks:u,_scales:l,durationUnit:h,splitTasks:f,calendar:p}=this.getState(),g=u.byId(r),m={_scales:l,durationUnit:h,calendar:p,splitTasks:f};if(d==="add-task"||d==="copy-task"||d==="move-task"||d==="update-task"||d==="delete-task"||d==="provide-data"){f&&g.segments&&(c=qe(g,c,m)),z(c,m),u.update(r,c);return}const k=l.lengthUnit;let y=T(k);const b=E(k,p);if(o&&(c.start&&(c.start=y(c.start,o)),!i&&i!==0&&(c.start&&c.end?c.duration=g.duration:(c.start?c.end=g.end:(c.end=y(c.end,o),c.start=g.start,c.duration=b(c.end,c.start)),b(c.end,c.start)||(c.duration=1)))),f&&g.segments&&(o&&i>=0&&c.end&&(c.end=y(c.end,o)),c=qe(g,c,m,i,o)),c.type=c.type??g.type,p&&c.start&&(c.start=Wt(c.start,o,p)),c.start&&c.end&&(!H(c.start,g.start)||!H(c.end,g.end))&&c.type==="summary"&&g.data?.length){let x=o||b(c.start,g.start);p&&(x=c.start>g.start?b(c.start,g.start):-b(g.start,c.start),y=lt(p)),this.moveSummaryKids(g,S=>(S=y(S,x),p?Wt(S,o,p):S),"update-task")}c.start||(c.start=g.start),!c.end&&!c.duration&&(c.duration=g.duration),z(c,m),u.update(r,c),(p&&c.type==="summary"||c.type==="summary"&&g.type!=="summary")&&this.resetSummaryDates(r,"update-task",!0);const _=u.getSummaryId(r);_&&this.resetSummaryDates(_,"update-task"),this.setStateAsync({tasks:u}),a.task=u.byId(r)}),n.on("add-task",a=>{const{tasks:r,_scales:i,unscheduledTasks:o,durationUnit:d,splitTasks:c,calendar:u}=this.getState(),{target:l,mode:h,task:f,show:p,select:g=!0}=a;!a.eventSource&&o&&(f.unscheduled=!0);let m=-1,k,y;if(l?(y=r.byId(l),h=="child"?(k=y,f.parent=k.id):(y.parent!==null&&(k=r.byId(y.parent),f.parent=k.id),m=r.getIndexById(l),h=="after"&&(m+=1))):f.parent&&(k=r.byId(f.parent)),!f.start){if(k?.start)f.start=new Date(k.start.valueOf());else if(y)f.start=new Date(y.start.valueOf());else{const S=r.getBranch(0);let v;if(S?.length){const M=S[S.length-1];if(!M.$skip){const F=new Date(M.start.valueOf());i.start<=F&&(v=F)}}f.start=v||T(d,u)(i.start,1)}f.duration=1}u&&(f.start=Wt(f.start,1,u)),this.getState().baselines&&(f.base_start=f.start,f.base_duration=f.duration),z(f,{durationUnit:d,splitTasks:c,calendar:u});const b=r.add(f,m),_={tasks:r};if(k&&p){for(;k&&k.id;)n.exec("open-task",{id:k.id,mode:!0}),k=r.byId(k.parent);_._scrollTask={id:b.id,mode:p}}a.id=b.id;const x=r.getSummaryId(b.id);x&&this.resetSummaryDates(x,"add-task"),this.setStateAsync(_),a.id=b.id,a.task=b,g&&n.exec("select-task",{id:b.id})}),n.on("delete-task",a=>{const{id:r}=a,{tasks:i,links:o,selected:d}=this.getState();a.source=i.byId(r).parent;const c=i.getSummaryId(r),u=[r];i.eachChild(h=>u.push(h.id),r),o.filter(h=>!(u.includes(h.source)||u.includes(h.target)));const l={tasks:i,links:o};d.includes(r)&&(l.selected=d.filter(h=>h!==r)),i.remove(r),c&&this.resetSummaryDates(c,"delete-task"),this.setStateAsync(l)}),n.on("indent-task",({id:a,mode:r})=>{const{tasks:i}=this.getState();if(r){const o=i.getBranch(a)[i.getIndexById(a)-1];o&&n.exec("move-task",{id:a,mode:"child",target:o.id})}else{const o=i.byId(a),d=i.byId(o.parent);d&&d.parent!==null&&n.exec("move-task",{id:a,mode:"after",target:o.parent})}}),n.on("copy-task",a=>{const{id:r,target:i,mode:o,eventSource:d}=a;if(d==="copy-task")return;const{tasks:c,links:u}=this.getState();if(c.contains(r,i)){a.skipProvider=!0;return}const l=c.getSummaryId(r),h=c.getSummaryId(i);let f=c.getIndexById(i);o=="before"&&(f-=1);const p=c.byId(r),g=c.copy(p,c.byId(i).parent,f+1);a.source=a.id,a.id=g[0][1],p.lazy&&(a.lazy=!0),l!=h&&h&&this.resetSummaryDates(h,"copy-task");let m=[];for(let k=1;k<g.length;k++){const[y,b]=g[k];u.forEach(_=>{if(_.source===y){const x={..._};delete x.target,m.push({...x,source:b})}else if(_.target===y){const x={..._};delete x.source,m.push({...x,target:b})}})}m=m.reduce((k,y)=>{const b=k.findIndex(_=>_.id===y.id);return b>-1?k[b]={...k[b],...y}:k.push(y),k},[]);for(let k=1;k<g.length;k++){const[y,b]=g[k],_=c.byId(b);n.exec("copy-task",{source:y,id:b,lazy:!!_.lazy,eventSource:"copy-task",target:_.parent,mode:"child",skipUndo:!0})}m.forEach(k=>{n.exec("add-link",{link:{source:k.source,target:k.target,type:k.type},eventSource:"copy-task",skipUndo:!0})}),this.setStateAsync({tasks:c})}),n.on("open-task",({id:a,mode:r})=>{const{tasks:i}=this.getState(),o=i.byId(a);o.lazy?n.exec("request-data",{id:o.id}):(i.toArray().forEach(d=>d.$y=0),i.update(a,{open:r}),this.setState({tasks:i}))}),n.on("scroll-chart",({left:a,top:r})=>{if(!isNaN(a)){const i=this.calcScaleDate(a);this.setState({scrollLeft:a,_scaleDate:i})}isNaN(r)||this.setState({scrollTop:r})}),n.on("render-data",a=>{this.setState({area:a})}),n.on("provide-data",a=>{const{tasks:r,links:i,durationUnit:o,calendar:d,splitTasks:c}=this.getState(),u=r.byId(a.id);u.lazy?(u.lazy=!1,u.open=!0):u.data=[],Ye(a.data.tasks,{durationUnit:o,splitTasks:c,calendar:d}),r.parse(a.data.tasks,a.id),u.type=="summary"&&this.resetSummaryDates(u.id,"provide-data"),this.setStateAsync({tasks:r,links:new Zt(i.map(l=>l).concat(Oe(a.data.links)))})}),n.on("zoom-scale",({dir:a,offset:r})=>{const{zoom:i,cellWidth:o,_cellWidth:d,scrollLeft:c}=this.getState(),u=r+c,l=this.calcScaleDate(u);let h=o;a<0&&(h=d||o);const f=h+a*50,p=i.levels[i.level],g=a<0&&o>p.maxCellWidth;if(f<p.minCellWidth||f>p.maxCellWidth||g){if(!this.changeScale(i,a))return}else this.setState({cellWidth:f,_cellWidth:f});const{_scales:m,_start:k,cellWidth:y,_weekStart:b}=this.getState(),_=I(m.minUnit,k,b),x=m.diff(l,_,"hour");typeof r>"u"&&(r=y);let S=Math.round(x*y)-r;S<0&&(S=0),this.setState({scrollLeft:S,_scaleDate:l,_zoomOffset:r})}),n.on("expand-scale",({minWidth:a})=>{const{_start:r,_scales:i,start:o,end:d,_end:c,cellWidth:u,_scaleDate:l,_zoomOffset:h}=this.getState(),f=T(i.minUnit);let p=i.width;if(o&&d){if(p<a&&p){const b=a/p;this.setState({cellWidth:u*b})}return!0}let g=0;for(;p<a;)p+=u,g++;const m=g?d?-g:-1:0,k=o||f(r,m);let y=0;if(l){const b=i.diff(l,k,"hour");y=Math.max(0,Math.round(b*u)-(h||0))}this.setState({_start:k,_end:d||f(c,g),scrollLeft:y})}),n.on("sort-tasks",({key:a,order:r,add:i})=>{const o=this.getState(),{tasks:d}=o;let c=o._sort;const u={key:a,order:r};let l=c?.length||0;l&&i?(c.forEach((h,f)=>{h.key===a&&(l=f)}),c[l]=u):c=[u],d.sort(c),this.setState({_sort:c,tasks:d})}),n.on("hotkey",({key:a,event:r,eventSource:i})=>{switch(a){case"arrowup":case"arrowdown":{const{selected:o,_tasks:d}=this.getState();r.preventDefault();const c=o.length;let u;if(a==="arrowup"?u=c?this.getPrevRow(o[c-1])?.id:d[d.length-1]?.id:u=c?this.getNextRow(o[c-1])?.id:d[0]?.id,u){const l=i==="chart"?"xy":!0;this.in.exec("select-task",{id:u,show:l})}break}case"ctrl+c":{tt(this,"copy-task",null,null);break}case"ctrl+x":{tt(this,"cut-task",null,null);break}case"ctrl+v":{tt(this,"paste-task",null,null);break}case"ctrl+d":case"backspace":{r.preventDefault(),tt(this,"delete-task",null,null);break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),n.on("undo",()=>{this.getHistory()?.handleUndo()}),n.on("redo",()=>{this.getHistory()?.handleRedo()}),n.on("split-task",({id:a,segmentIndex:r})=>{const i=this.getState(),{tasks:o,_scales:d,durationUnit:c,splitTasks:u,calendar:l}=i;if(!u)return;const h=o.byId(a);if(Ut(h))return;const f=$a(h,r,{_scales:d,durationUnit:c,calendar:l,splitTasks:u});f&&n.exec("update-task",{id:a,task:f,eventSource:"split-task"})})}init(t){const n=this.getState().area?{}:{scrollLeft:0,scrollTop:0,area:{from:0,start:0,end:0}};t.cellWidth&&(t._cellWidth=t.cellWidth),t._sort=null,Pt()&&(t.unscheduledTasks=!1,t.baselines=!1,t.markers=[],t.undo=!1,t.schedule={},t.criticalPath=null,t.splitTasks=!1),Array.isArray(t.tasks)&&this.getHistory()?.resetHistory(),this._router.init({_scrollTask:null,selected:[],markers:[],autoScale:!0,durationUnit:"day",...n,...t}),t.schedule?.auto?this.enableModule("autoScheduler",Ga).schedule(0,!0):this.disableModule("autoScheduler"),t.criticalPath?this.enableModule("criticalPath",Ja).calculate():this.disableModule("criticalPath"),t.undo?this.enableModule("historyManager",Wa):this.disableModule("historyManager")}enableModule(t,n){if(!this._modules.has(t)){const s=new n(this.in,this.getState.bind(this),this.setState.bind(this),this.getHistory.bind(this));return s.init(),this._modules.set(t,s),s}return this._modules.get(t)}disableModule(t){const n=this._modules.get(t);n&&(n.destroy(),this._modules.delete(t))}setState(t,n){return this._router.setState(t,n)}setStateAsync(t){this._router.setStateAsync(t)}getTask(t){const{tasks:n}=this.getState();return n.byId(t)}getHistory(){return this.getState().undo?this._modules.get("historyManager"):null}serialize(){const{tasks:t}=this.getState();return t.serialize()}changeScale(t,n){const s=t.level+n,a=t.levels[s];if(a){const{cellWidth:r,scales:i,_scales:o}=this.getState(),d=da(t,n,s,a,o.lengthUnit,i,r);return d._cellWidth=d.cellWidth,this.setState(d),!0}return!1}isScheduled(t){return this.getState().unscheduledTasks?t.some(n=>!n.unscheduled||n.data&&this.isScheduled(n.data)):!0}resetSummaryDates(t,n,s){const{tasks:a,durationUnit:r,splitTasks:i,calendar:o}=this.getState(),d=a.byId(t),c=d.data;if(c?.length&&this.isScheduled(c)){const u=Nt({...d,start:void 0,end:void 0,duration:void 0});if(!H(d.start,u.start)||!H(d.end,u.end)){s?(z(u,{durationUnit:r,splitTasks:i,calendar:o}),a.update(t,u)):this.in.exec("update-task",{id:t,task:u,eventSource:n,skipUndo:!0});const l=a.getSummaryId(t);l&&this.resetSummaryDates(l,n)}}}moveSummaryKids(t,n,s){const{tasks:a}=this.getState();t.data.forEach(r=>{const i={...a.byId(r.id),start:n(r.start)};delete i.end,delete i.id,this.in.exec("update-task",{id:r.id,task:i,eventSource:s,skipUndo:!0}),r.data?.length&&this.moveSummaryKids(r,n,s)})}calcScaleDate(t){const{_scales:n,_start:s,_weekStart:a}=this.getState(),r=n.lengthUnit==="day"?n.lengthUnitWidth/24:n.lengthUnitWidth;return T("hour")(I(n.minUnit,s,a),Math.floor(t/r))}getNextRow(t){const n=this.getState()._tasks,s=n.findIndex(a=>a.id==t);return n[s+1]}getPrevRow(t){const n=this.getState()._tasks,s=n.findIndex(a=>a.id==t);return n[s-1]}}function Ka(e,t,n,s){if(typeof document>"u")return"";const a=document.createElement("canvas");{const r=Za(a,e,t,1,n);tr(r,s,0,e,0,t)}return a.toDataURL()}function Za(e,t,n,s,a){e.setAttribute("width",(t*s).toString()),e.setAttribute("height",(n*s).toString());const r=e.getContext("2d");return r.translate(-.5,-.5),r.strokeStyle=a,r}function tr(e,t,n,s,a,r){e.beginPath(),e.moveTo(s,a),e.lineTo(s,r),t==="full"&&e.lineTo(n,r),e.stroke()}function er(e){let t=[...Gt];return e?.splitTasks&&(t.splice(4,0,{id:"split-task",text:"Split",icon:"wxi-arrow-split"}),t.splice(4,0,{id:"edit",text:"Edit",icon:"wxi-edit",data:[{id:"edit-task:task",text:"Task",isHidden:(n,s,a)=>!Q(a)},{id:"edit-task:segment",text:"Segment",isHidden:(n,s,a)=>!Q(a)}]}),t.push({id:"delete",icon:"wxi-delete",text:"Delete",data:[{id:"delete-task:task",text:"Task",isHidden:(n,s,a)=>!Qt(s)||!Q(a)},{id:"delete-task:segment",text:"Segment",isHidden:(n,s,a)=>!Qt(s)||!Q(a)}]})),t.length>Gt.length&&(t=at(t)),t}function at(e){return e.map(t=>{switch(t.data&&at(t.data),t.id){case"add-task:before":case"move-task:up":t.isDisabled=(n,s)=>sr(n,s);break;case"move-task:down":t.isDisabled=(n,s)=>ar(n,s);break;case"indent-task:add":t.isDisabled=(n,s)=>rr(n,s)===n.parent;break;case"indent-task:remove":t.isDisabled=n=>nr(n);break;case"undo":t.isDisabled=n=>!n.undo;break;case"redo":t.isDisabled=n=>!n.redo;break;case"split-task":t.isDisabled=(n,s,a)=>{let r;return typeof a=="object"&&(r=a.segmentIndex),Ha(n,s,r)};break}return t})}function nr(e){return e.parent===0}function sr(e,t){const{_tasks:n}=t;return n[0]?.id===e.id}function ar(e,t){const{_tasks:n}=t;return n[n.length-1]?.id===e.id}function rr(e,t){const{_tasks:n}=t,s=n.findIndex(a=>a.id===e.id);return n[s-1]?.id??e.parent}function Q(e){return e&&typeof e=="object"}function Qt(e){return!e.selected||e.selected.length<2}const ir=e=>t=>t.type===e,Gt=at([{id:"add-task",text:"Add",icon:"wxi-plus",data:[{id:"add-task:child",text:"Child task"},{id:"add-task:before",text:"Task above"},{id:"add-task:after",text:"Task below"}]},{type:"separator"},{id:"convert-task",text:"Convert to",icon:"wxi-swap-horizontal",dataFactory:e=>({id:`convert-task:${e.id}`,text:`${e.label}`,isDisabled:ir(e.id)})},{id:"edit-task",text:"Edit",icon:"wxi-edit",isHidden:(e,t,n)=>Q(n)},{type:"separator"},{id:"cut-task",text:"Cut",icon:"wxi-content-cut",subtext:"Ctrl+X"},{id:"copy-task",text:"Copy",icon:"wxi-content-copy",subtext:"Ctrl+C"},{id:"paste-task",text:"Paste",icon:"wxi-content-paste",subtext:"Ctrl+V"},{id:"move-task",text:"Move",icon:"wxi-swap-vertical",data:[{id:"move-task:up",text:"Up"},{id:"move-task:down",text:"Down"}]},{type:"separator"},{id:"indent-task:add",text:"Indent",icon:"wxi-indent"},{id:"indent-task:remove",text:"Outdent",icon:"wxi-unindent"},{type:"separator"},{id:"delete-task",icon:"wxi-delete",text:"Delete",subtext:"Ctrl+D / BS",isHidden:(e,t,n)=>Qt(t)&&Q(n)}]);function or(e){let t=[...Rt];return e?.undo&&(t=t.concat([{comp:"separator"},{id:"undo",comp:"icon",icon:"wxi-undo",menuText:"Undo"},{id:"redo",comp:"icon",icon:"wxi-redo",menuText:"Redo"}])),e?.splitTasks&&t.splice(2,0,{id:"split-task",comp:"icon",icon:"wxi-arrow-split",menuText:"Split"}),t.length>Rt.length&&(t=at(t)),t}const Rt=at([{id:"add-task",comp:"button",icon:"wxi-plus",text:"New task",type:"primary"},{id:"edit-task",comp:"icon",icon:"wxi-edit",menuText:"Edit",text:"Ctrl+E"},{id:"delete-task",comp:"icon",icon:"wxi-delete",menuText:"Delete",text:"Ctrl+D, Backspace"},{comp:"separator"},{id:"move-task:up",comp:"icon",icon:"wxi-angle-up",menuText:"Move up"},{id:"move-task:down",comp:"icon",icon:"wxi-angle-down",menuText:"Move down"},{comp:"separator"},{id:"copy-task",comp:"icon",icon:"wxi-content-copy",menuText:"Copy",text:"Ctrl+V"},{id:"cut-task",comp:"icon",icon:"wxi-content-cut",menuText:"Cut",text:"Ctrl+X"},{id:"paste-task",comp:"icon",icon:"wxi-content-paste",menuText:"Paste",text:"Ctrl+V"},{comp:"separator"},{id:"indent-task:add",comp:"icon",icon:"wxi-indent",menuText:"Indent"},{id:"indent-task:remove",comp:"icon",icon:"wxi-unindent",menuText:"Outdent"}]);function kt(e){return e.type==="summary"}function Jt(e){return e.type==="milestone"}function yt(e){return typeof e.parent>"u"}function Vt(e,t){return t.unscheduledTasks&&e.unscheduled}function dr(e){const t=[...dn];return e?.unscheduledTasks&&t.splice(6,0,{key:"unscheduled",comp:"twostate",label:"",config:{value:!0,text:"Unschedule",textActive:"Schedule"},isHidden:n=>kt(n)||yt(n)}),t}const dn=[{key:"text",comp:"text",label:"Name",config:{placeholder:"Add task name"}},{key:"details",comp:"textarea",label:"Description",config:{placeholder:"Add description"}},{key:"type",comp:"select",label:"Type",isHidden:e=>yt(e)},{key:"start",comp:"date",label:"Start date",isHidden:e=>kt(e),isDisabled:Vt},{key:"end",comp:"date",label:"End date",isHidden:e=>kt(e)||Jt(e),isDisabled:Vt},{key:"duration",comp:"counter",label:"Duration",config:{min:1},isHidden:e=>kt(e)||Jt(e),isDisabled:Vt},{key:"progress",comp:"slider",label:"Progress",config:{min:1,max:100},isHidden:e=>Jt(e)||yt(e)},{key:"links",comp:"links",label:"",isHidden:e=>yt(e)}],cr=[{id:"task",label:"Task"},{id:"summary",label:"Summary task"},{id:"milestone",label:"Milestone"}];export{Ya as Calendar,Va as DataStore,Sa as defaultColumns,dn as defaultEditorItems,Gt as defaultMenuOptions,cr as defaultTaskTypes,Rt as defaultToolbarButtons,fa as extendDragOptions,As as format,T as getAdder,E as getDiffer,dr as getEditorItems,er as getMenuOptions,or as getToolbarButtons,I as getUnitStart,Ka as grid,tt as handleAction,Ae as isHandledAction,ha as isSegmentMoveAllowed,Oe as normalizeLinks,oa as normalizeZoom,Ye as parseTaskDates,ya as placeLink,Da as prepareEditTask,aa as registerScaleUnit};
|