apexgantt 3.10.0 → 3.10.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/apexgantt.es.min.js +1 -1
- package/apexgantt.min.js +1 -1
- package/package.json +1 -1
package/apexgantt.es.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=()=>{};class e{constructor(t,e){this.injectedStyles=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),n=Array.from(e);return{item:t=>n[t]||null,get length(){return n.length},[Symbol.iterator]:()=>n[Symbol.iterator](),...Object.fromEntries(n.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,n):this.context.addEventListener(t,e,n)}removeEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,n):this.context.removeEventListener(t,e,n)}injectStyles(t,e,n={}){const{force:i=!1,priority:o="normal"}=n;if(!i&&this.injectedStyles.has(e))return;if(i){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!i)return void this.injectedStyles.add(e);const r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==o&&r.setAttribute("data-priority",o),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===o?t.insertBefore(r,t.firstChild):t.appendChild(r)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:n})=>{this.injectStyles(t,e,n)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}destroy(){this.removeAllStyles(),this.injectedStyles.clear()}}class n{constructor(t,n){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new e(t,n)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,n){this.chartContext.addEventListener(t,e,n)}removeEventListener(t,e,n){this.chartContext.removeEventListener(t,e,n)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}const i=globalThis.console;const o=class{static decodeLicenseData(t){try{const e=window.atob(t),n=JSON.parse(e);return n.issueDate&&n.expiryDate&&n.plan?{domains:Array.isArray(n.domains)?n.domains:void 0,expiryDate:n.expiryDate,issueDate:n.issueDate,plan:n.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,n="standard",i){const o={expiryDate:e,issueDate:t,plan:n};i&&i.length>0&&(o.domains=i);return`APEX-${window.btoa(JSON.stringify(o))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,i.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.split("-");if(2!==e.length)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=e[1],i=this.decodeLicenseData(n);if(!i)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const o=new Date;if(new Date(i.expiryDate)<o)return{data:i,expired:!0,message:`License expired on ${i.expiryDate}. Please renew your license.`,valid:!1};if(i.domains&&i.domains.length>0){const t="undefined"!=typeof window?window.location.hostname:"";if(!i.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:i,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${i.domains.join(", ")}.`,valid:!1}}return{data:i,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};o.licenseKey=null,o.validationResult=null;let r=o;const a="\n #toolbar {\n display: flex;\n gap: 5px;\n position: absolute;\n right: 10px;\n top: 10px;\n z-index: 100;\n }\n \n .toolbar-item {\n align-items: center;\n background-color: var(--toolbar-bg-color, #FFFFFF);\n border: 1px solid var(--toolbar-border-color, #BCBCBC);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n border-radius: 3px;\n transition: all 0.2s ease;\n position: relative;\n }\n \n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--toolbar-border-color, #999);\n transform: translateY(-1px);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n }\n \n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);\n }\n \n .toolbar-item:focus {\n outline: none;\n border-color: var(--button-bg-color, #0066cc);\n box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);\n }\n \n .toolbar-item img {\n width: 16px;\n height: 16px;\n pointer-events: none;\n filter: var(--toolbar-icon-filter, none);\n }\n \n .toolbar-item[disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n }\n \n /* Tooltip styles */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: -35px;\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, #333);\n color: var(--tooltip-text-color, white);\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 12px;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s ease;\n z-index: 1000;\n }\n \n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: -25px;\n left: 50%;\n transform: translateX(-50%);\n border: 5px solid transparent;\n border-bottom-color: var(--tooltip-bg-color, #333);\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s ease;\n z-index: 1000;\n }\n \n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n \n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 5px;\n position: absolute;\n right: 10px;\n top: 10px;\n z-index: 100;\n }\n",s=class{static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text \n x="50%" \n y="50%" \n dominant-baseline="middle" \n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};s.WATERMARK_ATTR="data-apexcharts-watermark",s.WATERMARK_TEXT="APEXCHARTS";let l=s;function c(t){const e=t.getRootNode();return e instanceof ShadowRoot?e.host:t.parentElement}function d(t,e){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),o=function(t){let e=1,n=1,i=0,o=0,r=t.parentElement;for(;r&&r!==document.body&&r!==document.documentElement;){const t=window.getComputedStyle(r),a=t.scale;if(a&&"none"!==a){const t=a.split(" ").map(parseFloat);1===t.length?(e*=t[0],n*=t[0]):t.length>=2&&(e*=t[0],n*=t[1])}const s=t.transform;if(s&&"none"!==s)try{const t=new DOMMatrix(s);e*=t.a,n*=t.d,i+=t.e,o+=t.f}catch{}r=c(r)}return{scaleX:e,scaleY:n,translateX:i,translateY:o}}(e),r=function(t){const e=window.getComputedStyle(t);let n=1,i=1,o=0,r=0,a=0;const s=e.scale;if(s&&"none"!==s){const t=s.split(" ").map(parseFloat);1===t.length?(n=t[0],i=t[0]):t.length>=2&&(n=t[0],i=t[1])}const l=e.transform;if(l&&"none"!==l)try{const t=new DOMMatrix(l);n*=t.a,i*=t.d,o=t.e,r=t.f,a=Math.atan2(t.b,t.a)}catch{}return{scaleX:n,scaleY:i,translateX:o,translateY:r,rotation:a}}(t),a=o.scaleX||1,s=o.scaleY||1,l=(n.left-i.left)/a,d=(n.top-i.top)/s,h=n.width/a,p=n.height/s;if(Math.abs(r.rotation)>.01){const t=l+h/2,e=d+p/2;return{left:t,right:t,top:e,bottom:e,width:0,height:0}}return{left:l,right:l+h,top:d,bottom:d+p,width:h,height:p}}const h="aria-hidden",p=(t,e="apex-tooltip-container")=>{let n=t.getElementById(e);if(!n){n=t.createElement("div"),n.id=e,n.setAttribute("role","tooltip"),n.setAttribute(h,"true");t.getAppendContainer().appendChild(n)}return n},u=(t,e="",n,i="")=>{const o=t.getElementById(e);if(!o)return p(t,e),u(t,e,n,i);if(n&&i){const t=i.includes("tooltip-content"),e=n.match(/background-color:\s*([^;]+);?/),r=n.match(/color:\s*([^;]+);?/),a=e?e[1]:"#333",s=r?r[1]:"white";o.innerHTML=t?i:`<div class="tooltip-content" style="background-color: ${a}; color: ${s};">${i}</div>`;const l=n+"; display: block !important; visibility: visible !important; opacity: 1 !important;";o.setAttribute("style",l),o.classList.add("visible"),o.setAttribute(h,"false")}else o.removeAttribute("style"),o.classList.remove("visible"),o.setAttribute(h,"true"),o.innerHTML=""},g=(t={})=>{const e=[];for(const i in t){const o=`${n=i,n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[i]};`;e.push(o)}var n;return e.join(" ")};function m(t,{className:e="",content:n,style:i={}}={}){const o=b(t,"div",{className:e,innerHTML:n||""});return o.setAttribute("style",g(i)),o}function b(t,e,n={}){const i=t.createElement(e);return Object.assign(i,n)}function f(t,e){if(!t)return"#000000";3===(t=t.replace(/^#/,"")).length&&(t=t.split("").map((t=>t+t)).join(""));const n=parseInt(t,16);let i=n>>16&255,o=n>>8&255,r=255&n;return e*=.299*i+.587*o+.114*r<100?-1:1,i=Math.min(255,Math.max(0,i+e)),o=Math.min(255,Math.max(0,o+e)),r=Math.min(255,Math.max(0,r+e)),`#${(1<<24|i<<16|o<<8|r).toString(16).slice(1)}`}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var v={exports:{}};v.exports=function(){var t=1e3,e=6e4,n=36e5,i="millisecond",o="second",r="minute",a="hour",s="day",l="week",c="month",d="quarter",h="year",p="date",u="Invalid Date",g=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},f=function(t,e,n){var i=String(t);return!i||i.length>=e?t:""+Array(e+1-i.length).join(n)+t},y={s:f,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),i=Math.floor(n/60),o=n%60;return(e<=0?"+":"-")+f(i,2,"0")+":"+f(o,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var i=12*(n.year()-e.year())+(n.month()-e.month()),o=e.clone().add(i,c),r=n-o<0,a=e.clone().add(i+(r?-1:1),c);return+(-(i+(n-o)/(r?o-a:a-o))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:l,d:s,D:p,h:a,m:r,s:o,ms:i,Q:d}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},v="en",w={};w[v]=b;var x="$isDayjsObject",k=function(t){return t instanceof M||!(!t||!t[x])},C=function t(e,n,i){var o;if(!e)return v;if("string"==typeof e){var r=e.toLowerCase();w[r]&&(o=r),n&&(w[r]=n,o=r);var a=e.split("-");if(!o&&a.length>1)return t(a[0])}else{var s=e.name;w[s]=e,o=s}return!i&&o&&(v=o),o||!i&&v},S=function(t,e){if(k(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new M(n)},E=y;E.l=C,E.i=k,E.w=function(t,e){return S(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var M=function(){function b(t){this.$L=C(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[x]=!0}var f=b.prototype;return f.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(E.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var i=e.match(g);if(i){var o=i[2]-1||0,r=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],o,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)):new Date(i[1],o,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)}}return new Date(e)}(t),this.init()},f.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},f.$utils=function(){return E},f.isValid=function(){return!(this.$d.toString()===u)},f.isSame=function(t,e){var n=S(t);return this.startOf(e)<=n&&n<=this.endOf(e)},f.isAfter=function(t,e){return S(t)<this.startOf(e)},f.isBefore=function(t,e){return this.endOf(e)<S(t)},f.$g=function(t,e,n){return E.u(t)?this[e]:this.set(n,t)},f.unix=function(){return Math.floor(this.valueOf()/1e3)},f.valueOf=function(){return this.$d.getTime()},f.startOf=function(t,e){var n=this,i=!!E.u(e)||e,d=E.p(t),u=function(t,e){var o=E.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return i?o:o.endOf(s)},g=function(t,e){return E.w(n.toDate()[t].apply(n.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},m=this.$W,b=this.$M,f=this.$D,y="set"+(this.$u?"UTC":"");switch(d){case h:return i?u(1,0):u(31,11);case c:return i?u(1,b):u(0,b+1);case l:var v=this.$locale().weekStart||0,w=(m<v?m+7:m)-v;return u(i?f-w:f+(6-w),b);case s:case p:return g(y+"Hours",0);case a:return g(y+"Minutes",1);case r:return g(y+"Seconds",2);case o:return g(y+"Milliseconds",3);default:return this.clone()}},f.endOf=function(t){return this.startOf(t,!1)},f.$set=function(t,e){var n,l=E.p(t),d="set"+(this.$u?"UTC":""),u=(n={},n[s]=d+"Date",n[p]=d+"Date",n[c]=d+"Month",n[h]=d+"FullYear",n[a]=d+"Hours",n[r]=d+"Minutes",n[o]=d+"Seconds",n[i]=d+"Milliseconds",n)[l],g=l===s?this.$D+(e-this.$W):e;if(l===c||l===h){var m=this.clone().set(p,1);m.$d[u](g),m.init(),this.$d=m.set(p,Math.min(this.$D,m.daysInMonth())).$d}else u&&this.$d[u](g);return this.init(),this},f.set=function(t,e){return this.clone().$set(t,e)},f.get=function(t){return this[E.p(t)]()},f.add=function(i,d){var p,u=this;i=Number(i);var g=E.p(d),m=function(t){var e=S(u);return E.w(e.date(e.date()+Math.round(t*i)),u)};if(g===c)return this.set(c,this.$M+i);if(g===h)return this.set(h,this.$y+i);if(g===s)return m(1);if(g===l)return m(7);var b=(p={},p[r]=e,p[a]=n,p[o]=t,p)[g]||1,f=this.$d.getTime()+i*b;return E.w(f,this)},f.subtract=function(t,e){return this.add(-1*t,e)},f.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||u;var i=t||"YYYY-MM-DDTHH:mm:ssZ",o=E.z(this),r=this.$H,a=this.$m,s=this.$M,l=n.weekdays,c=n.months,d=n.meridiem,h=function(t,n,o,r){return t&&(t[n]||t(e,i))||o[n].slice(0,r)},p=function(t){return E.s(r%12||12,t,"0")},g=d||function(t,e,n){var i=t<12?"AM":"PM";return n?i.toLowerCase():i};return i.replace(m,(function(t,i){return i||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return E.s(e.$y,4,"0");case"M":return s+1;case"MM":return E.s(s+1,2,"0");case"MMM":return h(n.monthsShort,s,c,3);case"MMMM":return h(c,s);case"D":return e.$D;case"DD":return E.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,l,2);case"ddd":return h(n.weekdaysShort,e.$W,l,3);case"dddd":return l[e.$W];case"H":return String(r);case"HH":return E.s(r,2,"0");case"h":return p(1);case"hh":return p(2);case"a":return g(r,a,!0);case"A":return g(r,a,!1);case"m":return String(a);case"mm":return E.s(a,2,"0");case"s":return String(e.$s);case"ss":return E.s(e.$s,2,"0");case"SSS":return E.s(e.$ms,3,"0");case"Z":return o}return null}(t)||o.replace(":","")}))},f.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},f.diff=function(i,p,u){var g,m=this,b=E.p(p),f=S(i),y=(f.utcOffset()-this.utcOffset())*e,v=this-f,w=function(){return E.m(m,f)};switch(b){case h:g=w()/12;break;case c:g=w();break;case d:g=w()/3;break;case l:g=(v-y)/6048e5;break;case s:g=(v-y)/864e5;break;case a:g=v/n;break;case r:g=v/e;break;case o:g=v/t;break;default:g=v}return u?g:E.a(g)},f.daysInMonth=function(){return this.endOf(c).$D},f.$locale=function(){return w[this.$L]},f.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),i=C(t,e,!0);return i&&(n.$L=i),n},f.clone=function(){return E.w(this.$d,this)},f.toDate=function(){return new Date(this.valueOf())},f.toJSON=function(){return this.isValid()?this.toISOString():null},f.toISOString=function(){return this.$d.toISOString()},f.toString=function(){return this.$d.toUTCString()},b}(),T=M.prototype;return S.prototype=T,[["$ms",i],["$s",o],["$m",r],["$H",a],["$W",s],["$M",c],["$y",h],["$D",p]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),S.extend=function(t,e){return t.$i||(t(e,M,S),t.$i=!0),S},S.locale=C,S.isDayjs=k,S.unix=function(t){return S(1e3*t)},S.en=w[v],S.Ls=w,S.p={},S}();const w=y(v.exports);var x={exports:{}};const k=y(x.exports=function(t,e){e.prototype.isSameOrBefore=function(t,e){return this.isSame(t,e)||this.isBefore(t,e)}});var C={exports:{}};C.exports=function(t,e,n){var i=function(t,e){if(!e||!e.length||1===e.length&&!e[0]||1===e.length&&Array.isArray(e[0])&&!e[0].length)return null;var n;1===e.length&&e[0].length>0&&(e=e[0]),n=(e=e.filter((function(t){return t})))[0];for(var i=1;i<e.length;i+=1)e[i].isValid()&&!e[i][t](n)||(n=e[i]);return n};n.max=function(){var t=[].slice.call(arguments,0);return i("isAfter",t)},n.min=function(){var t=[].slice.call(arguments,0);return i("isBefore",t)}};const S=y(C.exports);var E,M,T={exports:{}};const A=y(T.exports=(E="month",M="quarter",function(t,e){var n=e.prototype;n.quarter=function(t){return this.$utils().u(t)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(t-1))};var i=n.add;n.add=function(t,e){return t=Number(t),this.$utils().p(e)===M?this.add(3*t,E):i.bind(this)(t,e)};var o=n.startOf;n.startOf=function(t,e){var n=this.$utils(),i=!!n.u(e)||e;if(n.p(t)===M){var r=this.quarter()-1;return i?this.month(3*r).startOf(E).startOf("day"):this.month(3*r+2).endOf(E).endOf("day")}return o.bind(this)(t,e)}}));var $={exports:{}};$.exports=function(t,e){e.prototype.weekday=function(t){var e=this.$locale().weekStart||0,n=this.$W,i=(n<e?n+7:n)-e;return this.$utils().u(t)?i:this.subtract(i,"day").add(t,"day")}};const I=y($.exports);var D={exports:{}};D.exports=function(){var t="week",e="year";return function(n,i,o){var r=i.prototype;r.week=function(n){if(void 0===n&&(n=null),null!==n)return this.add(7*(n-this.week()),"day");var i=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var r=o(this).startOf(e).add(1,e).date(i),a=o(this).endOf(t);if(r.isBefore(a))return 1}var s=o(this).startOf(e).date(i).startOf(t).subtract(1,"millisecond"),l=this.diff(s,t,!0);return l<0?o(this).startOf("week").week():Math.ceil(l)},r.weeks=function(t){return void 0===t&&(t=null),this.week(t)}}}();const B=y(D.exports),F=globalThis.console,R={warn(...t){F.warn(...t)},error(...t){F.error(...t)}};function H(t,e){const n=t.getInstanceId(),i=`.bar-container .bar-timeline[data-taskid="${e}"][data-chart-instance="${n}"]`,o=t.querySelector(i);return o||R.warn(`[${n}] Bar element not found for task: ${e}`),o}function z(t,e){const n=t.getInstanceId(),i=`.timeline-body .timeline-data-row[data-taskid="${e}"][data-chart-instance="${n}"]`,o=t.querySelector(i);return o||R.warn(`[${n}] Bar row element not found for task: ${e}`),o}const L=["day","week","month","quarter","year"];var P=(t=>(t.Day="day",t.Month="month",t.Quarter="quarter",t.Week="week",t.Year="year",t))(P||{}),O=(t=>(t.Horizontal="horizontal",t.Vertical="vertical",t))(O||{});class q{constructor(t,e,n,i,o){this.options=t,this.ganttStartDate=e,this.viewMode=n,this.chartContext=i,this.totalHeight=o}calculateWidth(t){return w(t.x2).add(1,"day").diff(w(t.x1),`${this.viewMode}s`,!0)*N[this.viewMode]}calculateX(t){return w(t.x1).diff(this.ganttStartDate.startOf(this.viewMode),`${this.viewMode}s`,!0)*N[this.viewMode]}drawAnnotation(t){const e=m(this.chartContext,{className:"annotation"}),n=this.calculateX(t),i=g(this.getAnnotationStyles(t,n));if(e.setAttribute("style",i),t.label){const n=this.renderLabel(t);e.append(n)}return e}getAnnotationStyles(t,e){const{annotationBgColor:n,annotationBorderColor:i,annotationBorderWidth:o}=this.options,{bgColor:r,borderColor:a,borderWidth:s}=t;let l=0;const c=t.x2?s??o:(s??o??0)/2;return t.x2&&(l=this.calculateWidth(t)),{backgroundColor:r||n,borderColor:`${a||i}`,borderStyle:"solid",borderWidth:`${c}px`,height:`${this.totalHeight}px`,left:`${e}px`,position:"absolute",top:"0px",width:l?`${l}px`:"unset",zIndex:"10"}}renderLabel(t){const e=m(this.chartContext,{className:"annotation-label"}),{annotationBgColor:n,annotationBorderColor:i,fontColor:o,fontFamily:r,fontSize:a,fontWeight:s}=this.options,{bgColor:l,borderColor:c}=t,{label:d}=t;if(!d)return e;const h=d.fontColor||o,p=d.fontFamily||r,u=d.fontSize||a,b=d.fontWeight||s,f=g({background:l||n,borderColor:`${c||i}`,borderStyle:"solid",borderWidth:"1px",color:h,fontFamily:p,fontSize:u,fontWeight:b,left:"0px",padding:"2px 5px",position:"absolute",top:"-1px",width:"max-content",zIndex:"1"});return e.setAttribute("style",f),e.innerText=d.text??"",e}render(){const t=[];return this.options.annotations.forEach((e=>{t.push(this.drawAnnotation(e))})),t}}const N={[P.Day]:80,[P.Month]:150,[P.Quarter]:150,[P.Week]:180,[P.Year]:180};const W=(t,e)=>{const n=function(t,e){const n=w(t);switch(e){case P.Month:return n.daysInMonth();case P.Quarter:{const t=n.startOf("quarter");return n.endOf("quarter").diff(t,"day")+1}case P.Week:return 7;case P.Year:{const t=n.startOf("year");return n.endOf("year").diff(t,"day")+1}default:return 1}}(t,e);return N[e]/n},V={annotationBorderDashArray:[],annotationBorderWidth:2,annotationOrientation:O.Horizontal,annotations:[],barBorderRadius:"5px",barMargin:8,baseline:{enabled:!1,color:"#b0b8c1"},canvasStyle:"border: 1px solid #CACED0; box-sizing: border-box",criticalBarColor:"#e53935",criticalArrowColor:"#e53935",enableCriticalPath:!1,cellBorderWidth:"1px",enableSelection:!1,enableExport:!0,toolbarItems:[],enableResize:!0,enableTaskDrag:!0,enableTaskEdit:!1,enableTaskResize:!0,enableTooltip:!0,fontFamily:"sans-serif",fontSize:"14px",fontWeight:"400",height:"500px",inputDateFormat:"MM-DD-YYYY",rowHeight:38,series:[],showCheckboxColumn:!0,tasksContainerWidth:425,tooltipId:"apexgantt-tooltip-container",tooltipTemplate(t,e){const n=[`<div>\n <strong>Task:</strong>\n <span>${t.name}</span>\n </div>\n `];return t.type===ct.Task?n.push(`\n <div>\n <strong>Start:</strong>\n <span>${it(t,tt.StartTime,e)}</span>\n </div>\n <div>\n <strong>End:</strong>\n <span>${it(t,tt.EndTime,e)}</span>\n </div>\n <div>\n <strong>Duration:</strong>\n <span>${it(t,tt.Duration,e)}</span>\n </div>\n <div>\n <strong>Progress:</strong>\n <span>${t.progress}%</span>\n </div>\n `):t.type===ct.Milestone&&n.push(`\n <div>\n <strong>Date:</strong>\n <span>${it(t,tt.StartTime,e)}</span>\n </div>\n `),t.dependency&&n.push(`\n <div>\n <strong>Depends on:</strong>\n <span>${t.dependency}</span>\n </div>\n `),`\n <div>\n ${n.join("")}\n </div>\n `},viewMode:P.Week,width:"100%"},Y={annotationBgColor:"#DBEAFE",annotationBorderColor:"#60A5FA",arrowColor:"#1A6FC4",backgroundColor:"#FFFFFF",barBackgroundColor:"#318CE7",barTextColor:"#FFFFFF",borderColor:"#DFE0E1",cellBorderColor:"#E3EDF8",fontColor:"#000000",headerBackground:"#EBF3FB",rowBackgroundColors:["#FFFFFF"],tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#BCBCBC"},_={annotationBgColor:"#4A2D4D",annotationBorderColor:"#8B4D8F",arrowColor:"#A5B4FC",backgroundColor:"#1E1E1E",barBackgroundColor:"#818CF8",barTextColor:"#FFFFFF",borderColor:"#3A3A3A",cellBorderColor:"#3A3A3A",fontColor:"#E0E0E0",headerBackground:"#2A2A2A",rowBackgroundColors:["#1E1E1E","#252525"],tooltipBGColor:"#2D2D2D",tooltipBorderColor:"#444444"};function j(t){return{...V,..."dark"===t?_:Y}}const U=j("light"),K={TASK_UPDATE:"taskUpdate",TASK_VALIDATION_ERROR:"taskValidationError",TASK_UPDATE_SUCCESS:"taskUpdateSuccess",TASK_UPDATE_ERROR:"taskUpdateError",TASK_DRAGGED:"taskDragged",TASK_RESIZED:"taskResized",SELECTION_CHANGE:"selectionChange",DEPENDENCY_ARROW_UPDATE:"dependencyArrowUpdate"};class X{constructor(t,e,n,i,o){this.taskId=t,this.options=e,this.chartContext=i,this.dataManager=o,this.dragState={childTasks:[],daysPerPixel:0,initialLeft:0,initialPosition:0,initialStartTime:"",initialEndTime:"",isDragging:!1,startX:0},this.task=null;const r=this.dataManager.getTaskById(t);if(!r)throw new Error(`BarDragManager: Task with id "${t}" not found`);this.dragState.daysPerPixel=W(r.startTime,n)}calculateFinalPosition(t){const{daysPerPixel:e,initialLeft:n,initialPosition:i}=this.dragState,o=t.clientX-i,r=Math.round(o/e);return{calculatedLeft:n+r*e,daysMoved:r}}createMouseDownHandler(t){return e=>{this.task=this.dataManager.getTaskById(this.taskId),this.task&&(this.dragState={...this.dragState,initialLeft:parseInt(t.style.left)||0,initialPosition:e.clientX,initialStartTime:this.task.startTime,initialEndTime:this.task.endTime,isDragging:!0,startX:e.clientX},t.classList.add("dragging"),t.setAttribute("aria-grabbed","true"),this.dragState.childTasks=this.dataManager.getNestedChildTasks(this.task.id).map((t=>{const e=H(this.chartContext,t.id);return e?{...t,element:e,left:parseInt(e.style.left)||0,width:parseInt(e.style.width)||0}:t})))}}createMouseMoveHandler(t){return e=>{this.dragState.isDragging&&requestAnimationFrame((()=>{const n=e.clientX-this.dragState.startX,i=parseInt(t.style.left)||0;this.moveBar(t,i,n),this.task&&this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),this.moveChildBars(n),this.dragState.startX=e.clientX}))}}createMouseUpHandler(t,e){return n=>{if(!this.dragState.isDragging)return;if(this.dragState.isDragging=!1,t.classList.remove("dragging"),t.setAttribute("aria-grabbed","false"),!this.task)return;const{calculatedLeft:i,daysMoved:o}=this.calculateFinalPosition(n);if(0===o)return void(this.dragState={...this.dragState,isDragging:!1});const r=w(this.task.startTime).add(o,"day").format(this.options.inputDateFormat),a=w(this.task.endTime).add(o,"day").format(this.options.inputDateFormat),s=this.dragState.childTasks.map((t=>({taskId:t.id,newStartTime:w(t.startTime).add(o,"day").format(this.options.inputDateFormat),newEndTime:t.endTime?w(t.endTime).add(o,"day").format(this.options.inputDateFormat):null}))).filter((t=>null!==t.newEndTime));this.emitTaskDraggedEvent(o,r,a,s),this.updateTaskPosition(t,i,o,e),this.updateChildrenPositions(i,o,e)}}emitTaskDraggedEvent(t,e,n,i){if(!this.task)return;const o={taskId:this.task.id,oldStartTime:this.dragState.initialStartTime,oldEndTime:this.dragState.initialEndTime,newStartTime:e,newEndTime:n,daysMoved:t,affectedChildTasks:i,timestamp:Date.now()},r=new CustomEvent(K.TASK_DRAGGED,{detail:o,bubbles:!0,composed:!0,cancelable:!1}),a=this.chartContext.getChartContainer();a&&a.dispatchEvent(r)}moveBar(t,e,n){t.style.left=`${e+n}px`}moveChildBars(t){this.dragState.childTasks.forEach((e=>{if(e.element){const n=parseInt(e.element.style.left)||0;e.element.style.left=`${n+t}px`,this.dataManager.updateDependencyArrows(e.id,this.chartContext)}}))}updateChildrenPositions(t,e,n){this.dragState.childTasks.forEach((i=>{const o=H(this.chartContext,i.id);if(o){const r=t-this.dragState.initialLeft;o.style.left=`${(i.left??0)+r}px`;const a=w(i.startTime).add(e,"day").format(this.options.inputDateFormat),s=i.endTime?w(i.endTime).add(e,"day").format(this.options.inputDateFormat):null;this.dataManager.updateDependencyArrows(i.id,this.chartContext),null==n||n(i.id,{endTime:s??void 0,startTime:a})}}))}updateTaskPosition(t,e,n,i){if(!this.task)return;t.style.left=`${e}px`;const o=w(this.task.startTime).add(n,"day").format(this.options.inputDateFormat),r=w(this.task.endTime).add(n,"day").format(this.options.inputDateFormat);this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),null==i||i(this.task.id,{endTime:r,startTime:o})}makeDraggable(t,e){const n=this.createMouseDownHandler(t),i=this.createMouseMoveHandler(t),o=this.createMouseUpHandler(t,e);return t.addEventListener("mousedown",n),this.chartContext.addEventListener("mousemove",i),this.chartContext.addEventListener("mouseup",o),()=>{t.removeEventListener("mousedown",n),this.chartContext.removeEventListener("mousemove",i),this.chartContext.removeEventListener("mouseup",o)}}}class G{constructor(t,e,n,i,o){this.taskId=t,this.options=e,this.chartContext=i,this.dataManager=o,this.interactionState={daysPerPixel:0,initialLeft:0,initialPosition:0,initialWidth:0,initialStartTime:"",initialEndTime:"",isResizing:!1,resizeHandle:null,startX:0},this.task=null;const r=this.dataManager.getTaskById(t);if(!r)throw new Error(`BarResizeManager: Task with id "${t}" not found`);this.interactionState.daysPerPixel=W(r.startTime,n)}createMouseMoveHandler(t){return e=>{this.interactionState.isResizing&&requestAnimationFrame((()=>{const n=e.clientX-this.interactionState.startX,{daysPerPixel:i,resizeHandle:o}=this.interactionState,r=parseInt(t.style.left)||0,a=parseInt(t.style.width)||0;if("left"===o){const e=Math.max(0,r+n),o=a-(e-r);o>=i&&(t.style.left=`${e}px`,t.style.width=`${o}px`)}else{const e=Math.max(i,a+n);t.style.width=`${e}px`}this.task&&(this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),this.interactionState.startX=e.clientX)}))}}createMouseUpHandler(t,e){return n=>{if(!this.interactionState.isResizing)return;if(!this.task)return;t.classList.remove("resizing");const{daysPerPixel:i,initialLeft:o,initialPosition:r,initialWidth:a,resizeHandle:s}=this.interactionState,l=n.clientX-r,c=this.interactionState.initialStartTime,d=this.interactionState.initialEndTime;let h=c,p=d,u=0;if("left"===s){let n=Math.round(l/i),r=o+n*i,s=a-n*i;if(s<i&&(s=i,r=o+a-i,n=Math.round((r-o)/i)),0===n)return void(this.interactionState={...this.interactionState,isResizing:!1,resizeHandle:null});t.style.left=`${r}px`,t.style.width=`${s}px`,h=w(this.task.startTime).add(n,"day").format(this.options.inputDateFormat),u=-n,null==e||e(this.task.id,{startTime:h})}else{let n=Math.round(l/i),o=a+n*i;if(o<i&&(o=i,n=Math.round((o-a)/i)),0===n)return void(this.interactionState={...this.interactionState,isResizing:!1,resizeHandle:null});t.style.width=`${o}px`,p=w(this.task.endTime).add(n,"day").format(this.options.inputDateFormat),u=n,null==e||e(this.task.id,{endTime:p})}null!==s&&this.emitTaskResizedEvent(s,c,d,h,p,u),this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),this.interactionState={...this.interactionState,isResizing:!1,resizeHandle:null}}}emitTaskResizedEvent(t,e,n,i,o,r){if(!this.task)return;const a={taskId:this.task.id,resizeHandle:t,oldStartTime:e,oldEndTime:n,newStartTime:i,newEndTime:o,durationChange:r,timestamp:Date.now()},s=new CustomEvent(K.TASK_RESIZED,{detail:a,bubbles:!0,composed:!0,cancelable:!1}),l=this.chartContext.getChartContainer();l&&l.dispatchEvent(s)}createResizeMouseDownHandler(t){return(e,n)=>{e.stopPropagation(),this.task=this.dataManager.getTaskById(this.taskId),this.task&&(this.interactionState={...this.interactionState,initialLeft:parseInt(t.style.left)||0,initialPosition:e.clientX,initialWidth:parseInt(t.style.width)||0,initialStartTime:this.task.startTime,initialEndTime:this.task.endTime,isResizing:!0,resizeHandle:n,startX:e.clientX},t.classList.add("resizing"))}}makeResizable(t,e){const n=t.querySelector(".handle-left"),i=t.querySelector(".handle-right"),o=this.createResizeMouseDownHandler(t),r=this.createMouseMoveHandler(t),a=this.createMouseUpHandler(t,e);return null==n||n.addEventListener("mousedown",(t=>o(t,"left"))),null==i||i.addEventListener("mousedown",(t=>o(t,"right"))),this.chartContext.addEventListener("mousemove",r),this.chartContext.addEventListener("mouseup",a),()=>{null==n||n.removeEventListener("mousedown",(t=>o(t,"left"))),null==i||i.removeEventListener("mousedown",(t=>o(t,"right"))),this.chartContext.removeEventListener("mousemove",r),this.chartContext.removeEventListener("mouseup",a)}}}class Q{constructor(t,e){this.chartContext=t,this.options=e,this.overlay=null,this.keydownHandler=null,this.clickOutsideHandler=null,this.createDialog(),this.setupEventListeners()}createDialog(){const t=this.chartContext.getInstanceId(),e=this.chartContext.getElementById(`${this.options.id}-container`);if(e){this.container=e;const t=this.container.querySelector(".gantt-dialog");return void this.updateDialogContent(t)}this.container=this.chartContext.createElement("div"),this.container.id=`${this.options.id}-container`,this.container.className="gantt-dialog-container",this.container.setAttribute("role","dialog"),this.container.setAttribute("aria-modal","true"),this.container.setAttribute("aria-labelledby",`${this.options.id}-title`),this.container.setAttribute("data-chart-instance",t),this.options.modal&&(this.overlay=this.chartContext.createElement("div"),this.overlay.className="dialog-overlay",this.container.appendChild(this.overlay));const n=this.chartContext.createElement("div");n.id=this.options.id,n.className="gantt-dialog",this.createDialogStructure(n),this.options.width&&(n.style.width=this.options.width),this.options.height&&(n.style.height=this.options.height),this.container.appendChild(n),!1!==this.options.positionRelativeToChart&&this.positionRelativeToChart();const i=!1!==this.options.positionRelativeToChart?this.chartContext.getChartContainer():this.chartContext.getAppendContainer();null==i||i.appendChild(this.container)}createDialogStructure(t){t.innerHTML=`\n <div class="dialog-header">\n <h2 id="${this.options.id}-title-${this.chartContext.getInstanceId()}" class="dialog-title">${this.options.title||""}</h2>\n <button class="dialog-close" aria-label="Close dialog" type="button">×</button>\n </div>\n <div class="dialog-content"></div>\n `,this.updateDialogContent(t)}positionRelativeToChart(){const t=this.chartContext.getChartContainer();if(t){"static"===window.getComputedStyle(t).position&&(t.style.position="relative")}this.container.style.position="absolute",this.container.style.top="0",this.container.style.left="0",this.container.style.width="100%",this.container.style.height="100%",this.container.style.zIndex="999"}setupEventListeners(){const t=this.container.querySelector(".dialog-close");null==t||t.addEventListener("click",(()=>this.hide())),this.options.closeOnEscape&&(this.keydownHandler=t=>{"Escape"===t.key&&this.isVisible()&&(t.preventDefault(),this.hide())},this.chartContext.addEventListener("keydown",this.keydownHandler)),this.options.closeOnClickOutside&&this.overlay&&(this.clickOutsideHandler=t=>{t.target===this.overlay&&this.hide()},this.overlay.addEventListener("click",this.clickOutsideHandler)),this.container.addEventListener("keydown",(t=>{"Tab"===t.key&&this.isVisible()&&this.trapFocus(t)}))}trapFocus(t){const e=this.container.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=e[0],i=e[e.length-1],o=this.chartContext.getActiveElement();t.shiftKey?o===n&&(t.preventDefault(),null==i||i.focus()):o===i&&(t.preventDefault(),null==n||n.focus())}updateDialogContent(t){const e=t.querySelector(".dialog-content"),n=t.querySelector(".dialog-title");n&&(n.textContent=this.options.title||""),e&&(e.innerHTML="","string"==typeof this.options.content?e.innerHTML=this.options.content:this.options.content instanceof HTMLElement&&e.appendChild(this.options.content))}cleanupEventListeners(){this.keydownHandler&&(this.chartContext.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.clickOutsideHandler&&this.overlay&&(this.overlay.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}destroy(){this.cleanupEventListeners(),this.container.remove()}hide(){this.container.classList.remove("show","animate");const t=this.chartContext.querySelector("[data-dialog-trigger]");null==t||t.focus()}isVisible(){return this.container.classList.contains("show")}setContent(t){const e=this.container.querySelector(".dialog-content");e&&(e.innerHTML="","string"==typeof t?e.innerHTML=t:e.appendChild(t))}show(){const t=this.chartContext.getActiveElement();null==t||t.setAttribute("data-dialog-trigger","true"),this.container.classList.add("show","animate");const e=this.container.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');null==e||e.focus()}}class Z{constructor(t,e,n,i,o,r="MM-DD-YYYY"){this.chartContext=t,this.dataManager=e,this.task=n,this.containerElement=i,this.onSubmit=o,this.dateFormat=r,this.errors=[],this.submitButton=null,this.form=this.createForm()}emitEvent(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:!1});this.containerElement.dispatchEvent(n)}clearError(t){var e;const n=this.form.querySelector(`[name="${t}"]`),i=null==(e=n.parentElement)?void 0:e.querySelector(".form-error");null==i||i.remove(),n.classList.remove("invalid"),this.errors=this.errors.filter((e=>e.field!==t)),this.updateSubmitButton()}createForm(){const t=this.chartContext.createElement("form");t.className="task-form";const e=this.task.barBackgroundColor||"#87B7FE",n=this.task.rowBackgroundColor||"#FFFFFF";return t.innerHTML=`\n <div class="form-group">\n <label for="name">Task Name</label>\n <input type="text" id="name" name="name" value="${this.task.name}">\n </div>\n \n <div class="form-group">\n <label for="startTime">Start Date</label>\n <input type="date" id="startTime" name="startTime" value="${this.formatDate(this.task.startTime)}">\n </div>\n \n <div class="form-group">\n <label for="endTime">End Date</label>\n <input type="date" id="endTime" name="endTime" value="${this.formatDate(this.task.endTime)}">\n </div>\n \n <div class="form-group">\n <label for="progress">Progress (%)</label>\n <input type="number" id="progress" name="progress" min="0" max="100" value="${this.task.progress}">\n </div>\n\n <div class="grid">\n <div class="form-group">\n <label for="barColor">Bar Color</label>\n <div class="color-picker-wrapper">\n <input type="color" id="barColor" name="barBackgroundColor" \n value="${e}"\n title="Choose bar color">\n <span class="color-preview"></span>\n </div>\n </div>\n \n <div class="form-group">\n <label for="rowColor">Row Background Color</label>\n <div class="color-picker-wrapper">\n <input type="color" id="rowColor" name="rowBackgroundColor" \n value="${n}"\n title="Choose row color">\n <span class="color-preview"></span>\n </div>\n </div>\n </div>\n \n <div class="form-actions">\n <button type="submit" class="btn-primary">Update</button>\n </div>\n `,t.addEventListener("submit",this.handleSubmit.bind(this)),this.setupFieldValidation(t),t}formatDate(t){return w(t,this.dateFormat).format("YYYY-MM-DD")}handleSubmit(t){if(t.preventDefault(),this.errors.length>0)this.emitEvent(K.TASK_VALIDATION_ERROR,{taskId:this.task.id,errors:this.errors,timestamp:Date.now()});else try{const t=new FormData(this.form),e={...this.task,barBackgroundColor:t.get("barBackgroundColor"),endTime:w(t.get("endTime")).format(this.dateFormat),name:t.get("name"),progress:Number(t.get("progress")),rowBackgroundColor:t.get("rowBackgroundColor"),startTime:w(t.get("startTime")).format(this.dateFormat)},n=this.dataManager.getTaskById(this.task.id)??this.task;this.emitEvent(K.TASK_UPDATE,{taskId:this.task.id,updates:e,updatedTask:{...n,...e},timestamp:Date.now()}),this.onSubmit(e),this.emitEvent(K.TASK_UPDATE_SUCCESS,{taskId:this.task.id,updatedTask:{...n,...e},timestamp:Date.now()})}catch(t){R.warn(`[TaskForm] Error updating task ${this.task.id}:`,t),this.emitEvent(K.TASK_UPDATE_ERROR,{taskId:this.task.id,error:t instanceof Error?t:new Error(String(t)),timestamp:Date.now()})}}setupFieldValidation(t){const e=t.querySelector('[name="name"]'),n=t.querySelector('[name="startTime"]'),i=t.querySelector('[name="endTime"]'),o=t.querySelector('[name="progress"]');null==e||e.addEventListener("change",(()=>{const t=this.validateName(e.value);t?this.showError("name",t):this.clearError("name")}));const r=()=>{const{endError:t,startError:e}=this.validateDates(n.value,i.value);e?this.showError("startTime",e):this.clearError("startTime"),t?this.showError("endTime",t):this.clearError("endTime")};null==n||n.addEventListener("change",r),null==i||i.addEventListener("change",r),null==o||o.addEventListener("change",(()=>{const t=this.validateProgress(Number(o.value));t?this.showError("progress",t):this.clearError("progress")}))}showError(t,e){var n,i;const o=this.form.querySelector(`[name="${t}"]`),r=this.chartContext.createElement("div");r.className="form-error",r.textContent=e;const a=null==(n=o.parentElement)?void 0:n.querySelector(".form-error");null==a||a.remove(),null==(i=o.parentElement)||i.appendChild(r),o.classList.add("invalid"),this.errors.push({field:t,message:e}),this.updateSubmitButton()}updateSubmitButton(){if(this.submitButton||(this.submitButton=this.form.querySelector(".btn-primary")),this.submitButton){const t=this.errors.length>0;this.submitButton.disabled=t,this.submitButton.classList.toggle("btn-disabled",t)}}validateDates(t,e){const n={endError:null,startError:null},i=w(t),o=w(e);return t||(n.startError="Start date is required"),e||(n.endError="End date is required"),i.isValid()&&o.isValid()&&o.isBefore(i)&&(n.endError="End date must be after start date"),n}validateName(t){return t.trim()?null:"Task name is required"}validateProgress(t){return t||0===t?isNaN(t)||t<0||t>100?"Progress must be between 0 and 100":null:"Progress is required"}getElement(){return this.form}}class J{constructor(t,e,n,i,o,r,a){this.task=t,this.ganttStartDate=e,this.options=n,this.viewMode=i,this.index=o,this.chartContext=r,this.dataManager=a,this.tooltipHandler=null}static calculateWidth(t,e,n){const{barMargin:i,rowHeight:o}=n;if(t.type===ct.Milestone)return(o-i)/2;const r=w(t.startTime);return w(t.endTime).add(1,"days").diff(r,`${e}s`,!0)*N[e]}static calculateX(t,e,n,i){const o=w(t.startTime).diff(e.startOf(n),`${n}s`,!0)*N[n];let r=0;if(t.type===ct.Milestone){const{barMargin:t,rowHeight:e}=i;r=(e-t)/4*-1}return o+r}hasBaseline(){var t;return!(!(null==(t=this.options.baseline)?void 0:t.enabled)||!this.task.baseline)}calculateHeight(){const{barMargin:t,rowHeight:e}=this.options;return this.task.type===ct.Milestone?(e-t)/2:this.hasBaseline()?e-2*t-6-2:e-2*t}setupTooltip(t){if(!this.options.enableTooltip)return;const{tooltipBGColor:e,tooltipBorderColor:n,fontColor:i,fontFamily:o,fontSize:r,fontWeight:a,tooltipId:s,tooltipTemplate:l,inputDateFormat:c}=this.options;let d=!1,h=null;const p=t=>{d=!0,h&&(clearTimeout(h),h=null);const{x:p,y:g}=((t,e,n=300,i=120,o=20,r=20)=>{const a=window.innerWidth,s=window.innerHeight,l=window.scrollX||document.documentElement.scrollLeft,c=window.scrollY||document.documentElement.scrollTop;let d=t+o+l,h=e+r+c;return t+o+n>a&&(d=t-n-o+l),e+r+i>s&&(h=e-i-r+c),d=Math.max(l+5,d),h=Math.max(c+5,h),{x:d,y:h}})(t.clientX,t.clientY,300,120,5,10);if(!l)return;const m=this.dataManager.getTaskById(this.task.id);if(!m)return;const b=l(m,c),f=(({bgColor:t,borderColor:e,fontColor:n,fontFamily:i,fontSize:o,fontWeight:r,maxWidth:a,padding:s,x:l,y:c})=>{const d=["position: absolute;","z-index: 1000;","pointer-events: none;"];return d.push("box-sizing: border-box;"),d.push("word-wrap: break-word;"),d.push("overflow-wrap: break-word;"),d.push(`left: ${l}px;`),d.push(`top: ${c}px;`),e&&d.push(`border: 1px solid ${e};`),a&&(d.push(`width: ${a}px;`),d.push(`max-width: ${a}px;`)),d.push("border-radius: 6px;"),d.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);"),d.push("transition: opacity 0.2s ease;"),d.push(`color: ${n||"#000000"};`),d.push(`font-family: ${i||"sans-serif"};`),d.push(`font-weight: ${r||"400"};`),d.push(`font-size: ${o||"14px"};`),d.push(`background-color: ${t||"#FFFFFF"};`),void 0!==s&&d.push(`padding: ${s}px;`),d.join(" ")})({bgColor:e,borderColor:n,fontColor:i,fontFamily:o,fontSize:r,fontWeight:a,maxWidth:300,padding:0,x:p,y:g});u(this.chartContext,s,f,b)};t.addEventListener("mouseenter",p),t.addEventListener("mousemove",p),t.addEventListener("mouseleave",(()=>{d=!1,h=window.setTimeout((()=>{d||u(this.chartContext,s)}),100)}))}setupTaskEdit(t,e){if(!this.options.enableTaskEdit)return;const n=this.chartContext.getInstanceId();t.addEventListener("dblclick",(t=>{t.stopPropagation(),t.preventDefault();const i=this.dataManager.getTaskById(this.task.id);if(!i)return void R.error(`[${n}] Task not found in dataManager: ${this.task.id}`);const o=this.chartContext.getChartContainer();if(!o)return;const r=new Z(this.chartContext,this.dataManager,i,o,(t=>{null==e||e(i.id,t),s.hide()}),this.options.inputDateFormat),a=`taskDialog-${n}-${this.task.id}`,s=new Q(this.chartContext,{closeOnClickOutside:!1,closeOnEscape:!0,content:r.getElement(),id:a,modal:!0,title:`Edit Task: ${this.task.name}`,width:"400px",positionRelativeToChart:!0});s.show()}))}setupInteractions(t,e){const{enableTaskDrag:n,enableTaskResize:i}=this.options;if(n&&this.makeDraggable(t,e),i&&this.task.type===ct.Task){const n=m(this.chartContext,{className:"bar-handle handle-left"}),i=m(this.chartContext,{className:"bar-handle handle-right"});t.append(n,i),this.makeResizable(t,e)}}drawBar(e=t){const{barBackgroundColor:n,barBorderRadius:i}=this.options,o=m(this.chartContext,{className:"bar-timeline"}),r=m(this.chartContext,{className:"bar-label",content:this.task.name}),a=m(this.chartContext,{className:"bar-timeline-progress"}),s=this.task.barBackgroundColor||n,l=g(this.getBarStyles(s)),c=g({backgroundColor:f(s,-40),borderRadius:i,width:`${this.task.progress}%`}),d=this.chartContext.getInstanceId();o.setAttribute("data-taskid",this.task.id),o.setAttribute("data-chart-instance",d),a.setAttribute("style",c),o.setAttribute("style",l);const h=w(this.task.startTime),p=w(this.task.endTime),u=h.format("MMMM D, YYYY"),b=p.format("MMMM D, YYYY"),y=h.valueOf(),v=p.valueOf(),x=p.diff(h,"day"),{enableTaskDrag:k,enableTaskResize:C}=this.options;return k||C&&this.task.type===ct.Task?(o.setAttribute("role","slider"),o.setAttribute("aria-label",`${this.task.name}: ${u} to ${b}`),o.setAttribute("aria-valuenow",y.toString()),o.setAttribute("aria-valuemin",y.toString()),o.setAttribute("aria-valuemax",v.toString()),o.setAttribute("aria-valuetext",`${u} to ${b}, ${x} days`),o.setAttribute("aria-grabbed","false"),k&&o.setAttribute("aria-dropeffect","move")):(o.setAttribute("role","progressbar"),o.setAttribute("aria-label",`${this.task.name}: ${u} to ${b}, ${this.task.progress}% complete`),o.setAttribute("aria-valuenow",this.task.progress.toString()),o.setAttribute("aria-valuemin","0"),o.setAttribute("aria-valuemax","100")),o.setAttribute("tabindex","0"),this.task.type!==ct.Milestone&&o.append(r),o.append(a),this.setupTaskEdit(o,e),this.setupTooltip(o),this.setupInteractions(o,e),o.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0})))})),o}drawBaselineBar(){if(!this.hasBaseline())return null;const{barBorderRadius:t,barMargin:e,rowHeight:n}=this.options,i=this.options.baseline.color,o=this.task.baseline,r={...this.task,startTime:o.start,endTime:o.end,type:ct.Task},a=J.calculateX(r,this.ganttStartDate,this.viewMode,this.options),s=J.calculateWidth(r,this.viewMode,this.options),l=e+this.calculateHeight()+2+this.index*n,c=m(this.chartContext,{className:"bar-baseline"});c.setAttribute("aria-hidden","true"),c.setAttribute("data-taskid-baseline",this.task.id);const d=g({backgroundColor:i,borderRadius:t,height:"6px",left:`${a}px`,pointerEvents:"none",top:`${l}px`,width:`${s}px`});return c.setAttribute("style",d),c}getBarStyles(t){const{barBackgroundColor:e,barBorderRadius:n,barMargin:i,barTextColor:o,rowHeight:r}=this.options,a=J.calculateX(this.task,this.ganttStartDate,this.viewMode,this.options),s=J.calculateWidth(this.task,this.viewMode,this.options),l=this.calculateHeight(),c=t||e;return this.task.type===ct.Milestone?{backgroundColor:f(c,-40),borderRadius:"2px",color:o,height:`${l}px`,left:`${a}px`,top:r/3-i/2+this.index*r+"px",transform:"rotate(45deg)",width:`${s}px`}:{backgroundColor:c,borderRadius:n,color:o,height:`${l}px`,left:`${a}px`,top:`${i+this.index*r}px`,width:`${s}px`}}makeDraggable(t,e){new X(this.task.id,this.options,this.viewMode,this.chartContext,this.dataManager).makeDraggable(t,e)}makeResizable(t,e){new G(this.task.id,this.options,this.viewMode,this.chartContext,this.dataManager).makeResizable(t,e)}cleanup(){this.tooltipHandler&&(this.tooltipHandler.cleanup(),this.tooltipHandler=null)}}var tt=(t=>(t.Duration="duration",t.EndTime="endTime",t.Name="name",t.Progress="progress",t.StartTime="startTime",t))(tt||{});const et={duration:"Duration",endTime:"End",name:"Task Name",progress:"Progress",startTime:"Start"},nt=[{key:"name",title:et.name,minWidth:"120px",flexGrow:3},{key:"startTime",title:et.startTime,minWidth:"70px",flexGrow:1.5},{key:"duration",title:et.duration,minWidth:"50px",flexGrow:1},{key:"progress",title:et.progress,minWidth:"50px",flexGrow:1}];function it(t,e,n){const i=t[e];if("startTime"===e)return w(i,n).format(n);if("endTime"===e)return w(i,n).format(n);if("duration"===e){const e=w(t.startTime,n),i=w(t.endTime,n);return t.endTime?`${i.diff(e,"d")+1} d`:"0 d"}if("progress"===e){return`${t.progress??0}%`}return i}function ot(t,e){const n=t.getInstanceId(),i=`.tasks-container .tasks-data-row[data-taskid="${e}"][data-chart-instance="${n}"]`,o=t.querySelector(i);return o||R.warn(`[${n}] Task row element not found for task: ${e}`),o}function rt(t,e){return(null==e?void 0:e.length)?e[t%e.length]:"transparent"}function at(t,e,n){const i=ot(t,e),o=z(t,e);i&&(i.style.backgroundColor=n),o&&(o.style.backgroundColor=n)}const st=(t,e,n,i,o,r,a)=>{const{taskBar:s,taskBarRow:l,taskRow:c}=((t,e)=>{const n=ot(t,e);return{taskBar:H(t,e),taskBarRow:z(t,e),taskRow:n}})(t,n);if(!c||!s)return;const d=e.updateTask(n,i);if(!d)return;if(c.querySelectorAll(".tasks-data-cell").forEach((i=>{const r=i.getAttribute("data-columnid");if(r&&(i.innerHTML=it(d,r,o.inputDateFormat),"name"===r))if(e.hasChildren(n)){const o=t.createElement("span");o.className="task-toggle-icon "+(d.collapsed?"collapsed":"expanded"),o.addEventListener("click",(()=>{e.toggleTask(n)})),i.prepend(o)}else{const e=t.createElement("span");e.className="task-toggle-icon-blank",i.prepend(e)}})),i.rowBackgroundColor&&l&&(c.style.backgroundColor=i.rowBackgroundColor,l.style.backgroundColor=i.rowBackgroundColor),i.barBackgroundColor&&(s.style.backgroundColor=i.barBackgroundColor),i.startTime||i.endTime){const t=J.calculateX(d,a,r,o),e=J.calculateWidth(d,r,o);s.style.left=`${t}px`,s.style.width=`${e}px`}if(void 0!==i.progress){const t=s.querySelector(".bar-timeline-progress");t&&(t.style.width=`${i.progress}%`),i.barBackgroundColor&&(t.style.backgroundColor=f(i.barBackgroundColor,-40))}if(i.name){const t=s.querySelector(".bar-label");t&&(t.textContent=i.name)}e.updateDependencyArrows(n,t)},lt="data-chart-instance";var ct=(t=>(t.Milestone="milestone",t.Task="task",t))(ct||{});function dt(t){return"string"==typeof t?{taskId:t,type:"FS",lag:0}:{taskId:t.taskId,type:t.type??"FS",lag:t.lag??0}}class ht{constructor(t,e,n,i){this.options=t,this.chartContext=e,this.dataManager=n,this.selectionManager=i,this.selectionEnabled=t.enableSelection,this.showCheckbox=t.enableSelection&&t.showCheckboxColumn,this.effectiveColumnList=this.mergeColumnConfig(),this.injectDynamicColumnStyles()}mergeColumnConfig(){if(!this.options.columnConfig||0===this.options.columnConfig.length)return nt;const t=this.options.columnConfig.map((t=>{const e=nt.find((e=>e.key===t.key));return e?{...e,...t}:t})).filter((t=>!1!==t.visible));return 0===t.length?(R.warn("columnConfig resulted in zero visible columns — falling back to defaults"),nt):t}injectDynamicColumnStyles(){const t=this.effectiveColumnList.map((t=>`minmax(${t.minWidth||"30px"}, ${t.flexGrow||1}fr)`)).join(" ");const e=this.showCheckbox?"28px ":"",n=this.chartContext.getInstanceId(),i=`\n .tasks-container .tasks-header[data-chart-instance="${n}"] .tasks-header-row {\n grid-template-columns: ${e}${t};\n }\n\n .tasks-container .tasks-data-row[data-chart-instance="${n}"] {\n grid-template-columns: ${e}${t};\n }\n `;this.chartContext.injectStyles(i,`tasks-dynamic-columns-${n}`,{priority:"high",force:!0})}generateBody(t,e,n){const i=m(this.chartContext,{className:"tasks-data-container"}),o=n?n.allTasks:t;return i.setAttribute("role","treegrid"),i.setAttribute("aria-label",this.options.taskListAriaLabel??"Gantt task list"),i.setAttribute("aria-rowcount",o.length.toString()),n?this.generateRowsVirtualized(o,i,e,n.range,n.rowHeight):this.generateRows(t,i,e),i}generateHeader(t){const e=m(this.chartContext,{className:"tasks-header"}),n=m(this.chartContext,{className:"tasks-header-row"}),{rowHeight:i}=this.options,o=this.chartContext.getInstanceId();if(e.setAttribute(lt,o),this.showCheckbox){const t=m(this.chartContext,{className:"tasks-header-cell gantt-checkbox-cell"});t.style.height=2*i+"px";const e=this.chartContext.createElement("input");e.type="checkbox",e.className="gantt-select-all-checkbox",e.setAttribute("aria-label","Select all tasks"),e.addEventListener("change",(()=>{this.selectionManager&&(e.checked?this.selectionManager.selectAll():this.selectionManager.clearSelection())})),t.append(e),n.append(t)}return t.forEach((t=>{const e=m(this.chartContext,{className:"tasks-header-cell",content:t});e.style.height=2*i+"px",e.style.color="var(--text-color)",n.append(e)})),e.append(n),e.style.background="var(--header-bg-color)",e}generateRow(t,e,n){var i;const o=m(this.chartContext,{className:"tasks-data-row"}),{rowHeight:r}=this.options,a=this.chartContext.getInstanceId();if(o.setAttribute("data-taskid",t.id),o.setAttribute(lt,a),o.style.height=`${r}px`,o.setAttribute("role","row"),o.setAttribute("aria-rowindex",n.toString()),o.setAttribute("aria-level",(t.level??1).toString()),o.setAttribute("aria-selected","false"),o.setAttribute("tabindex",1===n?"0":"-1"),this.dataManager.hasChildren(t.id)&&o.setAttribute("aria-expanded",t.collapsed?"false":"true"),this.showCheckbox){const e=m(this.chartContext,{className:"tasks-data-cell gantt-checkbox-cell"});e.style.height=`${r}px`;const n=this.chartContext.createElement("input");n.type="checkbox",n.className="gantt-selection-checkbox",n.checked=(null==(i=this.selectionManager)?void 0:i.isSelected(t.id))??!1,n.setAttribute("aria-label",`Select ${t.name}`),n.addEventListener("click",(e=>{e.stopPropagation(),this.selectionManager&&this.selectionManager.handleClick(t.id,{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey})})),e.append(n),o.append(e)}if(this.selectionEnabled&&this.selectionManager){const e=this.selectionManager;o.addEventListener("click",(n=>{n.target.classList.contains("gantt-selection-checkbox")||n.target.classList.contains("task-toggle-icon")||(e.handleClick(t.id,{ctrlKey:n.ctrlKey,metaKey:n.metaKey,shiftKey:n.shiftKey}),o.focus())})),o.style.cursor="pointer"}let s=1;return this.effectiveColumnList.forEach((({key:n})=>{const i=m(this.chartContext,{className:"tasks-data-cell",content:it(t,n,this.options.inputDateFormat)});if(i.setAttribute("data-columnid",n),i.setAttribute(lt,a),i.style.height=`${r}px`,i.style.color="var(--text-color)",i.setAttribute("role","gridcell"),i.setAttribute("aria-colindex",s.toString()),i.setAttribute("aria-readonly","true"),s++,n===tt.Name){if(i.style.paddingLeft=15*(t.level??0)+"px",i.style.textAlign="left",i.innerHTML="",this.dataManager.hasChildren(t.id)){const n=b(this.chartContext,"span",{className:"task-toggle-icon "+(t.collapsed?"collapsed":"expanded")});n.addEventListener("click",(()=>{this.dataManager.toggleTask(t.id),e()})),i.append(n)}else{const t=b(this.chartContext,"span",{className:"task-toggle-icon-blank"});i.append(t)}const n=b(this.chartContext,"span",{textContent:t.name});i.append(n)}o.append(i)})),o}generateRows(t,e,n){return t.forEach(((t,i)=>{const o=this.generateRow(t,n,i+1);e.appendChild(o)})),this.fillEmptyRows(e,t.length,n),e}generateRowsVirtualized(t,e,n,i,o){const{startIndex:r,endIndex:a}=i,s=t.length,l=this.chartContext.createElement("div");l.className="virtualizer-top-spacer",l.style.height=r*o+"px",e.appendChild(l);t.slice(r,a+1).forEach(((t,i)=>{const o=r+i,a=this.generateRow(t,n,o+1);e.appendChild(a)}));const c=Math.max(0,(s-1-a)*o),d=this.chartContext.createElement("div");return d.className="virtualizer-bottom-spacer",d.style.height=`${c}px`,e.appendChild(d),e}fillEmptyRows(t,e,n){const i=this.chartContext.querySelector(".gantt-container");if(!i)return;const o=i.clientHeight,r=this.options.rowHeight,a=o-2*r,s=Math.floor(a/r),l=Math.max(0,s-e);for(let e=0;e<l;e++){const n=this.generateEmptyRow(e);t.appendChild(n)}}generateEmptyRow(t){const e=m(this.chartContext,{className:"tasks-data-row tasks-empty-row"}),{rowHeight:n}=this.options,i=this.chartContext.getInstanceId();return e.setAttribute("data-taskid",`empty-${t}`),e.setAttribute(lt,i),e.style.height=`${n}px`,this.effectiveColumnList.forEach((({key:t})=>{const o=m(this.chartContext,{className:"tasks-data-cell",content:""});o.setAttribute("data-columnid",t),o.setAttribute(lt,i),o.style.height=`${n}px`,o.style.color="var(--text-color)",e.append(o)})),e}render(t,e){const n=this.generateHeader(this.effectiveColumnList.map((t=>t.title))),i=e?e.allTasks.slice(e.range.startIndex,e.range.endIndex+1):this.dataManager.getFlatVisibleTasks();return[n,this.generateBody(i,t,e)]}}const pt="root";class ut{constructor(t=[]){this.dependencies=[],this.taskMap={},this.taskTree={},this.arrowLinkInstanceId=null,this.setTasks(t)}buildTaskTree(t){const e={[pt]:[]};t.forEach((t=>{var n;if(this.taskMap[t.id]=t,e[t.id]||(e[t.id]=[]),void 0===t.parentId||e[t.parentId]||(e[t.parentId]=[]),t.dependency){const{taskId:e,type:n,lag:i}=dt(t.dependency);this.addDependency(e,t.id,n,i)}t.parentId?null==(n=e[t.parentId])||n.push(t.id):e[pt].push(t.id)})),this.taskTree=e}processLevel(){const t=(e,n)=>{e.forEach((e=>{this.taskMap[e.id]={...e,level:n};const i=this.taskTree[e.id].map((t=>this.taskMap[t]));Array.isArray(i)&&t(i,n+1)}))};t(this.getTasks().filter((t=>!t.parentId)),1)}sortTasksByDate(t){const e=(e,n)=>new Date(e[t]).getTime()-new Date(n[t]).getTime(),n=(t,i)=>{t.sort(e),i&&(this.taskTree[i]=t.map((t=>t.id))),t.forEach((t=>{const e=this.taskTree[t.id].map((t=>this.getTaskById(t))).filter((t=>null!==t));e&&e.length>0&&n(e,t.id)}))},i=this.taskTree[pt].map((t=>this.getTaskById(t))).filter((t=>null!==t));n(i,pt)}validateTask(t){if("milestone"===t.type){if(!t.id||!t.startTime)throw new Error("Milestone must have an id and start date")}else if(!t.id||!t.startTime||!t.endTime)throw new Error("Task must have an id, start, and end date");return{...t,endTime:t.endTime||t.startTime,progress:t.progress??0,type:t.type??ct.Task,level:1}}addDependency(t,e,n="FS",i=0){this.dependencies.push({fromId:t,toId:e,type:n,lag:i})}addTask(t){const e=this.validateTask(t);this.taskMap[e.id]=e,this.buildTaskTree(this.getTasks())}calculateProgress(){const t=this.getTasks(),e=t.reduce(((t,e)=>t+w(e.endTime).diff(w(e.startTime),"day")),0),n=t.reduce(((t,e)=>t+e.progress/100*w(e.endTime).diff(w(e.startTime),"day")),0);return e?n/e*100:0}getDateRange(t=0,e){const n=this.getTasks();if(0===n.length){const n=w().startOf(e);let i=1;switch(e){case"day":i=30;break;case"week":case"month":default:i=12;break;case"quarter":i=4;break;case"year":i=5}const o=n.add(i+t,e);return[n,o]}const i=n.map((t=>w(t.startTime))),o=n.filter((t=>!!t.endTime)).map((t=>w(t.endTime)));return[w.min(i),w.max(o).add(t,e)]}getFlatSortedTasks(t,e=!1){let n=[];return t.forEach((t=>{n.push(t);const i=this.taskTree[t.id].map((t=>this.taskMap[t]));!e&&t.collapsed||!Array.isArray(i)||(n=n.concat(this.getFlatSortedTasks(i,e)))})),n}getFlatTasks(){return this.getFlatSortedTasks(this.taskTree[pt].map((t=>this.getTaskById(t))).filter((t=>null!==t)),!0)}getFlatVisibleTasks(){return this.getFlatSortedTasks(this.taskTree[pt].map((t=>this.getTaskById(t))).filter((t=>null!==t)))}getNestedChildTasks(t,e=!1){const n=[],i=t=>{var o;if(e&&(null==(o=this.taskMap[t])?void 0:o.collapsed))return;(this.taskTree[t]||[]).forEach((t=>{const e=this.taskMap[t];e&&(n.push(e),i(t))}))};return i(t),n}getTaskById(t){return this.taskMap[t]}getTaskDependencies(t){return{incoming:this.dependencies.filter((e=>e.toId===t)),outgoing:this.dependencies.filter((e=>e.fromId===t))}}getTasks(){return Object.values(this.taskMap)}getTopParentTasks(){return Object.values(this.taskMap).filter((t=>void 0===t.parentId&&t.type===ct.Task))}hasChildren(t){return this.taskTree[t].length>0}removeDependency(t,e){this.dependencies=this.dependencies.filter((n=>!(n.fromId===t&&n.toId===e)))}removeTask(t){delete this.taskMap[t],this.buildTaskTree(Object.values(this.taskMap))}setTasks(t){if(!Array.isArray(t))throw new Error("Tasks must be an array");const e=t.map((t=>this.validateTask(t)));this.taskMap={},this.dependencies=[],this.buildTaskTree(e),this.sortTasksByDate("startTime"),this.processLevel()}toggleTask(t){const e=this.getTaskById(t);e&&(this.taskMap[t]={...e,collapsed:!e.collapsed})}setArrowLinkInstanceId(t){this.arrowLinkInstanceId=t}updateDependencyArrows(t,e){const n=this.getTaskDependencies(t);[...n.incoming,...n.outgoing].forEach((t=>{const n=this.getTaskById(t.fromId),i=this.getTaskById(t.toId);if(n&&i){const n=(null==e?void 0:e.getInstanceId())||"unknown",i={fromId:t.fromId,toId:t.toId,type:t.type,lag:t.lag,chartInstanceId:n,arrowLinkInstanceId:this.arrowLinkInstanceId??void 0},o=new CustomEvent("dependencyArrowUpdate",{detail:i,bubbles:!1,cancelable:!1});e?e.dispatchEvent(o):(R.warn(`[${n}] No chartContext provided for dependency arrow update`),document.dispatchEvent(o))}}))}getAllDependencies(){return this.dependencies}updateTask(t,e){const n=this.taskMap[t];if(!n)throw new Error(`Task with id "${t}" not found`);const i=this.validateTask({...n,...e});return this.taskMap[t]=i,this.buildTaskTree(this.getTasks()),i}}const gt="MMMM, YYYY",mt={1:["Jan","Feb","Mar"],2:["Apr","May","Jun"],3:["Jul","Aug","Sep"],4:["Oct","Nov","Dec"]};function bt(t,e,n){const i=[];let o=t.startOf(n);const r=e.startOf(n);for(;o.isSameOrBefore(r);)i.push(o),o=o.add(1,`${n}s`);return i}function ft(t,e){return bt(t,e,P.Month)}function yt(t,e){return bt(t,e,P.Year)}function vt(t,e,n){const i=function(t,e){return bt(t,e,P.Day)}(t,e),o=ft(t,e),r=i.map((t=>t.format("DD MMM")));return[o.map(((i,r)=>0===r?{data:i.format("MMM YYYY"),width:(i.daysInMonth()-t.date()+1)*n}:r===o.length-1?{data:i.format("MMM YYYY"),width:(i.daysInMonth()-(i.daysInMonth()-e.date()))*n}:{data:i.format("MMM YYYY"),width:i.daysInMonth()*n})),r]}function wt(t,e,n){const i=function(t,e){return bt(t,e,P.Week)}(t,e),o=ft(t,e),r=i.map((t=>`#${t.week()}, ${t.day(0).format("DD MMM")} - ${t.day(6).format("DD MMM")}`));return[o.map(((i,r)=>{if(0===r){const e=i.endOf("month").date()-t.date()+1;return{data:i.format(gt),width:(e<7?7:e)/7*n}}if(r===o.length-1){const t=e.date()-i.startOf("month").date()+1;return{data:i.format(gt),width:(t<7?7:t)/7*n}}const a=i.endOf("month").date()-i.startOf("month").date()+1;return{data:i.format(gt),width:(a<7?7:a)/7*n}})),r]}function xt(t,e,n){const i=function(t,e){const n=[];let i=t.startOf(P.Quarter);const o=e.startOf(P.Quarter);for(;i.isSameOrBefore(o);)n.push(i),i=i.add(1,`${P.Quarter}s`);return n}(t,e),o=yt(t,e),r=i.map((t=>{const e=mt[t.quarter()];return`#${t.quarter()} ${e[0]}-${e[2]}`}));return[o.map(((i,r)=>0===r?{data:i.format("YYYY"),width:(5-t.quarter())*n}:r===o.length-1?{data:i.format("YYYY"),width:e.quarter()*n}:{data:i.format("YYYY"),width:4*n})),r]}function kt(t){return t.classList.contains("gantt-reduced-motion")}function Ct(t,e,n){if(kt(n))return;if("function"!=typeof t.animate)return;const i=Math.min(30*e,500);t.animate([{transformOrigin:"top",transform:"translateY(-8px) scaleY(0)"},{transformOrigin:"top",transform:"translateY(0) scaleY(1)"}],{duration:200,easing:"ease-out",delay:i,fill:"backwards"})}const St="data-chart-instance";class Et{constructor(t,e,n,i){this.viewMode=t,this.options=e,this.chartContext=n,this.dataManager=i}generateHeader(t,e){const n=m(this.chartContext,{className:"timeline-header"}),i=m(this.chartContext,{className:"timeline-header-row"}),{rowHeight:o}=this.options,r=this.chartContext.getInstanceId();if(n.setAttribute(St,r),n.setAttribute("tabindex","0"),n.setAttribute("aria-label","Timeline header"),t.forEach((t=>{const n=m(this.chartContext,{className:"timeline-header-cell",content:t.data,style:{height:e?`${o}px`:2*o+"px",minWidth:`${t.width}px`||"100%",color:"var(--text-color)"}});i.append(n)})),n.append(i),!e)return n.style.background="var(--header-bg-color)",n;const a=m(this.chartContext,{className:"timeline-header-row"});return e.forEach((t=>{const e=m(this.chartContext,{className:"timeline-header-cell",content:t,style:{height:`${o}px`,maxWidth:`${N[this.viewMode]}px`,minWidth:`${N[this.viewMode]}px`,color:"var(--text-color)"}});a.append(e)})),n.append(a),n.style.background="var(--header-bg-color)",n}generateRow(t,e){const n=m(this.chartContext,{className:"timeline-data-row"}),{rowHeight:i}=this.options,o=this.chartContext.getInstanceId();n.setAttribute("data-taskid",t),n.setAttribute(St,o);for(let t=0;t<e;t++){const t=m(this.chartContext,{className:"timeline-data-cell",style:{height:`${i}px`,minWidth:`${N[this.viewMode]}px`}});t.setAttribute(St,o),n.append(t)}return n}generateRows(t,e){const n=m(this.chartContext,{className:"timeline-body"}),i=this.chartContext.getInstanceId();return n.setAttribute(St,i),t.forEach((t=>{const i=this.generateRow(t.id,e);n.append(i)})),this.fillEmptyRows(n,t.length,e),n}generateRowsVirtualized(t,e,n,i){const o=m(this.chartContext,{className:"timeline-body"}),r=this.chartContext.getInstanceId();o.setAttribute(St,r);const{startIndex:a,endIndex:s}=n,l=t.length,c=this.chartContext.createElement("div");c.className="virtualizer-top-spacer",c.style.height=a*i+"px",o.appendChild(c);t.slice(a,s+1).forEach((t=>{const n=this.generateRow(t.id,e);o.append(n)}));const d=Math.max(0,(l-1-s)*i),h=this.chartContext.createElement("div");return h.className="virtualizer-bottom-spacer",h.style.height=`${d}px`,o.appendChild(h),o}fillEmptyRows(t,e,n){const i=this.chartContext.querySelector(".gantt-container");if(!i)return;const o=i.clientHeight,r=this.options.rowHeight,a=o-2*r,s=Math.floor(a/r),l=Math.max(0,s-e);for(let e=0;e<l;e++){const i=this.generateRow(`empty-${e}`,n);i.classList.add("timeline-empty-row"),t.append(i)}}getHeaderData(t,e,n){return n===P.Day?vt(t,e,N[this.viewMode]):n===P.Week?wt(t,e,N[this.viewMode]):n===P.Month?function(t,e,n){const i=ft(t,e),o=yt(t,e),r=i.map((t=>t.format("MMMM")));return[o.map(((i,r)=>0===r?{data:i.format("YYYY"),width:(12-t.month())*n}:r===o.length-1?{data:i.format("YYYY"),width:(e.month()+1)*n}:{data:i.format("YYYY"),width:12*n})),r]}(t,e,N[this.viewMode]):n===P.Quarter?xt(t,e,N[this.viewMode]):n===P.Year?function(t,e,n){return[yt(t,e).map((t=>({data:t.format("YYYY"),width:n}))),null]}(t,e,N[this.viewMode]):null}render(t,e=new Set){const n=t?t.allTasks:this.dataManager.getFlatVisibleTasks(),i=this.dataManager.getDateRange(8,this.viewMode),o=this.getHeaderData(i[0],i[1],this.viewMode);if(!o)return null;const[r,a]=o,s=this.generateHeader(r,a),l=(a||r).length;let c;c=t?this.generateRowsVirtualized(n,l,t.range,t.rowHeight):this.generateRows(n,l);const d=m(this.chartContext,{className:"bar-container"}),h=m(this.chartContext,{className:"annotation-container"}),p=this.chartContext.getChartContainer();if(t){const{startIndex:o,endIndex:r}=t.range,a=n.length*t.rowHeight;d.style.height=`${a}px`,d.style.width="100%";n.slice(o,r+1).forEach(((t,n)=>{const r=o+n,a=new J(t,i[0],this.options,this.viewMode,r,this.chartContext,this.dataManager),s=a.drawBar(((t,e)=>{st(this.chartContext,this.dataManager,t,e,this.options,this.viewMode,i[0])}));d.append(s),!e.has(t.id)&&p&&Ct(s,r,p);const l=a.drawBaselineBar();l&&d.append(l)}))}else n.forEach(((t,n)=>{const o=new J(t,i[0],this.options,this.viewMode,n,this.chartContext,this.dataManager),r=o.drawBar(((t,e)=>{st(this.chartContext,this.dataManager,t,e,this.options,this.viewMode,i[0])}));d.append(r),!e.has(t.id)&&p&&Ct(r,n,p);const a=o.drawBaselineBar();a&&d.append(a)}));const u=n.length*this.options.rowHeight,g=new q(this.options,i[0],this.viewMode,this.chartContext,u).render();h.append(...g);const b=m(this.chartContext,{className:"timeline-horizontal-scroll"}),f=m(this.chartContext,{className:"timeline-horizontal-scroll-content"}),y=this.chartContext.getInstanceId();b.id=`timeline-horizontal-scroll-${y}`;const v=(a||r).length*N[this.viewMode];return f.style.width=`${v}px`,f.style.height="1px",b.appendChild(f),[s,h,c,d,b]}}const Mt="http://www.w3.org/2000/svg",Tt={paddingX:20,paddingY:15};class At{constructor(t){this.elements=[],this.chartContext=null,this.instanceId=t??"arrow_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)}getInstanceId(){return this.instanceId}static calculateArrowPathFromRects(t,e,n,i="FS"){const{paddingX:o=Tt.paddingX,paddingY:r=Tt.paddingY}=n;switch(i){case"SS":return At.calculateSSPath(t,e,o,r);case"FF":return At.calculateFFPath(t,e,o,r);case"SF":return At.calculateSFPath(t,e,o,r);default:return At.calculateFSPath(t,e,o,r)}}static calculateArrowPath(t,e,n,i,o="FS"){const r=d(t,n),a=d(e,n),{paddingX:s=Tt.paddingX,paddingY:l=Tt.paddingY}=i;switch(o){case"SS":return At.calculateSSPath(r,a,s,l);case"FF":return At.calculateFFPath(r,a,s,l);case"SF":return At.calculateSFPath(r,a,s,l);default:return At.calculateFSPath(r,a,s,l)}}static calculateFSPath(t,e,n,i){const o=t.right,r=t.top+t.height/2,a=e.left-2,s=e.top+e.height/2,l=[`M ${o},${r}`];if(a>o){if(s<r){const t=o+n,e=r-i,c=a-n,d=s+i;l.push(`L ${t},${r}`),l.push(`L ${t},${e}`),l.push(`L ${c},${e}`),l.push(`L ${c},${d}`),l.push(`L ${c},${s}`)}else if(s>r){const e=t.bottom+i-t.height/2,c=(o+a)/2;if(a-o<20){const t=a-n;l.push(`L ${c},${r}`),l.push(`L ${c},${e}`),l.push(`L ${t},${e}`),l.push(`L ${t},${s}`)}else l.push(`L ${c},${r}`),l.push(`L ${c},${e}`),l.push(`L ${c},${s}`)}}else if(a<o)if(s!==r){const t=o+n,e=r+i*(s<r?-1:1),c=a-n,d=s+i*(s<r?1:-1);l.push(`L ${t},${r}`),l.push(`L ${t},${e}`),l.push(`L ${c},${e}`),l.push(`L ${c},${d}`),l.push(`L ${c},${s}`)}else{const t=o+n,e=r+i,c=a-n,d=s;l.push(`L ${t},${r}`),l.push(`L ${t},${e}`),l.push(`L ${c},${e}`),l.push(`L ${c},${d}`)}return l.push(`L ${a},${s}`),l.join(" ")}static calculateSSPath(t,e,n,i){const o=t.left,r=t.top+t.height/2,a=e.left-2,s=e.top+e.height/2,l=Math.min(o,a+2)-n,c=[`M ${o},${r}`];if(r===s)c.push(`L ${l},${r}`),c.push(`L ${l},${s}`);else{const t=r+i*(s>r?1:-1);c.push(`L ${l},${r}`),c.push(`L ${l},${t}`),c.push(`L ${l},${s}`)}return c.push(`L ${a},${s}`),c.join(" ")}static calculateFFPath(t,e,n,i){const o=t.right,r=t.top+t.height/2,a=e.right+2,s=e.top+e.height/2,l=Math.max(o,a-2)+n,c=[`M ${o},${r}`];if(r===s)c.push(`L ${l},${r}`),c.push(`L ${l},${s}`);else{const t=r+i*(s>r?1:-1);c.push(`L ${l},${r}`),c.push(`L ${l},${t}`),c.push(`L ${l},${s}`)}return c.push(`L ${a},${s}`),c.join(" ")}static calculateSFPath(t,e,n,i){const o=t.left,r=t.top+t.height/2,a=e.right+2,s=e.top+e.height/2,l=o-n,c=e.right+n,d=[`M ${o},${r}`];if(d.push(`L ${l},${r}`),r<=s){const e=t.bottom+i-t.height/2;d.push(`L ${l},${e}`),d.push(`L ${c},${e}`),d.push(`L ${c},${s}`)}else{const t=e.top-i;d.push(`L ${l},${t}`),d.push(`L ${c},${t}`),d.push(`L ${c},${s}`)}return d.push(`L ${a},${s}`),d.join(" ")}static drawArrow(t,e,n,i,o,r,a,s="FS",l=0){const c=a?a.createElementNS(Mt,"path"):document.createElementNS(Mt,"path"),d=At.calculateArrowPath(t,e,n,i,s);c.setAttribute("d",d);const h=i.arrowColor||"#0D6EFD";c.setAttribute("stroke",h),c.setAttribute("stroke-width","2"),c.setAttribute("fill","transparent");const p=r?`arrowhead-${r}`:"arrowhead";return c.setAttribute("marker-end",`url(#${p})`),c.setAttribute("data-edgeid",o),c.setAttribute("data-dependency-type",s),c.addEventListener("mouseout",(function(){c.setAttribute("stroke",h)})),0!==l&&c.setAttribute("data-lag-px",String(l)),c}static updateArrow(t,e,n,i,o,r="FS"){const a=n.querySelector(`[data-edgeid="${o}"]`),s=At.calculateArrowPath(t,e,n,i,r);a&&a.setAttribute("d",s)}createMarker(t){const e=t?t.createElementNS(Mt,"marker"):document.createElementNS(Mt,"marker"),n=`arrowhead-${this.instanceId}`;e.setAttribute("id",n),e.setAttribute("markerWidth","5"),e.setAttribute("markerHeight","5"),e.setAttribute("refX","4"),e.setAttribute("refY","2.5"),e.setAttribute("orient","auto"),e.setAttribute("fill","context-stroke");const i=t?t.createElementNS(Mt,"polygon"):document.createElementNS(Mt,"polygon");return i.setAttribute("points","0,0 5,2.5 0,5 1, 2.5"),e.appendChild(i),e}render(t,e,n,i){this.chartContext=i||null;const o=`timeline-arrows-${this.instanceId}`;let r=t.querySelector(`#${o}`);r||(r=i?i.createElementNS(Mt,"svg"):document.createElementNS(Mt,"svg"),r.setAttribute("id",o),t.appendChild(r)),this.svg=r,this.options={...Tt,...n},this.elements=e,this.svg.setAttribute("style",g({left:"0",position:"absolute",top:"0",pointerEvents:"none"})),this.svg.innerHTML="";const a=i?i.createElementNS(Mt,"defs"):document.createElementNS(Mt,"defs"),s=this.createMarker(i);return a.appendChild(s),this.svg.appendChild(a),this.svg.setAttribute("width",`${this.options.width}`),this.svg.setAttribute("height",`${this.options.height}`),this.elements.forEach((({id:t,source:e,target:n,dependencyType:o,lagPx:r})=>{this.svg.appendChild(At.drawArrow(e,n,this.svg,this.options,t,this.instanceId,i,o,r))})),this.svg}renderFromRects(t,e,n,i){this.chartContext=i||null;const o=`timeline-arrows-${this.instanceId}`;let r=t.querySelector(`#${o}`);r||(r=i?i.createElementNS(Mt,"svg"):document.createElementNS(Mt,"svg"),r.setAttribute("id",o),t.appendChild(r)),this.svg=r,this.options={...Tt,...n},this.svg.setAttribute("style",g({left:"0",position:"absolute",top:"0",pointerEvents:"none"})),this.svg.innerHTML="";const a=i?i.createElementNS(Mt,"defs"):document.createElementNS(Mt,"defs");a.appendChild(this.createMarker(i)),this.svg.appendChild(a),this.svg.setAttribute("width",`${this.options.width}`),this.svg.setAttribute("height",`${this.options.height}`);const s=n.arrowColor||"#0D6EFD",l=`arrowhead-${this.instanceId}`;return e.forEach((({id:t,sourceRect:e,targetRect:n,dependencyType:o="FS",lagPx:r=0})=>{const a=At.calculateArrowPathFromRects(e,n,this.options,o),c=i?i.createElementNS(Mt,"path"):document.createElementNS(Mt,"path");c.setAttribute("d",a),c.setAttribute("stroke",s),c.setAttribute("stroke-width","2"),c.setAttribute("fill","transparent"),c.setAttribute("marker-end",`url(#${l})`),c.setAttribute("data-edgeid",t),c.setAttribute("data-dependency-type",o),0!==r&&c.setAttribute("data-lag-px",String(r)),c.addEventListener("mouseout",(()=>{c.setAttribute("stroke",s)})),this.svg.appendChild(c)})),this.svg}}const $t={criticalTaskIds:new Set,criticalEdgeKeys:new Set};function It(t,e){const n=new Date(t).setHours(0,0,0,0),i=new Date(e).setHours(0,0,0,0);return Math.round((i-n)/864e5)+1}function Dt(t){const e=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e);return{barFill:e("--apex-gantt-bar-fill"),bgColor:e("--apex-gantt-background-color"),rowBgEven:e("--apex-gantt-row-bg-even"),rowBgOdd:e("--apex-gantt-row-bg-odd"),headerBg:e("--apex-gantt-header-bg"),gridLine:e("--apex-gantt-grid-line"),dependencyLine:e("--apex-gantt-dependency-line"),fontFamily:e("--apex-gantt-font-family"),fontSize:e("--apex-gantt-font-size"),fontColor:e("--apex-gantt-font-color")}}const Bt="http://www.w3.org/2000/svg";function Ft(t,e){t&&Object.assign(t.style,e)}function Rt(t){const e=[];for(let t=0;t<document.styleSheets.length;t++)try{const n=document.styleSheets[t];if(n.href&&!n.href.startsWith(window.location.origin))continue;if(n.cssRules)for(let t=0;t<n.cssRules.length;t++)e.push(n.cssRules[t].cssText)}catch(t){continue}document.querySelectorAll("style").forEach((t=>{t.textContent&&e.push(t.textContent)}));const n=function(t){const e=window.getComputedStyle(t),n=[];for(let e=0;e<t.style.length;e++){const i=t.style[e];if(i.startsWith("--")){const e=t.style.getPropertyValue(i);n.push(`${i}: ${e};`)}}return Array.from(e).forEach((t=>{if(t.startsWith("--")){const i=`${t}: ${e.getPropertyValue(t)};`;n.includes(i)||n.push(i)}})),0===n.length?"":`:root {\n ${n.join("\n ")}\n}`}(t);return n&&e.unshift(n),e.join("\n")}function Ht(t,e){const{contentWidth:n}=e,i=t.querySelector(".timeline-horizontal-scroll");null==i||i.remove();const o=t.querySelector(".timeline-container"),r=t.querySelector(".tasks-container"),a=t.querySelector(".timeline-body-wrapper"),s=t.querySelector(".timeline-header"),l=t.querySelector(".timeline-body"),c=t.querySelector(".bar-container"),d=t.querySelector(".annotation-container");var h;Ft(o,{overflow:"visible",maxWidth:"none",width:"auto",position:"relative"}),Ft(r,{overflow:"visible",height:"auto",maxHeight:"none"}),Ft(a,{overflow:"visible",maxWidth:"none",width:`${n}px`}),a&&(a.scrollLeft=0),Ft(s,{overflow:"visible",maxWidth:"none",width:`${n}px`}),s&&(s.scrollLeft=0),h={width:`${n}px`,minWidth:`${n}px`,maxWidth:"none"},[l,c,d].forEach((t=>Ft(t,h)))}const zt=async t=>{try{const e=function(t){const e=t.querySelector(".gantt-container");if(!e)throw new Error("Gantt container not found");const n=e.querySelector(".timeline-container"),i=e.querySelector(".tasks-container");if(!n||!i)throw new Error("Timeline or tasks container not found");return{ganttContainer:e,timelineContainer:n,tasksContainer:i,horizontalScroll:e.querySelector(".timeline-horizontal-scroll"),timelineBodyWrapper:n.querySelector(".timeline-body-wrapper"),timelineHeader:n.querySelector(".timeline-header"),timelineBody:n.querySelector(".timeline-body"),barContainer:n.querySelector(".bar-container"),annotationContainer:n.querySelector(".annotation-container")}}(t),n=function(t){var e,n,i,o;const r=Math.max((null==(e=t.timelineBody)?void 0:e.scrollWidth)||0,(null==(n=t.barContainer)?void 0:n.scrollWidth)||0,(null==(i=t.annotationContainer)?void 0:i.scrollWidth)||0,(null==(o=t.timelineHeader)?void 0:o.scrollWidth)||0),a=t.tasksContainer.scrollWidth;return{contentWidth:r,tasksWidth:a,totalWidth:a+r,totalHeight:Math.max(t.timelineContainer.scrollHeight,t.tasksContainer.scrollHeight)}}(e),i=e.ganttContainer.cloneNode(!0);Ht(i,n),Ft(i,{display:"flex",overflow:"visible",width:"fit-content",height:"auto"});const o=Rt(t),r=document.createElement("style");r.textContent=o,i.insertBefore(r,i.firstChild);const a=document.createElementNS(Bt,"svg");a.setAttribute("width",n.totalWidth.toString()),a.setAttribute("height",n.totalHeight.toString()),a.setAttribute("xmlns",Bt),a.setAttribute("viewBox",`0 0 ${n.totalWidth} ${n.totalHeight}`);const s=document.createElementNS(Bt,"foreignObject");s.setAttribute("width",n.totalWidth.toString()),s.setAttribute("height",n.totalHeight.toString()),s.setAttribute("x","0"),s.setAttribute("y","0"),s.appendChild(i),a.appendChild(s);const l='<?xml version="1.0" encoding="UTF-8"?>\n'+(new XMLSerializer).serializeToString(a),c=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),d=URL.createObjectURL(c),h=document.createElement("a");h.href=d,h.download=`gantt-chart-${Date.now()}.svg`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout((()=>URL.revokeObjectURL(d)),100)}catch(t){throw R.error("Error exporting gantt chart:",t),t}},Lt={zoomIn:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',zoomOut:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',calendar:'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>\n <line x1="16" y1="2" x2="16" y2="6"/>\n <line x1="8" y1="2" x2="8" y2="6"/>\n <line x1="3" y1="10" x2="21" y2="10"/>\n </svg>',chevronDown:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <polyline points="6 9 12 15 18 9"/>\n </svg>',download:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>'},Pt={ganttContainer:".gantt-container",actionsContainer:".gantt-actions-container",splitBar:".split-bar-container",tasksContainer:".tasks-container",tasksHeader:".tasks-header",tasksBodyWrapper:".tasks-body-wrapper",tasksDataContainer:".tasks-data-container",tasksDataRow:".tasks-data-row",tasksEmptyRow:".tasks-empty-row",tasksDataCell:".tasks-data-cell",timelineContainer:".timeline-container",timelineHeader:".timeline-header",timelineHeaderCell:".timeline-header-cell",timelineBodyWrapper:".timeline-body-wrapper",timelineBody:".timeline-body",timelineDataRow:".timeline-data-row",timelineEmptyRow:".timeline-empty-row",timelineDataCell:".timeline-data-cell",horizontalScroll:".timeline-horizontal-scroll",horizontalScrollContent:".timeline-horizontal-scroll-content",barContainer:".bar-container",virtualizerTopSpacer:".virtualizer-top-spacer",virtualizerBottomSpacer:".virtualizer-bottom-spacer"};class Ot{constructor(){this.state={scrollPosition:{horizontal:0,tasksVertical:0,timelineVertical:0},viewMode:P.Week,collapsedTasks:new Set,selectedTaskIds:[]}}captureState(t,e,n,i){const o=t.querySelector(".timeline-horizontal-scroll"),r=t.querySelector(".split-view-container");this.state.scrollPosition={horizontal:(null==o?void 0:o.scrollLeft)||0,tasksVertical:(null==r?void 0:r.scrollTop)||0,timelineVertical:(null==r?void 0:r.scrollTop)||0},this.state.viewMode=n,this.state.collapsedTasks=new Set(e.getFlatTasks().filter((t=>t.collapsed)).map((t=>t.id))),this.state.selectedTaskIds=i??[]}restoreState(t,e=!1){e||requestAnimationFrame((()=>{const e=t.querySelector(".timeline-horizontal-scroll"),n=t.querySelector(".split-view-container");e&&(e.scrollLeft=this.state.scrollPosition.horizontal),n&&(n.scrollTop=this.state.scrollPosition.tasksVertical);const i=t.querySelector(".timeline-header");i&&(i.scrollLeft=this.state.scrollPosition.horizontal)}))}getViewMode(){return this.state.viewMode}getSelectedTaskIds(){return this.state.selectedTaskIds}hasState(){return void 0!==this.state.viewMode}clearState(){this.state={scrollPosition:{horizontal:0,tasksVertical:0,timelineVertical:0},viewMode:P.Week,collapsedTasks:new Set,selectedTaskIds:[]}}}const qt=["endTime","progress","type","parentId","dependency","barBackgroundColor","rowBackgroundColor","collapsed"];class Nt{static getNestedValue(t,e){if(!t||!e)return;const n=e.split(".");let i=t;for(const t of n){if(null==i)return;i=i[t]}return i}static processParsingValue(t,e){if("string"==typeof e)return this.getNestedValue(t,e);const{key:n,transform:i}=e,o=this.getNestedValue(t,n);if(i&&"function"==typeof i)try{return i(o)}catch(t){return R.warn(`DataParser: Transform function failed for key "${n}":`,t),o}return o}static buildTaskInput(t,e,n){const i=this.processParsingValue(t,e.id),o=this.processParsingValue(t,e.name),r=this.processParsingValue(t,e.startTime);if(!i||!o||!r)return R.warn(`DataParser: Skipping item at index ${n} - missing required fields`,{id:i,name:o,startTime:r,rawItem:t}),null;const a={id:i,name:o,startTime:r};for(const n of qt)if(void 0!==e[n]){const i=this.processParsingValue(t,e[n]);void 0!==i&&(a[n]=i)}return a}static parse(t,e){return Array.isArray(t)?e?t.map(((t,n)=>{try{return this.buildTaskInput(t,e,n)}catch(e){return R.warn(`DataParser: Error parsing item at index ${n}:`,e,t),null}})).filter((t=>null!==t)):(R.warn("DataParser: Parsing config is required"),[]):(R.warn("DataParser: Data must be an array"),[])}static validateConfig(t){return!!t&&(!!(t.id&&t.name&&t.startTime)||(R.warn("DataParser: Parsing config must include id, name, and startTime"),!1))}}const Wt="splitview-resize",Vt="timeline-horizontal-scroll";class Yt{constructor(t,e,n,i,o,r){this.element=t,this.options=e,this.domCache=n,this.chartContext=i,this.instanceId=o,this.getViewMode=r,this.scrollbarResizeObserver=null,this.splitBarResizeHandler=null,this.timelineScrollHandlers={},this.isSyncingScroll=!1}setupTimelineHorizontalScroll(){const t=this.domCache.horizontalScroll,e=this.domCache.timelineHeader,n=this.domCache.timelineBodyWrapper;if(!t||!e||!n)return;this.updateHorizontalScrollbarContent(),this.applyScrollbarStylesToElement(t),this.timelineScrollHandlers.bodyScroll&&n.removeEventListener("scroll",this.timelineScrollHandlers.bodyScroll),this.timelineScrollHandlers.horizontalScroll&&t.removeEventListener("scroll",this.timelineScrollHandlers.horizontalScroll);const i=i=>{if(this.isSyncingScroll)return;this.isSyncingScroll=!0;const o=t.scrollLeft;e.scrollLeft=o,n.scrollLeft=o,requestAnimationFrame((()=>{this.isSyncingScroll=!1}))},o=i=>{if(this.isSyncingScroll)return;this.isSyncingScroll=!0;const o=n.scrollLeft;t.scrollLeft=o,e.scrollLeft=o,requestAnimationFrame((()=>{this.isSyncingScroll=!1}))};t.addEventListener("scroll",i,{passive:!0}),n.addEventListener("scroll",o,{passive:!0}),this.timelineScrollHandlers={horizontalScroll:i,bodyScroll:o}}positionHorizontalScrollbar(){const t=this.domCache.horizontalScroll,e=this.domCache.ganttContainer,n=this.domCache.tasksContainer;if(!t||!e)return void R.warn("Missing elements for scrollbar positioning");e.offsetHeight;const i=n?n.offsetWidth:0,o=this.domCache.splitBar,r=i+(o?o.offsetWidth:0)+2,a=window.getComputedStyle(this.element),s=parseFloat(a.paddingLeft)||0,l=parseFloat(a.paddingBottom)||0;t.style.left=`${r+s}px`,t.style.bottom=`${l}px`;const c=e.clientWidth-r;t.style.width=`${Math.max(0,c)}px`}compensateForScrollbar(){const t=this.domCache.tasksBodyWrapper,e=this.domCache.tasksHeader;if(!t||!e)return;const n=t.offsetWidth-t.clientWidth;e.style.paddingRight="",e.style.boxSizing="",n>0&&(e.style.paddingRight=`${n}px`,e.style.boxSizing="border-box")}setupScrollbarResizeObserver(){if(!this.element)return;this.scrollbarResizeObserver&&this.scrollbarResizeObserver.disconnect(),this.scrollbarResizeObserver=new ResizeObserver((()=>{this.positionHorizontalScrollbar()})),this.scrollbarResizeObserver.observe(this.element);const t=this.domCache.ganttContainer;t&&this.scrollbarResizeObserver.observe(t),this.setupSplitBarResizeListener()}setupSplitBarResizeListener(){this.splitBarResizeHandler&&this.chartContext.removeEventListener(Wt,this.splitBarResizeHandler),this.splitBarResizeHandler=()=>{requestAnimationFrame((()=>{this.positionHorizontalScrollbar()}))},this.chartContext.addEventListener(Wt,this.splitBarResizeHandler)}updateHorizontalScrollbarContent(){const t=this.domCache.horizontalScroll,e=this.domCache.horizontalScrollContent,n=this.domCache.timelineBody;if(!t||!e||!n)return void R.warn("Scrollbar update: Missing elements",{horizontalScroll:!!t,scrollContent:!!e,timelineBody:!!n});const i=n.scrollWidth;e.style.width=`${i}px`}applyScrollbarStylesToElement(t){const{backgroundColor:e}=this.options;if(!this.isColorDark(e))return;const{borderColor:n,cellBorderColor:i}=this.options,o=`scrollbar-${this.instanceId}-${Date.now()}`,r=`\n #${t.id||Vt} {\n scrollbar-width: thin;\n scrollbar-color: ${n} ${e};\n }\n\n #${t.id||Vt}::-webkit-scrollbar {\n width: 12px;\n height: 12px;\n }\n\n #${t.id||Vt}::-webkit-scrollbar-track {\n background: ${e};\n border-radius: 4px;\n }\n\n #${t.id||Vt}::-webkit-scrollbar-thumb {\n background: ${n};\n border-radius: 4px;\n border: 2px solid ${e};\n }\n\n #${t.id||Vt}::-webkit-scrollbar-thumb:hover {\n background: ${i};\n }\n `;t.id||(t.id=`timeline-horizontal-scroll-${this.instanceId}`),this.chartContext.injectStyles(r,o)}updateOptions(t){this.options=t}disableHeaderMousewheelScroll(){const t=this.domCache.timelineHeader;if(!t)return;t.addEventListener("wheel",(t=>{t.preventDefault()}),{passive:!1})}isColorDark(t){const e=t.replace("#","");return(.299*parseInt(e.substring(0,2),16)+.587*parseInt(e.substring(2,4),16)+.114*parseInt(e.substring(4,6),16))/255<.5}cleanup(){if(this.timelineScrollHandlers.bodyScroll||this.timelineScrollHandlers.horizontalScroll){const t=this.domCache.horizontalScroll,e=this.domCache.timelineBodyWrapper;t&&this.timelineScrollHandlers.horizontalScroll&&t.removeEventListener("scroll",this.timelineScrollHandlers.horizontalScroll),e&&this.timelineScrollHandlers.bodyScroll&&e.removeEventListener("scroll",this.timelineScrollHandlers.bodyScroll),this.timelineScrollHandlers={}}this.scrollbarResizeObserver&&(this.scrollbarResizeObserver.disconnect(),this.scrollbarResizeObserver=null),this.splitBarResizeHandler&&(this.chartContext.removeEventListener(Wt,this.splitBarResizeHandler),this.splitBarResizeHandler=null)}}class _t{constructor(t,e,n,i,o,r){this.element=t,this.domCache=e,this.chartContext=n,this.instanceId=i,this.getViewMode=o,this.callbacks=r,this.zoomHandler=null}setupZoomEventListener(){const t=this.instanceId,e=this.domCache.timelineContainer;e?(this.zoomHandler&&e.removeEventListener("wheel",this.zoomHandler),this.zoomHandler=t=>{if(!t.ctrlKey)return;t.preventDefault();const e=Math.sign(t.deltaY);e<0?this.zoomIn():e>0&&this.zoomOut()},e.addEventListener("wheel",this.zoomHandler)):R.warn(`[${t}] Timeline element not found for zoom listener`)}zoomIn(){const t=this.getViewMode();if(t===L[0])return;const e=L.findIndex((e=>e===t)),n=L[e-1];this.callbacks.onViewModeChange(n),this.callbacks.onToolbarUpdate(),this.callbacks.onTimelineRerender(),this.callbacks.onDependencyArrowsRender(),requestAnimationFrame((()=>{this.callbacks.onScrollbarUpdate(),this.callbacks.onScrollbarPosition()}))}zoomOut(){const t=this.getViewMode();if(t===L[L.length-1])return;const e=L.findIndex((e=>e===t)),n=L[e+1];this.callbacks.onViewModeChange(n),this.callbacks.onToolbarUpdate(),this.callbacks.onTimelineRerender(),this.callbacks.onDependencyArrowsRender(),requestAnimationFrame((()=>{this.callbacks.onScrollbarUpdate(),this.callbacks.onScrollbarPosition()}))}updateToolbarAfterZoom(){this.domCache.actionsContainer&&this.callbacks.onToolbarUpdate()}cleanup(){if(this.zoomHandler){const t=this.domCache.timelineContainer;t&&t.removeEventListener("wheel",this.zoomHandler),this.zoomHandler=null}}}const jt="aria-valuenow";class Ut{constructor(t,e,n,i={}){this.chartContext=t,this.leftContent=e,this.rightContent=n,this.options=i,this.isDragging=!1,this.mouseMoveHandler=null,this.mouseUpHandler=null}getSplitViewStyles(){return"\n .split-view-container {\n display: flex !important;\n height: 100%;\n width: 100%;\n position: relative;\n box-sizing: border-box;\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .split-view-container .split-left-container {\n flex-grow: 0 !important;\n flex-shrink: 1 !important;\n overflow: visible;\n display: flex !important;\n flex-direction: column;\n position: relative;\n box-sizing: border-box;\n height: fit-content;\n min-height: 100%;\n }\n\n .split-view-container .split-right-container {\n overflow: visible;\n position: relative;\n flex: 1 !important;\n display: flex !important;\n flex-direction: column;\n min-width: 0;\n box-sizing: border-box;\n height: fit-content;\n min-height: 100%;\n }\n \n .split-view-container .split-bar-container {\n cursor: col-resize !important;\n user-select: none !important;\n height: 100%;\n align-items: center;\n background: var(--split-bar-color, #DEE2E6);\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n min-width: 8px;\n width: 8px;\n z-index: 15;\n position: sticky;\n top: 0;\n box-sizing: border-box;\n border-left: 1px solid var(--split-bar-border-color, #BBBBBB);\n border-right: 1px solid var(--split-bar-border-color, #BBBBBB);\n opacity: 1;\n visibility: visible;\n box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);\n transition: background-color 0.2s ease, border-color 0.2s ease;\n }\n\n .split-view-container .split-bar-container:hover {\n background: var(--split-bar-hover-color, #007BFF);\n border-color: var(--split-bar-hover-border-color, #0056B3);\n }\n\n .split-view-container .split-bar-container .resize-handler {\n border-left: 1.5px solid var(--split-bar-handle-color, #666666);\n border-right: 1.5px solid var(--split-bar-handle-color, #666666);\n height: 20px;\n width: 4px;\n position: relative;\n pointer-events: none;\n box-sizing: border-box;\n background: rgba(102, 102, 102, 0.3);\n display: block;\n border-radius: 1px;\n margin: 0;\n padding: 0;\n opacity: 1;\n visibility: visible;\n transition: background-color 0.2s ease, border-color 0.2s ease;\n }\n\n .split-view-container .split-bar-container:hover .resize-handler {\n background: rgba(255, 255, 255, 0.9);\n border-color: #FFFFFF;\n }\n\n .split-view-container.dragging {\n user-select: none;\n cursor: col-resize;\n }\n\n .split-view-container.dragging * {\n pointer-events: none;\n }\n\n .split-view-container.dragging .split-bar-container {\n pointer-events: all;\n }\n\n :host .split-view-container {\n display: flex !important;\n height: auto;\n width: 100%;\n position: relative;\n box-sizing: border-box;\n overflow-y: auto; /* shadow DOM */\n }\n "}injectStyles(){this.chartContext.injectStyles(this.getSplitViewStyles(),"split-view-styles",{priority:"normal"})}buildElements(){const{leftContainerClass:t="",leftContainerWidth:e=425,rightContainerClass:n=""}=this.options;this.leftContainer=m(this.chartContext,{className:"split-left-container"+(t?" "+t:""),style:{flexBasis:`${e}px`}}),this.rightContainer=m(this.chartContext,{className:"split-right-container"+(n?" "+n:"")});const i=m(this.chartContext,{className:"resize-handler"}),o=m(this.chartContext,{className:"split-bar-click-area"});o.style.cssText="\n position: absolute;\n top: 0;\n left: 50%;\n transform: translateX(-50%);\n width: 20px;\n height: 100%;\n cursor: col-resize;\n z-index: 10;\n background: transparent;\n display: block;\n box-sizing: border-box;\n ",this.splitBarContainer=m(this.chartContext,{className:"split-bar-container"}),this.splitBarContainer.setAttribute("role","separator"),this.splitBarContainer.setAttribute("aria-orientation","vertical"),this.splitBarContainer.setAttribute("aria-label","Resize panels"),this.splitBarContainer.setAttribute(jt,String(e)),this.splitBarContainer.setAttribute("aria-valuemin","0"),this.splitBarContainer.setAttribute("aria-valuemax",String(4*e)),this.splitBarContainer.setAttribute("tabindex","0"),this.splitBarContainer.append(i,o),Array.isArray(this.leftContent)?this.leftContainer.append(...this.leftContent):this.leftContainer.append(this.leftContent),Array.isArray(this.rightContent)?this.rightContainer.append(...this.rightContent):this.rightContainer.append(this.rightContent)}attachEventListeners(){this.splitBarContainer.addEventListener("mousedown",(t=>{t.preventDefault(),this.isDragging=!0;const e=this.splitBarContainer.closest(".split-view-container");null==e||e.classList.add("dragging"),this.mouseMoveHandler=t=>{var e;if(!this.isDragging)return;const n=null==(e=this.leftContainer.parentElement)?void 0:e.getBoundingClientRect();if(!n)return;const i=t.clientX-n.left,o=n.width-50,r=Math.max(0,Math.min(o,i));this.leftContainer.style.flexBasis=`${r}px`,this.splitBarContainer.setAttribute(jt,String(Math.round(r))),this.dispatchResizeEvent()},this.mouseUpHandler=()=>{this.isDragging=!1;const t=this.splitBarContainer.closest(".split-view-container");null==t||t.classList.remove("dragging"),this.dispatchResizeEvent(),this.mouseMoveHandler&&(this.chartContext.removeEventListener("mousemove",this.mouseMoveHandler),this.mouseMoveHandler=null),this.mouseUpHandler&&(this.chartContext.removeEventListener("mouseup",this.mouseUpHandler),this.mouseUpHandler=null)},this.chartContext.addEventListener("mousemove",this.mouseMoveHandler),this.chartContext.addEventListener("mouseup",this.mouseUpHandler)})),this.splitBarContainer.addEventListener("keydown",(t=>{let e;const n=parseInt(this.leftContainer.style.flexBasis)||this.options.leftContainerWidth||400;switch(t.key){case"ArrowLeft":t.preventDefault(),e=Math.max(0,n-10),this.leftContainer.style.flexBasis=`${e}px`,this.splitBarContainer.setAttribute(jt,String(e)),this.dispatchResizeEvent();break;case"ArrowRight":t.preventDefault(),e=n+10,this.leftContainer.style.flexBasis=`${e}px`,this.splitBarContainer.setAttribute(jt,String(e)),this.dispatchResizeEvent();break;case"Home":t.preventDefault(),this.leftContainer.style.flexBasis="0px",this.splitBarContainer.setAttribute(jt,"0"),this.dispatchResizeEvent();break;case"End":{t.preventDefault();const e=this.splitBarContainer.parentElement;if(e){const t=e.clientWidth-50;this.leftContainer.style.flexBasis=`${t}px`,this.splitBarContainer.setAttribute(jt,String(Math.round(t)))}this.dispatchResizeEvent();break}}}))}dispatchResizeEvent(){const t=new CustomEvent("splitview-resize",{bubbles:!0,detail:{leftWidth:parseInt(this.leftContainer.style.flexBasis)||0}});this.chartContext.dispatchEvent(t)}cleanupEventListeners(){this.mouseMoveHandler&&(this.chartContext.removeEventListener("mousemove",this.mouseMoveHandler),this.mouseMoveHandler=null),this.mouseUpHandler&&(this.chartContext.removeEventListener("mouseup",this.mouseUpHandler),this.mouseUpHandler=null)}render(){this.injectStyles(),this.buildElements(),this.attachEventListeners();const t=m(this.chartContext,{className:"split-view-container"});return t.append(this.leftContainer,this.splitBarContainer,this.rightContainer),[t]}destroy(){this.cleanupEventListeners()}}const Kt="data-chart-instance";class Xt{constructor(t,e,n,i,o,r){this.element=t,this.options=e,this.domCache=n,this.chartContext=i,this.instanceId=o,this.getViewMode=r}updateOptions(t){this.options=t}setupChartContainerPositioning(){if(this.element){"static"===window.getComputedStyle(this.element).position&&(this.element.style.position="relative"),this.element.style.isolation="isolate"}}createLayout(t,e,n,i,o){t.style.position="relative",t.style.isolation="isolate";const r=this.instanceId,a=m(this.chartContext,{className:Pt.tasksContainer.slice(1)});let s,l;if(!Array.isArray(e))return void R.error("Tasks table should be an array of [header, body]");s=e[0],l=e[1];const c=m(this.chartContext,{className:Pt.tasksBodyWrapper.slice(1)});c.appendChild(l),a.appendChild(s),a.appendChild(c);const d=m(this.chartContext,{className:Pt.timelineContainer.slice(1)});d.setAttribute(Kt,r);const h=n[0];d.appendChild(h);const p=m(this.chartContext,{className:Pt.timelineBodyWrapper.slice(1)});for(let t=1;t<n.length-1;t++)p.appendChild(n[t]);d.appendChild(p);const u=n[n.length-1];if(i){const e=new Ut(this.chartContext,a,d,{leftContainerClass:"",leftContainerWidth:o,rightContainerClass:""}).render();t.append(...e)}else a.style.flex=`0 0 ${o}px`,t.append(a,d);t.appendChild(u)}syncTasksColumnWidths(){this.domCache.tasksContainer}fillEmptyRowsAfterRender(){const t=this.domCache.ganttContainer,e=this.domCache.timelineBody,n=this.domCache.tasksDataContainer;if(!t||!e||!n)return;e.querySelectorAll(Pt.timelineEmptyRow).forEach((t=>t.remove()));n.querySelectorAll(Pt.tasksEmptyRow).forEach((t=>t.remove()));const i=t.clientHeight,o=e.querySelectorAll(`${Pt.timelineDataRow}:not(${Pt.timelineEmptyRow})`).length,r=this.options.rowHeight,a=Math.floor(i/r),s=Math.max(0,a-o);if(0===s)return;let l=0;const c=e.querySelector(Pt.timelineDataRow);if(c)l=c.querySelectorAll(Pt.timelineDataCell).length;else{const t=this.domCache.timelineHeader;if(t){l=t.querySelectorAll(Pt.timelineHeaderCell).length}}if(0!==l){for(let t=0;t<s;t++){const n=this.createEmptyTimelineRow(t,l);e.appendChild(n)}for(let t=0;t<s;t++){const e=this.createEmptyTaskRow(t);n.appendChild(e)}}}createEmptyTimelineRow(t,e){const n=m(this.chartContext,{className:`${Pt.timelineDataRow.slice(1)} ${Pt.timelineEmptyRow.slice(1)}`}),{rowHeight:i}=this.options,o=this.instanceId,r=this.getViewMode();n.setAttribute("data-taskid",`empty-${t}`),n.setAttribute(Kt,o),n.style.height=`${i}px`;for(let t=0;t<e;t++){const t=m(this.chartContext,{className:Pt.timelineDataCell.slice(1),style:{height:`${i}px`,minWidth:`${N[r]}px`}});t.setAttribute(Kt,o),n.appendChild(t)}return n}createEmptyTaskRow(t){const e=m(this.chartContext,{className:`${Pt.tasksDataRow.slice(1)} ${Pt.tasksEmptyRow.slice(1)}`}),{rowHeight:n}=this.options,i=this.instanceId;return e.setAttribute("data-taskid",`empty-${t}`),e.setAttribute(Kt,i),e.style.height=`${n}px`,nt.forEach((({key:t})=>{const o=m(this.chartContext,{className:Pt.tasksDataCell.slice(1),content:""});o.setAttribute("data-columnid",t),o.setAttribute(Kt,i),o.style.height=`${n}px`,o.style.color="var(--text-color)",e.appendChild(o)})),e}}const Gt="\n .gantt-dialog-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: none;\n z-index: 999;\n overflow: hidden;\n }\n\n .gantt-dialog-container .dialog-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n }\n\n .gantt-dialog-container .gantt-dialog {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background: var(--dialog-bg-color, white);\n border-radius: 4px;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n border: 1px solid var(--dialog-border-color, #eee);\n z-index: 1000;\n min-width: 300px;\n max-width: 90%;\n max-height: 90%;\n display: flex;\n flex-direction: column;\n }\n\n .gantt-dialog .dialog-header {\n padding: 12px 16px;\n border-bottom: 1px solid var(--dialog-border-color, #eee);\n display: flex;\n justify-content: space-between;\n align-items: center;\n background: var(--header-bg-color, #f3f3f3);\n flex-shrink: 0;\n }\n\n .gantt-dialog .dialog-title {\n font-weight: 600;\n font-size: 16px;\n color: var(--header-text-color, #333);\n margin: 0;\n }\n\n .gantt-dialog .dialog-close {\n background: none;\n border: none;\n font-size: 20px;\n cursor: pointer;\n padding: 0;\n color: var(--text-color, #666);\n transition: color 0.2s;\n line-height: 1;\n }\n\n .gantt-dialog .dialog-close:hover {\n color: var(--text-color, #333);\n }\n\n .gantt-dialog .dialog-content {\n padding: 16px;\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n background: var(--dialog-bg-color, white);\n color: var(--text-color, #333);\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar {\n width: 8px;\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar-track {\n background: var(--dialog-bg-color, #f1f1f1);\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar-thumb {\n background: var(--border-color, #888);\n border-radius: 4px;\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar-thumb:hover {\n background: var(--text-color, #555);\n }\n\n .gantt-dialog-container.show {\n display: block;\n }\n\n .gantt-dialog-container.animate .dialog-overlay {\n animation: fadeIn 0.2s ease-out;\n }\n\n .gantt-dialog-container.animate .gantt-dialog {\n animation: slideIn 0.3s ease-out;\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translate(-50%, -48%);\n }\n to {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n\n .gantt-container {\n position: relative;\n }\n",Qt="\n .dropdown {\n position: relative;\n display: inline-block;\n }\n\n .dropdown .gantt-action-button {\n border-radius: 4px;\n }\n\n .dropdown.show .gantt-action-button {\n background: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--button-bg-color, #0066cc);\n }\n \n .dropdown-btn {\n padding: 8px 16px;\n background-color: var(--toolbar-bg-color, #fff);\n color: var(--text-color, rgba(0, 0, 0, 0.7));\n border: 1px solid var(--toolbar-border-color, #ddd);\n cursor: pointer;\n font-weight: bold;\n border-radius: 2px;\n font-family: inherit;\n font-size: inherit;\n line-height: 1.5;\n transition: background-color 0.2s ease, border-color 0.2s ease;\n }\n \n .dropdown-btn:hover {\n background-color: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--toolbar-border-color, #bbb);\n }\n \n .dropdown-btn:focus {\n outline: none;\n border-color: var(--button-bg-color, #0066cc);\n box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);\n }\n \n .dropdown-content {\n display: none;\n position: absolute;\n background-color: var(--dialog-bg-color, #fff);\n min-width: 160px;\n box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);\n z-index: 1000;\n border-radius: 4px;\n right: 0;\n top: calc(100% + 4px);\n border: 1px solid var(--dialog-border-color, #D9D9D9);\n overflow: hidden;\n }\n \n .dropdown-content a {\n color: var(--text-color, #333);\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n font-family: inherit;\n font-size: 13px;\n line-height: 1.4;\n transition: background-color 0.2s ease;\n cursor: pointer;\n }\n \n .dropdown-content a:hover {\n background-color: var(--toolbar-hover-bg-color, #f1f1f1);\n }\n \n .dropdown-content a:focus {\n background-color: var(--button-hover-bg-color, #e6f3ff);\n outline: none;\n }\n \n .dropdown.show .dropdown-content {\n display: block;\n animation: dropdownSlideDown 0.2s ease-out;\n }\n \n @keyframes dropdownSlideDown {\n from {\n opacity: 0;\n transform: translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n \n /* Shadow DOM specific adjustments */\n :host .dropdown {\n position: relative;\n display: inline-block;\n }\n",Zt="\n * {\n box-sizing: border-box;\n }\n\n .gantt-container * {\n user-select: none;\n }\n\n .gantt-actions-container {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 6px 10px;\n flex: 0 0 36px;\n min-height: 36px;\n max-height: 36px;\n background-color: var(--background-color, #FFFFFF);\n border-bottom: 1px solid var(--border-color, #DFE0E1);\n }\n\n .gantt-actions-spacer {\n flex: 1;\n min-width: 8px;\n }\n\n .gantt-action-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 0;\n border-radius: 4px;\n background: var(--toolbar-bg-color, #fff);\n color: var(--text-color, #333);\n cursor: pointer;\n transition: all 0.15s ease;\n flex-shrink: 0;\n }\n\n .gantt-action-button:hover:not(:disabled) {\n background: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--toolbar-border-color, #999);\n transform: translateY(-1px);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);\n }\n\n .gantt-action-button:active:not(:disabled) {\n transform: translateY(0);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\n }\n\n .gantt-action-button:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n background: var(--toolbar-bg-color, #fafafa);\n }\n\n .gantt-action-button svg {\n width: 16px;\n height: 16px;\n stroke: currentColor;\n flex-shrink: 0;\n }\n\n .gantt-action-separator {\n width: 1px;\n height: 20px;\n background-color: var(--border-color, #DFE0E1);\n margin: 0 4px;\n flex-shrink: 0;\n }\n\n .gantt-view-mode-display {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 10px;\n height: 28px;\n font-size: 13px;\n color: var(--text-color, #666);\n background: var(--toolbar-bg-color, #f8f9fa);\n border-radius: 4px;\n margin-left: 4px;\n font-weight: 500;\n white-space: nowrap;\n flex-shrink: 0;\n }\n\n .gantt-view-mode-display svg {\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n }\n \n .gantt-container {\n display: flex;\n flex: 1 1 auto;\n min-height: 0;\n min-width: 0;\n border: 1px solid var(--border-color, #DFE0E1);\n border-top: none;\n position: relative;\n background-color: var(--background-color, #FFFFFF);\n overflow: hidden;\n height: 100%;\n box-sizing: border-box;\n }\n \n .gantt-button {\n border: 1px solid var(--toolbar-border-color, #D9D9D9);\n border-radius: 2px;\n background: var(--toolbar-bg-color, #fff);\n padding: 4px 12px;\n color: var(--text-color, rgba(0, 0, 0, 0.7));\n line-height: 20px;\n font-weight: bold;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n\n .gantt-button:hover {\n background: var(--toolbar-hover-bg-color, #f8f9fa);\n }\n \n .gantt-button:disabled {\n color: rgba(128, 128, 128, 0.5);\n opacity: 0.6;\n }\n\n /* ── WCAG 2.1 AA: focus styles ─────────────────────────────────────────── */\n\n .tasks-data-row:focus-visible {\n outline: 2px solid var(--focus-ring-color, #005fcc);\n outline-offset: -2px;\n }\n\n .bar-timeline:focus {\n outline: 2px solid var(--focus-ring-color, #005fcc);\n outline-offset: 2px;\n }\n\n .tasks-data-row[aria-selected=\"true\"] {\n background-color: var(--row-selected-bg-color, rgba(0, 95, 204, 0.12));\n }\n\n /* ── Selection: checkbox column ────────────────────────────────────────── */\n\n .gantt-checkbox-cell {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n min-width: 28px;\n max-width: 28px;\n }\n\n .gantt-selection-checkbox,\n .gantt-select-all-checkbox {\n width: 15px;\n height: 15px;\n margin: 0;\n cursor: pointer;\n accent-color: var(--button-bg-color, #005fcc);\n }\n\n /* ── Selection: toolbar count indicator ─────────────────────────────────── */\n\n .gantt-selection-count {\n display: inline-flex;\n align-items: center;\n padding: 3px 10px;\n height: 24px;\n font-size: 12px;\n font-weight: 500;\n color: var(--button-bg-color, #005fcc);\n background: var(--row-selected-bg-color, rgba(0, 95, 204, 0.12));\n border-radius: 12px;\n margin-left: 8px;\n white-space: nowrap;\n flex-shrink: 0;\n }\n\n /* ── Custom toolbar items (Phase 2) ────────────────────────────────────── */\n\n .gantt-toolbar-button {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 0 10px;\n width: auto;\n min-width: 28px;\n font-size: 13px;\n font-weight: 500;\n color: var(--text-color, #333);\n white-space: nowrap;\n }\n\n .gantt-toolbar-button span {\n line-height: 1;\n }\n\n .gantt-toolbar-select-wrapper {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n flex-shrink: 0;\n }\n\n .gantt-toolbar-select-label {\n font-size: 13px;\n color: var(--text-color, #666);\n white-space: nowrap;\n flex-shrink: 0;\n }\n\n .gantt-toolbar-select {\n height: 28px;\n padding: 0 24px 0 8px;\n border: 1px solid var(--border-color, #DFE0E1);\n border-radius: 4px;\n background: var(--toolbar-bg-color, #fff);\n color: var(--text-color, #333);\n font-size: 13px;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");\n background-repeat: no-repeat;\n background-position: right 8px center;\n min-width: 100px;\n max-width: 180px;\n outline: none;\n }\n\n .gantt-toolbar-select:hover {\n border-color: var(--button-bg-color, #005fcc);\n }\n\n .gantt-toolbar-select:focus {\n border-color: var(--focus-ring-color, #005fcc);\n box-shadow: 0 0 0 2px rgba(0, 95, 204, 0.2);\n }\n\n /* ── prefers-reduced-motion ─────────────────────────────────────────────── */\n\n @media (prefers-reduced-motion: reduce) {\n .bar-timeline,\n .bar-timeline-progress,\n .bar-handle,\n .gantt-action-button,\n .gantt-button,\n .tasks-data-row,\n .gantt-dialog-container,\n .gantt-dialog {\n transition: none !important;\n animation: none !important;\n }\n }\n\n /* JS-detected reduced motion class (mirrors the media query in JS context) */\n .gantt-reduced-motion .bar-timeline,\n .gantt-reduced-motion .bar-timeline-progress,\n .gantt-reduced-motion .bar-handle,\n .gantt-reduced-motion .gantt-action-button,\n .gantt-reduced-motion .gantt-button,\n .gantt-reduced-motion .tasks-data-row,\n .gantt-reduced-motion .gantt-dialog-container,\n .gantt-reduced-motion .gantt-dialog {\n transition: none !important;\n animation: none !important;\n }\n",Jt="\n .gantt-container ::-webkit-scrollbar {\n width: 12px;\n height: 12px;\n }\n\n .gantt-container ::-webkit-scrollbar-track {\n background: var(--scrollbar-track-color, #F5F5F5);\n border-radius: 4px;\n }\n\n .gantt-container ::-webkit-scrollbar-thumb {\n background: var(--scrollbar-thumb-color, #C1C1C1);\n border-radius: 4px;\n border: 2px solid var(--scrollbar-track-color, #F5F5F5);\n }\n\n .gantt-container ::-webkit-scrollbar-thumb:hover {\n background: var(--scrollbar-thumb-hover-color, #A8A8A8);\n }\n\n .gantt-container * {\n scrollbar-width: thin;\n scrollbar-color: var(--scrollbar-thumb-color, #C1C1C1) var(--scrollbar-track-color, #F5F5F5);\n }\n\n /* Shadow DOM support */\n :host .gantt-container ::-webkit-scrollbar {\n width: 12px;\n height: 12px;\n }\n\n :host .gantt-container ::-webkit-scrollbar-track {\n background: var(--scrollbar-track-color, #F5F5F5);\n border-radius: 4px;\n }\n\n :host .gantt-container ::-webkit-scrollbar-thumb {\n background: var(--scrollbar-thumb-color, #C1C1C1);\n border-radius: 4px;\n border: 2px solid var(--scrollbar-track-color, #F5F5F5);\n }\n\n :host .gantt-container ::-webkit-scrollbar-thumb:hover {\n background: var(--scrollbar-thumb-hover-color, #A8A8A8);\n }\n\n :host .gantt-container * {\n scrollbar-width: thin;\n scrollbar-color: var(--scrollbar-thumb-color, #C1C1C1) var(--scrollbar-track-color, #F5F5F5);\n }\n",te='\n\n .task-form {\n overflow: visible;\n }\n\n .task-form .form-group {\n margin-bottom: 18px;\n position: relative;\n }\n\n /* extra padding to last form group for breathing room */\n .task-form .form-group:last-of-type {\n margin-bottom: 24px;\n }\n\n .task-form label {\n display: block;\n margin-bottom: 5px;\n font-weight: 500;\n color: var(--text-color, #333);\n }\n\n .task-form input {\n width: 100%;\n padding: 8px;\n border: 1px solid var(--dialog-border-color, #ddd);\n border-radius: 4px;\n font-size: 14px;\n background-color: var(--dialog-bg-color, #fff);\n color: var(--text-color, #333);\n }\n\n .task-form input:focus {\n outline: none;\n border-color: var(--button-bg-color, #0066cc);\n }\n\n .task-form .grid {\n display: flex;\n justify-content: space-between;\n gap: 12px;\n }\n\n .task-form .grid .form-group {\n flex: 1;\n }\n\n .task-form .form-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid var(--dialog-border-color, #eee);\n position: sticky;\n bottom: -16px;\n background: var(--dialog-bg-color, white);\n margin-left: -16px;\n margin-right: -16px;\n margin-bottom: -16px;\n padding-left: 16px;\n padding-right: 16px;\n padding-bottom: 16px;\n }\n\n .task-form .btn-primary {\n background: var(--button-bg-color, #0066cc);\n color: var(--button-text-color, white);\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-weight: 500;\n }\n\n .task-form .btn-primary:hover {\n background: var(--button-hover-bg-color, #0052a3);\n }\n\n .task-form .btn-disabled,\n .task-form .btn-disabled:hover {\n background: #99c2ff;\n cursor: not-allowed;\n opacity: 0.7;\n }\n\n .task-form .form-error {\n position: absolute;\n bottom: -15px;\n left: 0;\n color: #dc3545;\n font-size: 12px;\n margin-top: 4px;\n line-height: 1.2;\n transition: opacity 0.2s ease;\n }\n\n .task-form .invalid {\n border-color: #dc3545;\n }\n\n .task-form .invalid:focus {\n border-color: #dc3545;\n box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);\n }\n\n .color-picker-wrapper {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .color-picker-wrapper input[type="color"] {\n -webkit-appearance: none;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n\n .color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {\n padding: 0;\n }\n\n .color-picker-wrapper input[type="color"]::-webkit-color-swatch {\n border: 1px solid var(--dialog-border-color, #ddd);\n border-radius: 4px;\n }\n\n .color-picker-wrapper .color-preview {\n font-size: 12px;\n color: var(--text-color, #666);\n }\n',ee="\n .tasks-container {\n height: 100%;\n position: relative;\n display: flex;\n flex-direction: column;\n overflow-x: visible;\n overflow-y: visible;\n }\n\n .tasks-header {\n flex-shrink: 0;\n position: sticky;\n top: 0;\n z-index: 10;\n background-color: var(--header-bg-color, #F3F3F3);\n overflow: hidden;\n }\n\n .tasks-header-row {\n display: grid;\n width: 100%;\n }\n\n .tasks-header-cell {\n padding: 0 10px;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n border: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n color: var(--text-color, #000);\n box-sizing: border-box;\n font-weight: 600;\n }\n\n .tasks-body-wrapper {\n flex: 1;\n overflow: visible;\n position: relative;\n }\n\n .tasks-data-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n }\n\n .tasks-data-row {\n display: grid;\n width: 100%;\n border-bottom: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n box-sizing: border-box;\n }\n\n .tasks-data-cell {\n padding: 0 10px;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n border-left: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n border-right: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n color: var(--text-color, #000);\n box-sizing: border-box;\n }\n\n .tasks-data-row .tasks-data-cell:first-child {\n border-left: none;\n }\n\n .tasks-data-row .tasks-data-cell:last-child {\n border-right: none;\n }\n\n .tasks-data-row .task-toggle-icon,\n .tasks-data-row .task-toggle-icon-blank {\n display: inline-block;\n margin-right: 5px;\n width: 10px;\n height: 10px;\n vertical-align: middle;\n flex-shrink: 0;\n }\n\n .tasks-data-row .task-toggle-icon {\n cursor: pointer;\n position: relative;\n }\n\n /* Chevron (expanded) - pointing down */\n .tasks-data-row .task-toggle-icon.expanded::before {\n content: '';\n position: absolute;\n width: 6px;\n height: 6px;\n border-right: 2px solid var(--text-color, #000000);\n border-bottom: 2px solid var(--text-color, #000000);\n transform: rotate(45deg);\n top: 0;\n left: 2px;\n }\n\n /* Chevron - pointing right (collapsed) */\n .tasks-data-row .task-toggle-icon.collapsed::before {\n content: '';\n position: absolute;\n width: 6px;\n height: 6px;\n border-right: 2px solid var(--text-color, #000000);\n border-bottom: 2px solid var(--text-color, #000000);\n transform: rotate(-45deg);\n top: 2px;\n left: 0;\n }\n\n .tasks-data-row .task-toggle-icon:hover::before {\n opacity: 0.7;\n }\n\n /* Shadow DOM specific */\n :host .tasks-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n :host .tasks-header {\n position: sticky;\n top: 0;\n z-index: 10;\n }\n",ne="\n .gantt-container .timeline-container {\n width: 100%;\n height: 100%;\n position: relative;\n background-color: var(--background-color, #FFFFFF);\n display: flex;\n flex-direction: column;\n overflow: visible;\n padding-bottom: 0;\n box-sizing: border-box;\n }\n\n .timeline-container .timeline-header {\n position: sticky;\n top: 0;\n z-index: 100;\n background-color: var(--header-bg-color, #F3F3F3);\n flex-shrink: 0;\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n scrollbar-width: none; \n -ms-overflow-style: none; \n }\n\n .timeline-container .timeline-header::-webkit-scrollbar {\n display: none;\n height: 0;\n width: 0;\n }\n\n /* Shadow DOM specific */\n :host .timeline-container .timeline-header {\n scrollbar-width: none !important;\n -ms-overflow-style: none !important;\n }\n\n :host .timeline-container .timeline-header::-webkit-scrollbar {\n display: none !important;\n height: 0 !important;\n width: 0 !important;\n }\n\n .timeline-container .timeline-header > .timeline-header-row {\n width: max-content;\n position: relative;\n }\n\n .timeline-container .timeline-body-wrapper {\n flex: 1;\n overflow-x: auto;\n overflow-y: hidden;\n position: relative;\n width: 100%;\n min-height: 0;\n scrollbar-width: none;\n -ms-overflow-style: none;\n padding-bottom: 0; \n margin-bottom: 0;\n }\n\n .timeline-body-wrapper .timeline-horizontal-scroll, .timeline-container .timeline-body-wrapper::-webkit-scrollbar {\n display: none;\n height: 0;\n width: 0;\n }\n\n /* shadow DOM specific */\n :host .timeline-container .timeline-body-wrapper {\n scrollbar-width: none !important;\n -ms-overflow-style: none !important;\n }\n\n :host .timeline-container .timeline-body-wrapper::-webkit-scrollbar {\n display: none !important;\n height: 0 !important;\n width: 0 !important;\n }\n\n\n .timeline-horizontal-scroll {\n position: absolute;\n bottom: 0;\n height: 17px;\n overflow-x: auto;\n overflow-y: hidden;\n z-index: 300;\n background-color: var(--split-bar-color, var(--background-color, #FFFFFF));\n border-top: 1px solid var(--border-color, #DFE0E1);\n box-sizing: border-box;\n display: block;\n visibility: visible;\n opacity: 1;\n pointer-events: auto;\n }\n\n .timeline-horizontal-scroll-content {\n height: 1px;\n width: max-content;\n }\n\n .timeline-container .annotation,\n .timeline-container .annotation-container {\n position: absolute;\n top: 0;\n left: 0;\n pointer-events: none;\n }\n\n .timeline-container .annotation-container > * {\n pointer-events: auto;\n }\n\n .timeline-container .bar-container {\n position: absolute;\n top: 0;\n left: 0;\n pointer-events: none;\n }\n\n .timeline-container .bar-container > * {\n pointer-events: auto;\n }\n\n .timeline-container .bar-timeline {\n position: absolute;\n cursor: move;\n cursor: grab;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .timeline-container .bar-timeline .bar-handle {\n height: 100%;\n width: 5px;\n position: absolute;\n z-index: 1000;\n background: transparent;\n }\n\n .timeline-container .bar-timeline .bar-handle:hover {\n cursor: col-resize;\n }\n\n .resizing {\n pointer-events: none;\n opacity: 0.8;\n }\n\n .timeline-container .bar-timeline .bar-handle.handle-left {\n left: -5px;\n }\n\n .timeline-container .bar-timeline .bar-handle.handle-right {\n right: -5px;\n }\n\n .timeline-container .bar-timeline.dragging {\n cursor: grabbing;\n }\n\n .timeline-container .bar-baseline {\n position: absolute;\n pointer-events: none;\n z-index: 1;\n }\n\n .timeline-container .bar-timeline.bar-critical {\n background-color: var(--critical-bar-color, #e53935) !important;\n }\n\n .timeline-container .bar-timeline.bar-critical .bar-timeline-progress {\n background-color: color-mix(in srgb, var(--critical-bar-color, #e53935) 70%, white) !important;\n }\n\n svg path.critical-arrow {\n stroke: var(--critical-arrow-color, #e53935) !important;\n stroke-width: 2.5 !important;\n }\n\n .bar-timeline .bar-timeline-progress {\n position: absolute;\n pointer-events: none;\n height: 100%;\n left: 0;\n }\n\n .bar-timeline .bar-label {\n white-space: nowrap;\n pointer-events: none;\n overflow: hidden;\n z-index: 2;\n }\n\n .timeline-container .timeline-body {\n width: max-content;\n position: relative;\n padding-bottom: 17px;\n }\n \n .timeline-container .timeline-header-row,\n .timeline-container .timeline-data-row {\n display: flex;\n }\n\n .timeline-container .timeline-header-cell,\n .timeline-container .timeline-data-cell {\n padding: 0 10px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n justify-content: center;\n border: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n color: var(--text-color, #000);\n }\n\n .timeline-container .timeline-header-cell {\n background-color: var(--header-bg-color, #F3F3F3);\n color: var(--header-text-color, #333);\n }\n",ie='\n #apexgantt-tooltip-container,\n [role="tooltip"] {\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s ease;\n font-family: inherit;\n font-size: 13px;\n line-height: 1.4;\n display: none;\n width: 300px !important;\n max-width: 300px !important;\n box-sizing: border-box;\n }\n \n #apexgantt-tooltip-container.visible,\n [role="tooltip"].visible {\n display: block;\n opacity: 1;\n visibility: visible;\n }\n \n #apexgantt-tooltip-container .tooltip-content,\n [role="tooltip"] .tooltip-content {\n padding: 12px 16px;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);\n width: 100%;\n word-wrap: break-word;\n overflow-wrap: break-word;\n box-sizing: border-box;\n display: block;\n border: 1px solid rgba(255, 255, 255, 0.1);\n }\n \n /* Shadow DOM specific adjustments */\n :host #apexgantt-tooltip-container,\n :host [role="tooltip"] {\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s ease;\n font-family: inherit;\n font-size: 13px;\n line-height: 1.4;\n display: none;\n width: 300px !important;\n max-width: 300px !important;\n box-sizing: border-box;\n }\n \n :host #apexgantt-tooltip-container.visible,\n :host [role="tooltip"].visible {\n display: block;\n opacity: 1;\n visibility: visible;\n }\n\n #apexgantt-tooltip-container .tooltip-content div,\n [role="tooltip"] .tooltip-content div {\n margin: 6px 0;\n word-break: break-word;\n line-height: 1.4;\n }\n \n #apexgantt-tooltip-container .tooltip-content strong,\n [role="tooltip"] .tooltip-content strong {\n font-weight: 600;\n display: inline;\n margin-right: 8px;\n }\n \n #apexgantt-tooltip-container .tooltip-content span,\n [role="tooltip"] .tooltip-content span {\n display: inline;\n }\n \n /* First item (Name) styling */\n #apexgantt-tooltip-container .tooltip-content div:first-child,\n [role="tooltip"] .tooltip-content div:first-child {\n margin-bottom: 10px;\n padding-bottom: 8px;\n border-bottom: 1px solid rgba(255, 255, 255, 0.2);\n }\n \n #apexgantt-tooltip-container .tooltip-content div:first-child strong,\n [role="tooltip"] .tooltip-content div:first-child strong {\n font-weight: 700;\n }\n \n #apexgantt-tooltip-container .tooltip-content div:last-child,\n [role="tooltip"] .tooltip-content div:last-child {\n margin-bottom: 0;\n }\n';class oe{constructor(t,e,n,i,o,r){this.element=t,this.domCache=e,this.options=n,this.chartContext=i,this.isShadowDOM=o,this.instanceId=r,this.stylesInjected=!1}setupShadowDOMEnvironment(){if(!this.isShadowDOM)return;const t=this.chartContext.getContext().host;t&&(t.style.display="block",t.style.boxSizing="border-box",t.style.contain="layout style"),this.element&&(this.element.style.display="block",this.element.style.boxSizing="border-box")}injectGanttStyles(){if(!this.stylesInjected)if(this.isShadowDOM)this.injectStylesDirectly();else try{const t=[{content:Zt,id:"gantt-core-styles",options:{priority:"high"}},{content:ne,id:"gantt-timeline-styles"},{content:ee,id:"gantt-table-styles"},{content:Gt,id:"gantt-dialog-styles"},{content:te,id:"gantt-taskform-styles"},{content:ie,id:"gantt-tooltip-styles"},{content:a,id:"gantt-toolbar-styles"},{content:Qt,id:"gantt-dropdown-styles"},{content:Jt,id:"gantt-scrollbar-styles"}];this.chartContext.injectStylesheets(t),this.stylesInjected=!0}catch(t){R.error("injectGanttStyles: ChartContext injection failed",t)}}injectStylesDirectly(){const t=this.chartContext.getContext();if(t.querySelector("#gantt-all-styles"))return void(this.stylesInjected=!0);const e=document.createElement("style");e.id="gantt-all-styles",e.textContent=`\n /* Shadow DOM CSS Reset - Critical for proper layout */\n :host {\n all: initial;\n display: block;\n contain: layout style;\n }\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n div, table, thead, tbody, tr, td, th {\n display: revert;\n margin: 0;\n padding: 0;\n border: 0;\n }\n\n .split-view-container,\n .gantt-container {\n display: flex !important;\n width: 100% !important;\n height: 100% !important;\n }\n\n .split-left-container,\n .split-right-container {\n display: block !important;\n }\n\n .timeline-container {\n flex: 1 !important;\n overflow: auto !important;\n position: relative !important;\n }\n\n .tasks-container {\n flex-shrink: 0 !important;\n overflow: auto !important;\n }\n\n ${Zt}\n ${ne}\n ${ee}\n ${Gt}\n ${te}\n ${ie}\n ${a}\n ${Qt}\n ${Jt}\n `,t.insertBefore(e,t.firstChild),this.stylesInjected=!0}setCSSVariables(){["--apex-gantt-bar-fill","--apex-gantt-background-color","--apex-gantt-row-bg-even","--apex-gantt-row-bg-odd","--apex-gantt-header-bg","--apex-gantt-grid-line","--apex-gantt-dependency-line","--apex-gantt-font-family","--apex-gantt-font-size","--apex-gantt-font-color"].forEach((t=>this.element.style.removeProperty(t)));const t=Dt(this.element),e=t.gridLine||this.options.cellBorderColor,n=this.options.cellBorderWidth,i=t.fontColor||this.options.fontColor,o=t.headerBg||this.options.headerBackground,{tooltipBGColor:r,tooltipBorderColor:a,borderColor:s,barTextColor:l}=this.options,c=t.bgColor||this.options.backgroundColor,d=t.barFill||this.options.barBackgroundColor,h=t.dependencyLine||this.options.arrowColor,p=[...this.options.rowBackgroundColors??[]];t.rowBgEven&&(p[0]=t.rowBgEven),t.rowBgOdd&&(p[1]=t.rowBgOdd),this.element.style.setProperty("--apex-gantt-row-bg-even",p[0]??""),this.element.style.setProperty("--apex-gantt-row-bg-odd",p[1]??p[0]??""),this.element.style.setProperty("--cell-border-color",e),this.element.style.setProperty("--cell-border-width",n),this.element.style.setProperty("--gantt-font-color",i),this.element.style.setProperty("--text-color",i),this.element.style.setProperty("--header-bg-color",o),this.element.style.setProperty("--header-text-color",i),this.element.style.setProperty("--tooltip-bg-color",r),this.element.style.setProperty("--tooltip-border-color",a),this.element.style.setProperty("--tooltip-text-color",i),this.element.style.setProperty("--background-color",c),this.element.style.setProperty("--border-color",s),this.element.style.setProperty("--dialog-bg-color",c),this.element.style.setProperty("--dialog-border-color",s),this.element.style.setProperty("--button-bg-color",d),this.element.style.setProperty("--button-text-color",l),this.element.style.setProperty("--button-hover-bg-color",h),this.element.style.setProperty("--toolbar-bg-color",c),this.element.style.setProperty("--toolbar-border-color",s),this.element.style.setProperty("--toolbar-hover-bg-color",e),this.element.style.setProperty("--scrollbar-track-color",c),this.element.style.setProperty("--scrollbar-thumb-color",s),this.element.style.setProperty("--scrollbar-thumb-hover-color",e),this.element.style.setProperty("--split-bar-color",e),this.element.style.setProperty("--split-bar-hover-color",h),this.element.style.setProperty("--split-bar-border-color",s),this.element.style.setProperty("--split-bar-handle-color",i),this.element.style.setProperty("--split-bar-hover-border-color",h),this.element.style.setProperty("--critical-bar-color",this.options.criticalBarColor),this.element.style.setProperty("--critical-arrow-color",this.options.criticalArrowColor);this.isColorDark(c)?this.element.style.setProperty("--toolbar-icon-filter","invert(1) brightness(2)"):this.element.style.setProperty("--toolbar-icon-filter","none")}handleWatermark(){const t=this.domCache.ganttContainer;if(!t)return;const e=t.parentNode;e&&(r.isLicenseValid()?l.remove(e):l.add(e))}isColorDark(t){const e=t.replace("#","");return(.299*parseInt(e.substring(0,2),16)+.587*parseInt(e.substring(2,4),16)+.114*parseInt(e.substring(4,6),16))/255<.5}cleanupScrollbarStyles(){try{this.chartContext.getInjectedStyleIds().filter((t=>t.startsWith(`scrollbar-${this.instanceId}`))).forEach((t=>this.chartContext.removeStyles(t)));const t=this.domCache.horizontalScroll;if(t){const e=t.style.width,n=t.style.left,i=t.style.bottom;t.removeAttribute("style"),e&&(t.style.width=e),n&&(t.style.left=n),i&&(t.style.bottom=i)}}catch(t){R.warn("Error cleaning up scrollbar styles:",t)}}updateOptions(t){this.options=t}resetStylesInjected(){this.stylesInjected=!1}areStylesInjected(){return this.stylesInjected}}const re="data-taskid",ae="aria-level";class se{constructor(t,e,n,i,o){this.chartContext=t,this.dataManager=e,this.getTaskContainer=n,this.reRender=i,this.selectionManager=o,this.keydownHandler=null}attach(){this.detach();const t=this.getTaskContainer();t&&(this.initRovingTabindex(t),this.keydownHandler=e=>this.handleKeydown(e,t),t.addEventListener("keydown",this.keydownHandler))}detach(){const t=this.getTaskContainer();t&&this.keydownHandler&&t.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null}initRovingTabindex(t){this.getVisibleRows(t).forEach(((t,e)=>{t.setAttribute("tabindex",0===e?"0":"-1")}))}getVisibleRows(t){return Array.from(t.querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`))}moveFocusToRow(t,e){this.getVisibleRows(e).forEach((t=>t.setAttribute("tabindex","-1"))),t.setAttribute("tabindex","0"),t.focus()}handleKeydown(t,e){var n;const i=this.getVisibleRows(e);if(0===i.length)return;const o=this.chartContext.getActiveElement(),r=o?i.indexOf(o):-1;switch(t.key){case"ArrowDown":{t.preventDefault();const n=i[Math.min(r+1,i.length-1)];n&&this.moveFocusToRow(n,e);break}case"ArrowUp":{t.preventDefault();const n=i[Math.max(r-1,0)];n&&this.moveFocusToRow(n,e);break}case"ArrowRight":{if(t.preventDefault(),r<0||!o)break;const n=o.getAttribute(re);if(!n)break;const a=o.getAttribute("aria-expanded");if("false"===a)this.dataManager.toggleTask(n),this.reRender();else if("true"===a){const t=parseInt(o.getAttribute(ae)||"1",10),n=i[r+1];if(n){parseInt(n.getAttribute(ae)||"1",10)>t&&this.moveFocusToRow(n,e)}}break}case"ArrowLeft":{if(t.preventDefault(),r<0||!o)break;const n=o.getAttribute(re);if(!n)break;if("true"===o.getAttribute("aria-expanded"))this.dataManager.toggleTask(n),this.reRender();else{const t=parseInt(o.getAttribute(ae)||"1",10);if(t<=1)break;for(let n=r-1;n>=0;n--){const o=i[n];if(parseInt(o.getAttribute(ae)||"1",10)<t){this.moveFocusToRow(o,e);break}}}break}case"Home":{t.preventDefault();const n=i[0];n&&this.moveFocusToRow(n,e);break}case"End":{t.preventDefault();const n=i[i.length-1];n&&this.moveFocusToRow(n,e);break}case" ":{if(t.preventDefault(),!o)break;const e=o.getAttribute(re)?o:o.closest(`[${re}]`),n=(null==e?void 0:e.getAttribute(re))??null;if(!n)break;if(this.selectionManager)t.shiftKey?this.selectionManager.handleClick(n,{ctrlKey:!1,metaKey:!1,shiftKey:!0}):this.selectionManager.toggleTask(n);else{const t=e,n="true"===t.getAttribute("aria-selected");t.setAttribute("aria-selected",n?"false":"true")}break}case"a":if(!t.ctrlKey&&!t.metaKey)break;t.preventDefault(),null==(n=this.selectionManager)||n.selectAll();break;case"Enter":{if(t.preventDefault(),!o)break;const e=o.getAttribute(re);if(!e)break;const n=this.chartContext.querySelector(`[data-taskid="${CSS.escape(e)}"].bar-timeline`);n&&n.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0}));break}case"Escape":this.selectionManager&&this.selectionManager.getSelectedIds().size>0?this.selectionManager.clearSelection():o&&o.blur()}}}class le{constructor(t,e,n){this.chartContext=t,this.dataManager=e,this.getElement=n,this.selectedIds=new Set,this.lastClickedId=null}getSelectedTasks(){return Array.from(this.selectedIds).map((t=>this.dataManager.getTaskById(t))).filter((t=>null!==t))}getSelectedIds(){return new Set(this.selectedIds)}setSelectedTasks(t){const e=new Set(this.selectedIds);this.selectedIds.clear(),t.forEach((t=>{this.dataManager.getTaskById(t)&&this.selectedIds.add(t)})),this.syncDom(),this.emitChange(e)}clearSelection(){if(0===this.selectedIds.size)return;const t=new Set(this.selectedIds);this.selectedIds.clear(),this.lastClickedId=null,this.syncDom(),this.emitChange(t)}toggleTask(t){const e=new Set(this.selectedIds);this.selectedIds.has(t)?this.selectedIds.delete(t):this.selectedIds.add(t),this.lastClickedId=t,this.syncDom(),this.emitChange(e)}handleClick(t,e){const n=new Set(this.selectedIds);e.shiftKey&&this.lastClickedId?this.rangeSelect(this.lastClickedId,t):e.ctrlKey||e.metaKey?(this.selectedIds.has(t)?this.selectedIds.delete(t):this.selectedIds.add(t),this.lastClickedId=t):(this.selectedIds.clear(),this.selectedIds.add(t),this.lastClickedId=t),this.syncDom(),this.emitChange(n)}selectAll(){const t=new Set(this.selectedIds),e=this.dataManager.getFlatVisibleTasks();this.selectedIds.clear(),e.forEach((t=>this.selectedIds.add(t.id))),this.syncDom(),this.emitChange(t)}selectGroup(t){const e=new Set(this.selectedIds),n=this.dataManager.getNestedChildTasks(t,!0);this.selectedIds.add(t),n.forEach((t=>this.selectedIds.add(t.id))),this.syncDom(),this.emitChange(e)}isSelected(t){return this.selectedIds.has(t)}restoreAfterRender(){const t=new Set;this.selectedIds.forEach((e=>{this.dataManager.getTaskById(e)&&t.add(e)})),this.selectedIds=t,this.syncDom()}captureState(){return Array.from(this.selectedIds)}restoreState(t){this.selectedIds=new Set(t)}destroy(){this.selectedIds.clear(),this.lastClickedId=null}rangeSelect(t,e){const n=this.dataManager.getFlatVisibleTasks(),i=n.findIndex((e=>e.id===t)),o=n.findIndex((t=>t.id===e));if(-1===i||-1===o)return;const r=Math.min(i,o),a=Math.max(i,o);for(let t=r;t<=a;t++)this.selectedIds.add(n[t].id)}syncDom(){this.getElement().querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`).forEach((t=>{const e=t.getAttribute("data-taskid");if(!e)return;const n=this.selectedIds.has(e);t.setAttribute("aria-selected",n?"true":"false");const i=t.querySelector(".gantt-selection-checkbox");i&&(i.checked=n)})),this.syncSelectAllCheckbox()}syncSelectAllCheckbox(){const t=this.getElement().querySelector(".gantt-select-all-checkbox");if(!t)return;const e=this.dataManager.getFlatVisibleTasks().length,n=this.selectedIds.size;0===n?(t.checked=!1,t.indeterminate=!1):n>=e?(t.checked=!0,t.indeterminate=!1):(t.checked=!1,t.indeterminate=!0)}emitChange(t){if(this.setsEqual(t,this.selectedIds))return;const e={selectedTasks:this.getSelectedTasks(),selectedIds:Array.from(this.selectedIds),timestamp:Date.now()};this.getElement().dispatchEvent(new CustomEvent(K.SELECTION_CHANGE,{detail:e,bubbles:!0,cancelable:!1}))}setsEqual(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}}class ce{constructor(t){this._scrollTop=0,this._rowHeight=Math.max(1,t.rowHeight),this._overscan=Math.max(0,t.overscan??5),this._totalRows=Math.max(0,t.totalRows),this._containerHeight=Math.max(0,t.containerHeight)}getVisibleRange(){if(0===this._totalRows)return{startIndex:0,endIndex:-1};const t=Math.floor(this._scrollTop/this._rowHeight),e=Math.max(0,t-this._overscan),n=Math.ceil(this._containerHeight/this._rowHeight);return{startIndex:e,endIndex:Math.min(this._totalRows-1,t+n-1+this._overscan)}}getTotalHeight(){return this._totalRows*this._rowHeight}getOffsetForIndex(t){return t*this._rowHeight}getTopSpacerHeight(){const{startIndex:t}=this.getVisibleRange();return t*this._rowHeight}getBottomSpacerHeight(){if(0===this._totalRows)return 0;const{endIndex:t}=this.getVisibleRange();return Math.max(0,(this._totalRows-1-t)*this._rowHeight)}getVisibleCount(){const{startIndex:t,endIndex:e}=this.getVisibleRange();return e<t?0:e-t+1}setScrollTop(t){this._scrollTop=Math.max(0,t)}setTotalRows(t){this._totalRows=Math.max(0,t)}setContainerHeight(t){this._containerHeight=Math.max(0,t)}setOverscan(t){this._overscan=Math.max(0,t)}get scrollTop(){return this._scrollTop}get totalRows(){return this._totalRows}get containerHeight(){return this._containerHeight}get rowHeight(){return this._rowHeight}get overscan(){return this._overscan}}const de="virtualizer-top-spacer",he="virtualizer-bottom-spacer",pe=`.${de}`,ue=`.${he}`,ge="data-taskid";class me{constructor(t,e,n,i,o,r,a=(()=>{})){this.domRefs=t,this.options=e,this.chartContext=n,this.dataManager=i,this.getViewMode=o,this.onAfterUpdate=r,this.onToggle=a,this.cachedVisibleTasks=[],this.lastVisibleRange=null,this.virtualScrollRAF=null,this.verticalScrollHandler=null,this._isActive=!1,this.renderedTaskIds=new Set,this.virtualizer=new ce({rowHeight:e.rowHeight,totalRows:0,containerHeight:0})}get isActive(){return this._isActive}getRenderedTaskIds(){return this.renderedTaskIds}initialise(t){this.cachedVisibleTasks=t;const{rowHeight:e,height:n}=this.options,i="number"==typeof n?Math.max(n-100,200):600,o=Math.ceil(i/e);if(this.virtualizer=new ce({rowHeight:e,totalRows:t.length,containerHeight:i,overscan:o}),t.length<=50)return void(this._isActive=!1);this._isActive=!0;const r=this.virtualizer.getVisibleRange();return this.lastVisibleRange=r,this.renderedTaskIds=new Set(t.slice(r.startIndex,r.endIndex+1).map((t=>t.id))),{allTasks:t,range:r,rowHeight:e}}attach(){const{verticalScrollContainer:t}=this.domRefs;if(!t||!this._isActive)return;const e=t.clientHeight;e>0&&(this.virtualizer.setContainerHeight(e),this.virtualizer.setOverscan(Math.ceil(e/this.options.rowHeight))),this.detach(),this.verticalScrollHandler=()=>{const e=t.scrollTop;this.scheduleUpdate(e)},t.addEventListener("scroll",this.verticalScrollHandler,{passive:!0})}detach(){const{verticalScrollContainer:t}=this.domRefs;t&&this.verticalScrollHandler&&t.removeEventListener("scroll",this.verticalScrollHandler),this.verticalScrollHandler=null,null!==this.virtualScrollRAF&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(this.virtualScrollRAF),this.virtualScrollRAF=null),this.lastVisibleRange=null}destroy(){this.detach(),this.cachedVisibleTasks=[],this.renderedTaskIds.clear(),this._isActive=!1}updateTotalRows(t){if(this.cachedVisibleTasks=t,!this._isActive)return;this.virtualizer.setTotalRows(t.length);const e=Math.max(0,t.length*this.virtualizer.rowHeight-this.virtualizer.containerHeight);if(this.virtualizer.scrollTop>e){this.virtualizer.setScrollTop(e);const{verticalScrollContainer:t}=this.domRefs;t&&(t.scrollTop=e)}const n=this.virtualizer.getVisibleRange();this.lastVisibleRange=n,this.applyUpdate(n)}expandAllForExport(){if(!this._isActive)return null;const t=this.cachedVisibleTasks,{rowHeight:e}=this.options,n={startIndex:0,endIndex:t.length-1},i=this.domRefs.tasksDataContainer;if(i){this.patchTasksPanel(t,n,e);const o=i.querySelector(pe),r=i.querySelector(ue);o&&(o.style.height="0px"),r&&(r.style.height="0px")}const o=this.domRefs.timelineBody;if(o){this.patchTimelinePanel(t,n,e);const i=o.querySelector(pe),r=o.querySelector(ue);i&&(i.style.height="0px"),r&&(r.style.height="0px")}this.patchBars(t,n,e);const r=this.lastVisibleRange;return r?{startIndex:r.startIndex,endIndex:r.endIndex}:null}restoreAfterExport(t){if(!this._isActive)return;const e=t??this.virtualizer.getVisibleRange();this.applyUpdate(e)}handleResize(){if(!this._isActive)return;const{verticalScrollContainer:t}=this.domRefs;t&&this.virtualizer.setContainerHeight(t.clientHeight);const e=this.virtualizer.getVisibleRange();this.lastVisibleRange&&e.startIndex===this.lastVisibleRange.startIndex&&e.endIndex===this.lastVisibleRange.endIndex||(this.lastVisibleRange=e,this.applyUpdate(e))}updateDomRefs(t){this.domRefs=t}scheduleUpdate(t){this.virtualizer.setScrollTop(t),this.cachedVisibleTasks.length<=50||(null!==this.virtualScrollRAF&&"undefined"!=typeof cancelAnimationFrame&&cancelAnimationFrame(this.virtualScrollRAF),"undefined"!=typeof requestAnimationFrame?this.virtualScrollRAF=requestAnimationFrame((()=>{this.virtualScrollRAF=null,this.applyIfChanged()})):this.applyIfChanged())}applyIfChanged(){const t=this.virtualizer.getVisibleRange();this.lastVisibleRange&&t.startIndex===this.lastVisibleRange.startIndex&&t.endIndex===this.lastVisibleRange.endIndex||(this.lastVisibleRange=t,this.applyUpdate(t))}applyUpdate(t){const e=this.cachedVisibleTasks,{rowHeight:n}=this.options;0!==e.length&&(this.patchTasksPanel(e,t,n),this.patchTimelinePanel(e,t,n),this.patchBars(e,t,n),this.onAfterUpdate())}patchTasksPanel(t,e,n){const i=this.domRefs.tasksDataContainer;if(!i)return;const{startIndex:o,endIndex:r}=e,a=t.slice(o,r+1),s=new Set(a.map((t=>t.id))),l=Array.from(i.querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`)),c=new Map;l.forEach((t=>{const e=t.getAttribute(ge);e&&c.set(e,t)}));const d=new ht(this.options,this.chartContext,this.dataManager);a.forEach(((t,e)=>{if(!c.has(t.id)){const n=o+e,r=d.generateRow(t,this.onToggle,n+1);i.appendChild(r)}})),c.forEach(((t,e)=>{s.has(e)||i.removeChild(t)})),this.updateSpacers(i,o,r,t.length,n);const h=Array.from(i.querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`)),p=new Map;t.forEach(((t,e)=>p.set(t.id,e))),h.sort(((t,e)=>{const n=t.getAttribute(ge)||"",i=e.getAttribute(ge)||"";return(p.get(n)??0)-(p.get(i)??0)}));const u=i.querySelector(ue)||null;h.forEach((t=>{i.insertBefore(t,u)})),h.forEach(((t,e)=>{t.setAttribute("aria-rowindex",(o+e+1).toString())})),this.renderedTaskIds=s}patchTimelinePanel(t,e,n){const i=this.domRefs.timelineBody;if(!i)return;const{startIndex:o,endIndex:r}=e,a=t.slice(o,r+1),s=new Set(a.map((t=>t.id))),l=Array.from(i.querySelectorAll(`${Pt.timelineDataRow}:not(${Pt.timelineEmptyRow})`)),c=new Map;l.forEach((t=>{const e=t.getAttribute(ge);e&&c.set(e,t)}));const d=this.getTimelineCellCount();if(0===d)return;const h=new Et(this.getViewMode(),this.options,this.chartContext,this.dataManager);a.forEach((t=>{if(!c.has(t.id)){const e=h.generateRow(t.id,d);i.appendChild(e)}})),c.forEach(((t,e)=>{s.has(e)||i.removeChild(t)})),this.updateSpacers(i,o,r,t.length,n);const p=new Map;t.forEach(((t,e)=>p.set(t.id,e)));const u=Array.from(i.querySelectorAll(`${Pt.timelineDataRow}:not(${Pt.timelineEmptyRow})`));u.sort(((t,e)=>{const n=t.getAttribute(ge)||"",i=e.getAttribute(ge)||"";return(p.get(n)??0)-(p.get(i)??0)}));const g=i.querySelector(ue)||null;u.forEach((t=>{i.insertBefore(t,g)}))}patchBars(t,e,n){const i=this.domRefs.barContainer;if(!i)return;const{startIndex:o,endIndex:r}=e,a=this.dataManager.getDateRange(8,this.getViewMode()),s=t.length*n,l=t.slice(o,r+1),c=new Set(l.map((t=>t.id))),d=Array.from(i.querySelectorAll(`[${ge}]`)),h=new Map;d.forEach((t=>{const e=t.getAttribute(ge);e&&h.set(e,t)}));const p=this.chartContext.getChartContainer();l.forEach(((t,e)=>{if(!h.has(t.id)){const n=o+e,r=new J(t,a[0],this.options,this.getViewMode(),n,this.chartContext,this.dataManager),s=r.drawBar(((t,e)=>{st(this.chartContext,this.dataManager,t,e,this.options,this.getViewMode(),a[0])}));i.appendChild(s),p&&Ct(s,0,p);const l=r.drawBaselineBar();l&&i.appendChild(l)}})),h.forEach(((t,e)=>{c.has(e)||i.removeChild(t)})),i.style.height=`${s}px`,i.style.width="100%"}updateSpacers(t,e,n,i,o){let r=t.querySelector(pe);r||(r=this.chartContext.createElement("div"),r.className=de,t.insertBefore(r,t.firstChild)),r.style.height=e*o+"px";let a=t.querySelector(ue);a||(a=this.chartContext.createElement("div"),a.className=he,t.appendChild(a));const s=Math.max(0,(i-1-n)*o);a.style.height=`${s}px`}getTimelineCellCount(){var t;const e=null==(t=this.domRefs.timelineBodyWrapper)?void 0:t.closest(".timeline-container");if(!e)return 0;const n=e.querySelectorAll(".timeline-header-row"),i=n[n.length-1];return i?i.querySelectorAll(".timeline-header-cell").length:0}}w.extend(S),w.extend(k),w.extend(B),w.extend(A),w.extend(I);const be="dependencyArrowUpdate";class fe extends n{constructor(t,e){super(t,"gantt_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options=U,this.containerResizeObserver=null,this.lastKnownWidth=0,this.lastKnownHeight=0,this.resizeDebounceTimer=null,this.dependencyArrowHandler=null,this.rowHoverHandler=null,this.rowHoverLeaveHandler=null,this._afterActionsRafId=null,this.criticalPathResult=null,this.domCache={ganttContainer:null,timelineContainer:null,timelineBody:null,timelineBodyWrapper:null,timelineHeader:null,horizontalScroll:null,horizontalScrollContent:null,tasksContainer:null,tasksBodyWrapper:null,tasksHeader:null,tasksDataContainer:null,splitBar:null,actionsContainer:null},this.keyboardNavigationManager=null,this.selectionManager=null,this.virtualScrollCoordinator=null,this.reducedMotionMQL=null,this.reducedMotionHandler=null;const n=j(null==e?void 0:e.theme);let i;(null==e?void 0:e.parsing)?Nt.validateConfig(e.parsing)?i=Nt.parse(e.series,e.parsing):(R.error("ApexGantt: Invalid parsing configuration provided"),i=[]):i=(null==e?void 0:e.series)||[],this.options={...n,...e,baseline:{...n.baseline,...null==e?void 0:e.baseline},series:i},this.viewMode=this.options.viewMode;const o="arrows_"+crypto.randomUUID().replace(/-/g,"").substring(0,9);this.arrowLink=new At(o),this.dataManager=new ut,this.dataManager.setTasks(this.options.series),this.dataManager.setArrowLinkInstanceId(o),this.stateManager=new Ot,this.styleManager=new oe(this.element,this.domCache,this.options,this.chartContext,this.isShadowDOM(),this.getInstanceId()),this.scrollManager=new Yt(this.element,this.options,this.domCache,this.chartContext,this.getInstanceId(),(()=>this.viewMode)),this.layoutManager=new Xt(this.element,this.options,this.domCache,this.chartContext,this.getInstanceId(),(()=>this.viewMode));const r={onViewModeChange:t=>{this.viewMode=t},onToolbarUpdate:()=>{const t=this.domCache.actionsContainer;t&&this.renderToolbar(t)},onTimelineRerender:()=>{this.rerenderTimeline()},onDependencyArrowsRender:()=>{this.renderDependencyArrows(),this.fadeArrowsAfterAnimation(),this.computeCriticalPath(),this.applyCriticalPathHighlighting()},onScrollbarUpdate:()=>{this.scrollManager.updateHorizontalScrollbarContent()},onScrollbarPosition:()=>{this.scrollManager.positionHorizontalScrollbar()}};this.zoomManager=new _t(this.element,this.domCache,this.chartContext,this.getInstanceId(),(()=>this.viewMode),r),this.styleManager.setupShadowDOMEnvironment(),this.options.enableSelection&&(this.selectionManager=new le(this.chartContext,this.dataManager,(()=>this.element))),this.keyboardNavigationManager=new se(this.chartContext,this.dataManager,(()=>this.domCache.tasksDataContainer),(()=>this.render()),this.selectionManager??void 0),this.setupReducedMotion()}static setLicense(t){r.setLicense(t)}setupReducedMotion(){if("undefined"==typeof window||!window.matchMedia)return;this.reducedMotionMQL=window.matchMedia("(prefers-reduced-motion: reduce)");const t=t=>{t?this.element.classList.add("gantt-reduced-motion"):this.element.classList.remove("gantt-reduced-motion")};t(this.reducedMotionMQL.matches),this.reducedMotionHandler=e=>t(e.matches),this.reducedMotionMQL.addEventListener("change",this.reducedMotionHandler)}initializeTooltip(){const{enableTooltip:t,tooltipId:e}=this.options;if(t){const t=p(this.chartContext,e);if(!this.chartContext.getElementById(e)){R.warn("Tooltip init: Tooltip not found after creation, appending manually");this.chartContext.getAppendContainer().appendChild(t)}}}render(t){var e,n;if(!this.element)throw new Error("Element not found");this.virtualScrollCoordinator&&this.virtualScrollCoordinator.detach();const i=this.element&&this.element.children.length>0;i&&this.stateManager.captureState(this.element,this.dataManager,this.viewMode,null==(e=this.selectionManager)?void 0:e.captureState());const{enableResize:o,tasksContainerWidth:r,height:a,width:s}=this.options,l=Dt(this.element),c=l.fontColor||this.options.fontColor,d=l.fontFamily||this.options.fontFamily,h=l.fontSize||this.options.fontSize,{fontWeight:p}=this.options;this.layoutManager.setupChartContainerPositioning(),this.styleManager.injectGanttStyles(),this.styleManager.setCSSVariables(),this.initializeTooltip();const u=new Set(Array.from(this.element.querySelectorAll(".bar-timeline[data-taskid]")).map((t=>t.getAttribute("data-taskid"))));this.element.innerHTML="";const g=this.normalizeDimension(a),b=this.normalizeDimension(s);this.element.style.width=b,this.element.style.height=g,this.element.style.display="flex",this.element.style.flexDirection="column",this.element.style.boxSizing="border-box",this.element.style.overflow="hidden",this.element.style.setProperty("color",c),this.element.style.setProperty("font-family",d),this.element.style.setProperty("font-size",h),this.element.style.setProperty("font-weight",p);const f=m(this.chartContext,{className:Pt.actionsContainer.slice(1)});this.renderToolbar(f);const y=m(this.chartContext,{className:Pt.ganttContainer.slice(1)}),v=this.dataManager.getFlatVisibleTasks();this.initVirtualScrollCoordinator();const w=null==(n=this.virtualScrollCoordinator)?void 0:n.initialise(v),x=new Et(this.viewMode,this.options,this.chartContext,this.dataManager).render(w,u),k=new ht(this.options,this.chartContext,this.dataManager,this.selectionManager??void 0).render(this.render.bind(this),w);x&&this.layoutManager.createLayout(y,k,x,o,r),this.element.appendChild(f),this.element.appendChild(y);const C=this.element.querySelector(Pt.horizontalScroll);C&&(C.remove(),this.element.appendChild(C)),this.styleManager.handleWatermark(),this.cacheDomElements(),this.setupRowBackgroundColors(),this.zoomManager.setupZoomEventListener(),this.setupDependencyArrowEvents(),this.renderDependencyArrows();const S=new Set(v.map((t=>t.id))),E=u.size>0?new Set([...u,...S].filter((t=>!u.has(t)||!S.has(t)))):void 0;return this.fadeArrowsAfterAnimation(!1,E),this.computeCriticalPath(),this.applyCriticalPathHighlighting(),this._afterActionsRafId=requestAnimationFrame((()=>{this._afterActionsRafId=null,this.performAfterActions()})),i&&requestAnimationFrame((()=>{this.stateManager.restoreState(this.element)})),this.element}cacheDomElements(){var t;this.domCache.ganttContainer=this.element.querySelector(Pt.ganttContainer),this.domCache.timelineContainer=this.element.querySelector(Pt.timelineContainer),this.domCache.timelineBody=this.element.querySelector(Pt.timelineBody),this.domCache.timelineBodyWrapper=this.element.querySelector(Pt.timelineBodyWrapper),this.domCache.timelineHeader=this.element.querySelector(Pt.timelineHeader),this.domCache.horizontalScroll=this.element.querySelector(Pt.horizontalScroll),this.domCache.horizontalScrollContent=(null==(t=this.domCache.horizontalScroll)?void 0:t.querySelector(Pt.horizontalScrollContent))||null,this.domCache.tasksContainer=this.element.querySelector(Pt.tasksContainer),this.domCache.tasksBodyWrapper=this.element.querySelector(Pt.tasksBodyWrapper),this.domCache.tasksHeader=this.element.querySelector(Pt.tasksHeader),this.domCache.tasksDataContainer=this.element.querySelector(Pt.tasksDataContainer),this.domCache.splitBar=this.element.querySelector(Pt.splitBar),this.domCache.actionsContainer=this.element.querySelector(Pt.actionsContainer)}clearDomCache(){this.domCache.ganttContainer=null,this.domCache.timelineContainer=null,this.domCache.timelineBody=null,this.domCache.timelineBodyWrapper=null,this.domCache.timelineHeader=null,this.domCache.horizontalScroll=null,this.domCache.horizontalScrollContent=null,this.domCache.tasksContainer=null,this.domCache.tasksBodyWrapper=null,this.domCache.tasksHeader=null,this.domCache.tasksDataContainer=null,this.domCache.splitBar=null,this.domCache.actionsContainer=null}performAfterActions(){var t,e,n;if(!this.isDestroyed()){if(this.cacheDomElements(),this.layoutManager.syncTasksColumnWidths(),this.scrollManager.compensateForScrollbar(),this.scrollManager.updateHorizontalScrollbarContent(),this.scrollManager.setupTimelineHorizontalScroll(),this.scrollManager.positionHorizontalScrollbar(),this.setupContainerResizeObserver(),this.scrollManager.setupScrollbarResizeObserver(),this.setupRowBackgroundColors(),this.setupRowHoverSync(),this.scrollManager.disableHeaderMousewheelScroll(),(null==(t=this.virtualScrollCoordinator)?void 0:t.isActive)||this.layoutManager.fillEmptyRowsAfterRender(),this.virtualScrollCoordinator){const t=this.element.querySelector(".split-view-container")??this.domCache.ganttContainer;this.virtualScrollCoordinator.updateDomRefs({tasksDataContainer:this.domCache.tasksDataContainer,timelineBody:this.domCache.timelineBody,barContainer:this.element.querySelector(Pt.barContainer),tasksBodyWrapper:this.domCache.tasksBodyWrapper,timelineBodyWrapper:this.domCache.timelineBodyWrapper,verticalScrollContainer:t}),this.virtualScrollCoordinator.attach()}null==(e=this.keyboardNavigationManager)||e.attach(),null==(n=this.selectionManager)||n.restoreAfterRender()}}initVirtualScrollCoordinator(){this.virtualScrollCoordinator&&this.virtualScrollCoordinator.destroy(),this.virtualScrollCoordinator=new me({tasksDataContainer:null,timelineBody:null,barContainer:null,tasksBodyWrapper:null,timelineBodyWrapper:null,verticalScrollContainer:null},this.options,this.chartContext,this.dataManager,(()=>this.viewMode),(()=>{this.setupRowBackgroundColors(),this.renderDependencyArrows(),this.fadeArrowsAfterAnimation(),this.applyCriticalPathHighlighting()}),(()=>this.render()))}setupRowHoverSync(){const t=this.domCache.ganttContainer;if(!t)return;this.rowHoverHandler&&(t.removeEventListener("mousemove",this.rowHoverHandler),this.rowHoverHandler=null),this.rowHoverLeaveHandler&&(t.removeEventListener("mouseleave",this.rowHoverLeaveHandler),this.rowHoverLeaveHandler=null);const e=this.chartContext.getInstanceId(),n=`${Pt.tasksDataRow}[data-chart-instance="${e}"]`,i=`${Pt.timelineDataRow}[data-chart-instance="${e}"]`,o=getComputedStyle(this.element).getPropertyValue("--row-hover-color").trim()||"rgba(0,0,0,0.06)",r=(t,e)=>{const r=this.element.querySelector(`${n}[data-taskid="${t}"]`),a=this.element.querySelector(`${i}[data-taskid="${t}"]`);for(const t of[r,a])t&&(e?(t.dataset.origBg||(t.dataset.origBg=t.style.backgroundColor),t.style.backgroundColor=o):(t.style.backgroundColor=t.dataset.origBg??"",delete t.dataset.origBg))};let a=null;const s=t=>{const o=t.target,s=null==o?void 0:o.closest(`${n}, ${i}`),l=null==o?void 0:o.closest(`[data-taskid][data-chart-instance="${e}"]`),c=(null==s?void 0:s.dataset.taskid)??(null==l?void 0:l.dataset.taskid)??null;c!==a&&(a&&r(a,!1),a=c,a&&r(a,!0))},l=e=>{const{relatedTarget:n}=e;n&&t.contains(n)||(a&&r(a,!1),a=null)};this.rowHoverHandler=s,this.rowHoverLeaveHandler=l,t.addEventListener("mousemove",s),t.addEventListener("mouseleave",l)}setupRowBackgroundColors(){var t;const e=new Map,n=Dt(this.element),i=[...this.options.rowBackgroundColors];n.rowBgEven&&(i[0]=n.rowBgEven),n.rowBgOdd&&(i[1]=n.rowBgOdd);const o=(null==(t=this.virtualScrollCoordinator)?void 0:t.isActive)?this.virtualScrollCoordinator.getRenderedTaskIds():null;this.dataManager.getTopParentTasks().forEach(((t,n)=>{const r=t.rowBackgroundColor||rt(n,i);e.set(t.id,r),o&&!o.has(t.id)||at(this.chartContext,t.id,r)})),this.dataManager.getFlatTasks().forEach((t=>{if(o&&!o.has(t.id))return;if(!t.parentId){if(t.type===ct.Milestone&&!e.has(t.id)){const e=t.rowBackgroundColor||rt(0,i);at(this.chartContext,t.id,e)}return}let n=this.dataManager.getTaskById(t.parentId);for(;null==n?void 0:n.parentId;)n=this.dataManager.getTaskById(n.parentId);const r=n?n.id:t.parentId,a=t.rowBackgroundColor||(e.get(r??"")??"");at(this.chartContext,t.id,a)}))}fadeArrowsAfterAnimation(t=!1,e){var n;const i=`timeline-arrows-${this.arrowLink.getInstanceId()}`;!function(t,e,n=!1,i){if(!t)return;const o=kt(e);if(i&&i.size>0){const e=Array.from(t.querySelectorAll("path[data-edgeid]")).filter((t=>{const[e,n]=(t.getAttribute("data-edgeid")??"").split("-");return i.has(e)||i.has(n)}));if(0===e.length)return;return n||o?void e.forEach((t=>t.style.opacity="1")):(e.forEach((t=>t.style.opacity="0")),void setTimeout((()=>{e.forEach((t=>{"function"==typeof t.animate?t.animate([{opacity:"0"},{opacity:"1"}],{duration:150,easing:"ease-out",fill:"forwards"}).finished.then((()=>{t.style.opacity="1",t.getAnimations().forEach((t=>t.cancel()))})).catch((()=>{})):t.style.opacity="1"}))}),200))}n||o?t.style.opacity="1":(t.style.opacity="0",setTimeout((()=>{"function"==typeof t.animate?t.animate([{opacity:"0"},{opacity:"1"}],{duration:150,easing:"ease-out",fill:"forwards"}).finished.then((()=>{t.style.opacity="1",t.getAnimations().forEach((t=>t.cancel()))})).catch((()=>{})):t.style.opacity="1"}),200))}((null==(n=this.domCache.timelineBody)?void 0:n.querySelector(`#${i}`))??null,this.element,t,e)}renderDependencyArrows(){var t;const{rowHeight:e,barMargin:n}=this.options,i=this.getInstanceId(),o=this.arrowLink.getInstanceId(),r=this.domCache.timelineBody;if(!r)return void R.warn(`[${i}] Timeline body not found for arrows`);const a=`timeline-arrows-${o}`,s=r.querySelector(`#${a}`);s&&s.remove();const l=this.dataManager.getFlatVisibleTasks(),c=l.filter((t=>!!t.dependency));if(0===c.length)return;const d=new Map;l.forEach(((t,e)=>d.set(t.id,e)));const[h]=this.dataManager.getDateRange(8,this.viewMode),p=e-2*n,u=(t,i)=>{const o=J.calculateX(t,h,this.viewMode,this.options),r=J.calculateWidth(t,this.viewMode,this.options),a=n+i*e;return{left:o,right:o+r,top:a,bottom:a+p,width:r,height:p}},g=(null==(t=this.virtualScrollCoordinator)?void 0:t.isActive)?this.virtualScrollCoordinator.getRenderedTaskIds():null,m=c.flatMap((t=>{const{taskId:e,type:n,lag:i}=dt(t.dependency);if(g&&!g.has(e)&&!g.has(t.id))return[];const o=this.dataManager.getTaskById(e),r=d.get(e),a=d.get(t.id);if(!o||void 0===r||void 0===a)return[];return[{id:`${e}-${t.id}`,sourceRect:u(o,r),targetRect:u(t,a),dependencyType:n,lagPx:i}]}));if(0===m.length)return;const b=l.length*e;this.arrowLink.renderFromRects(r,m,{arrowColor:this.options.arrowColor,height:Math.max(b,r.clientHeight),paddingY:e/2,width:(r.scrollWidth||r.clientWidth)+40},this.chartContext)}setupDependencyArrowEvents(){const t=this.getInstanceId(),e=this.arrowLink.getInstanceId();this.dependencyArrowHandler&&this.chartContext.removeEventListener(be,this.dependencyArrowHandler),this.dependencyArrowHandler=n=>{const i=n;if(i.detail.chartInstanceId!==t)return;const o=i.detail.arrowLinkInstanceId||e,r=function(t,e,n,i,o="FS",r=38){const a=t.getInstanceId(),s=H(t,e),l=H(t,n);if(!s||!l)return R.warn(`[${a}] Arrow source or target not found: ${e} -> ${n}`),!1;const c=t.querySelector(`.timeline-body[data-chart-instance="${a}"]`),d=`timeline-arrows-${i}`,h=null==c?void 0:c.querySelector(`#${d}`);return h?(At.updateArrow(s,l,h,{paddingX:20,paddingY:r/2},`${e}-${n}`,o),!0):(R.warn(`[${a}] Arrow SVG not found: ${d}`),!1)}(this.chartContext,i.detail.fromId,i.detail.toId,o,i.detail.type,this.options.rowHeight);r||(this.renderDependencyArrows(),this.fadeArrowsAfterAnimation(!0))},this.chartContext.addEventListener(be,this.dependencyArrowHandler);const n=()=>{this.computeCriticalPath(),this.chartContext.querySelectorAll(".bar-critical").forEach((t=>t.classList.remove("bar-critical"))),this.chartContext.querySelectorAll(".critical-arrow").forEach((t=>t.classList.remove("critical-arrow"))),this.applyCriticalPathHighlighting()},i=this.chartContext.getChartContainer();i&&(i.removeEventListener(K.TASK_DRAGGED,n),i.removeEventListener(K.TASK_RESIZED,n),i.addEventListener(K.TASK_DRAGGED,n),i.addEventListener(K.TASK_RESIZED,n))}computeCriticalPath(){this.options.enableCriticalPath&&(this.criticalPathResult=function(t,e){if(0===t.length||0===e.length)return $t;const n=e.filter((t=>"FS"===t.type));if(0===n.length)return $t;const i=new Map;for(const e of t)i.set(e.id,e);const o=new Map,r=new Map,a=new Map;for(const e of t)a.set(e.id,0),o.set(e.id,[]),r.set(e.id,[]);for(const t of n)i.has(t.fromId)&&i.has(t.toId)&&(o.get(t.fromId).push(t),r.get(t.toId).push(t),a.set(t.toId,(a.get(t.toId)??0)+1));const s=[];for(const[t,e]of a)0===e&&s.push(t);const l=[];for(;s.length>0;){const t=s.shift();l.push(t);for(const e of o.get(t)??[]){const t=(a.get(e.toId)??0)-1;a.set(e.toId,t),0===t&&s.push(e.toId)}}if(l.length!==t.length)return $t;const c=new Map,d=new Map;for(const t of l){const e=i.get(t);if(!e)continue;const n=It(e.startTime,e.endTime??e.startTime);let o=0;for(const e of r.get(t)??[]){const t=d.get(e.fromId)??0;o=Math.max(o,t+e.lag+1)}c.set(t,o),d.set(t,o+n-1)}let h=0;for(const t of d.values())t>h&&(h=t);const p=new Map,u=new Map;for(const t of[...l].reverse()){const e=i.get(t);if(!e)continue;const n=It(e.startTime,e.endTime??e.startTime),r=o.get(t)??[];let a=h;for(const t of r){const e=u.get(t.toId)??h;a=Math.min(a,e-t.lag-1)}p.set(t,a),u.set(t,a-n+1)}const g=new Set;for(const t of l)0==(u.get(t)??0)-(c.get(t)??0)&&g.add(t);const m=new Set;for(const t of n)if(g.has(t.fromId)&&g.has(t.toId)){const e=d.get(t.fromId)??0,n=c.get(t.toId)??0;e+t.lag+1===n&&m.add(`${t.fromId}->${t.toId}`)}return{criticalTaskIds:g,criticalEdgeKeys:m}}(this.dataManager.getTasks(),this.dataManager.getAllDependencies()))}applyCriticalPathHighlighting(){var t,e;if(!this.options.enableCriticalPath||!this.criticalPathResult)return;for(const e of this.criticalPathResult.criticalTaskIds)null==(t=H(this.chartContext,e))||t.classList.add("bar-critical");const n=this.domCache.timelineBody;for(const t of this.criticalPathResult.criticalEdgeKeys){const[i,o]=t.split("->");null==(e=null==n?void 0:n.querySelector(`[data-edgeid="${i}-${o}"]`))||e.classList.add("critical-arrow")}}rerenderTimeline(){var t;const e=this.domCache.timelineContainer;if(!e)return;const n=new Map;this.element.querySelectorAll(".bar-timeline[data-taskid]").forEach((t=>{const e=t.getAttribute("data-taskid");n.set(e,{left:parseFloat(t.style.left)||0,width:parseFloat(t.style.width)||0})}));const i=this.dataManager.getFlatVisibleTasks(),o=null==(t=this.virtualScrollCoordinator)?void 0:t.initialise(i),r=new Set(i.map((t=>t.id))),a=this.domCache.timelineHeader,s=this.domCache.timelineBodyWrapper;if(a&&s){a.innerHTML="",s.innerHTML="";const t=new Et(this.viewMode,this.options,this.chartContext,this.dataManager).render(o,r);if(t){const e=t[0];a.innerHTML=e.innerHTML;for(let e=1;e<t.length-1;e++)s.appendChild(t[e])}}else{e.innerHTML="";const t=new Et(this.viewMode,this.options,this.chartContext,this.dataManager).render(o,r);if(t){const n=t[0];e.appendChild(n);const i=m(this.chartContext,{className:Pt.timelineBodyWrapper.slice(1)});for(let e=1;e<t.length-1;e++)i.appendChild(t[e]);e.appendChild(i)}}this.cacheDomElements(),this.cancelPendingAfterActionsRaf(),this._afterActionsRafId=requestAnimationFrame((()=>{if(this._afterActionsRafId=null,n.size>0){const t=this.element;this.element.querySelectorAll(".bar-timeline[data-taskid]").forEach((e=>{const i=e.getAttribute("data-taskid"),o=n.get(i);o&&function(t,e,n,i){if(kt(i))return;if("function"!=typeof t.animate)return;if(e.left===n.left&&e.width===n.width)return;const o=t.animate([{left:`${e.left}px`,width:`${e.width}px`},{left:`${n.left}px`,width:`${n.width}px`}],{duration:200,easing:"ease-in-out",fill:"forwards"});o.finished.then((()=>o.cancel())).catch((()=>{}))}(e,o,{left:parseFloat(e.style.left)||0,width:parseFloat(e.style.width)||0},t)}))}this.performAfterActions()}))}cancelPendingAfterActionsRaf(){null!=this._afterActionsRafId&&(cancelAnimationFrame(this._afterActionsRafId),this._afterActionsRafId=null)}cleanupEventListeners(){var t,e;try{this.dependencyArrowHandler&&(this.chartContext.removeEventListener(be,this.dependencyArrowHandler),this.dependencyArrowHandler=null),this.rowHoverHandler&&(null==(t=this.domCache.ganttContainer)||t.removeEventListener("mousemove",this.rowHoverHandler),this.rowHoverHandler=null),this.rowHoverLeaveHandler&&(null==(e=this.domCache.ganttContainer)||e.removeEventListener("mouseleave",this.rowHoverLeaveHandler),this.rowHoverLeaveHandler=null);const n=this.domCache.timelineContainer;if(null==n?void 0:n.parentNode){const t=n.cloneNode(!0);n.parentNode.replaceChild(t,n)}}catch(t){R.warn("Error cleaning up event listeners:",t)}}cleanupTooltips(){try{const{enableTooltip:t,tooltipId:e}=this.options;if(t){const t=this.chartContext.getElementById(e);t&&(t.style.display="none",t.innerHTML="",t.removeAttribute("style"),t.classList.remove("visible"),t.setAttribute("aria-hidden","true"),this.isShadowDOM()&&t.remove())}}catch(t){R.warn("Error cleaning up tooltips:",t)}}cleanupDependencyArrows(){try{const t=this.domCache.timelineBody;if(t&&this.arrowLink){const e=this.arrowLink.getInstanceId(),n=`timeline-arrows-${e}`,i=t.querySelector(`#${n}`);i&&i.remove();t.querySelectorAll("[data-edgeid]").forEach((t=>{const n=t.getAttribute("marker-end");(null==n?void 0:n.includes(`arrowhead-${e}`))&&t.remove()}))}}catch(t){R.warn("Error cleaning up dependency arrows:",t)}}createActionButton(t,e,n=!1){const i=this.chartContext.createElement("button");return i.className="gantt-action-button",i.innerHTML=t,i.title=e,i.disabled=n,i.setAttribute("aria-label",e),i}createSeparator(){const t=this.chartContext.createElement("div");return t.className="gantt-action-separator",t}createViewModeDisplay(){const t=this.chartContext.createElement("div");t.className="gantt-view-mode-display";const e=this.viewMode.charAt(0).toUpperCase()+this.viewMode.slice(1);return t.innerHTML=`${Lt.calendar} <span>${e}</span>`,t.title=`Current view: ${e}`,t}renderToolbar(t){t.innerHTML="";const e=[],n=()=>{var t;return{selectedTasks:(null==(t=this.selectionManager)?void 0:t.getSelectedTasks())??[]}},i=(this.options.toolbarItems??[]).filter((t=>"left"===(t.position??"right")));i.length>0&&(i.forEach((i=>{const o=this.createToolbarItem(i,n,e);o&&t.append(o)})),t.append(this.createSeparator()));const o=this.createActionButton(Lt.zoomIn,"Zoom In",this.viewMode===L[0]);o.addEventListener("click",(()=>this.zoomIn()));const r=this.createActionButton(Lt.zoomOut,"Zoom Out",this.viewMode===L[L.length-1]);r.addEventListener("click",(()=>this.zoomOut()));const a=this.createViewModeDisplay();if(t.append(o,r,this.createSeparator(),a),this.options.enableSelection&&this.selectionManager){const n=this.chartContext.createElement("div");n.className="gantt-selection-count";const i=this.selectionManager.getSelectedIds().size;n.textContent=i>0?`${i} selected`:"",n.style.display=i>0?"":"none",e.push((()=>{var t;const e=(null==(t=this.selectionManager)?void 0:t.getSelectedIds().size)??0;n.textContent=e>0?`${e} selected`:"",n.style.display=e>0?"":"none"})),t.append(n)}const s=(this.options.toolbarItems??[]).filter((t=>"right"===(t.position??"right")));if(s.length>0&&(t.append(this.createSeparator()),s.forEach((i=>{const o=this.createToolbarItem(i,n,e);o&&t.append(o)}))),this.options.enableExport){const e=this.chartContext.createElement("div");e.className="gantt-actions-spacer",t.append(e);const n=this.createActionButton(Lt.download,"Export as SVG");n.addEventListener("click",(()=>{var t;const e=this.element;if(!e)return R.error("Export failed: Chart element not found"),void alert("Export failed: Chart not found. Please refresh and try again.");if(e.querySelector(Pt.ganttContainer))try{const n=(null==(t=this.virtualScrollCoordinator)?void 0:t.expandAllForExport())??null;zt(e).finally((()=>{var t;null==(t=this.virtualScrollCoordinator)||t.restoreAfterExport(n)}))}catch(t){R.error("Export error:",t),alert("Export failed. Please check the console for details.")}else R.error("Export failed: Gantt container not found in chart")})),t.append(n)}e.length>0&&this.element.addEventListener(K.SELECTION_CHANGE,(()=>{e.forEach((t=>t()))}))}createToolbarItem(t,e,n){return"separator"===t.type?this.createSeparator():"button"===t.type?this.createToolbarButton(t,e,n):"select"===t.type?this.createToolbarSelect(t,e):null}createToolbarButton(t,e,n){const i=this.chartContext.createElement("button");i.className="gantt-action-button gantt-toolbar-button",t.tooltip?(i.title=t.tooltip,i.setAttribute("aria-label",t.tooltip)):t.label&&i.setAttribute("aria-label",t.label);const o=()=>{i.innerHTML=(()=>{const n=e().selectedTasks.length,i=t.showCount&&n>0?` (${n})`:"",o=t.label?`<span>${t.label}${i}</span>`:"";return`${t.icon??""}${o}`})(),i.disabled=t.requiresSelection?0===e().selectedTasks.length:"function"==typeof t.disabled?t.disabled(e()):t.disabled??!1};o(),i.addEventListener("click",(()=>{i.disabled||t.onClick(e())}));return(t.requiresSelection||"function"==typeof t.disabled||t.showCount)&&n.push(o),i}createToolbarSelect(t,e){const n=this.chartContext.createElement("div");if(n.className="gantt-toolbar-select-wrapper",t.label){const e=this.chartContext.createElement("span");e.className="gantt-toolbar-select-label",e.textContent=t.label,n.append(e)}const i=this.chartContext.createElement("select");if(i.className="gantt-toolbar-select",t.placeholder){const e=this.chartContext.createElement("option");e.value="",e.textContent=t.placeholder,e.disabled=!0,e.selected=!0,i.append(e)}return t.options.forEach((({value:t,text:e})=>{const n=this.chartContext.createElement("option");n.value=t,n.textContent=e,i.append(n)})),i.addEventListener("change",(()=>{t.onChange(i.value,e())})),n.append(i),n}update(t){var e;this.element&&!this.isDestroyed()&&this.stateManager.captureState(this.element,this.dataManager,this.viewMode,null==(e=this.selectionManager)?void 0:e.captureState());const n=this.detectCurrentTheme(),i=t.theme,o=i&&i!==n,r=this.stateManager.hasState()?this.stateManager.getViewMode():this.viewMode,a=new Set(Object.keys(t).filter((e=>void 0===t[e]))),s=Object.fromEntries(Object.entries(t).filter((([,t])=>void 0!==t))),l=j(i||n);let c,d;if(o){this.styleManager.cleanupScrollbarStyles();const t={series:this.options.series,parsing:this.options.parsing,width:this.options.width,height:this.options.height,viewMode:this.options.viewMode,rowHeight:this.options.rowHeight,tasksContainerWidth:this.options.tasksContainerWidth,inputDateFormat:this.options.inputDateFormat,annotations:this.options.annotations,enableSelection:this.options.enableSelection,enableExport:this.options.enableExport,enableResize:this.options.enableResize,enableTaskDrag:this.options.enableTaskDrag,enableTaskEdit:this.options.enableTaskEdit,enableTaskResize:this.options.enableTaskResize,enableTooltip:this.options.enableTooltip,tooltipTemplate:this.options.tooltipTemplate,canvasStyle:this.options.canvasStyle};c={...l,...t,...s},c.baseline={...l.baseline,...t.baseline??l.baseline,...s.baseline??{}}}else{const t=Object.fromEntries(Object.entries(this.options).filter((([t])=>!a.has(t))));c={...l,...t,...s},c.baseline={...l.baseline,...t.baseline??l.baseline,...s.baseline??{}}}t.viewMode||(c.viewMode=r),c.parsing?Nt.validateConfig(c.parsing)?d=Nt.parse(c.series,c.parsing):(R.error("ApexGantt: Invalid parsing configuration provided in update()"),d=this.options.series):d=c.series?c.series:this.options.series,this.options={...c,series:d},this.viewMode=this.options.viewMode,this.dataManager.setTasks(this.options.series),this.styleManager.updateOptions(this.options),this.scrollManager.updateOptions(this.options),this.layoutManager.updateOptions(this.options),this.render(),this.element&&!this.isDestroyed()&&this.stateManager.restoreState(this.element)}detectCurrentTheme(){const t=this.options.backgroundColor;return this.styleManager.isColorDark(t)?"dark":"light"}updateTask(t,e){if(!this.dataManager.getTaskById(t))throw new Error(`Task with ID ${t} not found`);const[n]=this.dataManager.getDateRange(0,this.viewMode);st(this.chartContext,this.dataManager,t,e,this.options,this.viewMode,n)}getSelectedTasks(){var t;return(null==(t=this.selectionManager)?void 0:t.getSelectedTasks())??[]}setSelectedTasks(t){var e;null==(e=this.selectionManager)||e.setSelectedTasks(t)}clearSelection(){var t;null==(t=this.selectionManager)||t.clearSelection()}zoomIn(){this.zoomManager.zoomIn()}zoomOut(){this.zoomManager.zoomOut()}normalizeDimension(t){return"number"==typeof t?`${t}px`:t}setupContainerResizeObserver(){if(!this.element)return;this.containerResizeObserver&&this.containerResizeObserver.disconnect();const t=this.normalizeDimension(this.options.width),e=this.normalizeDimension(this.options.height),n="string"==typeof t&&t.includes("%"),i="string"==typeof e&&e.includes("%");(n||i)&&(this.lastKnownWidth=this.element.offsetWidth,this.lastKnownHeight=this.element.offsetHeight,this.containerResizeObserver=new ResizeObserver((t=>{for(const e of t){const t=e.contentRect.width,n=e.contentRect.height,i=Math.abs(t-this.lastKnownWidth)>1,o=Math.abs(n-this.lastKnownHeight)>1;(i||o)&&(this.lastKnownWidth=t,this.lastKnownHeight=n,this.handleContainerResize())}})),this.containerResizeObserver.observe(this.element))}handleContainerResize(){null!==this.resizeDebounceTimer&&window.clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout((()=>{this.performResize(),this.resizeDebounceTimer=null}),150)}performResize(){if(!this.element||this.isDestroyed())return;const t=this.normalizeDimension(this.options.width),e=this.normalizeDimension(this.options.height),n="string"==typeof t&&t.includes("%"),i="string"==typeof e&&e.includes("%");if(n){window.getComputedStyle(this.element.parentElement||this.element).width!==window.getComputedStyle(this.element).width&&requestAnimationFrame((()=>{this.scrollManager.positionHorizontalScrollbar(),this.scrollManager.updateHorizontalScrollbarContent(),this.layoutManager.syncTasksColumnWidths()}))}i&&requestAnimationFrame((()=>{this.layoutManager.fillEmptyRowsAfterRender()}))}destroy(){var t,e;try{this.virtualScrollCoordinator&&(this.virtualScrollCoordinator.destroy(),this.virtualScrollCoordinator=null),this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),null!==this.resizeDebounceTimer&&(window.clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null),this.cancelPendingAfterActionsRaf(),this.zoomManager.cleanup(),this.scrollManager.cleanup(),null==(t=this.keyboardNavigationManager)||t.detach(),null==(e=this.selectionManager)||e.destroy(),this.reducedMotionMQL&&this.reducedMotionHandler&&(this.reducedMotionMQL.removeEventListener("change",this.reducedMotionHandler),this.reducedMotionMQL=null,this.reducedMotionHandler=null),this.cleanupEventListeners(),this.cleanupTooltips(),this.cleanupDependencyArrows(),this.element.innerHTML="",this.clearDomCache(),super.destroy()}catch(t){R.error("Error during ApexGantt destruction:",t)}}isDestroyed(){return!this.element||""===this.element.innerHTML}}const ye={tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#CCCCCC",tooltipTextColor:"#333333",cellBorderColor:"#E3EDF8",rowBackgroundColors:["#FFFFFF","#F5F9FF"],headerBackground:"#EBF3FB",headerTextColor:"#333333",barBackgroundColor:"#318CE7",barTextColor:"#FFFFFF",arrowColor:"#1A6FC4",backgroundColor:"#FFFFFF",textColor:"#000000",borderColor:"#DFE0E1",annotationBgColor:"#DBEAFE",annotationBorderColor:"#60A5FA",dialogBgColor:"#FFFFFF",dialogBorderColor:"#EEEEEE",buttonBgColor:"#318CE7",buttonTextColor:"#FFFFFF",buttonHoverBgColor:"#1A6FC4",toolbarBgColor:"#FFFFFF",toolbarBorderColor:"#BCBCBC",toolbarHoverBgColor:"#F0F7FF",scrollbarTrackColor:"#F5F5F5",scrollbarThumbColor:"#C1C1C1",scrollbarThumbHoverColor:"#A8A8A8",splitBarColor:"#DEE2E6",splitBarHoverColor:"#318CE7",splitBarBorderColor:"#BBBBBB",splitBarHandleColor:"#666666"},ve={tooltipBGColor:"#2D2D2D",tooltipBorderColor:"#444444",tooltipTextColor:"#E0E0E0",cellBorderColor:"#3A3A3A",rowBackgroundColors:["#1E1E1E","#252525"],headerBackground:"#2A2A2A",headerTextColor:"#E0E0E0",barBackgroundColor:"#818CF8",barTextColor:"#FFFFFF",arrowColor:"#A5B4FC",backgroundColor:"#1E1E1E",textColor:"#E0E0E0",borderColor:"#3A3A3A",annotationBgColor:"#4A2D4D",annotationBorderColor:"#8B4D8F",dialogBgColor:"#2D2D2D",dialogBorderColor:"#444444",buttonBgColor:"#6366F1",buttonTextColor:"#FFFFFF",buttonHoverBgColor:"#4F46E5",toolbarBgColor:"#2D2D2D",toolbarBorderColor:"#444444",toolbarHoverBgColor:"#3A3A3A",scrollbarTrackColor:"#000",scrollbarThumbColor:"#4A4A4A",scrollbarThumbHoverColor:"#5A5A5A",splitBarColor:"#3A3A3A",splitBarHoverColor:"#818CF8",splitBarBorderColor:"#4A4A4A",splitBarHandleColor:"#666666"};function we(t){return"dark"===t?ve:ye}"undefined"!=typeof window&&(window.ApexGantt=fe);export{fe as ApexGantt,tt as ColumnKey,nt as ColumnList,ve as DarkTheme,Nt as DataParser,K as GanttEvents,ye as LightTheme,O as Orientation,ct as TaskType,P as ViewMode,fe as default,we as getTheme};
|
|
1
|
+
const t=()=>{};class e{constructor(t,e){this.injectedStyles=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),n=Array.from(e);return{item:t=>n[t]||null,get length(){return n.length},[Symbol.iterator]:()=>n[Symbol.iterator](),...Object.fromEntries(n.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,n):this.context.addEventListener(t,e,n)}removeEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,n):this.context.removeEventListener(t,e,n)}injectStyles(t,e,n={}){const{force:i=!1,priority:o="normal"}=n;if(!i&&this.injectedStyles.has(e))return;if(i){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!i)return void this.injectedStyles.add(e);const r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==o&&r.setAttribute("data-priority",o),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===o?t.insertBefore(r,t.firstChild):t.appendChild(r)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:n})=>{this.injectStyles(t,e,n)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}destroy(){this.removeAllStyles(),this.injectedStyles.clear()}}class n{constructor(t,n){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new e(t,n)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,n){this.chartContext.addEventListener(t,e,n)}removeEventListener(t,e,n){this.chartContext.removeEventListener(t,e,n)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}const i=globalThis.console;const o=class{static decodeLicenseData(t){try{const e=window.atob(t),n=JSON.parse(e);return n.issueDate&&n.expiryDate&&n.plan?{domains:Array.isArray(n.domains)?n.domains:void 0,expiryDate:n.expiryDate,issueDate:n.issueDate,plan:n.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,n="standard",i){const o={expiryDate:e,issueDate:t,plan:n};i&&i.length>0&&(o.domains=i);return`APEX-${window.btoa(JSON.stringify(o))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,i.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.split("-");if(2!==e.length)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=e[1],i=this.decodeLicenseData(n);if(!i)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const o=new Date;if(new Date(i.expiryDate)<o)return{data:i,expired:!0,message:`License expired on ${i.expiryDate}. Please renew your license.`,valid:!1};if(i.domains&&i.domains.length>0){const t="undefined"!=typeof window?window.location.hostname:"";if(!i.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:i,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${i.domains.join(", ")}.`,valid:!1}}return{data:i,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};o.licenseKey=null,o.validationResult=null;let r=o;const a="\n #toolbar {\n display: flex;\n gap: 5px;\n position: absolute;\n right: 10px;\n top: 10px;\n z-index: 100;\n }\n \n .toolbar-item {\n align-items: center;\n background-color: var(--toolbar-bg-color, #FFFFFF);\n border: 1px solid var(--toolbar-border-color, #BCBCBC);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n border-radius: 3px;\n transition: all 0.2s ease;\n position: relative;\n }\n \n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--toolbar-border-color, #999);\n transform: translateY(-1px);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n }\n \n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);\n }\n \n .toolbar-item:focus {\n outline: none;\n border-color: var(--button-bg-color, #0066cc);\n box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);\n }\n \n .toolbar-item img {\n width: 16px;\n height: 16px;\n pointer-events: none;\n filter: var(--toolbar-icon-filter, none);\n }\n \n .toolbar-item[disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n }\n \n /* Tooltip styles */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: -35px;\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, #333);\n color: var(--tooltip-text-color, white);\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 12px;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s ease;\n z-index: 1000;\n }\n \n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: -25px;\n left: 50%;\n transform: translateX(-50%);\n border: 5px solid transparent;\n border-bottom-color: var(--tooltip-bg-color, #333);\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s ease;\n z-index: 1000;\n }\n \n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n \n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 5px;\n position: absolute;\n right: 10px;\n top: 10px;\n z-index: 100;\n }\n",s=class{static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text \n x="50%" \n y="50%" \n dominant-baseline="middle" \n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};s.WATERMARK_ATTR="data-apexcharts-watermark",s.WATERMARK_TEXT="APEXCHARTS";let l=s;function c(t){const e=t.getRootNode();return e instanceof ShadowRoot?e.host:t.parentElement}function d(t,e){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),o=function(t){let e=1,n=1,i=0,o=0,r=t.parentElement;for(;r&&r!==document.body&&r!==document.documentElement;){const t=window.getComputedStyle(r),a=t.scale;if(a&&"none"!==a){const t=a.split(" ").map(parseFloat);1===t.length?(e*=t[0],n*=t[0]):t.length>=2&&(e*=t[0],n*=t[1])}const s=t.transform;if(s&&"none"!==s)try{const t=new DOMMatrix(s);e*=t.a,n*=t.d,i+=t.e,o+=t.f}catch{}r=c(r)}return{scaleX:e,scaleY:n,translateX:i,translateY:o}}(e),r=function(t){const e=window.getComputedStyle(t);let n=1,i=1,o=0,r=0,a=0;const s=e.scale;if(s&&"none"!==s){const t=s.split(" ").map(parseFloat);1===t.length?(n=t[0],i=t[0]):t.length>=2&&(n=t[0],i=t[1])}const l=e.transform;if(l&&"none"!==l)try{const t=new DOMMatrix(l);n*=t.a,i*=t.d,o=t.e,r=t.f,a=Math.atan2(t.b,t.a)}catch{}return{scaleX:n,scaleY:i,translateX:o,translateY:r,rotation:a}}(t),a=o.scaleX||1,s=o.scaleY||1,l=(n.left-i.left)/a,d=(n.top-i.top)/s,h=n.width/a,p=n.height/s;if(Math.abs(r.rotation)>.01){const t=l+h/2,e=d+p/2;return{left:t,right:t,top:e,bottom:e,width:0,height:0}}return{left:l,right:l+h,top:d,bottom:d+p,width:h,height:p}}const h="aria-hidden",p=(t,e="apex-tooltip-container")=>{let n=t.getElementById(e);if(!n){n=t.createElement("div"),n.id=e,n.setAttribute("role","tooltip"),n.setAttribute(h,"true");t.getAppendContainer().appendChild(n)}return n},u=(t,e="",n,i="")=>{const o=t.getElementById(e);if(!o)return p(t,e),u(t,e,n,i);if(n&&i){const t=i.includes("tooltip-content"),e=n.match(/background-color:\s*([^;]+);?/),r=n.match(/color:\s*([^;]+);?/),a=e?e[1]:"#333",s=r?r[1]:"white";o.innerHTML=t?i:`<div class="tooltip-content" style="background-color: ${a}; color: ${s};">${i}</div>`;const l=n+"; display: block !important; visibility: visible !important; opacity: 1 !important;";o.setAttribute("style",l),o.classList.add("visible"),o.setAttribute(h,"false")}else o.removeAttribute("style"),o.classList.remove("visible"),o.setAttribute(h,"true"),o.innerHTML=""},g=(t={})=>{const e=[];for(const i in t){const o=`${n=i,n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[i]};`;e.push(o)}var n;return e.join(" ")};function m(t,{className:e="",content:n,style:i={}}={}){const o=b(t,"div",{className:e,innerHTML:n||""});return o.setAttribute("style",g(i)),o}function b(t,e,n={}){const i=t.createElement(e);return Object.assign(i,n)}function f(t,e){if(!t)return"#000000";3===(t=t.replace(/^#/,"")).length&&(t=t.split("").map((t=>t+t)).join(""));const n=parseInt(t,16);let i=n>>16&255,o=n>>8&255,r=255&n;return e*=.299*i+.587*o+.114*r<100?-1:1,i=Math.min(255,Math.max(0,i+e)),o=Math.min(255,Math.max(0,o+e)),r=Math.min(255,Math.max(0,r+e)),`#${(1<<24|i<<16|o<<8|r).toString(16).slice(1)}`}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var v={exports:{}};v.exports=function(){var t=1e3,e=6e4,n=36e5,i="millisecond",o="second",r="minute",a="hour",s="day",l="week",c="month",d="quarter",h="year",p="date",u="Invalid Date",g=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},f=function(t,e,n){var i=String(t);return!i||i.length>=e?t:""+Array(e+1-i.length).join(n)+t},y={s:f,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),i=Math.floor(n/60),o=n%60;return(e<=0?"+":"-")+f(i,2,"0")+":"+f(o,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var i=12*(n.year()-e.year())+(n.month()-e.month()),o=e.clone().add(i,c),r=n-o<0,a=e.clone().add(i+(r?-1:1),c);return+(-(i+(n-o)/(r?o-a:a-o))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:l,d:s,D:p,h:a,m:r,s:o,ms:i,Q:d}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},v="en",w={};w[v]=b;var x="$isDayjsObject",k=function(t){return t instanceof M||!(!t||!t[x])},C=function t(e,n,i){var o;if(!e)return v;if("string"==typeof e){var r=e.toLowerCase();w[r]&&(o=r),n&&(w[r]=n,o=r);var a=e.split("-");if(!o&&a.length>1)return t(a[0])}else{var s=e.name;w[s]=e,o=s}return!i&&o&&(v=o),o||!i&&v},S=function(t,e){if(k(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new M(n)},E=y;E.l=C,E.i=k,E.w=function(t,e){return S(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var M=function(){function b(t){this.$L=C(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[x]=!0}var f=b.prototype;return f.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(E.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var i=e.match(g);if(i){var o=i[2]-1||0,r=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],o,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)):new Date(i[1],o,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)}}return new Date(e)}(t),this.init()},f.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},f.$utils=function(){return E},f.isValid=function(){return!(this.$d.toString()===u)},f.isSame=function(t,e){var n=S(t);return this.startOf(e)<=n&&n<=this.endOf(e)},f.isAfter=function(t,e){return S(t)<this.startOf(e)},f.isBefore=function(t,e){return this.endOf(e)<S(t)},f.$g=function(t,e,n){return E.u(t)?this[e]:this.set(n,t)},f.unix=function(){return Math.floor(this.valueOf()/1e3)},f.valueOf=function(){return this.$d.getTime()},f.startOf=function(t,e){var n=this,i=!!E.u(e)||e,d=E.p(t),u=function(t,e){var o=E.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return i?o:o.endOf(s)},g=function(t,e){return E.w(n.toDate()[t].apply(n.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},m=this.$W,b=this.$M,f=this.$D,y="set"+(this.$u?"UTC":"");switch(d){case h:return i?u(1,0):u(31,11);case c:return i?u(1,b):u(0,b+1);case l:var v=this.$locale().weekStart||0,w=(m<v?m+7:m)-v;return u(i?f-w:f+(6-w),b);case s:case p:return g(y+"Hours",0);case a:return g(y+"Minutes",1);case r:return g(y+"Seconds",2);case o:return g(y+"Milliseconds",3);default:return this.clone()}},f.endOf=function(t){return this.startOf(t,!1)},f.$set=function(t,e){var n,l=E.p(t),d="set"+(this.$u?"UTC":""),u=(n={},n[s]=d+"Date",n[p]=d+"Date",n[c]=d+"Month",n[h]=d+"FullYear",n[a]=d+"Hours",n[r]=d+"Minutes",n[o]=d+"Seconds",n[i]=d+"Milliseconds",n)[l],g=l===s?this.$D+(e-this.$W):e;if(l===c||l===h){var m=this.clone().set(p,1);m.$d[u](g),m.init(),this.$d=m.set(p,Math.min(this.$D,m.daysInMonth())).$d}else u&&this.$d[u](g);return this.init(),this},f.set=function(t,e){return this.clone().$set(t,e)},f.get=function(t){return this[E.p(t)]()},f.add=function(i,d){var p,u=this;i=Number(i);var g=E.p(d),m=function(t){var e=S(u);return E.w(e.date(e.date()+Math.round(t*i)),u)};if(g===c)return this.set(c,this.$M+i);if(g===h)return this.set(h,this.$y+i);if(g===s)return m(1);if(g===l)return m(7);var b=(p={},p[r]=e,p[a]=n,p[o]=t,p)[g]||1,f=this.$d.getTime()+i*b;return E.w(f,this)},f.subtract=function(t,e){return this.add(-1*t,e)},f.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||u;var i=t||"YYYY-MM-DDTHH:mm:ssZ",o=E.z(this),r=this.$H,a=this.$m,s=this.$M,l=n.weekdays,c=n.months,d=n.meridiem,h=function(t,n,o,r){return t&&(t[n]||t(e,i))||o[n].slice(0,r)},p=function(t){return E.s(r%12||12,t,"0")},g=d||function(t,e,n){var i=t<12?"AM":"PM";return n?i.toLowerCase():i};return i.replace(m,(function(t,i){return i||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return E.s(e.$y,4,"0");case"M":return s+1;case"MM":return E.s(s+1,2,"0");case"MMM":return h(n.monthsShort,s,c,3);case"MMMM":return h(c,s);case"D":return e.$D;case"DD":return E.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,l,2);case"ddd":return h(n.weekdaysShort,e.$W,l,3);case"dddd":return l[e.$W];case"H":return String(r);case"HH":return E.s(r,2,"0");case"h":return p(1);case"hh":return p(2);case"a":return g(r,a,!0);case"A":return g(r,a,!1);case"m":return String(a);case"mm":return E.s(a,2,"0");case"s":return String(e.$s);case"ss":return E.s(e.$s,2,"0");case"SSS":return E.s(e.$ms,3,"0");case"Z":return o}return null}(t)||o.replace(":","")}))},f.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},f.diff=function(i,p,u){var g,m=this,b=E.p(p),f=S(i),y=(f.utcOffset()-this.utcOffset())*e,v=this-f,w=function(){return E.m(m,f)};switch(b){case h:g=w()/12;break;case c:g=w();break;case d:g=w()/3;break;case l:g=(v-y)/6048e5;break;case s:g=(v-y)/864e5;break;case a:g=v/n;break;case r:g=v/e;break;case o:g=v/t;break;default:g=v}return u?g:E.a(g)},f.daysInMonth=function(){return this.endOf(c).$D},f.$locale=function(){return w[this.$L]},f.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),i=C(t,e,!0);return i&&(n.$L=i),n},f.clone=function(){return E.w(this.$d,this)},f.toDate=function(){return new Date(this.valueOf())},f.toJSON=function(){return this.isValid()?this.toISOString():null},f.toISOString=function(){return this.$d.toISOString()},f.toString=function(){return this.$d.toUTCString()},b}(),T=M.prototype;return S.prototype=T,[["$ms",i],["$s",o],["$m",r],["$H",a],["$W",s],["$M",c],["$y",h],["$D",p]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),S.extend=function(t,e){return t.$i||(t(e,M,S),t.$i=!0),S},S.locale=C,S.isDayjs=k,S.unix=function(t){return S(1e3*t)},S.en=w[v],S.Ls=w,S.p={},S}();const w=y(v.exports);var x={exports:{}};const k=y(x.exports=function(t,e){e.prototype.isSameOrBefore=function(t,e){return this.isSame(t,e)||this.isBefore(t,e)}});var C={exports:{}};C.exports=function(t,e,n){var i=function(t,e){if(!e||!e.length||1===e.length&&!e[0]||1===e.length&&Array.isArray(e[0])&&!e[0].length)return null;var n;1===e.length&&e[0].length>0&&(e=e[0]),n=(e=e.filter((function(t){return t})))[0];for(var i=1;i<e.length;i+=1)e[i].isValid()&&!e[i][t](n)||(n=e[i]);return n};n.max=function(){var t=[].slice.call(arguments,0);return i("isAfter",t)},n.min=function(){var t=[].slice.call(arguments,0);return i("isBefore",t)}};const S=y(C.exports);var E,M,T={exports:{}};const A=y(T.exports=(E="month",M="quarter",function(t,e){var n=e.prototype;n.quarter=function(t){return this.$utils().u(t)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(t-1))};var i=n.add;n.add=function(t,e){return t=Number(t),this.$utils().p(e)===M?this.add(3*t,E):i.bind(this)(t,e)};var o=n.startOf;n.startOf=function(t,e){var n=this.$utils(),i=!!n.u(e)||e;if(n.p(t)===M){var r=this.quarter()-1;return i?this.month(3*r).startOf(E).startOf("day"):this.month(3*r+2).endOf(E).endOf("day")}return o.bind(this)(t,e)}}));var $={exports:{}};$.exports=function(t,e){e.prototype.weekday=function(t){var e=this.$locale().weekStart||0,n=this.$W,i=(n<e?n+7:n)-e;return this.$utils().u(t)?i:this.subtract(i,"day").add(t,"day")}};const I=y($.exports);var D={exports:{}};D.exports=function(){var t="week",e="year";return function(n,i,o){var r=i.prototype;r.week=function(n){if(void 0===n&&(n=null),null!==n)return this.add(7*(n-this.week()),"day");var i=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var r=o(this).startOf(e).add(1,e).date(i),a=o(this).endOf(t);if(r.isBefore(a))return 1}var s=o(this).startOf(e).date(i).startOf(t).subtract(1,"millisecond"),l=this.diff(s,t,!0);return l<0?o(this).startOf("week").week():Math.ceil(l)},r.weeks=function(t){return void 0===t&&(t=null),this.week(t)}}}();const B=y(D.exports),F=globalThis.console,R={warn(...t){F.warn(...t)},error(...t){F.error(...t)}};function H(t,e){const n=t.getInstanceId(),i=`.bar-container .bar-timeline[data-taskid="${e}"][data-chart-instance="${n}"]`,o=t.querySelector(i);return o||R.warn(`[${n}] Bar element not found for task: ${e}`),o}function z(t,e){const n=t.getInstanceId(),i=`.timeline-body .timeline-data-row[data-taskid="${e}"][data-chart-instance="${n}"]`,o=t.querySelector(i);return o||R.warn(`[${n}] Bar row element not found for task: ${e}`),o}const L=["day","week","month","quarter","year"];var P=(t=>(t.Day="day",t.Month="month",t.Quarter="quarter",t.Week="week",t.Year="year",t))(P||{}),O=(t=>(t.Horizontal="horizontal",t.Vertical="vertical",t))(O||{});class q{constructor(t,e,n,i,o){this.options=t,this.ganttStartDate=e,this.viewMode=n,this.chartContext=i,this.totalHeight=o}calculateWidth(t){return w(t.x2).add(1,"day").diff(w(t.x1),`${this.viewMode}s`,!0)*N[this.viewMode]}calculateX(t){return w(t.x1).diff(this.ganttStartDate.startOf(this.viewMode),`${this.viewMode}s`,!0)*N[this.viewMode]}drawAnnotation(t){const e=m(this.chartContext,{className:"annotation"}),n=this.calculateX(t),i=g(this.getAnnotationStyles(t,n));if(e.setAttribute("style",i),t.label){const n=this.renderLabel(t);e.append(n)}return e}getAnnotationStyles(t,e){const{annotationBgColor:n,annotationBorderColor:i,annotationBorderWidth:o}=this.options,{bgColor:r,borderColor:a,borderWidth:s}=t;let l=0;const c=t.x2?s??o:(s??o??0)/2;return t.x2&&(l=this.calculateWidth(t)),{backgroundColor:r||n,borderColor:`${a||i}`,borderStyle:"solid",borderWidth:`${c}px`,height:`${this.totalHeight}px`,left:`${e}px`,position:"absolute",top:"0px",width:l?`${l}px`:"unset",zIndex:"10"}}renderLabel(t){const e=m(this.chartContext,{className:"annotation-label"}),{annotationBgColor:n,annotationBorderColor:i,fontColor:o,fontFamily:r,fontSize:a,fontWeight:s}=this.options,{bgColor:l,borderColor:c}=t,{label:d}=t;if(!d)return e;const h=d.fontColor||o,p=d.fontFamily||r,u=d.fontSize||a,b=d.fontWeight||s,f=g({background:l||n,borderColor:`${c||i}`,borderStyle:"solid",borderWidth:"1px",color:h,fontFamily:p,fontSize:u,fontWeight:b,left:"0px",padding:"2px 5px",position:"absolute",top:"-1px",width:"max-content",zIndex:"1"});return e.setAttribute("style",f),e.innerText=d.text??"",e}render(){const t=[];return this.options.annotations.forEach((e=>{t.push(this.drawAnnotation(e))})),t}}const N={[P.Day]:80,[P.Month]:150,[P.Quarter]:150,[P.Week]:180,[P.Year]:180};const W=(t,e)=>{const n=function(t,e){const n=w(t);switch(e){case P.Month:return n.daysInMonth();case P.Quarter:{const t=n.startOf("quarter");return n.endOf("quarter").diff(t,"day")+1}case P.Week:return 7;case P.Year:{const t=n.startOf("year");return n.endOf("year").diff(t,"day")+1}default:return 1}}(t,e);return N[e]/n},V={annotationBorderDashArray:[],annotationBorderWidth:2,annotationOrientation:O.Horizontal,annotations:[],barBorderRadius:"5px",barMargin:8,baseline:{enabled:!1,color:"#b0b8c1"},canvasStyle:"border: 1px solid #CACED0; box-sizing: border-box",criticalBarColor:"#e53935",criticalArrowColor:"#e53935",enableCriticalPath:!1,cellBorderWidth:"1px",enableSelection:!1,enableExport:!0,toolbarItems:[],enableResize:!0,enableTaskDrag:!0,enableTaskEdit:!1,enableTaskResize:!0,enableTooltip:!0,fontFamily:"sans-serif",fontSize:"14px",fontWeight:"400",height:"500px",inputDateFormat:"MM-DD-YYYY",rowHeight:38,series:[],showCheckboxColumn:!0,tasksContainerWidth:425,tooltipId:"apexgantt-tooltip-container",tooltipTemplate(t,e){const n=[`<div>\n <strong>Task:</strong>\n <span>${t.name}</span>\n </div>\n `];return t.type===ct.Task?n.push(`\n <div>\n <strong>Start:</strong>\n <span>${it(t,tt.StartTime,e)}</span>\n </div>\n <div>\n <strong>End:</strong>\n <span>${it(t,tt.EndTime,e)}</span>\n </div>\n <div>\n <strong>Duration:</strong>\n <span>${it(t,tt.Duration,e)}</span>\n </div>\n <div>\n <strong>Progress:</strong>\n <span>${t.progress}%</span>\n </div>\n `):t.type===ct.Milestone&&n.push(`\n <div>\n <strong>Date:</strong>\n <span>${it(t,tt.StartTime,e)}</span>\n </div>\n `),t.dependency&&n.push(`\n <div>\n <strong>Depends on:</strong>\n <span>${t.dependency}</span>\n </div>\n `),`\n <div>\n ${n.join("")}\n </div>\n `},viewMode:P.Week,width:"100%"},Y={annotationBgColor:"#DBEAFE",annotationBorderColor:"#60A5FA",arrowColor:"#1A6FC4",backgroundColor:"#FFFFFF",barBackgroundColor:"#318CE7",barTextColor:"#FFFFFF",borderColor:"#DFE0E1",cellBorderColor:"#E3EDF8",fontColor:"#000000",headerBackground:"#EBF3FB",rowBackgroundColors:["#FFFFFF"],tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#BCBCBC"},_={annotationBgColor:"#4A2D4D",annotationBorderColor:"#8B4D8F",arrowColor:"#A5B4FC",backgroundColor:"#1E1E1E",barBackgroundColor:"#818CF8",barTextColor:"#FFFFFF",borderColor:"#3A3A3A",cellBorderColor:"#3A3A3A",fontColor:"#E0E0E0",headerBackground:"#2A2A2A",rowBackgroundColors:["#1E1E1E","#252525"],tooltipBGColor:"#2D2D2D",tooltipBorderColor:"#444444"};function j(t){return{...V,..."dark"===t?_:Y}}const U=j("light"),K={TASK_UPDATE:"taskUpdate",TASK_VALIDATION_ERROR:"taskValidationError",TASK_UPDATE_SUCCESS:"taskUpdateSuccess",TASK_UPDATE_ERROR:"taskUpdateError",TASK_DRAGGED:"taskDragged",TASK_RESIZED:"taskResized",SELECTION_CHANGE:"selectionChange",DEPENDENCY_ARROW_UPDATE:"dependencyArrowUpdate"};class X{constructor(t,e,n,i,o){this.taskId=t,this.options=e,this.chartContext=i,this.dataManager=o,this.dragState={childTasks:[],daysPerPixel:0,initialLeft:0,initialPosition:0,initialStartTime:"",initialEndTime:"",isDragging:!1,startX:0},this.task=null;const r=this.dataManager.getTaskById(t);if(!r)throw new Error(`BarDragManager: Task with id "${t}" not found`);this.dragState.daysPerPixel=W(r.startTime,n)}calculateFinalPosition(t){const{daysPerPixel:e,initialLeft:n,initialPosition:i}=this.dragState,o=t.clientX-i,r=Math.round(o/e);return{calculatedLeft:n+r*e,daysMoved:r}}createMouseDownHandler(t){return e=>{this.task=this.dataManager.getTaskById(this.taskId),this.task&&(this.dragState={...this.dragState,initialLeft:parseInt(t.style.left)||0,initialPosition:e.clientX,initialStartTime:this.task.startTime,initialEndTime:this.task.endTime,isDragging:!0,startX:e.clientX},t.classList.add("dragging"),t.setAttribute("aria-grabbed","true"),this.dragState.childTasks=this.dataManager.getNestedChildTasks(this.task.id).map((t=>{const e=H(this.chartContext,t.id);return e?{...t,element:e,left:parseInt(e.style.left)||0,width:parseInt(e.style.width)||0}:t})))}}createMouseMoveHandler(t){return e=>{this.dragState.isDragging&&requestAnimationFrame((()=>{const n=e.clientX-this.dragState.startX,i=parseInt(t.style.left)||0;this.moveBar(t,i,n),this.task&&this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),this.moveChildBars(n),this.dragState.startX=e.clientX}))}}createMouseUpHandler(t,e){return n=>{if(!this.dragState.isDragging)return;if(this.dragState.isDragging=!1,t.classList.remove("dragging"),t.setAttribute("aria-grabbed","false"),!this.task)return;const{calculatedLeft:i,daysMoved:o}=this.calculateFinalPosition(n);if(0===o)return void(this.dragState={...this.dragState,isDragging:!1});const r=w(this.task.startTime).add(o,"day").format(this.options.inputDateFormat),a=w(this.task.endTime).add(o,"day").format(this.options.inputDateFormat),s=this.dragState.childTasks.map((t=>({taskId:t.id,newStartTime:w(t.startTime).add(o,"day").format(this.options.inputDateFormat),newEndTime:t.endTime?w(t.endTime).add(o,"day").format(this.options.inputDateFormat):null}))).filter((t=>null!==t.newEndTime));this.emitTaskDraggedEvent(o,r,a,s),this.updateTaskPosition(t,i,o,e),this.updateChildrenPositions(i,o,e)}}emitTaskDraggedEvent(t,e,n,i){if(!this.task)return;const o={taskId:this.task.id,oldStartTime:this.dragState.initialStartTime,oldEndTime:this.dragState.initialEndTime,newStartTime:e,newEndTime:n,daysMoved:t,affectedChildTasks:i,timestamp:Date.now()},r=new CustomEvent(K.TASK_DRAGGED,{detail:o,bubbles:!0,composed:!0,cancelable:!1}),a=this.chartContext.getChartContainer();a&&a.dispatchEvent(r)}moveBar(t,e,n){t.style.left=`${e+n}px`}moveChildBars(t){this.dragState.childTasks.forEach((e=>{if(e.element){const n=parseInt(e.element.style.left)||0;e.element.style.left=`${n+t}px`,this.dataManager.updateDependencyArrows(e.id,this.chartContext)}}))}updateChildrenPositions(t,e,n){this.dragState.childTasks.forEach((i=>{const o=H(this.chartContext,i.id);if(o){const r=t-this.dragState.initialLeft;o.style.left=`${(i.left??0)+r}px`;const a=w(i.startTime).add(e,"day").format(this.options.inputDateFormat),s=i.endTime?w(i.endTime).add(e,"day").format(this.options.inputDateFormat):null;this.dataManager.updateDependencyArrows(i.id,this.chartContext),null==n||n(i.id,{endTime:s??void 0,startTime:a})}}))}updateTaskPosition(t,e,n,i){if(!this.task)return;t.style.left=`${e}px`;const o=w(this.task.startTime).add(n,"day").format(this.options.inputDateFormat),r=w(this.task.endTime).add(n,"day").format(this.options.inputDateFormat);this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),null==i||i(this.task.id,{endTime:r,startTime:o})}makeDraggable(t,e){const n=this.createMouseDownHandler(t),i=this.createMouseMoveHandler(t),o=this.createMouseUpHandler(t,e);return t.addEventListener("mousedown",n),this.chartContext.addEventListener("mousemove",i),this.chartContext.addEventListener("mouseup",o),()=>{t.removeEventListener("mousedown",n),this.chartContext.removeEventListener("mousemove",i),this.chartContext.removeEventListener("mouseup",o)}}}class G{constructor(t,e,n,i,o){this.taskId=t,this.options=e,this.chartContext=i,this.dataManager=o,this.interactionState={daysPerPixel:0,initialLeft:0,initialPosition:0,initialWidth:0,initialStartTime:"",initialEndTime:"",isResizing:!1,resizeHandle:null,startX:0},this.task=null;const r=this.dataManager.getTaskById(t);if(!r)throw new Error(`BarResizeManager: Task with id "${t}" not found`);this.interactionState.daysPerPixel=W(r.startTime,n)}createMouseMoveHandler(t){return e=>{this.interactionState.isResizing&&requestAnimationFrame((()=>{const n=e.clientX-this.interactionState.startX,{daysPerPixel:i,resizeHandle:o}=this.interactionState,r=parseInt(t.style.left)||0,a=parseInt(t.style.width)||0;if("left"===o){const e=Math.max(0,r+n),o=a-(e-r);o>=i&&(t.style.left=`${e}px`,t.style.width=`${o}px`)}else{const e=Math.max(i,a+n);t.style.width=`${e}px`}this.task&&(this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),this.interactionState.startX=e.clientX)}))}}createMouseUpHandler(t,e){return n=>{if(!this.interactionState.isResizing)return;if(!this.task)return;t.classList.remove("resizing");const{daysPerPixel:i,initialLeft:o,initialPosition:r,initialWidth:a,resizeHandle:s}=this.interactionState,l=n.clientX-r,c=this.interactionState.initialStartTime,d=this.interactionState.initialEndTime;let h=c,p=d,u=0;if("left"===s){let n=Math.round(l/i),r=o+n*i,s=a-n*i;if(s<i&&(s=i,r=o+a-i,n=Math.round((r-o)/i)),0===n)return void(this.interactionState={...this.interactionState,isResizing:!1,resizeHandle:null});t.style.left=`${r}px`,t.style.width=`${s}px`,h=w(this.task.startTime).add(n,"day").format(this.options.inputDateFormat),u=-n,null==e||e(this.task.id,{startTime:h})}else{let n=Math.round(l/i),o=a+n*i;if(o<i&&(o=i,n=Math.round((o-a)/i)),0===n)return void(this.interactionState={...this.interactionState,isResizing:!1,resizeHandle:null});t.style.width=`${o}px`,p=w(this.task.endTime).add(n,"day").format(this.options.inputDateFormat),u=n,null==e||e(this.task.id,{endTime:p})}null!==s&&this.emitTaskResizedEvent(s,c,d,h,p,u),this.dataManager.updateDependencyArrows(this.task.id,this.chartContext),this.interactionState={...this.interactionState,isResizing:!1,resizeHandle:null}}}emitTaskResizedEvent(t,e,n,i,o,r){if(!this.task)return;const a={taskId:this.task.id,resizeHandle:t,oldStartTime:e,oldEndTime:n,newStartTime:i,newEndTime:o,durationChange:r,timestamp:Date.now()},s=new CustomEvent(K.TASK_RESIZED,{detail:a,bubbles:!0,composed:!0,cancelable:!1}),l=this.chartContext.getChartContainer();l&&l.dispatchEvent(s)}createResizeMouseDownHandler(t){return(e,n)=>{e.stopPropagation(),this.task=this.dataManager.getTaskById(this.taskId),this.task&&(this.interactionState={...this.interactionState,initialLeft:parseInt(t.style.left)||0,initialPosition:e.clientX,initialWidth:parseInt(t.style.width)||0,initialStartTime:this.task.startTime,initialEndTime:this.task.endTime,isResizing:!0,resizeHandle:n,startX:e.clientX},t.classList.add("resizing"))}}makeResizable(t,e){const n=t.querySelector(".handle-left"),i=t.querySelector(".handle-right"),o=this.createResizeMouseDownHandler(t),r=this.createMouseMoveHandler(t),a=this.createMouseUpHandler(t,e);return null==n||n.addEventListener("mousedown",(t=>o(t,"left"))),null==i||i.addEventListener("mousedown",(t=>o(t,"right"))),this.chartContext.addEventListener("mousemove",r),this.chartContext.addEventListener("mouseup",a),()=>{null==n||n.removeEventListener("mousedown",(t=>o(t,"left"))),null==i||i.removeEventListener("mousedown",(t=>o(t,"right"))),this.chartContext.removeEventListener("mousemove",r),this.chartContext.removeEventListener("mouseup",a)}}}class Q{constructor(t,e){this.chartContext=t,this.options=e,this.overlay=null,this.keydownHandler=null,this.clickOutsideHandler=null,this.createDialog(),this.setupEventListeners()}createDialog(){const t=this.chartContext.getInstanceId(),e=this.chartContext.getElementById(`${this.options.id}-container`);if(e){this.container=e;const t=this.container.querySelector(".gantt-dialog");return void this.updateDialogContent(t)}this.container=this.chartContext.createElement("div"),this.container.id=`${this.options.id}-container`,this.container.className="gantt-dialog-container",this.container.setAttribute("role","dialog"),this.container.setAttribute("aria-modal","true"),this.container.setAttribute("aria-labelledby",`${this.options.id}-title`),this.container.setAttribute("data-chart-instance",t),this.options.modal&&(this.overlay=this.chartContext.createElement("div"),this.overlay.className="dialog-overlay",this.container.appendChild(this.overlay));const n=this.chartContext.createElement("div");n.id=this.options.id,n.className="gantt-dialog",this.createDialogStructure(n),this.options.width&&(n.style.width=this.options.width),this.options.height&&(n.style.height=this.options.height),this.container.appendChild(n),!1!==this.options.positionRelativeToChart&&this.positionRelativeToChart();const i=!1!==this.options.positionRelativeToChart?this.chartContext.getChartContainer():this.chartContext.getAppendContainer();null==i||i.appendChild(this.container)}createDialogStructure(t){t.innerHTML=`\n <div class="dialog-header">\n <h2 id="${this.options.id}-title-${this.chartContext.getInstanceId()}" class="dialog-title">${this.options.title||""}</h2>\n <button class="dialog-close" aria-label="Close dialog" type="button">×</button>\n </div>\n <div class="dialog-content"></div>\n `,this.updateDialogContent(t)}positionRelativeToChart(){const t=this.chartContext.getChartContainer();if(t){"static"===window.getComputedStyle(t).position&&(t.style.position="relative")}this.container.style.position="absolute",this.container.style.top="0",this.container.style.left="0",this.container.style.width="100%",this.container.style.height="100%",this.container.style.zIndex="999"}setupEventListeners(){const t=this.container.querySelector(".dialog-close");null==t||t.addEventListener("click",(()=>this.hide())),this.options.closeOnEscape&&(this.keydownHandler=t=>{"Escape"===t.key&&this.isVisible()&&(t.preventDefault(),this.hide())},this.chartContext.addEventListener("keydown",this.keydownHandler)),this.options.closeOnClickOutside&&this.overlay&&(this.clickOutsideHandler=t=>{t.target===this.overlay&&this.hide()},this.overlay.addEventListener("click",this.clickOutsideHandler)),this.container.addEventListener("keydown",(t=>{"Tab"===t.key&&this.isVisible()&&this.trapFocus(t)}))}trapFocus(t){const e=this.container.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=e[0],i=e[e.length-1],o=this.chartContext.getActiveElement();t.shiftKey?o===n&&(t.preventDefault(),null==i||i.focus()):o===i&&(t.preventDefault(),null==n||n.focus())}updateDialogContent(t){const e=t.querySelector(".dialog-content"),n=t.querySelector(".dialog-title");n&&(n.textContent=this.options.title||""),e&&(e.innerHTML="","string"==typeof this.options.content?e.innerHTML=this.options.content:this.options.content instanceof HTMLElement&&e.appendChild(this.options.content))}cleanupEventListeners(){this.keydownHandler&&(this.chartContext.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.clickOutsideHandler&&this.overlay&&(this.overlay.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}destroy(){this.cleanupEventListeners(),this.container.remove()}hide(){this.container.classList.remove("show","animate");const t=this.chartContext.querySelector("[data-dialog-trigger]");null==t||t.focus()}isVisible(){return this.container.classList.contains("show")}setContent(t){const e=this.container.querySelector(".dialog-content");e&&(e.innerHTML="","string"==typeof t?e.innerHTML=t:e.appendChild(t))}show(){const t=this.chartContext.getActiveElement();null==t||t.setAttribute("data-dialog-trigger","true"),this.container.classList.add("show","animate");const e=this.container.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');null==e||e.focus()}}class Z{constructor(t,e,n,i,o,r="MM-DD-YYYY"){this.chartContext=t,this.dataManager=e,this.task=n,this.containerElement=i,this.onSubmit=o,this.dateFormat=r,this.errors=[],this.submitButton=null,this.form=this.createForm()}emitEvent(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:!1});this.containerElement.dispatchEvent(n)}clearError(t){var e;const n=this.form.querySelector(`[name="${t}"]`),i=null==(e=n.parentElement)?void 0:e.querySelector(".form-error");null==i||i.remove(),n.classList.remove("invalid"),this.errors=this.errors.filter((e=>e.field!==t)),this.updateSubmitButton()}createForm(){const t=this.chartContext.createElement("form");t.className="task-form";const e=this.task.barBackgroundColor||"#87B7FE",n=this.task.rowBackgroundColor||"#FFFFFF";return t.innerHTML=`\n <div class="form-group">\n <label for="name">Task Name</label>\n <input type="text" id="name" name="name" value="${this.task.name}">\n </div>\n \n <div class="form-group">\n <label for="startTime">Start Date</label>\n <input type="date" id="startTime" name="startTime" value="${this.formatDate(this.task.startTime)}">\n </div>\n \n <div class="form-group">\n <label for="endTime">End Date</label>\n <input type="date" id="endTime" name="endTime" value="${this.formatDate(this.task.endTime)}">\n </div>\n \n <div class="form-group">\n <label for="progress">Progress (%)</label>\n <input type="number" id="progress" name="progress" min="0" max="100" value="${this.task.progress}">\n </div>\n\n <div class="grid">\n <div class="form-group">\n <label for="barColor">Bar Color</label>\n <div class="color-picker-wrapper">\n <input type="color" id="barColor" name="barBackgroundColor" \n value="${e}"\n title="Choose bar color">\n <span class="color-preview"></span>\n </div>\n </div>\n \n <div class="form-group">\n <label for="rowColor">Row Background Color</label>\n <div class="color-picker-wrapper">\n <input type="color" id="rowColor" name="rowBackgroundColor" \n value="${n}"\n title="Choose row color">\n <span class="color-preview"></span>\n </div>\n </div>\n </div>\n \n <div class="form-actions">\n <button type="submit" class="btn-primary">Update</button>\n </div>\n `,t.addEventListener("submit",this.handleSubmit.bind(this)),this.setupFieldValidation(t),t}formatDate(t){return w(t,this.dateFormat).format("YYYY-MM-DD")}handleSubmit(t){if(t.preventDefault(),this.errors.length>0)this.emitEvent(K.TASK_VALIDATION_ERROR,{taskId:this.task.id,errors:this.errors,timestamp:Date.now()});else try{const t=new FormData(this.form),e={...this.task,barBackgroundColor:t.get("barBackgroundColor"),endTime:w(t.get("endTime")).format(this.dateFormat),name:t.get("name"),progress:Number(t.get("progress")),rowBackgroundColor:t.get("rowBackgroundColor"),startTime:w(t.get("startTime")).format(this.dateFormat)},n=this.dataManager.getTaskById(this.task.id)??this.task;this.emitEvent(K.TASK_UPDATE,{taskId:this.task.id,updates:e,updatedTask:{...n,...e},timestamp:Date.now()}),this.onSubmit(e),this.emitEvent(K.TASK_UPDATE_SUCCESS,{taskId:this.task.id,updatedTask:{...n,...e},timestamp:Date.now()})}catch(t){R.warn(`[TaskForm] Error updating task ${this.task.id}:`,t),this.emitEvent(K.TASK_UPDATE_ERROR,{taskId:this.task.id,error:t instanceof Error?t:new Error(String(t)),timestamp:Date.now()})}}setupFieldValidation(t){const e=t.querySelector('[name="name"]'),n=t.querySelector('[name="startTime"]'),i=t.querySelector('[name="endTime"]'),o=t.querySelector('[name="progress"]');null==e||e.addEventListener("change",(()=>{const t=this.validateName(e.value);t?this.showError("name",t):this.clearError("name")}));const r=()=>{const{endError:t,startError:e}=this.validateDates(n.value,i.value);e?this.showError("startTime",e):this.clearError("startTime"),t?this.showError("endTime",t):this.clearError("endTime")};null==n||n.addEventListener("change",r),null==i||i.addEventListener("change",r),null==o||o.addEventListener("change",(()=>{const t=this.validateProgress(Number(o.value));t?this.showError("progress",t):this.clearError("progress")}))}showError(t,e){var n,i;const o=this.form.querySelector(`[name="${t}"]`),r=this.chartContext.createElement("div");r.className="form-error",r.textContent=e;const a=null==(n=o.parentElement)?void 0:n.querySelector(".form-error");null==a||a.remove(),null==(i=o.parentElement)||i.appendChild(r),o.classList.add("invalid"),this.errors.push({field:t,message:e}),this.updateSubmitButton()}updateSubmitButton(){if(this.submitButton||(this.submitButton=this.form.querySelector(".btn-primary")),this.submitButton){const t=this.errors.length>0;this.submitButton.disabled=t,this.submitButton.classList.toggle("btn-disabled",t)}}validateDates(t,e){const n={endError:null,startError:null},i=w(t),o=w(e);return t||(n.startError="Start date is required"),e||(n.endError="End date is required"),i.isValid()&&o.isValid()&&o.isBefore(i)&&(n.endError="End date must be after start date"),n}validateName(t){return t.trim()?null:"Task name is required"}validateProgress(t){return t||0===t?isNaN(t)||t<0||t>100?"Progress must be between 0 and 100":null:"Progress is required"}getElement(){return this.form}}class J{constructor(t,e,n,i,o,r,a){this.task=t,this.ganttStartDate=e,this.options=n,this.viewMode=i,this.index=o,this.chartContext=r,this.dataManager=a,this.tooltipHandler=null}static calculateWidth(t,e,n){const{barMargin:i,rowHeight:o}=n;if(t.type===ct.Milestone)return(o-i)/2;const r=w(t.startTime);return w(t.endTime).add(1,"days").diff(r,`${e}s`,!0)*N[e]}static calculateX(t,e,n,i){const o=w(t.startTime).diff(e.startOf(n),`${n}s`,!0)*N[n];let r=0;if(t.type===ct.Milestone){const{barMargin:t,rowHeight:e}=i;r=(e-t)/4*-1}return o+r}hasBaseline(){var t;return!(!(null==(t=this.options.baseline)?void 0:t.enabled)||!this.task.baseline)}calculateHeight(){const{barMargin:t,rowHeight:e}=this.options;return this.task.type===ct.Milestone?(e-t)/2:this.hasBaseline()?e-2*t-6-2:e-2*t}setupTooltip(t){if(!this.options.enableTooltip)return;const{tooltipBGColor:e,tooltipBorderColor:n,fontColor:i,fontFamily:o,fontSize:r,fontWeight:a,tooltipId:s,tooltipTemplate:l,inputDateFormat:c}=this.options;let d=!1,h=null;const p=t=>{d=!0,h&&(clearTimeout(h),h=null);const{x:p,y:g}=((t,e,n=300,i=120,o=20,r=20)=>{const a=window.innerWidth,s=window.innerHeight,l=window.scrollX||document.documentElement.scrollLeft,c=window.scrollY||document.documentElement.scrollTop;let d=t+o+l,h=e+r+c;return t+o+n>a&&(d=t-n-o+l),e+r+i>s&&(h=e-i-r+c),d=Math.max(l+5,d),h=Math.max(c+5,h),{x:d,y:h}})(t.clientX,t.clientY,300,120,5,10);if(!l)return;const m=this.dataManager.getTaskById(this.task.id);if(!m)return;const b=l(m,c),f=(({bgColor:t,borderColor:e,fontColor:n,fontFamily:i,fontSize:o,fontWeight:r,maxWidth:a,padding:s,x:l,y:c})=>{const d=["position: absolute;","z-index: 1000;","pointer-events: none;"];return d.push("box-sizing: border-box;"),d.push("word-wrap: break-word;"),d.push("overflow-wrap: break-word;"),d.push(`left: ${l}px;`),d.push(`top: ${c}px;`),e&&d.push(`border: 1px solid ${e};`),a&&(d.push(`width: ${a}px;`),d.push(`max-width: ${a}px;`)),d.push("border-radius: 6px;"),d.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);"),d.push("transition: opacity 0.2s ease;"),d.push(`color: ${n||"#000000"};`),d.push(`font-family: ${i||"sans-serif"};`),d.push(`font-weight: ${r||"400"};`),d.push(`font-size: ${o||"14px"};`),d.push(`background-color: ${t||"#FFFFFF"};`),void 0!==s&&d.push(`padding: ${s}px;`),d.join(" ")})({bgColor:e,borderColor:n,fontColor:i,fontFamily:o,fontSize:r,fontWeight:a,maxWidth:300,padding:0,x:p,y:g});u(this.chartContext,s,f,b)};t.addEventListener("mouseenter",p),t.addEventListener("mousemove",p),t.addEventListener("mouseleave",(()=>{d=!1,h=window.setTimeout((()=>{d||u(this.chartContext,s)}),100)}))}setupTaskEdit(t,e){if(!this.options.enableTaskEdit)return;const n=this.chartContext.getInstanceId();t.addEventListener("dblclick",(t=>{t.stopPropagation(),t.preventDefault();const i=this.dataManager.getTaskById(this.task.id);if(!i)return void R.error(`[${n}] Task not found in dataManager: ${this.task.id}`);const o=this.chartContext.getChartContainer();if(!o)return;const r=new Z(this.chartContext,this.dataManager,i,o,(t=>{null==e||e(i.id,t),s.hide()}),this.options.inputDateFormat),a=`taskDialog-${n}-${this.task.id}`,s=new Q(this.chartContext,{closeOnClickOutside:!1,closeOnEscape:!0,content:r.getElement(),id:a,modal:!0,title:`Edit Task: ${this.task.name}`,width:"400px",positionRelativeToChart:!0});s.show()}))}setupInteractions(t,e){const{enableTaskDrag:n,enableTaskResize:i}=this.options;if(n&&this.makeDraggable(t,e),i&&this.task.type===ct.Task){const n=m(this.chartContext,{className:"bar-handle handle-left"}),i=m(this.chartContext,{className:"bar-handle handle-right"});t.append(n,i),this.makeResizable(t,e)}}drawBar(e=t){const{barBackgroundColor:n,barBorderRadius:i}=this.options,o=m(this.chartContext,{className:"bar-timeline"}),r=m(this.chartContext,{className:"bar-label",content:this.task.name}),a=m(this.chartContext,{className:"bar-timeline-progress"}),s=this.task.barBackgroundColor||n,l=g(this.getBarStyles(s)),c=g({backgroundColor:f(s,-40),borderRadius:i,width:`${this.task.progress}%`}),d=this.chartContext.getInstanceId();o.setAttribute("data-taskid",this.task.id),o.setAttribute("data-chart-instance",d),a.setAttribute("style",c),o.setAttribute("style",l);const h=w(this.task.startTime),p=w(this.task.endTime),u=h.format("MMMM D, YYYY"),b=p.format("MMMM D, YYYY"),y=h.valueOf(),v=p.valueOf(),x=p.diff(h,"day"),{enableTaskDrag:k,enableTaskResize:C}=this.options;return k||C&&this.task.type===ct.Task?(o.setAttribute("role","slider"),o.setAttribute("aria-label",`${this.task.name}: ${u} to ${b}`),o.setAttribute("aria-valuenow",y.toString()),o.setAttribute("aria-valuemin",y.toString()),o.setAttribute("aria-valuemax",v.toString()),o.setAttribute("aria-valuetext",`${u} to ${b}, ${x} days`),o.setAttribute("aria-grabbed","false"),k&&o.setAttribute("aria-dropeffect","move")):(o.setAttribute("role","progressbar"),o.setAttribute("aria-label",`${this.task.name}: ${u} to ${b}, ${this.task.progress}% complete`),o.setAttribute("aria-valuenow",this.task.progress.toString()),o.setAttribute("aria-valuemin","0"),o.setAttribute("aria-valuemax","100")),o.setAttribute("tabindex","0"),this.task.type!==ct.Milestone&&o.append(r),o.append(a),this.setupTaskEdit(o,e),this.setupTooltip(o),this.setupInteractions(o,e),o.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0})))})),o}drawBaselineBar(){if(!this.hasBaseline())return null;const{barBorderRadius:t,barMargin:e,rowHeight:n}=this.options,i=this.options.baseline.color,o=this.task.baseline,r={...this.task,startTime:o.start,endTime:o.end,type:ct.Task},a=J.calculateX(r,this.ganttStartDate,this.viewMode,this.options),s=J.calculateWidth(r,this.viewMode,this.options),l=e+this.calculateHeight()+2+this.index*n,c=m(this.chartContext,{className:"bar-baseline"});c.setAttribute("aria-hidden","true"),c.setAttribute("data-taskid-baseline",this.task.id);const d=g({backgroundColor:i,borderRadius:t,height:"6px",left:`${a}px`,pointerEvents:"none",top:`${l}px`,width:`${s}px`});return c.setAttribute("style",d),c}getBarStyles(t){const{barBackgroundColor:e,barBorderRadius:n,barMargin:i,barTextColor:o,rowHeight:r}=this.options,a=J.calculateX(this.task,this.ganttStartDate,this.viewMode,this.options),s=J.calculateWidth(this.task,this.viewMode,this.options),l=this.calculateHeight(),c=t||e;return this.task.type===ct.Milestone?{backgroundColor:f(c,-40),borderRadius:"2px",color:o,height:`${l}px`,left:`${a}px`,top:r/3-i/2+this.index*r+"px",transform:"rotate(45deg)",width:`${s}px`}:{backgroundColor:c,borderRadius:n,color:o,height:`${l}px`,left:`${a}px`,top:`${i+this.index*r}px`,width:`${s}px`}}makeDraggable(t,e){new X(this.task.id,this.options,this.viewMode,this.chartContext,this.dataManager).makeDraggable(t,e)}makeResizable(t,e){new G(this.task.id,this.options,this.viewMode,this.chartContext,this.dataManager).makeResizable(t,e)}cleanup(){this.tooltipHandler&&(this.tooltipHandler.cleanup(),this.tooltipHandler=null)}}var tt=(t=>(t.Duration="duration",t.EndTime="endTime",t.Name="name",t.Progress="progress",t.StartTime="startTime",t))(tt||{});const et={duration:"Duration",endTime:"End",name:"Task Name",progress:"Progress",startTime:"Start"},nt=[{key:"name",title:et.name,minWidth:"120px",flexGrow:3},{key:"startTime",title:et.startTime,minWidth:"70px",flexGrow:1.5},{key:"duration",title:et.duration,minWidth:"50px",flexGrow:1},{key:"progress",title:et.progress,minWidth:"50px",flexGrow:1}];function it(t,e,n){const i=t[e];if("startTime"===e)return w(i,n).format(n);if("endTime"===e)return w(i,n).format(n);if("duration"===e){const e=w(t.startTime,n),i=w(t.endTime,n);return t.endTime?`${i.diff(e,"d")+1} d`:"0 d"}if("progress"===e){return`${t.progress??0}%`}return i}function ot(t,e){const n=t.getInstanceId(),i=`.tasks-container .tasks-data-row[data-taskid="${e}"][data-chart-instance="${n}"]`,o=t.querySelector(i);return o||R.warn(`[${n}] Task row element not found for task: ${e}`),o}function rt(t,e){return(null==e?void 0:e.length)?e[t%e.length]:"transparent"}function at(t,e,n){const i=ot(t,e),o=z(t,e);i&&(i.style.backgroundColor=n),o&&(o.style.backgroundColor=n)}const st=(t,e,n,i,o,r,a)=>{const{taskBar:s,taskBarRow:l,taskRow:c}=((t,e)=>{const n=ot(t,e);return{taskBar:H(t,e),taskBarRow:z(t,e),taskRow:n}})(t,n);if(!c||!s)return;const d=e.updateTask(n,i);if(!d)return;if(c.querySelectorAll(".tasks-data-cell").forEach((i=>{const r=i.getAttribute("data-columnid");if(r&&(i.innerHTML=it(d,r,o.inputDateFormat),"name"===r))if(e.hasChildren(n)){const o=t.createElement("span");o.className="task-toggle-icon "+(d.collapsed?"collapsed":"expanded"),o.addEventListener("click",(()=>{e.toggleTask(n)})),i.prepend(o)}else{const e=t.createElement("span");e.className="task-toggle-icon-blank",i.prepend(e)}})),i.rowBackgroundColor&&l&&(c.style.backgroundColor=i.rowBackgroundColor,l.style.backgroundColor=i.rowBackgroundColor),i.barBackgroundColor&&(s.style.backgroundColor=i.barBackgroundColor),i.startTime||i.endTime){const t=J.calculateX(d,a,r,o),e=J.calculateWidth(d,r,o);s.style.left=`${t}px`,s.style.width=`${e}px`}if(void 0!==i.progress){const t=s.querySelector(".bar-timeline-progress");t&&(t.style.width=`${i.progress}%`),i.barBackgroundColor&&(t.style.backgroundColor=f(i.barBackgroundColor,-40))}if(i.name){const t=s.querySelector(".bar-label");t&&(t.textContent=i.name)}e.updateDependencyArrows(n,t)},lt="data-chart-instance";var ct=(t=>(t.Milestone="milestone",t.Task="task",t))(ct||{});function dt(t){return"string"==typeof t?{taskId:t,type:"FS",lag:0}:{taskId:t.taskId,type:t.type??"FS",lag:t.lag??0}}class ht{constructor(t,e,n,i){this.options=t,this.chartContext=e,this.dataManager=n,this.selectionManager=i,this.selectionEnabled=t.enableSelection,this.showCheckbox=t.enableSelection&&t.showCheckboxColumn,this.effectiveColumnList=this.mergeColumnConfig(),this.injectDynamicColumnStyles()}mergeColumnConfig(){if(!this.options.columnConfig||0===this.options.columnConfig.length)return nt;const t=this.options.columnConfig.map((t=>{const e=nt.find((e=>e.key===t.key));return e?{...e,...t}:t})).filter((t=>!1!==t.visible));return 0===t.length?(R.warn("columnConfig resulted in zero visible columns — falling back to defaults"),nt):t}injectDynamicColumnStyles(){const t=this.effectiveColumnList.map((t=>`minmax(${t.minWidth||"30px"}, ${t.flexGrow||1}fr)`)).join(" ");const e=this.showCheckbox?"28px ":"",n=this.chartContext.getInstanceId(),i=`\n .tasks-container .tasks-header[data-chart-instance="${n}"] .tasks-header-row {\n grid-template-columns: ${e}${t};\n }\n\n .tasks-container .tasks-data-row[data-chart-instance="${n}"] {\n grid-template-columns: ${e}${t};\n }\n `;this.chartContext.injectStyles(i,`tasks-dynamic-columns-${n}`,{priority:"high",force:!0})}generateBody(t,e,n){const i=m(this.chartContext,{className:"tasks-data-container"}),o=n?n.allTasks:t;return i.setAttribute("role","treegrid"),i.setAttribute("aria-label",this.options.taskListAriaLabel??"Gantt task list"),i.setAttribute("aria-rowcount",o.length.toString()),n?this.generateRowsVirtualized(o,i,e,n.range,n.rowHeight):this.generateRows(t,i,e),i}generateHeader(t){const e=m(this.chartContext,{className:"tasks-header"}),n=m(this.chartContext,{className:"tasks-header-row"}),{rowHeight:i}=this.options,o=this.chartContext.getInstanceId();if(e.setAttribute(lt,o),this.showCheckbox){const t=m(this.chartContext,{className:"tasks-header-cell gantt-checkbox-cell"});t.style.height=2*i+"px";const e=this.chartContext.createElement("input");e.type="checkbox",e.className="gantt-select-all-checkbox",e.setAttribute("aria-label","Select all tasks"),e.addEventListener("change",(()=>{this.selectionManager&&(e.checked?this.selectionManager.selectAll():this.selectionManager.clearSelection())})),t.append(e),n.append(t)}return t.forEach((t=>{const e=m(this.chartContext,{className:"tasks-header-cell",content:t});e.style.height=2*i+"px",e.style.color="var(--text-color)",n.append(e)})),e.append(n),e.style.background="var(--header-bg-color)",e}generateRow(t,e,n){var i;const o=m(this.chartContext,{className:"tasks-data-row"}),{rowHeight:r}=this.options,a=this.chartContext.getInstanceId();if(o.setAttribute("data-taskid",t.id),o.setAttribute(lt,a),o.style.height=`${r}px`,o.setAttribute("role","row"),o.setAttribute("aria-rowindex",n.toString()),o.setAttribute("aria-level",(t.level??1).toString()),o.setAttribute("aria-selected","false"),o.setAttribute("tabindex",1===n?"0":"-1"),this.dataManager.hasChildren(t.id)&&o.setAttribute("aria-expanded",t.collapsed?"false":"true"),this.showCheckbox){const e=m(this.chartContext,{className:"tasks-data-cell gantt-checkbox-cell"});e.style.height=`${r}px`;const n=this.chartContext.createElement("input");n.type="checkbox",n.className="gantt-selection-checkbox",n.checked=(null==(i=this.selectionManager)?void 0:i.isSelected(t.id))??!1,n.setAttribute("aria-label",`Select ${t.name}`),n.addEventListener("click",(e=>{e.stopPropagation(),this.selectionManager&&this.selectionManager.handleClick(t.id,{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey})})),e.append(n),o.append(e)}if(this.selectionEnabled&&this.selectionManager){const e=this.selectionManager;o.addEventListener("click",(n=>{n.target.classList.contains("gantt-selection-checkbox")||n.target.classList.contains("task-toggle-icon")||(e.handleClick(t.id,{ctrlKey:n.ctrlKey,metaKey:n.metaKey,shiftKey:n.shiftKey}),o.focus())})),o.style.cursor="pointer"}let s=1;return this.effectiveColumnList.forEach((({key:n})=>{const i=m(this.chartContext,{className:"tasks-data-cell",content:it(t,n,this.options.inputDateFormat)});if(i.setAttribute("data-columnid",n),i.setAttribute(lt,a),i.style.height=`${r}px`,i.style.color="var(--text-color)",i.setAttribute("role","gridcell"),i.setAttribute("aria-colindex",s.toString()),i.setAttribute("aria-readonly","true"),s++,n===tt.Name){if(i.style.paddingLeft=15*(t.level??0)+"px",i.style.textAlign="left",i.innerHTML="",this.dataManager.hasChildren(t.id)){const n=b(this.chartContext,"span",{className:"task-toggle-icon "+(t.collapsed?"collapsed":"expanded")});n.addEventListener("click",(()=>{this.dataManager.toggleTask(t.id),e()})),i.append(n)}else{const t=b(this.chartContext,"span",{className:"task-toggle-icon-blank"});i.append(t)}const n=b(this.chartContext,"span",{textContent:t.name});i.append(n)}o.append(i)})),o}generateRows(t,e,n){return t.forEach(((t,i)=>{const o=this.generateRow(t,n,i+1);e.appendChild(o)})),this.fillEmptyRows(e,t.length,n),e}generateRowsVirtualized(t,e,n,i,o){const{startIndex:r,endIndex:a}=i,s=t.length,l=this.chartContext.createElement("div");l.className="virtualizer-top-spacer",l.style.height=r*o+"px",e.appendChild(l);t.slice(r,a+1).forEach(((t,i)=>{const o=r+i,a=this.generateRow(t,n,o+1);e.appendChild(a)}));const c=Math.max(0,(s-1-a)*o),d=this.chartContext.createElement("div");return d.className="virtualizer-bottom-spacer",d.style.height=`${c}px`,e.appendChild(d),e}fillEmptyRows(t,e,n){const i=this.chartContext.querySelector(".gantt-container");if(!i)return;const o=i.clientHeight,r=this.options.rowHeight,a=o-2*r,s=Math.floor(a/r),l=Math.max(0,s-e);for(let e=0;e<l;e++){const n=this.generateEmptyRow(e);t.appendChild(n)}}generateEmptyRow(t){const e=m(this.chartContext,{className:"tasks-data-row tasks-empty-row"}),{rowHeight:n}=this.options,i=this.chartContext.getInstanceId();return e.setAttribute("data-taskid",`empty-${t}`),e.setAttribute(lt,i),e.style.height=`${n}px`,this.effectiveColumnList.forEach((({key:t})=>{const o=m(this.chartContext,{className:"tasks-data-cell",content:""});o.setAttribute("data-columnid",t),o.setAttribute(lt,i),o.style.height=`${n}px`,o.style.color="var(--text-color)",e.append(o)})),e}render(t,e){const n=this.generateHeader(this.effectiveColumnList.map((t=>t.title))),i=e?e.allTasks.slice(e.range.startIndex,e.range.endIndex+1):this.dataManager.getFlatVisibleTasks();return[n,this.generateBody(i,t,e)]}}const pt="root";class ut{constructor(t=[]){this.dependencies=[],this.taskMap={},this.taskTree={},this.arrowLinkInstanceId=null,this.setTasks(t)}buildTaskTree(t){const e={[pt]:[]};t.forEach((t=>{var n;if(this.taskMap[t.id]=t,e[t.id]||(e[t.id]=[]),void 0===t.parentId||e[t.parentId]||(e[t.parentId]=[]),t.dependency){const{taskId:e,type:n,lag:i}=dt(t.dependency);this.addDependency(e,t.id,n,i)}t.parentId?null==(n=e[t.parentId])||n.push(t.id):e[pt].push(t.id)})),this.taskTree=e}processLevel(){const t=(e,n)=>{e.forEach((e=>{this.taskMap[e.id]={...e,level:n};const i=this.taskTree[e.id].map((t=>this.taskMap[t]));Array.isArray(i)&&t(i,n+1)}))};t(this.getTasks().filter((t=>!t.parentId)),1)}sortTasksByDate(t){const e=(e,n)=>new Date(e[t]).getTime()-new Date(n[t]).getTime(),n=(t,i)=>{t.sort(e),i&&(this.taskTree[i]=t.map((t=>t.id))),t.forEach((t=>{const e=this.taskTree[t.id].map((t=>this.getTaskById(t))).filter((t=>null!==t));e&&e.length>0&&n(e,t.id)}))},i=this.taskTree[pt].map((t=>this.getTaskById(t))).filter((t=>null!==t));n(i,pt)}validateTask(t){if("milestone"===t.type){if(!t.id||!t.startTime)throw new Error("Milestone must have an id and start date")}else if(!t.id||!t.startTime||!t.endTime)throw new Error("Task must have an id, start, and end date");return{...t,endTime:t.endTime||t.startTime,progress:t.progress??0,type:t.type??ct.Task,level:1}}addDependency(t,e,n="FS",i=0){this.dependencies.push({fromId:t,toId:e,type:n,lag:i})}addTask(t){const e=this.validateTask(t);this.taskMap[e.id]=e,this.buildTaskTree(this.getTasks())}calculateProgress(){const t=this.getTasks(),e=t.reduce(((t,e)=>t+w(e.endTime).diff(w(e.startTime),"day")),0),n=t.reduce(((t,e)=>t+e.progress/100*w(e.endTime).diff(w(e.startTime),"day")),0);return e?n/e*100:0}getDateRange(t=0,e){const n=this.getTasks();if(0===n.length){const n=w().startOf(e);let i=1;switch(e){case"day":i=30;break;case"week":case"month":default:i=12;break;case"quarter":i=4;break;case"year":i=5}const o=n.add(i+t,e);return[n,o]}const i=n.map((t=>w(t.startTime))),o=n.filter((t=>!!t.endTime)).map((t=>w(t.endTime)));return[w.min(i),w.max(o).add(t,e)]}getFlatSortedTasks(t,e=!1){let n=[];return t.forEach((t=>{n.push(t);const i=this.taskTree[t.id].map((t=>this.taskMap[t]));!e&&t.collapsed||!Array.isArray(i)||(n=n.concat(this.getFlatSortedTasks(i,e)))})),n}getFlatTasks(){return this.getFlatSortedTasks(this.taskTree[pt].map((t=>this.getTaskById(t))).filter((t=>null!==t)),!0)}getFlatVisibleTasks(){return this.getFlatSortedTasks(this.taskTree[pt].map((t=>this.getTaskById(t))).filter((t=>null!==t)))}getNestedChildTasks(t,e=!1){const n=[],i=t=>{var o;if(e&&(null==(o=this.taskMap[t])?void 0:o.collapsed))return;(this.taskTree[t]||[]).forEach((t=>{const e=this.taskMap[t];e&&(n.push(e),i(t))}))};return i(t),n}getTaskById(t){return this.taskMap[t]}getTaskDependencies(t){return{incoming:this.dependencies.filter((e=>e.toId===t)),outgoing:this.dependencies.filter((e=>e.fromId===t))}}getTasks(){return Object.values(this.taskMap)}getTopParentTasks(){return Object.values(this.taskMap).filter((t=>void 0===t.parentId&&t.type===ct.Task))}hasChildren(t){return this.taskTree[t].length>0}removeDependency(t,e){this.dependencies=this.dependencies.filter((n=>!(n.fromId===t&&n.toId===e)))}removeTask(t){delete this.taskMap[t],this.buildTaskTree(Object.values(this.taskMap))}setTasks(t){if(!Array.isArray(t))throw new Error("Tasks must be an array");const e=t.map((t=>this.validateTask(t)));this.taskMap={},this.dependencies=[],this.buildTaskTree(e),this.sortTasksByDate("startTime"),this.processLevel()}toggleTask(t){const e=this.getTaskById(t);e&&(this.taskMap[t]={...e,collapsed:!e.collapsed})}setArrowLinkInstanceId(t){this.arrowLinkInstanceId=t}updateDependencyArrows(t,e){const n=this.getTaskDependencies(t);[...n.incoming,...n.outgoing].forEach((t=>{const n=this.getTaskById(t.fromId),i=this.getTaskById(t.toId);if(n&&i){const n=(null==e?void 0:e.getInstanceId())||"unknown",i={fromId:t.fromId,toId:t.toId,type:t.type,lag:t.lag,chartInstanceId:n,arrowLinkInstanceId:this.arrowLinkInstanceId??void 0},o=new CustomEvent("dependencyArrowUpdate",{detail:i,bubbles:!1,cancelable:!1});e?e.dispatchEvent(o):(R.warn(`[${n}] No chartContext provided for dependency arrow update`),document.dispatchEvent(o))}}))}getAllDependencies(){return this.dependencies}updateTask(t,e){const n=this.taskMap[t];if(!n)throw new Error(`Task with id "${t}" not found`);const i=this.validateTask({...n,...e});return this.taskMap[t]=i,this.buildTaskTree(this.getTasks()),i}}const gt="MMMM, YYYY",mt={1:["Jan","Feb","Mar"],2:["Apr","May","Jun"],3:["Jul","Aug","Sep"],4:["Oct","Nov","Dec"]};function bt(t,e,n){const i=[];let o=t.startOf(n);const r=e.startOf(n);for(;o.isSameOrBefore(r);)i.push(o),o=o.add(1,`${n}s`);return i}function ft(t,e){return bt(t,e,P.Month)}function yt(t,e){return bt(t,e,P.Year)}function vt(t,e,n){const i=function(t,e){return bt(t,e,P.Day)}(t,e),o=ft(t,e),r=i.map((t=>t.format("DD MMM")));return[o.map(((i,r)=>0===r?{data:i.format("MMM YYYY"),width:(i.daysInMonth()-t.date()+1)*n}:r===o.length-1?{data:i.format("MMM YYYY"),width:(i.daysInMonth()-(i.daysInMonth()-e.date()))*n}:{data:i.format("MMM YYYY"),width:i.daysInMonth()*n})),r]}function wt(t,e,n){const i=function(t,e){return bt(t,e,P.Week)}(t,e),o=ft(t,e),r=i.map((t=>`#${t.week()}, ${t.day(0).format("DD MMM")} - ${t.day(6).format("DD MMM")}`));return[o.map(((i,r)=>{if(0===r){const e=i.endOf("month").date()-t.date()+1;return{data:i.format(gt),width:(e<7?7:e)/7*n}}if(r===o.length-1){const t=e.date()-i.startOf("month").date()+1;return{data:i.format(gt),width:(t<7?7:t)/7*n}}const a=i.endOf("month").date()-i.startOf("month").date()+1;return{data:i.format(gt),width:(a<7?7:a)/7*n}})),r]}function xt(t,e,n){const i=function(t,e){const n=[];let i=t.startOf(P.Quarter);const o=e.startOf(P.Quarter);for(;i.isSameOrBefore(o);)n.push(i),i=i.add(1,`${P.Quarter}s`);return n}(t,e),o=yt(t,e),r=i.map((t=>{const e=mt[t.quarter()];return`#${t.quarter()} ${e[0]}-${e[2]}`}));return[o.map(((i,r)=>0===r?{data:i.format("YYYY"),width:(5-t.quarter())*n}:r===o.length-1?{data:i.format("YYYY"),width:e.quarter()*n}:{data:i.format("YYYY"),width:4*n})),r]}function kt(t){return t.classList.contains("gantt-reduced-motion")}function Ct(t,e,n){if(kt(n))return;if("function"!=typeof t.animate)return;const i=Math.min(30*e,500);t.animate([{transformOrigin:"top",transform:"translateY(-8px) scaleY(0)"},{transformOrigin:"top",transform:"translateY(0) scaleY(1)"}],{duration:200,easing:"ease-out",delay:i,fill:"backwards"})}const St="data-chart-instance";class Et{constructor(t,e,n,i){this.viewMode=t,this.options=e,this.chartContext=n,this.dataManager=i}generateHeader(t,e){const n=m(this.chartContext,{className:"timeline-header"}),i=m(this.chartContext,{className:"timeline-header-row"}),{rowHeight:o}=this.options,r=this.chartContext.getInstanceId();if(n.setAttribute(St,r),n.setAttribute("tabindex","0"),n.setAttribute("aria-label","Timeline header"),t.forEach((t=>{const n=m(this.chartContext,{className:"timeline-header-cell",content:t.data,style:{height:e?`${o}px`:2*o+"px",minWidth:`${t.width}px`||"100%",color:"var(--text-color)"}});i.append(n)})),n.append(i),!e)return n.style.background="var(--header-bg-color)",n;const a=m(this.chartContext,{className:"timeline-header-row"});return e.forEach((t=>{const e=m(this.chartContext,{className:"timeline-header-cell",content:t,style:{height:`${o}px`,maxWidth:`${N[this.viewMode]}px`,minWidth:`${N[this.viewMode]}px`,color:"var(--text-color)"}});a.append(e)})),n.append(a),n.style.background="var(--header-bg-color)",n}generateRow(t,e){const n=m(this.chartContext,{className:"timeline-data-row"}),{rowHeight:i}=this.options,o=this.chartContext.getInstanceId();n.setAttribute("data-taskid",t),n.setAttribute(St,o);for(let t=0;t<e;t++){const t=m(this.chartContext,{className:"timeline-data-cell",style:{height:`${i}px`,minWidth:`${N[this.viewMode]}px`}});t.setAttribute(St,o),n.append(t)}return n}generateRows(t,e){const n=m(this.chartContext,{className:"timeline-body"}),i=this.chartContext.getInstanceId();return n.setAttribute(St,i),t.forEach((t=>{const i=this.generateRow(t.id,e);n.append(i)})),this.fillEmptyRows(n,t.length,e),n}generateRowsVirtualized(t,e,n,i){const o=m(this.chartContext,{className:"timeline-body"}),r=this.chartContext.getInstanceId();o.setAttribute(St,r);const{startIndex:a,endIndex:s}=n,l=t.length,c=this.chartContext.createElement("div");c.className="virtualizer-top-spacer",c.style.height=a*i+"px",o.appendChild(c);t.slice(a,s+1).forEach((t=>{const n=this.generateRow(t.id,e);o.append(n)}));const d=Math.max(0,(l-1-s)*i),h=this.chartContext.createElement("div");return h.className="virtualizer-bottom-spacer",h.style.height=`${d}px`,o.appendChild(h),o}fillEmptyRows(t,e,n){const i=this.chartContext.querySelector(".gantt-container");if(!i)return;const o=i.clientHeight,r=this.options.rowHeight,a=o-2*r,s=Math.floor(a/r),l=Math.max(0,s-e);for(let e=0;e<l;e++){const i=this.generateRow(`empty-${e}`,n);i.classList.add("timeline-empty-row"),t.append(i)}}getHeaderData(t,e,n){return n===P.Day?vt(t,e,N[this.viewMode]):n===P.Week?wt(t,e,N[this.viewMode]):n===P.Month?function(t,e,n){const i=ft(t,e),o=yt(t,e),r=i.map((t=>t.format("MMMM")));return[o.map(((i,r)=>0===r?{data:i.format("YYYY"),width:(12-t.month())*n}:r===o.length-1?{data:i.format("YYYY"),width:(e.month()+1)*n}:{data:i.format("YYYY"),width:12*n})),r]}(t,e,N[this.viewMode]):n===P.Quarter?xt(t,e,N[this.viewMode]):n===P.Year?function(t,e,n){return[yt(t,e).map((t=>({data:t.format("YYYY"),width:n}))),null]}(t,e,N[this.viewMode]):null}render(t,e=new Set){const n=t?t.allTasks:this.dataManager.getFlatVisibleTasks(),i=this.dataManager.getDateRange(8,this.viewMode),o=this.getHeaderData(i[0],i[1],this.viewMode);if(!o)return null;const[r,a]=o,s=this.generateHeader(r,a),l=(a||r).length;let c;c=t?this.generateRowsVirtualized(n,l,t.range,t.rowHeight):this.generateRows(n,l);const d=m(this.chartContext,{className:"bar-container"}),h=m(this.chartContext,{className:"annotation-container"}),p=this.chartContext.getChartContainer();if(t){const{startIndex:o,endIndex:r}=t.range,a=n.length*t.rowHeight;d.style.height=`${a}px`,d.style.width="100%";n.slice(o,r+1).forEach(((t,n)=>{const r=o+n,a=new J(t,i[0],this.options,this.viewMode,r,this.chartContext,this.dataManager),s=a.drawBar(((t,e)=>{st(this.chartContext,this.dataManager,t,e,this.options,this.viewMode,i[0])}));d.append(s),!e.has(t.id)&&p&&Ct(s,r,p);const l=a.drawBaselineBar();l&&d.append(l)}))}else n.forEach(((t,n)=>{const o=new J(t,i[0],this.options,this.viewMode,n,this.chartContext,this.dataManager),r=o.drawBar(((t,e)=>{st(this.chartContext,this.dataManager,t,e,this.options,this.viewMode,i[0])}));d.append(r),!e.has(t.id)&&p&&Ct(r,n,p);const a=o.drawBaselineBar();a&&d.append(a)}));const u=n.length*this.options.rowHeight,g=new q(this.options,i[0],this.viewMode,this.chartContext,u).render();h.append(...g);const b=m(this.chartContext,{className:"timeline-horizontal-scroll"}),f=m(this.chartContext,{className:"timeline-horizontal-scroll-content"}),y=this.chartContext.getInstanceId();b.id=`timeline-horizontal-scroll-${y}`;const v=(a||r).length*N[this.viewMode];return f.style.width=`${v}px`,f.style.height="1px",b.appendChild(f),[s,h,c,d,b]}}const Mt="http://www.w3.org/2000/svg",Tt={paddingX:20,paddingY:15};class At{constructor(t){this.elements=[],this.chartContext=null,this.instanceId=t??"arrow_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)}getInstanceId(){return this.instanceId}static calculateArrowPathFromRects(t,e,n,i="FS"){const{paddingX:o=Tt.paddingX,paddingY:r=Tt.paddingY}=n;switch(i){case"SS":return At.calculateSSPath(t,e,o,r);case"FF":return At.calculateFFPath(t,e,o,r);case"SF":return At.calculateSFPath(t,e,o,r);default:return At.calculateFSPath(t,e,o,r)}}static calculateArrowPath(t,e,n,i,o="FS"){const r=d(t,n),a=d(e,n),{paddingX:s=Tt.paddingX,paddingY:l=Tt.paddingY}=i;switch(o){case"SS":return At.calculateSSPath(r,a,s,l);case"FF":return At.calculateFFPath(r,a,s,l);case"SF":return At.calculateSFPath(r,a,s,l);default:return At.calculateFSPath(r,a,s,l)}}static calculateFSPath(t,e,n,i){const o=t.right,r=t.top+t.height/2,a=e.left-2,s=e.top+e.height/2,l=[`M ${o},${r}`];if(a>o){if(s<r){const t=o+n,e=r-i,c=a-n,d=s+i;l.push(`L ${t},${r}`),l.push(`L ${t},${e}`),l.push(`L ${c},${e}`),l.push(`L ${c},${d}`),l.push(`L ${c},${s}`)}else if(s>r){const e=t.bottom+i-t.height/2,c=(o+a)/2;if(a-o<20){const t=a-n;l.push(`L ${c},${r}`),l.push(`L ${c},${e}`),l.push(`L ${t},${e}`),l.push(`L ${t},${s}`)}else l.push(`L ${c},${r}`),l.push(`L ${c},${e}`),l.push(`L ${c},${s}`)}}else if(a<o)if(s!==r){const t=o+n,e=r+i*(s<r?-1:1),c=a-n,d=s+i*(s<r?1:-1);l.push(`L ${t},${r}`),l.push(`L ${t},${e}`),l.push(`L ${c},${e}`),l.push(`L ${c},${d}`),l.push(`L ${c},${s}`)}else{const t=o+n,e=r+i,c=a-n,d=s;l.push(`L ${t},${r}`),l.push(`L ${t},${e}`),l.push(`L ${c},${e}`),l.push(`L ${c},${d}`)}return l.push(`L ${a},${s}`),l.join(" ")}static calculateSSPath(t,e,n,i){const o=t.left,r=t.top+t.height/2,a=e.left-2,s=e.top+e.height/2,l=Math.min(o,a+2)-n,c=[`M ${o},${r}`];if(r===s)c.push(`L ${l},${r}`),c.push(`L ${l},${s}`);else{const t=r+i*(s>r?1:-1);c.push(`L ${l},${r}`),c.push(`L ${l},${t}`),c.push(`L ${l},${s}`)}return c.push(`L ${a},${s}`),c.join(" ")}static calculateFFPath(t,e,n,i){const o=t.right,r=t.top+t.height/2,a=e.right+2,s=e.top+e.height/2,l=Math.max(o,a-2)+n,c=[`M ${o},${r}`];if(r===s)c.push(`L ${l},${r}`),c.push(`L ${l},${s}`);else{const t=r+i*(s>r?1:-1);c.push(`L ${l},${r}`),c.push(`L ${l},${t}`),c.push(`L ${l},${s}`)}return c.push(`L ${a},${s}`),c.join(" ")}static calculateSFPath(t,e,n,i){const o=t.left,r=t.top+t.height/2,a=e.right+2,s=e.top+e.height/2,l=o-n,c=e.right+n,d=[`M ${o},${r}`];if(d.push(`L ${l},${r}`),r<=s){const e=t.bottom+i-t.height/2;d.push(`L ${l},${e}`),d.push(`L ${c},${e}`),d.push(`L ${c},${s}`)}else{const t=e.top-i;d.push(`L ${l},${t}`),d.push(`L ${c},${t}`),d.push(`L ${c},${s}`)}return d.push(`L ${a},${s}`),d.join(" ")}static drawArrow(t,e,n,i,o,r,a,s="FS",l=0){const c=a?a.createElementNS(Mt,"path"):document.createElementNS(Mt,"path"),d=At.calculateArrowPath(t,e,n,i,s);c.setAttribute("d",d);const h=i.arrowColor||"#0D6EFD";c.setAttribute("stroke",h),c.setAttribute("stroke-width","2"),c.setAttribute("fill","transparent");const p=r?`arrowhead-${r}`:"arrowhead";return c.setAttribute("marker-end",`url(#${p})`),c.setAttribute("data-edgeid",o),c.setAttribute("data-dependency-type",s),c.addEventListener("mouseout",(function(){c.setAttribute("stroke",h)})),0!==l&&c.setAttribute("data-lag-px",String(l)),c}static updateArrow(t,e,n,i,o,r="FS"){const a=n.querySelector(`[data-edgeid="${o}"]`),s=At.calculateArrowPath(t,e,n,i,r);a&&a.setAttribute("d",s)}createMarker(t){const e=t?t.createElementNS(Mt,"marker"):document.createElementNS(Mt,"marker"),n=`arrowhead-${this.instanceId}`;e.setAttribute("id",n),e.setAttribute("markerWidth","5"),e.setAttribute("markerHeight","5"),e.setAttribute("refX","4"),e.setAttribute("refY","2.5"),e.setAttribute("orient","auto"),e.setAttribute("fill","context-stroke");const i=t?t.createElementNS(Mt,"polygon"):document.createElementNS(Mt,"polygon");return i.setAttribute("points","0,0 5,2.5 0,5 1, 2.5"),e.appendChild(i),e}render(t,e,n,i){this.chartContext=i||null;const o=`timeline-arrows-${this.instanceId}`;let r=t.querySelector(`#${o}`);r||(r=i?i.createElementNS(Mt,"svg"):document.createElementNS(Mt,"svg"),r.setAttribute("id",o),t.appendChild(r)),this.svg=r,this.options={...Tt,...n},this.elements=e,this.svg.setAttribute("style",g({left:"0",position:"absolute",top:"0",pointerEvents:"none"})),this.svg.innerHTML="";const a=i?i.createElementNS(Mt,"defs"):document.createElementNS(Mt,"defs"),s=this.createMarker(i);return a.appendChild(s),this.svg.appendChild(a),this.svg.setAttribute("width",`${this.options.width}`),this.svg.setAttribute("height",`${this.options.height}`),this.elements.forEach((({id:t,source:e,target:n,dependencyType:o,lagPx:r})=>{this.svg.appendChild(At.drawArrow(e,n,this.svg,this.options,t,this.instanceId,i,o,r))})),this.svg}renderFromRects(t,e,n,i){this.chartContext=i||null;const o=`timeline-arrows-${this.instanceId}`;let r=t.querySelector(`#${o}`);r||(r=i?i.createElementNS(Mt,"svg"):document.createElementNS(Mt,"svg"),r.setAttribute("id",o),t.appendChild(r)),this.svg=r,this.options={...Tt,...n},this.svg.setAttribute("style",g({left:"0",position:"absolute",top:"0",pointerEvents:"none"})),this.svg.innerHTML="";const a=i?i.createElementNS(Mt,"defs"):document.createElementNS(Mt,"defs");a.appendChild(this.createMarker(i)),this.svg.appendChild(a),this.svg.setAttribute("width",`${this.options.width}`),this.svg.setAttribute("height",`${this.options.height}`);const s=n.arrowColor||"#0D6EFD",l=`arrowhead-${this.instanceId}`;return e.forEach((({id:t,sourceRect:e,targetRect:n,dependencyType:o="FS",lagPx:r=0})=>{const a=At.calculateArrowPathFromRects(e,n,this.options,o),c=i?i.createElementNS(Mt,"path"):document.createElementNS(Mt,"path");c.setAttribute("d",a),c.setAttribute("stroke",s),c.setAttribute("stroke-width","2"),c.setAttribute("fill","transparent"),c.setAttribute("marker-end",`url(#${l})`),c.setAttribute("data-edgeid",t),c.setAttribute("data-dependency-type",o),0!==r&&c.setAttribute("data-lag-px",String(r)),c.addEventListener("mouseout",(()=>{c.setAttribute("stroke",s)})),this.svg.appendChild(c)})),this.svg}}const $t={criticalTaskIds:new Set,criticalEdgeKeys:new Set};function It(t,e){const n=new Date(t).setHours(0,0,0,0),i=new Date(e).setHours(0,0,0,0);return Math.round((i-n)/864e5)+1}function Dt(t){const e=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e);return{barFill:e("--apex-gantt-bar-fill"),bgColor:e("--apex-gantt-background-color"),rowBgEven:e("--apex-gantt-row-bg-even"),rowBgOdd:e("--apex-gantt-row-bg-odd"),headerBg:e("--apex-gantt-header-bg"),gridLine:e("--apex-gantt-grid-line"),dependencyLine:e("--apex-gantt-dependency-line"),fontFamily:e("--apex-gantt-font-family"),fontSize:e("--apex-gantt-font-size"),fontColor:e("--apex-gantt-font-color")}}const Bt="http://www.w3.org/2000/svg";function Ft(t,e){t&&Object.assign(t.style,e)}function Rt(t){const e=[];for(let t=0;t<document.styleSheets.length;t++)try{const n=document.styleSheets[t];if(n.href&&!n.href.startsWith(window.location.origin))continue;if(n.cssRules)for(let t=0;t<n.cssRules.length;t++)e.push(n.cssRules[t].cssText)}catch(t){continue}document.querySelectorAll("style").forEach((t=>{t.textContent&&e.push(t.textContent)}));const n=function(t){const e=window.getComputedStyle(t),n=[];for(let e=0;e<t.style.length;e++){const i=t.style[e];if(i.startsWith("--")){const e=t.style.getPropertyValue(i);n.push(`${i}: ${e};`)}}return Array.from(e).forEach((t=>{if(t.startsWith("--")){const i=`${t}: ${e.getPropertyValue(t)};`;n.includes(i)||n.push(i)}})),0===n.length?"":`:root {\n ${n.join("\n ")}\n}`}(t);return n&&e.unshift(n),e.join("\n")}function Ht(t,e){const{contentWidth:n}=e,i=t.querySelector(".timeline-horizontal-scroll");null==i||i.remove();const o=t.querySelector(".timeline-container"),r=t.querySelector(".tasks-container"),a=t.querySelector(".timeline-body-wrapper"),s=t.querySelector(".timeline-header"),l=t.querySelector(".timeline-body"),c=t.querySelector(".bar-container"),d=t.querySelector(".annotation-container");var h;Ft(o,{overflow:"visible",maxWidth:"none",width:"auto",position:"relative"}),Ft(r,{overflow:"visible",height:"auto",maxHeight:"none"}),Ft(a,{overflow:"visible",maxWidth:"none",width:`${n}px`}),a&&(a.scrollLeft=0),Ft(s,{overflow:"visible",maxWidth:"none",width:`${n}px`}),s&&(s.scrollLeft=0),h={width:`${n}px`,minWidth:`${n}px`,maxWidth:"none"},[l,c,d].forEach((t=>Ft(t,h)))}const zt=async t=>{try{const e=function(t){const e=t.querySelector(".gantt-container");if(!e)throw new Error("Gantt container not found");const n=e.querySelector(".timeline-container"),i=e.querySelector(".tasks-container");if(!n||!i)throw new Error("Timeline or tasks container not found");return{ganttContainer:e,timelineContainer:n,tasksContainer:i,horizontalScroll:e.querySelector(".timeline-horizontal-scroll"),timelineBodyWrapper:n.querySelector(".timeline-body-wrapper"),timelineHeader:n.querySelector(".timeline-header"),timelineBody:n.querySelector(".timeline-body"),barContainer:n.querySelector(".bar-container"),annotationContainer:n.querySelector(".annotation-container")}}(t),n=function(t){var e,n,i,o;const r=Math.max((null==(e=t.timelineBody)?void 0:e.scrollWidth)||0,(null==(n=t.barContainer)?void 0:n.scrollWidth)||0,(null==(i=t.annotationContainer)?void 0:i.scrollWidth)||0,(null==(o=t.timelineHeader)?void 0:o.scrollWidth)||0),a=t.tasksContainer.scrollWidth;return{contentWidth:r,tasksWidth:a,totalWidth:a+r,totalHeight:Math.max(t.timelineContainer.scrollHeight,t.tasksContainer.scrollHeight)}}(e),i=e.ganttContainer.cloneNode(!0);Ht(i,n),Ft(i,{display:"flex",overflow:"visible",width:"fit-content",height:"auto"});const o=Rt(t),r=document.createElement("style");r.textContent=o,i.insertBefore(r,i.firstChild);const a=document.createElementNS(Bt,"svg");a.setAttribute("width",n.totalWidth.toString()),a.setAttribute("height",n.totalHeight.toString()),a.setAttribute("xmlns",Bt),a.setAttribute("viewBox",`0 0 ${n.totalWidth} ${n.totalHeight}`);const s=document.createElementNS(Bt,"foreignObject");s.setAttribute("width",n.totalWidth.toString()),s.setAttribute("height",n.totalHeight.toString()),s.setAttribute("x","0"),s.setAttribute("y","0"),s.appendChild(i),a.appendChild(s);const l='<?xml version="1.0" encoding="UTF-8"?>\n'+(new XMLSerializer).serializeToString(a),c=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),d=URL.createObjectURL(c),h=document.createElement("a");h.href=d,h.download=`gantt-chart-${Date.now()}.svg`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout((()=>URL.revokeObjectURL(d)),100)}catch(t){throw R.error("Error exporting gantt chart:",t),t}},Lt={zoomIn:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',zoomOut:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',calendar:'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>\n <line x1="16" y1="2" x2="16" y2="6"/>\n <line x1="8" y1="2" x2="8" y2="6"/>\n <line x1="3" y1="10" x2="21" y2="10"/>\n </svg>',chevronDown:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <polyline points="6 9 12 15 18 9"/>\n </svg>',download:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>'},Pt={ganttContainer:".gantt-container",actionsContainer:".gantt-actions-container",splitBar:".split-bar-container",tasksContainer:".tasks-container",tasksHeader:".tasks-header",tasksBodyWrapper:".tasks-body-wrapper",tasksDataContainer:".tasks-data-container",tasksDataRow:".tasks-data-row",tasksEmptyRow:".tasks-empty-row",tasksDataCell:".tasks-data-cell",timelineContainer:".timeline-container",timelineHeader:".timeline-header",timelineHeaderCell:".timeline-header-cell",timelineBodyWrapper:".timeline-body-wrapper",timelineBody:".timeline-body",timelineDataRow:".timeline-data-row",timelineEmptyRow:".timeline-empty-row",timelineDataCell:".timeline-data-cell",horizontalScroll:".timeline-horizontal-scroll",horizontalScrollContent:".timeline-horizontal-scroll-content",barContainer:".bar-container",virtualizerTopSpacer:".virtualizer-top-spacer",virtualizerBottomSpacer:".virtualizer-bottom-spacer"};class Ot{constructor(){this.state={scrollPosition:{horizontal:0,tasksVertical:0,timelineVertical:0},viewMode:P.Week,collapsedTasks:new Set,selectedTaskIds:[]}}captureState(t,e,n,i){const o=t.querySelector(".timeline-horizontal-scroll"),r=t.querySelector(".split-view-container");this.state.scrollPosition={horizontal:(null==o?void 0:o.scrollLeft)||0,tasksVertical:(null==r?void 0:r.scrollTop)||0,timelineVertical:(null==r?void 0:r.scrollTop)||0},this.state.viewMode=n,this.state.collapsedTasks=new Set(e.getFlatTasks().filter((t=>t.collapsed)).map((t=>t.id))),this.state.selectedTaskIds=i??[]}restoreState(t,e=!1){e||requestAnimationFrame((()=>{const e=t.querySelector(".timeline-horizontal-scroll"),n=t.querySelector(".split-view-container");e&&(e.scrollLeft=this.state.scrollPosition.horizontal),n&&(n.scrollTop=this.state.scrollPosition.tasksVertical);const i=t.querySelector(".timeline-header");i&&(i.scrollLeft=this.state.scrollPosition.horizontal)}))}getViewMode(){return this.state.viewMode}getSelectedTaskIds(){return this.state.selectedTaskIds}hasState(){return void 0!==this.state.viewMode}clearState(){this.state={scrollPosition:{horizontal:0,tasksVertical:0,timelineVertical:0},viewMode:P.Week,collapsedTasks:new Set,selectedTaskIds:[]}}}const qt=["endTime","progress","type","parentId","dependency","barBackgroundColor","rowBackgroundColor","collapsed"];class Nt{static getNestedValue(t,e){if(!t||!e)return;const n=e.split(".");let i=t;for(const t of n){if(null==i)return;i=i[t]}return i}static processParsingValue(t,e){if("string"==typeof e)return this.getNestedValue(t,e);const{key:n,transform:i}=e,o=this.getNestedValue(t,n);if(i&&"function"==typeof i)try{return i(o)}catch(t){return R.warn(`DataParser: Transform function failed for key "${n}":`,t),o}return o}static buildTaskInput(t,e,n){const i=this.processParsingValue(t,e.id),o=this.processParsingValue(t,e.name),r=this.processParsingValue(t,e.startTime);if(!i||!o||!r)return R.warn(`DataParser: Skipping item at index ${n} - missing required fields`,{id:i,name:o,startTime:r,rawItem:t}),null;const a={id:i,name:o,startTime:r};for(const n of qt)if(void 0!==e[n]){const i=this.processParsingValue(t,e[n]);void 0!==i&&(a[n]=i)}return a}static parse(t,e){return Array.isArray(t)?e?t.map(((t,n)=>{try{return this.buildTaskInput(t,e,n)}catch(e){return R.warn(`DataParser: Error parsing item at index ${n}:`,e,t),null}})).filter((t=>null!==t)):(R.warn("DataParser: Parsing config is required"),[]):(R.warn("DataParser: Data must be an array"),[])}static validateConfig(t){return!!t&&(!!(t.id&&t.name&&t.startTime)||(R.warn("DataParser: Parsing config must include id, name, and startTime"),!1))}}const Wt="splitview-resize",Vt="timeline-horizontal-scroll";class Yt{constructor(t,e,n,i,o,r){this.element=t,this.options=e,this.domCache=n,this.chartContext=i,this.instanceId=o,this.getViewMode=r,this.scrollbarResizeObserver=null,this.splitBarResizeHandler=null,this.timelineScrollHandlers={},this.isSyncingScroll=!1}setupTimelineHorizontalScroll(){const t=this.domCache.horizontalScroll,e=this.domCache.timelineHeader,n=this.domCache.timelineBodyWrapper;if(!t||!e||!n)return;this.updateHorizontalScrollbarContent(),this.applyScrollbarStylesToElement(t),this.timelineScrollHandlers.bodyScroll&&n.removeEventListener("scroll",this.timelineScrollHandlers.bodyScroll),this.timelineScrollHandlers.horizontalScroll&&t.removeEventListener("scroll",this.timelineScrollHandlers.horizontalScroll);const i=i=>{if(this.isSyncingScroll)return;this.isSyncingScroll=!0;const o=t.scrollLeft;e.scrollLeft=o,n.scrollLeft=o,requestAnimationFrame((()=>{this.isSyncingScroll=!1}))},o=i=>{if(this.isSyncingScroll)return;this.isSyncingScroll=!0;const o=n.scrollLeft;t.scrollLeft=o,e.scrollLeft=o,requestAnimationFrame((()=>{this.isSyncingScroll=!1}))};t.addEventListener("scroll",i,{passive:!0}),n.addEventListener("scroll",o,{passive:!0}),this.timelineScrollHandlers={horizontalScroll:i,bodyScroll:o}}positionHorizontalScrollbar(){const t=this.domCache.horizontalScroll,e=this.domCache.ganttContainer,n=this.domCache.tasksContainer;if(!t||!e)return void R.warn("Missing elements for scrollbar positioning");e.offsetHeight;const i=n?n.offsetWidth:0,o=this.domCache.splitBar,r=i+(o?o.offsetWidth:0)+2,a=window.getComputedStyle(this.element),s=parseFloat(a.paddingLeft)||0,l=parseFloat(a.paddingBottom)||0;t.style.left=`${r+s}px`,t.style.bottom=`${l}px`;const c=e.clientWidth-r;t.style.width=`${Math.max(0,c)}px`}compensateForScrollbar(){const t=this.domCache.tasksBodyWrapper,e=this.domCache.tasksHeader;if(!t||!e)return;const n=t.offsetWidth-t.clientWidth;e.style.paddingRight="",e.style.boxSizing="",n>0&&(e.style.paddingRight=`${n}px`,e.style.boxSizing="border-box")}setupScrollbarResizeObserver(){if(!this.element)return;this.scrollbarResizeObserver&&this.scrollbarResizeObserver.disconnect(),this.scrollbarResizeObserver=new ResizeObserver((()=>{this.positionHorizontalScrollbar()})),this.scrollbarResizeObserver.observe(this.element);const t=this.domCache.ganttContainer;t&&this.scrollbarResizeObserver.observe(t),this.setupSplitBarResizeListener()}setupSplitBarResizeListener(){this.splitBarResizeHandler&&this.chartContext.removeEventListener(Wt,this.splitBarResizeHandler),this.splitBarResizeHandler=()=>{requestAnimationFrame((()=>{this.positionHorizontalScrollbar()}))},this.chartContext.addEventListener(Wt,this.splitBarResizeHandler)}updateHorizontalScrollbarContent(){const t=this.domCache.horizontalScroll,e=this.domCache.horizontalScrollContent,n=this.domCache.timelineBody;if(!t||!e||!n)return void R.warn("Scrollbar update: Missing elements",{horizontalScroll:!!t,scrollContent:!!e,timelineBody:!!n});const i=n.scrollWidth;e.style.width=`${i}px`}applyScrollbarStylesToElement(t){const{backgroundColor:e}=this.options;if(!this.isColorDark(e))return;const{borderColor:n,cellBorderColor:i}=this.options,o=`scrollbar-${this.instanceId}-${Date.now()}`,r=`\n #${t.id||Vt} {\n scrollbar-width: thin;\n scrollbar-color: ${n} ${e};\n }\n\n #${t.id||Vt}::-webkit-scrollbar {\n width: 12px;\n height: 12px;\n }\n\n #${t.id||Vt}::-webkit-scrollbar-track {\n background: ${e};\n border-radius: 4px;\n }\n\n #${t.id||Vt}::-webkit-scrollbar-thumb {\n background: ${n};\n border-radius: 4px;\n border: 2px solid ${e};\n }\n\n #${t.id||Vt}::-webkit-scrollbar-thumb:hover {\n background: ${i};\n }\n `;t.id||(t.id=`timeline-horizontal-scroll-${this.instanceId}`),this.chartContext.injectStyles(r,o)}updateOptions(t){this.options=t}disableHeaderMousewheelScroll(){const t=this.domCache.timelineHeader;if(!t)return;t.addEventListener("wheel",(t=>{t.preventDefault()}),{passive:!1})}isColorDark(t){const e=t.replace("#","");return(.299*parseInt(e.substring(0,2),16)+.587*parseInt(e.substring(2,4),16)+.114*parseInt(e.substring(4,6),16))/255<.5}cleanup(){if(this.timelineScrollHandlers.bodyScroll||this.timelineScrollHandlers.horizontalScroll){const t=this.domCache.horizontalScroll,e=this.domCache.timelineBodyWrapper;t&&this.timelineScrollHandlers.horizontalScroll&&t.removeEventListener("scroll",this.timelineScrollHandlers.horizontalScroll),e&&this.timelineScrollHandlers.bodyScroll&&e.removeEventListener("scroll",this.timelineScrollHandlers.bodyScroll),this.timelineScrollHandlers={}}this.scrollbarResizeObserver&&(this.scrollbarResizeObserver.disconnect(),this.scrollbarResizeObserver=null),this.splitBarResizeHandler&&(this.chartContext.removeEventListener(Wt,this.splitBarResizeHandler),this.splitBarResizeHandler=null)}}class _t{constructor(t,e,n,i,o,r){this.element=t,this.domCache=e,this.chartContext=n,this.instanceId=i,this.getViewMode=o,this.callbacks=r,this.zoomHandler=null}setupZoomEventListener(){const t=this.instanceId,e=this.domCache.timelineContainer;e?(this.zoomHandler&&e.removeEventListener("wheel",this.zoomHandler),this.zoomHandler=t=>{if(!t.ctrlKey)return;t.preventDefault();const e=Math.sign(t.deltaY);e<0?this.zoomIn():e>0&&this.zoomOut()},e.addEventListener("wheel",this.zoomHandler)):R.warn(`[${t}] Timeline element not found for zoom listener`)}zoomIn(){const t=this.getViewMode();if(t===L[0])return;const e=L.findIndex((e=>e===t)),n=L[e-1];this.callbacks.onViewModeChange(n),this.callbacks.onToolbarUpdate(),this.callbacks.onTimelineRerender(),this.callbacks.onDependencyArrowsRender(),requestAnimationFrame((()=>{this.callbacks.onScrollbarUpdate(),this.callbacks.onScrollbarPosition()}))}zoomOut(){const t=this.getViewMode();if(t===L[L.length-1])return;const e=L.findIndex((e=>e===t)),n=L[e+1];this.callbacks.onViewModeChange(n),this.callbacks.onToolbarUpdate(),this.callbacks.onTimelineRerender(),this.callbacks.onDependencyArrowsRender(),requestAnimationFrame((()=>{this.callbacks.onScrollbarUpdate(),this.callbacks.onScrollbarPosition()}))}updateToolbarAfterZoom(){this.domCache.actionsContainer&&this.callbacks.onToolbarUpdate()}cleanup(){if(this.zoomHandler){const t=this.domCache.timelineContainer;t&&t.removeEventListener("wheel",this.zoomHandler),this.zoomHandler=null}}}const jt="aria-valuenow";class Ut{constructor(t,e,n,i={}){this.chartContext=t,this.leftContent=e,this.rightContent=n,this.options=i,this.isDragging=!1,this.mouseMoveHandler=null,this.mouseUpHandler=null}getSplitViewStyles(){return"\n .split-view-container {\n display: flex !important;\n height: 100%;\n width: 100%;\n position: relative;\n box-sizing: border-box;\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .split-view-container .split-left-container {\n flex-grow: 0 !important;\n flex-shrink: 1 !important;\n overflow: visible;\n display: flex !important;\n flex-direction: column;\n position: relative;\n box-sizing: border-box;\n height: fit-content;\n min-height: 100%;\n }\n\n .split-view-container .split-right-container {\n overflow: visible;\n position: relative;\n flex: 1 !important;\n display: flex !important;\n flex-direction: column;\n min-width: 0;\n box-sizing: border-box;\n height: fit-content;\n min-height: 100%;\n }\n \n .split-view-container .split-bar-container {\n cursor: col-resize !important;\n user-select: none !important;\n height: 100%;\n align-items: center;\n background: var(--split-bar-color, #DEE2E6);\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n min-width: 8px;\n width: 8px;\n z-index: 15;\n position: sticky;\n top: 0;\n box-sizing: border-box;\n border-left: 1px solid var(--split-bar-border-color, #BBBBBB);\n border-right: 1px solid var(--split-bar-border-color, #BBBBBB);\n opacity: 1;\n visibility: visible;\n box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);\n transition: background-color 0.2s ease, border-color 0.2s ease;\n }\n\n .split-view-container .split-bar-container:hover {\n background: var(--split-bar-hover-color, #007BFF);\n border-color: var(--split-bar-hover-border-color, #0056B3);\n }\n\n .split-view-container .split-bar-container .resize-handler {\n border-left: 1.5px solid var(--split-bar-handle-color, #666666);\n border-right: 1.5px solid var(--split-bar-handle-color, #666666);\n height: 20px;\n width: 4px;\n position: relative;\n pointer-events: none;\n box-sizing: border-box;\n background: rgba(102, 102, 102, 0.3);\n display: block;\n border-radius: 1px;\n margin: 0;\n padding: 0;\n opacity: 1;\n visibility: visible;\n transition: background-color 0.2s ease, border-color 0.2s ease;\n }\n\n .split-view-container .split-bar-container:hover .resize-handler {\n background: rgba(255, 255, 255, 0.9);\n border-color: #FFFFFF;\n }\n\n .split-view-container.dragging {\n user-select: none;\n cursor: col-resize;\n }\n\n .split-view-container.dragging * {\n pointer-events: none;\n }\n\n .split-view-container.dragging .split-bar-container {\n pointer-events: all;\n }\n\n :host .split-view-container {\n display: flex !important;\n height: auto;\n width: 100%;\n position: relative;\n box-sizing: border-box;\n overflow-y: auto; /* shadow DOM */\n }\n "}injectStyles(){this.chartContext.injectStyles(this.getSplitViewStyles(),"split-view-styles",{priority:"normal"})}buildElements(){const{leftContainerClass:t="",leftContainerWidth:e=425,rightContainerClass:n=""}=this.options;this.leftContainer=m(this.chartContext,{className:"split-left-container"+(t?" "+t:""),style:{flexBasis:`${e}px`}}),this.rightContainer=m(this.chartContext,{className:"split-right-container"+(n?" "+n:"")});const i=m(this.chartContext,{className:"resize-handler"}),o=m(this.chartContext,{className:"split-bar-click-area"});o.style.cssText="\n position: absolute;\n top: 0;\n left: 50%;\n transform: translateX(-50%);\n width: 20px;\n height: 100%;\n cursor: col-resize;\n z-index: 10;\n background: transparent;\n display: block;\n box-sizing: border-box;\n ",this.splitBarContainer=m(this.chartContext,{className:"split-bar-container"}),this.splitBarContainer.setAttribute("role","separator"),this.splitBarContainer.setAttribute("aria-orientation","vertical"),this.splitBarContainer.setAttribute("aria-label","Resize panels"),this.splitBarContainer.setAttribute(jt,String(e)),this.splitBarContainer.setAttribute("aria-valuemin","0"),this.splitBarContainer.setAttribute("aria-valuemax",String(4*e)),this.splitBarContainer.setAttribute("tabindex","0"),this.splitBarContainer.append(i,o),Array.isArray(this.leftContent)?this.leftContainer.append(...this.leftContent):this.leftContainer.append(this.leftContent),Array.isArray(this.rightContent)?this.rightContainer.append(...this.rightContent):this.rightContainer.append(this.rightContent)}attachEventListeners(){this.splitBarContainer.addEventListener("mousedown",(t=>{t.preventDefault(),this.isDragging=!0;const e=this.splitBarContainer.closest(".split-view-container");null==e||e.classList.add("dragging"),this.mouseMoveHandler=t=>{var e;if(!this.isDragging)return;const n=null==(e=this.leftContainer.parentElement)?void 0:e.getBoundingClientRect();if(!n)return;const i=t.clientX-n.left,o=n.width-50,r=Math.max(0,Math.min(o,i));this.leftContainer.style.flexBasis=`${r}px`,this.splitBarContainer.setAttribute(jt,String(Math.round(r))),this.dispatchResizeEvent()},this.mouseUpHandler=()=>{this.isDragging=!1;const t=this.splitBarContainer.closest(".split-view-container");null==t||t.classList.remove("dragging"),this.dispatchResizeEvent(),this.mouseMoveHandler&&(this.chartContext.removeEventListener("mousemove",this.mouseMoveHandler),this.mouseMoveHandler=null),this.mouseUpHandler&&(this.chartContext.removeEventListener("mouseup",this.mouseUpHandler),this.mouseUpHandler=null)},this.chartContext.addEventListener("mousemove",this.mouseMoveHandler),this.chartContext.addEventListener("mouseup",this.mouseUpHandler)})),this.splitBarContainer.addEventListener("keydown",(t=>{let e;const n=parseInt(this.leftContainer.style.flexBasis)||this.options.leftContainerWidth||400;switch(t.key){case"ArrowLeft":t.preventDefault(),e=Math.max(0,n-10),this.leftContainer.style.flexBasis=`${e}px`,this.splitBarContainer.setAttribute(jt,String(e)),this.dispatchResizeEvent();break;case"ArrowRight":t.preventDefault(),e=n+10,this.leftContainer.style.flexBasis=`${e}px`,this.splitBarContainer.setAttribute(jt,String(e)),this.dispatchResizeEvent();break;case"Home":t.preventDefault(),this.leftContainer.style.flexBasis="0px",this.splitBarContainer.setAttribute(jt,"0"),this.dispatchResizeEvent();break;case"End":{t.preventDefault();const e=this.splitBarContainer.parentElement;if(e){const t=e.clientWidth-50;this.leftContainer.style.flexBasis=`${t}px`,this.splitBarContainer.setAttribute(jt,String(Math.round(t)))}this.dispatchResizeEvent();break}}}))}dispatchResizeEvent(){const t=new CustomEvent("splitview-resize",{bubbles:!0,detail:{leftWidth:parseInt(this.leftContainer.style.flexBasis)||0}});this.chartContext.dispatchEvent(t)}cleanupEventListeners(){this.mouseMoveHandler&&(this.chartContext.removeEventListener("mousemove",this.mouseMoveHandler),this.mouseMoveHandler=null),this.mouseUpHandler&&(this.chartContext.removeEventListener("mouseup",this.mouseUpHandler),this.mouseUpHandler=null)}render(){this.injectStyles(),this.buildElements(),this.attachEventListeners();const t=m(this.chartContext,{className:"split-view-container"});return t.append(this.leftContainer,this.splitBarContainer,this.rightContainer),[t]}destroy(){this.cleanupEventListeners()}}const Kt="data-chart-instance";class Xt{constructor(t,e,n,i,o,r){this.element=t,this.options=e,this.domCache=n,this.chartContext=i,this.instanceId=o,this.getViewMode=r}updateOptions(t){this.options=t}setupChartContainerPositioning(){if(this.element){"static"===window.getComputedStyle(this.element).position&&(this.element.style.position="relative"),this.element.style.isolation="isolate"}}createLayout(t,e,n,i,o){t.style.position="relative",t.style.isolation="isolate";const r=this.instanceId,a=m(this.chartContext,{className:Pt.tasksContainer.slice(1)});let s,l;if(!Array.isArray(e))return void R.error("Tasks table should be an array of [header, body]");s=e[0],l=e[1];const c=m(this.chartContext,{className:Pt.tasksBodyWrapper.slice(1)});c.appendChild(l),a.appendChild(s),a.appendChild(c);const d=m(this.chartContext,{className:Pt.timelineContainer.slice(1)});d.setAttribute(Kt,r);const h=n[0];d.appendChild(h);const p=m(this.chartContext,{className:Pt.timelineBodyWrapper.slice(1)});for(let t=1;t<n.length-1;t++)p.appendChild(n[t]);d.appendChild(p);const u=n[n.length-1];if(i){const e=new Ut(this.chartContext,a,d,{leftContainerClass:"",leftContainerWidth:o,rightContainerClass:""}).render();t.append(...e)}else a.style.flex=`0 0 ${o}px`,t.append(a,d);t.appendChild(u)}syncTasksColumnWidths(){this.domCache.tasksContainer}fillEmptyRowsAfterRender(){const t=this.domCache.ganttContainer,e=this.domCache.timelineBody,n=this.domCache.tasksDataContainer;if(!t||!e||!n)return;e.querySelectorAll(Pt.timelineEmptyRow).forEach((t=>t.remove()));n.querySelectorAll(Pt.tasksEmptyRow).forEach((t=>t.remove()));const i=t.clientHeight,o=e.querySelectorAll(`${Pt.timelineDataRow}:not(${Pt.timelineEmptyRow})`).length,r=this.options.rowHeight,a=Math.floor(i/r),s=Math.max(0,a-o);if(0===s)return;let l=0;const c=e.querySelector(Pt.timelineDataRow);if(c)l=c.querySelectorAll(Pt.timelineDataCell).length;else{const t=this.domCache.timelineHeader;if(t){l=t.querySelectorAll(Pt.timelineHeaderCell).length}}if(0!==l){for(let t=0;t<s;t++){const n=this.createEmptyTimelineRow(t,l);e.appendChild(n)}for(let t=0;t<s;t++){const e=this.createEmptyTaskRow(t);n.appendChild(e)}}}createEmptyTimelineRow(t,e){const n=m(this.chartContext,{className:`${Pt.timelineDataRow.slice(1)} ${Pt.timelineEmptyRow.slice(1)}`}),{rowHeight:i}=this.options,o=this.instanceId,r=this.getViewMode();n.setAttribute("data-taskid",`empty-${t}`),n.setAttribute(Kt,o),n.style.height=`${i}px`;for(let t=0;t<e;t++){const t=m(this.chartContext,{className:Pt.timelineDataCell.slice(1),style:{height:`${i}px`,minWidth:`${N[r]}px`}});t.setAttribute(Kt,o),n.appendChild(t)}return n}createEmptyTaskRow(t){const e=m(this.chartContext,{className:`${Pt.tasksDataRow.slice(1)} ${Pt.tasksEmptyRow.slice(1)}`}),{rowHeight:n}=this.options,i=this.instanceId;return e.setAttribute("data-taskid",`empty-${t}`),e.setAttribute(Kt,i),e.style.height=`${n}px`,nt.forEach((({key:t})=>{const o=m(this.chartContext,{className:Pt.tasksDataCell.slice(1),content:""});o.setAttribute("data-columnid",t),o.setAttribute(Kt,i),o.style.height=`${n}px`,o.style.color="var(--text-color)",e.appendChild(o)})),e}}const Gt="\n .gantt-dialog-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: none;\n z-index: 999;\n overflow: hidden;\n }\n\n .gantt-dialog-container .dialog-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n }\n\n .gantt-dialog-container .gantt-dialog {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background: var(--dialog-bg-color, white);\n border-radius: 4px;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n border: 1px solid var(--dialog-border-color, #eee);\n z-index: 1000;\n min-width: 300px;\n max-width: 90%;\n max-height: 90%;\n display: flex;\n flex-direction: column;\n }\n\n .gantt-dialog .dialog-header {\n padding: 12px 16px;\n border-bottom: 1px solid var(--dialog-border-color, #eee);\n display: flex;\n justify-content: space-between;\n align-items: center;\n background: var(--header-bg-color, #f3f3f3);\n flex-shrink: 0;\n }\n\n .gantt-dialog .dialog-title {\n font-weight: 600;\n font-size: 16px;\n color: var(--header-text-color, #333);\n margin: 0;\n }\n\n .gantt-dialog .dialog-close {\n background: none;\n border: none;\n font-size: 20px;\n cursor: pointer;\n padding: 0;\n color: var(--text-color, #666);\n transition: color 0.2s;\n line-height: 1;\n }\n\n .gantt-dialog .dialog-close:hover {\n color: var(--text-color, #333);\n }\n\n .gantt-dialog .dialog-content {\n padding: 16px;\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n background: var(--dialog-bg-color, white);\n color: var(--text-color, #333);\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar {\n width: 8px;\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar-track {\n background: var(--dialog-bg-color, #f1f1f1);\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar-thumb {\n background: var(--border-color, #888);\n border-radius: 4px;\n }\n\n .gantt-dialog .dialog-content::-webkit-scrollbar-thumb:hover {\n background: var(--text-color, #555);\n }\n\n .gantt-dialog-container.show {\n display: block;\n }\n\n .gantt-dialog-container.animate .dialog-overlay {\n animation: fadeIn 0.2s ease-out;\n }\n\n .gantt-dialog-container.animate .gantt-dialog {\n animation: slideIn 0.3s ease-out;\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translate(-50%, -48%);\n }\n to {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n\n .gantt-container {\n position: relative;\n }\n",Qt="\n .dropdown {\n position: relative;\n display: inline-block;\n }\n\n .dropdown .gantt-action-button {\n border-radius: 4px;\n }\n\n .dropdown.show .gantt-action-button {\n background: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--button-bg-color, #0066cc);\n }\n \n .dropdown-btn {\n padding: 8px 16px;\n background-color: var(--toolbar-bg-color, #fff);\n color: var(--text-color, rgba(0, 0, 0, 0.7));\n border: 1px solid var(--toolbar-border-color, #ddd);\n cursor: pointer;\n font-weight: bold;\n border-radius: 2px;\n font-family: inherit;\n font-size: inherit;\n line-height: 1.5;\n transition: background-color 0.2s ease, border-color 0.2s ease;\n }\n \n .dropdown-btn:hover {\n background-color: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--toolbar-border-color, #bbb);\n }\n \n .dropdown-btn:focus {\n outline: none;\n border-color: var(--button-bg-color, #0066cc);\n box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);\n }\n \n .dropdown-content {\n display: none;\n position: absolute;\n background-color: var(--dialog-bg-color, #fff);\n min-width: 160px;\n box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);\n z-index: 1000;\n border-radius: 4px;\n right: 0;\n top: calc(100% + 4px);\n border: 1px solid var(--dialog-border-color, #D9D9D9);\n overflow: hidden;\n }\n \n .dropdown-content a {\n color: var(--text-color, #333);\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n font-family: inherit;\n font-size: 13px;\n line-height: 1.4;\n transition: background-color 0.2s ease;\n cursor: pointer;\n }\n \n .dropdown-content a:hover {\n background-color: var(--toolbar-hover-bg-color, #f1f1f1);\n }\n \n .dropdown-content a:focus {\n background-color: var(--button-hover-bg-color, #e6f3ff);\n outline: none;\n }\n \n .dropdown.show .dropdown-content {\n display: block;\n animation: dropdownSlideDown 0.2s ease-out;\n }\n \n @keyframes dropdownSlideDown {\n from {\n opacity: 0;\n transform: translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n \n /* Shadow DOM specific adjustments */\n :host .dropdown {\n position: relative;\n display: inline-block;\n }\n",Zt="\n * {\n box-sizing: border-box;\n }\n\n .gantt-container * {\n user-select: none;\n }\n\n .gantt-actions-container {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 6px 10px;\n flex: 0 0 36px;\n min-height: 36px;\n max-height: 36px;\n background-color: var(--background-color, #FFFFFF);\n border-bottom: 1px solid var(--border-color, #DFE0E1);\n }\n\n .gantt-actions-spacer {\n flex: 1;\n min-width: 8px;\n }\n\n .gantt-action-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 0;\n border-radius: 4px;\n background: var(--toolbar-bg-color, #fff);\n color: var(--text-color, #333);\n cursor: pointer;\n transition: all 0.15s ease;\n flex-shrink: 0;\n }\n\n .gantt-action-button:hover:not(:disabled) {\n background: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--toolbar-border-color, #999);\n transform: translateY(-1px);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);\n }\n\n .gantt-action-button:active:not(:disabled) {\n transform: translateY(0);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\n }\n\n .gantt-action-button:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n background: var(--toolbar-bg-color, #fafafa);\n }\n\n .gantt-action-button svg {\n width: 16px;\n height: 16px;\n stroke: currentColor;\n flex-shrink: 0;\n }\n\n .gantt-action-separator {\n width: 1px;\n height: 20px;\n background-color: var(--border-color, #DFE0E1);\n margin: 0 4px;\n flex-shrink: 0;\n }\n\n .gantt-view-mode-display {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 10px;\n height: 28px;\n font-size: 13px;\n color: var(--text-color, #666);\n background: var(--toolbar-bg-color, #f8f9fa);\n border-radius: 4px;\n margin-left: 4px;\n font-weight: 500;\n white-space: nowrap;\n flex-shrink: 0;\n }\n\n .gantt-view-mode-display svg {\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n }\n \n .gantt-container {\n display: flex;\n flex: 1 1 auto;\n min-height: 0;\n min-width: 0;\n border: 1px solid var(--border-color, #DFE0E1);\n border-top: none;\n position: relative;\n background-color: var(--background-color, #FFFFFF);\n overflow: hidden;\n height: 100%;\n box-sizing: border-box;\n }\n \n .gantt-button {\n border: 1px solid var(--toolbar-border-color, #D9D9D9);\n border-radius: 2px;\n background: var(--toolbar-bg-color, #fff);\n padding: 4px 12px;\n color: var(--text-color, rgba(0, 0, 0, 0.7));\n line-height: 20px;\n font-weight: bold;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n\n .gantt-button:hover {\n background: var(--toolbar-hover-bg-color, #f8f9fa);\n }\n \n .gantt-button:disabled {\n color: rgba(128, 128, 128, 0.5);\n opacity: 0.6;\n }\n\n /* ── WCAG 2.1 AA: focus styles ─────────────────────────────────────────── */\n\n .tasks-data-row:focus-visible {\n outline: 2px solid var(--focus-ring-color, #005fcc);\n outline-offset: -2px;\n }\n\n .bar-timeline:focus {\n outline: 2px solid var(--focus-ring-color, #005fcc);\n outline-offset: 2px;\n }\n\n .tasks-data-row[aria-selected=\"true\"] {\n background-color: var(--row-selected-bg-color, rgba(0, 95, 204, 0.12));\n }\n\n /* ── Selection: checkbox column ────────────────────────────────────────── */\n\n .gantt-checkbox-cell {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n min-width: 28px;\n max-width: 28px;\n }\n\n .gantt-selection-checkbox,\n .gantt-select-all-checkbox {\n width: 15px;\n height: 15px;\n margin: 0;\n cursor: pointer;\n accent-color: var(--button-bg-color, #005fcc);\n }\n\n /* ── Selection: toolbar count indicator ─────────────────────────────────── */\n\n .gantt-selection-count {\n display: inline-flex;\n align-items: center;\n padding: 3px 10px;\n height: 24px;\n font-size: 12px;\n font-weight: 500;\n color: var(--button-bg-color, #005fcc);\n background: var(--row-selected-bg-color, rgba(0, 95, 204, 0.12));\n border-radius: 12px;\n margin-left: 8px;\n white-space: nowrap;\n flex-shrink: 0;\n }\n\n /* ── Custom toolbar items (Phase 2) ────────────────────────────────────── */\n\n .gantt-toolbar-button {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 0 10px;\n width: auto;\n min-width: 28px;\n font-size: 13px;\n font-weight: 500;\n color: var(--text-color, #333);\n white-space: nowrap;\n }\n\n .gantt-toolbar-button span {\n line-height: 1;\n }\n\n .gantt-toolbar-select-wrapper {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n flex-shrink: 0;\n }\n\n .gantt-toolbar-select-label {\n font-size: 13px;\n color: var(--text-color, #666);\n white-space: nowrap;\n flex-shrink: 0;\n }\n\n .gantt-toolbar-select {\n height: 28px;\n padding: 0 24px 0 8px;\n border: 1px solid var(--border-color, #DFE0E1);\n border-radius: 4px;\n background: var(--toolbar-bg-color, #fff);\n color: var(--text-color, #333);\n font-size: 13px;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");\n background-repeat: no-repeat;\n background-position: right 8px center;\n min-width: 100px;\n max-width: 180px;\n outline: none;\n }\n\n .gantt-toolbar-select:hover {\n border-color: var(--button-bg-color, #005fcc);\n }\n\n .gantt-toolbar-select:focus {\n border-color: var(--focus-ring-color, #005fcc);\n box-shadow: 0 0 0 2px rgba(0, 95, 204, 0.2);\n }\n\n /* ── prefers-reduced-motion ─────────────────────────────────────────────── */\n\n @media (prefers-reduced-motion: reduce) {\n .bar-timeline,\n .bar-timeline-progress,\n .bar-handle,\n .gantt-action-button,\n .gantt-button,\n .tasks-data-row,\n .gantt-dialog-container,\n .gantt-dialog {\n transition: none !important;\n animation: none !important;\n }\n }\n\n /* JS-detected reduced motion class (mirrors the media query in JS context) */\n .gantt-reduced-motion .bar-timeline,\n .gantt-reduced-motion .bar-timeline-progress,\n .gantt-reduced-motion .bar-handle,\n .gantt-reduced-motion .gantt-action-button,\n .gantt-reduced-motion .gantt-button,\n .gantt-reduced-motion .tasks-data-row,\n .gantt-reduced-motion .gantt-dialog-container,\n .gantt-reduced-motion .gantt-dialog {\n transition: none !important;\n animation: none !important;\n }\n",Jt="\n .gantt-container ::-webkit-scrollbar {\n width: 12px;\n height: 12px;\n }\n\n .gantt-container ::-webkit-scrollbar-track {\n background: var(--scrollbar-track-color, #F5F5F5);\n border-radius: 4px;\n }\n\n .gantt-container ::-webkit-scrollbar-thumb {\n background: var(--scrollbar-thumb-color, #C1C1C1);\n border-radius: 4px;\n border: 2px solid var(--scrollbar-track-color, #F5F5F5);\n }\n\n .gantt-container ::-webkit-scrollbar-thumb:hover {\n background: var(--scrollbar-thumb-hover-color, #A8A8A8);\n }\n\n .gantt-container * {\n scrollbar-width: thin;\n scrollbar-color: var(--scrollbar-thumb-color, #C1C1C1) var(--scrollbar-track-color, #F5F5F5);\n }\n\n /* Shadow DOM support */\n :host .gantt-container ::-webkit-scrollbar {\n width: 12px;\n height: 12px;\n }\n\n :host .gantt-container ::-webkit-scrollbar-track {\n background: var(--scrollbar-track-color, #F5F5F5);\n border-radius: 4px;\n }\n\n :host .gantt-container ::-webkit-scrollbar-thumb {\n background: var(--scrollbar-thumb-color, #C1C1C1);\n border-radius: 4px;\n border: 2px solid var(--scrollbar-track-color, #F5F5F5);\n }\n\n :host .gantt-container ::-webkit-scrollbar-thumb:hover {\n background: var(--scrollbar-thumb-hover-color, #A8A8A8);\n }\n\n :host .gantt-container * {\n scrollbar-width: thin;\n scrollbar-color: var(--scrollbar-thumb-color, #C1C1C1) var(--scrollbar-track-color, #F5F5F5);\n }\n",te='\n\n .task-form {\n overflow: visible;\n }\n\n .task-form .form-group {\n margin-bottom: 18px;\n position: relative;\n }\n\n /* extra padding to last form group for breathing room */\n .task-form .form-group:last-of-type {\n margin-bottom: 24px;\n }\n\n .task-form label {\n display: block;\n margin-bottom: 5px;\n font-weight: 500;\n color: var(--text-color, #333);\n }\n\n .task-form input {\n width: 100%;\n padding: 8px;\n border: 1px solid var(--dialog-border-color, #ddd);\n border-radius: 4px;\n font-size: 14px;\n background-color: var(--dialog-bg-color, #fff);\n color: var(--text-color, #333);\n }\n\n .task-form input:focus {\n outline: none;\n border-color: var(--button-bg-color, #0066cc);\n }\n\n .task-form .grid {\n display: flex;\n justify-content: space-between;\n gap: 12px;\n }\n\n .task-form .grid .form-group {\n flex: 1;\n }\n\n .task-form .form-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid var(--dialog-border-color, #eee);\n position: sticky;\n bottom: -16px;\n background: var(--dialog-bg-color, white);\n margin-left: -16px;\n margin-right: -16px;\n margin-bottom: -16px;\n padding-left: 16px;\n padding-right: 16px;\n padding-bottom: 16px;\n }\n\n .task-form .btn-primary {\n background: var(--button-bg-color, #0066cc);\n color: var(--button-text-color, white);\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-weight: 500;\n }\n\n .task-form .btn-primary:hover {\n background: var(--button-hover-bg-color, #0052a3);\n }\n\n .task-form .btn-disabled,\n .task-form .btn-disabled:hover {\n background: #99c2ff;\n cursor: not-allowed;\n opacity: 0.7;\n }\n\n .task-form .form-error {\n position: absolute;\n bottom: -15px;\n left: 0;\n color: #dc3545;\n font-size: 12px;\n margin-top: 4px;\n line-height: 1.2;\n transition: opacity 0.2s ease;\n }\n\n .task-form .invalid {\n border-color: #dc3545;\n }\n\n .task-form .invalid:focus {\n border-color: #dc3545;\n box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);\n }\n\n .color-picker-wrapper {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .color-picker-wrapper input[type="color"] {\n -webkit-appearance: none;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n\n .color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {\n padding: 0;\n }\n\n .color-picker-wrapper input[type="color"]::-webkit-color-swatch {\n border: 1px solid var(--dialog-border-color, #ddd);\n border-radius: 4px;\n }\n\n .color-picker-wrapper .color-preview {\n font-size: 12px;\n color: var(--text-color, #666);\n }\n',ee="\n .tasks-container {\n height: 100%;\n position: relative;\n display: flex;\n flex-direction: column;\n overflow-x: visible;\n overflow-y: visible;\n }\n\n .tasks-header {\n flex-shrink: 0;\n position: sticky;\n top: 0;\n z-index: 10;\n background-color: var(--header-bg-color, #F3F3F3);\n overflow: hidden;\n }\n\n .tasks-header-row {\n display: grid;\n width: 100%;\n }\n\n .tasks-header-cell {\n padding: 0 10px;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n border: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n color: var(--text-color, #000);\n box-sizing: border-box;\n font-weight: 600;\n }\n\n .tasks-body-wrapper {\n flex: 1;\n overflow: visible;\n position: relative;\n }\n\n .tasks-data-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n }\n\n .tasks-data-row {\n display: grid;\n width: 100%;\n border-bottom: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n box-sizing: border-box;\n }\n\n .tasks-data-cell {\n padding: 0 10px;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n border-left: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n border-right: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n color: var(--text-color, #000);\n box-sizing: border-box;\n }\n\n .tasks-data-row .tasks-data-cell:first-child {\n border-left: none;\n }\n\n .tasks-data-row .tasks-data-cell:last-child {\n border-right: none;\n }\n\n .tasks-data-row .task-toggle-icon,\n .tasks-data-row .task-toggle-icon-blank {\n display: inline-block;\n margin-right: 5px;\n width: 10px;\n height: 10px;\n vertical-align: middle;\n flex-shrink: 0;\n }\n\n .tasks-data-row .task-toggle-icon {\n cursor: pointer;\n position: relative;\n }\n\n /* Chevron (expanded) - pointing down */\n .tasks-data-row .task-toggle-icon.expanded::before {\n content: '';\n position: absolute;\n width: 6px;\n height: 6px;\n border-right: 2px solid var(--text-color, #000000);\n border-bottom: 2px solid var(--text-color, #000000);\n transform: rotate(45deg);\n top: 0;\n left: 2px;\n }\n\n /* Chevron - pointing right (collapsed) */\n .tasks-data-row .task-toggle-icon.collapsed::before {\n content: '';\n position: absolute;\n width: 6px;\n height: 6px;\n border-right: 2px solid var(--text-color, #000000);\n border-bottom: 2px solid var(--text-color, #000000);\n transform: rotate(-45deg);\n top: 2px;\n left: 0;\n }\n\n .tasks-data-row .task-toggle-icon:hover::before {\n opacity: 0.7;\n }\n\n /* Shadow DOM specific */\n :host .tasks-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n :host .tasks-header {\n position: sticky;\n top: 0;\n z-index: 10;\n }\n",ne="\n .gantt-container .timeline-container {\n width: 100%;\n height: 100%;\n position: relative;\n background-color: var(--background-color, #FFFFFF);\n display: flex;\n flex-direction: column;\n overflow: visible;\n padding-bottom: 0;\n box-sizing: border-box;\n }\n\n .timeline-container .timeline-header {\n position: sticky;\n top: 0;\n z-index: 100;\n background-color: var(--header-bg-color, #F3F3F3);\n flex-shrink: 0;\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n scrollbar-width: none; \n -ms-overflow-style: none; \n }\n\n .timeline-container .timeline-header::-webkit-scrollbar {\n display: none;\n height: 0;\n width: 0;\n }\n\n /* Shadow DOM specific */\n :host .timeline-container .timeline-header {\n scrollbar-width: none !important;\n -ms-overflow-style: none !important;\n }\n\n :host .timeline-container .timeline-header::-webkit-scrollbar {\n display: none !important;\n height: 0 !important;\n width: 0 !important;\n }\n\n .timeline-container .timeline-header > .timeline-header-row {\n width: max-content;\n position: relative;\n }\n\n .timeline-container .timeline-body-wrapper {\n flex: 1;\n overflow-x: auto;\n overflow-y: hidden;\n position: relative;\n width: 100%;\n min-height: 0;\n scrollbar-width: none;\n -ms-overflow-style: none;\n padding-bottom: 0; \n margin-bottom: 0;\n }\n\n .timeline-body-wrapper .timeline-horizontal-scroll, .timeline-container .timeline-body-wrapper::-webkit-scrollbar {\n display: none;\n height: 0;\n width: 0;\n }\n\n /* shadow DOM specific */\n :host .timeline-container .timeline-body-wrapper {\n scrollbar-width: none !important;\n -ms-overflow-style: none !important;\n }\n\n :host .timeline-container .timeline-body-wrapper::-webkit-scrollbar {\n display: none !important;\n height: 0 !important;\n width: 0 !important;\n }\n\n\n .timeline-horizontal-scroll {\n position: absolute;\n bottom: 0;\n height: 17px;\n overflow-x: auto;\n overflow-y: hidden;\n z-index: 300;\n background-color: var(--split-bar-color, var(--background-color, #FFFFFF));\n border-top: 1px solid var(--border-color, #DFE0E1);\n box-sizing: border-box;\n display: block;\n visibility: visible;\n opacity: 1;\n pointer-events: auto;\n }\n\n .timeline-horizontal-scroll-content {\n height: 1px;\n width: max-content;\n }\n\n .timeline-container .annotation,\n .timeline-container .annotation-container {\n position: absolute;\n top: 0;\n left: 0;\n pointer-events: none;\n }\n\n .timeline-container .annotation-container > * {\n pointer-events: auto;\n }\n\n .timeline-container .bar-container {\n position: absolute;\n top: 0;\n left: 0;\n pointer-events: none;\n }\n\n .timeline-container .bar-container > * {\n pointer-events: auto;\n }\n\n .timeline-container .bar-timeline {\n position: absolute;\n cursor: move;\n cursor: grab;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .timeline-container .bar-timeline .bar-handle {\n height: 100%;\n width: 5px;\n position: absolute;\n z-index: 1000;\n background: transparent;\n }\n\n .timeline-container .bar-timeline .bar-handle:hover {\n cursor: col-resize;\n }\n\n .resizing {\n pointer-events: none;\n opacity: 0.8;\n }\n\n .timeline-container .bar-timeline .bar-handle.handle-left {\n left: -5px;\n }\n\n .timeline-container .bar-timeline .bar-handle.handle-right {\n right: -5px;\n }\n\n .timeline-container .bar-timeline.dragging {\n cursor: grabbing;\n }\n\n .timeline-container .bar-baseline {\n position: absolute;\n pointer-events: none;\n z-index: 1;\n }\n\n .timeline-container .bar-timeline.bar-critical {\n background-color: var(--critical-bar-color, #e53935) !important;\n }\n\n .timeline-container .bar-timeline.bar-critical .bar-timeline-progress {\n background-color: color-mix(in srgb, var(--critical-bar-color, #e53935) 70%, white) !important;\n }\n\n svg path.critical-arrow {\n stroke: var(--critical-arrow-color, #e53935) !important;\n stroke-width: 2.5 !important;\n }\n\n .bar-timeline .bar-timeline-progress {\n position: absolute;\n pointer-events: none;\n height: 100%;\n left: 0;\n }\n\n .bar-timeline .bar-label {\n white-space: nowrap;\n pointer-events: none;\n overflow: hidden;\n z-index: 2;\n }\n\n .timeline-container .timeline-body {\n width: max-content;\n position: relative;\n padding-bottom: 17px;\n }\n \n .timeline-container .timeline-header-row,\n .timeline-container .timeline-data-row {\n display: flex;\n }\n\n .timeline-container .timeline-header-cell,\n .timeline-container .timeline-data-cell {\n padding: 0 10px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n justify-content: center;\n border: var(--cell-border-width, 1px) solid var(--cell-border-color, #eff0f0);\n color: var(--text-color, #000);\n }\n\n .timeline-container .timeline-header-cell {\n background-color: var(--header-bg-color, #F3F3F3);\n color: var(--header-text-color, #333);\n }\n",ie='\n #apexgantt-tooltip-container,\n [role="tooltip"] {\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s ease;\n font-family: inherit;\n font-size: 13px;\n line-height: 1.4;\n display: none;\n width: 300px !important;\n max-width: 300px !important;\n box-sizing: border-box;\n }\n \n #apexgantt-tooltip-container.visible,\n [role="tooltip"].visible {\n display: block;\n opacity: 1;\n visibility: visible;\n }\n \n #apexgantt-tooltip-container .tooltip-content,\n [role="tooltip"] .tooltip-content {\n padding: 12px 16px;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);\n width: 100%;\n word-wrap: break-word;\n overflow-wrap: break-word;\n box-sizing: border-box;\n display: block;\n border: 1px solid rgba(255, 255, 255, 0.1);\n }\n \n /* Shadow DOM specific adjustments */\n :host #apexgantt-tooltip-container,\n :host [role="tooltip"] {\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s ease;\n font-family: inherit;\n font-size: 13px;\n line-height: 1.4;\n display: none;\n width: 300px !important;\n max-width: 300px !important;\n box-sizing: border-box;\n }\n \n :host #apexgantt-tooltip-container.visible,\n :host [role="tooltip"].visible {\n display: block;\n opacity: 1;\n visibility: visible;\n }\n\n #apexgantt-tooltip-container .tooltip-content div,\n [role="tooltip"] .tooltip-content div {\n margin: 6px 0;\n word-break: break-word;\n line-height: 1.4;\n }\n \n #apexgantt-tooltip-container .tooltip-content strong,\n [role="tooltip"] .tooltip-content strong {\n font-weight: 600;\n display: inline;\n margin-right: 8px;\n }\n \n #apexgantt-tooltip-container .tooltip-content span,\n [role="tooltip"] .tooltip-content span {\n display: inline;\n }\n \n /* First item (Name) styling */\n #apexgantt-tooltip-container .tooltip-content div:first-child,\n [role="tooltip"] .tooltip-content div:first-child {\n margin-bottom: 10px;\n padding-bottom: 8px;\n border-bottom: 1px solid rgba(255, 255, 255, 0.2);\n }\n \n #apexgantt-tooltip-container .tooltip-content div:first-child strong,\n [role="tooltip"] .tooltip-content div:first-child strong {\n font-weight: 700;\n }\n \n #apexgantt-tooltip-container .tooltip-content div:last-child,\n [role="tooltip"] .tooltip-content div:last-child {\n margin-bottom: 0;\n }\n';class oe{constructor(t,e,n,i,o,r){this.element=t,this.domCache=e,this.options=n,this.chartContext=i,this.isShadowDOM=o,this.instanceId=r,this.stylesInjected=!1}setupShadowDOMEnvironment(){if(!this.isShadowDOM)return;const t=this.chartContext.getContext().host;t&&(t.style.display="block",t.style.boxSizing="border-box",t.style.contain="layout style"),this.element&&(this.element.style.display="block",this.element.style.boxSizing="border-box")}injectGanttStyles(){if(!this.stylesInjected)if(this.isShadowDOM)this.injectStylesDirectly();else try{const t=[{content:Zt,id:"gantt-core-styles",options:{priority:"high"}},{content:ne,id:"gantt-timeline-styles"},{content:ee,id:"gantt-table-styles"},{content:Gt,id:"gantt-dialog-styles"},{content:te,id:"gantt-taskform-styles"},{content:ie,id:"gantt-tooltip-styles"},{content:a,id:"gantt-toolbar-styles"},{content:Qt,id:"gantt-dropdown-styles"},{content:Jt,id:"gantt-scrollbar-styles"}];this.chartContext.injectStylesheets(t),this.stylesInjected=!0}catch(t){R.error("injectGanttStyles: ChartContext injection failed",t)}}injectStylesDirectly(){const t=this.chartContext.getContext();if(t.querySelector("#gantt-all-styles"))return void(this.stylesInjected=!0);const e=document.createElement("style");e.id="gantt-all-styles",e.textContent=`\n /* Shadow DOM CSS Reset - Critical for proper layout */\n :host {\n all: initial;\n display: block;\n contain: layout style;\n }\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n div, table, thead, tbody, tr, td, th {\n display: revert;\n margin: 0;\n padding: 0;\n border: 0;\n }\n\n .split-view-container,\n .gantt-container {\n display: flex !important;\n width: 100% !important;\n height: 100% !important;\n }\n\n .split-left-container,\n .split-right-container {\n display: block !important;\n }\n\n .timeline-container {\n flex: 1 !important;\n overflow: auto !important;\n position: relative !important;\n }\n\n .tasks-container {\n flex-shrink: 0 !important;\n overflow: auto !important;\n }\n\n ${Zt}\n ${ne}\n ${ee}\n ${Gt}\n ${te}\n ${ie}\n ${a}\n ${Qt}\n ${Jt}\n `,t.insertBefore(e,t.firstChild),this.stylesInjected=!0}setCSSVariables(){["--apex-gantt-bar-fill","--apex-gantt-background-color","--apex-gantt-row-bg-even","--apex-gantt-row-bg-odd","--apex-gantt-header-bg","--apex-gantt-grid-line","--apex-gantt-dependency-line","--apex-gantt-font-family","--apex-gantt-font-size","--apex-gantt-font-color"].forEach((t=>this.element.style.removeProperty(t)));const t=Dt(this.element),e=t.gridLine||this.options.cellBorderColor,n=this.options.cellBorderWidth,i=t.fontColor||this.options.fontColor,o=t.headerBg||this.options.headerBackground,{tooltipBGColor:r,tooltipBorderColor:a,borderColor:s,barTextColor:l}=this.options,c=t.bgColor||this.options.backgroundColor,d=t.barFill||this.options.barBackgroundColor,h=t.dependencyLine||this.options.arrowColor,p=[...this.options.rowBackgroundColors??[]];t.rowBgEven&&(p[0]=t.rowBgEven),t.rowBgOdd&&(p[1]=t.rowBgOdd),this.element.style.setProperty("--apex-gantt-row-bg-even",p[0]??""),this.element.style.setProperty("--apex-gantt-row-bg-odd",p[1]??p[0]??""),this.element.style.setProperty("--cell-border-color",e),this.element.style.setProperty("--cell-border-width",n),this.element.style.setProperty("--gantt-font-color",i),this.element.style.setProperty("--text-color",i),this.element.style.setProperty("--header-bg-color",o),this.element.style.setProperty("--header-text-color",i),this.element.style.setProperty("--tooltip-bg-color",r),this.element.style.setProperty("--tooltip-border-color",a),this.element.style.setProperty("--tooltip-text-color",i),this.element.style.setProperty("--background-color",c),this.element.style.setProperty("--border-color",s),this.element.style.setProperty("--dialog-bg-color",c),this.element.style.setProperty("--dialog-border-color",s),this.element.style.setProperty("--button-bg-color",d),this.element.style.setProperty("--button-text-color",l),this.element.style.setProperty("--button-hover-bg-color",h),this.element.style.setProperty("--toolbar-bg-color",c),this.element.style.setProperty("--toolbar-border-color",s),this.element.style.setProperty("--toolbar-hover-bg-color",e),this.element.style.setProperty("--scrollbar-track-color",c),this.element.style.setProperty("--scrollbar-thumb-color",s),this.element.style.setProperty("--scrollbar-thumb-hover-color",e),this.element.style.setProperty("--split-bar-color",e),this.element.style.setProperty("--split-bar-hover-color",h),this.element.style.setProperty("--split-bar-border-color",s),this.element.style.setProperty("--split-bar-handle-color",i),this.element.style.setProperty("--split-bar-hover-border-color",h),this.element.style.setProperty("--critical-bar-color",this.options.criticalBarColor),this.element.style.setProperty("--critical-arrow-color",this.options.criticalArrowColor);this.isColorDark(c)?this.element.style.setProperty("--toolbar-icon-filter","invert(1) brightness(2)"):this.element.style.setProperty("--toolbar-icon-filter","none")}handleWatermark(){const t=this.domCache.ganttContainer;if(!t)return;const e=t.parentNode;e&&(r.isLicenseValid()?l.remove(e):l.add(e))}isColorDark(t){const e=t.replace("#","");return(.299*parseInt(e.substring(0,2),16)+.587*parseInt(e.substring(2,4),16)+.114*parseInt(e.substring(4,6),16))/255<.5}cleanupScrollbarStyles(){try{this.chartContext.getInjectedStyleIds().filter((t=>t.startsWith(`scrollbar-${this.instanceId}`))).forEach((t=>this.chartContext.removeStyles(t)));const t=this.domCache.horizontalScroll;if(t){const e=t.style.width,n=t.style.left,i=t.style.bottom;t.removeAttribute("style"),e&&(t.style.width=e),n&&(t.style.left=n),i&&(t.style.bottom=i)}}catch(t){R.warn("Error cleaning up scrollbar styles:",t)}}updateOptions(t){this.options=t}resetStylesInjected(){this.stylesInjected=!1}areStylesInjected(){return this.stylesInjected}}const re="data-taskid",ae="aria-level";class se{constructor(t,e,n,i,o){this.chartContext=t,this.dataManager=e,this.getTaskContainer=n,this.reRender=i,this.selectionManager=o,this.keydownHandler=null}attach(){this.detach();const t=this.getTaskContainer();t&&(this.initRovingTabindex(t),this.keydownHandler=e=>this.handleKeydown(e,t),t.addEventListener("keydown",this.keydownHandler))}detach(){const t=this.getTaskContainer();t&&this.keydownHandler&&t.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null}initRovingTabindex(t){this.getVisibleRows(t).forEach(((t,e)=>{t.setAttribute("tabindex",0===e?"0":"-1")}))}getVisibleRows(t){return Array.from(t.querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`))}moveFocusToRow(t,e){this.getVisibleRows(e).forEach((t=>t.setAttribute("tabindex","-1"))),t.setAttribute("tabindex","0"),t.focus()}handleKeydown(t,e){var n;const i=this.getVisibleRows(e);if(0===i.length)return;const o=this.chartContext.getActiveElement(),r=o?i.indexOf(o):-1;switch(t.key){case"ArrowDown":{t.preventDefault();const n=i[Math.min(r+1,i.length-1)];n&&this.moveFocusToRow(n,e);break}case"ArrowUp":{t.preventDefault();const n=i[Math.max(r-1,0)];n&&this.moveFocusToRow(n,e);break}case"ArrowRight":{if(t.preventDefault(),r<0||!o)break;const n=o.getAttribute(re);if(!n)break;const a=o.getAttribute("aria-expanded");if("false"===a)this.dataManager.toggleTask(n),this.reRender();else if("true"===a){const t=parseInt(o.getAttribute(ae)||"1",10),n=i[r+1];if(n){parseInt(n.getAttribute(ae)||"1",10)>t&&this.moveFocusToRow(n,e)}}break}case"ArrowLeft":{if(t.preventDefault(),r<0||!o)break;const n=o.getAttribute(re);if(!n)break;if("true"===o.getAttribute("aria-expanded"))this.dataManager.toggleTask(n),this.reRender();else{const t=parseInt(o.getAttribute(ae)||"1",10);if(t<=1)break;for(let n=r-1;n>=0;n--){const o=i[n];if(parseInt(o.getAttribute(ae)||"1",10)<t){this.moveFocusToRow(o,e);break}}}break}case"Home":{t.preventDefault();const n=i[0];n&&this.moveFocusToRow(n,e);break}case"End":{t.preventDefault();const n=i[i.length-1];n&&this.moveFocusToRow(n,e);break}case" ":{if(t.preventDefault(),!o)break;const e=o.getAttribute(re)?o:o.closest(`[${re}]`),n=(null==e?void 0:e.getAttribute(re))??null;if(!n)break;if(this.selectionManager)t.shiftKey?this.selectionManager.handleClick(n,{ctrlKey:!1,metaKey:!1,shiftKey:!0}):this.selectionManager.toggleTask(n);else{const t=e,n="true"===t.getAttribute("aria-selected");t.setAttribute("aria-selected",n?"false":"true")}break}case"a":if(!t.ctrlKey&&!t.metaKey)break;t.preventDefault(),null==(n=this.selectionManager)||n.selectAll();break;case"Enter":{if(t.preventDefault(),!o)break;const e=o.getAttribute(re);if(!e)break;const n=this.chartContext.querySelector(`[data-taskid="${CSS.escape(e)}"].bar-timeline`);n&&n.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0}));break}case"Escape":this.selectionManager&&this.selectionManager.getSelectedIds().size>0?this.selectionManager.clearSelection():o&&o.blur()}}}class le{constructor(t,e,n){this.chartContext=t,this.dataManager=e,this.getElement=n,this.selectedIds=new Set,this.lastClickedId=null}getSelectedTasks(){return Array.from(this.selectedIds).map((t=>this.dataManager.getTaskById(t))).filter((t=>null!==t))}getSelectedIds(){return new Set(this.selectedIds)}setSelectedTasks(t){const e=new Set(this.selectedIds);this.selectedIds.clear(),t.forEach((t=>{this.dataManager.getTaskById(t)&&this.selectedIds.add(t)})),this.syncDom(),this.emitChange(e)}clearSelection(){if(0===this.selectedIds.size)return;const t=new Set(this.selectedIds);this.selectedIds.clear(),this.lastClickedId=null,this.syncDom(),this.emitChange(t)}toggleTask(t){const e=new Set(this.selectedIds);this.selectedIds.has(t)?this.selectedIds.delete(t):this.selectedIds.add(t),this.lastClickedId=t,this.syncDom(),this.emitChange(e)}handleClick(t,e){const n=new Set(this.selectedIds);e.shiftKey&&this.lastClickedId?this.rangeSelect(this.lastClickedId,t):e.ctrlKey||e.metaKey?(this.selectedIds.has(t)?this.selectedIds.delete(t):this.selectedIds.add(t),this.lastClickedId=t):(this.selectedIds.clear(),this.selectedIds.add(t),this.lastClickedId=t),this.syncDom(),this.emitChange(n)}selectAll(){const t=new Set(this.selectedIds),e=this.dataManager.getFlatVisibleTasks();this.selectedIds.clear(),e.forEach((t=>this.selectedIds.add(t.id))),this.syncDom(),this.emitChange(t)}selectGroup(t){const e=new Set(this.selectedIds),n=this.dataManager.getNestedChildTasks(t,!0);this.selectedIds.add(t),n.forEach((t=>this.selectedIds.add(t.id))),this.syncDom(),this.emitChange(e)}isSelected(t){return this.selectedIds.has(t)}restoreAfterRender(){const t=new Set;this.selectedIds.forEach((e=>{this.dataManager.getTaskById(e)&&t.add(e)})),this.selectedIds=t,this.syncDom()}captureState(){return Array.from(this.selectedIds)}restoreState(t){this.selectedIds=new Set(t)}destroy(){this.selectedIds.clear(),this.lastClickedId=null}rangeSelect(t,e){const n=this.dataManager.getFlatVisibleTasks(),i=n.findIndex((e=>e.id===t)),o=n.findIndex((t=>t.id===e));if(-1===i||-1===o)return;const r=Math.min(i,o),a=Math.max(i,o);for(let t=r;t<=a;t++)this.selectedIds.add(n[t].id)}syncDom(){this.getElement().querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`).forEach((t=>{const e=t.getAttribute("data-taskid");if(!e)return;const n=this.selectedIds.has(e);t.setAttribute("aria-selected",n?"true":"false");const i=t.querySelector(".gantt-selection-checkbox");i&&(i.checked=n)})),this.syncSelectAllCheckbox()}syncSelectAllCheckbox(){const t=this.getElement().querySelector(".gantt-select-all-checkbox");if(!t)return;const e=this.dataManager.getFlatVisibleTasks().length,n=this.selectedIds.size;0===n?(t.checked=!1,t.indeterminate=!1):n>=e?(t.checked=!0,t.indeterminate=!1):(t.checked=!1,t.indeterminate=!0)}emitChange(t){if(this.setsEqual(t,this.selectedIds))return;const e={selectedTasks:this.getSelectedTasks(),selectedIds:Array.from(this.selectedIds),timestamp:Date.now()};this.getElement().dispatchEvent(new CustomEvent(K.SELECTION_CHANGE,{detail:e,bubbles:!0,cancelable:!1}))}setsEqual(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}}class ce{constructor(t){this._scrollTop=0,this._rowHeight=Math.max(1,t.rowHeight),this._overscan=Math.max(0,t.overscan??5),this._totalRows=Math.max(0,t.totalRows),this._containerHeight=Math.max(0,t.containerHeight)}getVisibleRange(){if(0===this._totalRows)return{startIndex:0,endIndex:-1};const t=Math.floor(this._scrollTop/this._rowHeight),e=Math.max(0,t-this._overscan),n=Math.ceil(this._containerHeight/this._rowHeight);return{startIndex:e,endIndex:Math.min(this._totalRows-1,t+n-1+this._overscan)}}getTotalHeight(){return this._totalRows*this._rowHeight}getOffsetForIndex(t){return t*this._rowHeight}getTopSpacerHeight(){const{startIndex:t}=this.getVisibleRange();return t*this._rowHeight}getBottomSpacerHeight(){if(0===this._totalRows)return 0;const{endIndex:t}=this.getVisibleRange();return Math.max(0,(this._totalRows-1-t)*this._rowHeight)}getVisibleCount(){const{startIndex:t,endIndex:e}=this.getVisibleRange();return e<t?0:e-t+1}setScrollTop(t){this._scrollTop=Math.max(0,t)}setTotalRows(t){this._totalRows=Math.max(0,t)}setContainerHeight(t){this._containerHeight=Math.max(0,t)}setOverscan(t){this._overscan=Math.max(0,t)}get scrollTop(){return this._scrollTop}get totalRows(){return this._totalRows}get containerHeight(){return this._containerHeight}get rowHeight(){return this._rowHeight}get overscan(){return this._overscan}}const de="virtualizer-top-spacer",he="virtualizer-bottom-spacer",pe=`.${de}`,ue=`.${he}`,ge="data-taskid";class me{constructor(t,e,n,i,o,r,a=(()=>{})){this.domRefs=t,this.options=e,this.chartContext=n,this.dataManager=i,this.getViewMode=o,this.onAfterUpdate=r,this.onToggle=a,this.cachedVisibleTasks=[],this.lastVisibleRange=null,this.virtualScrollRAF=null,this.verticalScrollHandler=null,this._isActive=!1,this.renderedTaskIds=new Set,this.virtualizer=new ce({rowHeight:e.rowHeight,totalRows:0,containerHeight:0})}get isActive(){return this._isActive}getRenderedTaskIds(){return this.renderedTaskIds}initialise(t){this.cachedVisibleTasks=t;const{rowHeight:e,height:n}=this.options,i="number"==typeof n?Math.max(n-100,200):600,o=Math.ceil(i/e);if(this.virtualizer=new ce({rowHeight:e,totalRows:t.length,containerHeight:i,overscan:o}),t.length<=50)return void(this._isActive=!1);this._isActive=!0;const r=this.virtualizer.getVisibleRange();return this.lastVisibleRange=r,this.renderedTaskIds=new Set(t.slice(r.startIndex,r.endIndex+1).map((t=>t.id))),{allTasks:t,range:r,rowHeight:e}}attach(){const{verticalScrollContainer:t}=this.domRefs;if(!t||!this._isActive)return;const e=t.clientHeight;e>0&&(this.virtualizer.setContainerHeight(e),this.virtualizer.setOverscan(Math.ceil(e/this.options.rowHeight))),this.detach(),this.verticalScrollHandler=()=>{const e=t.scrollTop;this.scheduleUpdate(e)},t.addEventListener("scroll",this.verticalScrollHandler,{passive:!0})}detach(){const{verticalScrollContainer:t}=this.domRefs;t&&this.verticalScrollHandler&&t.removeEventListener("scroll",this.verticalScrollHandler),this.verticalScrollHandler=null,null!==this.virtualScrollRAF&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(this.virtualScrollRAF),this.virtualScrollRAF=null),this.lastVisibleRange=null}destroy(){this.detach(),this.cachedVisibleTasks=[],this.renderedTaskIds.clear(),this._isActive=!1}updateTotalRows(t){if(this.cachedVisibleTasks=t,!this._isActive)return;this.virtualizer.setTotalRows(t.length);const e=Math.max(0,t.length*this.virtualizer.rowHeight-this.virtualizer.containerHeight);if(this.virtualizer.scrollTop>e){this.virtualizer.setScrollTop(e);const{verticalScrollContainer:t}=this.domRefs;t&&(t.scrollTop=e)}const n=this.virtualizer.getVisibleRange();this.lastVisibleRange=n,this.applyUpdate(n)}expandAllForExport(){if(!this._isActive)return null;const t=this.cachedVisibleTasks,{rowHeight:e}=this.options,n={startIndex:0,endIndex:t.length-1},i=this.domRefs.tasksDataContainer;if(i){this.patchTasksPanel(t,n,e);const o=i.querySelector(pe),r=i.querySelector(ue);o&&(o.style.height="0px"),r&&(r.style.height="0px")}const o=this.domRefs.timelineBody;if(o){this.patchTimelinePanel(t,n,e);const i=o.querySelector(pe),r=o.querySelector(ue);i&&(i.style.height="0px"),r&&(r.style.height="0px")}this.patchBars(t,n,e);const r=this.lastVisibleRange;return r?{startIndex:r.startIndex,endIndex:r.endIndex}:null}restoreAfterExport(t){if(!this._isActive)return;const e=t??this.virtualizer.getVisibleRange();this.applyUpdate(e)}handleResize(){if(!this._isActive)return;const{verticalScrollContainer:t}=this.domRefs;t&&this.virtualizer.setContainerHeight(t.clientHeight);const e=this.virtualizer.getVisibleRange();this.lastVisibleRange&&e.startIndex===this.lastVisibleRange.startIndex&&e.endIndex===this.lastVisibleRange.endIndex||(this.lastVisibleRange=e,this.applyUpdate(e))}updateDomRefs(t){this.domRefs=t}scheduleUpdate(t){this.virtualizer.setScrollTop(t),this.cachedVisibleTasks.length<=50||(null!==this.virtualScrollRAF&&"undefined"!=typeof cancelAnimationFrame&&cancelAnimationFrame(this.virtualScrollRAF),"undefined"!=typeof requestAnimationFrame?this.virtualScrollRAF=requestAnimationFrame((()=>{this.virtualScrollRAF=null,this.applyIfChanged()})):this.applyIfChanged())}applyIfChanged(){const t=this.virtualizer.getVisibleRange();this.lastVisibleRange&&t.startIndex===this.lastVisibleRange.startIndex&&t.endIndex===this.lastVisibleRange.endIndex||(this.lastVisibleRange=t,this.applyUpdate(t))}applyUpdate(t){const e=this.cachedVisibleTasks,{rowHeight:n}=this.options;0!==e.length&&(this.patchTasksPanel(e,t,n),this.patchTimelinePanel(e,t,n),this.patchBars(e,t,n),this.onAfterUpdate())}patchTasksPanel(t,e,n){const i=this.domRefs.tasksDataContainer;if(!i)return;const{startIndex:o,endIndex:r}=e,a=t.slice(o,r+1),s=new Set(a.map((t=>t.id))),l=Array.from(i.querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`)),c=new Map;l.forEach((t=>{const e=t.getAttribute(ge);e&&c.set(e,t)}));const d=new ht(this.options,this.chartContext,this.dataManager);a.forEach(((t,e)=>{if(!c.has(t.id)){const n=o+e,r=d.generateRow(t,this.onToggle,n+1);i.appendChild(r)}})),c.forEach(((t,e)=>{s.has(e)||i.removeChild(t)})),this.updateSpacers(i,o,r,t.length,n);const h=Array.from(i.querySelectorAll(`${Pt.tasksDataRow}:not(${Pt.tasksEmptyRow})`)),p=new Map;t.forEach(((t,e)=>p.set(t.id,e))),h.sort(((t,e)=>{const n=t.getAttribute(ge)||"",i=e.getAttribute(ge)||"";return(p.get(n)??0)-(p.get(i)??0)}));const u=i.querySelector(ue)||null;h.forEach((t=>{i.insertBefore(t,u)})),h.forEach(((t,e)=>{t.setAttribute("aria-rowindex",(o+e+1).toString())})),this.renderedTaskIds=s}patchTimelinePanel(t,e,n){const i=this.domRefs.timelineBody;if(!i)return;const{startIndex:o,endIndex:r}=e,a=t.slice(o,r+1),s=new Set(a.map((t=>t.id))),l=Array.from(i.querySelectorAll(`${Pt.timelineDataRow}:not(${Pt.timelineEmptyRow})`)),c=new Map;l.forEach((t=>{const e=t.getAttribute(ge);e&&c.set(e,t)}));const d=this.getTimelineCellCount();if(0===d)return;const h=new Et(this.getViewMode(),this.options,this.chartContext,this.dataManager);a.forEach((t=>{if(!c.has(t.id)){const e=h.generateRow(t.id,d);i.appendChild(e)}})),c.forEach(((t,e)=>{s.has(e)||i.removeChild(t)})),this.updateSpacers(i,o,r,t.length,n);const p=new Map;t.forEach(((t,e)=>p.set(t.id,e)));const u=Array.from(i.querySelectorAll(`${Pt.timelineDataRow}:not(${Pt.timelineEmptyRow})`));u.sort(((t,e)=>{const n=t.getAttribute(ge)||"",i=e.getAttribute(ge)||"";return(p.get(n)??0)-(p.get(i)??0)}));const g=i.querySelector(ue)||null;u.forEach((t=>{i.insertBefore(t,g)}))}patchBars(t,e,n){const i=this.domRefs.barContainer;if(!i)return;const{startIndex:o,endIndex:r}=e,a=this.dataManager.getDateRange(8,this.getViewMode()),s=t.length*n,l=t.slice(o,r+1),c=new Set(l.map((t=>t.id))),d=Array.from(i.querySelectorAll(`[${ge}]`)),h=new Map;d.forEach((t=>{const e=t.getAttribute(ge);e&&h.set(e,t)}));const p=this.chartContext.getChartContainer();l.forEach(((t,e)=>{if(!h.has(t.id)){const n=o+e,r=new J(t,a[0],this.options,this.getViewMode(),n,this.chartContext,this.dataManager),s=r.drawBar(((t,e)=>{st(this.chartContext,this.dataManager,t,e,this.options,this.getViewMode(),a[0])}));i.appendChild(s),p&&Ct(s,0,p);const l=r.drawBaselineBar();l&&i.appendChild(l)}})),h.forEach(((t,e)=>{c.has(e)||i.removeChild(t)})),i.style.height=`${s}px`,i.style.width="100%"}updateSpacers(t,e,n,i,o){let r=t.querySelector(pe);r||(r=this.chartContext.createElement("div"),r.className=de,t.insertBefore(r,t.firstChild)),r.style.height=e*o+"px";let a=t.querySelector(ue);a||(a=this.chartContext.createElement("div"),a.className=he,t.appendChild(a));const s=Math.max(0,(i-1-n)*o);a.style.height=`${s}px`}getTimelineCellCount(){var t;const e=null==(t=this.domRefs.timelineBodyWrapper)?void 0:t.closest(".timeline-container");if(!e)return 0;const n=e.querySelectorAll(".timeline-header-row"),i=n[n.length-1];return i?i.querySelectorAll(".timeline-header-cell").length:0}}w.extend(S),w.extend(k),w.extend(B),w.extend(A),w.extend(I);const be="dependencyArrowUpdate";class fe extends n{constructor(t,e){super(t,"gantt_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options=U,this.containerResizeObserver=null,this.lastKnownWidth=0,this.lastKnownHeight=0,this.resizeDebounceTimer=null,this.dependencyArrowHandler=null,this.rowHoverHandler=null,this.rowHoverLeaveHandler=null,this._afterActionsRafId=null,this._destroyed=!1,this.criticalPathResult=null,this.domCache={ganttContainer:null,timelineContainer:null,timelineBody:null,timelineBodyWrapper:null,timelineHeader:null,horizontalScroll:null,horizontalScrollContent:null,tasksContainer:null,tasksBodyWrapper:null,tasksHeader:null,tasksDataContainer:null,splitBar:null,actionsContainer:null},this.keyboardNavigationManager=null,this.selectionManager=null,this.virtualScrollCoordinator=null,this.reducedMotionMQL=null,this.reducedMotionHandler=null;const n=j(null==e?void 0:e.theme);let i;(null==e?void 0:e.parsing)?Nt.validateConfig(e.parsing)?i=Nt.parse(e.series,e.parsing):(R.error("ApexGantt: Invalid parsing configuration provided"),i=[]):i=(null==e?void 0:e.series)||[],this.options={...n,...e,baseline:{...n.baseline,...null==e?void 0:e.baseline},series:i},this.viewMode=this.options.viewMode;const o="arrows_"+crypto.randomUUID().replace(/-/g,"").substring(0,9);this.arrowLink=new At(o),this.dataManager=new ut,this.dataManager.setTasks(this.options.series),this.dataManager.setArrowLinkInstanceId(o),this.stateManager=new Ot,this.styleManager=new oe(this.element,this.domCache,this.options,this.chartContext,this.isShadowDOM(),this.getInstanceId()),this.scrollManager=new Yt(this.element,this.options,this.domCache,this.chartContext,this.getInstanceId(),(()=>this.viewMode)),this.layoutManager=new Xt(this.element,this.options,this.domCache,this.chartContext,this.getInstanceId(),(()=>this.viewMode));const r={onViewModeChange:t=>{this.viewMode=t},onToolbarUpdate:()=>{const t=this.domCache.actionsContainer;t&&this.renderToolbar(t)},onTimelineRerender:()=>{this.rerenderTimeline()},onDependencyArrowsRender:()=>{this.renderDependencyArrows(),this.fadeArrowsAfterAnimation(),this.computeCriticalPath(),this.applyCriticalPathHighlighting()},onScrollbarUpdate:()=>{this.scrollManager.updateHorizontalScrollbarContent()},onScrollbarPosition:()=>{this.scrollManager.positionHorizontalScrollbar()}};this.zoomManager=new _t(this.element,this.domCache,this.chartContext,this.getInstanceId(),(()=>this.viewMode),r),this.styleManager.setupShadowDOMEnvironment(),this.options.enableSelection&&(this.selectionManager=new le(this.chartContext,this.dataManager,(()=>this.element))),this.keyboardNavigationManager=new se(this.chartContext,this.dataManager,(()=>this.domCache.tasksDataContainer),(()=>this.render()),this.selectionManager??void 0),this.setupReducedMotion()}static setLicense(t){r.setLicense(t)}setupReducedMotion(){if("undefined"==typeof window||!window.matchMedia)return;this.reducedMotionMQL=window.matchMedia("(prefers-reduced-motion: reduce)");const t=t=>{t?this.element.classList.add("gantt-reduced-motion"):this.element.classList.remove("gantt-reduced-motion")};t(this.reducedMotionMQL.matches),this.reducedMotionHandler=e=>t(e.matches),this.reducedMotionMQL.addEventListener("change",this.reducedMotionHandler)}initializeTooltip(){const{enableTooltip:t,tooltipId:e}=this.options;if(t){const t=p(this.chartContext,e);if(!this.chartContext.getElementById(e)){R.warn("Tooltip init: Tooltip not found after creation, appending manually");this.chartContext.getAppendContainer().appendChild(t)}}}render(t){var e,n;if(!this.element)throw new Error("Element not found");this.virtualScrollCoordinator&&this.virtualScrollCoordinator.detach();const i=this.element&&this.element.children.length>0;i&&this.stateManager.captureState(this.element,this.dataManager,this.viewMode,null==(e=this.selectionManager)?void 0:e.captureState());const{enableResize:o,tasksContainerWidth:r,height:a,width:s}=this.options,l=Dt(this.element),c=l.fontColor||this.options.fontColor,d=l.fontFamily||this.options.fontFamily,h=l.fontSize||this.options.fontSize,{fontWeight:p}=this.options;this.layoutManager.setupChartContainerPositioning(),this.styleManager.injectGanttStyles(),this.styleManager.setCSSVariables(),this.initializeTooltip();const u=new Set(Array.from(this.element.querySelectorAll(".bar-timeline[data-taskid]")).map((t=>t.getAttribute("data-taskid"))));this.element.innerHTML="";const g=this.normalizeDimension(a),b=this.normalizeDimension(s);this.element.style.width=b,this.element.style.height=g,this.element.style.display="flex",this.element.style.flexDirection="column",this.element.style.boxSizing="border-box",this.element.style.overflow="hidden",this.element.style.setProperty("color",c),this.element.style.setProperty("font-family",d),this.element.style.setProperty("font-size",h),this.element.style.setProperty("font-weight",p);const f=m(this.chartContext,{className:Pt.actionsContainer.slice(1)});this.renderToolbar(f);const y=m(this.chartContext,{className:Pt.ganttContainer.slice(1)}),v=this.dataManager.getFlatVisibleTasks();this.initVirtualScrollCoordinator();const w=null==(n=this.virtualScrollCoordinator)?void 0:n.initialise(v),x=new Et(this.viewMode,this.options,this.chartContext,this.dataManager).render(w,u),k=new ht(this.options,this.chartContext,this.dataManager,this.selectionManager??void 0).render(this.render.bind(this),w);x&&this.layoutManager.createLayout(y,k,x,o,r),this.element.appendChild(f),this.element.appendChild(y);const C=this.element.querySelector(Pt.horizontalScroll);C&&(C.remove(),this.element.appendChild(C)),this.styleManager.handleWatermark(),this.cacheDomElements(),this.setupRowBackgroundColors(),this.zoomManager.setupZoomEventListener(),this.setupDependencyArrowEvents(),this.renderDependencyArrows();const S=new Set(v.map((t=>t.id))),E=u.size>0?new Set([...u,...S].filter((t=>!u.has(t)||!S.has(t)))):void 0;return this.fadeArrowsAfterAnimation(!1,E),this.computeCriticalPath(),this.applyCriticalPathHighlighting(),this._afterActionsRafId=requestAnimationFrame((()=>{this._afterActionsRafId=null,this.performAfterActions()})),i&&requestAnimationFrame((()=>{this.stateManager.restoreState(this.element)})),this.element}cacheDomElements(){var t;this.domCache.ganttContainer=this.element.querySelector(Pt.ganttContainer),this.domCache.timelineContainer=this.element.querySelector(Pt.timelineContainer),this.domCache.timelineBody=this.element.querySelector(Pt.timelineBody),this.domCache.timelineBodyWrapper=this.element.querySelector(Pt.timelineBodyWrapper),this.domCache.timelineHeader=this.element.querySelector(Pt.timelineHeader),this.domCache.horizontalScroll=this.element.querySelector(Pt.horizontalScroll),this.domCache.horizontalScrollContent=(null==(t=this.domCache.horizontalScroll)?void 0:t.querySelector(Pt.horizontalScrollContent))||null,this.domCache.tasksContainer=this.element.querySelector(Pt.tasksContainer),this.domCache.tasksBodyWrapper=this.element.querySelector(Pt.tasksBodyWrapper),this.domCache.tasksHeader=this.element.querySelector(Pt.tasksHeader),this.domCache.tasksDataContainer=this.element.querySelector(Pt.tasksDataContainer),this.domCache.splitBar=this.element.querySelector(Pt.splitBar),this.domCache.actionsContainer=this.element.querySelector(Pt.actionsContainer)}clearDomCache(){this.domCache.ganttContainer=null,this.domCache.timelineContainer=null,this.domCache.timelineBody=null,this.domCache.timelineBodyWrapper=null,this.domCache.timelineHeader=null,this.domCache.horizontalScroll=null,this.domCache.horizontalScrollContent=null,this.domCache.tasksContainer=null,this.domCache.tasksBodyWrapper=null,this.domCache.tasksHeader=null,this.domCache.tasksDataContainer=null,this.domCache.splitBar=null,this.domCache.actionsContainer=null}performAfterActions(){var t,e,n;if(!this.isDestroyed()){if(this.cacheDomElements(),this.layoutManager.syncTasksColumnWidths(),this.scrollManager.compensateForScrollbar(),this.scrollManager.updateHorizontalScrollbarContent(),this.scrollManager.setupTimelineHorizontalScroll(),this.scrollManager.positionHorizontalScrollbar(),this.setupContainerResizeObserver(),this.scrollManager.setupScrollbarResizeObserver(),this.setupRowBackgroundColors(),this.setupRowHoverSync(),this.scrollManager.disableHeaderMousewheelScroll(),(null==(t=this.virtualScrollCoordinator)?void 0:t.isActive)||this.layoutManager.fillEmptyRowsAfterRender(),this.virtualScrollCoordinator){const t=this.element.querySelector(".split-view-container")??this.domCache.ganttContainer;this.virtualScrollCoordinator.updateDomRefs({tasksDataContainer:this.domCache.tasksDataContainer,timelineBody:this.domCache.timelineBody,barContainer:this.element.querySelector(Pt.barContainer),tasksBodyWrapper:this.domCache.tasksBodyWrapper,timelineBodyWrapper:this.domCache.timelineBodyWrapper,verticalScrollContainer:t}),this.virtualScrollCoordinator.attach()}null==(e=this.keyboardNavigationManager)||e.attach(),null==(n=this.selectionManager)||n.restoreAfterRender()}}initVirtualScrollCoordinator(){this.virtualScrollCoordinator&&this.virtualScrollCoordinator.destroy(),this.virtualScrollCoordinator=new me({tasksDataContainer:null,timelineBody:null,barContainer:null,tasksBodyWrapper:null,timelineBodyWrapper:null,verticalScrollContainer:null},this.options,this.chartContext,this.dataManager,(()=>this.viewMode),(()=>{this.setupRowBackgroundColors(),this.renderDependencyArrows(),this.fadeArrowsAfterAnimation(),this.applyCriticalPathHighlighting()}),(()=>this.render()))}setupRowHoverSync(){const t=this.domCache.ganttContainer;if(!t)return;this.rowHoverHandler&&(t.removeEventListener("mousemove",this.rowHoverHandler),this.rowHoverHandler=null),this.rowHoverLeaveHandler&&(t.removeEventListener("mouseleave",this.rowHoverLeaveHandler),this.rowHoverLeaveHandler=null);const e=this.chartContext.getInstanceId(),n=`${Pt.tasksDataRow}[data-chart-instance="${e}"]`,i=`${Pt.timelineDataRow}[data-chart-instance="${e}"]`,o=getComputedStyle(this.element).getPropertyValue("--row-hover-color").trim()||"rgba(0,0,0,0.06)",r=(t,e)=>{const r=this.element.querySelector(`${n}[data-taskid="${t}"]`),a=this.element.querySelector(`${i}[data-taskid="${t}"]`);for(const t of[r,a])t&&(e?(t.dataset.origBg||(t.dataset.origBg=t.style.backgroundColor),t.style.backgroundColor=o):(t.style.backgroundColor=t.dataset.origBg??"",delete t.dataset.origBg))};let a=null;const s=t=>{const o=t.target,s=null==o?void 0:o.closest(`${n}, ${i}`),l=null==o?void 0:o.closest(`[data-taskid][data-chart-instance="${e}"]`),c=(null==s?void 0:s.dataset.taskid)??(null==l?void 0:l.dataset.taskid)??null;c!==a&&(a&&r(a,!1),a=c,a&&r(a,!0))},l=e=>{const{relatedTarget:n}=e;n&&t.contains(n)||(a&&r(a,!1),a=null)};this.rowHoverHandler=s,this.rowHoverLeaveHandler=l,t.addEventListener("mousemove",s),t.addEventListener("mouseleave",l)}setupRowBackgroundColors(){var t;const e=new Map,n=Dt(this.element),i=[...this.options.rowBackgroundColors];n.rowBgEven&&(i[0]=n.rowBgEven),n.rowBgOdd&&(i[1]=n.rowBgOdd);const o=(null==(t=this.virtualScrollCoordinator)?void 0:t.isActive)?this.virtualScrollCoordinator.getRenderedTaskIds():null;this.dataManager.getTopParentTasks().forEach(((t,n)=>{const r=t.rowBackgroundColor||rt(n,i);e.set(t.id,r),o&&!o.has(t.id)||at(this.chartContext,t.id,r)})),this.dataManager.getFlatTasks().forEach((t=>{if(o&&!o.has(t.id))return;if(!t.parentId){if(t.type===ct.Milestone&&!e.has(t.id)){const e=t.rowBackgroundColor||rt(0,i);at(this.chartContext,t.id,e)}return}let n=this.dataManager.getTaskById(t.parentId);for(;null==n?void 0:n.parentId;)n=this.dataManager.getTaskById(n.parentId);const r=n?n.id:t.parentId,a=t.rowBackgroundColor||(e.get(r??"")??"");at(this.chartContext,t.id,a)}))}fadeArrowsAfterAnimation(t=!1,e){var n;const i=`timeline-arrows-${this.arrowLink.getInstanceId()}`;!function(t,e,n=!1,i){if(!t)return;const o=kt(e);if(i&&i.size>0){const e=Array.from(t.querySelectorAll("path[data-edgeid]")).filter((t=>{const[e,n]=(t.getAttribute("data-edgeid")??"").split("-");return i.has(e)||i.has(n)}));if(0===e.length)return;return n||o?void e.forEach((t=>t.style.opacity="1")):(e.forEach((t=>t.style.opacity="0")),void setTimeout((()=>{e.forEach((t=>{"function"==typeof t.animate?t.animate([{opacity:"0"},{opacity:"1"}],{duration:150,easing:"ease-out",fill:"forwards"}).finished.then((()=>{t.style.opacity="1",t.getAnimations().forEach((t=>t.cancel()))})).catch((()=>{})):t.style.opacity="1"}))}),200))}n||o?t.style.opacity="1":(t.style.opacity="0",setTimeout((()=>{"function"==typeof t.animate?t.animate([{opacity:"0"},{opacity:"1"}],{duration:150,easing:"ease-out",fill:"forwards"}).finished.then((()=>{t.style.opacity="1",t.getAnimations().forEach((t=>t.cancel()))})).catch((()=>{})):t.style.opacity="1"}),200))}((null==(n=this.domCache.timelineBody)?void 0:n.querySelector(`#${i}`))??null,this.element,t,e)}renderDependencyArrows(){var t;const{rowHeight:e,barMargin:n}=this.options,i=this.getInstanceId(),o=this.arrowLink.getInstanceId(),r=this.domCache.timelineBody;if(!r)return void R.warn(`[${i}] Timeline body not found for arrows`);const a=`timeline-arrows-${o}`,s=r.querySelector(`#${a}`);s&&s.remove();const l=this.dataManager.getFlatVisibleTasks(),c=l.filter((t=>!!t.dependency));if(0===c.length)return;const d=new Map;l.forEach(((t,e)=>d.set(t.id,e)));const[h]=this.dataManager.getDateRange(8,this.viewMode),p=e-2*n,u=(t,i)=>{const o=J.calculateX(t,h,this.viewMode,this.options),r=J.calculateWidth(t,this.viewMode,this.options),a=n+i*e;return{left:o,right:o+r,top:a,bottom:a+p,width:r,height:p}},g=(null==(t=this.virtualScrollCoordinator)?void 0:t.isActive)?this.virtualScrollCoordinator.getRenderedTaskIds():null,m=c.flatMap((t=>{const{taskId:e,type:n,lag:i}=dt(t.dependency);if(g&&!g.has(e)&&!g.has(t.id))return[];const o=this.dataManager.getTaskById(e),r=d.get(e),a=d.get(t.id);if(!o||void 0===r||void 0===a)return[];return[{id:`${e}-${t.id}`,sourceRect:u(o,r),targetRect:u(t,a),dependencyType:n,lagPx:i}]}));if(0===m.length)return;const b=l.length*e;this.arrowLink.renderFromRects(r,m,{arrowColor:this.options.arrowColor,height:Math.max(b,r.clientHeight),paddingY:e/2,width:(r.scrollWidth||r.clientWidth)+40},this.chartContext)}setupDependencyArrowEvents(){const t=this.getInstanceId(),e=this.arrowLink.getInstanceId();this.dependencyArrowHandler&&this.chartContext.removeEventListener(be,this.dependencyArrowHandler),this.dependencyArrowHandler=n=>{const i=n;if(i.detail.chartInstanceId!==t)return;const o=i.detail.arrowLinkInstanceId||e,r=function(t,e,n,i,o="FS",r=38){const a=t.getInstanceId(),s=H(t,e),l=H(t,n);if(!s||!l)return R.warn(`[${a}] Arrow source or target not found: ${e} -> ${n}`),!1;const c=t.querySelector(`.timeline-body[data-chart-instance="${a}"]`),d=`timeline-arrows-${i}`,h=null==c?void 0:c.querySelector(`#${d}`);return h?(At.updateArrow(s,l,h,{paddingX:20,paddingY:r/2},`${e}-${n}`,o),!0):(R.warn(`[${a}] Arrow SVG not found: ${d}`),!1)}(this.chartContext,i.detail.fromId,i.detail.toId,o,i.detail.type,this.options.rowHeight);r||(this.renderDependencyArrows(),this.fadeArrowsAfterAnimation(!0))},this.chartContext.addEventListener(be,this.dependencyArrowHandler);const n=()=>{this.computeCriticalPath(),this.chartContext.querySelectorAll(".bar-critical").forEach((t=>t.classList.remove("bar-critical"))),this.chartContext.querySelectorAll(".critical-arrow").forEach((t=>t.classList.remove("critical-arrow"))),this.applyCriticalPathHighlighting()},i=this.chartContext.getChartContainer();i&&(i.removeEventListener(K.TASK_DRAGGED,n),i.removeEventListener(K.TASK_RESIZED,n),i.addEventListener(K.TASK_DRAGGED,n),i.addEventListener(K.TASK_RESIZED,n))}computeCriticalPath(){this.options.enableCriticalPath&&(this.criticalPathResult=function(t,e){if(0===t.length||0===e.length)return $t;const n=e.filter((t=>"FS"===t.type));if(0===n.length)return $t;const i=new Map;for(const e of t)i.set(e.id,e);const o=new Map,r=new Map,a=new Map;for(const e of t)a.set(e.id,0),o.set(e.id,[]),r.set(e.id,[]);for(const t of n)i.has(t.fromId)&&i.has(t.toId)&&(o.get(t.fromId).push(t),r.get(t.toId).push(t),a.set(t.toId,(a.get(t.toId)??0)+1));const s=[];for(const[t,e]of a)0===e&&s.push(t);const l=[];for(;s.length>0;){const t=s.shift();l.push(t);for(const e of o.get(t)??[]){const t=(a.get(e.toId)??0)-1;a.set(e.toId,t),0===t&&s.push(e.toId)}}if(l.length!==t.length)return $t;const c=new Map,d=new Map;for(const t of l){const e=i.get(t);if(!e)continue;const n=It(e.startTime,e.endTime??e.startTime);let o=0;for(const e of r.get(t)??[]){const t=d.get(e.fromId)??0;o=Math.max(o,t+e.lag+1)}c.set(t,o),d.set(t,o+n-1)}let h=0;for(const t of d.values())t>h&&(h=t);const p=new Map,u=new Map;for(const t of[...l].reverse()){const e=i.get(t);if(!e)continue;const n=It(e.startTime,e.endTime??e.startTime),r=o.get(t)??[];let a=h;for(const t of r){const e=u.get(t.toId)??h;a=Math.min(a,e-t.lag-1)}p.set(t,a),u.set(t,a-n+1)}const g=new Set;for(const t of l)0==(u.get(t)??0)-(c.get(t)??0)&&g.add(t);const m=new Set;for(const t of n)if(g.has(t.fromId)&&g.has(t.toId)){const e=d.get(t.fromId)??0,n=c.get(t.toId)??0;e+t.lag+1===n&&m.add(`${t.fromId}->${t.toId}`)}return{criticalTaskIds:g,criticalEdgeKeys:m}}(this.dataManager.getTasks(),this.dataManager.getAllDependencies()))}applyCriticalPathHighlighting(){var t,e;if(!this.options.enableCriticalPath||!this.criticalPathResult)return;for(const e of this.criticalPathResult.criticalTaskIds)null==(t=H(this.chartContext,e))||t.classList.add("bar-critical");const n=this.domCache.timelineBody;for(const t of this.criticalPathResult.criticalEdgeKeys){const[i,o]=t.split("->");null==(e=null==n?void 0:n.querySelector(`[data-edgeid="${i}-${o}"]`))||e.classList.add("critical-arrow")}}rerenderTimeline(){var t;const e=this.domCache.timelineContainer;if(!e)return;const n=new Map;this.element.querySelectorAll(".bar-timeline[data-taskid]").forEach((t=>{const e=t.getAttribute("data-taskid");n.set(e,{left:parseFloat(t.style.left)||0,width:parseFloat(t.style.width)||0})}));const i=this.dataManager.getFlatVisibleTasks(),o=null==(t=this.virtualScrollCoordinator)?void 0:t.initialise(i),r=new Set(i.map((t=>t.id))),a=this.domCache.timelineHeader,s=this.domCache.timelineBodyWrapper;if(a&&s){a.innerHTML="",s.innerHTML="";const t=new Et(this.viewMode,this.options,this.chartContext,this.dataManager).render(o,r);if(t){const e=t[0];a.innerHTML=e.innerHTML;for(let e=1;e<t.length-1;e++)s.appendChild(t[e])}}else{e.innerHTML="";const t=new Et(this.viewMode,this.options,this.chartContext,this.dataManager).render(o,r);if(t){const n=t[0];e.appendChild(n);const i=m(this.chartContext,{className:Pt.timelineBodyWrapper.slice(1)});for(let e=1;e<t.length-1;e++)i.appendChild(t[e]);e.appendChild(i)}}this.cacheDomElements(),this.cancelPendingAfterActionsRaf(),this._afterActionsRafId=requestAnimationFrame((()=>{if(this._afterActionsRafId=null,n.size>0){const t=this.element;this.element.querySelectorAll(".bar-timeline[data-taskid]").forEach((e=>{const i=e.getAttribute("data-taskid"),o=n.get(i);o&&function(t,e,n,i){if(kt(i))return;if("function"!=typeof t.animate)return;if(e.left===n.left&&e.width===n.width)return;const o=t.animate([{left:`${e.left}px`,width:`${e.width}px`},{left:`${n.left}px`,width:`${n.width}px`}],{duration:200,easing:"ease-in-out",fill:"forwards"});o.finished.then((()=>o.cancel())).catch((()=>{}))}(e,o,{left:parseFloat(e.style.left)||0,width:parseFloat(e.style.width)||0},t)}))}this.performAfterActions()}))}cancelPendingAfterActionsRaf(){null!=this._afterActionsRafId&&(cancelAnimationFrame(this._afterActionsRafId),this._afterActionsRafId=null)}cleanupEventListeners(){var t,e;try{this.dependencyArrowHandler&&(this.chartContext.removeEventListener(be,this.dependencyArrowHandler),this.dependencyArrowHandler=null),this.rowHoverHandler&&(null==(t=this.domCache.ganttContainer)||t.removeEventListener("mousemove",this.rowHoverHandler),this.rowHoverHandler=null),this.rowHoverLeaveHandler&&(null==(e=this.domCache.ganttContainer)||e.removeEventListener("mouseleave",this.rowHoverLeaveHandler),this.rowHoverLeaveHandler=null);const n=this.domCache.timelineContainer;if(null==n?void 0:n.parentNode){const t=n.cloneNode(!0);n.parentNode.replaceChild(t,n)}}catch(t){R.warn("Error cleaning up event listeners:",t)}}cleanupTooltips(){try{const{enableTooltip:t,tooltipId:e}=this.options;if(t){const t=this.chartContext.getElementById(e);t&&(t.style.display="none",t.innerHTML="",t.removeAttribute("style"),t.classList.remove("visible"),t.setAttribute("aria-hidden","true"),this.isShadowDOM()&&t.remove())}}catch(t){R.warn("Error cleaning up tooltips:",t)}}cleanupDependencyArrows(){try{const t=this.domCache.timelineBody;if(t&&this.arrowLink){const e=this.arrowLink.getInstanceId(),n=`timeline-arrows-${e}`,i=t.querySelector(`#${n}`);i&&i.remove();t.querySelectorAll("[data-edgeid]").forEach((t=>{const n=t.getAttribute("marker-end");(null==n?void 0:n.includes(`arrowhead-${e}`))&&t.remove()}))}}catch(t){R.warn("Error cleaning up dependency arrows:",t)}}createActionButton(t,e,n=!1){const i=this.chartContext.createElement("button");return i.className="gantt-action-button",i.innerHTML=t,i.title=e,i.disabled=n,i.setAttribute("aria-label",e),i}createSeparator(){const t=this.chartContext.createElement("div");return t.className="gantt-action-separator",t}createViewModeDisplay(){const t=this.chartContext.createElement("div");t.className="gantt-view-mode-display";const e=this.viewMode.charAt(0).toUpperCase()+this.viewMode.slice(1);return t.innerHTML=`${Lt.calendar} <span>${e}</span>`,t.title=`Current view: ${e}`,t}renderToolbar(t){t.innerHTML="";const e=[],n=()=>{var t;return{selectedTasks:(null==(t=this.selectionManager)?void 0:t.getSelectedTasks())??[]}},i=(this.options.toolbarItems??[]).filter((t=>"left"===(t.position??"right")));i.length>0&&(i.forEach((i=>{const o=this.createToolbarItem(i,n,e);o&&t.append(o)})),t.append(this.createSeparator()));const o=this.createActionButton(Lt.zoomIn,"Zoom In",this.viewMode===L[0]);o.addEventListener("click",(()=>this.zoomIn()));const r=this.createActionButton(Lt.zoomOut,"Zoom Out",this.viewMode===L[L.length-1]);r.addEventListener("click",(()=>this.zoomOut()));const a=this.createViewModeDisplay();if(t.append(o,r,this.createSeparator(),a),this.options.enableSelection&&this.selectionManager){const n=this.chartContext.createElement("div");n.className="gantt-selection-count";const i=this.selectionManager.getSelectedIds().size;n.textContent=i>0?`${i} selected`:"",n.style.display=i>0?"":"none",e.push((()=>{var t;const e=(null==(t=this.selectionManager)?void 0:t.getSelectedIds().size)??0;n.textContent=e>0?`${e} selected`:"",n.style.display=e>0?"":"none"})),t.append(n)}const s=(this.options.toolbarItems??[]).filter((t=>"right"===(t.position??"right")));if(s.length>0&&(t.append(this.createSeparator()),s.forEach((i=>{const o=this.createToolbarItem(i,n,e);o&&t.append(o)}))),this.options.enableExport){const e=this.chartContext.createElement("div");e.className="gantt-actions-spacer",t.append(e);const n=this.createActionButton(Lt.download,"Export as SVG");n.addEventListener("click",(()=>{var t;const e=this.element;if(!e)return R.error("Export failed: Chart element not found"),void alert("Export failed: Chart not found. Please refresh and try again.");if(e.querySelector(Pt.ganttContainer))try{const n=(null==(t=this.virtualScrollCoordinator)?void 0:t.expandAllForExport())??null;zt(e).finally((()=>{var t;null==(t=this.virtualScrollCoordinator)||t.restoreAfterExport(n)}))}catch(t){R.error("Export error:",t),alert("Export failed. Please check the console for details.")}else R.error("Export failed: Gantt container not found in chart")})),t.append(n)}e.length>0&&this.element.addEventListener(K.SELECTION_CHANGE,(()=>{e.forEach((t=>t()))}))}createToolbarItem(t,e,n){return"separator"===t.type?this.createSeparator():"button"===t.type?this.createToolbarButton(t,e,n):"select"===t.type?this.createToolbarSelect(t,e):null}createToolbarButton(t,e,n){const i=this.chartContext.createElement("button");i.className="gantt-action-button gantt-toolbar-button",t.tooltip?(i.title=t.tooltip,i.setAttribute("aria-label",t.tooltip)):t.label&&i.setAttribute("aria-label",t.label);const o=()=>{i.innerHTML=(()=>{const n=e().selectedTasks.length,i=t.showCount&&n>0?` (${n})`:"",o=t.label?`<span>${t.label}${i}</span>`:"";return`${t.icon??""}${o}`})(),i.disabled=t.requiresSelection?0===e().selectedTasks.length:"function"==typeof t.disabled?t.disabled(e()):t.disabled??!1};o(),i.addEventListener("click",(()=>{i.disabled||t.onClick(e())}));return(t.requiresSelection||"function"==typeof t.disabled||t.showCount)&&n.push(o),i}createToolbarSelect(t,e){const n=this.chartContext.createElement("div");if(n.className="gantt-toolbar-select-wrapper",t.label){const e=this.chartContext.createElement("span");e.className="gantt-toolbar-select-label",e.textContent=t.label,n.append(e)}const i=this.chartContext.createElement("select");if(i.className="gantt-toolbar-select",t.placeholder){const e=this.chartContext.createElement("option");e.value="",e.textContent=t.placeholder,e.disabled=!0,e.selected=!0,i.append(e)}return t.options.forEach((({value:t,text:e})=>{const n=this.chartContext.createElement("option");n.value=t,n.textContent=e,i.append(n)})),i.addEventListener("change",(()=>{t.onChange(i.value,e())})),n.append(i),n}update(t){var e;this.element&&!this.isDestroyed()&&this.stateManager.captureState(this.element,this.dataManager,this.viewMode,null==(e=this.selectionManager)?void 0:e.captureState());const n=this.detectCurrentTheme(),i=t.theme,o=i&&i!==n,r=this.stateManager.hasState()?this.stateManager.getViewMode():this.viewMode,a=new Set(Object.keys(t).filter((e=>void 0===t[e]))),s=Object.fromEntries(Object.entries(t).filter((([,t])=>void 0!==t))),l=j(i||n);let c,d;if(o){this.styleManager.cleanupScrollbarStyles();const t={series:this.options.series,parsing:this.options.parsing,width:this.options.width,height:this.options.height,viewMode:this.options.viewMode,rowHeight:this.options.rowHeight,tasksContainerWidth:this.options.tasksContainerWidth,inputDateFormat:this.options.inputDateFormat,annotations:this.options.annotations,enableSelection:this.options.enableSelection,enableExport:this.options.enableExport,enableResize:this.options.enableResize,enableTaskDrag:this.options.enableTaskDrag,enableTaskEdit:this.options.enableTaskEdit,enableTaskResize:this.options.enableTaskResize,enableTooltip:this.options.enableTooltip,tooltipTemplate:this.options.tooltipTemplate,canvasStyle:this.options.canvasStyle};c={...l,...t,...s},c.baseline={...l.baseline,...t.baseline??l.baseline,...s.baseline??{}}}else{const t=Object.fromEntries(Object.entries(this.options).filter((([t])=>!a.has(t))));c={...l,...t,...s},c.baseline={...l.baseline,...t.baseline??l.baseline,...s.baseline??{}}}t.viewMode||(c.viewMode=r),c.parsing?Nt.validateConfig(c.parsing)?d=Nt.parse(c.series,c.parsing):(R.error("ApexGantt: Invalid parsing configuration provided in update()"),d=this.options.series):d=c.series?c.series:this.options.series,this.options={...c,series:d},this.viewMode=this.options.viewMode,this.dataManager.setTasks(this.options.series),this.styleManager.updateOptions(this.options),this.scrollManager.updateOptions(this.options),this.layoutManager.updateOptions(this.options),this.render(),this.element&&!this.isDestroyed()&&this.stateManager.restoreState(this.element)}detectCurrentTheme(){const t=this.options.backgroundColor;return this.styleManager.isColorDark(t)?"dark":"light"}updateTask(t,e){if(!this.dataManager.getTaskById(t))throw new Error(`Task with ID ${t} not found`);const[n]=this.dataManager.getDateRange(0,this.viewMode);st(this.chartContext,this.dataManager,t,e,this.options,this.viewMode,n)}getSelectedTasks(){var t;return(null==(t=this.selectionManager)?void 0:t.getSelectedTasks())??[]}setSelectedTasks(t){var e;null==(e=this.selectionManager)||e.setSelectedTasks(t)}clearSelection(){var t;null==(t=this.selectionManager)||t.clearSelection()}zoomIn(){this.zoomManager.zoomIn()}zoomOut(){this.zoomManager.zoomOut()}normalizeDimension(t){return"number"==typeof t?`${t}px`:t}setupContainerResizeObserver(){if(!this.element)return;this.containerResizeObserver&&this.containerResizeObserver.disconnect();const t=this.normalizeDimension(this.options.width),e=this.normalizeDimension(this.options.height),n="string"==typeof t&&t.includes("%"),i="string"==typeof e&&e.includes("%");(n||i)&&(this.lastKnownWidth=this.element.offsetWidth,this.lastKnownHeight=this.element.offsetHeight,this.containerResizeObserver=new ResizeObserver((t=>{for(const e of t){const t=e.contentRect.width,n=e.contentRect.height,i=Math.abs(t-this.lastKnownWidth)>1,o=Math.abs(n-this.lastKnownHeight)>1;(i||o)&&(this.lastKnownWidth=t,this.lastKnownHeight=n,this.handleContainerResize())}})),this.containerResizeObserver.observe(this.element))}handleContainerResize(){null!==this.resizeDebounceTimer&&window.clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout((()=>{this.performResize(),this.resizeDebounceTimer=null}),150)}performResize(){if(!this.element||this.isDestroyed())return;const t=this.normalizeDimension(this.options.width),e=this.normalizeDimension(this.options.height),n="string"==typeof t&&t.includes("%"),i="string"==typeof e&&e.includes("%");if(n){window.getComputedStyle(this.element.parentElement||this.element).width!==window.getComputedStyle(this.element).width&&requestAnimationFrame((()=>{this.scrollManager.positionHorizontalScrollbar(),this.scrollManager.updateHorizontalScrollbarContent(),this.layoutManager.syncTasksColumnWidths()}))}i&&requestAnimationFrame((()=>{this.layoutManager.fillEmptyRowsAfterRender()}))}destroy(){var t,e;this._destroyed=!0;try{this.virtualScrollCoordinator&&(this.virtualScrollCoordinator.destroy(),this.virtualScrollCoordinator=null),this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),null!==this.resizeDebounceTimer&&(window.clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null),this.cancelPendingAfterActionsRaf(),this.zoomManager.cleanup(),this.scrollManager.cleanup(),null==(t=this.keyboardNavigationManager)||t.detach(),null==(e=this.selectionManager)||e.destroy(),this.reducedMotionMQL&&this.reducedMotionHandler&&(this.reducedMotionMQL.removeEventListener("change",this.reducedMotionHandler),this.reducedMotionMQL=null,this.reducedMotionHandler=null),this.cleanupEventListeners(),this.cleanupTooltips(),this.cleanupDependencyArrows(),this.element.innerHTML="",this.clearDomCache(),super.destroy()}catch(t){R.error("Error during ApexGantt destruction:",t)}}isDestroyed(){return this._destroyed||!this.element}}const ye={tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#CCCCCC",tooltipTextColor:"#333333",cellBorderColor:"#E3EDF8",rowBackgroundColors:["#FFFFFF","#F5F9FF"],headerBackground:"#EBF3FB",headerTextColor:"#333333",barBackgroundColor:"#318CE7",barTextColor:"#FFFFFF",arrowColor:"#1A6FC4",backgroundColor:"#FFFFFF",textColor:"#000000",borderColor:"#DFE0E1",annotationBgColor:"#DBEAFE",annotationBorderColor:"#60A5FA",dialogBgColor:"#FFFFFF",dialogBorderColor:"#EEEEEE",buttonBgColor:"#318CE7",buttonTextColor:"#FFFFFF",buttonHoverBgColor:"#1A6FC4",toolbarBgColor:"#FFFFFF",toolbarBorderColor:"#BCBCBC",toolbarHoverBgColor:"#F0F7FF",scrollbarTrackColor:"#F5F5F5",scrollbarThumbColor:"#C1C1C1",scrollbarThumbHoverColor:"#A8A8A8",splitBarColor:"#DEE2E6",splitBarHoverColor:"#318CE7",splitBarBorderColor:"#BBBBBB",splitBarHandleColor:"#666666"},ve={tooltipBGColor:"#2D2D2D",tooltipBorderColor:"#444444",tooltipTextColor:"#E0E0E0",cellBorderColor:"#3A3A3A",rowBackgroundColors:["#1E1E1E","#252525"],headerBackground:"#2A2A2A",headerTextColor:"#E0E0E0",barBackgroundColor:"#818CF8",barTextColor:"#FFFFFF",arrowColor:"#A5B4FC",backgroundColor:"#1E1E1E",textColor:"#E0E0E0",borderColor:"#3A3A3A",annotationBgColor:"#4A2D4D",annotationBorderColor:"#8B4D8F",dialogBgColor:"#2D2D2D",dialogBorderColor:"#444444",buttonBgColor:"#6366F1",buttonTextColor:"#FFFFFF",buttonHoverBgColor:"#4F46E5",toolbarBgColor:"#2D2D2D",toolbarBorderColor:"#444444",toolbarHoverBgColor:"#3A3A3A",scrollbarTrackColor:"#000",scrollbarThumbColor:"#4A4A4A",scrollbarThumbHoverColor:"#5A5A5A",splitBarColor:"#3A3A3A",splitBarHoverColor:"#818CF8",splitBarBorderColor:"#4A4A4A",splitBarHandleColor:"#666666"};function we(t){return"dark"===t?ve:ye}"undefined"!=typeof window&&(window.ApexGantt=fe);export{fe as ApexGantt,tt as ColumnKey,nt as ColumnList,ve as DarkTheme,Nt as DataParser,K as GanttEvents,ye as LightTheme,O as Orientation,ct as TaskType,P as ViewMode,fe as default,we as getTheme};
|